[x3d-public] Turning on and off simultaneous animations individually
John Carlson
yottzumm at gmail.com
Sat Dec 7 14:08:44 PST 2024
Here’s something for me to try. It hadn’t occurred to me to use a Script
to toggle a Switch, very interesting.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD
X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd"> <X3D profile
='Immersive' version='3.3'> <Scene> <Switch whichChoice='0' DEF='
NavigationSwitch'> <Transform DEF='Option1'> <Shape> <Appearance> <Material
diffuseColor='1 0 0'/> </Appearance> <Box size='1 1 1'/> </Shape> <
TimeSensor DEF='RedTimer' cycleInterval='2' loop='true'/> <ColorInterpolator
DEF='RedColorChanger' key='0 0.5 1' keyValue='1 0 0, 0.8 0 0, 1 0 0'/> <
ROUTE fromNode='RedTimer' fromField='fraction_changed' toNode='
RedColorChanger' toField='set_fraction'/> </Transform> <Transform DEF='
Option2'> <Shape> <Appearance> <Material diffuseColor='0 1 0'/> </Appearance
> <Sphere radius='1'/> </Shape> <TimeSensor DEF='GreenTimer' cycleInterval='
3' loop='true'/> <ColorInterpolator DEF='GreenColorChanger' key='0 0.5 1'
keyValue='0 1 0, 0 0.8 0, 0 1 0'/> <ROUTE fromNode='GreenTimer' fromField='
fraction_changed' toNode='GreenColorChanger' toField='set_fraction'/> </
Transform> </Switch> <!-- Script to switch between options --> <Script DEF='
SwitchController'> <field name='currentChoice' type='SFInt32' accessType='
inputOutput' value='0'/> <field name='toggle' type='SFBool' accessType='
inputOutput' value='false'/> <body><![CDATA[ function toggle(value) {
currentChoice
= 1 - currentChoice; return currentChoice; } ]]></body> </Script> <
TimeTrigger DEF='SwitchTrigger'/> <ROUTE fromNode='SwitchTrigger' fromField=
'triggerTime' toNode='SwitchController' toField='toggle'/> <ROUTE fromNode='
SwitchController' fromField='currentChoice' toNode='NavigationSwitch'
toField='whichChoice'/> </Scene> </X3D>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241207/1f4e8c83/attachment-0001.html>
More information about the x3d-public
mailing list