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

x3dom: http://doc.x3dom.org/author/time/timesensor.html


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -