Fix TrackballControls : appel handleResize après affichage du canvas
All checks were successful
Deploy / Deploy to Production (push) Successful in 11s
All checks were successful
Deploy / Deploy to Production (push) Successful in 11s
Le contrôle s'initialisait avec des dimensions 0×0 (canvas display:none), rendant toute interaction impossible. handleResize() est maintenant appelé une fois le modèle chargé et le canvas visible, puis à chaque redimensionnement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d014027ad9
commit
f530bf7fcb
1 changed files with 6 additions and 4 deletions
|
|
@ -325,7 +325,7 @@
|
|||
<script type="module">
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
||||
import { TrackballControls } from 'three/addons/controls/TrackballControls.js';
|
||||
|
||||
const canvas = document.getElementById('viewer3d');
|
||||
const pholder = document.getElementById('viewer-placeholder');
|
||||
|
|
@ -353,9 +353,9 @@
|
|||
scene.add(fill);
|
||||
|
||||
// ── Controls ──────────────────────────────────────────
|
||||
const controls = new OrbitControls(camera, canvas);
|
||||
controls.enableDamping = true;
|
||||
controls.dampingFactor = 0.06;
|
||||
const controls = new TrackballControls(camera, canvas);
|
||||
controls.rotateSpeed = 3.0;
|
||||
controls.dynamicDampingFactor = 0.12;
|
||||
|
||||
// ── Model ─────────────────────────────────────────────
|
||||
let initCamPos, initTarget;
|
||||
|
|
@ -391,6 +391,7 @@
|
|||
bar.style.width = '100%';
|
||||
canvas.style.display = 'block';
|
||||
pholder.style.display = 'none';
|
||||
controls.handleResize();
|
||||
},
|
||||
({ loaded, total }) => {
|
||||
if (total) bar.style.width = `${Math.round(loaded / total * 100)}%`;
|
||||
|
|
@ -407,6 +408,7 @@
|
|||
camera.aspect = w / h;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(w, h);
|
||||
controls.handleResize();
|
||||
}
|
||||
resize();
|
||||
new ResizeObserver(resize).observe(viewer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue