Skip to content

Commit 572a1aa

Browse files
Fix the cube changing size when the view is reset with reset-view-btn
1 parent 3ebb202 commit 572a1aa

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

_includes/model-viewer.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// User stands BEHIND the cube, sees Yellow (right hand) on left, Blue (left hand) on right.
1212
const camera = new THREE.PerspectiveCamera(25, 1, 0.1, 1000);
1313
camera.position.set(0, 2, -4);
14-
const initialCameraPosition = camera.position.clone();
14+
let initialCameraPosition = camera.position.clone();
1515

1616
// Renderer
1717
const renderer = new THREE.WebGLRenderer({antialias: true, powerPreference: 'high-performance', alpha: true});
@@ -360,6 +360,8 @@
360360
controls.maxDistance = Math.max(distance * 1.8, controls.minDistance + 0.1);
361361
controls.update();
362362
}
363+
364+
initialCameraPosition = camera.position.clone();
363365
}
364366

365367
fitCameraToObject(keycubeGroup, camera, controls);
@@ -470,12 +472,8 @@
470472

471473
if (data.resetView) {
472474
camera.position.copy(initialCameraPosition);
473-
controls.target.copy(initialControlsTarget);
474475
autoRotateStoppedByUser = false;
475476
controls.autoRotate = true;
476-
camera.zoom = 1;
477-
camera.updateProjectionMatrix();
478-
controls.update();
479477
fitCameraToObject(keycubeGroup, camera, controls);
480478
}
481479

0 commit comments

Comments
 (0)