[x3d-public] [x3dom-users] delay before animation
web3d at realism.com
Fri Sep 25 20:54:04 PDT 2015
On 9/25/2015 5:52 PM, Andreas Plesch wrote:
> I would like to automatically start a cyclic animation but after some initial delay (say 5s). My first approach was to use a looping timesensor with a startTime. However, setting a startTime on a looping timesensor turns out to be ignored since looping automatically activates the timesensor right after it is loaded (added to the scenegraph?). And active timesensors ignore attempts to set the startTime.
The StartTime field accepts any SFTime value. If the StartTime is in the
past, the TimeSensor starts immediately. (If StopTime is also in the
past, it may stop immediately too.) StartTime is the number of seconds
since 1970-01-01 00:00:00 on the local computer.
I don't have an example right here, but I have used a TimeSensor that
starts a few seconds into the scene. There is a Script node methods that
runs just prior to the scene being displayed. That is useful for
grabbing the current time to use for your deltas.
All events when presented to a Script function are really two
parameters. The first being the event data (SFVec3F or whatever) and the
second being the timestamp. The event model in X3D has all events in a
cascade happening at the same time. That is not the case in HTML. If the
initial delay is not critical, you can use the jQuery document.ready
function and grab the time from their to feed into the TimeSensor.
If you are creating an X3DOM-only scene, I suggest to not use X3D's
the bottom of the HTML file so it only runs after the stuff above gets
queued for loading. It may work to create a TimeSensor with startTime >
the last value of 'time' to be the base time for your calculation.
> My second approach was then to disable the looping timesensor and use a second nonlooping timesensor with a setable startTime to enable it. This works by routing the isActive event issued by the second sensor after startTime has arrived to the enable field of the looping sensor. While this approach works in principle, it seems rather convoluted. Is there a better, third approach ?
> How would it be best done in x3d ? Is there a sensor which produces a time event when the scene starts ? Use bindTime for the background node ? Is there a way to avoid a script ?
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the x3d-public