Adjust camera position to fit the entire grid in the Model Layer Visualization

This commit is contained in:
ali asaria
2025-04-09 14:01:27 -04:00
parent 2c285c4bf6
commit 524e9562a3

View File

@@ -563,6 +563,13 @@ export default function ModelLayerVisualization({
// Point the camera at the center of the grid
camera.lookAt(0, 0, 0);
// zoom out the camera to fit the entire grid:
const maxDimension = Math.max(width, length);
const cameraDistance = maxDimension * (boxSize + spacing) * 0.75;
camera.position.set(0, cameraDistance, cameraDistance);
camera.lookAt(0, 0, 0);
controls.target.set(0, 0, 0);
controls.update();
// Add lights