@shopware-ag/dive 2.3.7 → 3.0.0-beta.0

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 (142) hide show
  1. package/build/chunks/Animator-DHnpWRt_.mjs +16 -0
  2. package/build/chunks/Animator-YDE8aFEd.cjs +1 -0
  3. package/build/chunks/{AssetCache-DSpWOp3n.mjs → AssetCache-C2DuXcmp.mjs} +6 -5
  4. package/build/chunks/AssetCache-CnbDDhU8.cjs +1 -0
  5. package/build/chunks/AssetExporter-Cdxb04b3.cjs +1 -0
  6. package/build/chunks/AssetExporter-DLL_vJae.mjs +67 -0
  7. package/build/chunks/AssetLoader-DO7xlbC3.mjs +499 -0
  8. package/build/chunks/AssetLoader-h2uyFEfZ.cjs +3 -0
  9. package/build/chunks/{ClipAnimator-keFLDMNZ.mjs → ClipAnimator-D8Gho4Ec.mjs} +2 -2
  10. package/build/chunks/ClipAnimator-SdDq2wk1.cjs +1 -0
  11. package/build/chunks/FileTypes-BB4_1gBJ.mjs +1975 -0
  12. package/build/chunks/FileTypes-Bvt5QTJC.cjs +29 -0
  13. package/build/chunks/GridNode-0R5ZnzR6.mjs +30 -0
  14. package/build/chunks/GridNode-iqnu86_v.cjs +1 -0
  15. package/build/chunks/{PerspectiveCamera-BFzE2TQU.mjs → PerspectiveCamera-B5TvUzTa.mjs} +1 -1
  16. package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +1 -0
  17. package/build/chunks/{TargetAnimator-DuqPk2eq.cjs → TargetAnimator-D37bWNKD.cjs} +1 -1
  18. package/build/chunks/{TargetAnimator-DUqkkdVb.mjs → TargetAnimator-DL_9b921.mjs} +1 -1
  19. package/build/chunks/{isFileTypeSupported-zLrD710P.mjs → isFileTypeSupported-D1z0zckw.mjs} +1 -1
  20. package/build/chunks/{isFileTypeSupported-Bh5Scxis.cjs → isFileTypeSupported-MJWHcUsR.cjs} +1 -1
  21. package/build/components/boundingbox/BoundingBox.d.ts +1 -1
  22. package/build/components/floor/Floor.d.ts +1 -1
  23. package/build/components/gizmo/Gizmo.d.ts +1 -1
  24. package/build/components/gizmo/handles/AxisHandle.d.ts +1 -1
  25. package/build/components/gizmo/handles/RadialHandle.d.ts +1 -1
  26. package/build/components/gizmo/handles/ScaleHandle.d.ts +1 -1
  27. package/build/components/gizmo/plane/GizmoPlane.d.ts +1 -1
  28. package/build/components/gizmo/rotate/RotateGizmo.d.ts +1 -1
  29. package/build/components/gizmo/scale/ScaleGizmo.d.ts +1 -1
  30. package/build/components/gizmo/translate/TranslateGizmo.d.ts +1 -1
  31. package/build/components/grid/Grid.d.ts +2 -1
  32. package/build/components/group/Group.d.ts +1 -1
  33. package/build/components/light/AmbientLight.d.ts +1 -1
  34. package/build/components/light/PointLight.d.ts +1 -1
  35. package/build/components/light/SceneLight.d.ts +1 -1
  36. package/build/components/model/Model.d.ts +1 -1
  37. package/build/components/node/Node.d.ts +1 -1
  38. package/build/components/primitive/Primitive.d.ts +1 -1
  39. package/build/components/root/Root.d.ts +1 -1
  40. package/build/dive.cjs +1 -1
  41. package/build/dive.mjs +58 -60
  42. package/build/engine/Dive.d.ts +3 -31
  43. package/build/engine/camera/PerspectiveCamera.d.ts +1 -1
  44. package/build/engine/environment/Environment.d.ts +12 -27
  45. package/build/engine/renderer/Renderer.d.ts +7 -8
  46. package/build/engine/scene/Scene.d.ts +1 -1
  47. package/build/engine/scene/xrroot/XRRoot.d.ts +2 -3
  48. package/build/engine/scene/xrroot/xrlightroot/XRLightRoot.d.ts +3 -3
  49. package/build/helpers/findInterface/findInterface.d.ts +1 -1
  50. package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +1 -1
  51. package/build/helpers/implementsInterface/implementsInterface.d.ts +1 -1
  52. package/build/helpers/math/signedAngleTo/signedAngleTo.d.ts +1 -1
  53. package/build/interfaces/Hoverable.d.ts +1 -1
  54. package/build/plugins/animation/index.cjs +1 -1
  55. package/build/plugins/animation/index.mjs +12 -20
  56. package/build/plugins/animation/src/animator/Animator.d.ts +1 -1
  57. package/build/plugins/animation/src/animator/ClipAnimator.d.ts +1 -1
  58. package/build/plugins/animation/src/system/AnimationSystem.d.ts +1 -6
  59. package/build/plugins/animation/src/types/AnimatorTypes.d.ts +1 -1
  60. package/build/plugins/ar/index.cjs +1 -1
  61. package/build/plugins/ar/index.mjs +5 -4
  62. package/build/plugins/ar/src/webxr/controller/WebXRController.d.ts +1 -1
  63. package/build/plugins/ar/src/webxr/crosshair/WebXRCrosshair.d.ts +1 -1
  64. package/build/plugins/ar/src/webxr/origin/WebXROrigin.d.ts +1 -1
  65. package/build/plugins/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +1 -1
  66. package/build/plugins/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
  67. package/build/plugins/assetcache/index.cjs +1 -1
  68. package/build/plugins/assetcache/index.mjs +1 -1
  69. package/build/plugins/assetexporter/index.cjs +1 -1
  70. package/build/plugins/assetexporter/index.mjs +1 -1
  71. package/build/plugins/assetexporter/src/AssetExporter.d.ts +1 -1
  72. package/build/plugins/assetloader/index.cjs +1 -1
  73. package/build/plugins/assetloader/index.mjs +2 -2
  74. package/build/plugins/assetloader/src/loader/AssetLoader.d.ts +2 -2
  75. package/build/plugins/assetloader/src/step/STEPLoader.d.ts +1 -1
  76. package/build/plugins/mediacreator/index.cjs +1 -1
  77. package/build/plugins/mediacreator/index.mjs +52 -24
  78. package/build/plugins/mediacreator/src/MediaCreator.d.ts +4 -3
  79. package/build/plugins/mediacreator/types/MediaGenerationByPosition.d.ts +1 -1
  80. package/build/plugins/orbitcontroller/index.cjs +1 -1
  81. package/build/plugins/orbitcontroller/index.mjs +1 -1
  82. package/build/plugins/orbitcontroller/src/OrbitController.d.ts +1 -1
  83. package/build/plugins/orbitcontroller/types/OrbitControllerState.types.d.ts +1 -1
  84. package/build/plugins/orientationdisplay/index.cjs +1 -1
  85. package/build/plugins/orientationdisplay/index.mjs +17 -16
  86. package/build/plugins/orientationdisplay/src/axes/Axes.d.ts +1 -1
  87. package/build/plugins/quickview/index.cjs +1 -1
  88. package/build/plugins/quickview/index.mjs +9 -8
  89. package/build/plugins/shader/index.cjs +1 -1
  90. package/build/plugins/shader/index.mjs +2 -3
  91. package/build/plugins/shader/src/index.d.ts +1 -3
  92. package/build/plugins/shader/src/shaders/GridNode.d.ts +16 -0
  93. package/build/plugins/state/index.cjs +11 -11
  94. package/build/plugins/state/index.mjs +1538 -1537
  95. package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
  96. package/build/plugins/state/src/actions/camera/getcameratransform.d.ts +1 -1
  97. package/build/plugins/state/src/actions/camera/movecamera.d.ts +1 -1
  98. package/build/plugins/state/src/actions/camera/setcameratransform.d.ts +1 -1
  99. package/build/plugins/state/types/StateSceneData.d.ts +1 -1
  100. package/build/plugins/toolbox/index.cjs +1 -1
  101. package/build/plugins/toolbox/index.d.ts +0 -1
  102. package/build/plugins/toolbox/index.mjs +224 -853
  103. package/build/plugins/toolbox/src/PointerContext.d.ts +1 -1
  104. package/build/plugins/toolbox/src/SelectionState.d.ts +1 -1
  105. package/build/plugins/toolbox/src/Toolbox.d.ts +0 -10
  106. package/build/plugins/toolbox/src/drag/DragTool.d.ts +1 -1
  107. package/build/plugins/toolbox/src/drag/DraggableEvent.d.ts +1 -1
  108. package/build/plugins/toolbox/src/hover/HoverTool.d.ts +1 -1
  109. package/build/plugins/toolbox/src/select/SelectTool.d.ts +1 -1
  110. package/build/plugins/toolbox/src/transform/TransformTool.d.ts +2 -1
  111. package/build/types/schema/GroupSchema.d.ts +1 -1
  112. package/build/types/schema/LightSchema.d.ts +1 -1
  113. package/build/types/schema/MaterialSchema.d.ts +1 -1
  114. package/build/types/schema/ModelSchema.d.ts +1 -1
  115. package/build/types/schema/PovSchema.d.ts +1 -1
  116. package/build/types/schema/PrimitiveSchema.d.ts +1 -1
  117. package/package.json +5 -4
  118. package/build/chunks/Animator-BGFdF70Z.mjs +0 -47
  119. package/build/chunks/Animator-Cu7NIkVg.cjs +0 -1
  120. package/build/chunks/AssetCache-DJyYrAdR.cjs +0 -1
  121. package/build/chunks/AssetExporter-PFiNYi50.mjs +0 -1628
  122. package/build/chunks/AssetExporter-yVhYmVXW.cjs +0 -164
  123. package/build/chunks/AssetLoader-BA_QwJMR.mjs +0 -2590
  124. package/build/chunks/AssetLoader-DJb8P6eB.cjs +0 -5
  125. package/build/chunks/ClipAnimator-tjhLo851.cjs +0 -1
  126. package/build/chunks/DIVEShaderMaterial-Bt0d8oJB.mjs +0 -3468
  127. package/build/chunks/DIVEShaderMaterial-DE8YRWj9.cjs +0 -1554
  128. package/build/chunks/FileTypes-BSJhZREN.cjs +0 -33
  129. package/build/chunks/FileTypes-CUf24rq6.mjs +0 -2155
  130. package/build/chunks/PerspectiveCamera-iAsZqrnY.cjs +0 -1
  131. package/build/chunks/draco_decoder-Bh9flJPu.cjs +0 -1
  132. package/build/chunks/draco_decoder-CEzwqP9o.mjs +0 -38
  133. package/build/chunks/draco_decoder-DtHHc5d0.mjs +0 -4
  134. package/build/chunks/draco_decoder-DvYjcLz_.cjs +0 -35
  135. package/build/chunks/draco_wasm_wrapper-FoEVV9af.cjs +0 -118
  136. package/build/chunks/draco_wasm_wrapper-yQy2VLhb.mjs +0 -121
  137. package/build/chunks/fflate.module-DHdJvhNh.cjs +0 -6
  138. package/build/chunks/fflate.module-xyO_T3Zm.mjs +0 -602
  139. package/build/plugins/shader/src/material/DIVEShaderMaterial.d.ts +0 -5
  140. package/build/plugins/shader/src/shaders/DIVEShaderLib.d.ts +0 -2
  141. package/build/plugins/shader/src/shaders/grid/index.d.ts +0 -40
  142. package/build/plugins/toolbox/src/BaseTool.d.ts +0 -59
@@ -1,5 +1,5 @@
1
1
  import { Action } from '../action.ts';
2
- import { Vector3Like } from 'three';
2
+ import { Vector3Like } from 'three/webgpu';
3
3
  import { ActionDependencies } from '../../../types/index.ts';
4
4
  export declare const ComputeEncompassingViewAction: new (payload: void, dependencies: Pick<ActionDependencies, "engine" | "controller">) => Action<void, Pick<ActionDependencies, "engine" | "controller">, {
5
5
  position: Vector3Like;
@@ -1,6 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
- import { Vector3Like } from 'three';
3
+ import { Vector3Like } from 'three/webgpu';
4
4
  export declare const GetCameraTransformAction: new (payload: void, dependencies: Pick<ActionDependencies, "controller">) => Action<void, Pick<ActionDependencies, "controller">, {
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
@@ -1,6 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
- import { Vector3Like } from 'three';
3
+ import { Vector3Like } from 'three/webgpu';
4
4
  export declare const MoveCameraAction: new (payload: {
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
@@ -1,6 +1,6 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
- import { Vector3Like } from 'three';
3
+ import { Vector3Like } from 'three/webgpu';
4
4
  export declare const SetCameraTransformAction: new (payload: {
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
@@ -1,4 +1,4 @@
1
- import { Vector3Like } from 'three';
1
+ import { Vector3Like } from 'three/webgpu';
2
2
  import { GroupSchema, LightSchema, ModelSchema, PovSchema, PrimitiveSchema } from '../../../index.ts';
3
3
  export type StateSceneData = {
4
4
  name: string;
@@ -1 +1 @@
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-BSJhZREN.cjs");const M=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs");require("../../chunks/DIVEShaderMaterial-DE8YRWj9.cjs");const 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;
1
+ "use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-Bvt5QTJC.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.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 b{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 i,o,a,l,p,f,v;const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.name==="select";class g{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=_.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=n=>n.name==="transform";class u extends c.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging||e.uiIntersects.length>0&&e.uiIntersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object,this._controller.domElement);return e.mode="translate",e.getHelper().traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.001;class D{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 c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.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=_.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)>C&&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,i;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),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.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 E=.001;class M{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 m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(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 i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,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 i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.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,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.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=h.PRODUCT_LAYER_MASK|h.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)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
@@ -7,7 +7,6 @@ export * from './src/select/SelectTool.ts';
7
7
  export * from './src/transform/TransformTool.ts';
8
8
  export * from './src/drag/DragTool.ts';
9
9
  export * from './src/drag/DraggableEvent.ts';
10
- export { DIVEBaseTool } from './src/BaseTool.ts';
11
10
  export { SelectTool as DIVESelectTool } from './src/select/SelectTool.ts';
12
11
  export { TransformTool as DIVETransformTool } from './src/transform/TransformTool.ts';
13
12
  export * from './types/index.ts';