Skip to content

Commit

Permalink
chore(web): correct ordering of camera updates in map viewer animatio…
Browse files Browse the repository at this point in the history
…n loop
  • Loading branch information
fallenoak committed Feb 8, 2024
1 parent 5a9ea6e commit 2f3e98a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/spelunker-web/src/components/core/MapViewer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 2f3e98a

Please sign in to comment.