2026-03-18 23:52:06 +00:00
|
|
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
|
|
|
|
|
|
|
|
let controls;
|
|
|
|
|
|
|
|
|
|
export function initInteraction(camera, renderer) {
|
|
|
|
|
controls = new OrbitControls(camera, renderer.domElement);
|
|
|
|
|
controls.enableDamping = true;
|
|
|
|
|
controls.dampingFactor = 0.05;
|
|
|
|
|
controls.screenSpacePanning = false;
|
|
|
|
|
controls.minDistance = 5;
|
|
|
|
|
controls.maxDistance = 80;
|
|
|
|
|
controls.maxPolarAngle = Math.PI / 2.1;
|
|
|
|
|
controls.target.set(0, 0, 0);
|
|
|
|
|
controls.update();
|
|
|
|
|
|
|
|
|
|
renderer.domElement.addEventListener('contextmenu', e => e.preventDefault());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function updateControls() {
|
|
|
|
|
if (controls) controls.update();
|
|
|
|
|
}
|
2026-03-19 02:01:23 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dispose orbit controls (used on world teardown).
|
|
|
|
|
*/
|
|
|
|
|
export function disposeInteraction() {
|
|
|
|
|
if (controls) {
|
|
|
|
|
controls.dispose();
|
|
|
|
|
controls = null;
|
|
|
|
|
}
|
|
|
|
|
}
|