three-stdlib 2.9.1 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/controls/DragControls.cjs.js +1 -1
  2. package/controls/DragControls.d.ts +2 -1
  3. package/controls/DragControls.js +2 -0
  4. package/controls/TransformControls.cjs.js +1 -1
  5. package/controls/TransformControls.d.ts +1 -0
  6. package/controls/TransformControls.js +17 -0
  7. package/index.cjs.js +1 -1
  8. package/index.js +1 -1
  9. package/objects/MarchingCubes.cjs.js +1 -1
  10. package/objects/MarchingCubes.js +49 -109
  11. package/package.json +1 -1
  12. package/postprocessing/BloomPass.cjs.js +1 -1
  13. package/postprocessing/BloomPass.d.ts +12 -10
  14. package/postprocessing/BloomPass.js +93 -58
  15. package/postprocessing/BokehPass.cjs.js +1 -1
  16. package/postprocessing/BokehPass.d.ts +12 -14
  17. package/postprocessing/BokehPass.js +70 -55
  18. package/postprocessing/ClearPass.cjs.js +1 -1
  19. package/postprocessing/ClearPass.d.ts +6 -5
  20. package/postprocessing/ClearPass.js +21 -12
  21. package/postprocessing/DotScreenPass.cjs.js +1 -1
  22. package/postprocessing/DotScreenPass.d.ts +8 -8
  23. package/postprocessing/DotScreenPass.js +29 -20
  24. package/postprocessing/FilmPass.cjs.js +1 -1
  25. package/postprocessing/FilmPass.d.ts +8 -8
  26. package/postprocessing/FilmPass.js +30 -23
  27. package/postprocessing/GlitchPass.cjs.js +1 -1
  28. package/postprocessing/GlitchPass.d.ts +8 -9
  29. package/postprocessing/GlitchPass.js +15 -1
  30. package/postprocessing/HalftonePass.cjs.js +1 -1
  31. package/postprocessing/HalftonePass.d.ts +13 -13
  32. package/postprocessing/HalftonePass.js +35 -26
  33. package/postprocessing/OutlinePass.cjs.js +1 -1
  34. package/postprocessing/OutlinePass.d.ts +15 -26
  35. package/postprocessing/OutlinePass.js +317 -220
  36. package/utils/GeometryUtils.cjs.js +1 -1
  37. package/utils/GeometryUtils.d.ts +5 -26
  38. package/utils/GeometryUtils.js +29 -43
  39. package/utils/SceneUtils.cjs.js +1 -1
  40. package/utils/SceneUtils.d.ts +9 -12
  41. package/utils/SceneUtils.js +7 -7
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);class o extends e.EventDispatcher{constructor(t,s,o){super(),i.default(this,"enabled",!0),i.default(this,"transformGroup",!1),i.default(this,"_objects",void 0),i.default(this,"_camera",void 0),i.default(this,"_domElement",void 0),i.default(this,"_plane",new e.Plane),i.default(this,"_raycaster",new e.Raycaster),i.default(this,"_mouse",new e.Vector2),i.default(this,"_offset",new e.Vector3),i.default(this,"_intersection",new e.Vector3),i.default(this,"_worldPosition",new e.Vector3),i.default(this,"_inverseMatrix",new e.Matrix4),i.default(this,"_intersections",[]),i.default(this,"_selected",null),i.default(this,"_hovered",null),i.default(this,"activate",(()=>{this._domElement.addEventListener("pointermove",this.onPointerMove),this._domElement.addEventListener("pointerdown",this.onPointerDown),this._domElement.addEventListener("pointerup",this.onPointerCancel),this._domElement.addEventListener("pointerleave",this.onPointerCancel),this._domElement.addEventListener("touchmove",this.onTouchMove),this._domElement.addEventListener("touchstart",this.onTouchStart),this._domElement.addEventListener("touchend",this.onTouchEnd)})),i.default(this,"deactivate",(()=>{this._domElement.removeEventListener("pointermove",this.onPointerMove),this._domElement.removeEventListener("pointerdown",this.onPointerDown),this._domElement.removeEventListener("pointerup",this.onPointerCancel),this._domElement.removeEventListener("pointerleave",this.onPointerCancel),this._domElement.removeEventListener("touchmove",this.onTouchMove),this._domElement.removeEventListener("touchstart",this.onTouchStart),this._domElement.removeEventListener("touchend",this.onTouchEnd),this._domElement.style.cursor=""})),i.default(this,"dispose",(()=>this.deactivate())),i.default(this,"getObjects",(()=>this._objects)),i.default(this,"onMouseMove",(t=>{const e=this._domElement.getBoundingClientRect();if(this._mouse.x=(t.clientX-e.left)/e.width*2-1,this._mouse.y=-(t.clientY-e.top)/e.height*2+1,this._raycaster.setFromCamera(this._mouse,this._camera),this._selected&&this.enabled)return this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix)),void this.dispatchEvent({type:"drag",object:this._selected});if(this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0){const t=this._intersections[0].object;this._plane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._plane.normal),this._worldPosition.setFromMatrixPosition(t.matrixWorld)),this._hovered!==t&&(this.dispatchEvent({type:"hoveron",object:t}),this._domElement.style.cursor="pointer",this._hovered=t)}else null!==this._hovered&&(this.dispatchEvent({type:"hoveroff",object:this._hovered}),this._domElement.style.cursor="auto",this._hovered=null)})),i.default(this,"onMouseDown",(()=>{this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0&&(this._selected=!0===this.transformGroup?this._objects[0]:this._intersections[0].object,this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._offset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))),this._domElement.style.cursor="move",this.dispatchEvent({type:"dragstart",object:this._selected}))})),i.default(this,"onMouseCancel",(()=>{this._selected&&(this.dispatchEvent({type:"dragend",object:this._selected}),this._selected=null),this._domElement.style.cursor=this._hovered?"pointer":"auto"})),i.default(this,"onPointerMove",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseMove(t)}})),i.default(this,"onPointerDown",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseDown()}})),i.default(this,"onPointerCancel",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseCancel()}})),i.default(this,"onTouchMove",(t=>{t.preventDefault();const e=t.changedTouches[0],s=this._domElement.getBoundingClientRect();if(this._mouse.x=(e.clientX-s.left)/s.width*2-1,this._mouse.y=-(e.clientY-s.top)/s.height*2+1,this._raycaster.setFromCamera(this._mouse,this._camera),this._selected&&this.enabled)return this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix)),void this.dispatchEvent({type:"drag",object:this._selected})})),i.default(this,"onTouchStart",(t=>{t.preventDefault();const e=t.changedTouches[0],s=this._domElement.getBoundingClientRect();this._mouse.x=(e.clientX-s.left)/s.width*2-1,this._mouse.y=-(e.clientY-s.top)/s.height*2+1,this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0&&(this._selected=!0===this.transformGroup?this._objects[0]:this._intersections[0].object,this._plane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._plane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._offset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))),this._domElement.style.cursor="move",this.dispatchEvent({type:"dragstart",object:this._selected}))})),i.default(this,"onTouchEnd",(t=>{t.preventDefault(),this._selected&&(this.dispatchEvent({type:"dragend",object:this._selected}),this._selected=null),this._domElement.style.cursor="auto"})),this._objects=t,this._camera=s,this._domElement=o,this.activate()}}exports.DragControls=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);class o extends e.EventDispatcher{constructor(t,s,o){super(),i.default(this,"enabled",!0),i.default(this,"transformGroup",!1),i.default(this,"_objects",void 0),i.default(this,"_camera",void 0),i.default(this,"_domElement",void 0),i.default(this,"_plane",new e.Plane),i.default(this,"_raycaster",new e.Raycaster),i.default(this,"_mouse",new e.Vector2),i.default(this,"_offset",new e.Vector3),i.default(this,"_intersection",new e.Vector3),i.default(this,"_worldPosition",new e.Vector3),i.default(this,"_inverseMatrix",new e.Matrix4),i.default(this,"_intersections",[]),i.default(this,"_selected",null),i.default(this,"_hovered",null),i.default(this,"activate",(()=>{this._domElement.addEventListener("pointermove",this.onPointerMove),this._domElement.addEventListener("pointerdown",this.onPointerDown),this._domElement.addEventListener("pointerup",this.onPointerCancel),this._domElement.addEventListener("pointerleave",this.onPointerCancel),this._domElement.addEventListener("touchmove",this.onTouchMove),this._domElement.addEventListener("touchstart",this.onTouchStart),this._domElement.addEventListener("touchend",this.onTouchEnd)})),i.default(this,"deactivate",(()=>{this._domElement.removeEventListener("pointermove",this.onPointerMove),this._domElement.removeEventListener("pointerdown",this.onPointerDown),this._domElement.removeEventListener("pointerup",this.onPointerCancel),this._domElement.removeEventListener("pointerleave",this.onPointerCancel),this._domElement.removeEventListener("touchmove",this.onTouchMove),this._domElement.removeEventListener("touchstart",this.onTouchStart),this._domElement.removeEventListener("touchend",this.onTouchEnd),this._domElement.style.cursor=""})),i.default(this,"dispose",(()=>this.deactivate())),i.default(this,"getObjects",(()=>this._objects)),i.default(this,"getRaycaster",(()=>this._raycaster)),i.default(this,"onMouseMove",(t=>{const e=this._domElement.getBoundingClientRect();if(this._mouse.x=(t.clientX-e.left)/e.width*2-1,this._mouse.y=-(t.clientY-e.top)/e.height*2+1,this._raycaster.setFromCamera(this._mouse,this._camera),this._selected&&this.enabled)return this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix)),void this.dispatchEvent({type:"drag",object:this._selected});if(this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0){const t=this._intersections[0].object;this._plane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._plane.normal),this._worldPosition.setFromMatrixPosition(t.matrixWorld)),this._hovered!==t&&(this.dispatchEvent({type:"hoveron",object:t}),this._domElement.style.cursor="pointer",this._hovered=t)}else null!==this._hovered&&(this.dispatchEvent({type:"hoveroff",object:this._hovered}),this._domElement.style.cursor="auto",this._hovered=null)})),i.default(this,"onMouseDown",(()=>{this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0&&(this._selected=!0===this.transformGroup?this._objects[0]:this._intersections[0].object,this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._offset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))),this._domElement.style.cursor="move",this.dispatchEvent({type:"dragstart",object:this._selected}))})),i.default(this,"onMouseCancel",(()=>{this._selected&&(this.dispatchEvent({type:"dragend",object:this._selected}),this._selected=null),this._domElement.style.cursor=this._hovered?"pointer":"auto"})),i.default(this,"onPointerMove",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseMove(t)}})),i.default(this,"onPointerDown",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseDown()}})),i.default(this,"onPointerCancel",(t=>{switch(t.pointerType){case"mouse":case"pen":this.onMouseCancel()}})),i.default(this,"onTouchMove",(t=>{t.preventDefault();const e=t.changedTouches[0],s=this._domElement.getBoundingClientRect();if(this._mouse.x=(e.clientX-s.left)/s.width*2-1,this._mouse.y=-(e.clientY-s.top)/s.height*2+1,this._raycaster.setFromCamera(this._mouse,this._camera),this._selected&&this.enabled)return this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix)),void this.dispatchEvent({type:"drag",object:this._selected})})),i.default(this,"onTouchStart",(t=>{t.preventDefault();const e=t.changedTouches[0],s=this._domElement.getBoundingClientRect();this._mouse.x=(e.clientX-s.left)/s.width*2-1,this._mouse.y=-(e.clientY-s.top)/s.height*2+1,this._intersections.length=0,this._raycaster.setFromCamera(this._mouse,this._camera),this._raycaster.intersectObjects(this._objects,!0,this._intersections),this._intersections.length>0&&(this._selected=!0===this.transformGroup?this._objects[0]:this._intersections[0].object,this._plane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._plane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._plane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._offset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))),this._domElement.style.cursor="move",this.dispatchEvent({type:"dragstart",object:this._selected}))})),i.default(this,"onTouchEnd",(t=>{t.preventDefault(),this._selected&&(this.dispatchEvent({type:"dragend",object:this._selected}),this._selected=null),this._domElement.style.cursor="auto"})),this._objects=t,this._camera=s,this._domElement=o,this.activate()}}exports.DragControls=o;
@@ -1,4 +1,4 @@
1
- import { Camera, EventDispatcher, Object3D } from 'three';
1
+ import { Camera, EventDispatcher, Object3D, Raycaster } from 'three';
2
2
  declare class DragControls extends EventDispatcher {
3
3
  enabled: boolean;
4
4
  transformGroup: boolean;
@@ -20,6 +20,7 @@ declare class DragControls extends EventDispatcher {
20
20
  deactivate: () => void;
21
21
  dispose: () => void;
22
22
  getObjects: () => Object3D[];
23
+ getRaycaster: () => Raycaster;
23
24
  private onMouseMove;
24
25
  private onMouseDown;
25
26
  private onMouseCancel;
@@ -73,6 +73,8 @@ class DragControls extends EventDispatcher {
73
73
 
74
74
  _defineProperty(this, "getObjects", () => this._objects);
75
75
 
76
+ _defineProperty(this, "getRaycaster", () => this._raycaster);
77
+
76
78
  _defineProperty(this, "onMouseMove", event => {
77
79
  const rect = this._domElement.getBoundingClientRect();
78
80
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=i(t);class o extends e.Object3D{constructor(t,i){super(),n.default(this,"isTransformControls",!0),n.default(this,"visible",!1),n.default(this,"domElement",void 0),n.default(this,"raycaster",new e.Raycaster),n.default(this,"gizmo",void 0),n.default(this,"plane",void 0),n.default(this,"tempVector",new e.Vector3),n.default(this,"tempVector2",new e.Vector3),n.default(this,"tempQuaternion",new e.Quaternion),n.default(this,"unit",{X:new e.Vector3(1,0,0),Y:new e.Vector3(0,1,0),Z:new e.Vector3(0,0,1)}),n.default(this,"pointStart",new e.Vector3),n.default(this,"pointEnd",new e.Vector3),n.default(this,"offset",new e.Vector3),n.default(this,"rotationAxis",new e.Vector3),n.default(this,"startNorm",new e.Vector3),n.default(this,"endNorm",new e.Vector3),n.default(this,"rotationAngle",0),n.default(this,"cameraPosition",new e.Vector3),n.default(this,"cameraQuaternion",new e.Quaternion),n.default(this,"cameraScale",new e.Vector3),n.default(this,"parentPosition",new e.Vector3),n.default(this,"parentQuaternion",new e.Quaternion),n.default(this,"parentQuaternionInv",new e.Quaternion),n.default(this,"parentScale",new e.Vector3),n.default(this,"worldPositionStart",new e.Vector3),n.default(this,"worldQuaternionStart",new e.Quaternion),n.default(this,"worldScaleStart",new e.Vector3),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"worldQuaternionInv",new e.Quaternion),n.default(this,"worldScale",new e.Vector3),n.default(this,"eye",new e.Vector3),n.default(this,"positionStart",new e.Vector3),n.default(this,"quaternionStart",new e.Quaternion),n.default(this,"scaleStart",new e.Vector3),n.default(this,"camera",void 0),n.default(this,"object",void 0),n.default(this,"enabled",!0),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"translationSnap",null),n.default(this,"rotationSnap",null),n.default(this,"scaleSnap",null),n.default(this,"space","world"),n.default(this,"size",1),n.default(this,"dragging",!1),n.default(this,"showX",!0),n.default(this,"showY",!0),n.default(this,"showZ",!0),n.default(this,"changeEvent",{type:"change"}),n.default(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),n.default(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),n.default(this,"objectChangeEvent",{type:"objectChange"}),n.default(this,"intersectObjectWithRay",((t,e,i)=>{const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1})),n.default(this,"attach",(t=>(this.object=t,this.visible=!0,this))),n.default(this,"detach",(()=>(this.object=void 0,this.visible=!1,this.axis=null,this))),n.default(this,"updateMatrixWorld",(()=>{void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?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.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()})),n.default(this,"pointerHover",(t=>{if(void 0===this.object||!0===this.dragging)return;this.raycaster.setFromCamera(t,this.camera);const e=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);this.axis=e?e.object.name:null})),n.default(this,"pointerDown",(t=>{if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){this.raycaster.setFromCamera(t,this.camera);const e=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(e){let t=this.space;if("scale"===this.mode?t="local":"E"!==this.axis&&"XYZE"!==this.axis&&"XYZ"!==this.axis||(t="world"),"local"===t&&"rotate"===this.mode){const t=this.rotationSnap;"X"===this.axis&&t&&(this.object.rotation.x=Math.round(this.object.rotation.x/t)*t),"Y"===this.axis&&t&&(this.object.rotation.y=Math.round(this.object.rotation.y/t)*t),"Z"===this.axis&&t&&(this.object.rotation.z=Math.round(this.object.rotation.z/t)*t)}this.object.updateMatrixWorld(),this.object.parent&&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,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}})),n.default(this,"pointerMove",(t=>{const e=this.axis,i=this.mode,n=this.object;let o=this.space;if("scale"===i?o="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(o="world"),void 0===n||null===e||!1===this.dragging||-1!==t.button)return;this.raycaster.setFromCamera(t,this.camera);const s=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this.offset.copy(this.pointEnd).sub(this.pointStart),"local"===o&&"XYZ"!==e&&this.offset.applyQuaternion(this.worldQuaternionInv),-1===e.indexOf("X")&&(this.offset.x=0),-1===e.indexOf("Y")&&(this.offset.y=0),-1===e.indexOf("Z")&&(this.offset.z=0),"local"===o&&"XYZ"!==e?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),n.position.copy(this.offset).add(this.positionStart),this.translationSnap&&("local"===o&&(n.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this.quaternionStart)),"world"===o&&(n.parent&&n.position.add(this.tempVector.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(this.tempVector.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),this.tempVector2.set(t,t,t)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),-1===e.search("X")&&(this.tempVector2.x=1),-1===e.search("Y")&&(this.tempVector2.y=1),-1===e.search("Z")&&(this.tempVector2.z=1);n.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(-1!==e.search("X")&&(this.object.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this.offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));"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):"XYZE"===e?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(this.unit[e]),this.tempVector.copy(this.unit[e]),"local"===o&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===o&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this.quaternionStart),n.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),n.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}})),n.default(this,"pointerUp",(t=>{0===t.button&&(this.dragging&&null!==this.axis&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)})),n.default(this,"getPointer",(t=>{var e;if(this.domElement&&null!==(e=this.domElement.ownerDocument)&&void 0!==e&&e.pointerLockElement)return{x:0,y:0,button:t.button};{var i;const e=t.changedTouches?t.changedTouches[0]:t,n=null===(i=this.domElement)||void 0===i?void 0:i.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-(e.clientY-n.top)/n.height*2+1,button:t.button}}})),n.default(this,"onPointerHover",(t=>{if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(t))}})),n.default(this,"onPointerDown",(t=>{this.enabled&&this.domElement&&(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(t)),this.pointerDown(this.getPointer(t)))})),n.default(this,"onPointerMove",(t=>{this.enabled&&this.pointerMove(this.getPointer(t))})),n.default(this,"onPointerUp",(t=>{this.enabled&&this.domElement&&(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(t)))})),n.default(this,"getMode",(()=>this.mode)),n.default(this,"setMode",(t=>{this.mode=t})),n.default(this,"setTranslationSnap",(t=>{this.translationSnap=t})),n.default(this,"setRotationSnap",(t=>{this.rotationSnap=t})),n.default(this,"setScaleSnap",(t=>{this.scaleSnap=t})),n.default(this,"setSize",(t=>{this.size=t})),n.default(this,"setSpace",(t=>{this.space=t})),n.default(this,"update",(()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")})),n.default(this,"connect",(t=>{t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=t,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)})),n.default(this,"dispose",(()=>{var t,e,i,n,o,s;null===(t=this.domElement)||void 0===t||t.removeEventListener("pointerdown",this.onPointerDown),null===(e=this.domElement)||void 0===e||e.removeEventListener("pointermove",this.onPointerHover),null===(i=this.domElement)||void 0===i||null===(n=i.ownerDocument)||void 0===n||n.removeEventListener("pointermove",this.onPointerMove),null===(o=this.domElement)||void 0===o||null===(s=o.ownerDocument)||void 0===s||s.removeEventListener("pointerup",this.onPointerUp),this.traverse((t=>{const e=t;e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))})),this.domElement=i,this.camera=t,this.gizmo=new s,this.add(this.gizmo),this.plane=new a,this.add(this.plane);const o=(t,e)=>{let i=e;Object.defineProperty(this,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,this.plane[t]=e,this.gizmo[t]=e,this.dispatchEvent({type:t+"-changed",value:e}),this.dispatchEvent(this.changeEvent))}}),this[t]=e,this.plane[t]=e,this.gizmo[t]=e};o("camera",this.camera),o("object",this.object),o("enabled",this.enabled),o("axis",this.axis),o("mode",this.mode),o("translationSnap",this.translationSnap),o("rotationSnap",this.rotationSnap),o("scaleSnap",this.scaleSnap),o("space",this.space),o("size",this.size),o("dragging",this.dragging),o("showX",this.showX),o("showY",this.showY),o("showZ",this.showZ),o("worldPosition",this.worldPosition),o("worldPositionStart",this.worldPositionStart),o("worldQuaternion",this.worldQuaternion),o("worldQuaternionStart",this.worldQuaternionStart),o("cameraPosition",this.cameraPosition),o("cameraQuaternion",this.cameraQuaternion),o("pointStart",this.pointStart),o("pointEnd",this.pointEnd),o("rotationAxis",this.rotationAxis),o("rotationAngle",this.rotationAngle),o("eye",this.eye),void 0!==i&&this.connect(i)}}class s extends e.Object3D{constructor(){super(),n.default(this,"isTransformControlsGizmo",!0),n.default(this,"type","TransformControlsGizmo"),n.default(this,"tempVector",new e.Vector3(0,0,0)),n.default(this,"tempEuler",new e.Euler),n.default(this,"alignVector",new e.Vector3(0,1,0)),n.default(this,"zeroVector",new e.Vector3(0,0,0)),n.default(this,"lookAtMatrix",new e.Matrix4),n.default(this,"tempQuaternion",new e.Quaternion),n.default(this,"tempQuaternion2",new e.Quaternion),n.default(this,"identityQuaternion",new e.Quaternion),n.default(this,"unitX",new e.Vector3(1,0,0)),n.default(this,"unitY",new e.Vector3(0,1,0)),n.default(this,"unitZ",new e.Vector3(0,0,1)),n.default(this,"gizmo",void 0),n.default(this,"picker",void 0),n.default(this,"helper",void 0),n.default(this,"rotationAxis",new e.Vector3),n.default(this,"cameraPosition",new e.Vector3),n.default(this,"worldPositionStart",new e.Vector3),n.default(this,"worldQuaternionStart",new e.Quaternion),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"eye",new e.Vector3),n.default(this,"camera",null),n.default(this,"enabled",!0),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"space","world"),n.default(this,"size",1),n.default(this,"dragging",!1),n.default(this,"showX",!0),n.default(this,"showY",!0),n.default(this,"showZ",!0),n.default(this,"updateMatrixWorld",(()=>{let t=this.space;"scale"===this.mode&&(t="local");const i="local"===t?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let t=0;t<n.length;t++){const o=n[t];let s;if(o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition),s=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(s*this.size/7),"helper"!==o.tag){if(o.quaternion.copy(i),"translate"===this.mode||"scale"===this.mode){const t=.99,e=.2,n=0;"X"!==o.name&&"XYZX"!==o.name||Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"Y"!==o.name&&"XYZY"!==o.name||Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"Z"!==o.name&&"XYZZ"!==o.name||Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"XY"===o.name&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"YZ"===o.name&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"XZ"===o.name&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),-1!==o.name.search("X")&&(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.x*=-1:"bwd"===o.tag&&(o.visible=!1)),-1!==o.name.search("Y")&&(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.y*=-1:"bwd"===o.tag&&(o.visible=!1)),-1!==o.name.search("Z")&&(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.z*=-1:"bwd"===o.tag&&(o.visible=!1))}else"rotate"===this.mode&&(this.tempQuaternion2.copy(i),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(i).invert()),-1!==o.name.search("E")&&o.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),"X"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)),"Y"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)),"Z"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)));o.visible=o.visible&&(-1===o.name.indexOf("X")||this.showX),o.visible=o.visible&&(-1===o.name.indexOf("Y")||this.showY),o.visible=o.visible&&(-1===o.name.indexOf("Z")||this.showZ),o.visible=o.visible&&(-1===o.name.indexOf("E")||this.showX&&this.showY&&this.showZ),o.material.tempOpacity=o.material.tempOpacity||o.material.opacity,o.material.tempColor=o.material.tempColor||o.material.color.clone(),o.material.color.copy(o.material.tempColor),o.material.opacity=o.material.tempOpacity,this.enabled?this.axis&&(o.name===this.axis||this.axis.split("").some((function(t){return o.name===t}))?(o.material.opacity=1,o.material.color.lerp(new e.Color(1,1,1),.5)):(o.material.opacity*=.25,o.material.color.lerp(new e.Color(1,1,1),.5))):(o.material.opacity*=.5,o.material.color.lerp(new e.Color(1,1,1),.5))}else o.visible=!1,"AXIS"===o.name?(o.position.copy(this.worldPositionStart),o.visible=!!this.axis,"X"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"Y"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"Z"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"XYZE"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),o.quaternion.multiply(this.tempQuaternion),o.visible=this.dragging),"E"===this.axis&&(o.visible=!1)):"START"===o.name?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):"END"===o.name?(o.position.copy(this.worldPosition),o.visible=this.dragging):"DELTA"===o.name?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(this.tempVector),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=-1!==this.axis.search(o.name)))}super.updateMatrixWorld()}));const t=new e.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:e.DoubleSide,fog:!1,toneMapped:!1}),i=new e.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),o=t.clone();o.opacity=.15;const s=t.clone();s.opacity=.33;const a=t.clone();a.color.set(16711680);const r=t.clone();r.color.set(65280);const h=t.clone();h.color.set(255);const l=t.clone();l.opacity=.25;const c=l.clone();c.color.set(16776960);const d=l.clone();d.color.set(65535);const u=l.clone();u.color.set(16711935);t.clone().color.set(16776960);const p=i.clone();p.color.set(16711680);const m=i.clone();m.color.set(65280);const w=i.clone();w.color.set(255);const y=i.clone();y.color.set(65535);const f=i.clone();f.color.set(16711935);const M=i.clone();M.color.set(16776960);const g=i.clone();g.color.set(7895160);const b=M.clone();b.opacity=.25;const v=new e.CylinderGeometry(0,.05,.2,12,1,!1),P=new e.BoxGeometry(.125,.125,.125),Q=new e.BufferGeometry;Q.setAttribute("position",new e.Float32BufferAttribute([0,0,0,1,0,0],3));const x=(t,i)=>{const n=new e.BufferGeometry,o=[];for(let e=0;e<=64*i;++e)o.push(0,Math.cos(e/32*Math.PI)*t,Math.sin(e/32*Math.PI)*t);return n.setAttribute("position",new e.Float32BufferAttribute(o,3)),n},V={X:[[new e.Mesh(v,a),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new e.Mesh(v,a),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new e.Line(Q,p)]],Y:[[new e.Mesh(v,r),[0,1,0],null,null,"fwd"],[new e.Mesh(v,r),[0,1,0],[Math.PI,0,0],null,"bwd"],[new e.Line(Q,m),null,[0,0,Math.PI/2]]],Z:[[new e.Mesh(v,h),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new e.Mesh(v,h),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new e.Line(Q,w),null,[0,-Math.PI/2,0]]],XYZ:[[new e.Mesh(new e.OctahedronGeometry(.1,0),l.clone()),[0,0,0],[0,0,0]]],XY:[[new e.Mesh(new e.PlaneGeometry(.295,.295),c.clone()),[.15,.15,0]],[new e.Line(Q,M),[.18,.3,0],null,[.125,1,1]],[new e.Line(Q,M),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new e.Line(Q,y),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(Q,y),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),u.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new e.Line(Q,f),[.18,0,.3],null,[.125,1,1]],[new e.Line(Q,f),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},S={X:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[0,.6,0]]],Z:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new e.Mesh(new e.OctahedronGeometry(.2,0),o)]],XY:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[.2,.2,0]]],YZ:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[.2,0,.2],[-Math.PI/2,0,0]]]},E={START:[[new e.Mesh(new e.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new e.Mesh(new e.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new e.Line((()=>{const t=new e.BufferGeometry;return t.setAttribute("position",new e.Float32BufferAttribute([0,0,0,1,1,1],3)),t})(),s),null,null,null,"helper"]],X:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(Q,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(Q,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},Y={X:[[new e.Line(x(1,.5),p)],[new e.Mesh(new e.OctahedronGeometry(.04,0),a),[0,0,.99],null,[1,3,1]]],Y:[[new e.Line(x(1,.5),m),null,[0,0,-Math.PI/2]],[new e.Mesh(new e.OctahedronGeometry(.04,0),r),[0,0,.99],null,[3,1,1]]],Z:[[new e.Line(x(1,.5),w),null,[0,Math.PI/2,0]],[new e.Mesh(new e.OctahedronGeometry(.04,0),h),[.99,0,0],null,[1,3,1]]],E:[[new e.Line(x(1.25,1),b),null,[0,Math.PI/2,0]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new e.Line(x(1,1),g),null,[0,Math.PI/2,0]]]},X={AXIS:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Z={X:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new e.Mesh(new e.TorusGeometry(1.25,.1,2,24),o)]],XYZE:[[new e.Mesh(new e.SphereGeometry(.7,10,8),o)]]},I={X:[[new e.Mesh(P,a),[.8,0,0],[0,0,-Math.PI/2]],[new e.Line(Q,p),null,null,[.8,1,1]]],Y:[[new e.Mesh(P,r),[0,.8,0]],[new e.Line(Q,m),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new e.Mesh(P,h),[0,0,.8],[Math.PI/2,0,0]],[new e.Line(Q,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new e.Mesh(P,c),[.85,.85,0],null,[2,2,.2]],[new e.Line(Q,M),[.855,.98,0],null,[.125,1,1]],[new e.Line(Q,M),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(P,d),[0,.85,.85],null,[.2,2,2]],[new e.Line(Q,y),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(Q,y),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(P,u),[.85,0,.85],null,[2,.2,2]],[new e.Line(Q,f),[.855,0,.98],null,[.125,1,1]],[new e.Line(Q,f),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[1.1,0,0]]],XYZY:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[0,1.1,0]]],XYZZ:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[0,0,1.1]]]},A={X:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[0,.5,0]]],Z:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new e.Mesh(P,o),[.85,.85,0],null,[3,3,.2]]],YZ:[[new e.Mesh(P,o),[0,.85,.85],null,[.2,3,3]]],XZ:[[new e.Mesh(P,o),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[1.1,0,0]]],XYZY:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[0,1.1,0]]],XYZZ:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[0,0,1.1]]]},z={X:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(Q,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(Q,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},j=t=>{const i=new e.Object3D;for(let e in t)for(let n=t[e].length;n--;){const o=t[e][n][0].clone(),s=t[e][n][1],a=t[e][n][2],r=t[e][n][3],h=t[e][n][4];o.name=e,o.tag=h,s&&o.position.set(s[0],s[1],s[2]),a&&o.rotation.set(a[0],a[1],a[2]),r&&o.scale.set(r[0],r[1],r[2]),o.updateMatrix();const l=o.geometry.clone();l.applyMatrix4(o.matrix),o.geometry=l,o.renderOrder=1/0,o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),i.add(o)}return i};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=j(V)),this.add(this.gizmo.rotate=j(Y)),this.add(this.gizmo.scale=j(I)),this.add(this.picker.translate=j(S)),this.add(this.picker.rotate=j(Z)),this.add(this.picker.scale=j(A)),this.add(this.helper.translate=j(E)),this.add(this.helper.rotate=j(X)),this.add(this.helper.scale=j(z)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class a extends e.Mesh{constructor(){super(new e.PlaneGeometry(1e5,1e5,2,2),new e.MeshBasicMaterial({visible:!1,wireframe:!0,side:e.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),n.default(this,"isTransformControlsPlane",!0),n.default(this,"type","TransformControlsPlane"),n.default(this,"unitX",new e.Vector3(1,0,0)),n.default(this,"unitY",new e.Vector3(0,1,0)),n.default(this,"unitZ",new e.Vector3(0,0,1)),n.default(this,"tempVector",new e.Vector3),n.default(this,"dirVector",new e.Vector3),n.default(this,"alignVector",new e.Vector3),n.default(this,"tempMatrix",new e.Matrix4),n.default(this,"identityQuaternion",new e.Quaternion),n.default(this,"cameraQuaternion",new e.Quaternion),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"eye",new e.Vector3),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"space","world"),n.default(this,"updateMatrixWorld",(()=>{let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),this.unitX.set(1,0,0).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0)}break;case"rotate":default:this.dirVector.set(0,0,0)}0===this.dirVector.length()?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()}))}}exports.TransformControls=o,exports.TransformControlsGizmo=s,exports.TransformControlsPlane=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=i(t);class o extends e.Object3D{constructor(t,i){super(),n.default(this,"isTransformControls",!0),n.default(this,"visible",!1),n.default(this,"domElement",void 0),n.default(this,"raycaster",new e.Raycaster),n.default(this,"gizmo",void 0),n.default(this,"plane",void 0),n.default(this,"tempVector",new e.Vector3),n.default(this,"tempVector2",new e.Vector3),n.default(this,"tempQuaternion",new e.Quaternion),n.default(this,"unit",{X:new e.Vector3(1,0,0),Y:new e.Vector3(0,1,0),Z:new e.Vector3(0,0,1)}),n.default(this,"pointStart",new e.Vector3),n.default(this,"pointEnd",new e.Vector3),n.default(this,"offset",new e.Vector3),n.default(this,"rotationAxis",new e.Vector3),n.default(this,"startNorm",new e.Vector3),n.default(this,"endNorm",new e.Vector3),n.default(this,"rotationAngle",0),n.default(this,"cameraPosition",new e.Vector3),n.default(this,"cameraQuaternion",new e.Quaternion),n.default(this,"cameraScale",new e.Vector3),n.default(this,"parentPosition",new e.Vector3),n.default(this,"parentQuaternion",new e.Quaternion),n.default(this,"parentQuaternionInv",new e.Quaternion),n.default(this,"parentScale",new e.Vector3),n.default(this,"worldPositionStart",new e.Vector3),n.default(this,"worldQuaternionStart",new e.Quaternion),n.default(this,"worldScaleStart",new e.Vector3),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"worldQuaternionInv",new e.Quaternion),n.default(this,"worldScale",new e.Vector3),n.default(this,"eye",new e.Vector3),n.default(this,"positionStart",new e.Vector3),n.default(this,"quaternionStart",new e.Quaternion),n.default(this,"scaleStart",new e.Vector3),n.default(this,"camera",void 0),n.default(this,"object",void 0),n.default(this,"enabled",!0),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"translationSnap",null),n.default(this,"rotationSnap",null),n.default(this,"scaleSnap",null),n.default(this,"space","world"),n.default(this,"size",1),n.default(this,"dragging",!1),n.default(this,"showX",!0),n.default(this,"showY",!0),n.default(this,"showZ",!0),n.default(this,"changeEvent",{type:"change"}),n.default(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),n.default(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),n.default(this,"objectChangeEvent",{type:"objectChange"}),n.default(this,"intersectObjectWithRay",((t,e,i)=>{const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1})),n.default(this,"attach",(t=>(this.object=t,this.visible=!0,this))),n.default(this,"detach",(()=>(this.object=void 0,this.visible=!1,this.axis=null,this))),n.default(this,"reset",(()=>this.enabled?(this.dragging&&void 0!==this.object&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this)),n.default(this,"updateMatrixWorld",(()=>{void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?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.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()})),n.default(this,"pointerHover",(t=>{if(void 0===this.object||!0===this.dragging)return;this.raycaster.setFromCamera(t,this.camera);const e=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);this.axis=e?e.object.name:null})),n.default(this,"pointerDown",(t=>{if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){this.raycaster.setFromCamera(t,this.camera);const e=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(e){let t=this.space;if("scale"===this.mode?t="local":"E"!==this.axis&&"XYZE"!==this.axis&&"XYZ"!==this.axis||(t="world"),"local"===t&&"rotate"===this.mode){const t=this.rotationSnap;"X"===this.axis&&t&&(this.object.rotation.x=Math.round(this.object.rotation.x/t)*t),"Y"===this.axis&&t&&(this.object.rotation.y=Math.round(this.object.rotation.y/t)*t),"Z"===this.axis&&t&&(this.object.rotation.z=Math.round(this.object.rotation.z/t)*t)}this.object.updateMatrixWorld(),this.object.parent&&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,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}})),n.default(this,"pointerMove",(t=>{const e=this.axis,i=this.mode,n=this.object;let o=this.space;if("scale"===i?o="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(o="world"),void 0===n||null===e||!1===this.dragging||-1!==t.button)return;this.raycaster.setFromCamera(t,this.camera);const s=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this.offset.copy(this.pointEnd).sub(this.pointStart),"local"===o&&"XYZ"!==e&&this.offset.applyQuaternion(this.worldQuaternionInv),-1===e.indexOf("X")&&(this.offset.x=0),-1===e.indexOf("Y")&&(this.offset.y=0),-1===e.indexOf("Z")&&(this.offset.z=0),"local"===o&&"XYZ"!==e?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),n.position.copy(this.offset).add(this.positionStart),this.translationSnap&&("local"===o&&(n.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this.quaternionStart)),"world"===o&&(n.parent&&n.position.add(this.tempVector.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(this.tempVector.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),this.tempVector2.set(t,t,t)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),-1===e.search("X")&&(this.tempVector2.x=1),-1===e.search("Y")&&(this.tempVector2.y=1),-1===e.search("Z")&&(this.tempVector2.z=1);n.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(-1!==e.search("X")&&(this.object.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this.offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));"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):"XYZE"===e?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(this.unit[e]),this.tempVector.copy(this.unit[e]),"local"===o&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===o&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this.quaternionStart),n.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),n.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}})),n.default(this,"pointerUp",(t=>{0===t.button&&(this.dragging&&null!==this.axis&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)})),n.default(this,"getPointer",(t=>{var e;if(this.domElement&&null!==(e=this.domElement.ownerDocument)&&void 0!==e&&e.pointerLockElement)return{x:0,y:0,button:t.button};{var i;const e=t.changedTouches?t.changedTouches[0]:t,n=null===(i=this.domElement)||void 0===i?void 0:i.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-(e.clientY-n.top)/n.height*2+1,button:t.button}}})),n.default(this,"onPointerHover",(t=>{if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(t))}})),n.default(this,"onPointerDown",(t=>{this.enabled&&this.domElement&&(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(t)),this.pointerDown(this.getPointer(t)))})),n.default(this,"onPointerMove",(t=>{this.enabled&&this.pointerMove(this.getPointer(t))})),n.default(this,"onPointerUp",(t=>{this.enabled&&this.domElement&&(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(t)))})),n.default(this,"getMode",(()=>this.mode)),n.default(this,"setMode",(t=>{this.mode=t})),n.default(this,"setTranslationSnap",(t=>{this.translationSnap=t})),n.default(this,"setRotationSnap",(t=>{this.rotationSnap=t})),n.default(this,"setScaleSnap",(t=>{this.scaleSnap=t})),n.default(this,"setSize",(t=>{this.size=t})),n.default(this,"setSpace",(t=>{this.space=t})),n.default(this,"update",(()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")})),n.default(this,"connect",(t=>{t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=t,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)})),n.default(this,"dispose",(()=>{var t,e,i,n,o,s;null===(t=this.domElement)||void 0===t||t.removeEventListener("pointerdown",this.onPointerDown),null===(e=this.domElement)||void 0===e||e.removeEventListener("pointermove",this.onPointerHover),null===(i=this.domElement)||void 0===i||null===(n=i.ownerDocument)||void 0===n||n.removeEventListener("pointermove",this.onPointerMove),null===(o=this.domElement)||void 0===o||null===(s=o.ownerDocument)||void 0===s||s.removeEventListener("pointerup",this.onPointerUp),this.traverse((t=>{const e=t;e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))})),this.domElement=i,this.camera=t,this.gizmo=new s,this.add(this.gizmo),this.plane=new a,this.add(this.plane);const o=(t,e)=>{let i=e;Object.defineProperty(this,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,this.plane[t]=e,this.gizmo[t]=e,this.dispatchEvent({type:t+"-changed",value:e}),this.dispatchEvent(this.changeEvent))}}),this[t]=e,this.plane[t]=e,this.gizmo[t]=e};o("camera",this.camera),o("object",this.object),o("enabled",this.enabled),o("axis",this.axis),o("mode",this.mode),o("translationSnap",this.translationSnap),o("rotationSnap",this.rotationSnap),o("scaleSnap",this.scaleSnap),o("space",this.space),o("size",this.size),o("dragging",this.dragging),o("showX",this.showX),o("showY",this.showY),o("showZ",this.showZ),o("worldPosition",this.worldPosition),o("worldPositionStart",this.worldPositionStart),o("worldQuaternion",this.worldQuaternion),o("worldQuaternionStart",this.worldQuaternionStart),o("cameraPosition",this.cameraPosition),o("cameraQuaternion",this.cameraQuaternion),o("pointStart",this.pointStart),o("pointEnd",this.pointEnd),o("rotationAxis",this.rotationAxis),o("rotationAngle",this.rotationAngle),o("eye",this.eye),void 0!==i&&this.connect(i)}}class s extends e.Object3D{constructor(){super(),n.default(this,"isTransformControlsGizmo",!0),n.default(this,"type","TransformControlsGizmo"),n.default(this,"tempVector",new e.Vector3(0,0,0)),n.default(this,"tempEuler",new e.Euler),n.default(this,"alignVector",new e.Vector3(0,1,0)),n.default(this,"zeroVector",new e.Vector3(0,0,0)),n.default(this,"lookAtMatrix",new e.Matrix4),n.default(this,"tempQuaternion",new e.Quaternion),n.default(this,"tempQuaternion2",new e.Quaternion),n.default(this,"identityQuaternion",new e.Quaternion),n.default(this,"unitX",new e.Vector3(1,0,0)),n.default(this,"unitY",new e.Vector3(0,1,0)),n.default(this,"unitZ",new e.Vector3(0,0,1)),n.default(this,"gizmo",void 0),n.default(this,"picker",void 0),n.default(this,"helper",void 0),n.default(this,"rotationAxis",new e.Vector3),n.default(this,"cameraPosition",new e.Vector3),n.default(this,"worldPositionStart",new e.Vector3),n.default(this,"worldQuaternionStart",new e.Quaternion),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"eye",new e.Vector3),n.default(this,"camera",null),n.default(this,"enabled",!0),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"space","world"),n.default(this,"size",1),n.default(this,"dragging",!1),n.default(this,"showX",!0),n.default(this,"showY",!0),n.default(this,"showZ",!0),n.default(this,"updateMatrixWorld",(()=>{let t=this.space;"scale"===this.mode&&(t="local");const i="local"===t?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let t=0;t<n.length;t++){const o=n[t];let s;if(o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition),s=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(s*this.size/7),"helper"!==o.tag){if(o.quaternion.copy(i),"translate"===this.mode||"scale"===this.mode){const t=.99,e=.2,n=0;"X"!==o.name&&"XYZX"!==o.name||Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"Y"!==o.name&&"XYZY"!==o.name||Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"Z"!==o.name&&"XYZZ"!==o.name||Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))>t&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"XY"===o.name&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"YZ"===o.name&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),"XZ"===o.name&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))<e&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),-1!==o.name.search("X")&&(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.x*=-1:"bwd"===o.tag&&(o.visible=!1)),-1!==o.name.search("Y")&&(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.y*=-1:"bwd"===o.tag&&(o.visible=!1)),-1!==o.name.search("Z")&&(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye)<n?"fwd"===o.tag?o.visible=!1:o.scale.z*=-1:"bwd"===o.tag&&(o.visible=!1))}else"rotate"===this.mode&&(this.tempQuaternion2.copy(i),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(i).invert()),-1!==o.name.search("E")&&o.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),"X"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)),"Y"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)),"Z"===o.name&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),o.quaternion.copy(this.tempQuaternion)));o.visible=o.visible&&(-1===o.name.indexOf("X")||this.showX),o.visible=o.visible&&(-1===o.name.indexOf("Y")||this.showY),o.visible=o.visible&&(-1===o.name.indexOf("Z")||this.showZ),o.visible=o.visible&&(-1===o.name.indexOf("E")||this.showX&&this.showY&&this.showZ),o.material.tempOpacity=o.material.tempOpacity||o.material.opacity,o.material.tempColor=o.material.tempColor||o.material.color.clone(),o.material.color.copy(o.material.tempColor),o.material.opacity=o.material.tempOpacity,this.enabled?this.axis&&(o.name===this.axis||this.axis.split("").some((function(t){return o.name===t}))?(o.material.opacity=1,o.material.color.lerp(new e.Color(1,1,1),.5)):(o.material.opacity*=.25,o.material.color.lerp(new e.Color(1,1,1),.5))):(o.material.opacity*=.5,o.material.color.lerp(new e.Color(1,1,1),.5))}else o.visible=!1,"AXIS"===o.name?(o.position.copy(this.worldPositionStart),o.visible=!!this.axis,"X"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"Y"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"Z"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),"XYZE"===this.axis&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),o.quaternion.multiply(this.tempQuaternion),o.visible=this.dragging),"E"===this.axis&&(o.visible=!1)):"START"===o.name?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):"END"===o.name?(o.position.copy(this.worldPosition),o.visible=this.dragging):"DELTA"===o.name?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(this.tempVector),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=-1!==this.axis.search(o.name)))}super.updateMatrixWorld()}));const t=new e.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:e.DoubleSide,fog:!1,toneMapped:!1}),i=new e.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),o=t.clone();o.opacity=.15;const s=t.clone();s.opacity=.33;const a=t.clone();a.color.set(16711680);const r=t.clone();r.color.set(65280);const h=t.clone();h.color.set(255);const l=t.clone();l.opacity=.25;const c=l.clone();c.color.set(16776960);const d=l.clone();d.color.set(65535);const u=l.clone();u.color.set(16711935);t.clone().color.set(16776960);const p=i.clone();p.color.set(16711680);const m=i.clone();m.color.set(65280);const w=i.clone();w.color.set(255);const y=i.clone();y.color.set(65535);const f=i.clone();f.color.set(16711935);const M=i.clone();M.color.set(16776960);const g=i.clone();g.color.set(7895160);const b=M.clone();b.opacity=.25;const v=new e.CylinderGeometry(0,.05,.2,12,1,!1),P=new e.BoxGeometry(.125,.125,.125),Q=new e.BufferGeometry;Q.setAttribute("position",new e.Float32BufferAttribute([0,0,0,1,0,0],3));const x=(t,i)=>{const n=new e.BufferGeometry,o=[];for(let e=0;e<=64*i;++e)o.push(0,Math.cos(e/32*Math.PI)*t,Math.sin(e/32*Math.PI)*t);return n.setAttribute("position",new e.Float32BufferAttribute(o,3)),n},S={X:[[new e.Mesh(v,a),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new e.Mesh(v,a),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new e.Line(Q,p)]],Y:[[new e.Mesh(v,r),[0,1,0],null,null,"fwd"],[new e.Mesh(v,r),[0,1,0],[Math.PI,0,0],null,"bwd"],[new e.Line(Q,m),null,[0,0,Math.PI/2]]],Z:[[new e.Mesh(v,h),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new e.Mesh(v,h),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new e.Line(Q,w),null,[0,-Math.PI/2,0]]],XYZ:[[new e.Mesh(new e.OctahedronGeometry(.1,0),l.clone()),[0,0,0],[0,0,0]]],XY:[[new e.Mesh(new e.PlaneGeometry(.295,.295),c.clone()),[.15,.15,0]],[new e.Line(Q,M),[.18,.3,0],null,[.125,1,1]],[new e.Line(Q,M),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new e.Line(Q,y),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(Q,y),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),u.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new e.Line(Q,f),[.18,0,.3],null,[.125,1,1]],[new e.Line(Q,f),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},V={X:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[0,.6,0]]],Z:[[new e.Mesh(new e.CylinderGeometry(.2,0,1,4,1,!1),o),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new e.Mesh(new e.OctahedronGeometry(.2,0),o)]],XY:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[.2,.2,0]]],YZ:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new e.Mesh(new e.PlaneGeometry(.4,.4),o),[.2,0,.2],[-Math.PI/2,0,0]]]},E={START:[[new e.Mesh(new e.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new e.Mesh(new e.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new e.Line((()=>{const t=new e.BufferGeometry;return t.setAttribute("position",new e.Float32BufferAttribute([0,0,0,1,1,1],3)),t})(),s),null,null,null,"helper"]],X:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(Q,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(Q,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},Y={X:[[new e.Line(x(1,.5),p)],[new e.Mesh(new e.OctahedronGeometry(.04,0),a),[0,0,.99],null,[1,3,1]]],Y:[[new e.Line(x(1,.5),m),null,[0,0,-Math.PI/2]],[new e.Mesh(new e.OctahedronGeometry(.04,0),r),[0,0,.99],null,[3,1,1]]],Z:[[new e.Line(x(1,.5),w),null,[0,Math.PI/2,0]],[new e.Mesh(new e.OctahedronGeometry(.04,0),h),[.99,0,0],null,[1,3,1]]],E:[[new e.Line(x(1.25,1),b),null,[0,Math.PI/2,0]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new e.Mesh(new e.CylinderGeometry(.03,0,.15,4,1,!1),b),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new e.Line(x(1,1),g),null,[0,Math.PI/2,0]]]},X={AXIS:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Z={X:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new e.Mesh(new e.TorusGeometry(1,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new e.Mesh(new e.TorusGeometry(1.25,.1,2,24),o)]],XYZE:[[new e.Mesh(new e.SphereGeometry(.7,10,8),o)]]},I={X:[[new e.Mesh(P,a),[.8,0,0],[0,0,-Math.PI/2]],[new e.Line(Q,p),null,null,[.8,1,1]]],Y:[[new e.Mesh(P,r),[0,.8,0]],[new e.Line(Q,m),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new e.Mesh(P,h),[0,0,.8],[Math.PI/2,0,0]],[new e.Line(Q,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new e.Mesh(P,c),[.85,.85,0],null,[2,2,.2]],[new e.Line(Q,M),[.855,.98,0],null,[.125,1,1]],[new e.Line(Q,M),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(P,d),[0,.85,.85],null,[.2,2,2]],[new e.Line(Q,y),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(Q,y),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(P,u),[.85,0,.85],null,[2,.2,2]],[new e.Line(Q,f),[.855,0,.98],null,[.125,1,1]],[new e.Line(Q,f),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[1.1,0,0]]],XYZY:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[0,1.1,0]]],XYZZ:[[new e.Mesh(new e.BoxGeometry(.125,.125,.125),l.clone()),[0,0,1.1]]]},A={X:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[0,.5,0]]],Z:[[new e.Mesh(new e.CylinderGeometry(.2,0,.8,4,1,!1),o),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new e.Mesh(P,o),[.85,.85,0],null,[3,3,.2]]],YZ:[[new e.Mesh(P,o),[0,.85,.85],null,[.2,3,3]]],XZ:[[new e.Mesh(P,o),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[1.1,0,0]]],XYZY:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[0,1.1,0]]],XYZZ:[[new e.Mesh(new e.BoxGeometry(.2,.2,.2),o),[0,0,1.1]]]},j={X:[[new e.Line(Q,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(Q,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(Q,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z=t=>{const i=new e.Object3D;for(let e in t)for(let n=t[e].length;n--;){const o=t[e][n][0].clone(),s=t[e][n][1],a=t[e][n][2],r=t[e][n][3],h=t[e][n][4];o.name=e,o.tag=h,s&&o.position.set(s[0],s[1],s[2]),a&&o.rotation.set(a[0],a[1],a[2]),r&&o.scale.set(r[0],r[1],r[2]),o.updateMatrix();const l=o.geometry.clone();l.applyMatrix4(o.matrix),o.geometry=l,o.renderOrder=1/0,o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),i.add(o)}return i};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=z(S)),this.add(this.gizmo.rotate=z(Y)),this.add(this.gizmo.scale=z(I)),this.add(this.picker.translate=z(V)),this.add(this.picker.rotate=z(Z)),this.add(this.picker.scale=z(A)),this.add(this.helper.translate=z(E)),this.add(this.helper.rotate=z(X)),this.add(this.helper.scale=z(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class a extends e.Mesh{constructor(){super(new e.PlaneGeometry(1e5,1e5,2,2),new e.MeshBasicMaterial({visible:!1,wireframe:!0,side:e.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),n.default(this,"isTransformControlsPlane",!0),n.default(this,"type","TransformControlsPlane"),n.default(this,"unitX",new e.Vector3(1,0,0)),n.default(this,"unitY",new e.Vector3(0,1,0)),n.default(this,"unitZ",new e.Vector3(0,0,1)),n.default(this,"tempVector",new e.Vector3),n.default(this,"dirVector",new e.Vector3),n.default(this,"alignVector",new e.Vector3),n.default(this,"tempMatrix",new e.Matrix4),n.default(this,"identityQuaternion",new e.Quaternion),n.default(this,"cameraQuaternion",new e.Quaternion),n.default(this,"worldPosition",new e.Vector3),n.default(this,"worldQuaternion",new e.Quaternion),n.default(this,"eye",new e.Vector3),n.default(this,"axis",null),n.default(this,"mode","translate"),n.default(this,"space","world"),n.default(this,"updateMatrixWorld",(()=>{let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),this.unitX.set(1,0,0).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion("local"===t?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0)}break;case"rotate":default:this.dirVector.set(0,0,0)}0===this.dirVector.length()?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()}))}}exports.TransformControls=o,exports.TransformControlsGizmo=s,exports.TransformControlsPlane=a;
@@ -62,6 +62,7 @@ declare class TransformControls<TCamera extends Camera = Camera> extends Object3
62
62
  private intersectObjectWithRay;
63
63
  attach: (object: Object3D) => this;
64
64
  detach: () => this;
65
+ reset: () => this;
65
66
  updateMatrixWorld: () => void;
66
67
  private pointerHover;
67
68
  private pointerDown;
@@ -151,6 +151,23 @@ class TransformControls extends Object3D {
151
151
  return this;
152
152
  });
153
153
 
154
+ _defineProperty(this, "reset", () => {
155
+ if (!this.enabled) return this;
156
+
157
+ if (this.dragging) {
158
+ if (this.object !== undefined) {
159
+ this.object.position.copy(this.positionStart);
160
+ this.object.quaternion.copy(this.quaternionStart);
161
+ this.object.scale.copy(this.scaleStart);
162
+ this.dispatchEvent(this.changeEvent);
163
+ this.dispatchEvent(this.objectChangeEvent);
164
+ this.pointStart.copy(this.pointEnd);
165
+ }
166
+ }
167
+
168
+ return this;
169
+ });
170
+
154
171
  _defineProperty(this, "updateMatrixWorld", () => {
155
172
  if (this.object !== undefined) {
156
173
  this.object.updateMatrixWorld();