I’m trying to stack objects on top of each other. I was using OBB, but sometimes the stacked object would float. Is there a way to use buffergeometry information so that the objects will stack perfectly on top of other objects?
Obb would be ideal for this, remember to update your bounding boxes and object matrices, otherwise you could calculate an absolute height of each object from its bounding box and use each one additively.
Thanks for the response. I’m using OBB right now but running into the issue where the stacked object will float on the OBB of the couch (screenshot included) because of the varying heights of the couch.
OK, is the couch a model you are loading? If so you could iterate through each child mesh using
traverse() on load to create an obb per mesh, or, if you are looking at rapid intersections look at @gkjohnson 's Mesh bvh library
Excuse my poor drawing. Yes, I’m loading the couch model into my scene and creating a OBB around the mesh on load which looks like the drawing below. However, if I try placing an object on the seat of the couch (since it is a lower height than the back rest), the object floats. The center of the couch is at the origin center of mass. I’m wondering if there is any values from raycasting that I could use so that the object sitting on top of the OBB won’t float.
Is the floating object in this illustration? I can’t see a floating object. You will need to create a bounding box for each individual part of the imported model
If the mesh is one unbroken surface, consider calculating a bvh tree as suggested previously.
Ah got it, yes the mesh is one piece so calculating a bounding box for each part would be troublesome. Thank you for the bvh tree suggestion… will try that out!
OK. Any intersected point on the model from a ray would also provide an absolute position to snap an object to, it’s difficult to tell your use case from the information provided