<div dir="ltr">Switch JavaScript versions in FreeWRL found the issue. deleteRoute takes 1 parameter.<div><br></div><div>This script works in Sunrize and FreeWRL:</div><div><br></div><div> <Script DEF="Script21"><br> <field name="inTime" type="SFTime" accessType="inputOnly"/><br> <field name="fraction" type="SFFloat" accessType="inputOutput" value="0"/><br> <field name="diffuseColor" type="SFColor" accessType="inputOutput" value="0 0 1"/><br> <field name="checked" type="SFBool" accessType="inputOutput" value="false"/><br> <![CDATA[ecmascript:<br> var route = null;<br> function inTime(value) {<br> // Browser.print("in", diffuseColor.g, diffuseColor.b);<br> if (value) {<br> checked = !checked;<br> }<br> scene = Browser.currentScene;<br> if (checked) {<br> route = scene.addRoute(scene.getNamedNode("Main_Clock"), 'fraction_changed', scene.getNamedNode("AnimationAdapter_JinMouthStretch"), 'set_fraction');<br><br> diffuseColor.g = 1;<br> diffuseColor.b = 0;<br> fraction = 0;<br> } else {<br> if (route != null) {<br> scene.deleteRoute(route);<br>// scene.deleteRoute(scene.getNamedNode("Main_Clock"), 'fraction_changed', scene.getNamedNode("AnimationAdapter_JinMouthStretch"), 'set_fraction');<br><br> }<br> diffuseColor.g = 1;<br> diffuseColor.g = 0;<br> diffuseColor.b = 1;<br> fraction = 0;<br> }<br> // Browser.print("out", diffuseColor.g, diffuseColor.b);<br> }<br> ]]><br> </Script></div><div><br></div><div>Question: I'm guessing one can't have X3DRoutes as field types, and I have to use a global Script variable? I'm hoping this isn't global in all Scripts. If it is, I will probably implement a PROTO.</div><div><br></div><div><br></div><div>Thanks.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Dec 9, 2024 at 11:33 AM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Apparently there was some kind of caching issue with Sunrize, when I used npx sunrize@latest, everything was perfect.<div><br></div><div>deleteRoute does not work in FreeWRL, and has been reported to Doug.</div><div><br></div><div>Thanks,</div><div><br></div><div>John</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 9, 2024 at 11:24 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> Can someone confirm if this script looks like valid SAI?<div><br></div><div>The scene was working great until I added addRoute/deleteRoute.</div><div><br></div><div>Thanks!</div><div><br></div><div>John</div><div><br></div><div> <Script DEF="Script21"><br> <field name="inTime" type="SFTime" accessType="inputOnly"/><br> <field name="fraction" type="SFFloat" accessType="inputOutput" value="0"/><br> <field name="diffuseColor" type="SFColor" accessType="inputOutput" value="0 0 1"/><br> <field name="checked" type="SFBool" accessType="inputOutput" value="false"/><br> <![CDATA[ecmascript:<br> function inTime(value) {<br> // Browser.print("in", diffuseColor.g, diffuseColor.b);<br> if (value) {<br> checked = !checked;<br> }<br> scene = Browser.currentScene;<br> if (checked) {<br> scene.addRoute(scene.getNamedNode("Main_Clock"), 'fraction_changed', scene.getNamedNode("AnimationAdapter_JinMouthStretch"), 'set_fraction');<br><br> diffuseColor.g = 1;<br> diffuseColor.b = 0;<br> fraction = 0;<br> } else {<br> scene.deleteRoute(scene.getNamedNode("Main_Clock"), 'fraction_changed', scene.getNamedNode("AnimationAdapter_JinMouthStretch"), 'set_fraction');<br><br> diffuseColor.g = 1;<br> diffuseColor.g = 0;<br> diffuseColor.b = 1;<br> fraction = 0;<br> }<br> // Browser.print("out", diffuseColor.g, diffuseColor.b);<br> }<br> ]]><br> </Script></div></div>
</blockquote></div>
</blockquote></div>