Switching/Loading Scene Causes Mesh Jumping

Recommended Posts

Language: TypeScript

Physics Engine: CannonJS


Hey all,

I would appreciate it if someone would help me solve these 2 mesh physics problems that I feel are related. I spent a lot of time trying to solve these related issues on my own and could not figure out what was going wrong.


RELEVANT NOTE: BOTH problems occur right after switching from 1 scene to another scene. They only happen right after a scene loads. I have a video that demonstrates the error below.

Problem 1:

After loading each mesh (each with its own physics impostor), each mesh jumps a little (and then afterwards, they start falling because of gravity). I was wondering why/how to prevent it from happening.

Note: I suspected that it is because they load too close to the ground and bounce because the computer erroneously thinks that the meshes/ground are touching. I am able to lessen the jump by making the ground’s position.y = -0.5 (so it is even clearer to the computer that the objects are not touching because all objects right now load at position.y = 0 (and I move objects before the next object loads so they don't intersect and start a collision)), but the jump still occurs, just less of a jump and still noticeable.


Problem 2:

After loading a certain scene, after being loaded, each instance of a special object I created (a class I created that includes a mesh) jumps in opposite directions from each other. I’m not sure why. I have a feeling it has to do with having multiple instances of the same class, each with their own mesh. After the scene loads, I am able to individually access each mesh and have them move individually, so their movement isn’t intertwined.


Code/Video in Link:

Relevant code and 1 video demonstrating error are in the Dropbox link.

Note: The video shows both errors happening at the same time.

Note: The code in this folder are not in the same directory/folder structure that I normally use for this program (so that is not the cause of my issues)


Thank you to all who read/and might help me with this issue!


Share this post

Link to post
Share on other sites

Hi Deltakosh!

Thanks for responding! I'm having trouble translating my project for the playground. How do I translate the following code into something that the playground can read? I use the following code to delete the current scene and load a new one.

this._scene = null; //Is this line needed to make .dispose() work so the garbage collection automatically clears the previous scene?

(Different if statements in the createScene creates different scenes.)

Thanks for the help!




Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.