@shopware-ag/dive 2.2.30 → 2.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/build/chunks/{AssetCache-DqR9MuYr.cjs → AssetCache-USoLeA8n.cjs} +1 -1
  2. package/build/chunks/{AssetCache-BAVgjwZD.mjs → AssetCache-Yaezy697.mjs} +1 -1
  3. package/build/chunks/{AssetLoader-DYfC6o4E.mjs → AssetLoader-CWm-aunM.mjs} +3 -3
  4. package/build/chunks/{AssetLoader-ULFVz0k1.cjs → AssetLoader-CxWzLiHn.cjs} +1 -1
  5. package/build/chunks/{FileTypes-DvYQDBRG.cjs → FileTypes-D3vblaAa.cjs} +1 -1
  6. package/build/chunks/{FileTypes-Bf6fWggQ.mjs → FileTypes-qgM3TaRh.mjs} +1 -1
  7. package/build/chunks/{isFileTypeSupported-DRAnF6K8.mjs → isFileTypeSupported-CGTPFOhi.mjs} +1 -1
  8. package/build/chunks/{isFileTypeSupported-rlWKlVtV.cjs → isFileTypeSupported-uAFXvyzy.cjs} +1 -1
  9. package/build/dive.cjs +1 -1
  10. package/build/dive.mjs +2 -2
  11. package/build/plugins/ar/index.cjs +1 -1
  12. package/build/plugins/ar/index.mjs +1 -1
  13. package/build/plugins/assetcache/index.cjs +1 -1
  14. package/build/plugins/assetcache/index.mjs +1 -1
  15. package/build/plugins/assetloader/index.cjs +1 -1
  16. package/build/plugins/assetloader/index.mjs +1 -1
  17. package/build/plugins/orbitcontroller/index.cjs +1 -1
  18. package/build/plugins/orbitcontroller/index.mjs +1 -1
  19. package/build/plugins/orientationdisplay/index.cjs +1 -1
  20. package/build/plugins/orientationdisplay/index.mjs +1 -1
  21. package/build/plugins/quickview/index.cjs +1 -1
  22. package/build/plugins/quickview/index.mjs +1 -1
  23. package/build/plugins/state/index.cjs +1 -1
  24. package/build/plugins/state/index.mjs +1 -1
  25. package/build/plugins/toolbox/index.cjs +1 -1
  26. package/build/plugins/toolbox/index.mjs +339 -313
  27. package/build/plugins/toolbox/src/transform/TransformTool.d.ts +18 -2
  28. package/package.json +1 -1
@@ -2,7 +2,7 @@ var l = Object.defineProperty;
2
2
  var _ = (s, e, r) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
3
3
  var t = (s, e, r) => _(s, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { Object3D as p, AxesHelper as c, Color as n, Matrix4 as d, OrthographicCamera as m, MathUtils as x, Vector4 as w } from "three";
5
- import "../../chunks/FileTypes-Bf6fWggQ.mjs";
5
+ import "../../chunks/FileTypes-qgM3TaRh.mjs";
6
6
  import { C as i } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
7
7
  import { A as C, a as g, b as u, c as A, d as H, e as b } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
8
8
  import h from "three-spritetext";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-DvYQDBRG.cjs");require("three");const r={...t.DIVEDefaultSettings},l=async(n,c)=>{const e=new t.DIVE(c);e.mainView.camera.position.set(0,1,2);const o=await new t.DIVEModel().setFromURL(n);e.scene.root.add(o),o.placeOnFloor();const i=new t.OrbitController(e.mainView.camera,e.mainView.canvas);i.focusObject(o),e.clock.addTicker(i);const s=Object.assign(e,{orbitController:i}),a=e.dispose.bind(e);return s.dispose=async()=>{i.dispose(),await a()},s};exports.QuickView=l;exports.QuickViewDefaultSettings=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-D3vblaAa.cjs");require("three");const r={...t.DIVEDefaultSettings},l=async(n,c)=>{const e=new t.DIVE(c);e.mainView.camera.position.set(0,1,2);const o=await new t.DIVEModel().setFromURL(n);e.scene.root.add(o),o.placeOnFloor();const i=new t.OrbitController(e.mainView.camera,e.mainView.canvas);i.focusObject(o),e.clock.addTicker(i);const s=Object.assign(e,{orbitController:i}),a=e.dispose.bind(e);return s.dispose=async()=>{i.dispose(),await a()},s};exports.QuickView=l;exports.QuickViewDefaultSettings=r;
@@ -1,4 +1,4 @@
1
- import { D as c, b as r, c as l, a as d } from "../../chunks/FileTypes-Bf6fWggQ.mjs";
1
+ import { D as c, b as r, c as l, a as d } from "../../chunks/FileTypes-qgM3TaRh.mjs";
2
2
  import "three";
3
3
  const p = {
4
4
  ...c
@@ -1,4 +1,4 @@
1
- "use strict";var Nd=Object.defineProperty;var $d=(d,g,o)=>g in d?Nd(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var un=(d,g,o)=>$d(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Hd=require("three"),qd=require("../../chunks/FileTypes-DvYQDBRG.cjs"),Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),vo={};function G(d,g){vo[d]=g}function wo(d){return vo[d]}class F{constructor(g,o){un(this,"_payload");un(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,$){super(m,$);un(this,"_description",g);un(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const Ao=F.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",Ao);const xo=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new qd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",xo);const mo=F.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",mo);const Eo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const Y=o.get(d.id);if(!Y)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Y))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Y}`);$=Y.position,q=Y.target}else $=d.position,q=d.target;const gn=await S().then(Y=>{m.clock.hasTicker(Y)||m.clock.addTicker(Y),g.enabled=!0;const sr=Y.animate(g.object.position,$,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out}).play(),ve=Y.animate(g.target,q,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}}).play();return[sr,ve]});return{stop:()=>gn.forEach(Y=>Y.stop())}}});G("MOVE_CAMERA",Eo);const So=F.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",So);const bo=F.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",bo);const Oo=F.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",Oo);const To=F.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:$}=d,{position:q,target:gn}=m;return S.generateMedia({position:q,target:gn,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",To);const Co=F.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Co);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
1
+ "use strict";var Nd=Object.defineProperty;var $d=(d,g,o)=>g in d?Nd(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var un=(d,g,o)=>$d(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Hd=require("three"),qd=require("../../chunks/FileTypes-D3vblaAa.cjs"),Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),vo={};function G(d,g){vo[d]=g}function wo(d){return vo[d]}class F{constructor(g,o){un(this,"_payload");un(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,$){super(m,$);un(this,"_description",g);un(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const Ao=F.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",Ao);const xo=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new qd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",xo);const mo=F.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",mo);const Eo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const Y=o.get(d.id);if(!Y)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Y))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Y}`);$=Y.position,q=Y.target}else $=d.position,q=d.target;const gn=await S().then(Y=>{m.clock.hasTicker(Y)||m.clock.addTicker(Y),g.enabled=!0;const sr=Y.animate(g.object.position,$,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out}).play(),ve=Y.animate(g.target,q,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}}).play();return[sr,ve]});return{stop:()=>gn.forEach(Y=>Y.stop())}}});G("MOVE_CAMERA",Eo);const So=F.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",So);const bo=F.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",bo);const Oo=F.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",Oo);const To=F.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:$}=d,{position:q,target:gn}=m;return S.generateMedia({position:q,target:gn,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",To);const Co=F.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Co);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -2,7 +2,7 @@ var gd = Object.defineProperty;
2
2
  var _d = (d, g, o) => g in d ? gd(d, g, { enumerable: !0, configurable: !0, writable: !0, value: o }) : d[g] = o;
3
3
  var un = (d, g, o) => _d(d, typeof g != "symbol" ? g + "" : g, o);
4
4
  import { MathUtils as dd } from "three";
5
- import { B as pd } from "../../chunks/FileTypes-Bf6fWggQ.mjs";
5
+ import { B as pd } from "../../chunks/FileTypes-qgM3TaRh.mjs";
6
6
  import { a as _o, i as vd } from "../../chunks/PovSchema-DWWvr_ED.mjs";
7
7
  const po = {};
8
8
  function N(d, g) {
@@ -1 +1 @@
1
- "use strict";var vt=Object.defineProperty;var Mt=(h,t,e)=>t in h?vt(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var r=(h,t,e)=>Mt(h,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("three");require("../../chunks/FileTypes-DvYQDBRG.cjs");const M=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),S=require("../../chunks/findInterface-C6mrvf_t.cjs"),G=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class lt{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,o;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(o=t.onSelect)==null||o.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class ct{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var o,a,n,l,_,w,P;const e=t.modelIntersects[0],s=S.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(o=s.onPointerEnter)==null||o.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(a=this._hovered).onPointerLeave)==null||n.call(a),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(_=s.onPointerOver)==null||_.call(s,e);return}this._hovered&&((P=(w=this._hovered).onPointerLeave)==null||P.call(w),this._hovered=null)}}const St=h=>h.name==="select";class ${constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.modelIntersects[0],s=S.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const o=this._selectionState.selected;o&&o.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const A=new i.Raycaster,p=new i.Vector3,T=new i.Vector3,d=new i.Quaternion,it={X:new i.Vector3(1,0,0),Y:new i.Vector3(0,1,0),Z:new i.Vector3(0,0,1)},N={type:"change"},st={type:"mouseDown"},nt={type:"mouseUp",mode:null},ot={type:"objectChange"};class Pt extends i.Object3D{constructor(t,e){super(),e===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const s=new At;this._gizmo=s,this.add(s);const o=new Ct;this._plane=o,this.add(o);const a=this;function n(u,f){let L=f;Object.defineProperty(a,u,{get:function(){return L!==void 0?L:f},set:function(I){L!==I&&(L=I,o[u]=I,s[u]=I,a.dispatchEvent({type:u+"-changed",value:I}),a.dispatchEvent(N))}}),a[u]=f,o[u]=f,s[u]=f}n("camera",t),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const l=new i.Vector3,_=new i.Vector3,w=new i.Quaternion,P=new i.Quaternion,R=new i.Vector3,Y=new i.Quaternion,tt=new i.Vector3,j=new i.Vector3,D=new i.Vector3,E=0,b=new i.Vector3;n("worldPosition",l),n("worldPositionStart",_),n("worldQuaternion",w),n("worldQuaternionStart",P),n("cameraPosition",R),n("cameraQuaternion",Y),n("pointStart",tt),n("pointEnd",j),n("rotationAxis",D),n("rotationAngle",E),n("eye",b),this._offset=new i.Vector3,this._startNorm=new i.Vector3,this._endNorm=new i.Vector3,this._cameraScale=new i.Vector3,this._parentPosition=new i.Vector3,this._parentQuaternion=new i.Quaternion,this._parentQuaternionInv=new i.Quaternion,this._parentScale=new i.Vector3,this._worldScaleStart=new i.Vector3,this._worldQuaternionInv=new i.Quaternion,this._worldScale=new i.Vector3,this._positionStart=new i.Vector3,this._quaternionStart=new i.Quaternion,this._scaleStart=new i.Vector3,this._getPointer=Dt.bind(this),this._onPointerDown=xt.bind(this),this._onPointerHover=Et.bind(this),this._onPointerMove=Tt.bind(this),this._onPointerUp=It.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(t){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(t)}pointerHover(t){if(this.object===void 0||this.dragging===!0)return;t!==null&&A.setFromCamera(t,this.camera);const e=K(this._gizmo.picker[this.mode],A);e?this.axis=e.object.name:this.axis=null}pointerDown(t){if(!(this.object===void 0||this.dragging===!0||t!=null&&t.button!==0)&&this.axis!==null){t!==null&&A.setFromCamera(t,this.camera);const e=K(this._plane,A,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,st.mode=this.mode,this.dispatchEvent(st)}}pointerMove(t){const e=this.axis,s=this.mode,o=this.object;let a=this.space;if(s==="scale"?a="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(a="world"),o===void 0||e===null||this.dragging===!1||t!==null&&t.button!==-1)return;t!==null&&A.setFromCamera(t,this.camera);const n=K(this._plane,A,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),o.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(o.position.applyQuaternion(d.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.position.applyQuaternion(this._quaternionStart)),a==="world"&&(o.parent&&o.position.add(p.setFromMatrixPosition(o.parent.matrixWorld)),e.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.parent&&o.position.sub(p.setFromMatrixPosition(o.parent.matrixWorld))));else if(s==="scale"){if(e.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),T.set(l,l,l)}else p.copy(this.pointStart),T.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),T.applyQuaternion(this._worldQuaternionInv),T.divide(p),e.search("X")===-1&&(T.x=1),e.search("Y")===-1&&(T.y=1),e.search("Z")===-1&&(T.z=1);o.scale.copy(this._scaleStart).multiply(T),this.scaleSnap&&(e.search("X")!==-1&&(o.scale.x=Math.round(o.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(o.scale.y=Math.round(o.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(o.scale.z=Math.round(o.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let _=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*l):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(it[e]),p.copy(it[e]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?_=!0:this.rotationAngle=this._offset.dot(p.normalize())*l),(e==="E"||_)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&e!=="E"&&e!=="XYZE"?(o.quaternion.copy(this._quaternionStart),o.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),o.quaternion.copy(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),o.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(N),this.dispatchEvent(ot)}}pointerUp(t){t!==null&&t.button!==0||(this.dragging&&this.axis!==null&&(nt.mode=this.mode,this.dispatchEvent(nt)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(N),this.dispatchEvent(ot),this.pointStart.copy(this.pointEnd))}getRaycaster(){return A}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function Dt(h){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:h.button};{const t=this.domElement.getBoundingClientRect();return{x:(h.clientX-t.left)/t.width*2-1,y:-(h.clientY-t.top)/t.height*2+1,button:h.button}}}function Et(h){if(this.enabled)switch(h.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(h));break}}function xt(h){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(h.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(h)),this.pointerDown(this._getPointer(h)))}function Tt(h){this.enabled&&this.pointerMove(this._getPointer(h))}function It(h){this.enabled&&(this.domElement.releasePointerCapture(h.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(h)))}function K(h,t,e){const s=t.intersectObject(h,!0);for(let o=0;o<s.length;o++)if(s[o].object.visible||e)return s[o];return!1}const B=new i.Euler,c=new i.Vector3(0,1,0),rt=new i.Vector3(0,0,0),at=new i.Matrix4,q=new i.Quaternion,F=new i.Quaternion,v=new i.Vector3,ht=new i.Matrix4,O=new i.Vector3(1,0,0),C=new i.Vector3(0,1,0),X=new i.Vector3(0,0,1),U=new i.Vector3,Q=new i.Vector3,H=new i.Vector3;class At extends i.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new i.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new i.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=t.clone();s.opacity=.15;const o=e.clone();o.opacity=.5;const a=t.clone();a.color.setHex(16711680);const n=t.clone();n.color.setHex(65280);const l=t.clone();l.color.setHex(255);const _=t.clone();_.color.setHex(16711680),_.opacity=.5;const w=t.clone();w.color.setHex(65280),w.opacity=.5;const P=t.clone();P.color.setHex(255),P.opacity=.5;const R=t.clone();R.opacity=.25;const Y=t.clone();Y.color.setHex(16776960),Y.opacity=.25,t.clone().color.setHex(16776960);const j=t.clone();j.color.setHex(7895160);const D=new i.CylinderGeometry(0,.04,.1,12);D.translate(0,.05,0);const E=new i.BoxGeometry(.08,.08,.08);E.translate(0,.04,0);const b=new i.BufferGeometry;b.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,0,0],3));const u=new i.CylinderGeometry(.0075,.0075,.5,3);u.translate(0,.25,0);function f(g,k){const y=new i.TorusGeometry(g,.0075,3,64,k*Math.PI*2);return y.rotateY(Math.PI/2),y.rotateX(Math.PI/2),y}function L(){const g=new i.BufferGeometry;return g.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,1,1],3)),g}const I={X:[[new i.Mesh(D,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(D,a),[-.5,0,0],[0,0,Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new i.Mesh(D,n),[0,.5,0]],[new i.Mesh(D,n),[0,-.5,0],[Math.PI,0,0]],[new i.Mesh(u,n)]],Z:[[new i.Mesh(D,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(D,l),[0,0,-.5],[-Math.PI/2,0,0]],[new i.Mesh(u,l),null,[Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.1,0),R.clone()),[0,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P.clone()),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},pt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.2,0),s)]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},_t={START:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new i.Line(L(),o),null,null,null,"helper"]],X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ut={XYZE:[[new i.Mesh(f(.5,1),j),null,[0,Math.PI/2,0]]],X:[[new i.Mesh(f(.5,.5),a)]],Y:[[new i.Mesh(f(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new i.Mesh(f(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new i.Mesh(f(.75,1),Y),null,[0,Math.PI/2,0]]]},mt={AXIS:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},gt={XYZE:[[new i.Mesh(new i.SphereGeometry(.25,10,8),s)]],X:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new i.Mesh(new i.TorusGeometry(.75,.1,2,24),s)]]},ft={X:[[new i.Mesh(E,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]],[new i.Mesh(E,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(E,n),[0,.5,0]],[new i.Mesh(u,n)],[new i.Mesh(E,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new i.Mesh(E,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(u,l),[0,0,0],[Math.PI/2,0,0]],[new i.Mesh(E,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.1,.1,.1),R.clone())]]},yt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},wt={X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function x(g){const k=new i.Object3D;for(const y in g)for(let z=g[y].length;z--;){const m=g[y][z][0].clone(),V=g[y][z][1],Z=g[y][z][2],W=g[y][z][3],bt=g[y][z][4];m.name=y,m.tag=bt,V&&m.position.set(V[0],V[1],V[2]),Z&&m.rotation.set(Z[0],Z[1],Z[2]),W&&m.scale.set(W[0],W[1],W[2]),m.updateMatrix();const et=m.geometry.clone();et.applyMatrix4(m.matrix),m.geometry=et,m.renderOrder=1/0,m.position.set(0,0,0),m.rotation.set(0,0,0),m.scale.set(1,1,1),k.add(m)}return k}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=x(I)),this.add(this.gizmo.rotate=x(ut)),this.add(this.gizmo.scale=x(ft)),this.add(this.picker.translate=x(pt)),this.add(this.picker.rotate=x(gt)),this.add(this.picker.scale=x(yt)),this.add(this.helper.translate=x(_t)),this.add(this.helper.rotate=x(mt)),this.add(this.helper.scale=x(wt)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:F;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let o=[];o=o.concat(this.picker[this.mode].children),o=o.concat(this.gizmo[this.mode].children),o=o.concat(this.helper[this.mode].children);for(let a=0;a<o.length;a++){const n=o[a];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(l*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(d.setFromEuler(B.set(0,0,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(d.setFromEuler(B.set(0,0,Math.PI/2)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(X).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),c.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(at.lookAt(rt,c,C)),n.quaternion.multiply(d),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),p.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),p.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(p),n.visible=this.dragging):(n.quaternion.copy(s),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(c.copy(X).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(c.copy(X).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(q.copy(s),c.copy(this.eye).applyQuaternion(d.copy(s).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(at.lookAt(this.eye,rt,C)),n.name==="X"&&(d.setFromAxisAngle(O,Math.atan2(-c.y,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Y"&&(d.setFromAxisAngle(C,Math.atan2(c.x,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Z"&&(d.setFromAxisAngle(X,Math.atan2(c.y,c.x)),d.multiplyQuaternions(q,d),n.quaternion.copy(d))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(_){return n.name===_}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(t)}}class Ct extends i.Mesh{constructor(){super(new i.PlaneGeometry(1e5,1e5,2,2),new i.MeshBasicMaterial({visible:!1,wireframe:!0,side:i.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),U.copy(O).applyQuaternion(e==="local"?this.worldQuaternion:F),Q.copy(C).applyQuaternion(e==="local"?this.worldQuaternion:F),H.copy(X).applyQuaternion(e==="local"?this.worldQuaternion:F),c.copy(Q),this.mode){case"translate":case"scale":switch(this.axis){case"X":c.copy(this.eye).cross(U),v.copy(U).cross(c);break;case"Y":c.copy(this.eye).cross(Q),v.copy(Q).cross(c);break;case"Z":c.copy(this.eye).cross(H),v.copy(H).cross(c);break;case"XY":v.copy(H);break;case"YZ":v.copy(U);break;case"XZ":c.copy(H),v.copy(Q);break;case"XYZ":case"E":v.set(0,0,0);break}break;case"rotate":default:v.set(0,0,0)}v.length()===0?this.quaternion.copy(this.cameraQuaternion):(ht.lookAt(p.set(0,0,0),v,c),this.quaternion.setFromRotationMatrix(ht)),super.updateMatrixWorld(t)}}const Lt=h=>h.name==="transform";class J{constructor(t,e,s){r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=t,this._controller=e,this._selectionState=s,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const t=this._selectionState.selected;t&&this.attachGizmo(t)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(t){if(this._gizmo.dragging||t.uiIntersects.length>0&&t.uiIntersects.some(s=>this.isGizmoChild(s.object)))return!0}setGizmoMode(t){this._gizmo.mode=t}setGizmoVisible(t){this._gizmoVisible=t;const e=this._scene.children.includes(this._gizmo);t&&!e?(this._scene.add(this._gizmo),this._gizmo.getRaycaster().layers.enableAll()):!t&&e&&(this._scene.remove(this._gizmo),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(t){this._scaleLinked=t}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmo),this._gizmo.dispose()}onSelectionChange(t){t&&S.implementsInterface(t,"isMovable")?this.attachGizmo(t):this._gizmo.detach()}attachGizmo(t){S.implementsInterface(t,"isMovable")&&(this._gizmo.attach(t),this.setGizmoVisible(t.visible&&this._gizmoVisible))}isGizmoChild(t){let e=t;for(;e;){if(e===this._gizmo)return!0;e=e.parent}return!1}initGizmo(){const t=new Pt(this._controller.object,this._controller.domElement);return t.mode="translate",t.traverse(e=>{if(!("isMesh"in e))return;const s=e.material;e.name==="X"&&s.color.set(G.AxesColorRed),e.name==="Y"&&s.color.set(G.AxesColorGreen),e.name==="Z"&&s.color.set(G.AxesColorBlue),e.name==="XY"&&s.color.set(G.AxesColorBlue),e.name==="YZ"&&s.color.set(G.AxesColorRed),e.name==="XZ"&&s.color.set(G.AxesColorGreen)}),t.addEventListener("mouseDown",()=>{var e,s;this._controller.enabled=!1,S.implementsInterface(t.object,"isMovable")&&((s=(e=t.object).onMoveStart)==null||s.call(e))}),t.addEventListener("objectChange",()=>{var e,s;if(S.implementsInterface(t.object,"isMovable")&&((s=(e=t.object).onMove)==null||s.call(e),this._scaleLinked&&t.object)){const o=t.object.scale,a=(o.x+o.y+o.z)/3;t.object.scale.set(a,a,a)}}),t.addEventListener("mouseUp",()=>{var e,s;this._controller.enabled=!0,S.implementsInterface(t.object,"isMovable")&&((s=(e=t.object).onMoveEnd)==null||s.call(e))}),t}}const zt=.001;class dt{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new i.Vector3);r(this,"_dragCurrent",new i.Vector3);r(this,"_dragEnd",new i.Vector3);r(this,"_dragDelta",new i.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new i.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=S.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>zt&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,o;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(o=(s=this._draggable)==null?void 0:s.onDragStart)==null||o.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,o;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(o=(s=this._draggable)==null?void 0:s.onDrag)==null||o.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const Gt=.001;class Rt{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new lt,this._raycaster=new i.Raycaster,this._pointer=new i.Vector2,this._lastPointerDown=new i.Vector2,this._productLayerMask=new i.Layers,this._productLayerMask.set(Math.log2(M.PRODUCT_LAYER_MASK)),this._uiLayerMask=new i.Layers,this._uiLayerMask.set(Math.log2(M.UI_LAYER_MASK)),this._tools=new Map([["hover",new ct],["select",new $(this._selectionState)],["transform",new J(t,e,this._selectionState)],["drag",new dt(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const o of this._sortedActiveTools)if((s=o.onPointerMove)==null?void 0:s.call(o,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const o of this._sortedActiveTools)if((s=o.onPointerDown)==null?void 0:s.call(o,e))break}onPointerUp(t){var o,a;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((o=n.onPointerUp)==null?void 0:o.call(n,e))break;if(s){for(const n of this._sortedActiveTools)if((a=n.onClick)==null?void 0:a.call(n,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const o of this._sortedActiveTools)if((s=o.onWheel)==null?void 0:s.call(o,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,M.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,M.UI_LAYER_MASK)}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>Gt}useTool(t){const e=["hover","select","transform","drag"];for(const s of e)(s===t||t==="select")&&this.enableTool(s)}getActiveTool(){return this._sortedActiveTools[0]||null}}class Yt{constructor(t,e){r(this,"POINTER_DRAG_THRESHOLD",.001);r(this,"name");r(this,"_canvas");r(this,"_scene");r(this,"_controller");r(this,"_pointer");r(this,"_pointerPrimaryDown");r(this,"_pointerMiddleDown");r(this,"_pointerSecondaryDown");r(this,"_lastPointerDown");r(this,"_lastPointerUp");r(this,"_raycaster");r(this,"_intersects");r(this,"_hovered");r(this,"_dragging");r(this,"_dragStart");r(this,"_dragCurrent");r(this,"_dragEnd");r(this,"_dragDelta");r(this,"_draggable");r(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=e.domElement,this._scene=t,this._controller=e,this._pointer=new i.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new i.Vector2,this._lastPointerUp=new i.Vector2,this._raycaster=new i.Raycaster,this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new i.Vector3,this._dragCurrent=new i.Vector3,this._dragEnd=new i.Vector3,this._dragDelta=new i.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(t){var e;switch(t.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+t.button)}this._lastPointerDown.copy(this._pointer),this._draggable=S.findInterface((e=this._intersects[0])==null?void 0:e.object,"isDraggable")||null}onDragStart(t){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(t){var s;this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const e=S.findInterface((s=this._intersects[0])==null?void 0:s.object,"isHoverable");if(this._intersects[0]&&e){if(!this._hovered){e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}if(this._hovered.uuid!==e.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}e.onPointerOver&&e.onPointerOver(this._intersects[0]),this._hovered=e}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(t),this.onDrag(t))}onDrag(t){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const e=this._intersects[0];e&&(this._dragCurrent.copy(e.point.clone()),this._dragEnd.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(t){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(t):this.onClick(t),t.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(t){}onDragEnd(t){const e=this._intersects[0];e&&(this._dragEnd.copy(e.point.clone()),this._dragCurrent.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(t){}raycast(t){const s=(t||this._scene.children).filter(o=>o.visible&&"isMesh"in o&&o.isMesh);return this._raycaster.intersectObjects(s,!0)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}exports.DIVEBaseTool=Yt;exports.DIVESelectTool=$;exports.DIVETransformTool=J;exports.DragTool=dt;exports.HoverTool=ct;exports.SelectTool=$;exports.SelectionState=lt;exports.Toolbox=Rt;exports.TransformTool=J;exports.isSelectTool=St;exports.isTransformTool=Lt;
1
+ "use strict";var vt=Object.defineProperty;var Mt=(h,e,t)=>e in h?vt(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var r=(h,e,t)=>Mt(h,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("three");require("../../chunks/FileTypes-D3vblaAa.cjs");const M=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),S=require("../../chunks/findInterface-C6mrvf_t.cjs"),j=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class lt{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(e){var t,s,o;this._selected!==e&&(this._selected&&((s=(t=this._selected).onDeselect)==null||s.call(t)),this._selected=e,(o=e.onSelect)==null||o.call(e),this.notifyListeners())}deselect(){var e,t;this._selected&&((t=(e=this._selected).onDeselect)==null||t.call(e),this._selected=null,this.notifyListeners())}onChange(e){this._listeners.add(e)}offChange(e){this._listeners.delete(e)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const e of this._listeners)e(this._selected)}}class ct{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var e,t;this._hovered&&((t=(e=this._hovered).onPointerLeave)==null||t.call(e),this._hovered=null)}onPointerMove(e){var o,a,n,l,_,w,P;const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isHoverable");if(t&&s){if(!this._hovered){(o=s.onPointerEnter)==null||o.call(s,t),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(a=this._hovered).onPointerLeave)==null||n.call(a),(l=s.onPointerEnter)==null||l.call(s,t),this._hovered=s;return}(_=s.onPointerOver)==null||_.call(s,t);return}this._hovered&&((P=(w=this._hovered).onPointerLeave)==null||P.call(w),this._hovered=null)}}const St=h=>h.name==="select";class ${constructor(e){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=e}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(e){const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isSelectable");if(!t||!s){this._selectionState.deselect();return}const o=this._selectionState.selected;o&&o.uuid===s.uuid||this._selectionState.select(s)}select(e){this._selectionState.select(e)}deselect(){this._selectionState.deselect()}}const A=new i.Raycaster,p=new i.Vector3,T=new i.Vector3,d=new i.Quaternion,it={X:new i.Vector3(1,0,0),Y:new i.Vector3(0,1,0),Z:new i.Vector3(0,0,1)},N={type:"change"},st={type:"mouseDown"},nt={type:"mouseUp",mode:null},ot={type:"objectChange"};class Pt extends i.Object3D{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const s=new At;this._gizmo=s,this.add(s);const o=new Ct;this._plane=o,this.add(o);const a=this;function n(u,f){let L=f;Object.defineProperty(a,u,{get:function(){return L!==void 0?L:f},set:function(I){L!==I&&(L=I,o[u]=I,s[u]=I,a.dispatchEvent({type:u+"-changed",value:I}),a.dispatchEvent(N))}}),a[u]=f,o[u]=f,s[u]=f}n("camera",e),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const l=new i.Vector3,_=new i.Vector3,w=new i.Quaternion,P=new i.Quaternion,G=new i.Vector3,R=new i.Quaternion,tt=new i.Vector3,X=new i.Vector3,D=new i.Vector3,E=0,b=new i.Vector3;n("worldPosition",l),n("worldPositionStart",_),n("worldQuaternion",w),n("worldQuaternionStart",P),n("cameraPosition",G),n("cameraQuaternion",R),n("pointStart",tt),n("pointEnd",X),n("rotationAxis",D),n("rotationAngle",E),n("eye",b),this._offset=new i.Vector3,this._startNorm=new i.Vector3,this._endNorm=new i.Vector3,this._cameraScale=new i.Vector3,this._parentPosition=new i.Vector3,this._parentQuaternion=new i.Quaternion,this._parentQuaternionInv=new i.Quaternion,this._parentScale=new i.Vector3,this._worldScaleStart=new i.Vector3,this._worldQuaternionInv=new i.Quaternion,this._worldScale=new i.Vector3,this._positionStart=new i.Vector3,this._quaternionStart=new i.Quaternion,this._scaleStart=new i.Vector3,this._getPointer=Dt.bind(this),this._onPointerDown=xt.bind(this),this._onPointerHover=Et.bind(this),this._onPointerMove=Tt.bind(this),this._onPointerUp=It.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(e){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(e)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&A.setFromCamera(e,this.camera);const t=K(this._gizmo.picker[this.mode],A);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&A.setFromCamera(e,this.camera);const t=K(this._plane,A,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,st.mode=this.mode,this.dispatchEvent(st)}}pointerMove(e){const t=this.axis,s=this.mode,o=this.object;let a=this.space;if(s==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),o===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&A.setFromCamera(e,this.camera);const n=K(this._plane,A,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),o.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(o.position.applyQuaternion(d.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.position.applyQuaternion(this._quaternionStart)),a==="world"&&(o.parent&&o.position.add(p.setFromMatrixPosition(o.parent.matrixWorld)),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.parent&&o.position.sub(p.setFromMatrixPosition(o.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),T.set(l,l,l)}else p.copy(this.pointStart),T.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),T.applyQuaternion(this._worldQuaternionInv),T.divide(p),t.search("X")===-1&&(T.x=1),t.search("Y")===-1&&(T.y=1),t.search("Z")===-1&&(T.z=1);o.scale.copy(this._scaleStart).multiply(T),this.scaleSnap&&(t.search("X")!==-1&&(o.scale.x=Math.round(o.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(o.scale.y=Math.round(o.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(o.scale.z=Math.round(o.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let _=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(it[t]),p.copy(it[t]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?_=!0:this.rotationAngle=this._offset.dot(p.normalize())*l),(t==="E"||_)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&t!=="E"&&t!=="XYZE"?(o.quaternion.copy(this._quaternionStart),o.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),o.quaternion.copy(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),o.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(N),this.dispatchEvent(ot)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(nt.mode=this.mode,this.dispatchEvent(nt)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(N),this.dispatchEvent(ot),this.pointStart.copy(this.pointEnd))}getRaycaster(){return A}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Dt(h){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:h.button};{const e=this.domElement.getBoundingClientRect();return{x:(h.clientX-e.left)/e.width*2-1,y:-(h.clientY-e.top)/e.height*2+1,button:h.button}}}function Et(h){if(this.enabled)switch(h.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(h));break}}function xt(h){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(h.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(h)),this.pointerDown(this._getPointer(h)))}function Tt(h){this.enabled&&this.pointerMove(this._getPointer(h))}function It(h){this.enabled&&(this.domElement.releasePointerCapture(h.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(h)))}function K(h,e,t){const s=e.intersectObject(h,!0);for(let o=0;o<s.length;o++)if(s[o].object.visible||t)return s[o];return!1}const B=new i.Euler,c=new i.Vector3(0,1,0),rt=new i.Vector3(0,0,0),at=new i.Matrix4,q=new i.Quaternion,F=new i.Quaternion,v=new i.Vector3,ht=new i.Matrix4,H=new i.Vector3(1,0,0),C=new i.Vector3(0,1,0),O=new i.Vector3(0,0,1),U=new i.Vector3,Y=new i.Vector3,Q=new i.Vector3;class At extends i.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new i.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new i.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const o=t.clone();o.opacity=.5;const a=e.clone();a.color.setHex(16711680);const n=e.clone();n.color.setHex(65280);const l=e.clone();l.color.setHex(255);const _=e.clone();_.color.setHex(16711680),_.opacity=.5;const w=e.clone();w.color.setHex(65280),w.opacity=.5;const P=e.clone();P.color.setHex(255),P.opacity=.5;const G=e.clone();G.opacity=.25;const R=e.clone();R.color.setHex(16776960),R.opacity=.25,e.clone().color.setHex(16776960);const X=e.clone();X.color.setHex(7895160);const D=new i.CylinderGeometry(0,.04,.1,12);D.translate(0,.05,0);const E=new i.BoxGeometry(.08,.08,.08);E.translate(0,.04,0);const b=new i.BufferGeometry;b.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,0,0],3));const u=new i.CylinderGeometry(.0075,.0075,.5,3);u.translate(0,.25,0);function f(m,k){const y=new i.TorusGeometry(m,.0075,3,64,k*Math.PI*2);return y.rotateY(Math.PI/2),y.rotateX(Math.PI/2),y}function L(){const m=new i.BufferGeometry;return m.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,1,1],3)),m}const I={X:[[new i.Mesh(D,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(D,a),[-.5,0,0],[0,0,Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new i.Mesh(D,n),[0,.5,0]],[new i.Mesh(D,n),[0,-.5,0],[Math.PI,0,0]],[new i.Mesh(u,n)]],Z:[[new i.Mesh(D,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(D,l),[0,0,-.5],[-Math.PI/2,0,0]],[new i.Mesh(u,l),null,[Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.1,0),G.clone()),[0,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P.clone()),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},pt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.2,0),s)]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},_t={START:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new i.Line(L(),o),null,null,null,"helper"]],X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ut={XYZE:[[new i.Mesh(f(.5,1),X),null,[0,Math.PI/2,0]]],X:[[new i.Mesh(f(.5,.5),a)]],Y:[[new i.Mesh(f(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new i.Mesh(f(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new i.Mesh(f(.75,1),R),null,[0,Math.PI/2,0]]]},gt={AXIS:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},mt={XYZE:[[new i.Mesh(new i.SphereGeometry(.25,10,8),s)]],X:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new i.Mesh(new i.TorusGeometry(.75,.1,2,24),s)]]},ft={X:[[new i.Mesh(E,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]],[new i.Mesh(E,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(E,n),[0,.5,0]],[new i.Mesh(u,n)],[new i.Mesh(E,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new i.Mesh(E,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(u,l),[0,0,0],[Math.PI/2,0,0]],[new i.Mesh(E,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.1,.1,.1),G.clone())]]},yt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},wt={X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function x(m){const k=new i.Object3D;for(const y in m)for(let z=m[y].length;z--;){const g=m[y][z][0].clone(),V=m[y][z][1],Z=m[y][z][2],W=m[y][z][3],bt=m[y][z][4];g.name=y,g.tag=bt,V&&g.position.set(V[0],V[1],V[2]),Z&&g.rotation.set(Z[0],Z[1],Z[2]),W&&g.scale.set(W[0],W[1],W[2]),g.updateMatrix();const et=g.geometry.clone();et.applyMatrix4(g.matrix),g.geometry=et,g.renderOrder=1/0,g.position.set(0,0,0),g.rotation.set(0,0,0),g.scale.set(1,1,1),k.add(g)}return k}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=x(I)),this.add(this.gizmo.rotate=x(ut)),this.add(this.gizmo.scale=x(ft)),this.add(this.picker.translate=x(pt)),this.add(this.picker.rotate=x(mt)),this.add(this.picker.scale=x(yt)),this.add(this.helper.translate=x(_t)),this.add(this.helper.rotate=x(gt)),this.add(this.helper.scale=x(wt)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:F;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let o=[];o=o.concat(this.picker[this.mode].children),o=o.concat(this.gizmo[this.mode].children),o=o.concat(this.helper[this.mode].children);for(let a=0;a<o.length;a++){const n=o[a];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(l*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(d.setFromEuler(B.set(0,0,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(d.setFromEuler(B.set(0,0,Math.PI/2)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),c.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(at.lookAt(rt,c,C)),n.quaternion.multiply(d),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),p.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),p.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(p),n.visible=this.dragging):(n.quaternion.copy(s),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(q.copy(s),c.copy(this.eye).applyQuaternion(d.copy(s).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(at.lookAt(this.eye,rt,C)),n.name==="X"&&(d.setFromAxisAngle(H,Math.atan2(-c.y,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Y"&&(d.setFromAxisAngle(C,Math.atan2(c.x,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Z"&&(d.setFromAxisAngle(O,Math.atan2(c.y,c.x)),d.multiplyQuaternions(q,d),n.quaternion.copy(d))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(_){return n.name===_}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(e)}}class Ct extends i.Mesh{constructor(){super(new i.PlaneGeometry(1e5,1e5,2,2),new i.MeshBasicMaterial({visible:!1,wireframe:!0,side:i.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),U.copy(H).applyQuaternion(t==="local"?this.worldQuaternion:F),Y.copy(C).applyQuaternion(t==="local"?this.worldQuaternion:F),Q.copy(O).applyQuaternion(t==="local"?this.worldQuaternion:F),c.copy(Y),this.mode){case"translate":case"scale":switch(this.axis){case"X":c.copy(this.eye).cross(U),v.copy(U).cross(c);break;case"Y":c.copy(this.eye).cross(Y),v.copy(Y).cross(c);break;case"Z":c.copy(this.eye).cross(Q),v.copy(Q).cross(c);break;case"XY":v.copy(Q);break;case"YZ":v.copy(U);break;case"XZ":c.copy(Q),v.copy(Y);break;case"XYZ":case"E":v.set(0,0,0);break}break;case"rotate":default:v.set(0,0,0)}v.length()===0?this.quaternion.copy(this.cameraQuaternion):(ht.lookAt(p.set(0,0,0),v,c),this.quaternion.setFromRotationMatrix(ht)),super.updateMatrixWorld(e)}}const Lt=h=>h.name==="transform";class J extends i.EventDispatcher{constructor(t,s,o){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=t,this._controller=s,this._selectionState=o,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const t=this._selectionState.selected;t&&this.attachGizmo(t)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(t){if(this._gizmo.dragging||t.uiIntersects.length>0&&t.uiIntersects.some(o=>this.isGizmoChild(o.object)))return!0}setGizmoMode(t){this._gizmo.mode=t}setGizmoVisible(t){this._gizmoVisible=t;const s=this._scene.children.includes(this._gizmo);t&&!s?(this._scene.add(this._gizmo),this._gizmo.getRaycaster().layers.enableAll()):!t&&s&&(this._scene.remove(this._gizmo),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(t){this._scaleLinked=t}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmo),this._gizmo.dispose()}onSelectionChange(t){t&&S.implementsInterface(t,"isMovable")?this.attachGizmo(t):this._gizmo.detach()}attachGizmo(t){S.implementsInterface(t,"isMovable")&&(this._gizmo.attach(t),this.setGizmoVisible(t.visible&&this._gizmoVisible))}isGizmoChild(t){let s=t;for(;s;){if(s===this._gizmo)return!0;s=s.parent}return!1}initGizmo(){const t=new Pt(this._controller.object,this._controller.domElement);return t.mode="translate",t.traverse(s=>{if(!("isMesh"in s))return;const o=s.material;s.name==="X"&&o.color.set(j.AxesColorRed),s.name==="Y"&&o.color.set(j.AxesColorGreen),s.name==="Z"&&o.color.set(j.AxesColorBlue),s.name==="XY"&&o.color.set(j.AxesColorBlue),s.name==="YZ"&&o.color.set(j.AxesColorRed),s.name==="XZ"&&o.color.set(j.AxesColorGreen)}),t.addEventListener("mouseDown",()=>{var s,o;this._controller.enabled=!1,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveStart)==null||o.call(s))}),t.addEventListener("objectChange",()=>{var s,o;if(S.implementsInterface(t.object,"isMovable")){if((o=(s=t.object).onMove)==null||o.call(s),this._scaleLinked&&t.object){const a=t.object.scale,n=(a.x+a.y+a.z)/3;t.object.scale.set(n,n,n)}switch(this.dispatchEvent({type:"object-change",object:t.object}),t.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:t.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:t.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:t.object});break}}}),t.addEventListener("mouseUp",()=>{var s,o;this._controller.enabled=!0,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveEnd)==null||o.call(s))}),t}}const zt=.001;class dt{constructor(e){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new i.Vector3);r(this,"_dragCurrent",new i.Vector3);r(this,"_dragEnd",new i.Vector3);r(this,"_dragDelta",new i.Vector3);r(this,"_dragRaycastTargets",null);this._controller=e,this._raycaster=new i.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(e){var t;e.pointerPrimaryDown&&(this._draggable=S.findInterface((t=e.intersects[0])==null?void 0:t.object,"isDraggable")||null)}onPointerMove(e){if(e.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this._dragging||e.lastPointerDown.distanceTo(e.pointer)>zt&&this.startDrag(e),this._dragging))return this.updateDrag(e),!0}onPointerUp(e){this._dragging&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(e){this._dragRaycastTargets=e}startDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragStart.copy(t.point),this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.set(0,0,0),(o=(s=this._draggable)==null?void 0:s.onDragStart)==null||o.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(o=(s=this._draggable)==null?void 0:s.onDrag)==null||o.call(s,this.createDragEvent()))}endDrag(){var t,s;const e=this.createDragEvent();(s=(t=this._draggable)==null?void 0:t.onDragEnd)==null||s.call(t,e),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(e){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:e.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const jt=.001;class Gt{constructor(e,t){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=e,this._controller=t,this._canvas=t.domElement,this._selectionState=new lt,this._raycaster=new i.Raycaster,this._pointer=new i.Vector2,this._lastPointerDown=new i.Vector2,this._productLayerMask=new i.Layers,this._productLayerMask.set(Math.log2(M.PRODUCT_LAYER_MASK)),this._uiLayerMask=new i.Layers,this._uiLayerMask.set(Math.log2(M.UI_LAYER_MASK)),this._tools=new Map([["hover",new ct],["select",new $(this._selectionState)],["transform",new J(e,t,this._selectionState)],["drag",new dt(t)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(e){var s;const t=this._tools.get(e);t&&(this._activeTools.has(e)||(this._activeTools.set(e,t),this.updateSortedTools(),(s=t.onActivate)==null||s.call(t)))}disableTool(e){var s;const t=this._activeTools.get(e);t&&((s=t.onDeactivate)==null||s.call(t),this._activeTools.delete(e),this.updateSortedTools())}isToolEnabled(e){return this._activeTools.has(e)}getTool(e){return this._tools.get(e)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var e;for(const t of this._activeTools.values())(e=t.onDeactivate)==null||e.call(t);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(e){var s;this.updatePointer(e);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerMove)==null?void 0:s.call(o,t))break}onPointerDown(e){var s;this.updatePointerState(e,!0),this.updatePointer(e),this._lastPointerDown.copy(this._pointer);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerDown)==null?void 0:s.call(o,t))break}onPointerUp(e){var o,a;this.updatePointer(e);const t=this.createPointerContext(e),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((o=n.onPointerUp)==null?void 0:o.call(n,t))break;if(s){for(const n of this._sortedActiveTools)if((a=n.onClick)==null?void 0:a.call(n,t))break}this.updatePointerState(e,!1)}onWheel(e){var s;const t=this.createWheelContext(e);for(const o of this._sortedActiveTools)if((s=o.onWheel)==null?void 0:s.call(o,t))break}createPointerContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK)}}updatePointer(e){this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(e,t){switch(e.button){case 0:this._pointerPrimaryDown=t;break;case 1:this._pointerMiddleDown=t;break;case 2:this._pointerSecondaryDown=t;break}}raycast(){this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK;const e=this._scene.children.filter(t=>t.visible&&"isMesh"in t&&t.isMesh);return this._raycaster.intersectObjects(e,!0)}filterIntersectsByLayer(e,t){return e.filter(s=>(s.object.layers.mask&t)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((e,t)=>e.priority-t.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>jt}useTool(e){const t=["hover","select","transform","drag"];for(const s of t)(s===e||e==="select")&&this.enableTool(s)}getActiveTool(){return this._sortedActiveTools[0]||null}}class Rt{constructor(e,t){r(this,"POINTER_DRAG_THRESHOLD",.001);r(this,"name");r(this,"_canvas");r(this,"_scene");r(this,"_controller");r(this,"_pointer");r(this,"_pointerPrimaryDown");r(this,"_pointerMiddleDown");r(this,"_pointerSecondaryDown");r(this,"_lastPointerDown");r(this,"_lastPointerUp");r(this,"_raycaster");r(this,"_intersects");r(this,"_hovered");r(this,"_dragging");r(this,"_dragStart");r(this,"_dragCurrent");r(this,"_dragEnd");r(this,"_dragDelta");r(this,"_draggable");r(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=t.domElement,this._scene=e,this._controller=t,this._pointer=new i.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new i.Vector2,this._lastPointerUp=new i.Vector2,this._raycaster=new i.Raycaster,this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new i.Vector3,this._dragCurrent=new i.Vector3,this._dragEnd=new i.Vector3,this._dragDelta=new i.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(e){var t;switch(e.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+e.button)}this._lastPointerDown.copy(this._pointer),this._draggable=S.findInterface((t=this._intersects[0])==null?void 0:t.object,"isDraggable")||null}onDragStart(e){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(e){var s;this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const t=S.findInterface((s=this._intersects[0])==null?void 0:s.object,"isHoverable");if(this._intersects[0]&&t){if(!this._hovered){t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}if(this._hovered.uuid!==t.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}t.onPointerOver&&t.onPointerOver(this._intersects[0]),this._hovered=t}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(e),this.onDrag(e))}onDrag(e){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const t=this._intersects[0];t&&(this._dragCurrent.copy(t.point.clone()),this._dragEnd.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(e){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(e):this.onClick(e),e.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(e){}onDragEnd(e){const t=this._intersects[0];t&&(this._dragEnd.copy(t.point.clone()),this._dragCurrent.copy(t.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(e){}raycast(e){const s=(e||this._scene.children).filter(o=>o.visible&&"isMesh"in o&&o.isMesh);return this._raycaster.intersectObjects(s,!0)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}exports.DIVEBaseTool=Rt;exports.DIVESelectTool=$;exports.DIVETransformTool=J;exports.DragTool=dt;exports.HoverTool=ct;exports.SelectTool=$;exports.SelectionState=lt;exports.Toolbox=Gt;exports.TransformTool=J;exports.isSelectTool=St;exports.isTransformTool=Lt;