Skip to content

Commit 9fb1ebd

Browse files
committed
Fix near / far planes in viewer tst
1 parent 0f20668 commit 9fb1ebd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

example/viewerTest.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,14 @@ async function updateModel() {
445445
creditEl.style.visibility = modelInfo.credit ? 'visible' : 'hidden';
446446
buildGui();
447447

448+
geometry.computeBoundingSphere();
449+
450+
// mirror the model-viewer near / far planes
451+
const radius = geometry.boundingSphere.radius;
452+
camera.near = 2 * radius / 1000;
453+
camera.far = 2 * radius;
454+
camera.updateProjectionMatrix();
455+
448456
camera.position.setFromSphericalCoords( orbit.radius, MathUtils.DEG2RAD * orbit.phi, MathUtils.DEG2RAD * orbit.theta );
449457
camera.position.x += target.x;
450458
camera.position.y += target.y;

0 commit comments

Comments
 (0)