@shopware-ag/dive
Version:
Shopware Spatial Framework
2 lines (1 loc) • 30.8 kB
JavaScript
"use strict";var Jt=Object.defineProperty;var $t=(D,e,i)=>e in D?Jt(D,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):D[e]=i;var b=(D,e,i)=>$t(D,typeof e!="symbol"?e+"":e,i);const p=require("three"),Z=require("./MathUtils-CBW56ZuG.cjs"),vt=require("./VisibilityLayerMask-BI7jPKdx.cjs"),Pt={type:"change"},st={type:"start"},Ct={type:"end"},W=new p.Ray,Dt=new p.Plane,te=Math.cos(70*p.MathUtils.DEG2RAD);class ee extends p.EventDispatcher{constructor(e,i){super(),this.object=e,this.domElement=i,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new p.Vector3,this.cursor=new p.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:p.MOUSE.ROTATE,MIDDLE:p.MOUSE.DOLLY,RIGHT:p.MOUSE.PAN},this.touches={ONE:p.TOUCH.ROTATE,TWO:p.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(s){s.addEventListener("keydown",it),this._domElementKeyEvents=s},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",it),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(Pt),t.update(),n=o.NONE},this.update=function(){const s=new p.Vector3,l=new p.Quaternion().setFromUnitVectors(e.up,new p.Vector3(0,1,0)),_=l.clone().invert(),g=new p.Vector3,w=new p.Quaternion,k=new p.Vector3,T=2*Math.PI;return function(Gt=null){const Et=t.object.position;s.copy(Et).sub(t.target),s.applyQuaternion(l),a.setFromVector3(s),t.autoRotate&&n===o.NONE&&Y(jt(Gt)),t.enableDamping?(a.theta+=m.theta*t.dampingFactor,a.phi+=m.phi*t.dampingFactor):(a.theta+=m.theta,a.phi+=m.phi);let A=t.minAzimuthAngle,O=t.maxAzimuthAngle;isFinite(A)&&isFinite(O)&&(A<-Math.PI?A+=T:A>Math.PI&&(A-=T),O<-Math.PI?O+=T:O>Math.PI&&(O-=T),A<=O?a.theta=Math.max(A,Math.min(O,a.theta)):a.theta=a.theta>(A+O)/2?Math.max(A,a.theta):Math.min(O,a.theta)),a.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,a.phi)),a.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(c,t.dampingFactor):t.target.add(c),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor);let U=!1;if(t.zoomToCursor&&R||t.object.isOrthographicCamera)a.radius=tt(a.radius);else{const j=a.radius;a.radius=tt(a.radius*r),U=j!=a.radius}if(s.setFromSpherical(a),s.applyQuaternion(_),Et.copy(t.target).add(s),t.object.lookAt(t.target),t.enableDamping===!0?(m.theta*=1-t.dampingFactor,m.phi*=1-t.dampingFactor,c.multiplyScalar(1-t.dampingFactor)):(m.set(0,0,0),c.set(0,0,0)),t.zoomToCursor&&R){let j=null;if(t.object.isPerspectiveCamera){const F=s.length();j=tt(F*r);const K=F-j;t.object.position.addScaledVector(L,K),t.object.updateMatrixWorld(),U=!!K}else if(t.object.isOrthographicCamera){const F=new p.Vector3(f.x,f.y,0);F.unproject(t.object);const K=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/r)),t.object.updateProjectionMatrix(),U=K!==t.object.zoom;const Tt=new p.Vector3(f.x,f.y,0);Tt.unproject(t.object),t.object.position.sub(Tt).add(F),t.object.updateMatrixWorld(),j=s.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;j!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(j).add(t.object.position):(W.origin.copy(t.object.position),W.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(W.direction))<te?e.lookAt(t.target):(Dt.setFromNormalAndCoplanarPoint(t.object.up,t.target),W.intersectPlane(Dt,t.target))))}else if(t.object.isOrthographicCamera){const j=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/r)),j!==t.object.zoom&&(t.object.updateProjectionMatrix(),U=!0)}return r=1,R=!1,U||g.distanceToSquared(t.object.position)>y||8*(1-w.dot(t.object.quaternion))>y||k.distanceToSquared(t.target)>y?(t.dispatchEvent(Pt),g.copy(t.object.position),w.copy(t.object.quaternion),k.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",Mt),t.domElement.removeEventListener("pointerdown",_t),t.domElement.removeEventListener("pointercancel",H),t.domElement.removeEventListener("wheel",gt),t.domElement.removeEventListener("pointermove",et),t.domElement.removeEventListener("pointerup",H),t.domElement.getRootNode().removeEventListener("keydown",ft,{capture:!0}),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",it),t._domElementKeyEvents=null)};const t=this,o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let n=o.NONE;const y=1e-6,a=new p.Spherical,m=new p.Spherical;let r=1;const c=new p.Vector3,u=new p.Vector2,d=new p.Vector2,h=new p.Vector2,x=new p.Vector2,E=new p.Vector2,M=new p.Vector2,P=new p.Vector2,S=new p.Vector2,C=new p.Vector2,L=new p.Vector3,f=new p.Vector2;let R=!1;const z=[],V={};let J=!1;function jt(s){return s!==null?2*Math.PI/60*t.autoRotateSpeed*s:2*Math.PI/60/60*t.autoRotateSpeed}function q(s){const l=Math.abs(s*.01);return Math.pow(.95,t.zoomSpeed*l)}function Y(s){m.theta-=s}function X(s){m.phi-=s}const rt=function(){const s=new p.Vector3;return function(_,g){s.setFromMatrixColumn(g,0),s.multiplyScalar(-_),c.add(s)}}(),at=function(){const s=new p.Vector3;return function(_,g){t.screenSpacePanning===!0?s.setFromMatrixColumn(g,1):(s.setFromMatrixColumn(g,0),s.crossVectors(t.object.up,s)),s.multiplyScalar(_),c.add(s)}}(),N=function(){const s=new p.Vector3;return function(_,g){const w=t.domElement;if(t.object.isPerspectiveCamera){const k=t.object.position;s.copy(k).sub(t.target);let T=s.length();T*=Math.tan(t.object.fov/2*Math.PI/180),rt(2*_*T/w.clientHeight,t.object.matrix),at(2*g*T/w.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(rt(_*(t.object.right-t.object.left)/t.object.zoom/w.clientWidth,t.object.matrix),at(g*(t.object.top-t.object.bottom)/t.object.zoom/w.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function $(s){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?r/=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function ht(s){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?r*=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function v(s,l){if(!t.zoomToCursor)return;R=!0;const _=t.domElement.getBoundingClientRect(),g=s-_.left,w=l-_.top,k=_.width,T=_.height;f.x=g/k*2-1,f.y=-(w/T)*2+1,L.set(f.x,f.y,1).unproject(t.object).sub(t.object.position).normalize()}function tt(s){return Math.max(t.minDistance,Math.min(t.maxDistance,s))}function ct(s){u.set(s.clientX,s.clientY)}function kt(s){v(s.clientX,s.clientX),P.set(s.clientX,s.clientY)}function lt(s){x.set(s.clientX,s.clientY)}function Lt(s){d.set(s.clientX,s.clientY),h.subVectors(d,u).multiplyScalar(t.rotateSpeed);const l=t.domElement;Y(2*Math.PI*h.x/l.clientHeight),X(2*Math.PI*h.y/l.clientHeight),u.copy(d),t.update()}function Rt(s){S.set(s.clientX,s.clientY),C.subVectors(S,P),C.y>0?$(q(C.y)):C.y<0&&ht(q(C.y)),P.copy(S),t.update()}function Nt(s){E.set(s.clientX,s.clientY),M.subVectors(E,x).multiplyScalar(t.panSpeed),N(M.x,M.y),x.copy(E),t.update()}function It(s){v(s.clientX,s.clientY),s.deltaY<0?ht(q(s.deltaY)):s.deltaY>0&&$(q(s.deltaY)),t.update()}function Vt(s){let l=!1;switch(s.code){case t.keys.UP:s.ctrlKey||s.metaKey||s.shiftKey?X(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):N(0,t.keyPanSpeed),l=!0;break;case t.keys.BOTTOM:s.ctrlKey||s.metaKey||s.shiftKey?X(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):N(0,-t.keyPanSpeed),l=!0;break;case t.keys.LEFT:s.ctrlKey||s.metaKey||s.shiftKey?Y(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):N(t.keyPanSpeed,0),l=!0;break;case t.keys.RIGHT:s.ctrlKey||s.metaKey||s.shiftKey?Y(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):N(-t.keyPanSpeed,0),l=!0;break}l&&(s.preventDefault(),t.update())}function ut(s){if(z.length===1)u.set(s.pageX,s.pageY);else{const l=I(s),_=.5*(s.pageX+l.x),g=.5*(s.pageY+l.y);u.set(_,g)}}function pt(s){if(z.length===1)x.set(s.pageX,s.pageY);else{const l=I(s),_=.5*(s.pageX+l.x),g=.5*(s.pageY+l.y);x.set(_,g)}}function mt(s){const l=I(s),_=s.pageX-l.x,g=s.pageY-l.y,w=Math.sqrt(_*_+g*g);P.set(0,w)}function Yt(s){t.enableZoom&&mt(s),t.enablePan&&pt(s)}function Ht(s){t.enableZoom&&mt(s),t.enableRotate&&ut(s)}function dt(s){if(z.length==1)d.set(s.pageX,s.pageY);else{const _=I(s),g=.5*(s.pageX+_.x),w=.5*(s.pageY+_.y);d.set(g,w)}h.subVectors(d,u).multiplyScalar(t.rotateSpeed);const l=t.domElement;Y(2*Math.PI*h.x/l.clientHeight),X(2*Math.PI*h.y/l.clientHeight),u.copy(d)}function yt(s){if(z.length===1)E.set(s.pageX,s.pageY);else{const l=I(s),_=.5*(s.pageX+l.x),g=.5*(s.pageY+l.y);E.set(_,g)}M.subVectors(E,x).multiplyScalar(t.panSpeed),N(M.x,M.y),x.copy(E)}function xt(s){const l=I(s),_=s.pageX-l.x,g=s.pageY-l.y,w=Math.sqrt(_*_+g*g);S.set(0,w),C.set(0,Math.pow(S.y/P.y,t.zoomSpeed)),$(C.y),P.copy(S);const k=(s.pageX+l.x)*.5,T=(s.pageY+l.y)*.5;v(k,T)}function Ut(s){t.enableZoom&&xt(s),t.enablePan&&yt(s)}function Ft(s){t.enableZoom&&xt(s),t.enableRotate&&dt(s)}function _t(s){t.enabled!==!1&&(z.length===0&&(t.domElement.setPointerCapture(s.pointerId),t.domElement.addEventListener("pointermove",et),t.domElement.addEventListener("pointerup",H)),!Qt(s)&&(Kt(s),s.pointerType==="touch"?bt(s):Zt(s)))}function et(s){t.enabled!==!1&&(s.pointerType==="touch"?Xt(s):Bt(s))}function H(s){switch(Wt(s),z.length){case 0:t.domElement.releasePointerCapture(s.pointerId),t.domElement.removeEventListener("pointermove",et),t.domElement.removeEventListener("pointerup",H),t.dispatchEvent(Ct),n=o.NONE;break;case 1:const l=z[0],_=V[l];bt({pointerId:l,pageX:_.x,pageY:_.y});break}}function Zt(s){let l;switch(s.button){case 0:l=t.mouseButtons.LEFT;break;case 1:l=t.mouseButtons.MIDDLE;break;case 2:l=t.mouseButtons.RIGHT;break;default:l=-1}switch(l){case p.MOUSE.DOLLY:if(t.enableZoom===!1)return;kt(s),n=o.DOLLY;break;case p.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(t.enablePan===!1)return;lt(s),n=o.PAN}else{if(t.enableRotate===!1)return;ct(s),n=o.ROTATE}break;case p.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(t.enableRotate===!1)return;ct(s),n=o.ROTATE}else{if(t.enablePan===!1)return;lt(s),n=o.PAN}break;default:n=o.NONE}n!==o.NONE&&t.dispatchEvent(st)}function Bt(s){switch(n){case o.ROTATE:if(t.enableRotate===!1)return;Lt(s);break;case o.DOLLY:if(t.enableZoom===!1)return;Rt(s);break;case o.PAN:if(t.enablePan===!1)return;Nt(s);break}}function gt(s){t.enabled===!1||t.enableZoom===!1||n!==o.NONE||(s.preventDefault(),t.dispatchEvent(st),It(qt(s)),t.dispatchEvent(Ct))}function qt(s){const l=s.deltaMode,_={clientX:s.clientX,clientY:s.clientY,deltaY:s.deltaY};switch(l){case 1:_.deltaY*=16;break;case 2:_.deltaY*=100;break}return s.ctrlKey&&!J&&(_.deltaY*=10),_}function ft(s){s.key==="Control"&&(J=!0,t.domElement.getRootNode().addEventListener("keyup",zt,{passive:!0,capture:!0}))}function zt(s){s.key==="Control"&&(J=!1,t.domElement.getRootNode().removeEventListener("keyup",zt,{passive:!0,capture:!0}))}function it(s){t.enabled===!1||t.enablePan===!1||Vt(s)}function bt(s){switch(wt(s),z.length){case 1:switch(t.touches.ONE){case p.TOUCH.ROTATE:if(t.enableRotate===!1)return;ut(s),n=o.TOUCH_ROTATE;break;case p.TOUCH.PAN:if(t.enablePan===!1)return;pt(s),n=o.TOUCH_PAN;break;default:n=o.NONE}break;case 2:switch(t.touches.TWO){case p.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;Yt(s),n=o.TOUCH_DOLLY_PAN;break;case p.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;Ht(s),n=o.TOUCH_DOLLY_ROTATE;break;default:n=o.NONE}break;default:n=o.NONE}n!==o.NONE&&t.dispatchEvent(st)}function Xt(s){switch(wt(s),n){case o.TOUCH_ROTATE:if(t.enableRotate===!1)return;dt(s),t.update();break;case o.TOUCH_PAN:if(t.enablePan===!1)return;yt(s),t.update();break;case o.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;Ut(s),t.update();break;case o.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;Ft(s),t.update();break;default:n=o.NONE}}function Mt(s){t.enabled!==!1&&s.preventDefault()}function Kt(s){z.push(s.pointerId)}function Wt(s){delete V[s.pointerId];for(let l=0;l<z.length;l++)if(z[l]==s.pointerId){z.splice(l,1);return}}function Qt(s){for(let l=0;l<z.length;l++)if(z[l]==s.pointerId)return!0;return!1}function wt(s){let l=V[s.pointerId];l===void 0&&(l=new p.Vector2,V[s.pointerId]=l),l.set(s.pageX,s.pageY)}function I(s){const l=s.pointerId===z[0]?z[1]:z[0];return V[l]}t.domElement.addEventListener("contextmenu",Mt),t.domElement.addEventListener("pointerdown",_t),t.domElement.addEventListener("pointercancel",H),t.domElement.addEventListener("wheel",gt,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",ft,{passive:!0,capture:!0}),this.update()}}class ie{constructor(e=0,i=0,t=0,o=1){this.isQuaternion=!0,this._x=e,this._y=i,this._z=t,this._w=o}static slerpFlat(e,i,t,o,n,y,a){let m=t[o+0],r=t[o+1],c=t[o+2],u=t[o+3];const d=n[y+0],h=n[y+1],x=n[y+2],E=n[y+3];if(a===0){e[i+0]=m,e[i+1]=r,e[i+2]=c,e[i+3]=u;return}if(a===1){e[i+0]=d,e[i+1]=h,e[i+2]=x,e[i+3]=E;return}if(u!==E||m!==d||r!==h||c!==x){let M=1-a;const P=m*d+r*h+c*x+u*E,S=P>=0?1:-1,C=1-P*P;if(C>Number.EPSILON){const f=Math.sqrt(C),R=Math.atan2(f,P*S);M=Math.sin(M*R)/f,a=Math.sin(a*R)/f}const L=a*S;if(m=m*M+d*L,r=r*M+h*L,c=c*M+x*L,u=u*M+E*L,M===1-a){const f=1/Math.sqrt(m*m+r*r+c*c+u*u);m*=f,r*=f,c*=f,u*=f}}e[i]=m,e[i+1]=r,e[i+2]=c,e[i+3]=u}static multiplyQuaternionsFlat(e,i,t,o,n,y){const a=t[o],m=t[o+1],r=t[o+2],c=t[o+3],u=n[y],d=n[y+1],h=n[y+2],x=n[y+3];return e[i]=a*x+c*u+m*h-r*d,e[i+1]=m*x+c*d+r*u-a*h,e[i+2]=r*x+c*h+a*d-m*u,e[i+3]=c*x-a*u-m*d-r*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,i,t,o){return this._x=e,this._y=i,this._z=t,this._w=o,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,i=!0){const t=e._x,o=e._y,n=e._z,y=e._order,a=Math.cos,m=Math.sin,r=a(t/2),c=a(o/2),u=a(n/2),d=m(t/2),h=m(o/2),x=m(n/2);switch(y){case"XYZ":this._x=d*c*u+r*h*x,this._y=r*h*u-d*c*x,this._z=r*c*x+d*h*u,this._w=r*c*u-d*h*x;break;case"YXZ":this._x=d*c*u+r*h*x,this._y=r*h*u-d*c*x,this._z=r*c*x-d*h*u,this._w=r*c*u+d*h*x;break;case"ZXY":this._x=d*c*u-r*h*x,this._y=r*h*u+d*c*x,this._z=r*c*x+d*h*u,this._w=r*c*u-d*h*x;break;case"ZYX":this._x=d*c*u-r*h*x,this._y=r*h*u+d*c*x,this._z=r*c*x-d*h*u,this._w=r*c*u+d*h*x;break;case"YZX":this._x=d*c*u+r*h*x,this._y=r*h*u+d*c*x,this._z=r*c*x-d*h*u,this._w=r*c*u-d*h*x;break;case"XZY":this._x=d*c*u-r*h*x,this._y=r*h*u-d*c*x,this._z=r*c*x+d*h*u,this._w=r*c*u+d*h*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+y)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,i){const t=i/2,o=Math.sin(t);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){const i=e.elements,t=i[0],o=i[4],n=i[8],y=i[1],a=i[5],m=i[9],r=i[2],c=i[6],u=i[10],d=t+a+u;if(d>0){const h=.5/Math.sqrt(d+1);this._w=.25/h,this._x=(c-m)*h,this._y=(n-r)*h,this._z=(y-o)*h}else if(t>a&&t>u){const h=2*Math.sqrt(1+t-a-u);this._w=(c-m)/h,this._x=.25*h,this._y=(o+y)/h,this._z=(n+r)/h}else if(a>u){const h=2*Math.sqrt(1+a-t-u);this._w=(n-r)/h,this._x=(o+y)/h,this._y=.25*h,this._z=(m+c)/h}else{const h=2*Math.sqrt(1+u-t-a);this._w=(y-o)/h,this._x=(n+r)/h,this._y=(m+c)/h,this._z=.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,i){let t=e.dot(i)+1;return t<Number.EPSILON?(t=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=t):(this._x=0,this._y=-e.z,this._z=e.y,this._w=t)):(this._x=e.y*i.z-e.z*i.y,this._y=e.z*i.x-e.x*i.z,this._z=e.x*i.y-e.y*i.x,this._w=t),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Z.clamp(this.dot(e),-1,1)))}rotateTowards(e,i){const t=this.angleTo(e);if(t===0)return this;const o=Math.min(1,i/t);return this.slerp(e,o),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,i){const t=e._x,o=e._y,n=e._z,y=e._w,a=i._x,m=i._y,r=i._z,c=i._w;return this._x=t*c+y*a+o*r-n*m,this._y=o*c+y*m+n*a-t*r,this._z=n*c+y*r+t*m-o*a,this._w=y*c-t*a-o*m-n*r,this._onChangeCallback(),this}slerp(e,i){if(i===0)return this;if(i===1)return this.copy(e);const t=this._x,o=this._y,n=this._z,y=this._w;let a=y*e._w+t*e._x+o*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=y,this._x=t,this._y=o,this._z=n,this;const m=1-a*a;if(m<=Number.EPSILON){const h=1-i;return this._w=h*y+i*this._w,this._x=h*t+i*this._x,this._y=h*o+i*this._y,this._z=h*n+i*this._z,this.normalize(),this}const r=Math.sqrt(m),c=Math.atan2(r,a),u=Math.sin((1-i)*c)/r,d=Math.sin(i*c)/r;return this._w=y*u+this._w*d,this._x=t*u+this._x*d,this._y=o*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,i,t){return this.copy(e).slerp(i,t)}random(){const e=2*Math.PI*Math.random(),i=2*Math.PI*Math.random(),t=Math.random(),o=Math.sqrt(1-t),n=Math.sqrt(t);return this.set(o*Math.sin(e),o*Math.cos(e),n*Math.sin(i),n*Math.cos(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,i=0){return this._x=e[i],this._y=e[i+1],this._z=e[i+2],this._w=e[i+3],this._onChangeCallback(),this}toArray(e=[],i=0){return e[i]=this._x,e[i+1]=this._y,e[i+2]=this._z,e[i+3]=this._w,e}fromBufferAttribute(e,i){return this._x=e.getX(i),this._y=e.getY(i),this._z=e.getZ(i),this._w=e.getW(i),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,i=0,t=0){G.prototype.isVector3=!0,this.x=e,this.y=i,this.z=t}set(e,i,t){return t===void 0&&(t=this.z),this.x=e,this.y=i,this.z=t,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,i){return this.x=e.x+i.x,this.y=e.y+i.y,this.z=e.z+i.z,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this.z+=e.z*i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,i){return this.x=e.x-i.x,this.y=e.y-i.y,this.z=e.z-i.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,i){return this.x=e.x*i.x,this.y=e.y*i.y,this.z=e.z*i.z,this}applyEuler(e){return this.applyQuaternion(St.setFromEuler(e))}applyAxisAngle(e,i){return this.applyQuaternion(St.setFromAxisAngle(e,i))}applyMatrix3(e){const i=this.x,t=this.y,o=this.z,n=e.elements;return this.x=n[0]*i+n[3]*t+n[6]*o,this.y=n[1]*i+n[4]*t+n[7]*o,this.z=n[2]*i+n[5]*t+n[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const i=this.x,t=this.y,o=this.z,n=e.elements,y=1/(n[3]*i+n[7]*t+n[11]*o+n[15]);return this.x=(n[0]*i+n[4]*t+n[8]*o+n[12])*y,this.y=(n[1]*i+n[5]*t+n[9]*o+n[13])*y,this.z=(n[2]*i+n[6]*t+n[10]*o+n[14])*y,this}applyQuaternion(e){const i=this.x,t=this.y,o=this.z,n=e.x,y=e.y,a=e.z,m=e.w,r=2*(y*o-a*t),c=2*(a*i-n*o),u=2*(n*t-y*i);return this.x=i+m*r+y*u-a*c,this.y=t+m*c+a*r-n*u,this.z=o+m*u+n*c-y*r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const i=this.x,t=this.y,o=this.z,n=e.elements;return this.x=n[0]*i+n[4]*t+n[8]*o,this.y=n[1]*i+n[5]*t+n[9]*o,this.z=n[2]*i+n[6]*t+n[10]*o,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,i){return this.x=Math.max(e.x,Math.min(i.x,this.x)),this.y=Math.max(e.y,Math.min(i.y,this.y)),this.z=Math.max(e.z,Math.min(i.z,this.z)),this}clampScalar(e,i){return this.x=Math.max(e,Math.min(i,this.x)),this.y=Math.max(e,Math.min(i,this.y)),this.z=Math.max(e,Math.min(i,this.z)),this}clampLength(e,i){const t=this.length();return this.divideScalar(t||1).multiplyScalar(Math.max(e,Math.min(i,t)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this.z+=(e.z-this.z)*i,this}lerpVectors(e,i,t){return this.x=e.x+(i.x-e.x)*t,this.y=e.y+(i.y-e.y)*t,this.z=e.z+(i.z-e.z)*t,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,i){const t=e.x,o=e.y,n=e.z,y=i.x,a=i.y,m=i.z;return this.x=o*m-n*a,this.y=n*y-t*m,this.z=t*a-o*y,this}projectOnVector(e){const i=e.lengthSq();if(i===0)return this.set(0,0,0);const t=e.dot(this)/i;return this.copy(e).multiplyScalar(t)}projectOnPlane(e){return nt.copy(this).projectOnVector(e),this.sub(nt)}reflect(e){return this.sub(nt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const i=Math.sqrt(this.lengthSq()*e.lengthSq());if(i===0)return Math.PI/2;const t=this.dot(e)/i;return Math.acos(Z.clamp(t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const i=this.x-e.x,t=this.y-e.y,o=this.z-e.z;return i*i+t*t+o*o}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,i,t){const o=Math.sin(i)*e;return this.x=o*Math.sin(t),this.y=Math.cos(i)*e,this.z=o*Math.cos(t),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,i,t){return this.x=e*Math.sin(i),this.y=t,this.z=e*Math.cos(i),this}setFromMatrixPosition(e){const i=e.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(e){const i=this.setFromMatrixColumn(e,0).length(),t=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=i,this.y=t,this.z=o,this}setFromMatrixColumn(e,i){return this.fromArray(e.elements,i*4)}setFromMatrix3Column(e,i){return this.fromArray(e.elements,i*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,i=0){return this.x=e[i],this.y=e[i+1],this.z=e[i+2],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e[i+2]=this.z,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this.z=e.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,i=Math.random()*2-1,t=Math.sqrt(1-i*i);return this.x=t*Math.cos(e),this.y=i,this.z=t*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const nt=new G,St=new ie;class At extends p.Object3D{constructor(){super();b(this,"isSelectable",!0);b(this,"isMovable",!0);b(this,"isDIVENode",!0);b(this,"gizmo",null);b(this,"_positionWorldBuffer");b(this,"_boundingBox");this.layers.mask=vt.PRODUCT_LAYER_MASK,this._positionWorldBuffer=new p.Vector3,this._boundingBox=new p.Box3}setPosition(i){if(!this.parent){this.position.set(i.x,i.y,i.z);return}const t=new p.Vector3(i.x,i.y,i.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.updateLineTo(this)}setRotation(i){this.rotation.set(i.x,i.y,i.z)}setScale(i){this.scale.set(i.x,i.y,i.z)}setVisibility(i){this.visible=i}setToWorldOrigin(){this.position.set(0,0,0),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:i})=>{var t;(t=i.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:i})=>{var t;(t=i.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:i})=>{var t;(t=i.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:i})=>{var t;(t=i.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class Ot extends At{constructor(i,t=!1,o=65280){super();b(this,"_box");b(this,"_sphere");b(this,"_center");b(this,"_radius");b(this,"_boxHelper");b(this,"_sphereHelper");b(this,"_size");const n=new p.Box3;t?n.setFromObject(i):(i.updateWorldMatrix(!0,!0),i.traverse(a=>{if(a.isMesh){const m=a,r=m.geometry.clone();r.applyMatrix4(m.matrixWorld);const c=m.getWorldQuaternion(new p.Quaternion).invert();r.applyQuaternion(c),r.computeBoundingBox(),r.boundingBox&&n.union(r.boundingBox)}})),this.rotation.copy(i.rotation),this._box=n,this._size=n.getSize(new p.Vector3),this._center=n.getCenter(new p.Vector3),this._boxHelper=new p.Box3Helper(this._box,o),this._boxHelper.visible=!1,this.add(this._boxHelper),this._sphere=n.getBoundingSphere(new p.Sphere),this._radius=this._sphere.radius;const y=new p.SphereGeometry(this._radius,32,32);y.translate(this._center.x,this._center.y,this._center.z),this._sphereHelper=new p.Mesh(y,new p.MeshBasicMaterial({color:o,wireframe:!0})),this._sphereHelper.visible=!1,this.add(this._sphereHelper)}get box(){return this._box}get sphere(){return this._sphere}get center(){return this._center}get radius(){return this._radius}get size(){return this._size}setBoxHelperVisible(i){this._boxHelper.visible=i}setSphereHelperVisible(i){this._sphereHelper.visible=i}}const Q={enableDamping:!0,dampingFactor:.05},B=class B extends ee{constructor(i,t,o=Q){super(i,t);b(this,"uuid",Z.MathUtils.generateUUID());b(this,"object");this.domElement=t,this.domElement=t,this.object=i,this.enableDamping=o.enableDamping??Q.enableDamping,this.dampingFactor=o.dampingFactor??Q.dampingFactor,this.object.position.set(0,2,2),this.target.copy({x:0,y:.5,z:0}),this.update()}tick(){this.enabled&&this.update()}computeEncompassingView(i,t=0){const o=i.center,y=i.sphere.radius,a=this.object.fov*Math.PI/180,m=this.object.aspect,r=a/2,c=Math.atan(Math.tan(r)*m),u=y/Math.sin(r),d=y/Math.sin(c),h=Math.max(u,d)*(1+t),x=this.object.position.clone().sub(this.target).normalize(),E=x.length()>.001?x:new G(0,0,1);return{position:o.clone().add(E.multiplyScalar(h)),target:o}}focusOnObject(i,t=0){const o=new Ot(i,!1,65280),n=this.computeEncompassingView(o,t);this.object.position.copy(n.position),this.target.copy(n.target),this.update()}zoomIn(i){const t=i||B.DEFAULT_ZOOM_FACTOR,{minDistance:o,maxDistance:n}=this;this.minDistance=this.maxDistance=Z.MathUtils.clamp(this.getDistance()-t,o+t,n-t),this.update(),this.minDistance=o,this.maxDistance=n}zoomOut(i){const t=i||B.DEFAULT_ZOOM_FACTOR,{minDistance:o,maxDistance:n}=this;this.minDistance=this.maxDistance=Z.MathUtils.clamp(this.getDistance()+t,o+t,n-t),this.update(),this.minDistance=o,this.maxDistance=n}};b(B,"DEFAULT_ZOOM_FACTOR",1);let ot=B;exports.BoundingBox=Ot;exports.DIVENode=At;exports.OrbitController=ot;exports.OrbitControllerDefaultSettings=Q;