<div dir="ltr"><div class="gmail_extra">Hi Leonard</div><div class="gmail_extra"><br></div><div class="gmail_extra">thanks !<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite"><pre>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>
    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.</div></blockquote><div><br></div><div>I believe you are referring to the initialize() function in a script node ? Using this had occurred to me but I was not sure if there is a solution without using a script. It looks there may be not.</div><div><br></div><div>I  could not get a looping timesensor such as</div><div><br></div><div><TimeSensor DEF='delayedclock' startTime='5s_from_loadTime' cycleInterval='30s'  loop='true' /> </div><div><br></div><div>with the actual startTime set via Javascript to work and I assumed it was due to how the spec. prescribes that a timesensor is supposed to ignore resetting of startTime after becoming active, and loop='true' activates the sensor as quickly as possible. So ignoring the delay started to make sense but you seem to suggest that a timesensor like above should work ?</div><div><br></div><div>What worked but seemed overly complicated was:</div><div><br></div><div><div><TimeSensor def='slowclock' enabled='false' cycleInterval='32' loop='true' /></div></div><div><div><TimeSensor def='slowclocktrigger' startTime='5s_from_loadTime' cycleInterval='1000' loop='false' /></div><div><ROUTE fromNode='slowclocktrigger' fromField='isActive' toNode='slowclock' toField='enabled' /></div></div><div>with the actual startTime set via Javascript.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    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></div></blockquote><div><br></div><div>I believe there is probably a regular, non-JQuery DOM equivalent as well. And x3dom provides x3dom.runtime.ready().</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    If you are creating a 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></div></blockquote><div><br></div><div>Using x3dom.runtime.ready() should guarantee that the scene's nodes and attributes are available to the script if requested,</div><div><br></div><div>I see, a short cycleInterval should get you the time close to the load time of the scene without a script node.</div><div><br></div><div>A way to get a 5s delay without a script may be:</div><div><br></div><div><TimeSensor def='delay' startTime='1' stopTime='0' cycleInterval='5' /></div><div><div><TimeSensor def='slowclock' enabled='false' cycleInterval='32' loop='true' /></div><div></div></div><div><BooleanFilter def='invert' /></div><div><ROUTE fromNode='delay' fromField='isActive' toNode='invert' toField='set_boolean' /></div><div><ROUTE fromNode='invert' fromField='inputNegate' toNode='slowclock' toField='enabled' /></div><div><br></div><div>Just trying out more declarative ways of programming to compare to the imperative approach which does seem more concise.</div><div><br></div><div>Andreas</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class=""><font color="#888888">
    <div>-- <br>
      <font 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>
  </font></span></div>

<br>------------------------------------------------------------------------------<br>
<br>_______________________________________________<br>
X3dom-users mailing list<br>
<a href="mailto:X3dom-users@lists.sourceforge.net">X3dom-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/x3dom-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/x3dom-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Andreas Plesch<br>39 Barbara Rd.<br>Waltham, MA 02453</div>
</div></div>