InstancedMesh/SkinnedMesh and computeBoundingBox().
See original GitHub issueGeometry bounding box gives a somewhat misleading result when used in an InstancedMesh.
var count = 10000;
var mesh = new THREE.InstancedMesh( geometry, material, count );
var dummy = new THREE.Object3D();
for ( var i = 0; i < count; i ++ ) {
dummy.position.set(
Math.random() * 20 - 10,
Math.random() * 20 - 10,
Math.random() * 20 - 10
);
dummy.updateMatrix();
mesh.setMatrixAt( i, dummy.matrix );
}
Using new Box3().setFromObject(mesh) only gives you the Box3 for the single geometry, and not for the whole instance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
BufferGeometry#computeBoundingBox – three.js docs
BufferGeometry. A representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colors, UVs, and custom attributes ...
Read more >When should I call Geometry.computeBoundingBox() etc?
I always call the required compute methods just after I ended adding vertices, faces, etc and before creating the mesh with the geometry:...
Read more >Compute bounding box — Axom documentation
The BoundingBox class represents an axis-aligned bounding box, which has two walls perpendicular to the X-axis, two perpendicular to the Y-axis, and two ......
Read more >`compute bounding box` C++ Examples - ProgramCreek.com
const AABB& Submesh::computeBoundingBox() { Vec3f maxPos(std::numeric_limits<float>::lowest()); Vec3f minPos(std::numeric_limits<float>::max()); ...
Read more >OpenSceneGraph: osg::Drawable Class Reference
Compute the bounding sphere around Drawables's geometry. More... virtual BoundingBox · computeBoundingBox () const. Compute the bounding box around Drawables's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
SkinnedMesh
case is a less visible glitch. But yes, we should solve this at some point.I agree – there are cases even with just a mesh where being able to specify the bounding volume per-object rather than per-geometry would be beneficial. Materials can change the apparent bounds of geometry, as well, with custom vertex shaders, instancing, and displacement maps (which I also think don’t work correctly at the moment).
I still think it’s valuable to store the bounding volume on the geometry, though, to share the volume instances. Maybe the responsibility of checking for frustum intersection should shift to the objects? Should the Mesh class define an
intersectsFrustum
function that can be implemented by derivative classes? I think this would help with the problems mentioned here. Here’s a simple example:This would allow a bounding box to optionally be set on the Mesh to account for cases where the material changes the visual bounds of the shape. Of course raycasting would also have to be updated to support custom intersections if desired but that’s already override-able.