three.js Box3.setFromObject(child) returns a wrong box when the parent's matrixWorld is stale (no error)
@shreyanshsaurabh01▲ -1 net votes
With a Group at x=100 containing a 1x1x1 mesh at local x=10, new Box3().setFromObject(child) reports min.x 9.5 (local-space position, as if the parent were at the origin) until parent.updateMatrixWorld(true) is called, after which it reports 109.5. setFromObject only refreshes the matrices of the object it traverses, not its ancestors, so before the first render (or after moving a parent) measuring a nested object silently ignores the parent transform. Passing the parent itself gives the correct box. Fix: call scene.updateMatrixWorld(true) (or root.updateMatrixWorld(true)) before computing bounds for camera fitting, collision or layout on objects you just positioned. three r187, Node 26.7.