[x3d-public] Having a bit of difficult ROUTEing to node outside the ProtoDeclare in Sunrize
John Carlson
yottzumm at gmail.com
Sat Feb 1 18:47:11 PST 2025
Apparently, I overthought this, and simpler answers overcame this.
John
On Fri, Jan 31, 2025 at 4:29 PM John Carlson <yottzumm at gmail.com> wrote:
> I'm having a bit of difficult ROUTEing to node outside the ProtoDeclare
> in Sunrize
> I get this error:
>
> Sunrize reports:
> XML Parser: Unknown named or imported node 'clock'.
>
> CGE model viewer reports:
>
> X3D: Route destination node name "clock" not found
>
> I don't really see what I am doing wrong yet.
>
> <TimeSensor DEF="JinBlink_Clock" cycleInterval="0.99" enabled="false"
> loop="true" />
> <ProtoDeclare name="MenuItem">
> <ProtoInterface>
> <field name="translation" accessType="inputOutput" type="SFVec3f"/>
> <field name="textTranslation" accessType="inputOutput"
> type="SFVec3f"/>
> <field name="description" accessType="inputOutput"
> type="SFString"/>
> <field name="menuItemString" accessType="inputOutput"
> type="MFString"/>
> <field name="adapters" accessType="inputOutput" type="MFNode"/>
> <field name="clock" accessType="inputOutput" type="SFNode"/>
> <field name="size" accessType="initializeOnly" type="SFVec2f"
> value="40.0 3.0"/>
> <field name="fontSize" accessType="inputOutput" type="SFFloat"
> value="2.4"/>
> <field name="spacing" accessType="initializeOnly" type="SFFloat"
> value="1.2"/>
> </ProtoInterface>
> <ProtoBody>
> <Group>
> <!--
> <TimeSensor DEF="Main_Clock" cycleInterval="0.99" loop="true"
> enabled="true"/>
> -->
>
> <Transform>
> <IS>
> <connect nodeField="translation" protoField="translation"/>
> </IS>
> <TouchSensor DEF="StartStopAnimationUnit_Sensor">
> <IS>
> <connect nodeField="description" protoField="description"/>
> </IS>
> </TouchSensor>
> <Transform translation="0 0 0">
> <IS>
> <connect nodeField="translation"
> protoField="textTranslation"/>
> </IS>
> <Shape>
> <Appearance>
> <Material diffuseColor="1 1 1"/>
> </Appearance>
> <Text>
> <IS>
> <connect nodeField="string"
> protoField="menuItemString"/>
> </IS>
> <FontStyle justify='"MIDDLE" "MIDDLE"'>
> <IS>
> <connect nodeField="size" protoField="fontSize"/>
> <connect nodeField="spacing" protoField="spacing"/>
> </IS>
> </FontStyle>
> </Text>
> </Shape>
> </Transform>
> <Transform translation="0 0 -0.01">
> <Shape>
> <Appearance>
> <Material DEF="MenuBackground_Material" diffuseColor="0 0
> 1"/>
> </Appearance>
> <Rectangle2D size="40.0 3.0">
> <IS>
> <connect nodeField="size" protoField="size"/>
> </IS>
> </Rectangle2D>
> </Shape>
> </Transform>
> </Transform>
> <Script DEF="ScriptToggle">
> <field name="inTime" type="SFTime" accessType="inputOnly"/>
> <field name="fraction" type="SFFloat" accessType="inputOutput"
> value="0"/>
> <field name="diffuseColor" type="SFColor" accessType="inputOutput"
> value="0 0 1"/>
> <field name="checked" type="SFBool" accessType="inputOutput"
> value="false"/>
> <field name="adapters" type="MFNode" accessType="inputOutput"/>
> <![CDATA[ecmascript:
> function inTime(value) {
> if (value) {
> checked = !checked;
> }
> scene = Browser.currentScene;
> var num_adapters = adapters.length;
> Browser.print("in", checked, num_adapters, diffuseColor.g,
> diffuseColor.b);
> for (var adapter = 0; adapter < num_adapters; adapter++) {
> Browser.print("adapter", adapter,
> adapters[adapter].metadata)
> }
> if (checked) {
> for (var adapter = 0; adapter < num_adapters; adapter++) {
> adapters[adapter].set_fraction = 0;
> }
> diffuseColor.g = 1;
> diffuseColor.b = 0;
> } else {
> for (var adapter = 0; adapter < num_adapters; adapter++) {
> adapters[adapter].set_fraction = 0;
> }
> diffuseColor.g = 0;
> diffuseColor.b = 1;
> }
>
> }
> ]]>
> <IS>
> <connect nodeField="adapters" protoField="adapters"/>
> </IS>
> </Script>
> <ROUTE fromNode="StartStopAnimationUnit_Sensor"
> fromField="touchTime" toNode="ScriptToggle" toField="inTime"/>
> <ROUTE fromNode="MenuBackground_Material" fromField="diffuseColor"
> toNode="ScriptToggle" toField="diffuseColor"/>
> <ROUTE fromNode="ScriptToggle" fromField="diffuseColor"
> toNode="MenuBackground_Material" toField="diffuseColor" />
> <ROUTE fromNode="StartStopAnimationUnit_Sensor"
> fromField="touchTime" toNode="clock" toField="startTime"/>
> '
> </Group>
> </ProtoBody>
> </ProtoDeclare>
> <ProtoInstance name="MenuItem">
> <fieldValue name="translation" value="24 63.4 0"/>
> <fieldValue name="textTranslation" value="0 0 0"/>
> <fieldValue name="description" value="Jin Blink"/>
> <fieldValue name="menuItemString" value='"JinBlink"'/>
> <fieldValue name="size" value="40.0 3.0"/>
> <fieldValue name="fontSize" value="2.4"/>
> <fieldValue name="spacing" value="1.2"/>
> <fieldValue name="clock">
> <TimeSensor USE="JinBlink_Clock"/>
> </fieldValue>
> <fieldValue name="adapters">
> <ScalarInterpolator USE="AnimationAdapter_JinBlink"/>
> </fieldValue>
> </ProtoInstance>
> <ROUTE fromNode="JinBlink_Clock" fromField="fraction_changed"
> toNode="AnimationAdapter_JinBlink" toField="set_fraction"/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20250201/f2910307/attachment.html>
More information about the x3d-public
mailing list