Skip to content

Commit

Permalink
fix breaking bug by detecting null boundsTree
Browse files Browse the repository at this point in the history
  • Loading branch information
memelotsqui committed Oct 26, 2023
1 parent a4cefe6 commit af540e6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/Scene.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ export default function Scene({sceneModel, lookatManager}) {
const setOriginalInidicesAndColliders = () => {
avatarModel.traverse((child)=>{
if (child.isMesh) {
child.userData.lastBoundsTree = child.geometry.boundsTree;
child.geometry.disposeBoundsTree();
if (child.userData.lastBoundsTree){
child.userData.lastBoundsTree = child.geometry.boundsTree;
child.geometry.disposeBoundsTree();
}
if (child.userData.origIndexBuffer){
child.userData.clippedIndexGeometry = child.geometry.index.clone();
child.geometry.setIndex(child.userData.origIndexBuffer);
Expand Down Expand Up @@ -187,13 +189,9 @@ export default function Scene({sceneModel, lookatManager}) {
if (clipIndices != null){
if (!checkIndicesExist(clipIndices,newIndices)){
const uint32ArrayAsArray = Array.from(clipIndices);
console.log(clipIndices);
const mergedIndices = [...uint32ArrayAsArray, ...newIndices];
intersectedObject.userData.clippedIndexGeometry = new THREE.BufferAttribute(new Uint32Array(mergedIndices),1,false);
}
else{
console.log("already exist")
}
}
}

Expand Down

0 comments on commit af540e6

Please sign in to comment.