Skip to content

Commit

Permalink
Only use first intersection with the terrain
Browse files Browse the repository at this point in the history
I have observed that there might be more than just one intersection when doing raycasting to get the distance of the map from the camera. I guess that only the first intersection should be used to determine the LOD, right?

This situation of multiple intersections during one raycast happend when the camera was close to the ground and looking towards mountains (MapView with MapView.HEIGHT).
  • Loading branch information
tobias74 authored Jan 5, 2024
1 parent f846323 commit 8331aaf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/lod/LODRaycast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ export class LODRaycast implements LODControl

// Check intersection
this.raycaster.setFromCamera(this.mouse, camera);
this.raycaster.intersectObjects(view.children, true, intersects);

let myIntersects = [];
this.raycaster.intersectObjects(view.children, true, myIntersects);
if (myIntersects.length > 0) {
// Only use first intersection with the terrain
intersects.push(myIntersects[0]);
}
}

for (let i = 0; i < intersects.length; i++)
Expand Down

0 comments on commit 8331aaf

Please sign in to comment.