[x3d-public] Turning on and off simultaneous animations individually
Holger Seelig
holger.seelig at yahoo.de
Sat Dec 7 14:17:20 PST 2024
When I want to activate/deactivate something is a Switch when it becomes visible or hidden, I like to use VisiblitySensor or ProximitySensor nodes. Put a sensor node in every branch of the Switch. They send a *isActive* event (SFBool) and *enterTime*, *exitTime* (SFTime). I guess that’s exactly what you are looking for.
Best regards,
Holger
--
Holger Seelig
Leipzig, Germany
holger.seelig at yahoo.de
https://create3000.github.io/x_ite/
> Am 07.12.2024 um 23:08 schrieb John Carlson via x3d-public <x3d-public at web3d.org>:
>
> 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>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241207/d9a94c63/attachment-0001.html>
More information about the x3d-public
mailing list