diff --git a/packages/spelunker-web/src/components/core/MapViewer/index.jsx b/packages/spelunker-web/src/components/core/MapViewer/index.jsx index 6b80478..2f6b7ce 100644 --- a/packages/spelunker-web/src/components/core/MapViewer/index.jsx +++ b/packages/spelunker-web/src/components/core/MapViewer/index.jsx @@ -93,16 +93,21 @@ const MapViewer = ({ map: { id, filename } }) => { const animate = () => { const delta = clock.getDelta(); - mapManager.setTarget(camera.position.x, camera.position.y); - setCurrentPosition({ x: camera.position.x, y: camera.position.y, z: camera.position.z }); - controls.update(delta); - mapManager.update(delta, camera); // Adjust far clip (reduce draw calls by matching frustum to fog distance) camera.far = mapManager.cameraFar; camera.updateProjectionMatrix(); + // Ensure camera world matrices are up-to-date before camera is used in culling or bone + // matrix calculations + camera.updateMatrixWorld(); + + mapManager.setTarget(camera.position.x, camera.position.y); + setCurrentPosition({ x: camera.position.x, y: camera.position.y, z: camera.position.z }); + + mapManager.update(delta, camera); + renderer.setClearColor(mapManager.clearColor); renderer.render(scene, camera);