<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 9/25/2015 5:52 PM, Andreas Plesch
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAKdk67v9JkzRWROeW1Xqr71wmsskSCjvyJ1Zoc16qV1tLTj=Gw@mail.gmail.com"
      type="cite">
      <pre wrap="">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.</pre>
    </blockquote>
    <br>
    <br>
    Andreas,<br>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    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.<br>
    <br>
    If you are creating an X3DOM-only scene, I suggest to not use X3D's
    Script node and grab the time from JavaScript. You can put that code
    at 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 > stopTime and a short cycleInterval. You can (in
    HTML's JavaScript) get the last value of 'time' to be the base time
    for your calculation.<br>
    <br>
    <br>
    Leonard Daly<br>
    <br>
    <br>
    <br>
    <blockquote
cite="mid:CAKdk67v9JkzRWROeW1Xqr71wmsskSCjvyJ1Zoc16qV1tLTj=Gw@mail.gmail.com"
      type="cite">
      <pre wrap="">

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 ?

Another issue is how to determine what the startTime is. In x3dom I can override the x3dom.runtime.ready function to get the current time with the JavaScript Date object and then add a delay to arrive at a startTime. (Why does x3dom not provide any of the timestamps such as touchtime or bindtime?)

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 ?

Andreas





</pre>
    </blockquote>
    <br>
    <br>
    <div class="moz-signature">-- <br>
      <font class="tahoma,arial,helvetica san serif" color="#333366">
        <font size="+1"><b>Leonard Daly</b></font><br>
        X3D Co-Chair<br>
        Cloud Consultant<br>
        President, Daly Realism - <i>Creating the Future</i>
      </font></div>
  </body>
</html>