three-stdlib 2.7.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/{Nodes-ec4e1143.js → Nodes-894ac9dc.js} +0 -0
  2. package/{Nodes-427f68b0.js → Nodes-af575af7.js} +0 -0
  3. package/cameras/CinematicCamera.cjs.js +1 -1
  4. package/cameras/CinematicCamera.js +3 -8
  5. package/controls/ArcballControls.cjs.js +1 -1
  6. package/controls/ArcballControls.d.ts +6 -9
  7. package/controls/ArcballControls.js +188 -234
  8. package/controls/FirstPersonControls.cjs.js +1 -1
  9. package/controls/FirstPersonControls.d.ts +4 -5
  10. package/controls/FirstPersonControls.js +36 -45
  11. package/controls/TransformControls.cjs.js +1 -1
  12. package/controls/TransformControls.d.ts +2 -1
  13. package/controls/TransformControls.js +25 -26
  14. package/exporters/GLTFExporter.cjs.js +1 -1
  15. package/exporters/GLTFExporter.js +9 -18
  16. package/geometries/TeapotGeometry.js +2 -2
  17. package/index.cjs.js +1 -1
  18. package/loaders/EXRLoader.cjs.js +1 -1
  19. package/loaders/EXRLoader.js +21 -10
  20. package/loaders/GLTFLoader.cjs.js +1 -1
  21. package/loaders/GLTFLoader.js +5 -6
  22. package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
  23. package/loaders/HDRCubeTextureLoader.js +1 -3
  24. package/loaders/LDrawLoader.cjs.js +1 -1
  25. package/loaders/LDrawLoader.js +1450 -1105
  26. package/loaders/LUT3dlLoader.cjs.js +1 -1
  27. package/loaders/LUT3dlLoader.js +18 -11
  28. package/loaders/LUTCubeLoader.cjs.js +1 -1
  29. package/loaders/LUTCubeLoader.js +4 -5
  30. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  31. package/loaders/PCDLoader.cjs.js +1 -1
  32. package/loaders/PCDLoader.js +2 -2
  33. package/loaders/RGBELoader.cjs.js +1 -1
  34. package/loaders/RGBELoader.js +6 -6
  35. package/loaders/STLLoader.js +7 -7
  36. package/loaders/VRMLLoader.cjs.js +1 -1
  37. package/loaders/VRMLLoader.js +10 -18
  38. package/modifiers/CurveModifier.cjs.js +1 -1
  39. package/modifiers/CurveModifier.js +9 -8
  40. package/nodes/accessors/CameraNode.js +12 -12
  41. package/nodes/accessors/PositionNode.js +3 -3
  42. package/nodes/accessors/ReflectNode.js +3 -3
  43. package/nodes/core/FunctionNode.js +3 -3
  44. package/nodes/core/InputNode.js +3 -3
  45. package/nodes/core/Node.js +6 -6
  46. package/nodes/core/TempNode.js +6 -6
  47. package/nodes/effects/BlurNode.js +3 -3
  48. package/nodes/math/MathNode.js +3 -3
  49. package/nodes/utils/VelocityNode.js +6 -6
  50. package/objects/Lensflare.cjs.js +1 -1
  51. package/objects/Lensflare.js +3 -11
  52. package/objects/Reflector.cjs.js +1 -1
  53. package/objects/Reflector.js +16 -12
  54. package/objects/ReflectorForSSRPass.cjs.js +1 -1
  55. package/objects/ReflectorForSSRPass.js +1 -9
  56. package/objects/Refractor.cjs.js +1 -1
  57. package/objects/Refractor.js +7 -12
  58. package/objects/Water.cjs.js +1 -1
  59. package/objects/Water.js +5 -16
  60. package/package.json +2 -2
  61. package/postprocessing/GlitchPass.cjs.js +1 -1
  62. package/postprocessing/GlitchPass.js +36 -33
  63. package/postprocessing/SMAAPass.cjs.js +1 -1
  64. package/postprocessing/SMAAPass.js +93 -96
  65. package/postprocessing/SSAOPass.cjs.js +1 -1
  66. package/postprocessing/SSAOPass.js +151 -152
  67. package/postprocessing/SavePass.cjs.js +1 -1
  68. package/postprocessing/SavePass.js +27 -28
  69. package/renderers/nodes/accessors/UVNode.js +1 -3
  70. package/renderers/nodes/core/AttributeNode.js +1 -3
  71. package/renderers/nodes/core/Node.js +4 -12
  72. package/renderers/nodes/core/NodeBuilder.js +6 -18
  73. package/renderers/webgpu/WebGPUTextures.cjs.js +1 -1
  74. package/renderers/webgpu/WebGPUTextures.js +1 -2
  75. package/utils/LDrawUtils.cjs.js +1 -0
  76. package/utils/LDrawUtils.js +144 -0
  77. package/webxr/ARButton.js +6 -6
  78. package/webxr/VRButton.js +6 -6
@@ -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 s=i(t);class o extends e.EventDispatcher{constructor(t,i){super(),s.default(this,"object",void 0),s.default(this,"domElement",void 0),s.default(this,"enabled",!0),s.default(this,"movementSpeed",1),s.default(this,"lookSpeed",.005),s.default(this,"lookVertical",!0),s.default(this,"autoForward",!1),s.default(this,"activeLook",!0),s.default(this,"heightSpeed",!1),s.default(this,"heightCoef",1),s.default(this,"heightMin",0),s.default(this,"heightMax",1),s.default(this,"constrainVertical",!1),s.default(this,"verticalMin",0),s.default(this,"verticalMax",Math.PI),s.default(this,"mouseDragOn",!1),s.default(this,"autoSpeedFactor",0),s.default(this,"mouseX",0),s.default(this,"mouseY",0),s.default(this,"moveForward",!1),s.default(this,"moveBackward",!1),s.default(this,"moveLeft",!1),s.default(this,"moveRight",!1),s.default(this,"moveUp",!1),s.default(this,"moveDown",!1),s.default(this,"viewHalfX",0),s.default(this,"viewHalfY",0),s.default(this,"lat",0),s.default(this,"lon",0),s.default(this,"lookDirection",new e.Vector3),s.default(this,"spherical",new e.Spherical),s.default(this,"target",new e.Vector3),s.default(this,"dispose",(()=>{this.domElement.removeEventListener("contextmenu",this.contextmenu),this.domElement.removeEventListener("mousedown",this.onMouseDown),this.domElement.removeEventListener("mousemove",this.onMouseMove),this.domElement.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)})),s.default(this,"handleResize",(()=>{this.domElement instanceof Document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2)})),s.default(this,"onMouseDown",(t=>{if(this.domElement instanceof HTMLElement&&this.domElement.focus(),this.activeLook)switch(t.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0})),s.default(this,"onMouseUp",(t=>{if(this.activeLook)switch(t.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1})),s.default(this,"onMouseMove",(t=>{this.domElement instanceof Document?(this.mouseX=t.pageX-this.viewHalfX,this.mouseY=t.pageY-this.viewHalfY):(this.mouseX=t.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=t.pageY-this.domElement.offsetTop-this.viewHalfY)})),s.default(this,"onKeyDown",(t=>{switch(t.code){case"ArrowUp":case"KeyW":this.moveForward=!0;break;case"ArrowLeft":case"KeyA":this.moveLeft=!0;break;case"ArrowDown":case"KeyS":this.moveBackward=!0;break;case"ArrowRight":case"KeyD":this.moveRight=!0;break;case"KeyR":this.moveUp=!0;break;case"KeyF":this.moveDown=!0}})),s.default(this,"onKeyUp",(t=>{switch(t.code){case"ArrowUp":case"KeyW":this.moveForward=!1;break;case"ArrowLeft":case"KeyA":this.moveLeft=!1;break;case"ArrowDown":case"KeyS":this.moveBackward=!1;break;case"ArrowRight":case"KeyD":this.moveRight=!1;break;case"KeyR":this.moveUp=!1;break;case"KeyF":this.moveDown=!1}})),s.default(this,"lookAt",((t,i,s)=>(t instanceof e.Vector3?this.target.copy(t):i&&s&&this.target.set(t,i,s),this.object.lookAt(this.target),this.setOrientation(this),this))),s.default(this,"targetPosition",new e.Vector3),s.default(this,"update",(t=>{if(!1===this.enabled)return;if(this.heightSpeed){const i=e.MathUtils.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=t*(i*this.heightCoef)}else this.autoSpeedFactor=0;const i=t*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(i+this.autoSpeedFactor)),this.moveBackward&&this.object.translateZ(i),this.moveLeft&&this.object.translateX(-i),this.moveRight&&this.object.translateX(i),this.moveUp&&this.object.translateY(i),this.moveDown&&this.object.translateY(-i);let s=t*this.lookSpeed;this.activeLook||(s=0);let o=1;this.constrainVertical&&(o=Math.PI/(this.verticalMax-this.verticalMin)),this.lon-=this.mouseX*s,this.lookVertical&&(this.lat-=this.mouseY*s*o),this.lat=Math.max(-85,Math.min(85,this.lat));let a=e.MathUtils.degToRad(90-this.lat);const h=e.MathUtils.degToRad(this.lon);this.constrainVertical&&(a=e.MathUtils.mapLinear(a,0,Math.PI,this.verticalMin,this.verticalMax));const n=this.object.position;this.targetPosition.setFromSphericalCoords(1,a,h).add(n),this.object.lookAt(this.targetPosition)})),s.default(this,"contextmenu",(t=>t.preventDefault())),s.default(this,"setOrientation",(t=>{const i=t.object.quaternion;this.lookDirection.set(0,0,-1).applyQuaternion(i),this.spherical.setFromVector3(this.lookDirection),this.lat=90-e.MathUtils.radToDeg(this.spherical.phi),this.lon=e.MathUtils.radToDeg(this.spherical.theta)})),void 0===i&&(console.warn('THREE.FirstPersonControls: The second parameter "domElement" is now mandatory.'),i=document),this.object=t,this.domElement=i,this.domElement instanceof HTMLElement&&this.domElement.setAttribute("tabindex","-1"),this.handleResize(),this.setOrientation(this),this.domElement.addEventListener("contextmenu",this.contextmenu),this.domElement.addEventListener("mousemove",this.onMouseMove),this.domElement.addEventListener("mousedown",this.onMouseDown),this.domElement.addEventListener("mouseup",this.onMouseUp),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}}exports.FirstPersonControls=o;
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 s=i(t);const o=new e.Vector3;class a extends e.EventDispatcher{constructor(t,i){super(),s.default(this,"object",void 0),s.default(this,"domElement",void 0),s.default(this,"enabled",!0),s.default(this,"movementSpeed",1),s.default(this,"lookSpeed",.005),s.default(this,"lookVertical",!0),s.default(this,"autoForward",!1),s.default(this,"activeLook",!0),s.default(this,"heightSpeed",!1),s.default(this,"heightCoef",1),s.default(this,"heightMin",0),s.default(this,"heightMax",1),s.default(this,"constrainVertical",!1),s.default(this,"verticalMin",0),s.default(this,"verticalMax",Math.PI),s.default(this,"mouseDragOn",!1),s.default(this,"autoSpeedFactor",0),s.default(this,"mouseX",0),s.default(this,"mouseY",0),s.default(this,"moveForward",!1),s.default(this,"moveBackward",!1),s.default(this,"moveLeft",!1),s.default(this,"moveRight",!1),s.default(this,"moveUp",!1),s.default(this,"moveDown",!1),s.default(this,"viewHalfX",0),s.default(this,"viewHalfY",0),s.default(this,"lat",0),s.default(this,"lon",0),s.default(this,"lookDirection",new e.Vector3),s.default(this,"spherical",new e.Spherical),s.default(this,"target",new e.Vector3),s.default(this,"connect",(t=>{t.setAttribute("tabindex","-1"),t.style.touchAction="none",t.addEventListener("contextmenu",this.contextmenu),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mouseup",this.onMouseUp),this.domElement=t,window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.handleResize()})),s.default(this,"dispose",(()=>{var t,e,i,s;null===(t=this.domElement)||void 0===t||t.removeEventListener("contextmenu",this.contextmenu),null===(e=this.domElement)||void 0===e||e.removeEventListener("mousedown",this.onMouseDown),null===(i=this.domElement)||void 0===i||i.removeEventListener("mousemove",this.onMouseMove),null===(s=this.domElement)||void 0===s||s.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)})),s.default(this,"handleResize",(()=>{this.domElement&&(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2)})),s.default(this,"onMouseDown",(t=>{var e;if(null===(e=this.domElement)||void 0===e||e.focus(),this.activeLook)switch(t.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0})),s.default(this,"onMouseUp",(t=>{if(this.activeLook)switch(t.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1})),s.default(this,"onMouseMove",(t=>{this.domElement&&(this.mouseX=t.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=t.pageY-this.domElement.offsetTop-this.viewHalfY)})),s.default(this,"onKeyDown",(t=>{switch(t.code){case"ArrowUp":case"KeyW":this.moveForward=!0;break;case"ArrowLeft":case"KeyA":this.moveLeft=!0;break;case"ArrowDown":case"KeyS":this.moveBackward=!0;break;case"ArrowRight":case"KeyD":this.moveRight=!0;break;case"KeyR":this.moveUp=!0;break;case"KeyF":this.moveDown=!0}})),s.default(this,"onKeyUp",(t=>{switch(t.code){case"ArrowUp":case"KeyW":this.moveForward=!1;break;case"ArrowLeft":case"KeyA":this.moveLeft=!1;break;case"ArrowDown":case"KeyS":this.moveBackward=!1;break;case"ArrowRight":case"KeyD":this.moveRight=!1;break;case"KeyR":this.moveUp=!1;break;case"KeyF":this.moveDown=!1}})),s.default(this,"lookAt",((t,i,s)=>(t instanceof e.Vector3?this.target.copy(t):i&&s&&this.target.set(t,i,s),this.object.lookAt(this.target),this.setOrientation(),this))),s.default(this,"update",(t=>{if(!this.enabled)return;if(this.heightSpeed){const i=e.MathUtils.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=t*(i*this.heightCoef)}else this.autoSpeedFactor=0;const i=t*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(i+this.autoSpeedFactor)),this.moveBackward&&this.object.translateZ(i),this.moveLeft&&this.object.translateX(-i),this.moveRight&&this.object.translateX(i),this.moveUp&&this.object.translateY(i),this.moveDown&&this.object.translateY(-i);let s=t*this.lookSpeed;this.activeLook||(s=0);let a=1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin)),this.lon-=this.mouseX*s,this.lookVertical&&(this.lat-=this.mouseY*s*a),this.lat=Math.max(-85,Math.min(85,this.lat));let h=e.MathUtils.degToRad(90-this.lat);const n=e.MathUtils.degToRad(this.lon);this.constrainVertical&&(h=e.MathUtils.mapLinear(h,0,Math.PI,this.verticalMin,this.verticalMax));const r=this.object.position;o.setFromSphericalCoords(1,h,n).add(r),this.object.lookAt(o)})),s.default(this,"contextmenu",(t=>t.preventDefault())),s.default(this,"setOrientation",(()=>{this.lookDirection.set(0,0,-1).applyQuaternion(this.object.quaternion),this.spherical.setFromVector3(this.lookDirection),this.lat=90-e.MathUtils.radToDeg(this.spherical.phi),this.lon=e.MathUtils.radToDeg(this.spherical.theta)})),this.object=t,this.domElement=i,this.setOrientation(),i&&this.connect(i)}}exports.FirstPersonControls=a;
@@ -1,7 +1,7 @@
1
1
  import { Vector3, EventDispatcher, Camera } from 'three';
2
- declare class FirstPersonControls extends EventDispatcher {
2
+ export declare class FirstPersonControls extends EventDispatcher {
3
3
  object: Camera;
4
- domElement: HTMLElement | Document;
4
+ domElement?: HTMLElement | null;
5
5
  enabled: boolean;
6
6
  movementSpeed: number;
7
7
  lookSpeed: number;
@@ -32,7 +32,8 @@ declare class FirstPersonControls extends EventDispatcher {
32
32
  private lookDirection;
33
33
  private spherical;
34
34
  private target;
35
- constructor(object: Camera, domElement: HTMLElement | Document);
35
+ constructor(object: Camera, domElement?: HTMLElement | null);
36
+ connect: (domElement: HTMLElement) => void;
36
37
  dispose: () => void;
37
38
  handleResize: () => void;
38
39
  private onMouseDown;
@@ -41,9 +42,7 @@ declare class FirstPersonControls extends EventDispatcher {
41
42
  private onKeyDown;
42
43
  private onKeyUp;
43
44
  lookAt: (x: Vector3 | number, y?: number | undefined, z?: number | undefined) => this;
44
- private targetPosition;
45
45
  update: (delta: number) => void;
46
46
  private contextmenu;
47
47
  private setOrientation;
48
48
  }
49
- export { FirstPersonControls };
@@ -1,9 +1,10 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import { EventDispatcher, Vector3, Spherical, MathUtils } from 'three';
2
+ import { Vector3, EventDispatcher, Spherical, MathUtils } from 'three';
3
3
 
4
+ const targetPosition = new Vector3();
4
5
  class FirstPersonControls extends EventDispatcher {
5
6
  // internals
6
- constructor(object, domElement) {
7
+ constructor(object, _domElement) {
7
8
  super();
8
9
 
9
10
  _defineProperty(this, "object", void 0);
@@ -70,29 +71,41 @@ class FirstPersonControls extends EventDispatcher {
70
71
 
71
72
  _defineProperty(this, "target", new Vector3());
72
73
 
74
+ _defineProperty(this, "connect", domElement => {
75
+ domElement.setAttribute('tabindex', '-1');
76
+ domElement.style.touchAction = 'none';
77
+ domElement.addEventListener('contextmenu', this.contextmenu);
78
+ domElement.addEventListener('mousemove', this.onMouseMove);
79
+ domElement.addEventListener('mousedown', this.onMouseDown);
80
+ domElement.addEventListener('mouseup', this.onMouseUp);
81
+ this.domElement = domElement;
82
+ window.addEventListener('keydown', this.onKeyDown);
83
+ window.addEventListener('keyup', this.onKeyUp);
84
+ this.handleResize();
85
+ });
86
+
73
87
  _defineProperty(this, "dispose", () => {
74
- this.domElement.removeEventListener('contextmenu', this.contextmenu);
75
- this.domElement.removeEventListener('mousedown', this.onMouseDown);
76
- this.domElement.removeEventListener('mousemove', this.onMouseMove);
77
- this.domElement.removeEventListener('mouseup', this.onMouseUp);
88
+ var _this$domElement, _this$domElement2, _this$domElement3, _this$domElement4;
89
+
90
+ (_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.removeEventListener('contextmenu', this.contextmenu);
91
+ (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.removeEventListener('mousedown', this.onMouseDown);
92
+ (_this$domElement3 = this.domElement) === null || _this$domElement3 === void 0 ? void 0 : _this$domElement3.removeEventListener('mousemove', this.onMouseMove);
93
+ (_this$domElement4 = this.domElement) === null || _this$domElement4 === void 0 ? void 0 : _this$domElement4.removeEventListener('mouseup', this.onMouseUp);
78
94
  window.removeEventListener('keydown', this.onKeyDown);
79
95
  window.removeEventListener('keyup', this.onKeyUp);
80
96
  });
81
97
 
82
98
  _defineProperty(this, "handleResize", () => {
83
- if (this.domElement instanceof Document) {
84
- this.viewHalfX = window.innerWidth / 2;
85
- this.viewHalfY = window.innerHeight / 2;
86
- } else {
99
+ if (this.domElement) {
87
100
  this.viewHalfX = this.domElement.offsetWidth / 2;
88
101
  this.viewHalfY = this.domElement.offsetHeight / 2;
89
102
  }
90
103
  });
91
104
 
92
105
  _defineProperty(this, "onMouseDown", event => {
93
- if (this.domElement instanceof HTMLElement) {
94
- this.domElement.focus();
95
- }
106
+ var _this$domElement5;
107
+
108
+ (_this$domElement5 = this.domElement) === null || _this$domElement5 === void 0 ? void 0 : _this$domElement5.focus();
96
109
 
97
110
  if (this.activeLook) {
98
111
  switch (event.button) {
@@ -126,10 +139,7 @@ class FirstPersonControls extends EventDispatcher {
126
139
  });
127
140
 
128
141
  _defineProperty(this, "onMouseMove", event => {
129
- if (this.domElement instanceof Document) {
130
- this.mouseX = event.pageX - this.viewHalfX;
131
- this.mouseY = event.pageY - this.viewHalfY;
132
- } else {
142
+ if (this.domElement) {
133
143
  this.mouseX = event.pageX - this.domElement.offsetLeft - this.viewHalfX;
134
144
  this.mouseY = event.pageY - this.domElement.offsetTop - this.viewHalfY;
135
145
  }
@@ -207,14 +217,12 @@ class FirstPersonControls extends EventDispatcher {
207
217
  }
208
218
 
209
219
  this.object.lookAt(this.target);
210
- this.setOrientation(this);
220
+ this.setOrientation();
211
221
  return this;
212
222
  });
213
223
 
214
- _defineProperty(this, "targetPosition", new Vector3());
215
-
216
224
  _defineProperty(this, "update", delta => {
217
- if (this.enabled === false) return;
225
+ if (!this.enabled) return;
218
226
 
219
227
  if (this.heightSpeed) {
220
228
  const y = MathUtils.clamp(this.object.position.y, this.heightMin, this.heightMax);
@@ -258,40 +266,23 @@ class FirstPersonControls extends EventDispatcher {
258
266
  }
259
267
 
260
268
  const position = this.object.position;
261
- this.targetPosition.setFromSphericalCoords(1, phi, theta).add(position);
262
- this.object.lookAt(this.targetPosition);
269
+ targetPosition.setFromSphericalCoords(1, phi, theta).add(position);
270
+ this.object.lookAt(targetPosition);
263
271
  });
264
272
 
265
273
  _defineProperty(this, "contextmenu", event => event.preventDefault());
266
274
 
267
- _defineProperty(this, "setOrientation", controls => {
268
- const quaternion = controls.object.quaternion;
269
- this.lookDirection.set(0, 0, -1).applyQuaternion(quaternion);
275
+ _defineProperty(this, "setOrientation", () => {
276
+ this.lookDirection.set(0, 0, -1).applyQuaternion(this.object.quaternion);
270
277
  this.spherical.setFromVector3(this.lookDirection);
271
278
  this.lat = 90 - MathUtils.radToDeg(this.spherical.phi);
272
279
  this.lon = MathUtils.radToDeg(this.spherical.theta);
273
280
  });
274
281
 
275
- if (domElement === undefined) {
276
- console.warn('THREE.FirstPersonControls: The second parameter "domElement" is now mandatory.');
277
- domElement = document;
278
- }
279
-
280
282
  this.object = object;
281
- this.domElement = domElement;
282
-
283
- if (this.domElement instanceof HTMLElement) {
284
- this.domElement.setAttribute('tabindex', '-1');
285
- }
286
-
287
- this.handleResize();
288
- this.setOrientation(this);
289
- this.domElement.addEventListener('contextmenu', this.contextmenu);
290
- this.domElement.addEventListener('mousemove', this.onMouseMove);
291
- this.domElement.addEventListener('mousedown', this.onMouseDown);
292
- this.domElement.addEventListener('mouseup', this.onMouseUp);
293
- window.addEventListener('keydown', this.onKeyDown);
294
- window.addEventListener('keyup', this.onKeyUp);
283
+ this.domElement = _domElement;
284
+ this.setOrientation();
285
+ if (_domElement) this.connect(_domElement);
295
286
  }
296
287
 
297
288
  }
@@ -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=>{var e;this.enabled&&(this.domElement.style.touchAction="none",null===(e=this.domElement.ownerDocument)||void 0===e||e.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=>{var e;this.enabled&&(this.domElement.style.touchAction="",null===(e=this.domElement.ownerDocument)||void 0===e||e.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,"dispose",(()=>{var t,e;this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerHover),null===(t=this.domElement.ownerDocument)||void 0===t||t.removeEventListener("pointermove",this.onPointerMove),null===(e=this.domElement.ownerDocument)||void 0===e||e.removeEventListener("pointerup",this.onPointerUp),this.traverse((t=>{const e=t;e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))})),void 0===i&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),this.domElement=document),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),i.addEventListener("pointerdown",this.onPointerDown),i.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}}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 u=l.clone();u.color.set(65535);const d=l.clone();d.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),Q=new e.BoxGeometry(.125,.125,.125),P=new e.BufferGeometry;P.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(P,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(P,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(P,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(P,M),[.18,.3,0],null,[.125,1,1]],[new e.Line(P,M),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),u.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new e.Line(P,y),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(P,y),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(new e.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new e.Line(P,f),[.18,0,.3],null,[.125,1,1]],[new e.Line(P,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(P,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(P,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(P,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(P,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(Q,a),[.8,0,0],[0,0,-Math.PI/2]],[new e.Line(P,p),null,null,[.8,1,1]]],Y:[[new e.Mesh(Q,r),[0,.8,0]],[new e.Line(P,m),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new e.Mesh(Q,h),[0,0,.8],[Math.PI/2,0,0]],[new e.Line(P,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new e.Mesh(Q,c),[.85,.85,0],null,[2,2,.2]],[new e.Line(P,M),[.855,.98,0],null,[.125,1,1]],[new e.Line(P,M),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new e.Mesh(Q,u),[0,.85,.85],null,[.2,2,2]],[new e.Line(P,y),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new e.Line(P,y),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new e.Mesh(Q,d),[.85,0,.85],null,[2,.2,2]],[new e.Line(P,f),[.855,0,.98],null,[.125,1,1]],[new e.Line(P,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(Q,o),[.85,.85,0],null,[3,3,.2]]],YZ:[[new e.Mesh(Q,o),[0,.85,.85],null,[.2,3,3]]],XZ:[[new e.Mesh(Q,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(P,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new e.Line(P,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new e.Line(P,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,"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;
@@ -58,7 +58,7 @@ declare class TransformControls<TCamera extends Camera = Camera> extends Object3
58
58
  private mouseDownEvent;
59
59
  private mouseUpEvent;
60
60
  private objectChangeEvent;
61
- constructor(camera: TCamera, domElement: HTMLElement);
61
+ constructor(camera: TCamera, domElement: HTMLElement | undefined);
62
62
  private intersectObjectWithRay;
63
63
  attach: (object: Object3D) => this;
64
64
  detach: () => this;
@@ -80,6 +80,7 @@ declare class TransformControls<TCamera extends Camera = Camera> extends Object3
80
80
  setSize: (size: number) => void;
81
81
  setSpace: (space: string) => void;
82
82
  update: () => void;
83
+ connect: (domElement: HTMLElement) => void;
83
84
  dispose: () => void;
84
85
  }
85
86
  declare type TransformControlsGizmoPrivateGizmos = {
@@ -3,7 +3,7 @@ import { Object3D, Raycaster, Vector3, Quaternion, Euler, Matrix4, Color, MeshBa
3
3
 
4
4
  class TransformControls extends Object3D {
5
5
  // events
6
- constructor(camera, domElement) {
6
+ constructor(camera, _domElement) {
7
7
  super();
8
8
 
9
9
  _defineProperty(this, "isTransformControls", true);
@@ -436,12 +436,10 @@ class TransformControls extends Object3D {
436
436
  });
437
437
 
438
438
  _defineProperty(this, "onPointerDown", event => {
439
- var _this$domElement$owne2;
440
-
441
- if (!this.enabled) return;
439
+ if (!this.enabled || !this.domElement) return;
442
440
  this.domElement.style.touchAction = 'none'; // disable touch scroll
443
441
 
444
- (_this$domElement$owne2 = this.domElement.ownerDocument) === null || _this$domElement$owne2 === void 0 ? void 0 : _this$domElement$owne2.addEventListener('pointermove', this.onPointerMove);
442
+ this.domElement.ownerDocument.addEventListener('pointermove', this.onPointerMove);
445
443
  this.pointerHover(this.getPointer(event));
446
444
  this.pointerDown(this.getPointer(event));
447
445
  });
@@ -452,11 +450,9 @@ class TransformControls extends Object3D {
452
450
  });
453
451
 
454
452
  _defineProperty(this, "onPointerUp", event => {
455
- var _this$domElement$owne3;
456
-
457
- if (!this.enabled) return;
453
+ if (!this.enabled || !this.domElement) return;
458
454
  this.domElement.style.touchAction = '';
459
- (_this$domElement$owne3 = this.domElement.ownerDocument) === null || _this$domElement$owne3 === void 0 ? void 0 : _this$domElement$owne3.removeEventListener('pointermove', this.onPointerMove);
455
+ this.domElement.ownerDocument.removeEventListener('pointermove', this.onPointerMove);
460
456
  this.pointerUp(this.getPointer(event));
461
457
  });
462
458
 
@@ -490,13 +486,24 @@ class TransformControls extends Object3D {
490
486
  console.warn('THREE.TransformControls: update function has no more functionality and therefore has been deprecated.');
491
487
  });
492
488
 
489
+ _defineProperty(this, "connect", domElement => {
490
+ if (domElement === document) {
491
+ console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
492
+ }
493
+
494
+ this.domElement = domElement;
495
+ this.domElement.addEventListener('pointerdown', this.onPointerDown);
496
+ this.domElement.addEventListener('pointermove', this.onPointerHover);
497
+ this.domElement.ownerDocument.addEventListener('pointerup', this.onPointerUp);
498
+ });
499
+
493
500
  _defineProperty(this, "dispose", () => {
494
- var _this$domElement$owne4, _this$domElement$owne5;
501
+ var _this$domElement2, _this$domElement3, _this$domElement4, _this$domElement4$own, _this$domElement5, _this$domElement5$own;
495
502
 
496
- this.domElement.removeEventListener('pointerdown', this.onPointerDown);
497
- this.domElement.removeEventListener('pointermove', this.onPointerHover);
498
- (_this$domElement$owne4 = this.domElement.ownerDocument) === null || _this$domElement$owne4 === void 0 ? void 0 : _this$domElement$owne4.removeEventListener('pointermove', this.onPointerMove);
499
- (_this$domElement$owne5 = this.domElement.ownerDocument) === null || _this$domElement$owne5 === void 0 ? void 0 : _this$domElement$owne5.removeEventListener('pointerup', this.onPointerUp);
503
+ (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.removeEventListener('pointerdown', this.onPointerDown);
504
+ (_this$domElement3 = this.domElement) === null || _this$domElement3 === void 0 ? void 0 : _this$domElement3.removeEventListener('pointermove', this.onPointerHover);
505
+ (_this$domElement4 = this.domElement) === null || _this$domElement4 === void 0 ? void 0 : (_this$domElement4$own = _this$domElement4.ownerDocument) === null || _this$domElement4$own === void 0 ? void 0 : _this$domElement4$own.removeEventListener('pointermove', this.onPointerMove);
506
+ (_this$domElement5 = this.domElement) === null || _this$domElement5 === void 0 ? void 0 : (_this$domElement5$own = _this$domElement5.ownerDocument) === null || _this$domElement5$own === void 0 ? void 0 : _this$domElement5$own.removeEventListener('pointerup', this.onPointerUp);
500
507
  this.traverse(child => {
501
508
  const mesh = child;
502
509
 
@@ -510,12 +517,7 @@ class TransformControls extends Object3D {
510
517
  });
511
518
  });
512
519
 
513
- if (domElement === undefined) {
514
- console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.');
515
- this.domElement = document;
516
- }
517
-
518
- this.domElement = domElement;
520
+ this.domElement = _domElement;
519
521
  this.camera = camera;
520
522
  this.gizmo = new TransformControlsGizmo();
521
523
  this.add(this.gizmo);
@@ -573,12 +575,9 @@ class TransformControls extends Object3D {
573
575
  defineProperty('pointEnd', this.pointEnd);
574
576
  defineProperty('rotationAxis', this.rotationAxis);
575
577
  defineProperty('rotationAngle', this.rotationAngle);
576
- defineProperty('eye', this.eye);
577
- {
578
- domElement.addEventListener('pointerdown', this.onPointerDown);
579
- domElement.addEventListener('pointermove', this.onPointerHover);
580
- this.domElement.ownerDocument.addEventListener('pointerup', this.onPointerUp);
581
- }
578
+ defineProperty('eye', this.eye); // connect events
579
+
580
+ if (_domElement !== undefined) this.connect(_domElement);
582
581
  }
583
582
 
584
583
  }