@tonybfox/threejs-tools 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/asset-loader/index.cjs +3 -355
  2. package/dist/asset-loader/index.d.mts +6 -1
  3. package/dist/asset-loader/index.d.ts +6 -1
  4. package/dist/asset-loader/index.mjs +1 -6
  5. package/dist/camera/index.cjs +1 -393
  6. package/dist/camera/index.mjs +1 -6
  7. package/dist/chunk-4O4ENFL7.mjs +83 -0
  8. package/dist/chunk-55YVGK52.mjs +1 -0
  9. package/dist/chunk-B75TYEOO.mjs +44 -0
  10. package/dist/chunk-EQRUOKFV.mjs +1 -0
  11. package/dist/chunk-JRJBW66X.mjs +1 -0
  12. package/dist/chunk-OJFYE56U.mjs +1 -0
  13. package/dist/chunk-UJF4S4J3.mjs +1 -0
  14. package/dist/chunk-WZ4X7GQ2.mjs +1 -0
  15. package/dist/chunk-Z5VL3O6M.mjs +43 -0
  16. package/dist/compass/index.cjs +3 -304
  17. package/dist/compass/index.mjs +1 -6
  18. package/dist/grid/index.cjs +3 -159
  19. package/dist/grid/index.mjs +1 -6
  20. package/dist/index.cjs +7 -5005
  21. package/dist/index.d.mts +169 -1
  22. package/dist/index.d.ts +169 -1
  23. package/dist/index.mjs +1 -46
  24. package/dist/measurements/index.cjs +1 -1197
  25. package/dist/measurements/index.mjs +1 -8
  26. package/dist/sunlight/index.cjs +1 -440
  27. package/dist/sunlight/index.d.mts +19 -0
  28. package/dist/sunlight/index.d.ts +19 -0
  29. package/dist/sunlight/index.mjs +1 -6
  30. package/dist/terrain/index.cjs +1 -422
  31. package/dist/terrain/index.mjs +1 -6
  32. package/dist/transform-controls/index.cjs +1 -1586
  33. package/dist/transform-controls/index.mjs +1 -12
  34. package/dist/view-helper/index.cjs +1 -435
  35. package/dist/view-helper/index.mjs +1 -6
  36. package/package.json +1 -1
  37. package/dist/chunk-27WUVRGX.mjs +0 -360
  38. package/dist/chunk-2CDI7ORN.mjs +0 -163
  39. package/dist/chunk-FBTT6MU6.mjs +0 -386
  40. package/dist/chunk-IAZH4OHC.mjs +0 -399
  41. package/dist/chunk-OZKJ3GAD.mjs +0 -1160
  42. package/dist/chunk-W4DAAAW6.mjs +0 -404
  43. package/dist/chunk-XA7OKYSM.mjs +0 -357
  44. package/dist/chunk-YMMLYGHV.mjs +0 -1578
  45. package/dist/chunk-ZNGFST7K.mjs +0 -348
@@ -1,1586 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/transform-controls/src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- TransformControls: () => TransformControls,
24
- TransformControlsGizmo: () => TransformControlsGizmo,
25
- TransformControlsPlane: () => TransformControlsPlane,
26
- calculateBoundingBoxCenter: () => calculateBoundingBoxCenter
27
- });
28
- module.exports = __toCommonJS(src_exports);
29
-
30
- // packages/transform-controls/src/TransformControls.ts
31
- var import_three = require("three");
32
- var import_CSS2DRenderer = require("three/examples/jsm/renderers/CSS2DRenderer.js");
33
- var _raycaster = new import_three.Raycaster();
34
- var _tempVector = new import_three.Vector3();
35
- var _tempVector2 = new import_three.Vector3();
36
- var _tempQuaternion = new import_three.Quaternion();
37
- var _unit = {
38
- X: new import_three.Vector3(1, 0, 0),
39
- Y: new import_three.Vector3(0, 1, 0),
40
- Z: new import_three.Vector3(0, 0, 1)
41
- };
42
- var _changeEvent = { type: "change" };
43
- var _mouseDownEvent = { type: "mouseDown", mode: null };
44
- var _mouseUpEvent = { type: "mouseUp", mode: null };
45
- var _objectChangeEvent = { type: "objectChange" };
46
- var TransformControls = class extends import_three.Controls {
47
- /**
48
- * Constructs a new controls instance.
49
- *
50
- * @param {Camera} camera - The camera of the rendered scene.
51
- * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
52
- */
53
- constructor(camera, domElement = null) {
54
- super(void 0, domElement);
55
- const root = new TransformControlsRoot(this);
56
- this._root = root;
57
- const gizmo = new TransformControlsGizmo();
58
- this._gizmo = gizmo;
59
- root.add(gizmo);
60
- const plane = new TransformControlsPlane();
61
- this._plane = plane;
62
- root.add(plane);
63
- const scope = this;
64
- this._overlay = document.createElement("div");
65
- this._overlay.classList.add("absolute");
66
- this._overlay.classList.add("bottom-2");
67
- this._overlay.classList.add("left-80");
68
- this._overlay.classList.add("z-50");
69
- this._overlay.classList.add("bg-gray-700");
70
- this._overlay.classList.add("bg-opacity-70");
71
- this._overlay.classList.add("text-white");
72
- this._overlay.classList.add("p-2");
73
- this._overlay.classList.add("rounded-md");
74
- this._overlay.classList.add("border");
75
- this._overlay.classList.add("border-gray-500");
76
- this._overlay.classList.add("hidden");
77
- if (domElement) {
78
- domElement.appendChild(this._overlay);
79
- }
80
- const labelDiv = document.createElement("div");
81
- labelDiv.className = "distance-label";
82
- labelDiv.style.padding = "4px 8px";
83
- labelDiv.style.background = "rgba(0, 0, 0, 0.8)";
84
- labelDiv.style.border = "1px solid rgba(255, 255, 255, 0.3)";
85
- labelDiv.style.borderRadius = "4px";
86
- labelDiv.style.color = "#fff";
87
- labelDiv.style.fontSize = "12px";
88
- labelDiv.style.fontFamily = "monospace";
89
- labelDiv.style.whiteSpace = "nowrap";
90
- labelDiv.style.pointerEvents = "none";
91
- labelDiv.style.userSelect = "none";
92
- labelDiv.textContent = "0.00";
93
- this._distanceLabel = new import_CSS2DRenderer.CSS2DObject(labelDiv);
94
- this._distanceLabel.visible = false;
95
- root.add(this._distanceLabel);
96
- const angleLabelDiv = document.createElement("div");
97
- angleLabelDiv.className = "rotation-angle-label";
98
- angleLabelDiv.style.padding = "4px 8px";
99
- angleLabelDiv.style.background = "rgba(0, 0, 0, 0.8)";
100
- angleLabelDiv.style.border = "1px solid rgba(255, 255, 255, 0.3)";
101
- angleLabelDiv.style.borderRadius = "4px";
102
- angleLabelDiv.style.color = "#fff";
103
- angleLabelDiv.style.fontSize = "12px";
104
- angleLabelDiv.style.fontFamily = "monospace";
105
- angleLabelDiv.style.whiteSpace = "nowrap";
106
- angleLabelDiv.style.pointerEvents = "none";
107
- angleLabelDiv.style.userSelect = "none";
108
- angleLabelDiv.textContent = "0\xB0";
109
- this._rotationAngleLabel = new import_CSS2DRenderer.CSS2DObject(angleLabelDiv);
110
- this._rotationAngleLabel.visible = false;
111
- root.add(this._rotationAngleLabel);
112
- this._rotationArc = null;
113
- function defineProperty(propName, defaultValue) {
114
- let propValue = defaultValue;
115
- Object.defineProperty(scope, propName, {
116
- get: function() {
117
- return propValue !== void 0 ? propValue : defaultValue;
118
- },
119
- set: function(value) {
120
- if (propValue !== value) {
121
- propValue = value;
122
- plane[propName] = value;
123
- gizmo[propName] = value;
124
- scope.dispatchEvent({
125
- type: propName + "-changed",
126
- value
127
- });
128
- scope.dispatchEvent(_changeEvent);
129
- }
130
- }
131
- });
132
- scope[propName] = defaultValue;
133
- plane[propName] = defaultValue;
134
- gizmo[propName] = defaultValue;
135
- }
136
- defineProperty("camera", camera);
137
- defineProperty("object", void 0);
138
- defineProperty("enabled", true);
139
- defineProperty("axis", null);
140
- defineProperty("mode", "all");
141
- defineProperty("translationSnap", null);
142
- defineProperty("rotationSnap", null);
143
- defineProperty("scaleSnap", null);
144
- defineProperty("space", "world");
145
- defineProperty("size", 0.75);
146
- defineProperty("dragging", false);
147
- defineProperty("activeMode", "translate");
148
- defineProperty("showX", true);
149
- defineProperty("showY", true);
150
- defineProperty("showZ", true);
151
- defineProperty("minX", -Infinity);
152
- defineProperty("maxX", Infinity);
153
- defineProperty("minY", -Infinity);
154
- defineProperty("maxY", Infinity);
155
- defineProperty("minZ", -Infinity);
156
- defineProperty("maxZ", Infinity);
157
- defineProperty("minRotation", -2 * Math.PI);
158
- defineProperty("maxRotation", 2 * Math.PI);
159
- const worldPosition = new import_three.Vector3();
160
- const worldPositionStart = new import_three.Vector3();
161
- const worldQuaternion = new import_three.Quaternion();
162
- const worldQuaternionStart = new import_three.Quaternion();
163
- const cameraPosition = new import_three.Vector3();
164
- const cameraQuaternion = new import_three.Quaternion();
165
- const pointStart = new import_three.Vector3();
166
- const pointEnd = new import_three.Vector3();
167
- const rotationAxis = new import_three.Vector3();
168
- const rotationAngle = 0;
169
- const eye = new import_three.Vector3();
170
- defineProperty("worldPosition", worldPosition);
171
- defineProperty("worldPositionStart", worldPositionStart);
172
- defineProperty("worldQuaternion", worldQuaternion);
173
- defineProperty("worldQuaternionStart", worldQuaternionStart);
174
- defineProperty("cameraPosition", cameraPosition);
175
- defineProperty("cameraQuaternion", cameraQuaternion);
176
- defineProperty("pointStart", pointStart);
177
- defineProperty("pointEnd", pointEnd);
178
- defineProperty("rotationAxis", rotationAxis);
179
- defineProperty("rotationAngle", rotationAngle);
180
- defineProperty("eye", eye);
181
- this._offset = new import_three.Vector3();
182
- this._startNorm = new import_three.Vector3();
183
- this._endNorm = new import_three.Vector3();
184
- this._cameraScale = new import_three.Vector3();
185
- this._parentPosition = new import_three.Vector3();
186
- this._parentQuaternion = new import_three.Quaternion();
187
- this._parentQuaternionInv = new import_three.Quaternion();
188
- this._parentScale = new import_three.Vector3();
189
- this._worldScaleStart = new import_three.Vector3();
190
- this._worldQuaternionInv = new import_three.Quaternion();
191
- this._worldScale = new import_three.Vector3();
192
- this._tempPosition = new import_three.Vector3();
193
- this._positionStart = new import_three.Vector3();
194
- this._quaternionStart = new import_three.Quaternion();
195
- this._scaleStart = new import_three.Vector3();
196
- this._getPointer = getPointer.bind(this);
197
- this._onPointerDown = onPointerDown.bind(this);
198
- this._onPointerHover = onPointerHover.bind(this);
199
- this._onPointerMove = onPointerMove.bind(this);
200
- this._onPointerUp = onPointerUp.bind(this);
201
- if (domElement !== null) {
202
- this.connect(domElement);
203
- }
204
- }
205
- connect(element) {
206
- super.connect(element);
207
- if (this.domElement?.parentNode) {
208
- this.domElement.parentNode.appendChild(this._overlay);
209
- }
210
- this.domElement?.addEventListener("pointerdown", this._onPointerDown);
211
- this.domElement?.addEventListener("pointermove", this._onPointerHover);
212
- this.domElement?.addEventListener("pointerup", this._onPointerUp);
213
- if (this.domElement) {
214
- this.domElement.style.touchAction = "none";
215
- }
216
- }
217
- disconnect() {
218
- if (this._overlay.parentNode) {
219
- this._overlay.parentNode.removeChild(this._overlay);
220
- }
221
- this.domElement?.removeEventListener("pointerdown", this._onPointerDown);
222
- this.domElement?.removeEventListener("pointermove", this._onPointerHover);
223
- this.domElement?.removeEventListener("pointermove", this._onPointerMove);
224
- this.domElement?.removeEventListener("pointerup", this._onPointerUp);
225
- if (this.domElement) {
226
- this.domElement.style.touchAction = "auto";
227
- }
228
- }
229
- /**
230
- * Returns the visual representation of the controls. Add the helper to your scene to
231
- * visually transform the attached 3D object.
232
- *
233
- * @return {TransformControlsRoot} The helper.
234
- */
235
- getHelper() {
236
- return this._root;
237
- }
238
- pointerHover(pointer) {
239
- if (this.object === void 0 || this.dragging === true) return;
240
- if (pointer !== null) _raycaster.setFromCamera(pointer, this.camera);
241
- let intersect = null;
242
- if (this.mode === "all") {
243
- intersect = intersectObjectWithRay(
244
- this._gizmo.picker["scale"],
245
- _raycaster
246
- );
247
- if (!intersect) {
248
- intersect = intersectObjectWithRay(
249
- this._gizmo.picker["rotate"],
250
- _raycaster
251
- );
252
- }
253
- if (!intersect) {
254
- intersect = intersectObjectWithRay(
255
- this._gizmo.picker["translate"],
256
- _raycaster
257
- );
258
- }
259
- } else {
260
- intersect = intersectObjectWithRay(
261
- this._gizmo.picker[this.mode],
262
- _raycaster
263
- );
264
- }
265
- if (intersect) {
266
- this.axis = intersect.object.name;
267
- } else {
268
- this.axis = null;
269
- }
270
- }
271
- pointerDown(pointer) {
272
- if (this.object === void 0 || this.dragging === true || pointer != null && pointer.button !== 0)
273
- return;
274
- if (this.axis !== null) {
275
- if (pointer !== null) _raycaster.setFromCamera(pointer, this.camera);
276
- if (this.mode === "all") {
277
- let intersect = intersectObjectWithRay(
278
- this._gizmo.picker["scale"],
279
- _raycaster
280
- );
281
- if (intersect && intersect.object.name === this.axis) {
282
- this.activeMode = "scale";
283
- } else {
284
- intersect = intersectObjectWithRay(
285
- this._gizmo.picker["rotate"],
286
- _raycaster
287
- );
288
- if (intersect && intersect.object.name === this.axis) {
289
- this.activeMode = "rotate";
290
- } else {
291
- this.activeMode = "translate";
292
- }
293
- }
294
- } else {
295
- this.activeMode = this.mode;
296
- }
297
- const planeIntersect = intersectObjectWithRay(
298
- this._plane,
299
- _raycaster,
300
- true
301
- );
302
- if (planeIntersect) {
303
- this.object.updateMatrixWorld();
304
- this.object.parent.updateMatrixWorld();
305
- this._positionStart.copy(this.object.position);
306
- this._quaternionStart.copy(this.object.quaternion);
307
- this._scaleStart.copy(this.object.scale);
308
- const boundingBoxCenter = calculateBoundingBoxCenter(this.object);
309
- this.worldPositionStart.copy(boundingBoxCenter);
310
- this.object.matrixWorld.decompose(
311
- this._tempPosition,
312
- // Use temporary variable for position
313
- this.worldQuaternionStart,
314
- this._worldScaleStart
315
- );
316
- this.pointStart.copy(planeIntersect.point).sub(this.worldPositionStart);
317
- }
318
- this.dragging = true;
319
- _mouseDownEvent.mode = this.mode === "all" ? this.activeMode : this.mode;
320
- this.dispatchEvent(_mouseDownEvent);
321
- }
322
- }
323
- pointerMove(pointer) {
324
- const axis = this.axis;
325
- const mode = this.mode === "all" ? this.activeMode : this.mode;
326
- const object = this.object;
327
- let space = this.space;
328
- if (mode === "scale") {
329
- space = "local";
330
- } else if (axis === "E" || axis === "XYZE" || axis === "XYZ") {
331
- space = "world";
332
- }
333
- if (object === void 0 || axis === null || this.dragging === false || pointer !== null && pointer.button !== -1) {
334
- this._updateDistanceOverlay();
335
- return;
336
- }
337
- if (pointer !== null) _raycaster.setFromCamera(pointer, this.camera);
338
- const planeIntersect = intersectObjectWithRay(this._plane, _raycaster, true);
339
- if (!planeIntersect) return;
340
- this.pointEnd.copy(planeIntersect.point).sub(this.worldPositionStart);
341
- if (mode === "translate") {
342
- this._offset.copy(this.pointEnd).sub(this.pointStart);
343
- if (space === "local" && axis !== "XYZ") {
344
- this._offset.applyQuaternion(this._worldQuaternionInv);
345
- }
346
- if (axis.indexOf("X") === -1) this._offset.x = 0;
347
- if (axis.indexOf("Y") === -1) this._offset.y = 0;
348
- if (axis.indexOf("Z") === -1) this._offset.z = 0;
349
- if (space === "local" && axis !== "XYZ") {
350
- this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale);
351
- } else {
352
- this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale);
353
- }
354
- object.position.copy(this._offset).add(this._positionStart);
355
- if (this.translationSnap) {
356
- if (space === "local") {
357
- object.position.applyQuaternion(
358
- _tempQuaternion.copy(this._quaternionStart).invert()
359
- );
360
- if (axis.search("X") !== -1) {
361
- object.position.x = Math.round(object.position.x / this.translationSnap) * this.translationSnap;
362
- }
363
- if (axis.search("Y") !== -1) {
364
- object.position.y = Math.round(object.position.y / this.translationSnap) * this.translationSnap;
365
- }
366
- if (axis.search("Z") !== -1) {
367
- object.position.z = Math.round(object.position.z / this.translationSnap) * this.translationSnap;
368
- }
369
- object.position.applyQuaternion(this._quaternionStart);
370
- }
371
- if (space === "world") {
372
- if (object.parent) {
373
- object.position.add(
374
- _tempVector.setFromMatrixPosition(object.parent.matrixWorld)
375
- );
376
- }
377
- if (axis.search("X") !== -1) {
378
- object.position.x = Math.round(object.position.x / this.translationSnap) * this.translationSnap;
379
- }
380
- if (axis.search("Y") !== -1) {
381
- object.position.y = Math.round(object.position.y / this.translationSnap) * this.translationSnap;
382
- }
383
- if (axis.search("Z") !== -1) {
384
- object.position.z = Math.round(object.position.z / this.translationSnap) * this.translationSnap;
385
- }
386
- if (object.parent) {
387
- object.position.sub(
388
- _tempVector.setFromMatrixPosition(object.parent.matrixWorld)
389
- );
390
- }
391
- }
392
- }
393
- object.position.x = Math.max(
394
- this.minX,
395
- Math.min(this.maxX, object.position.x)
396
- );
397
- object.position.y = Math.max(
398
- this.minY,
399
- Math.min(this.maxY, object.position.y)
400
- );
401
- object.position.z = Math.max(
402
- this.minZ,
403
- Math.min(this.maxZ, object.position.z)
404
- );
405
- } else if (mode === "scale") {
406
- if (axis.search("XYZ") !== -1) {
407
- let d = this.pointEnd.length() / this.pointStart.length();
408
- if (this.pointEnd.dot(this.pointStart) < 0) d *= -1;
409
- _tempVector2.set(d, d, d);
410
- } else {
411
- _tempVector.copy(this.pointStart);
412
- _tempVector2.copy(this.pointEnd);
413
- _tempVector.applyQuaternion(this._worldQuaternionInv);
414
- _tempVector2.applyQuaternion(this._worldQuaternionInv);
415
- _tempVector2.divide(_tempVector);
416
- if (axis.search("X") === -1) {
417
- _tempVector2.x = 1;
418
- }
419
- if (axis.search("Y") === -1) {
420
- _tempVector2.y = 1;
421
- }
422
- if (axis.search("Z") === -1) {
423
- _tempVector2.z = 1;
424
- }
425
- }
426
- object.scale.copy(this._scaleStart).multiply(_tempVector2);
427
- if (this.scaleSnap) {
428
- if (axis.search("X") !== -1) {
429
- object.scale.x = Math.round(object.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
430
- }
431
- if (axis.search("Y") !== -1) {
432
- object.scale.y = Math.round(object.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
433
- }
434
- if (axis.search("Z") !== -1) {
435
- object.scale.z = Math.round(object.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
436
- }
437
- }
438
- } else if (mode === "rotate") {
439
- this._offset.copy(this.pointEnd).sub(this.pointStart);
440
- const ROTATION_SPEED = 20 / this.worldPosition.distanceTo(
441
- _tempVector.setFromMatrixPosition(this.camera.matrixWorld)
442
- );
443
- let _inPlaneRotation = false;
444
- if (axis === "XYZE") {
445
- this.rotationAxis.copy(this._offset).cross(this.eye).normalize();
446
- this.rotationAngle = this._offset.dot(
447
- _tempVector.copy(this.rotationAxis).cross(this.eye)
448
- ) * ROTATION_SPEED;
449
- } else if (axis === "X" || axis === "Y" || axis === "Z") {
450
- this.rotationAxis.copy(_unit[axis]);
451
- _tempVector.copy(_unit[axis]);
452
- if (space === "local") {
453
- _tempVector.applyQuaternion(this.worldQuaternion);
454
- }
455
- _tempVector.cross(this.eye);
456
- if (_tempVector.length() === 0) {
457
- _inPlaneRotation = true;
458
- } else {
459
- this.rotationAngle = this._offset.dot(_tempVector.normalize()) * ROTATION_SPEED;
460
- }
461
- }
462
- if (axis === "E" || _inPlaneRotation) {
463
- this.rotationAxis.copy(this.eye);
464
- this.rotationAngle = this.pointEnd.angleTo(this.pointStart);
465
- this._startNorm.copy(this.pointStart).normalize();
466
- this._endNorm.copy(this.pointEnd).normalize();
467
- this.rotationAngle *= this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1;
468
- }
469
- if (this.rotationSnap)
470
- this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap;
471
- this.rotationAngle = Math.max(
472
- this.minRotation,
473
- Math.min(this.maxRotation, this.rotationAngle)
474
- );
475
- if (space === "local" && axis !== "E" && axis !== "XYZE") {
476
- object.quaternion.copy(this._quaternionStart);
477
- object.quaternion.multiply(
478
- _tempQuaternion.setFromAxisAngle(
479
- this.rotationAxis,
480
- this.rotationAngle
481
- )
482
- ).normalize();
483
- } else {
484
- this.rotationAxis.applyQuaternion(this._parentQuaternionInv);
485
- object.quaternion.copy(
486
- _tempQuaternion.setFromAxisAngle(
487
- this.rotationAxis,
488
- this.rotationAngle
489
- )
490
- );
491
- object.quaternion.multiply(this._quaternionStart).normalize();
492
- }
493
- }
494
- this.dispatchEvent(_changeEvent);
495
- this.dispatchEvent(_objectChangeEvent);
496
- this._updateDistanceOverlay();
497
- }
498
- pointerUp(pointer) {
499
- if (pointer !== null && pointer.button !== 0) return;
500
- if (this.dragging && this.axis !== null) {
501
- _mouseUpEvent.mode = this.mode;
502
- this.dispatchEvent(_mouseUpEvent);
503
- }
504
- this.dragging = false;
505
- this.axis = null;
506
- this._updateDistanceOverlay();
507
- }
508
- dispose() {
509
- this.disconnect();
510
- this._root.dispose();
511
- }
512
- /**
513
- * Sets the 3D object that should be transformed and ensures the controls UI is visible.
514
- *
515
- * @param {Object3D} object - The 3D object that should be transformed.
516
- * @return {TransformControls} A reference to this controls.
517
- */
518
- attach(object) {
519
- this.object = object;
520
- this._root.visible = true;
521
- return this;
522
- }
523
- /**
524
- * Removes the current 3D object from the controls and makes the helper UI invisible.
525
- *
526
- * @return {TransformControls} A reference to this controls.
527
- */
528
- detach() {
529
- this.object = void 0;
530
- this.axis = null;
531
- this._root.visible = false;
532
- return this;
533
- }
534
- /**
535
- * Resets the object's position, rotation and scale to when the current transform began.
536
- */
537
- reset() {
538
- if (!this.enabled) return;
539
- if (this.dragging) {
540
- this.object.position.copy(this._positionStart);
541
- this.object.quaternion.copy(this._quaternionStart);
542
- this.object.scale.copy(this._scaleStart);
543
- this.dispatchEvent(_changeEvent);
544
- this.dispatchEvent(_objectChangeEvent);
545
- this.pointStart.copy(this.pointEnd);
546
- }
547
- }
548
- /**
549
- * Returns the raycaster that is used for user interaction. This object is shared between all
550
- * instances of `TransformControls`.
551
- *
552
- * @returns {Raycaster} The internal raycaster.
553
- */
554
- getRaycaster() {
555
- return _raycaster;
556
- }
557
- /**
558
- * Returns the transformation mode.
559
- *
560
- * @returns {'translate'|'rotate'|'scale'} The transformation mode.
561
- */
562
- getMode() {
563
- return this.mode;
564
- }
565
- /**
566
- * Sets the given transformation mode.
567
- *
568
- * @param {'translate'|'rotate'|'scale'|'all'} mode - The transformation mode to set.
569
- */
570
- setMode(mode) {
571
- }
572
- /**
573
- * Sets the translation snap.
574
- *
575
- * @param {?number} translationSnap - The translation snap to set.
576
- */
577
- setTranslationSnap(translationSnap) {
578
- this.translationSnap = translationSnap;
579
- }
580
- /**
581
- * Sets the rotation snap.
582
- *
583
- * @param {?number} rotationSnap - The rotation snap to set.
584
- */
585
- setRotationSnap(rotationSnap) {
586
- this.rotationSnap = rotationSnap;
587
- }
588
- /**
589
- * Sets the minimum rotation angle limit (in radians).
590
- *
591
- * @param {number} minRotation - The minimum rotation angle to set (in radians).
592
- */
593
- setMinRotation(minRotation) {
594
- this.minRotation = minRotation;
595
- }
596
- /**
597
- * Sets the maximum rotation angle limit (in radians).
598
- *
599
- * @param {number} maxRotation - The maximum rotation angle to set (in radians).
600
- */
601
- setMaxRotation(maxRotation) {
602
- this.maxRotation = maxRotation;
603
- }
604
- /**
605
- * Sets the scale snap.
606
- *
607
- * @param {?number} scaleSnap - The scale snap to set.
608
- */
609
- setScaleSnap(scaleSnap) {
610
- this.scaleSnap = scaleSnap;
611
- }
612
- /**
613
- * Sets the size of the helper UI.
614
- *
615
- * @param {number} size - The size to set.
616
- */
617
- setSize(size) {
618
- this.size = size;
619
- }
620
- /**
621
- * Sets the coordinate space in which transformations are applied.
622
- *
623
- * @param {'world'|'local'} space - The space to set.
624
- */
625
- setSpace(space) {
626
- this.space = space;
627
- }
628
- _updateDistanceOverlay() {
629
- if (!this.object || !this.dragging) {
630
- this._overlay.classList.add("hidden");
631
- this._distanceLabel.visible = false;
632
- this._rotationAngleLabel.visible = false;
633
- return;
634
- }
635
- if (this.mode === "translate" || this.mode === "all" && this.activeMode === "translate") {
636
- const xDistance = this.object.position.x - this._positionStart.x;
637
- const yDistance = this.object.position.y - this._positionStart.y;
638
- const zDistance = this.object.position.z - this._positionStart.z;
639
- const totalDistance = Math.sqrt(
640
- xDistance * xDistance + yDistance * yDistance + zDistance * zDistance
641
- );
642
- const midPoint = new import_three.Vector3(
643
- (this._positionStart.x + this.object.position.x) / 2,
644
- (this._positionStart.y + this.object.position.y) / 2,
645
- (this._positionStart.z + this.object.position.z) / 2
646
- );
647
- this._distanceLabel.position.copy(midPoint);
648
- this._distanceLabel.visible = true;
649
- this._rotationAngleLabel.visible = false;
650
- this._distanceLabel.element.textContent = `${totalDistance.toFixed(3)}`;
651
- this._overlay.textContent = `X: ${xDistance.toFixed(2)} Y: ${yDistance.toFixed(2)} Z: ${zDistance.toFixed(2)}`;
652
- } else if (this.mode === "rotate" || this.mode === "all" && this.activeMode === "rotate") {
653
- this._distanceLabel.visible = false;
654
- const angleDegrees = this.rotationAngle * 180 / Math.PI;
655
- const labelRadius = 0.55;
656
- const labelAngle = this.rotationAngle / 2;
657
- const labelPos = new import_three.Vector3();
658
- if (this.axis === "X" || this.axis === "Y" || this.axis === "Z") {
659
- const axisvec = _unit[this.axis];
660
- const perpVector = new import_three.Vector3();
661
- if (Math.abs(axisvec.dot(this.pointStart.clone().normalize())) > 0.99) {
662
- perpVector.copy(this.eye).cross(axisvec).normalize();
663
- } else {
664
- perpVector.copy(this.pointStart).normalize();
665
- }
666
- const rotQuat = new import_three.Quaternion().setFromAxisAngle(axisvec, labelAngle);
667
- perpVector.applyQuaternion(rotQuat);
668
- if (this.space === "local") {
669
- perpVector.applyQuaternion(this.worldQuaternion);
670
- }
671
- perpVector.multiplyScalar(labelRadius);
672
- labelPos.copy(this.worldPosition).add(perpVector);
673
- } else {
674
- labelPos.copy(this.worldPosition);
675
- const offsetDir = this.pointStart.clone().normalize();
676
- if (this.space === "local") {
677
- offsetDir.applyQuaternion(this.worldQuaternion);
678
- }
679
- offsetDir.multiplyScalar(labelRadius);
680
- labelPos.add(offsetDir);
681
- }
682
- this._rotationAngleLabel.position.copy(labelPos);
683
- this._rotationAngleLabel.visible = true;
684
- this._rotationAngleLabel.element.textContent = `${Math.abs(angleDegrees).toFixed(1)}\xB0`;
685
- this._overlay.textContent = `X: ${(this.object.rotation.x * (180 / Math.PI)).toFixed(2)}\xB0 Y: ${(this.object.rotation.y * (180 / Math.PI)).toFixed(2)}\xB0 Z: ${(this.object.rotation.z * (180 / Math.PI)).toFixed(2)}\xB0`;
686
- } else if (this.mode === "scale") {
687
- this._distanceLabel.visible = false;
688
- this._rotationAngleLabel.visible = false;
689
- this._overlay.textContent = `X: ${this.object.scale.x.toFixed(2)} Y: ${this.object.scale.y.toFixed(2)} Z: ${this.object.scale.z.toFixed(2)}`;
690
- }
691
- this._overlay.classList.remove("hidden");
692
- }
693
- };
694
- function getPointer(event) {
695
- if (this.domElement.ownerDocument.pointerLockElement) {
696
- return {
697
- x: 0,
698
- y: 0,
699
- button: event.button
700
- };
701
- } else {
702
- const rect = this.domElement.getBoundingClientRect();
703
- return {
704
- x: (event.clientX - rect.left) / rect.width * 2 - 1,
705
- y: -(event.clientY - rect.top) / rect.height * 2 + 1,
706
- button: event.button
707
- };
708
- }
709
- }
710
- function onPointerHover(event) {
711
- if (!this.enabled) return;
712
- switch (event.pointerType) {
713
- case "mouse":
714
- case "pen":
715
- this.pointerHover(this._getPointer(event));
716
- break;
717
- }
718
- }
719
- function onPointerDown(event) {
720
- if (!this.enabled) return;
721
- if (!document.pointerLockElement) {
722
- this.domElement.setPointerCapture(event.pointerId);
723
- }
724
- this.domElement.addEventListener("pointermove", this._onPointerMove);
725
- this.pointerHover(this._getPointer(event));
726
- this.pointerDown(this._getPointer(event));
727
- }
728
- function onPointerMove(event) {
729
- if (!this.enabled) return;
730
- this.pointerMove(this._getPointer(event));
731
- }
732
- function onPointerUp(event) {
733
- if (!this.enabled) return;
734
- this.domElement.releasePointerCapture(event.pointerId);
735
- this.domElement.removeEventListener("pointermove", this._onPointerMove);
736
- this.pointerUp(this._getPointer(event));
737
- }
738
- function intersectObjectWithRay(object, raycaster, includeInvisible) {
739
- const allIntersections = raycaster.intersectObject(object, true);
740
- for (let i = 0; i < allIntersections.length; i++) {
741
- if (allIntersections[i].object.visible || includeInvisible) {
742
- return allIntersections[i];
743
- }
744
- }
745
- return false;
746
- }
747
- var _tempEuler = new import_three.Euler();
748
- var _alignVector = new import_three.Vector3(0, 1, 0);
749
- var _zeroVector = new import_three.Vector3(0, 0, 0);
750
- var _lookAtMatrix = new import_three.Matrix4();
751
- var _tempQuaternion2 = new import_three.Quaternion();
752
- var _identityQuaternion = new import_three.Quaternion();
753
- var _dirVector = new import_three.Vector3();
754
- var _tempMatrix = new import_three.Matrix4();
755
- var _unitX = new import_three.Vector3(1, 0, 0);
756
- var _unitY = new import_three.Vector3(0, 1, 0);
757
- var _unitZ = new import_three.Vector3(0, 0, 1);
758
- var _v1 = new import_three.Vector3();
759
- var _v2 = new import_three.Vector3();
760
- var _v3 = new import_three.Vector3();
761
- function calculateBoundingBoxCenter(object) {
762
- const box = new import_three.Box3();
763
- object.traverse((child) => {
764
- if (child.isMesh && child.geometry) {
765
- child.geometry.computeBoundingBox();
766
- box.expandByObject(child);
767
- }
768
- });
769
- if (box.isEmpty()) {
770
- return object.getWorldPosition(new import_three.Vector3());
771
- }
772
- const center = new import_three.Vector3();
773
- box.getCenter(center);
774
- return center;
775
- }
776
- var TransformControlsRoot = class extends import_three.Object3D {
777
- constructor(controls) {
778
- super();
779
- this.isTransformControlsRoot = true;
780
- this.controls = controls;
781
- this.visible = false;
782
- }
783
- // updateMatrixWorld updates key transformation variables
784
- updateMatrixWorld(force) {
785
- const controls = this.controls;
786
- if (controls.object !== void 0) {
787
- controls.object.updateMatrixWorld();
788
- if (controls.object.parent === null) {
789
- console.error(
790
- "TransformControls: The attached 3D object must be a part of the scene graph."
791
- );
792
- } else {
793
- controls.object.parent.matrixWorld.decompose(
794
- controls._parentPosition,
795
- controls._parentQuaternion,
796
- controls._parentScale
797
- );
798
- }
799
- const boundingBoxCenter = calculateBoundingBoxCenter(controls.object);
800
- controls.worldPosition.copy(boundingBoxCenter);
801
- controls.object.matrixWorld.decompose(
802
- controls._tempPosition,
803
- // Use temporary variable for position
804
- controls.worldQuaternion,
805
- controls._worldScale
806
- );
807
- controls._parentQuaternionInv.copy(controls._parentQuaternion).invert();
808
- controls._worldQuaternionInv.copy(controls.worldQuaternion).invert();
809
- }
810
- controls.camera.updateMatrixWorld();
811
- controls.camera.matrixWorld.decompose(
812
- controls.cameraPosition,
813
- controls.cameraQuaternion,
814
- controls._cameraScale
815
- );
816
- if (controls.camera.isOrthographicCamera) {
817
- controls.eye.copy(controls.cameraPosition).sub(controls.worldPosition).normalize();
818
- } else {
819
- controls.eye.copy(controls.cameraPosition).sub(controls.worldPosition).normalize();
820
- }
821
- super.updateMatrixWorld(force);
822
- }
823
- dispose() {
824
- this.traverse(function(child) {
825
- if (child.geometry) child.geometry.dispose();
826
- if (child.material) child.material.dispose();
827
- });
828
- }
829
- };
830
- var TransformControlsGizmo = class extends import_three.Object3D {
831
- constructor() {
832
- super();
833
- this.isTransformControlsGizmo = true;
834
- this.type = "TransformControlsGizmo";
835
- const gizmoMaterial = new import_three.MeshBasicMaterial({
836
- depthTest: false,
837
- depthWrite: false,
838
- fog: false,
839
- toneMapped: false,
840
- transparent: true
841
- });
842
- const gizmoLineMaterial = new import_three.LineBasicMaterial({
843
- depthTest: false,
844
- depthWrite: false,
845
- fog: false,
846
- toneMapped: false,
847
- transparent: true
848
- });
849
- const matInvisible = gizmoMaterial.clone();
850
- matInvisible.opacity = 0.15;
851
- const matHelper = gizmoLineMaterial.clone();
852
- matHelper.opacity = 0.5;
853
- const matRed = gizmoMaterial.clone();
854
- matRed.color.setHex(15549272);
855
- const matGreen = gizmoMaterial.clone();
856
- matGreen.color.setHex(8571929);
857
- const matBlue = gizmoMaterial.clone();
858
- matBlue.color.setHex(3245547);
859
- const matRedTransparent = gizmoMaterial.clone();
860
- matRedTransparent.color.setHex(15549272);
861
- matRedTransparent.opacity = 0.5;
862
- const matGreenTransparent = gizmoMaterial.clone();
863
- matGreenTransparent.color.setHex(8571929);
864
- matGreenTransparent.opacity = 0.5;
865
- const matBlueTransparent = gizmoMaterial.clone();
866
- matBlueTransparent.color.setHex(3245547);
867
- matBlueTransparent.opacity = 0.5;
868
- const matWhiteTransparent = gizmoMaterial.clone();
869
- matWhiteTransparent.opacity = 0.25;
870
- const matYellowTransparent = gizmoMaterial.clone();
871
- matYellowTransparent.color.setHex(16776960);
872
- matYellowTransparent.opacity = 0.25;
873
- const matYellow = gizmoMaterial.clone();
874
- matYellow.color.setHex(16776960);
875
- const matGray = gizmoMaterial.clone();
876
- matGray.color.setHex(7895160);
877
- const arrowGeometry = new import_three.CylinderGeometry(0, 0.04, 0.1, 12);
878
- arrowGeometry.translate(0, 0.05, 0);
879
- const scaleHandleGeometry = new import_three.BoxGeometry(0.08, 0.08, 0.08);
880
- scaleHandleGeometry.translate(0, 0.04, 0);
881
- const lineGeometry = new import_three.BufferGeometry();
882
- lineGeometry.setAttribute(
883
- "position",
884
- new import_three.Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3)
885
- );
886
- const lineGeometry2 = new import_three.CylinderGeometry(0.02, 0.02, 0.5, 3);
887
- lineGeometry2.translate(0, 0.25, 0);
888
- function CircleGeometry(radius, arc) {
889
- const geometry = new import_three.TorusGeometry(radius, 0.02, 3, 64, arc * Math.PI * 2);
890
- geometry.rotateY(Math.PI / 2);
891
- geometry.rotateX(Math.PI / 2);
892
- return geometry;
893
- }
894
- function TranslateHelperGeometry() {
895
- const geometry = new import_three.BufferGeometry();
896
- geometry.setAttribute(
897
- "position",
898
- new import_three.Float32BufferAttribute([0, 0, 0, 1, 1, 1], 3)
899
- );
900
- return geometry;
901
- }
902
- const gizmoTranslate = {
903
- X: [
904
- [new import_three.Mesh(arrowGeometry, matRed), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
905
- [new import_three.Mesh(lineGeometry2, matRed), [0, 0, 0], [0, 0, -Math.PI / 2]]
906
- ],
907
- Y: [
908
- [new import_three.Mesh(arrowGeometry, matGreen), [0, 0.5, 0]],
909
- [new import_three.Mesh(lineGeometry2, matGreen)]
910
- ],
911
- Z: [
912
- [new import_three.Mesh(arrowGeometry, matBlue), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
913
- [new import_three.Mesh(lineGeometry2, matBlue), null, [Math.PI / 2, 0, 0]]
914
- ]
915
- };
916
- const pickerTranslate = {
917
- X: [
918
- [
919
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
920
- [0.3, 0, 0],
921
- [0, 0, -Math.PI / 2]
922
- ],
923
- [
924
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
925
- [-0.3, 0, 0],
926
- [0, 0, Math.PI / 2]
927
- ]
928
- ],
929
- Y: [
930
- [
931
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
932
- [0, 0.3, 0]
933
- ],
934
- [
935
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
936
- [0, -0.3, 0],
937
- [0, 0, Math.PI]
938
- ]
939
- ],
940
- Z: [
941
- [
942
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
943
- [0, 0, 0.3],
944
- [Math.PI / 2, 0, 0]
945
- ],
946
- [
947
- new import_three.Mesh(new import_three.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible),
948
- [0, 0, -0.3],
949
- [-Math.PI / 2, 0, 0]
950
- ]
951
- ]
952
- };
953
- const helperTranslate = {
954
- START: [
955
- [
956
- new import_three.Mesh(new import_three.OctahedronGeometry(0.01, 2), matHelper),
957
- null,
958
- null,
959
- null,
960
- "helper"
961
- ]
962
- ],
963
- END: [
964
- [
965
- new import_three.Mesh(new import_three.OctahedronGeometry(0.01, 2), matHelper),
966
- null,
967
- null,
968
- null,
969
- "helper"
970
- ]
971
- ],
972
- DELTA: [
973
- [
974
- new import_three.Line(TranslateHelperGeometry(), matHelper),
975
- null,
976
- null,
977
- null,
978
- "helper"
979
- ]
980
- ]
981
- };
982
- const gizmoRotate = {
983
- X: [[new import_three.Mesh(CircleGeometry(0.45, 0.25), matRed)]],
984
- Y: [
985
- [
986
- new import_three.Mesh(CircleGeometry(0.45, 0.25), matGreen),
987
- null,
988
- [0, 0, -Math.PI / 2]
989
- ]
990
- ],
991
- Z: [
992
- [
993
- new import_three.Mesh(CircleGeometry(0.45, 0.25), matBlue),
994
- null,
995
- [0, Math.PI / 2, 0]
996
- ]
997
- ]
998
- };
999
- const helperRotate = {
1000
- AXIS: [],
1001
- START: [
1002
- [new import_three.Line(lineGeometry.clone(), matHelper), null, null, null, "helper"]
1003
- ],
1004
- END: [
1005
- [new import_three.Line(lineGeometry.clone(), matHelper), null, null, null, "helper"]
1006
- ],
1007
- ARC: [
1008
- [new import_three.Line(new import_three.BufferGeometry(), matHelper), null, null, null, "helper"]
1009
- ]
1010
- };
1011
- const pickerRotate = {
1012
- X: [[new import_three.Mesh(CircleGeometry(0.45, 0.25), matRed)]],
1013
- Y: [
1014
- [
1015
- new import_three.Mesh(CircleGeometry(0.45, 0.25), matGreen),
1016
- null,
1017
- [0, 0, -Math.PI / 2]
1018
- ]
1019
- ],
1020
- Z: [
1021
- [
1022
- new import_three.Mesh(CircleGeometry(0.45, 0.25), matBlue),
1023
- null,
1024
- [0, Math.PI / 2, 0]
1025
- ]
1026
- ]
1027
- };
1028
- const gizmoScale = {
1029
- X: [
1030
- [
1031
- new import_three.Mesh(scaleHandleGeometry, matRed),
1032
- [0.7, 0, 0],
1033
- [0, 0, -Math.PI / 2]
1034
- ]
1035
- ],
1036
- Y: [[new import_three.Mesh(scaleHandleGeometry, matGreen), [0, 0.7, 0]]],
1037
- Z: [
1038
- [
1039
- new import_three.Mesh(scaleHandleGeometry, matBlue),
1040
- [0, 0, 0.7],
1041
- [Math.PI / 2, 0, 0]
1042
- ]
1043
- ]
1044
- };
1045
- const pickerScale = {
1046
- X: [
1047
- [
1048
- new import_three.Mesh(new import_three.BoxGeometry(0.2, 0.2, 0.2), matInvisible),
1049
- [0.7, 0, 0],
1050
- [0, 0, -Math.PI / 2]
1051
- ]
1052
- ],
1053
- Y: [
1054
- [new import_three.Mesh(new import_three.BoxGeometry(0.2, 0.2, 0.2), matInvisible), [0, 0.7, 0]]
1055
- ],
1056
- Z: [
1057
- [
1058
- new import_three.Mesh(new import_three.BoxGeometry(0.2, 0.2, 0.2), matInvisible),
1059
- [0, 0, 0.7],
1060
- [Math.PI / 2, 0, 0]
1061
- ]
1062
- ]
1063
- };
1064
- const helperScale = {
1065
- X: [],
1066
- Y: [],
1067
- Z: []
1068
- };
1069
- function setupGizmo(gizmoMap) {
1070
- const gizmo = new import_three.Object3D();
1071
- for (const name in gizmoMap) {
1072
- for (let i = gizmoMap[name].length; i--; ) {
1073
- const object = gizmoMap[name][i][0].clone();
1074
- object.userData.type = "gizmo";
1075
- const position = gizmoMap[name][i][1];
1076
- const rotation = gizmoMap[name][i][2];
1077
- const scale = gizmoMap[name][i][3];
1078
- const tag = gizmoMap[name][i][4];
1079
- object.name = name;
1080
- object.tag = tag;
1081
- if (position) {
1082
- object.position.set(position[0], position[1], position[2]);
1083
- }
1084
- if (rotation) {
1085
- object.rotation.set(rotation[0], rotation[1], rotation[2]);
1086
- }
1087
- if (scale) {
1088
- object.scale.set(scale[0], scale[1], scale[2]);
1089
- }
1090
- object.updateMatrix();
1091
- const tempGeometry = object.geometry.clone();
1092
- tempGeometry.applyMatrix4(object.matrix);
1093
- object.geometry = tempGeometry;
1094
- object.renderOrder = Infinity;
1095
- object.position.set(0, 0, 0);
1096
- object.rotation.set(0, 0, 0);
1097
- object.scale.set(1, 1, 1);
1098
- gizmo.add(object);
1099
- }
1100
- }
1101
- return gizmo;
1102
- }
1103
- this.gizmo = {};
1104
- this.picker = {};
1105
- this.helper = {};
1106
- this.add(this.gizmo["translate"] = setupGizmo(gizmoTranslate));
1107
- this.add(this.gizmo["rotate"] = setupGizmo(gizmoRotate));
1108
- this.add(this.gizmo["scale"] = setupGizmo(gizmoScale));
1109
- this.add(this.picker["translate"] = setupGizmo(pickerTranslate));
1110
- this.add(this.picker["rotate"] = setupGizmo(pickerRotate));
1111
- this.add(this.picker["scale"] = setupGizmo(pickerScale));
1112
- this.add(this.helper["translate"] = setupGizmo(helperTranslate));
1113
- this.add(this.helper["rotate"] = setupGizmo(helperRotate));
1114
- this.add(this.helper["scale"] = setupGizmo(helperScale));
1115
- this.picker["translate"].visible = false;
1116
- this.picker["rotate"].visible = false;
1117
- this.picker["scale"].visible = false;
1118
- }
1119
- // updateMatrixWorld will update transformations and appearance of individual handles
1120
- updateMatrixWorld(force) {
1121
- const space = this.mode === "scale" ? "local" : this.space;
1122
- const quaternion = space === "local" ? this.worldQuaternion : _identityQuaternion;
1123
- if (this.mode === "all") {
1124
- this.gizmo["translate"].visible = true;
1125
- this.gizmo["rotate"].visible = true;
1126
- this.gizmo["scale"].visible = true;
1127
- this.helper["translate"].visible = true;
1128
- this.helper["rotate"].visible = true;
1129
- this.helper["scale"].visible = false;
1130
- } else {
1131
- this.gizmo["translate"].visible = this.mode === "translate";
1132
- this.gizmo["rotate"].visible = this.mode === "rotate";
1133
- this.gizmo["scale"].visible = this.mode === "scale";
1134
- this.helper["translate"].visible = this.mode === "translate";
1135
- this.helper["rotate"].visible = this.mode === "rotate";
1136
- this.helper["scale"].visible = this.mode === "scale";
1137
- }
1138
- let handles = [];
1139
- if (this.mode === "all") {
1140
- handles = handles.concat(this.picker["translate"].children);
1141
- handles = handles.concat(this.picker["rotate"].children);
1142
- handles = handles.concat(this.picker["scale"].children);
1143
- handles = handles.concat(this.gizmo["translate"].children);
1144
- handles = handles.concat(this.gizmo["rotate"].children);
1145
- handles = handles.concat(this.gizmo["scale"].children);
1146
- handles = handles.concat(this.helper["translate"].children);
1147
- handles = handles.concat(this.helper["rotate"].children);
1148
- } else {
1149
- handles = handles.concat(this.picker[this.mode].children);
1150
- handles = handles.concat(this.gizmo[this.mode].children);
1151
- handles = handles.concat(this.helper[this.mode].children);
1152
- }
1153
- for (let i = 0; i < handles.length; i++) {
1154
- const handle = handles[i];
1155
- handle.visible = true;
1156
- handle.rotation.set(0, 0, 0);
1157
- handle.position.copy(this.worldPosition);
1158
- let factor;
1159
- if (this.camera.isOrthographicCamera) {
1160
- factor = (this.camera.top - this.camera.bottom) / this.camera.zoom;
1161
- } else {
1162
- factor = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(
1163
- 1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom,
1164
- 7
1165
- );
1166
- }
1167
- handle.scale.set(1, 1, 1).multiplyScalar(factor * this.size / 4);
1168
- if (handle.tag === "helper") {
1169
- handle.visible = false;
1170
- if (handle.name === "AXIS") {
1171
- handle.visible = !!this.axis;
1172
- if (this.axis === "X") {
1173
- _tempQuaternion.setFromEuler(_tempEuler.set(0, 0, 0));
1174
- handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
1175
- if (Math.abs(
1176
- _alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)
1177
- ) > 0.9) {
1178
- handle.visible = false;
1179
- }
1180
- }
1181
- if (this.axis === "Y") {
1182
- _tempQuaternion.setFromEuler(_tempEuler.set(0, 0, Math.PI / 2));
1183
- handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
1184
- if (Math.abs(
1185
- _alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)
1186
- ) > 0.9) {
1187
- handle.visible = false;
1188
- }
1189
- }
1190
- if (this.axis === "Z") {
1191
- _tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
1192
- handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
1193
- if (Math.abs(
1194
- _alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)
1195
- ) > 0.9) {
1196
- handle.visible = false;
1197
- }
1198
- }
1199
- if (this.axis === "XYZE") {
1200
- _tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
1201
- _alignVector.copy(this.rotationAxis);
1202
- handle.quaternion.setFromRotationMatrix(
1203
- _lookAtMatrix.lookAt(_zeroVector, _alignVector, _unitY)
1204
- );
1205
- handle.quaternion.multiply(_tempQuaternion);
1206
- handle.visible = this.dragging;
1207
- }
1208
- if (this.axis === "E") {
1209
- handle.visible = false;
1210
- }
1211
- } else if (handle.name === "START") {
1212
- if (this.mode === "rotate" || this.mode === "all") {
1213
- handle.position.copy(this.worldPosition);
1214
- const isRotating = this.mode === "rotate" || this.mode === "all" && this.activeMode === "rotate";
1215
- handle.visible = this.dragging && isRotating;
1216
- if (handle.visible) {
1217
- const rotSpace = this.space;
1218
- if (rotSpace === "local") {
1219
- handle.quaternion.copy(this.worldQuaternionStart);
1220
- } else {
1221
- handle.quaternion.copy(_identityQuaternion);
1222
- }
1223
- let rotAxis = new import_three.Vector3();
1224
- if (this.axis === "X" || this.axis === "Y" || this.axis === "Z") {
1225
- rotAxis.copy(_unit[this.axis]);
1226
- } else if (this.axis === "E" || this.axis === "XYZE") {
1227
- rotAxis.copy(this.rotationAxis);
1228
- if (rotSpace === "local") {
1229
- rotAxis.applyQuaternion(
1230
- this.worldQuaternionStart.clone().invert()
1231
- );
1232
- }
1233
- }
1234
- let startPoint = this.pointStart.clone();
1235
- if (rotSpace === "local") {
1236
- startPoint.applyQuaternion(
1237
- this.worldQuaternionStart.clone().invert()
1238
- );
1239
- }
1240
- const dotProduct = startPoint.dot(rotAxis);
1241
- startPoint.sub(rotAxis.clone().multiplyScalar(dotProduct));
1242
- startPoint.normalize();
1243
- startPoint.multiplyScalar(0.45);
1244
- const startLineGeometry = new import_three.BufferGeometry();
1245
- startLineGeometry.setAttribute(
1246
- "position",
1247
- new import_three.Float32BufferAttribute(
1248
- [0, 0, 0, startPoint.x, startPoint.y, startPoint.z],
1249
- 3
1250
- )
1251
- );
1252
- handle.geometry.dispose();
1253
- handle.geometry = startLineGeometry;
1254
- }
1255
- } else {
1256
- handle.position.copy(this.worldPositionStart);
1257
- handle.visible = this.dragging && this.mode === "translate";
1258
- }
1259
- } else if (handle.name === "ARC") {
1260
- const isRotating = this.mode === "rotate" || this.mode === "all" && this.activeMode === "rotate";
1261
- handle.visible = this.dragging && isRotating;
1262
- if (handle.visible && this.rotationAngle !== 0) {
1263
- handle.position.copy(this.worldPosition);
1264
- const rotSpace = this.space;
1265
- if (rotSpace === "local") {
1266
- handle.quaternion.copy(this.worldQuaternionStart);
1267
- } else {
1268
- handle.quaternion.copy(_identityQuaternion);
1269
- }
1270
- const arcRadius = 0.45;
1271
- const segments = Math.max(
1272
- 8,
1273
- Math.floor(Math.abs(this.rotationAngle) * 50)
1274
- );
1275
- const arcPoints = [];
1276
- let rotAxis = new import_three.Vector3();
1277
- if (this.axis === "X" || this.axis === "Y" || this.axis === "Z") {
1278
- rotAxis.copy(_unit[this.axis]);
1279
- if (rotSpace !== "local") {
1280
- }
1281
- } else if (this.axis === "E" || this.axis === "XYZE") {
1282
- rotAxis.copy(this.rotationAxis);
1283
- if (rotSpace === "local") {
1284
- rotAxis.applyQuaternion(
1285
- this.worldQuaternionStart.clone().invert()
1286
- );
1287
- }
1288
- }
1289
- let startDir = this.pointStart.clone();
1290
- if (rotSpace === "local") {
1291
- startDir.applyQuaternion(
1292
- this.worldQuaternionStart.clone().invert()
1293
- );
1294
- }
1295
- const dotProduct = startDir.dot(rotAxis);
1296
- startDir.sub(rotAxis.clone().multiplyScalar(dotProduct));
1297
- startDir.normalize();
1298
- for (let j = 0; j <= segments; j++) {
1299
- const angle = this.rotationAngle * j / segments;
1300
- const point = startDir.clone();
1301
- const arcQuat = new import_three.Quaternion().setFromAxisAngle(rotAxis, angle);
1302
- point.applyQuaternion(arcQuat);
1303
- point.multiplyScalar(arcRadius);
1304
- arcPoints.push(point.x, point.y, point.z);
1305
- }
1306
- const arcGeometry = new import_three.BufferGeometry();
1307
- arcGeometry.setAttribute(
1308
- "position",
1309
- new import_three.Float32BufferAttribute(arcPoints, 3)
1310
- );
1311
- handle.geometry.dispose();
1312
- handle.geometry = arcGeometry;
1313
- }
1314
- } else if (handle.name === "END") {
1315
- if (this.mode === "rotate" || this.mode === "all") {
1316
- handle.position.copy(this.worldPosition);
1317
- const isRotating = this.mode === "rotate" || this.mode === "all" && this.activeMode === "rotate";
1318
- handle.visible = this.dragging && isRotating;
1319
- if (handle.visible) {
1320
- const rotSpace = this.space;
1321
- if (rotSpace === "local") {
1322
- handle.quaternion.copy(this.worldQuaternionStart);
1323
- } else {
1324
- handle.quaternion.copy(_identityQuaternion);
1325
- }
1326
- const endLineGeometry = new import_three.BufferGeometry();
1327
- let rotAxis = new import_three.Vector3();
1328
- if (this.axis === "X" || this.axis === "Y" || this.axis === "Z") {
1329
- rotAxis.copy(_unit[this.axis]);
1330
- } else if (this.axis === "E" || this.axis === "XYZE") {
1331
- rotAxis.copy(this.rotationAxis);
1332
- if (rotSpace === "local") {
1333
- rotAxis.applyQuaternion(
1334
- this.worldQuaternionStart.clone().invert()
1335
- );
1336
- }
1337
- }
1338
- let startDir = this.pointStart.clone();
1339
- if (rotSpace === "local") {
1340
- startDir.applyQuaternion(
1341
- this.worldQuaternionStart.clone().invert()
1342
- );
1343
- }
1344
- const dotProduct = startDir.dot(rotAxis);
1345
- startDir.sub(rotAxis.clone().multiplyScalar(dotProduct));
1346
- startDir.normalize();
1347
- const endPoint = startDir.clone();
1348
- const arcQuat = new import_three.Quaternion().setFromAxisAngle(
1349
- rotAxis,
1350
- this.rotationAngle
1351
- );
1352
- endPoint.applyQuaternion(arcQuat);
1353
- endPoint.multiplyScalar(0.45);
1354
- endLineGeometry.setAttribute(
1355
- "position",
1356
- new import_three.Float32BufferAttribute(
1357
- [0, 0, 0, endPoint.x, endPoint.y, endPoint.z],
1358
- 3
1359
- )
1360
- );
1361
- handle.geometry.dispose();
1362
- handle.geometry = endLineGeometry;
1363
- }
1364
- } else {
1365
- handle.position.copy(this.worldPosition);
1366
- handle.visible = false;
1367
- }
1368
- } else if (handle.name === "DELTA") {
1369
- handle.position.copy(this.worldPositionStart);
1370
- handle.quaternion.copy(this.worldQuaternionStart);
1371
- _tempVector.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1);
1372
- _tempVector.applyQuaternion(
1373
- this.worldQuaternionStart.clone().invert()
1374
- );
1375
- handle.scale.copy(_tempVector);
1376
- handle.visible = this.dragging;
1377
- } else {
1378
- handle.quaternion.copy(quaternion);
1379
- if (this.dragging) {
1380
- handle.position.copy(this.worldPositionStart);
1381
- } else {
1382
- handle.position.copy(this.worldPosition);
1383
- }
1384
- if (this.axis) {
1385
- handle.visible = this.axis.search(handle.name) !== -1;
1386
- }
1387
- }
1388
- continue;
1389
- }
1390
- handle.quaternion.copy(quaternion);
1391
- if (this.mode === "translate" || this.mode === "scale") {
1392
- const AXIS_HIDE_THRESHOLD = 0.99;
1393
- const PLANE_HIDE_THRESHOLD = 0.2;
1394
- if (handle.name === "X") {
1395
- if (Math.abs(
1396
- _alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)
1397
- ) > AXIS_HIDE_THRESHOLD) {
1398
- handle.scale.set(1e-10, 1e-10, 1e-10);
1399
- handle.visible = false;
1400
- }
1401
- }
1402
- if (handle.name === "Y") {
1403
- if (Math.abs(
1404
- _alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)
1405
- ) > AXIS_HIDE_THRESHOLD) {
1406
- handle.scale.set(1e-10, 1e-10, 1e-10);
1407
- handle.visible = false;
1408
- }
1409
- }
1410
- if (handle.name === "Z") {
1411
- if (Math.abs(
1412
- _alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)
1413
- ) > AXIS_HIDE_THRESHOLD) {
1414
- handle.scale.set(1e-10, 1e-10, 1e-10);
1415
- handle.visible = false;
1416
- }
1417
- }
1418
- if (handle.name === "XY") {
1419
- if (Math.abs(
1420
- _alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)
1421
- ) < PLANE_HIDE_THRESHOLD) {
1422
- handle.scale.set(1e-10, 1e-10, 1e-10);
1423
- handle.visible = false;
1424
- }
1425
- }
1426
- if (handle.name === "YZ") {
1427
- if (Math.abs(
1428
- _alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)
1429
- ) < PLANE_HIDE_THRESHOLD) {
1430
- handle.scale.set(1e-10, 1e-10, 1e-10);
1431
- handle.visible = false;
1432
- }
1433
- }
1434
- if (handle.name === "XZ") {
1435
- if (Math.abs(
1436
- _alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)
1437
- ) < PLANE_HIDE_THRESHOLD) {
1438
- handle.scale.set(1e-10, 1e-10, 1e-10);
1439
- handle.visible = false;
1440
- }
1441
- }
1442
- } else if (this.mode === "rotate") {
1443
- _tempQuaternion2.copy(quaternion);
1444
- _alignVector.copy(this.eye).applyQuaternion(_tempQuaternion.copy(quaternion).invert());
1445
- if (handle.name.search("E") !== -1) {
1446
- handle.quaternion.setFromRotationMatrix(
1447
- _lookAtMatrix.lookAt(this.eye, _zeroVector, _unitY)
1448
- );
1449
- }
1450
- if (handle.name === "X") {
1451
- _tempQuaternion.setFromAxisAngle(
1452
- _unitX,
1453
- Math.atan2(-_alignVector.y, _alignVector.z)
1454
- );
1455
- _tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
1456
- handle.quaternion.copy(_tempQuaternion);
1457
- }
1458
- if (handle.name === "Y") {
1459
- _tempQuaternion.setFromAxisAngle(
1460
- _unitY,
1461
- Math.atan2(_alignVector.x, _alignVector.z)
1462
- );
1463
- _tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
1464
- handle.quaternion.copy(_tempQuaternion);
1465
- }
1466
- if (handle.name === "Z") {
1467
- _tempQuaternion.setFromAxisAngle(
1468
- _unitZ,
1469
- Math.atan2(_alignVector.y, _alignVector.x)
1470
- );
1471
- _tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
1472
- handle.quaternion.copy(_tempQuaternion);
1473
- }
1474
- }
1475
- handle.visible = handle.visible && (handle.name.indexOf("X") === -1 || this.showX);
1476
- handle.visible = handle.visible && (handle.name.indexOf("Y") === -1 || this.showY);
1477
- handle.visible = handle.visible && (handle.name.indexOf("Z") === -1 || this.showZ);
1478
- handle.visible = handle.visible && (handle.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ);
1479
- handle.material._color = handle.material._color || handle.material.color.clone();
1480
- handle.material._opacity = handle.material._opacity || handle.material.opacity;
1481
- handle.material.color.copy(handle.material._color);
1482
- handle.material.opacity = handle.material._opacity;
1483
- if (this.dragging) {
1484
- handle.material.opacity = 0.2;
1485
- }
1486
- if (this.enabled && this.axis) {
1487
- if (handle.name === this.axis) {
1488
- handle.material.color.setHex(16776960);
1489
- if (!this.dragging) {
1490
- handle.material.opacity = 1;
1491
- }
1492
- } else if (this.axis.split("").some(function(a) {
1493
- return handle.name === a;
1494
- })) {
1495
- handle.material.color.setHex(16776960);
1496
- if (!this.dragging) {
1497
- handle.material.opacity = 1;
1498
- }
1499
- }
1500
- }
1501
- }
1502
- super.updateMatrixWorld(force);
1503
- }
1504
- };
1505
- var TransformControlsPlane = class extends import_three.Mesh {
1506
- constructor() {
1507
- super(
1508
- new import_three.PlaneGeometry(1e5, 1e5, 2, 2),
1509
- new import_three.MeshBasicMaterial({
1510
- visible: false,
1511
- wireframe: true,
1512
- side: import_three.DoubleSide,
1513
- transparent: true,
1514
- opacity: 0.1,
1515
- toneMapped: false
1516
- })
1517
- );
1518
- this.isTransformControlsPlane = true;
1519
- this.type = "TransformControlsPlane";
1520
- }
1521
- updateMatrixWorld(force) {
1522
- let space = this.space;
1523
- this.position.copy(this.worldPosition);
1524
- if (this.mode === "scale") space = "local";
1525
- _v1.copy(_unitX).applyQuaternion(
1526
- space === "local" ? this.worldQuaternion : _identityQuaternion
1527
- );
1528
- _v2.copy(_unitY).applyQuaternion(
1529
- space === "local" ? this.worldQuaternion : _identityQuaternion
1530
- );
1531
- _v3.copy(_unitZ).applyQuaternion(
1532
- space === "local" ? this.worldQuaternion : _identityQuaternion
1533
- );
1534
- _alignVector.copy(_v2);
1535
- switch (this.mode) {
1536
- case "translate":
1537
- case "scale":
1538
- switch (this.axis) {
1539
- case "X":
1540
- _alignVector.copy(this.eye).cross(_v1);
1541
- _dirVector.copy(_v1).cross(_alignVector);
1542
- break;
1543
- case "Y":
1544
- _alignVector.copy(this.eye).cross(_v2);
1545
- _dirVector.copy(_v2).cross(_alignVector);
1546
- break;
1547
- case "Z":
1548
- _alignVector.copy(this.eye).cross(_v3);
1549
- _dirVector.copy(_v3).cross(_alignVector);
1550
- break;
1551
- case "XY":
1552
- _dirVector.copy(_v3);
1553
- break;
1554
- case "YZ":
1555
- _dirVector.copy(_v1);
1556
- break;
1557
- case "XZ":
1558
- _alignVector.copy(_v3);
1559
- _dirVector.copy(_v2);
1560
- break;
1561
- case "XYZ":
1562
- case "E":
1563
- _dirVector.set(0, 0, 0);
1564
- break;
1565
- }
1566
- break;
1567
- case "rotate":
1568
- default:
1569
- _dirVector.set(0, 0, 0);
1570
- }
1571
- if (_dirVector.length() === 0) {
1572
- this.quaternion.copy(this.cameraQuaternion);
1573
- } else {
1574
- _tempMatrix.lookAt(_tempVector.set(0, 0, 0), _dirVector, _alignVector);
1575
- this.quaternion.setFromRotationMatrix(_tempMatrix);
1576
- }
1577
- super.updateMatrixWorld(force);
1578
- }
1579
- };
1580
- // Annotate the CommonJS export names for ESM import in node:
1581
- 0 && (module.exports = {
1582
- TransformControls,
1583
- TransformControlsGizmo,
1584
- TransformControlsPlane,
1585
- calculateBoundingBoxCenter
1586
- });
1
+ "use strict";var tt=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var vt=(c,n)=>{for(var i in n)tt(c,i,{get:n[i],enumerable:!0})},St=(c,n,i,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of xt(n))!gt.call(c,o)&&o!==i&&tt(c,o,{get:()=>n[o],enumerable:!(s=_t(n,o))||s.enumerable});return c};var Pt=c=>St(tt({},"__esModule",{value:!0}),c);var It={};vt(It,{TransformControls:()=>ot,TransformControlsGizmo:()=>J,TransformControlsPlane:()=>K,calculateBoundingBoxCenter:()=>st});module.exports=Pt(It);var t=require("three"),it=require("three/examples/jsm/renderers/CSS2DRenderer.js"),v=new t.Raycaster,u=new t.Vector3,L=new t.Vector3,d=new t.Quaternion,T={X:new t.Vector3(1,0,0),Y:new t.Vector3(0,1,0),Z:new t.Vector3(0,0,1)},et={type:"change"},rt={type:"mouseDown",mode:null},lt={type:"mouseUp",mode:null},ct={type:"objectChange"},ot=class extends t.Controls{constructor(n,i=null){super(void 0,i);let s=new nt(this);this._root=s;let o=new J;this._gizmo=o,s.add(o);let r=new K;this._plane=r,s.add(r);let e=this;this._overlay=document.createElement("div"),this._overlay.classList.add("absolute"),this._overlay.classList.add("bottom-2"),this._overlay.classList.add("left-80"),this._overlay.classList.add("z-50"),this._overlay.classList.add("bg-gray-700"),this._overlay.classList.add("bg-opacity-70"),this._overlay.classList.add("text-white"),this._overlay.classList.add("p-2"),this._overlay.classList.add("rounded-md"),this._overlay.classList.add("border"),this._overlay.classList.add("border-gray-500"),this._overlay.classList.add("hidden"),i&&i.appendChild(this._overlay);let l=document.createElement("div");l.className="distance-label",l.style.padding="4px 8px",l.style.background="rgba(0, 0, 0, 0.8)",l.style.border="1px solid rgba(255, 255, 255, 0.3)",l.style.borderRadius="4px",l.style.color="#fff",l.style.fontSize="12px",l.style.fontFamily="monospace",l.style.whiteSpace="nowrap",l.style.pointerEvents="none",l.style.userSelect="none",l.textContent="0.00",this._distanceLabel=new it.CSS2DObject(l),this._distanceLabel.visible=!1,s.add(this._distanceLabel);let h=document.createElement("div");h.className="rotation-angle-label",h.style.padding="4px 8px",h.style.background="rgba(0, 0, 0, 0.8)",h.style.border="1px solid rgba(255, 255, 255, 0.3)",h.style.borderRadius="4px",h.style.color="#fff",h.style.fontSize="12px",h.style.fontFamily="monospace",h.style.whiteSpace="nowrap",h.style.pointerEvents="none",h.style.userSelect="none",h.textContent="0\xB0",this._rotationAngleLabel=new it.CSS2DObject(h),this._rotationAngleLabel.visible=!1,s.add(this._rotationAngleLabel),this._rotationArc=null;function a(Q,Y){let Z=Y;Object.defineProperty(e,Q,{get:function(){return Z!==void 0?Z:Y},set:function(D){Z!==D&&(Z=D,r[Q]=D,o[Q]=D,e.dispatchEvent({type:Q+"-changed",value:D}),e.dispatchEvent(et))}}),e[Q]=Y,r[Q]=Y,o[Q]=Y}a("camera",n),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","all"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",.75),a("dragging",!1),a("activeMode","translate"),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0),a("minRotation",-2*Math.PI),a("maxRotation",2*Math.PI);let y=new t.Vector3,m=new t.Vector3,f=new t.Quaternion,w=new t.Quaternion,_=new t.Vector3,P=new t.Quaternion,E=new t.Vector3,A=new t.Vector3,I=new t.Vector3,x=0,C=new t.Vector3;a("worldPosition",y),a("worldPositionStart",m),a("worldQuaternion",f),a("worldQuaternionStart",w),a("cameraPosition",_),a("cameraQuaternion",P),a("pointStart",E),a("pointEnd",A),a("rotationAxis",I),a("rotationAngle",x),a("eye",C),this._offset=new t.Vector3,this._startNorm=new t.Vector3,this._endNorm=new t.Vector3,this._cameraScale=new t.Vector3,this._parentPosition=new t.Vector3,this._parentQuaternion=new t.Quaternion,this._parentQuaternionInv=new t.Quaternion,this._parentScale=new t.Vector3,this._worldScaleStart=new t.Vector3,this._worldQuaternionInv=new t.Quaternion,this._worldScale=new t.Vector3,this._tempPosition=new t.Vector3,this._positionStart=new t.Vector3,this._quaternionStart=new t.Quaternion,this._scaleStart=new t.Vector3,this._getPointer=Mt.bind(this),this._onPointerDown=At.bind(this),this._onPointerHover=Et.bind(this),this._onPointerMove=Qt.bind(this),this._onPointerUp=zt.bind(this),i!==null&&this.connect(i)}connect(n){super.connect(n),this.domElement?.parentNode&&this.domElement.parentNode.appendChild(this._overlay),this.domElement?.addEventListener("pointerdown",this._onPointerDown),this.domElement?.addEventListener("pointermove",this._onPointerHover),this.domElement?.addEventListener("pointerup",this._onPointerUp),this.domElement&&(this.domElement.style.touchAction="none")}disconnect(){this._overlay.parentNode&&this._overlay.parentNode.removeChild(this._overlay),this.domElement?.removeEventListener("pointerdown",this._onPointerDown),this.domElement?.removeEventListener("pointermove",this._onPointerHover),this.domElement?.removeEventListener("pointermove",this._onPointerMove),this.domElement?.removeEventListener("pointerup",this._onPointerUp),this.domElement&&(this.domElement.style.touchAction="auto")}getHelper(){return this._root}pointerHover(n){if(this.object===void 0||this.dragging===!0)return;n!==null&&v.setFromCamera(n,this.camera);let i=null;this.mode==="all"?(i=X(this._gizmo.picker.scale,v),i||(i=X(this._gizmo.picker.rotate,v)),i||(i=X(this._gizmo.picker.translate,v))):i=X(this._gizmo.picker[this.mode],v),i?this.axis=i.object.name:this.axis=null}pointerDown(n){if(!(this.object===void 0||this.dragging===!0||n!=null&&n.button!==0)&&this.axis!==null){if(n!==null&&v.setFromCamera(n,this.camera),this.mode==="all"){let s=X(this._gizmo.picker.scale,v);s&&s.object.name===this.axis?this.activeMode="scale":(s=X(this._gizmo.picker.rotate,v),s&&s.object.name===this.axis?this.activeMode="rotate":this.activeMode="translate")}else this.activeMode=this.mode;let i=X(this._plane,v,!0);if(i){this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale);let s=st(this.object);this.worldPositionStart.copy(s),this.object.matrixWorld.decompose(this._tempPosition,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(i.point).sub(this.worldPositionStart)}this.dragging=!0,rt.mode=this.mode==="all"?this.activeMode:this.mode,this.dispatchEvent(rt)}}pointerMove(n){let i=this.axis,s=this.mode==="all"?this.activeMode:this.mode,o=this.object,r=this.space;if(s==="scale"?r="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(r="world"),o===void 0||i===null||this.dragging===!1||n!==null&&n.button!==-1){this._updateDistanceOverlay();return}n!==null&&v.setFromCamera(n,this.camera);let e=X(this._plane,v,!0);if(e){if(this.pointEnd.copy(e.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&i!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),i.indexOf("X")===-1&&(this._offset.x=0),i.indexOf("Y")===-1&&(this._offset.y=0),i.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&i!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),o.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(o.position.applyQuaternion(d.copy(this._quaternionStart).invert()),i.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.position.applyQuaternion(this._quaternionStart)),r==="world"&&(o.parent&&o.position.add(u.setFromMatrixPosition(o.parent.matrixWorld)),i.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.parent&&o.position.sub(u.setFromMatrixPosition(o.parent.matrixWorld)))),o.position.x=Math.max(this.minX,Math.min(this.maxX,o.position.x)),o.position.y=Math.max(this.minY,Math.min(this.maxY,o.position.y)),o.position.z=Math.max(this.minZ,Math.min(this.maxZ,o.position.z));else if(s==="scale"){if(i.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),L.set(l,l,l)}else u.copy(this.pointStart),L.copy(this.pointEnd),u.applyQuaternion(this._worldQuaternionInv),L.applyQuaternion(this._worldQuaternionInv),L.divide(u),i.search("X")===-1&&(L.x=1),i.search("Y")===-1&&(L.y=1),i.search("Z")===-1&&(L.z=1);o.scale.copy(this._scaleStart).multiply(L),this.scaleSnap&&(i.search("X")!==-1&&(o.scale.x=Math.round(o.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(o.scale.y=Math.round(o.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(o.scale.z=Math.round(o.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);let l=20/this.worldPosition.distanceTo(u.setFromMatrixPosition(this.camera.matrixWorld)),h=!1;i==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(u.copy(this.rotationAxis).cross(this.eye))*l):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(T[i]),u.copy(T[i]),r==="local"&&u.applyQuaternion(this.worldQuaternion),u.cross(this.eye),u.length()===0?h=!0:this.rotationAngle=this._offset.dot(u.normalize())*l),(i==="E"||h)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),this.rotationAngle=Math.max(this.minRotation,Math.min(this.maxRotation,this.rotationAngle)),r==="local"&&i!=="E"&&i!=="XYZE"?(o.quaternion.copy(this._quaternionStart),o.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),o.quaternion.copy(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),o.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(et),this.dispatchEvent(ct),this._updateDistanceOverlay()}}pointerUp(n){n!==null&&n.button!==0||(this.dragging&&this.axis!==null&&(lt.mode=this.mode,this.dispatchEvent(lt)),this.dragging=!1,this.axis=null,this._updateDistanceOverlay())}dispose(){this.disconnect(),this._root.dispose()}attach(n){return this.object=n,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(et),this.dispatchEvent(ct),this.pointStart.copy(this.pointEnd))}getRaycaster(){return v}getMode(){return this.mode}setMode(n){}setTranslationSnap(n){this.translationSnap=n}setRotationSnap(n){this.rotationSnap=n}setMinRotation(n){this.minRotation=n}setMaxRotation(n){this.maxRotation=n}setScaleSnap(n){this.scaleSnap=n}setSize(n){this.size=n}setSpace(n){this.space=n}_updateDistanceOverlay(){if(!this.object||!this.dragging){this._overlay.classList.add("hidden"),this._distanceLabel.visible=!1,this._rotationAngleLabel.visible=!1;return}if(this.mode==="translate"||this.mode==="all"&&this.activeMode==="translate"){let n=this.object.position.x-this._positionStart.x,i=this.object.position.y-this._positionStart.y,s=this.object.position.z-this._positionStart.z,o=Math.sqrt(n*n+i*i+s*s),r=new t.Vector3((this._positionStart.x+this.object.position.x)/2,(this._positionStart.y+this.object.position.y)/2,(this._positionStart.z+this.object.position.z)/2);this._distanceLabel.position.copy(r),this._distanceLabel.visible=!0,this._rotationAngleLabel.visible=!1,this._distanceLabel.element.textContent=`${o.toFixed(3)}`,this._overlay.textContent=`X: ${n.toFixed(2)} Y: ${i.toFixed(2)} Z: ${s.toFixed(2)}`}else if(this.mode==="rotate"||this.mode==="all"&&this.activeMode==="rotate"){this._distanceLabel.visible=!1;let n=this.rotationAngle*180/Math.PI,i=.55,s=this.rotationAngle/2,o=new t.Vector3;if(this.axis==="X"||this.axis==="Y"||this.axis==="Z"){let r=T[this.axis],e=new t.Vector3;Math.abs(r.dot(this.pointStart.clone().normalize()))>.99?e.copy(this.eye).cross(r).normalize():e.copy(this.pointStart).normalize();let l=new t.Quaternion().setFromAxisAngle(r,s);e.applyQuaternion(l),this.space==="local"&&e.applyQuaternion(this.worldQuaternion),e.multiplyScalar(i),o.copy(this.worldPosition).add(e)}else{o.copy(this.worldPosition);let r=this.pointStart.clone().normalize();this.space==="local"&&r.applyQuaternion(this.worldQuaternion),r.multiplyScalar(i),o.add(r)}this._rotationAngleLabel.position.copy(o),this._rotationAngleLabel.visible=!0,this._rotationAngleLabel.element.textContent=`${Math.abs(n).toFixed(1)}\xB0`,this._overlay.textContent=`X: ${(this.object.rotation.x*(180/Math.PI)).toFixed(2)}\xB0 Y: ${(this.object.rotation.y*(180/Math.PI)).toFixed(2)}\xB0 Z: ${(this.object.rotation.z*(180/Math.PI)).toFixed(2)}\xB0`}else this.mode==="scale"&&(this._distanceLabel.visible=!1,this._rotationAngleLabel.visible=!1,this._overlay.textContent=`X: ${this.object.scale.x.toFixed(2)} Y: ${this.object.scale.y.toFixed(2)} Z: ${this.object.scale.z.toFixed(2)}`);this._overlay.classList.remove("hidden")}};function Mt(c){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:c.button};{let n=this.domElement.getBoundingClientRect();return{x:(c.clientX-n.left)/n.width*2-1,y:-(c.clientY-n.top)/n.height*2+1,button:c.button}}}function Et(c){if(this.enabled)switch(c.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(c));break}}function At(c){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(c.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(c)),this.pointerDown(this._getPointer(c)))}function Qt(c){this.enabled&&this.pointerMove(this._getPointer(c))}function zt(c){this.enabled&&(this.domElement.releasePointerCapture(c.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(c)))}function X(c,n,i){let s=n.intersectObject(c,!0);for(let o=0;o<s.length;o++)if(s[o].object.visible||i)return s[o];return!1}var V=new t.Euler,p=new t.Vector3(0,1,0),ht=new t.Vector3(0,0,0),pt=new t.Matrix4,$=new t.Quaternion,H=new t.Quaternion,M=new t.Vector3,dt=new t.Matrix4,F=new t.Vector3(1,0,0),j=new t.Vector3(0,1,0),O=new t.Vector3(0,0,1),U=new t.Vector3,k=new t.Vector3,q=new t.Vector3;function st(c){let n=new t.Box3;if(c.traverse(s=>{s.isMesh&&s.geometry&&(s.geometry.computeBoundingBox(),n.expandByObject(s))}),n.isEmpty())return c.getWorldPosition(new t.Vector3);let i=new t.Vector3;return n.getCenter(i),i}var nt=class extends t.Object3D{constructor(n){super(),this.isTransformControlsRoot=!0,this.controls=n,this.visible=!1}updateMatrixWorld(n){let i=this.controls;if(i.object!==void 0){i.object.updateMatrixWorld(),i.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):i.object.parent.matrixWorld.decompose(i._parentPosition,i._parentQuaternion,i._parentScale);let s=st(i.object);i.worldPosition.copy(s),i.object.matrixWorld.decompose(i._tempPosition,i.worldQuaternion,i._worldScale),i._parentQuaternionInv.copy(i._parentQuaternion).invert(),i._worldQuaternionInv.copy(i.worldQuaternion).invert()}i.camera.updateMatrixWorld(),i.camera.matrixWorld.decompose(i.cameraPosition,i.cameraQuaternion,i._cameraScale),i.camera.isOrthographicCamera,i.eye.copy(i.cameraPosition).sub(i.worldPosition).normalize(),super.updateMatrixWorld(n)}dispose(){this.traverse(function(n){n.geometry&&n.geometry.dispose(),n.material&&n.material.dispose()})}},J=class extends t.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";let n=new t.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new t.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=n.clone();s.opacity=.15;let o=i.clone();o.opacity=.5;let r=n.clone();r.color.setHex(15549272);let e=n.clone();e.color.setHex(8571929);let l=n.clone();l.color.setHex(3245547);let h=n.clone();h.color.setHex(15549272),h.opacity=.5;let a=n.clone();a.color.setHex(8571929),a.opacity=.5;let y=n.clone();y.color.setHex(3245547),y.opacity=.5;let m=n.clone();m.opacity=.25;let f=n.clone();f.color.setHex(16776960),f.opacity=.25,n.clone().color.setHex(16776960),n.clone().color.setHex(7895160);let P=new t.CylinderGeometry(0,.04,.1,12);P.translate(0,.05,0);let E=new t.BoxGeometry(.08,.08,.08);E.translate(0,.04,0);let A=new t.BufferGeometry;A.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,0,0],3));let I=new t.CylinderGeometry(.02,.02,.5,3);I.translate(0,.25,0);function x(g,G){let S=new t.TorusGeometry(g,.02,3,64,G*Math.PI*2);return S.rotateY(Math.PI/2),S.rotateX(Math.PI/2),S}function C(){let g=new t.BufferGeometry;return g.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,1,1],3)),g}let Q={X:[[new t.Mesh(P,r),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(I,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(P,e),[0,.5,0]],[new t.Mesh(I,e)]],Z:[[new t.Mesh(P,l),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(I,l),null,[Math.PI/2,0,0]]]},Y={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]]},Z={START:[[new t.Mesh(new t.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new t.Mesh(new t.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new t.Line(C(),o),null,null,null,"helper"]]},D={X:[[new t.Mesh(x(.45,.25),r)]],Y:[[new t.Mesh(x(.45,.25),e),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(x(.45,.25),l),null,[0,Math.PI/2,0]]]},mt={AXIS:[],START:[[new t.Line(A.clone(),o),null,null,null,"helper"]],END:[[new t.Line(A.clone(),o),null,null,null,"helper"]],ARC:[[new t.Line(new t.BufferGeometry,o),null,null,null,"helper"]]},ut={X:[[new t.Mesh(x(.45,.25),r)]],Y:[[new t.Mesh(x(.45,.25),e),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(x(.45,.25),l),null,[0,Math.PI/2,0]]]},yt={X:[[new t.Mesh(E,r),[.7,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(E,e),[0,.7,0]]],Z:[[new t.Mesh(E,l),[0,0,.7],[Math.PI/2,0,0]]]},ft={X:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),s),[.7,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),s),[0,.7,0]]],Z:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),s),[0,0,.7],[Math.PI/2,0,0]]]},bt={X:[],Y:[],Z:[]};function z(g){let G=new t.Object3D;for(let S in g)for(let R=g[S].length;R--;){let b=g[S][R][0].clone();b.userData.type="gizmo";let W=g[S][R][1],B=g[S][R][2],N=g[S][R][3],wt=g[S][R][4];b.name=S,b.tag=wt,W&&b.position.set(W[0],W[1],W[2]),B&&b.rotation.set(B[0],B[1],B[2]),N&&b.scale.set(N[0],N[1],N[2]),b.updateMatrix();let at=b.geometry.clone();at.applyMatrix4(b.matrix),b.geometry=at,b.renderOrder=1/0,b.position.set(0,0,0),b.rotation.set(0,0,0),b.scale.set(1,1,1),G.add(b)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=z(Q)),this.add(this.gizmo.rotate=z(D)),this.add(this.gizmo.scale=z(yt)),this.add(this.picker.translate=z(Y)),this.add(this.picker.rotate=z(ut)),this.add(this.picker.scale=z(ft)),this.add(this.helper.translate=z(Z)),this.add(this.helper.rotate=z(mt)),this.add(this.helper.scale=z(bt)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(n){let s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:H;this.mode==="all"?(this.gizmo.translate.visible=!0,this.gizmo.rotate.visible=!0,this.gizmo.scale.visible=!0,this.helper.translate.visible=!0,this.helper.rotate.visible=!0,this.helper.scale.visible=!1):(this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale");let o=[];this.mode==="all"?(o=o.concat(this.picker.translate.children),o=o.concat(this.picker.rotate.children),o=o.concat(this.picker.scale.children),o=o.concat(this.gizmo.translate.children),o=o.concat(this.gizmo.rotate.children),o=o.concat(this.gizmo.scale.children),o=o.concat(this.helper.translate.children),o=o.concat(this.helper.rotate.children)):(o=o.concat(this.picker[this.mode].children),o=o.concat(this.gizmo[this.mode].children),o=o.concat(this.helper[this.mode].children));for(let r=0;r<o.length;r++){let e=o[r];e.visible=!0,e.rotation.set(0,0,0),e.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),e.scale.set(1,1,1).multiplyScalar(l*this.size/4),e.tag==="helper"){if(e.visible=!1,e.name==="AXIS")e.visible=!!this.axis,this.axis==="X"&&(d.setFromEuler(V.set(0,0,0)),e.quaternion.copy(s).multiply(d),Math.abs(p.copy(F).applyQuaternion(s).dot(this.eye))>.9&&(e.visible=!1)),this.axis==="Y"&&(d.setFromEuler(V.set(0,0,Math.PI/2)),e.quaternion.copy(s).multiply(d),Math.abs(p.copy(j).applyQuaternion(s).dot(this.eye))>.9&&(e.visible=!1)),this.axis==="Z"&&(d.setFromEuler(V.set(0,Math.PI/2,0)),e.quaternion.copy(s).multiply(d),Math.abs(p.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(e.visible=!1)),this.axis==="XYZE"&&(d.setFromEuler(V.set(0,Math.PI/2,0)),p.copy(this.rotationAxis),e.quaternion.setFromRotationMatrix(pt.lookAt(ht,p,j)),e.quaternion.multiply(d),e.visible=this.dragging),this.axis==="E"&&(e.visible=!1);else if(e.name==="START")if(this.mode==="rotate"||this.mode==="all"){e.position.copy(this.worldPosition);let h=this.mode==="rotate"||this.mode==="all"&&this.activeMode==="rotate";if(e.visible=this.dragging&&h,e.visible){let a=this.space;a==="local"?e.quaternion.copy(this.worldQuaternionStart):e.quaternion.copy(H);let y=new t.Vector3;this.axis==="X"||this.axis==="Y"||this.axis==="Z"?y.copy(T[this.axis]):(this.axis==="E"||this.axis==="XYZE")&&(y.copy(this.rotationAxis),a==="local"&&y.applyQuaternion(this.worldQuaternionStart.clone().invert()));let m=this.pointStart.clone();a==="local"&&m.applyQuaternion(this.worldQuaternionStart.clone().invert());let f=m.dot(y);m.sub(y.clone().multiplyScalar(f)),m.normalize(),m.multiplyScalar(.45);let w=new t.BufferGeometry;w.setAttribute("position",new t.Float32BufferAttribute([0,0,0,m.x,m.y,m.z],3)),e.geometry.dispose(),e.geometry=w}}else e.position.copy(this.worldPositionStart),e.visible=this.dragging&&this.mode==="translate";else if(e.name==="ARC"){let h=this.mode==="rotate"||this.mode==="all"&&this.activeMode==="rotate";if(e.visible=this.dragging&&h,e.visible&&this.rotationAngle!==0){e.position.copy(this.worldPosition);let a=this.space;a==="local"?e.quaternion.copy(this.worldQuaternionStart):e.quaternion.copy(H);let y=.45,m=Math.max(8,Math.floor(Math.abs(this.rotationAngle)*50)),f=[],w=new t.Vector3;this.axis==="X"||this.axis==="Y"||this.axis==="Z"?w.copy(T[this.axis]):(this.axis==="E"||this.axis==="XYZE")&&(w.copy(this.rotationAxis),a==="local"&&w.applyQuaternion(this.worldQuaternionStart.clone().invert()));let _=this.pointStart.clone();a==="local"&&_.applyQuaternion(this.worldQuaternionStart.clone().invert());let P=_.dot(w);_.sub(w.clone().multiplyScalar(P)),_.normalize();for(let A=0;A<=m;A++){let I=this.rotationAngle*A/m,x=_.clone(),C=new t.Quaternion().setFromAxisAngle(w,I);x.applyQuaternion(C),x.multiplyScalar(y),f.push(x.x,x.y,x.z)}let E=new t.BufferGeometry;E.setAttribute("position",new t.Float32BufferAttribute(f,3)),e.geometry.dispose(),e.geometry=E}}else if(e.name==="END")if(this.mode==="rotate"||this.mode==="all"){e.position.copy(this.worldPosition);let h=this.mode==="rotate"||this.mode==="all"&&this.activeMode==="rotate";if(e.visible=this.dragging&&h,e.visible){let a=this.space;a==="local"?e.quaternion.copy(this.worldQuaternionStart):e.quaternion.copy(H);let y=new t.BufferGeometry,m=new t.Vector3;this.axis==="X"||this.axis==="Y"||this.axis==="Z"?m.copy(T[this.axis]):(this.axis==="E"||this.axis==="XYZE")&&(m.copy(this.rotationAxis),a==="local"&&m.applyQuaternion(this.worldQuaternionStart.clone().invert()));let f=this.pointStart.clone();a==="local"&&f.applyQuaternion(this.worldQuaternionStart.clone().invert());let w=f.dot(m);f.sub(m.clone().multiplyScalar(w)),f.normalize();let _=f.clone(),P=new t.Quaternion().setFromAxisAngle(m,this.rotationAngle);_.applyQuaternion(P),_.multiplyScalar(.45),y.setAttribute("position",new t.Float32BufferAttribute([0,0,0,_.x,_.y,_.z],3)),e.geometry.dispose(),e.geometry=y}}else e.position.copy(this.worldPosition),e.visible=!1;else e.name==="DELTA"?(e.position.copy(this.worldPositionStart),e.quaternion.copy(this.worldQuaternionStart),u.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),u.applyQuaternion(this.worldQuaternionStart.clone().invert()),e.scale.copy(u),e.visible=this.dragging):(e.quaternion.copy(s),this.dragging?e.position.copy(this.worldPositionStart):e.position.copy(this.worldPosition),this.axis&&(e.visible=this.axis.search(e.name)!==-1));continue}e.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(e.name==="X"&&Math.abs(p.copy(F).applyQuaternion(s).dot(this.eye))>.99&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),e.name==="Y"&&Math.abs(p.copy(j).applyQuaternion(s).dot(this.eye))>.99&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),e.name==="Z"&&Math.abs(p.copy(O).applyQuaternion(s).dot(this.eye))>.99&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),e.name==="XY"&&Math.abs(p.copy(O).applyQuaternion(s).dot(this.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),e.name==="YZ"&&Math.abs(p.copy(F).applyQuaternion(s).dot(this.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1),e.name==="XZ"&&Math.abs(p.copy(j).applyQuaternion(s).dot(this.eye))<.2&&(e.scale.set(1e-10,1e-10,1e-10),e.visible=!1)):this.mode==="rotate"&&($.copy(s),p.copy(this.eye).applyQuaternion(d.copy(s).invert()),e.name.search("E")!==-1&&e.quaternion.setFromRotationMatrix(pt.lookAt(this.eye,ht,j)),e.name==="X"&&(d.setFromAxisAngle(F,Math.atan2(-p.y,p.z)),d.multiplyQuaternions($,d),e.quaternion.copy(d)),e.name==="Y"&&(d.setFromAxisAngle(j,Math.atan2(p.x,p.z)),d.multiplyQuaternions($,d),e.quaternion.copy(d)),e.name==="Z"&&(d.setFromAxisAngle(O,Math.atan2(p.y,p.x)),d.multiplyQuaternions($,d),e.quaternion.copy(d))),e.visible=e.visible&&(e.name.indexOf("X")===-1||this.showX),e.visible=e.visible&&(e.name.indexOf("Y")===-1||this.showY),e.visible=e.visible&&(e.name.indexOf("Z")===-1||this.showZ),e.visible=e.visible&&(e.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),e.material._color=e.material._color||e.material.color.clone(),e.material._opacity=e.material._opacity||e.material.opacity,e.material.color.copy(e.material._color),e.material.opacity=e.material._opacity,this.dragging&&(e.material.opacity=.2),this.enabled&&this.axis&&(e.name===this.axis?(e.material.color.setHex(16776960),this.dragging||(e.material.opacity=1)):this.axis.split("").some(function(h){return e.name===h})&&(e.material.color.setHex(16776960),this.dragging||(e.material.opacity=1)))}super.updateMatrixWorld(n)}},K=class extends t.Mesh{constructor(){super(new t.PlaneGeometry(1e5,1e5,2,2),new t.MeshBasicMaterial({visible:!1,wireframe:!0,side:t.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(n){let i=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(i="local"),U.copy(F).applyQuaternion(i==="local"?this.worldQuaternion:H),k.copy(j).applyQuaternion(i==="local"?this.worldQuaternion:H),q.copy(O).applyQuaternion(i==="local"?this.worldQuaternion:H),p.copy(k),this.mode){case"translate":case"scale":switch(this.axis){case"X":p.copy(this.eye).cross(U),M.copy(U).cross(p);break;case"Y":p.copy(this.eye).cross(k),M.copy(k).cross(p);break;case"Z":p.copy(this.eye).cross(q),M.copy(q).cross(p);break;case"XY":M.copy(q);break;case"YZ":M.copy(U);break;case"XZ":p.copy(q),M.copy(k);break;case"XYZ":case"E":M.set(0,0,0);break}break;case"rotate":default:M.set(0,0,0)}M.length()===0?this.quaternion.copy(this.cameraQuaternion):(dt.lookAt(u.set(0,0,0),M,p),this.quaternion.setFromRotationMatrix(dt)),super.updateMatrixWorld(n)}};0&&(module.exports={TransformControls,TransformControlsGizmo,TransformControlsPlane,calculateBoundingBoxCenter});