Hagop

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.

Share this post


Link to post
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.

http://playground.babylonjs.com/#1VNAYW#77

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!

Share this post


Link to post
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.

Share this post


Link to post
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.

http://playground.babylonjs.com/#1VNAYW#82

DB

Share this post


Link to post
Share on other sites

OK - I had the mesh.position returning the correct position for the sphere working in the console, and now it does not. Any one have any thoughts as to why this is inconsistant?

DB

Share this post


Link to post
Share on other sites

Delete does not seem to work, because  if after deleting physics if I parent the mesh  to the camera and position it (after parenting the position of the mesh is relative to the camera), mesh makes a small jump.

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.