import{OrbitControls}from"three/examples/jsm/controls/OrbitControls";import{definePlugin}from"../../core/extension";export default definePlugin("orbit-control",{setup(a={},b){let c={enableDamping:!1,maxPolarAngle:Math.PI/2,keyPanSpeed:15,minDistance:.1,zommSpeed:10,...a};const d=new OrbitControls(b.camera,b.renderer.domElement);for(let e in c)d[e]=c[e];d.addEventListener("start",()=>{b.camera.stop()}),d.addEventListener("end",()=>{}),d.maxPolarAngle=Math.PI/2,d.minPolarAngle=0;let e=!0;return{control:d,mode:a=>{"2d"===a?(d.maxPolarAngle=0,d.minPolarAngle=0):(d.maxPolarAngle=Math.PI/2,d.minPolarAngle=0),d.update()},set enabled(a){e=a,this.control.enabled=a},update(){if(e)if(!b.renderer.isPaused){this.control.enabled=!0;let{x:a,y:c,z:d}=b.camera.target;this.control.target.set(a,c,d),this.control.update()}else this.control.enabled=!1}}},render(a){this.update(a)},destroyed(){this.control.dispose()}});