javascript - x3d TimeSensor pause and resume on click -
i have cute solar system implemented in x3d, , thing i've been trying couple hours stop rotation of planet on single click mouse, "works" :
<timesensor def='clocksol' id='clocksol' cycleinterval='80' loop='true' enabled='true' /> ... <orientationinterpolator def='interrotacion' key='0 0.25 0.5 0.75 1' keyvalue='0 1 0 0 0 1 0 1.57079 0 1 0 3.14159 0 1 0 4.71239 0 1 0 6.28317'/> ... <route fromnode='clocksol' fromfield='fraction_changed' tonode='interrotacion' tofield='set_fraction'></route> <route fromnode='interrotacion' fromfield='value_changed' tonode='rotacionsol' tofield='set_rotation'></route> *............*
that's implementation of sun animation.
the click event follows:
document.getelementbyid('sol').addeventlistener('click', function() { if(document.getelementbyid('clocksol').getattribute('enabled') == 'true' ) document.getelementbyid('clocksol').setattribute('enabled', 'false'); else document.getelementbyid('clocksol').setattribute('enabled', 'true'); }, false);
this stops animation disables node, when resumen animation, cycle internally doesn't seem have stopped. effect when click again, , resume animation, object blinks new position instead of resuming rotation smoothly should be.
any ideas how it?
the 'enable' field stops timesensor sending time events, not 'stop' or 'pause' sensor. want send current time (available 'time' field or other locations) pausetime field. freeze timesensor @ it's current state. resume send current time resumetime.
see full definition of timesensor @ http://www.web3d.org/documents/specifications/19775-1/v3.2/part01/components/time.html#timesensor
Comments
Post a Comment