Skip to content

Commit

Permalink
feat: enable frustum culling
Browse files Browse the repository at this point in the history
Which was disabled because it did not work, since the bounding box was computed wrong
  • Loading branch information
piellardj authored and Sceat committed Apr 1, 2024
1 parent 6cac017 commit 4ecee79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/terrain/patch/patch-factory/patch-factory-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ abstract class PatchFactoryBase {
return null;
}

const boundingBox = new THREE.Box3(patchStart, patchEnd);
const boundingBoxFrom = new THREE.Vector3(0, 0, 0);
const boundingBoxTo = patchEnd.clone().sub(patchStart);
const boundingBox = new THREE.Box3(boundingBoxFrom, boundingBoxTo);
const boundingSphere = new THREE.Sphere();
boundingBox.getBoundingSphere(boundingSphere);

Expand All @@ -114,7 +116,7 @@ abstract class PatchFactoryBase {
mesh.customDepthMaterial = shadowMaterial;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.frustumCulled = false;
mesh.frustumCulled = true;
mesh.translateX(patchStart.x);
mesh.translateY(patchStart.y);
mesh.translateZ(patchStart.z);
Expand Down

0 comments on commit 4ecee79

Please sign in to comment.