simplify cache code
This commit is contained in:
parent
155d01db5b
commit
6921142949
1 changed files with 3 additions and 7 deletions
|
|
@ -384,18 +384,14 @@ let util = mesh.util = {
|
||||||
let matrix = object.matrixWorld;
|
let matrix = object.matrixWorld;
|
||||||
let bkey = [matrix.elements.map(v => v.round(5))].join(',')
|
let bkey = [matrix.elements.map(v => v.round(5))].join(',')
|
||||||
let cached = boundsCache[object.id];
|
let cached = boundsCache[object.id];
|
||||||
let bounds;
|
|
||||||
if (!cached || cached.bkey !== bkey) {
|
if (!cached || cached.bkey !== bkey) {
|
||||||
let position = geometry.attributes.position.clone();
|
let position = geometry.attributes.position.clone();
|
||||||
position.applyMatrix4(new THREE.Matrix4().extractRotation(matrix));
|
position.applyMatrix4(new THREE.Matrix4().extractRotation(matrix));
|
||||||
bounds = new THREE.Box3().setFromBufferAttribute(position);
|
cached = boundsCache[object.id] = { bkey,
|
||||||
cached = boundsCache[object.id] = {
|
bounds: new THREE.Box3().setFromBufferAttribute(position)
|
||||||
bkey,
|
|
||||||
bounds
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
bounds = cached.bounds.clone();
|
let bt = cached.bounds.clone();
|
||||||
let bt = new THREE.Box3().copy(bounds);
|
|
||||||
let m4 = new THREE.Matrix4();
|
let m4 = new THREE.Matrix4();
|
||||||
m4.setPosition(new THREE.Vector3().setFromMatrixPosition(object.matrixWorld));
|
m4.setPosition(new THREE.Vector3().setFromMatrixPosition(object.matrixWorld));
|
||||||
bt.applyMatrix4(m4);
|
bt.applyMatrix4(m4);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue