Jump to content

How to remove an impostor from a mesh?


Recommended Posts

Hi all

I am using Cannon engine and applying physics to a mesh using either of the commands.

  1. currentMesh.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, { mass: 8  });
  2. currentMesh.physicsImpostor = new BABYLON.PhysicsImpostor(currentMesh, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 8, restitution: 0.9 }, scene);

The mesh drops and restitues successfulyy on another mesh which has Plane impostor and mass = 0.

After dropping I want to remove the impostor of the dropped mesh so that the mesh behaves like a "normal" mesh. The reason for doing that is that I want to parent the mesh to the free camera of the scene, because I want the mesh to rotate smoothly with the camera. I could not parent the physics mesh to the free camera.

Then there is another question. The currentMesh.position returns the coordinates of the it's position before being dropped even if I evaluate it after being dropped.

Link to comment
Share on other sites

Hi Hagop!  Sorry for the slow replies.  Have you done any experiments with currentMesh.physicsImpostor = BABYLON.PhysicsEngine.NoImpostor()  ?

How about... delete currentMesh.physicsImpostor  ?  I think that will work.

Here's a PG with various experiments... tested at 5 seconds and 10 seconds after drop.


I really wanted to see sphere.position === camera.position after the parenting, but I couldn't get that to happen. 

Sphere parenting to camera IS working, though, as best I can tell.

Holler back as wanted/needed, or to teach us things you discover.  Thanks!

Link to comment
Share on other sites

34 minutes ago, dbawel said:

Either way, I believe you have your answers.

thx db.  Too bad he had to wait 3 days.  That's just embarrassing.  I stop working the dailies for a week, and a 3-day-old 0-reply drops through the grates.  How many forum helpers here?  40?  Sad.

Link to comment
Share on other sites

@Hagop -

When I use .position it returns the correct x,y,z position. I wrote these values to the console in the PG script below. And I am as embarrassed as @Wingnut is that you didn't recieve an answer to such a simple question sooner. I was also off the grid for a time. I hope you either figured it out yourself, or will come back for the answers.



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