Jump to content

BJS Timeline / Timed sequence of actions


Recommended Posts

Looking for the best approach to create a simulated timeline of actions/events. For example, over a 2 minute timeline I would like to animate my camera around my scene on a curved path, and have numerous things happen at certain times in my timeline. I could create a timer/timeline object from scratch, but was wondering if there is a better BJS way of handling this. 

Imagine a camera navigating through a house, at 10 seconds in the door opens, at 15 seconds a light turns on, at 25 seconds a painting on the wall rotates and falls to the ground. 

Also looking for an approach to easily tweaks the timeline of events. 

Does this sound like something that should be handled within Unity or in code.

Interested in everyone's thoughts. Thanks! 

Link to comment
Share on other sites

off the top of my head...
var start = (new Date()).getTime();
action = function(name, time, callback){
this.name = name || "New-Event";
this.time = time;
this.callback = callback;
return this;
var events = [new action("Step-1", start+(1000*6), function(){...}),
new action("Step-2", start+(1000*10), function(){...}),

onbeforeRegister =>
for(var i=0; i<events.length;i++){
var cE = events;
var now = (new Date()).getTime();
if(cE.time < now){
 var cE = events.splice(i,1);

should get you in the right direction.

Link to comment
Share on other sites

@Luaacro I believe I am using the integrated animation events as in line 33.  If there is a better way of putting together a sequence of animations then I would be very grateful to learn how. The PG is just one I made from what I have learned so far. Any adjustments very welcome.

Link to comment
Share on other sites

Still learning  - in writing the documentation for the PG I gave in earlier post I came up with a simplified way of putting together animations which you can find written about here

http://babylonjsguide.github.io/gamelets/Sequence though you might also want to read this first http://babylonjsguide.github.io/basics/Starter

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...