Jump to content

How to create a hollow box (open from top side)


Hagop
 Share

Recommended Posts

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 be

box .setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:0, friction:0.5, restitution: 0.4});

 

The items dropped into the box will use physics

items.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, { mass: 1  });

 

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;

});
                 

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