Jump to content

Where should I be putting my animation code in complex scene?


fateriddle
 Share

Recommended Posts

I notice we have a 

    scene.registerBeforeRender(function() {

    })

function for inserting your animations. In a complex scene, where

1. everything start from a trigger action

2. they play in sequence, and the next one started when the first one play to a certain frame

3. more animations needs to be waiting for another trigger

4. some needs to play after assets loaded, and some assets will be loaded after trigger action 

should I be putting all the animation inside registerBeforeRender ? Is it even possible? I find my animation code everywhere, what is the best practice?

Link to comment
Share on other sites

Hi @fateriddle and welcome from me. There are two main ways of achieving animation in BJS. One uses 

9 hours ago, fateriddle said:

scene.registerBeforeRender(function() { })

in this case you can change properties of BJS objects such as position, rotation etc.

Another way is to use animatables https://doc.babylonjs.com/features/animations

From your description it seems you are using animatables which do not go inside the registerBeforeRender loop.

Link to comment
Share on other sites

Thanks, @JohnK  btw, should I create all the mesh needed and set the unused ones to invisible till later, or should I create things out on the fly? How do I do it in later case?
It seems to me that I can only animate properties, so I can't just meshBuilder a mesh at the end of an animation?

Link to comment
Share on other sites

5 hours ago, fateriddle said:

I can't just meshBuilder a mesh at the end of an animation?

You could always use the onAnimationEnd parameter from scene.beginAnimation to create a mesh and start a new animation. When there are more than one way of doing something sometimes you just have to try them with a simplified example. I am not clear enough on what you are trying to achieve with your animation to have an opinion, sorry ?

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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