You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just as the issue title indicated, I create an InstancedMesh with more than one instances at different positions, but it's just the Box3 result of the Geometry attached to it. After reading the code, I have made a fix.
var_box=newTHREE.Box3();var_vector=newTHREE.Vector3();THREE.Box3.prototype.expandByObject=function(object){// Computes the world-axis-aligned bounding box of an object (including its children),// accounting for both the object's, and children's, world transformsobject.updateWorldMatrix(false,false);vargeometry=object.geometry;if(geometry!==undefined){if(geometry.boundingBox===null){geometry.computeBoundingBox();}if(object.isInstancedMesh){varmatrixWorld=object.matrixWorld,matrix4Array=object.instanceMatrix.array,arrayLength=matrix4Array.length;for(varposOffset=12;posOffset<arrayLength;posOffset+=16){_vector.set(matrix4Array[posOffset],matrix4Array[1+posOffset],matrix4Array[2+posOffset]);_box.expandByPoint(_vector);}}else{_box.copy(geometry.boundingBox);}_box.applyMatrix4(object.matrixWorld);this.expandByPoint(_box.min);this.expandByPoint(_box.max);}varchildren=object.children;for(vari=0,l=children.length;i<l;i++){this.expandByObject(children[i]);}returnthis;}
@Fang3s A huge thank you to providing this code. InstancedMeshes are cumbersome to work with and miss a lot of the practical methods and abilities of normal geometry - I hope that changes over time!
Description of the problem
Just as the issue title indicated, I create an InstancedMesh with more than one instances at different positions, but it's just the Box3 result of the Geometry attached to it. After reading the code, I have made a fix.
See also:
Please also include a live example if possible. You can start from these templates:
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
The text was updated successfully, but these errors were encountered: