Hagop Posted January 5, 2016 Share Posted January 5, 2016 Hi all I want to create a box (or a mesh) which should be open from top side. I will use it to drop items into it using a physics engine such as cannon.js For example the physics applied to the box will bebox .setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:0, friction:0.5, restitution: 0.4}); The items dropped into the box will use physicsitems.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, { mass: 1 }); Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 5, 2016 Share Posted January 5, 2016 Hi,You could create the box using CSG - put a smaller box in a bigger box and subtract.About physics - box impostor won't work, as it won't know of the open end. You could use a height map impostor (if the box's width == depth) or the mesh impostor , if you want to deal with spheres only (inside the open box) Quote Link to comment Share on other sites More sharing options...
Hagop Posted January 5, 2016 Author Share Posted January 5, 2016 Thank you RannanW for the prompt answer. Basically I have a shopping cart and I want to drop products in the shopping cart. Because of the shopping carts' complexity, it takes ages for the physics engine to calculate the Mesh impostor. So I thought to place a rectangular box (open from top side) within the shopping cart and make it invisible. Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 5, 2016 Share Posted January 5, 2016 Just build "walls" (can be invisible) and use the box impostor on them. This will work wonderfully. Same thing is done in the physcis example on babylonjs.com - http://www.babylonjs.com/Demos/Physics/ Quote Link to comment Share on other sites More sharing options...
Hagop Posted January 5, 2016 Author Share Posted January 5, 2016 I thought so. By walls, i guess you mean planes right? Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 5, 2016 Share Posted January 5, 2016 Box impostors would be much better. In Babylon they can be planes, but use the mesh impostors, as they are double sides and limited in size. the plane impostor (at least in cannon.js) is a one-sided unlimited plane (to simulate an endless floor). Quote Link to comment Share on other sites More sharing options...
Hagop Posted January 5, 2016 Author Share Posted January 5, 2016 RaananW, one more question.After applying setPhysicsState to my shopping cart (or the "walls" in the shopping cart), the shopping cart does not move with the camera.globalCart.setPhysicsState(BABYLON.PhysicsEngine.PlaneImpostor, {mass:0, friction:0.5, restitution: 0.4}); I have something like this scene.registerBeforeRender(function () { currPosition = scene.activeCamera.position.clone(); globalCart.position.z = currPosition.z + 220;}); Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 5, 2016 Share Posted January 5, 2016 After changing the position, update the mesh's physics state using globalCart.updatePhysicsBodyPosition() This will update the ... Physics body position :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.