@mavonengine/editor 0.0.8 → 0.0.9

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 (35) hide show
  1. package/dist/Editor/UI/ActivityBar.d.ts +1 -1
  2. package/dist/Editor/UI/Assets/AssetStats.d.ts +3 -3
  3. package/dist/Editor/UI/Assets/Assets.d.ts +1 -1
  4. package/dist/Editor/UI/Assets/AudioPlayer.d.ts +1 -1
  5. package/dist/Editor/UI/Assets/ModelViewer.d.ts +3 -3
  6. package/dist/Editor/UI/Assets/ParticleViewer.d.ts +3 -3
  7. package/dist/Editor/UI/Assets/TextureViewer.d.ts +3 -3
  8. package/dist/Editor/UI/CanvasPanel.d.ts +1 -1
  9. package/dist/Editor/UI/CanvasToolbar.d.ts +1 -1
  10. package/dist/Editor/UI/Controllers/ControllerDebug.d.ts +1 -0
  11. package/dist/Editor/UI/Controllers/GamepadDiagram.d.ts +5 -0
  12. package/dist/Editor/UI/Controllers/useGamepads.d.ts +6 -0
  13. package/dist/Editor/UI/DockArea.d.ts +17 -0
  14. package/dist/Editor/UI/Editor.d.ts +1 -1
  15. package/dist/Editor/UI/PanelHeader.d.ts +1 -1
  16. package/dist/Editor/UI/PropertiesPanel.d.ts +1 -1
  17. package/dist/Editor/UI/SceneExplorer.d.ts +1 -1
  18. package/dist/Editor/UI/ScenePanel.d.ts +1 -0
  19. package/dist/Editor/UI/ShadeModeButtons.d.ts +1 -1
  20. package/dist/Editor/UI/StatusBar.d.ts +1 -1
  21. package/dist/Editor/UI/TabBar.d.ts +1 -1
  22. package/dist/Editor/UI/Window.d.ts +1 -1
  23. package/dist/Editor/builtinPrefabs.d.ts +4 -0
  24. package/dist/Editor/demoScene.d.ts +7 -0
  25. package/dist/Editor/panels.d.ts +22 -0
  26. package/dist/Editor/recordPrefabUsage.d.ts +7 -0
  27. package/dist/Editor.css +2 -1
  28. package/dist/Editor.d.ts +26 -2
  29. package/dist/Editor.mjs +1654 -9
  30. package/dist/global-l94NfB94.mjs +22 -0
  31. package/dist/mount-CnirMLg0.mjs +35603 -0
  32. package/dist/panels-BqmX3eap.mjs +45 -0
  33. package/package.json +12 -12
  34. package/dist/Editor-CUEoQ8jG.mjs +0 -1352
  35. package/dist/mount-Da8g-2BI.mjs +0 -40805
package/dist/Editor.mjs CHANGED
@@ -1,10 +1,1655 @@
1
- import "@mavonengine/core/Editor/EditorHelper";
2
- import "@mavonengine/core/Game";
3
- import "@mavonengine/core/Prefab/Lights/index";
4
- import "@mavonengine/core/Prefab/Primitives/index";
5
- import "@mavonengine/core/Utils/EventEmitter";
6
- import "three";
7
- import { E as f } from "./Editor-CUEoQ8jG.mjs";
8
- export {
9
- f as default
1
+ import { a as e, o as t, r as n } from "./panels-BqmX3eap.mjs";
2
+ import r from "@mavonengine/core/Editor/EditorHelper";
3
+ import i from "@mavonengine/core/Game";
4
+ import { SCENE_SAVE_PATH as a } from "@mavonengine/core/Plugins/types";
5
+ import o from "@mavonengine/core/Utils/EventEmitter";
6
+ import { AdditiveBlending as s, BoxGeometry as c, BufferGeometry as l, Color as u, Controls as d, CylinderGeometry as f, DoubleSide as p, Euler as m, Float32BufferAttribute as h, HalfFloatType as g, Line as _, LineBasicMaterial as ee, Matrix4 as v, Mesh as y, MeshBasicMaterial as te, MeshDepthMaterial as b, NoBlending as x, Object3D as S, OctahedronGeometry as C, OrthographicCamera as w, PlaneGeometry as T, Quaternion as E, RGBADepthPacking as ne, Raycaster as re, ShaderMaterial as D, SphereGeometry as ie, TorusGeometry as O, UniformsUtils as ae, Vector2 as k, Vector3 as A, WebGLRenderTarget as j } from "three";
7
+ import { lightType as M, primitiveType as N } from "@mavonengine/core/Scene/builtinSceneObjects";
8
+ import { SCENE_FORMAT_VERSION as oe } from "@mavonengine/core/Scene/types";
9
+ // ../../node_modules/three/examples/jsm/controls/FlyControls.js
10
+ var P = { type: "change" }, se = 1e-6, ce = new E(), le = class extends d {
11
+ constructor(e, t = null) {
12
+ super(e, t), this.movementSpeed = 1, this.rollSpeed = .005, this.dragToLook = !1, this.autoForward = !1, this._moveState = {
13
+ up: 0,
14
+ down: 0,
15
+ left: 0,
16
+ right: 0,
17
+ forward: 0,
18
+ back: 0,
19
+ pitchUp: 0,
20
+ pitchDown: 0,
21
+ yawLeft: 0,
22
+ yawRight: 0,
23
+ rollLeft: 0,
24
+ rollRight: 0
25
+ }, this._moveVector = new A(0, 0, 0), this._rotationVector = new A(0, 0, 0), this._lastQuaternion = new E(), this._lastPosition = new A(), this._status = 0, this._onKeyDown = ue.bind(this), this._onKeyUp = de.bind(this), this._onPointerMove = pe.bind(this), this._onPointerDown = fe.bind(this), this._onPointerUp = me.bind(this), this._onPointerCancel = he.bind(this), this._onContextMenu = ge.bind(this), t !== null && this.connect(t);
26
+ }
27
+ connect(e) {
28
+ super.connect(e), window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
29
+ }
30
+ disconnect() {
31
+ window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerCancel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "";
32
+ }
33
+ dispose() {
34
+ this.disconnect();
35
+ }
36
+ update(e) {
37
+ if (this.enabled === !1) return;
38
+ let t = this.object, n = e * this.movementSpeed, r = e * this.rollSpeed;
39
+ t.translateX(this._moveVector.x * n), t.translateY(this._moveVector.y * n), t.translateZ(this._moveVector.z * n), ce.set(this._rotationVector.x * r, this._rotationVector.y * r, this._rotationVector.z * r, 1).normalize(), t.quaternion.multiply(ce), (this._lastPosition.distanceToSquared(t.position) > se || 8 * (1 - this._lastQuaternion.dot(t.quaternion)) > se) && (this.dispatchEvent(P), this._lastQuaternion.copy(t.quaternion), this._lastPosition.copy(t.position));
40
+ }
41
+ _updateMovementVector() {
42
+ let e = this._moveState.forward || this.autoForward && !this._moveState.back ? 1 : 0;
43
+ this._moveVector.x = -this._moveState.left + this._moveState.right, this._moveVector.y = -this._moveState.down + this._moveState.up, this._moveVector.z = -e + this._moveState.back;
44
+ }
45
+ _updateRotationVector() {
46
+ this._rotationVector.x = -this._moveState.pitchDown + this._moveState.pitchUp, this._rotationVector.y = -this._moveState.yawRight + this._moveState.yawLeft, this._rotationVector.z = -this._moveState.rollRight + this._moveState.rollLeft;
47
+ }
48
+ _getContainerDimensions() {
49
+ return this.domElement == document ? {
50
+ size: [window.innerWidth, window.innerHeight],
51
+ offset: [0, 0]
52
+ } : {
53
+ size: [this.domElement.offsetWidth, this.domElement.offsetHeight],
54
+ offset: [this.domElement.offsetLeft, this.domElement.offsetTop]
55
+ };
56
+ }
10
57
  };
58
+ function ue(e) {
59
+ if (!(e.altKey || this.enabled === !1)) {
60
+ switch (e.code) {
61
+ case "ShiftLeft":
62
+ case "ShiftRight":
63
+ this.movementSpeedMultiplier = .1;
64
+ break;
65
+ case "KeyW":
66
+ this._moveState.forward = 1;
67
+ break;
68
+ case "KeyS":
69
+ this._moveState.back = 1;
70
+ break;
71
+ case "KeyA":
72
+ this._moveState.left = 1;
73
+ break;
74
+ case "KeyD":
75
+ this._moveState.right = 1;
76
+ break;
77
+ case "KeyR":
78
+ this._moveState.up = 1;
79
+ break;
80
+ case "KeyF":
81
+ this._moveState.down = 1;
82
+ break;
83
+ case "ArrowUp":
84
+ this._moveState.pitchUp = 1;
85
+ break;
86
+ case "ArrowDown":
87
+ this._moveState.pitchDown = 1;
88
+ break;
89
+ case "ArrowLeft":
90
+ this._moveState.yawLeft = 1;
91
+ break;
92
+ case "ArrowRight":
93
+ this._moveState.yawRight = 1;
94
+ break;
95
+ case "KeyQ":
96
+ this._moveState.rollLeft = 1;
97
+ break;
98
+ case "KeyE": this._moveState.rollRight = 1;
99
+ }
100
+ this._updateMovementVector(), this._updateRotationVector();
101
+ }
102
+ }
103
+ function de(e) {
104
+ if (this.enabled !== !1) {
105
+ switch (e.code) {
106
+ case "ShiftLeft":
107
+ case "ShiftRight":
108
+ this.movementSpeedMultiplier = 1;
109
+ break;
110
+ case "KeyW":
111
+ this._moveState.forward = 0;
112
+ break;
113
+ case "KeyS":
114
+ this._moveState.back = 0;
115
+ break;
116
+ case "KeyA":
117
+ this._moveState.left = 0;
118
+ break;
119
+ case "KeyD":
120
+ this._moveState.right = 0;
121
+ break;
122
+ case "KeyR":
123
+ this._moveState.up = 0;
124
+ break;
125
+ case "KeyF":
126
+ this._moveState.down = 0;
127
+ break;
128
+ case "ArrowUp":
129
+ this._moveState.pitchUp = 0;
130
+ break;
131
+ case "ArrowDown":
132
+ this._moveState.pitchDown = 0;
133
+ break;
134
+ case "ArrowLeft":
135
+ this._moveState.yawLeft = 0;
136
+ break;
137
+ case "ArrowRight":
138
+ this._moveState.yawRight = 0;
139
+ break;
140
+ case "KeyQ":
141
+ this._moveState.rollLeft = 0;
142
+ break;
143
+ case "KeyE": this._moveState.rollRight = 0;
144
+ }
145
+ this._updateMovementVector(), this._updateRotationVector();
146
+ }
147
+ }
148
+ function fe(e) {
149
+ if (this.enabled !== !1) {
150
+ if (this.dragToLook) this._status++;
151
+ else {
152
+ switch (e.button) {
153
+ case 0:
154
+ this._moveState.forward = 1;
155
+ break;
156
+ case 2: this._moveState.back = 1;
157
+ }
158
+ this._updateMovementVector();
159
+ }
160
+ }
161
+ }
162
+ function pe(e) {
163
+ if (this.enabled !== !1 && (!this.dragToLook || this._status > 0)) {
164
+ let t = this._getContainerDimensions(), n = t.size[0] / 2, r = t.size[1] / 2;
165
+ this._moveState.yawLeft = -(e.pageX - t.offset[0] - n) / n, this._moveState.pitchDown = (e.pageY - t.offset[1] - r) / r, this._updateRotationVector();
166
+ }
167
+ }
168
+ function me(e) {
169
+ if (this.enabled !== !1) {
170
+ if (this.dragToLook) this._status--, this._moveState.yawLeft = this._moveState.pitchDown = 0;
171
+ else {
172
+ switch (e.button) {
173
+ case 0:
174
+ this._moveState.forward = 0;
175
+ break;
176
+ case 2: this._moveState.back = 0;
177
+ }
178
+ this._updateMovementVector();
179
+ }
180
+ this._updateRotationVector();
181
+ }
182
+ }
183
+ function he() {
184
+ this.enabled !== !1 && (this.dragToLook ? (this._status = 0, this._moveState.yawLeft = this._moveState.pitchDown = 0) : (this._moveState.forward = 0, this._moveState.back = 0, this._updateMovementVector()), this._updateRotationVector());
185
+ }
186
+ function ge(e) {
187
+ this.enabled !== !1 && e.preventDefault();
188
+ }
189
+ // ../../node_modules/three/examples/jsm/controls/TransformControls.js
190
+ var F = new re(), I = new A(), L = new A(), R = new E(), _e = {
191
+ X: new A(1, 0, 0),
192
+ Y: new A(0, 1, 0),
193
+ Z: new A(0, 0, 1)
194
+ }, z = { type: "change" }, ve = {
195
+ type: "mouseDown",
196
+ mode: null
197
+ }, ye = {
198
+ type: "mouseUp",
199
+ mode: null
200
+ }, be = { type: "objectChange" }, xe = class extends d {
201
+ constructor(e, t = null) {
202
+ super(void 0, t);
203
+ let n = new Ae(this);
204
+ this._root = n;
205
+ let r = new je();
206
+ this._gizmo = r, n.add(r);
207
+ let i = new Me();
208
+ this._plane = i, n.add(i);
209
+ let a = this;
210
+ function o(e, t) {
211
+ let n = t;
212
+ Object.defineProperty(a, e, {
213
+ get: function() {
214
+ return n === void 0 ? t : n;
215
+ },
216
+ set: function(t) {
217
+ n !== t && (n = t, i[e] = t, r[e] = t, a.dispatchEvent({
218
+ type: e + "-changed",
219
+ value: t
220
+ }), a.dispatchEvent(z));
221
+ }
222
+ }), a[e] = t, i[e] = t, r[e] = t;
223
+ }
224
+ o("camera", e), o("object", void 0), o("enabled", !0), o("axis", null), o("mode", "translate"), o("translationSnap", null), o("rotationSnap", null), o("scaleSnap", null), o("space", "world"), o("size", 1), o("dragging", !1), o("showX", !0), o("showY", !0), o("showZ", !0), o("showXY", !0), o("showYZ", !0), o("showXZ", !0), o("minX", -Infinity), o("maxX", Infinity), o("minY", -Infinity), o("maxY", Infinity), o("minZ", -Infinity), o("maxZ", Infinity);
225
+ let s = new A(), c = new A(), l = new E(), u = new E(), d = new A(), f = new E(), p = new A(), m = new A(), h = new A(), g = new A();
226
+ o("worldPosition", s), o("worldPositionStart", c), o("worldQuaternion", l), o("worldQuaternionStart", u), o("cameraPosition", d), o("cameraQuaternion", f), o("pointStart", p), o("pointEnd", m), o("rotationAxis", h), o("rotationAngle", 0), o("eye", g), this._offset = new A(), this._startNorm = new A(), this._endNorm = new A(), this._cameraScale = new A(), this._parentPosition = new A(), this._parentQuaternion = new E(), this._parentQuaternionInv = new E(), this._parentScale = new A(), this._worldScaleStart = new A(), this._worldQuaternionInv = new E(), this._worldScale = new A(), this._positionStart = new A(), this._quaternionStart = new E(), this._scaleStart = new A(), this._getPointer = Se.bind(this), this._onPointerDown = we.bind(this), this._onPointerHover = Ce.bind(this), this._onPointerMove = Te.bind(this), this._onPointerUp = Ee.bind(this), t !== null && this.connect(t);
227
+ }
228
+ connect(e) {
229
+ super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.style.touchAction = "none";
230
+ }
231
+ disconnect() {
232
+ 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.style.touchAction = "";
233
+ }
234
+ getHelper() {
235
+ return this._root;
236
+ }
237
+ pointerHover(e) {
238
+ if (this.object === void 0 || this.dragging === !0) return;
239
+ e !== null && F.setFromCamera(e, this.camera);
240
+ let t = B(this._gizmo.picker[this.mode], F);
241
+ this.axis = t ? t.object.name : null;
242
+ }
243
+ pointerDown(e) {
244
+ if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
245
+ e !== null && F.setFromCamera(e, this.camera);
246
+ let t = B(this._plane, F, !0);
247
+ t && (this.object.updateMatrixWorld(), this.object.parent.updateMatrixWorld(), this._positionStart.copy(this.object.position), this._quaternionStart.copy(this.object.quaternion), this._scaleStart.copy(this.object.scale), this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart), this.pointStart.copy(t.point).sub(this.worldPositionStart)), this.dragging = !0, ve.mode = this.mode, this.dispatchEvent(ve);
248
+ }
249
+ }
250
+ pointerMove(e) {
251
+ let t = this.axis, n = this.mode, r = this.object, i = this.space;
252
+ if (n === "scale" ? i = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (i = "world"), r === void 0 || t === null || this.dragging === !1 || e !== null && e.button !== -1) return;
253
+ e !== null && F.setFromCamera(e, this.camera);
254
+ let a = B(this._plane, F, !0);
255
+ if (a) {
256
+ if (this.pointEnd.copy(a.point).sub(this.worldPositionStart), n === "translate") this._offset.copy(this.pointEnd).sub(this.pointStart), i === "local" && t !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), t.indexOf("X") === -1 && (this._offset.x = 0), t.indexOf("Y") === -1 && (this._offset.y = 0), t.indexOf("Z") === -1 && (this._offset.z = 0), i === "local" && t !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), r.position.copy(this._offset).add(this._positionStart), this.translationSnap && (i === "local" && (r.position.applyQuaternion(R.copy(this._quaternionStart).invert()), t.search("X") !== -1 && (r.position.x = Math.round(r.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (r.position.y = Math.round(r.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (r.position.z = Math.round(r.position.z / this.translationSnap) * this.translationSnap), r.position.applyQuaternion(this._quaternionStart)), i === "world" && (r.parent && r.position.add(I.setFromMatrixPosition(r.parent.matrixWorld)), t.search("X") !== -1 && (r.position.x = Math.round(r.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (r.position.y = Math.round(r.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (r.position.z = Math.round(r.position.z / this.translationSnap) * this.translationSnap), r.parent && r.position.sub(I.setFromMatrixPosition(r.parent.matrixWorld)))), r.position.x = Math.max(this.minX, Math.min(this.maxX, r.position.x)), r.position.y = Math.max(this.minY, Math.min(this.maxY, r.position.y)), r.position.z = Math.max(this.minZ, Math.min(this.maxZ, r.position.z));
257
+ else if (n === "scale") {
258
+ if (t.search("XYZ") !== -1) {
259
+ let e = this.pointEnd.length() / this.pointStart.length();
260
+ this.pointEnd.dot(this.pointStart) < 0 && (e *= -1), L.set(e, e, e);
261
+ } else I.copy(this.pointStart), L.copy(this.pointEnd), I.applyQuaternion(this._worldQuaternionInv), L.applyQuaternion(this._worldQuaternionInv), L.divide(I), t.search("X") === -1 && (L.x = 1), t.search("Y") === -1 && (L.y = 1), t.search("Z") === -1 && (L.z = 1);
262
+ r.scale.copy(this._scaleStart).multiply(L), this.scaleSnap && (t.search("X") !== -1 && (r.scale.x = Math.round(r.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (r.scale.y = Math.round(r.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (r.scale.z = Math.round(r.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
263
+ } else if (n === "rotate") {
264
+ this._offset.copy(this.pointEnd).sub(this.pointStart);
265
+ let e = 20 / this.worldPosition.distanceTo(I.setFromMatrixPosition(this.camera.matrixWorld)), n = !1;
266
+ t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(I.copy(this.rotationAxis).cross(this.eye)) * e) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(_e[t]), I.copy(_e[t]), i === "local" && I.applyQuaternion(this.worldQuaternion), I.cross(this.eye), I.length() === 0 ? n = !0 : this.rotationAngle = this._offset.dot(I.normalize()) * e), (t === "E" || n) && (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), i === "local" && t !== "E" && t !== "XYZE" ? (r.quaternion.copy(this._quaternionStart), r.quaternion.multiply(R.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), r.quaternion.copy(R.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), r.quaternion.multiply(this._quaternionStart).normalize());
267
+ }
268
+ this.dispatchEvent(z), this.dispatchEvent(be);
269
+ }
270
+ }
271
+ pointerUp(e) {
272
+ (e === null || e.button === 0) && (this.dragging && this.axis !== null && (ye.mode = this.mode, this.dispatchEvent(ye)), this.dragging = !1, this.axis = null);
273
+ }
274
+ dispose() {
275
+ this.disconnect(), this._root.dispose();
276
+ }
277
+ attach(e) {
278
+ return this.object = e, this._root.visible = !0, this;
279
+ }
280
+ detach() {
281
+ return this.object = void 0, this.axis = null, this._root.visible = !1, this;
282
+ }
283
+ reset() {
284
+ this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(z), this.dispatchEvent(be), this.pointStart.copy(this.pointEnd));
285
+ }
286
+ getRaycaster() {
287
+ return F;
288
+ }
289
+ getMode() {
290
+ return this.mode;
291
+ }
292
+ setMode(e) {
293
+ this.mode = e;
294
+ }
295
+ setTranslationSnap(e) {
296
+ this.translationSnap = e;
297
+ }
298
+ setRotationSnap(e) {
299
+ this.rotationSnap = e;
300
+ }
301
+ setScaleSnap(e) {
302
+ this.scaleSnap = e;
303
+ }
304
+ setSize(e) {
305
+ this.size = e;
306
+ }
307
+ setSpace(e) {
308
+ this.space = e;
309
+ }
310
+ setColors(e, t, n, r) {
311
+ let i = this._gizmo.materialLib;
312
+ i.xAxis.color.set(e), i.yAxis.color.set(t), i.zAxis.color.set(n), i.active.color.set(r), i.xAxisTransparent.color.set(e), i.yAxisTransparent.color.set(t), i.zAxisTransparent.color.set(n), i.activeTransparent.color.set(r), i.xAxis._color && i.xAxis._color.set(e), i.yAxis._color && i.yAxis._color.set(t), i.zAxis._color && i.zAxis._color.set(n), i.active._color && i.active._color.set(r), i.xAxisTransparent._color && i.xAxisTransparent._color.set(e), i.yAxisTransparent._color && i.yAxisTransparent._color.set(t), i.zAxisTransparent._color && i.zAxisTransparent._color.set(n), i.activeTransparent._color && i.activeTransparent._color.set(r);
313
+ }
314
+ };
315
+ function Se(e) {
316
+ if (this.domElement.ownerDocument.pointerLockElement) return {
317
+ x: 0,
318
+ y: 0,
319
+ button: e.button
320
+ };
321
+ {
322
+ let t = this.domElement.getBoundingClientRect();
323
+ return {
324
+ x: (e.clientX - t.left) / t.width * 2 - 1,
325
+ y: -(e.clientY - t.top) / t.height * 2 + 1,
326
+ button: e.button
327
+ };
328
+ }
329
+ }
330
+ function Ce(e) {
331
+ if (this.enabled) switch (e.pointerType) {
332
+ case "mouse":
333
+ case "pen": this.pointerHover(this._getPointer(e));
334
+ }
335
+ }
336
+ function we(e) {
337
+ this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(e.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(e)), this.pointerDown(this._getPointer(e)));
338
+ }
339
+ function Te(e) {
340
+ this.enabled && this.pointerMove(this._getPointer(e));
341
+ }
342
+ function Ee(e) {
343
+ this.enabled && (this.domElement.releasePointerCapture(e.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(e)));
344
+ }
345
+ function B(e, t, n) {
346
+ let r = t.intersectObject(e, !0);
347
+ for (let e = 0; e < r.length; e++) if (r[e].object.visible || n) return r[e];
348
+ return !1;
349
+ }
350
+ var V = new m(), H = new A(0, 1, 0), De = new A(0, 0, 0), Oe = new v(), U = new E(), W = new E(), G = new A(), ke = new v(), K = new A(1, 0, 0), q = new A(0, 1, 0), J = new A(0, 0, 1), Y = new A(), X = new A(), Z = new A(), Ae = class extends S {
351
+ constructor(e) {
352
+ super(), this.isTransformControlsRoot = !0, this.controls = e, this.visible = !1;
353
+ }
354
+ updateMatrixWorld(e) {
355
+ let t = this.controls;
356
+ t.object !== void 0 && (t.object.updateMatrixWorld(), t.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : t.object.parent.matrixWorld.decompose(t._parentPosition, t._parentQuaternion, t._parentScale), t.object.matrixWorld.decompose(t.worldPosition, t.worldQuaternion, t._worldScale), t._parentQuaternionInv.copy(t._parentQuaternion).invert(), t._worldQuaternionInv.copy(t.worldQuaternion).invert()), t.camera.updateMatrixWorld(), t.camera.matrixWorld.decompose(t.cameraPosition, t.cameraQuaternion, t._cameraScale), t.camera.isOrthographicCamera ? t.camera.getWorldDirection(t.eye).negate() : t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(), super.updateMatrixWorld(e);
357
+ }
358
+ dispose() {
359
+ this.traverse(function(e) {
360
+ e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
361
+ });
362
+ }
363
+ }, je = class extends S {
364
+ constructor() {
365
+ super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
366
+ let e = new te({
367
+ depthTest: !1,
368
+ depthWrite: !1,
369
+ fog: !1,
370
+ toneMapped: !1,
371
+ transparent: !0
372
+ }), t = new ee({
373
+ depthTest: !1,
374
+ depthWrite: !1,
375
+ fog: !1,
376
+ toneMapped: !1,
377
+ transparent: !0
378
+ }), n = e.clone();
379
+ n.opacity = .15;
380
+ let r = t.clone();
381
+ r.opacity = .5;
382
+ let i = e.clone();
383
+ i.color.setHex(16711680);
384
+ let a = e.clone();
385
+ a.color.setHex(65280);
386
+ let o = e.clone();
387
+ o.color.setHex(255);
388
+ let s = e.clone();
389
+ s.color.setHex(16711680), s.opacity = .5;
390
+ let u = e.clone();
391
+ u.color.setHex(65280), u.opacity = .5;
392
+ let d = e.clone();
393
+ d.color.setHex(255), d.opacity = .5;
394
+ let p = e.clone();
395
+ p.opacity = .25;
396
+ let m = e.clone();
397
+ m.color.setHex(16776960), m.opacity = .25;
398
+ let g = e.clone();
399
+ g.color.setHex(16776960);
400
+ let v = e.clone();
401
+ v.color.setHex(7895160), this.materialLib = {
402
+ xAxis: i,
403
+ yAxis: a,
404
+ zAxis: o,
405
+ active: g,
406
+ xAxisTransparent: s,
407
+ yAxisTransparent: u,
408
+ zAxisTransparent: d,
409
+ activeTransparent: m
410
+ };
411
+ let b = new f(0, .04, .1, 12);
412
+ b.translate(0, .05, 0);
413
+ let x = new c(.08, .08, .08);
414
+ x.translate(0, .04, 0);
415
+ let w = new l();
416
+ w.setAttribute("position", new h([
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 1,
421
+ 0,
422
+ 0
423
+ ], 3));
424
+ let T = new f(.0075, .0075, .5, 3);
425
+ T.translate(0, .25, 0);
426
+ function E(e, t) {
427
+ let n = new O(e, .0075, 3, 64, t * Math.PI * 2);
428
+ return n.rotateY(Math.PI / 2), n.rotateX(Math.PI / 2), n;
429
+ }
430
+ function ne() {
431
+ let e = new l();
432
+ return e.setAttribute("position", new h([
433
+ 0,
434
+ 0,
435
+ 0,
436
+ 1,
437
+ 1,
438
+ 1
439
+ ], 3)), e;
440
+ }
441
+ let re = {
442
+ X: [
443
+ [
444
+ new y(b, i),
445
+ [
446
+ .5,
447
+ 0,
448
+ 0
449
+ ],
450
+ [
451
+ 0,
452
+ 0,
453
+ -Math.PI / 2
454
+ ]
455
+ ],
456
+ [
457
+ new y(b, i),
458
+ [
459
+ -.5,
460
+ 0,
461
+ 0
462
+ ],
463
+ [
464
+ 0,
465
+ 0,
466
+ Math.PI / 2
467
+ ]
468
+ ],
469
+ [
470
+ new y(T, i),
471
+ [
472
+ 0,
473
+ 0,
474
+ 0
475
+ ],
476
+ [
477
+ 0,
478
+ 0,
479
+ -Math.PI / 2
480
+ ]
481
+ ]
482
+ ],
483
+ Y: [
484
+ [new y(b, a), [
485
+ 0,
486
+ .5,
487
+ 0
488
+ ]],
489
+ [
490
+ new y(b, a),
491
+ [
492
+ 0,
493
+ -.5,
494
+ 0
495
+ ],
496
+ [
497
+ Math.PI,
498
+ 0,
499
+ 0
500
+ ]
501
+ ],
502
+ [new y(T, a)]
503
+ ],
504
+ Z: [
505
+ [
506
+ new y(b, o),
507
+ [
508
+ 0,
509
+ 0,
510
+ .5
511
+ ],
512
+ [
513
+ Math.PI / 2,
514
+ 0,
515
+ 0
516
+ ]
517
+ ],
518
+ [
519
+ new y(b, o),
520
+ [
521
+ 0,
522
+ 0,
523
+ -.5
524
+ ],
525
+ [
526
+ -Math.PI / 2,
527
+ 0,
528
+ 0
529
+ ]
530
+ ],
531
+ [
532
+ new y(T, o),
533
+ null,
534
+ [
535
+ Math.PI / 2,
536
+ 0,
537
+ 0
538
+ ]
539
+ ]
540
+ ],
541
+ XYZ: [[new y(new C(.1, 0), p), [
542
+ 0,
543
+ 0,
544
+ 0
545
+ ]]],
546
+ XY: [[new y(new c(.15, .15, .01), d), [
547
+ .15,
548
+ .15,
549
+ 0
550
+ ]]],
551
+ YZ: [[
552
+ new y(new c(.15, .15, .01), s),
553
+ [
554
+ 0,
555
+ .15,
556
+ .15
557
+ ],
558
+ [
559
+ 0,
560
+ Math.PI / 2,
561
+ 0
562
+ ]
563
+ ]],
564
+ XZ: [[
565
+ new y(new c(.15, .15, .01), u),
566
+ [
567
+ .15,
568
+ 0,
569
+ .15
570
+ ],
571
+ [
572
+ -Math.PI / 2,
573
+ 0,
574
+ 0
575
+ ]
576
+ ]]
577
+ }, D = {
578
+ X: [[
579
+ new y(new f(.2, 0, .6, 4), n),
580
+ [
581
+ .3,
582
+ 0,
583
+ 0
584
+ ],
585
+ [
586
+ 0,
587
+ 0,
588
+ -Math.PI / 2
589
+ ]
590
+ ], [
591
+ new y(new f(.2, 0, .6, 4), n),
592
+ [
593
+ -.3,
594
+ 0,
595
+ 0
596
+ ],
597
+ [
598
+ 0,
599
+ 0,
600
+ Math.PI / 2
601
+ ]
602
+ ]],
603
+ Y: [[new y(new f(.2, 0, .6, 4), n), [
604
+ 0,
605
+ .3,
606
+ 0
607
+ ]], [
608
+ new y(new f(.2, 0, .6, 4), n),
609
+ [
610
+ 0,
611
+ -.3,
612
+ 0
613
+ ],
614
+ [
615
+ 0,
616
+ 0,
617
+ Math.PI
618
+ ]
619
+ ]],
620
+ Z: [[
621
+ new y(new f(.2, 0, .6, 4), n),
622
+ [
623
+ 0,
624
+ 0,
625
+ .3
626
+ ],
627
+ [
628
+ Math.PI / 2,
629
+ 0,
630
+ 0
631
+ ]
632
+ ], [
633
+ new y(new f(.2, 0, .6, 4), n),
634
+ [
635
+ 0,
636
+ 0,
637
+ -.3
638
+ ],
639
+ [
640
+ -Math.PI / 2,
641
+ 0,
642
+ 0
643
+ ]
644
+ ]],
645
+ XYZ: [[new y(new C(.2, 0), n)]],
646
+ XY: [[new y(new c(.2, .2, .01), n), [
647
+ .15,
648
+ .15,
649
+ 0
650
+ ]]],
651
+ YZ: [[
652
+ new y(new c(.2, .2, .01), n),
653
+ [
654
+ 0,
655
+ .15,
656
+ .15
657
+ ],
658
+ [
659
+ 0,
660
+ Math.PI / 2,
661
+ 0
662
+ ]
663
+ ]],
664
+ XZ: [[
665
+ new y(new c(.2, .2, .01), n),
666
+ [
667
+ .15,
668
+ 0,
669
+ .15
670
+ ],
671
+ [
672
+ -Math.PI / 2,
673
+ 0,
674
+ 0
675
+ ]
676
+ ]]
677
+ }, ae = {
678
+ START: [[
679
+ new y(new C(.01, 2), r),
680
+ null,
681
+ null,
682
+ null,
683
+ "helper"
684
+ ]],
685
+ END: [[
686
+ new y(new C(.01, 2), r),
687
+ null,
688
+ null,
689
+ null,
690
+ "helper"
691
+ ]],
692
+ DELTA: [[
693
+ new _(ne(), r),
694
+ null,
695
+ null,
696
+ null,
697
+ "helper"
698
+ ]],
699
+ X: [[
700
+ new _(w, r),
701
+ [
702
+ -1e3,
703
+ 0,
704
+ 0
705
+ ],
706
+ null,
707
+ [
708
+ 1e6,
709
+ 1,
710
+ 1
711
+ ],
712
+ "helper"
713
+ ]],
714
+ Y: [[
715
+ new _(w, r),
716
+ [
717
+ 0,
718
+ -1e3,
719
+ 0
720
+ ],
721
+ [
722
+ 0,
723
+ 0,
724
+ Math.PI / 2
725
+ ],
726
+ [
727
+ 1e6,
728
+ 1,
729
+ 1
730
+ ],
731
+ "helper"
732
+ ]],
733
+ Z: [[
734
+ new _(w, r),
735
+ [
736
+ 0,
737
+ 0,
738
+ -1e3
739
+ ],
740
+ [
741
+ 0,
742
+ -Math.PI / 2,
743
+ 0
744
+ ],
745
+ [
746
+ 1e6,
747
+ 1,
748
+ 1
749
+ ],
750
+ "helper"
751
+ ]]
752
+ }, k = {
753
+ XYZE: [[
754
+ new y(E(.5, 1), v),
755
+ null,
756
+ [
757
+ 0,
758
+ Math.PI / 2,
759
+ 0
760
+ ]
761
+ ]],
762
+ X: [[new y(E(.5, .5), i)]],
763
+ Y: [[
764
+ new y(E(.5, .5), a),
765
+ null,
766
+ [
767
+ 0,
768
+ 0,
769
+ -Math.PI / 2
770
+ ]
771
+ ]],
772
+ Z: [[
773
+ new y(E(.5, .5), o),
774
+ null,
775
+ [
776
+ 0,
777
+ Math.PI / 2,
778
+ 0
779
+ ]
780
+ ]],
781
+ E: [[
782
+ new y(E(.75, 1), m),
783
+ null,
784
+ [
785
+ 0,
786
+ Math.PI / 2,
787
+ 0
788
+ ]
789
+ ]]
790
+ }, A = { AXIS: [[
791
+ new _(w, r),
792
+ [
793
+ -1e3,
794
+ 0,
795
+ 0
796
+ ],
797
+ null,
798
+ [
799
+ 1e6,
800
+ 1,
801
+ 1
802
+ ],
803
+ "helper"
804
+ ]] }, j = {
805
+ XYZE: [[new y(new ie(.25, 10, 8), n)]],
806
+ X: [[
807
+ new y(new O(.5, .1, 4, 24), n),
808
+ [
809
+ 0,
810
+ 0,
811
+ 0
812
+ ],
813
+ [
814
+ 0,
815
+ -Math.PI / 2,
816
+ -Math.PI / 2
817
+ ]
818
+ ]],
819
+ Y: [[
820
+ new y(new O(.5, .1, 4, 24), n),
821
+ [
822
+ 0,
823
+ 0,
824
+ 0
825
+ ],
826
+ [
827
+ Math.PI / 2,
828
+ 0,
829
+ 0
830
+ ]
831
+ ]],
832
+ Z: [[
833
+ new y(new O(.5, .1, 4, 24), n),
834
+ [
835
+ 0,
836
+ 0,
837
+ 0
838
+ ],
839
+ [
840
+ 0,
841
+ 0,
842
+ -Math.PI / 2
843
+ ]
844
+ ]],
845
+ E: [[new y(new O(.75, .1, 2, 24), n)]]
846
+ }, M = {
847
+ X: [
848
+ [
849
+ new y(x, i),
850
+ [
851
+ .5,
852
+ 0,
853
+ 0
854
+ ],
855
+ [
856
+ 0,
857
+ 0,
858
+ -Math.PI / 2
859
+ ]
860
+ ],
861
+ [
862
+ new y(T, i),
863
+ [
864
+ 0,
865
+ 0,
866
+ 0
867
+ ],
868
+ [
869
+ 0,
870
+ 0,
871
+ -Math.PI / 2
872
+ ]
873
+ ],
874
+ [
875
+ new y(x, i),
876
+ [
877
+ -.5,
878
+ 0,
879
+ 0
880
+ ],
881
+ [
882
+ 0,
883
+ 0,
884
+ Math.PI / 2
885
+ ]
886
+ ]
887
+ ],
888
+ Y: [
889
+ [new y(x, a), [
890
+ 0,
891
+ .5,
892
+ 0
893
+ ]],
894
+ [new y(T, a)],
895
+ [
896
+ new y(x, a),
897
+ [
898
+ 0,
899
+ -.5,
900
+ 0
901
+ ],
902
+ [
903
+ 0,
904
+ 0,
905
+ Math.PI
906
+ ]
907
+ ]
908
+ ],
909
+ Z: [
910
+ [
911
+ new y(x, o),
912
+ [
913
+ 0,
914
+ 0,
915
+ .5
916
+ ],
917
+ [
918
+ Math.PI / 2,
919
+ 0,
920
+ 0
921
+ ]
922
+ ],
923
+ [
924
+ new y(T, o),
925
+ [
926
+ 0,
927
+ 0,
928
+ 0
929
+ ],
930
+ [
931
+ Math.PI / 2,
932
+ 0,
933
+ 0
934
+ ]
935
+ ],
936
+ [
937
+ new y(x, o),
938
+ [
939
+ 0,
940
+ 0,
941
+ -.5
942
+ ],
943
+ [
944
+ -Math.PI / 2,
945
+ 0,
946
+ 0
947
+ ]
948
+ ]
949
+ ],
950
+ XY: [[new y(new c(.15, .15, .01), d), [
951
+ .15,
952
+ .15,
953
+ 0
954
+ ]]],
955
+ YZ: [[
956
+ new y(new c(.15, .15, .01), s),
957
+ [
958
+ 0,
959
+ .15,
960
+ .15
961
+ ],
962
+ [
963
+ 0,
964
+ Math.PI / 2,
965
+ 0
966
+ ]
967
+ ]],
968
+ XZ: [[
969
+ new y(new c(.15, .15, .01), u),
970
+ [
971
+ .15,
972
+ 0,
973
+ .15
974
+ ],
975
+ [
976
+ -Math.PI / 2,
977
+ 0,
978
+ 0
979
+ ]
980
+ ]],
981
+ XYZ: [[new y(new c(.1, .1, .1), p)]]
982
+ }, N = {
983
+ X: [[
984
+ new y(new f(.2, 0, .6, 4), n),
985
+ [
986
+ .3,
987
+ 0,
988
+ 0
989
+ ],
990
+ [
991
+ 0,
992
+ 0,
993
+ -Math.PI / 2
994
+ ]
995
+ ], [
996
+ new y(new f(.2, 0, .6, 4), n),
997
+ [
998
+ -.3,
999
+ 0,
1000
+ 0
1001
+ ],
1002
+ [
1003
+ 0,
1004
+ 0,
1005
+ Math.PI / 2
1006
+ ]
1007
+ ]],
1008
+ Y: [[new y(new f(.2, 0, .6, 4), n), [
1009
+ 0,
1010
+ .3,
1011
+ 0
1012
+ ]], [
1013
+ new y(new f(.2, 0, .6, 4), n),
1014
+ [
1015
+ 0,
1016
+ -.3,
1017
+ 0
1018
+ ],
1019
+ [
1020
+ 0,
1021
+ 0,
1022
+ Math.PI
1023
+ ]
1024
+ ]],
1025
+ Z: [[
1026
+ new y(new f(.2, 0, .6, 4), n),
1027
+ [
1028
+ 0,
1029
+ 0,
1030
+ .3
1031
+ ],
1032
+ [
1033
+ Math.PI / 2,
1034
+ 0,
1035
+ 0
1036
+ ]
1037
+ ], [
1038
+ new y(new f(.2, 0, .6, 4), n),
1039
+ [
1040
+ 0,
1041
+ 0,
1042
+ -.3
1043
+ ],
1044
+ [
1045
+ -Math.PI / 2,
1046
+ 0,
1047
+ 0
1048
+ ]
1049
+ ]],
1050
+ XY: [[new y(new c(.2, .2, .01), n), [
1051
+ .15,
1052
+ .15,
1053
+ 0
1054
+ ]]],
1055
+ YZ: [[
1056
+ new y(new c(.2, .2, .01), n),
1057
+ [
1058
+ 0,
1059
+ .15,
1060
+ .15
1061
+ ],
1062
+ [
1063
+ 0,
1064
+ Math.PI / 2,
1065
+ 0
1066
+ ]
1067
+ ]],
1068
+ XZ: [[
1069
+ new y(new c(.2, .2, .01), n),
1070
+ [
1071
+ .15,
1072
+ 0,
1073
+ .15
1074
+ ],
1075
+ [
1076
+ -Math.PI / 2,
1077
+ 0,
1078
+ 0
1079
+ ]
1080
+ ]],
1081
+ XYZ: [[new y(new c(.2, .2, .2), n), [
1082
+ 0,
1083
+ 0,
1084
+ 0
1085
+ ]]]
1086
+ }, oe = {
1087
+ X: [[
1088
+ new _(w, r),
1089
+ [
1090
+ -1e3,
1091
+ 0,
1092
+ 0
1093
+ ],
1094
+ null,
1095
+ [
1096
+ 1e6,
1097
+ 1,
1098
+ 1
1099
+ ],
1100
+ "helper"
1101
+ ]],
1102
+ Y: [[
1103
+ new _(w, r),
1104
+ [
1105
+ 0,
1106
+ -1e3,
1107
+ 0
1108
+ ],
1109
+ [
1110
+ 0,
1111
+ 0,
1112
+ Math.PI / 2
1113
+ ],
1114
+ [
1115
+ 1e6,
1116
+ 1,
1117
+ 1
1118
+ ],
1119
+ "helper"
1120
+ ]],
1121
+ Z: [[
1122
+ new _(w, r),
1123
+ [
1124
+ 0,
1125
+ 0,
1126
+ -1e3
1127
+ ],
1128
+ [
1129
+ 0,
1130
+ -Math.PI / 2,
1131
+ 0
1132
+ ],
1133
+ [
1134
+ 1e6,
1135
+ 1,
1136
+ 1
1137
+ ],
1138
+ "helper"
1139
+ ]]
1140
+ };
1141
+ function P(e) {
1142
+ let t = new S();
1143
+ for (let n in e) for (let r = e[n].length; r--;) {
1144
+ let i = e[n][r][0].clone(), a = e[n][r][1], o = e[n][r][2], s = e[n][r][3], c = e[n][r][4];
1145
+ i.name = n, i.tag = c, a && i.position.set(a[0], a[1], a[2]), o && i.rotation.set(o[0], o[1], o[2]), s && i.scale.set(s[0], s[1], s[2]), i.updateMatrix();
1146
+ let l = i.geometry.clone();
1147
+ l.applyMatrix4(i.matrix), i.geometry = l, i.renderOrder = Infinity, i.position.set(0, 0, 0), i.rotation.set(0, 0, 0), i.scale.set(1, 1, 1), t.add(i);
1148
+ }
1149
+ return t;
1150
+ }
1151
+ this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = P(re)), this.add(this.gizmo.rotate = P(k)), this.add(this.gizmo.scale = P(M)), this.add(this.picker.translate = P(D)), this.add(this.picker.rotate = P(j)), this.add(this.picker.scale = P(N)), this.add(this.helper.translate = P(ae)), this.add(this.helper.rotate = P(A)), this.add(this.helper.scale = P(oe)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
1152
+ }
1153
+ updateMatrixWorld(e) {
1154
+ let t = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : W;
1155
+ 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";
1156
+ let n = [];
1157
+ n = n.concat(this.picker[this.mode].children), n = n.concat(this.gizmo[this.mode].children), n = n.concat(this.helper[this.mode].children);
1158
+ for (let e = 0; e < n.length; e++) {
1159
+ let r = n[e];
1160
+ r.visible = !0, r.rotation.set(0, 0, 0), r.position.copy(this.worldPosition);
1161
+ let i;
1162
+ if (i = 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), r.scale.set(1, 1, 1).multiplyScalar(i * this.size / 4), r.tag === "helper") r.visible = !1, r.name === "AXIS" ? (r.visible = !!this.axis, this.axis === "X" && (R.setFromEuler(V.set(0, 0, 0)), r.quaternion.copy(t).multiply(R), Math.abs(H.copy(K).applyQuaternion(t).dot(this.eye)) > .9 && (r.visible = !1)), this.axis === "Y" && (R.setFromEuler(V.set(0, 0, Math.PI / 2)), r.quaternion.copy(t).multiply(R), Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye)) > .9 && (r.visible = !1)), this.axis === "Z" && (R.setFromEuler(V.set(0, Math.PI / 2, 0)), r.quaternion.copy(t).multiply(R), Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye)) > .9 && (r.visible = !1)), this.axis === "XYZE" && (R.setFromEuler(V.set(0, Math.PI / 2, 0)), H.copy(this.rotationAxis), r.quaternion.setFromRotationMatrix(Oe.lookAt(De, H, q)), r.quaternion.multiply(R), r.visible = this.dragging), this.axis === "E" && (r.visible = !1)) : r.name === "START" ? (r.position.copy(this.worldPositionStart), r.visible = this.dragging) : r.name === "END" ? (r.position.copy(this.worldPosition), r.visible = this.dragging) : r.name === "DELTA" ? (r.position.copy(this.worldPositionStart), r.quaternion.copy(this.worldQuaternionStart), I.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), I.applyQuaternion(this.worldQuaternionStart.clone().invert()), r.scale.copy(I), r.visible = this.dragging) : (r.quaternion.copy(t), this.dragging ? r.position.copy(this.worldPositionStart) : r.position.copy(this.worldPosition), this.axis && (r.visible = this.axis.search(r.name) !== -1));
1163
+ else {
1164
+ if (r.quaternion.copy(t), this.mode === "translate" || this.mode === "scale") {
1165
+ let e = .99, n = .2;
1166
+ r.name === "X" && Math.abs(H.copy(K).applyQuaternion(t).dot(this.eye)) > e && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1), r.name === "Y" && Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye)) > e && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1), r.name === "Z" && Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye)) > e && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1), r.name === "XY" && Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye)) < n && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1), r.name === "YZ" && Math.abs(H.copy(K).applyQuaternion(t).dot(this.eye)) < n && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1), r.name === "XZ" && Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye)) < n && (r.scale.set(1e-10, 1e-10, 1e-10), r.visible = !1);
1167
+ } else this.mode === "rotate" && (U.copy(t), H.copy(this.eye).applyQuaternion(R.copy(t).invert()), r.name.search("E") !== -1 && r.quaternion.setFromRotationMatrix(Oe.lookAt(this.eye, De, q)), r.name === "X" && (R.setFromAxisAngle(K, Math.atan2(-H.y, H.z)), R.multiplyQuaternions(U, R), r.quaternion.copy(R)), r.name === "Y" && (R.setFromAxisAngle(q, Math.atan2(H.x, H.z)), R.multiplyQuaternions(U, R), r.quaternion.copy(R)), r.name === "Z" && (R.setFromAxisAngle(J, Math.atan2(H.y, H.x)), R.multiplyQuaternions(U, R), r.quaternion.copy(R)));
1168
+ r.visible = r.visible && (r.name.indexOf("X") === -1 || this.showX), r.visible = r.visible && (r.name.indexOf("Y") === -1 || this.showY), r.visible = r.visible && (r.name.indexOf("Z") === -1 || this.showZ), r.visible = r.visible && (r.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), r.visible = r.visible && (r.name.indexOf("XY") === -1 || this.showXY), r.visible = r.visible && (r.name.indexOf("YZ") === -1 || this.showYZ), r.visible = r.visible && (r.name.indexOf("XZ") === -1 || this.showXZ), r.material._color = r.material._color || r.material.color.clone(), r.material._opacity = r.material._opacity || r.material.opacity, r.material.color.copy(r.material._color), r.material.opacity = r.material._opacity, this.enabled && this.axis && (r.name === this.axis || this.axis.split("").some(function(e) {
1169
+ return r.name === e;
1170
+ })) && (r.material.color.copy(this.materialLib.active.color), r.material.opacity = 1);
1171
+ }
1172
+ }
1173
+ super.updateMatrixWorld(e);
1174
+ }
1175
+ }, Me = class extends y {
1176
+ constructor() {
1177
+ super(new T(1e5, 1e5, 2, 2), new te({
1178
+ visible: !1,
1179
+ wireframe: !0,
1180
+ side: p,
1181
+ transparent: !0,
1182
+ opacity: .1,
1183
+ toneMapped: !1
1184
+ })), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
1185
+ }
1186
+ updateMatrixWorld(e) {
1187
+ let t = this.space;
1188
+ switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), Y.copy(K).applyQuaternion(t === "local" ? this.worldQuaternion : W), X.copy(q).applyQuaternion(t === "local" ? this.worldQuaternion : W), Z.copy(J).applyQuaternion(t === "local" ? this.worldQuaternion : W), H.copy(X), this.mode) {
1189
+ case "translate":
1190
+ case "scale":
1191
+ switch (this.axis) {
1192
+ case "X":
1193
+ H.copy(this.eye).cross(Y), G.copy(Y).cross(H);
1194
+ break;
1195
+ case "Y":
1196
+ H.copy(this.eye).cross(X), G.copy(X).cross(H);
1197
+ break;
1198
+ case "Z":
1199
+ H.copy(this.eye).cross(Z), G.copy(Z).cross(H);
1200
+ break;
1201
+ case "XY":
1202
+ G.copy(Z);
1203
+ break;
1204
+ case "YZ":
1205
+ G.copy(Y);
1206
+ break;
1207
+ case "XZ":
1208
+ H.copy(Z), G.copy(X);
1209
+ break;
1210
+ case "XYZ":
1211
+ case "E": G.set(0, 0, 0);
1212
+ }
1213
+ break;
1214
+ default: G.set(0, 0, 0);
1215
+ }
1216
+ G.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (ke.lookAt(I.set(0, 0, 0), G, H), this.quaternion.setFromRotationMatrix(ke)), super.updateMatrixWorld(e);
1217
+ }
1218
+ }, Ne = class {
1219
+ constructor() {
1220
+ this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
1221
+ }
1222
+ setSize() {}
1223
+ render() {
1224
+ console.error("THREE.Pass: .render() must be implemented in derived pass.");
1225
+ }
1226
+ dispose() {}
1227
+ }, Pe = new w(-1, 1, 1, -1, 0, 1), Fe = new class extends l {
1228
+ constructor() {
1229
+ super(), this.setAttribute("position", new h([
1230
+ -1,
1231
+ 3,
1232
+ 0,
1233
+ -1,
1234
+ -1,
1235
+ 0,
1236
+ 3,
1237
+ -1,
1238
+ 0
1239
+ ], 3)), this.setAttribute("uv", new h([
1240
+ 0,
1241
+ 2,
1242
+ 0,
1243
+ 0,
1244
+ 2,
1245
+ 0
1246
+ ], 2));
1247
+ }
1248
+ }(), Ie = class {
1249
+ constructor(e) {
1250
+ this._mesh = new y(Fe, e);
1251
+ }
1252
+ dispose() {
1253
+ this._mesh.geometry.dispose();
1254
+ }
1255
+ render(e) {
1256
+ e.render(this._mesh, Pe);
1257
+ }
1258
+ get material() {
1259
+ return this._mesh.material;
1260
+ }
1261
+ set material(e) {
1262
+ this._mesh.material = e;
1263
+ }
1264
+ }, Le = {
1265
+ name: "CopyShader",
1266
+ uniforms: {
1267
+ tDiffuse: { value: null },
1268
+ opacity: { value: 1 }
1269
+ },
1270
+ vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
1271
+ fragmentShader: "\n\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = opacity * texel;\n\n\n }"
1272
+ }, Re = class e extends Ne {
1273
+ constructor(e, t, n, r) {
1274
+ super(), this.renderScene = t, this.renderCamera = n, this.selectedObjects = r === void 0 ? [] : r, this.visibleEdgeColor = new u(1, 1, 1), this.hiddenEdgeColor = new u(.1, .04, .02), this.edgeGlow = 0, this.usePatternTexture = !1, this.patternTexture = null, this.edgeThickness = 1, this.edgeStrength = 3, this.downSampleRatio = 2, this.pulsePeriod = 0, this._visibilityCache = /* @__PURE__ */ new Map(), this._selectionCache = /* @__PURE__ */ new Set(), this.resolution = e === void 0 ? new k(256, 256) : new k(e.x, e.y);
1275
+ let i = Math.round(this.resolution.x / this.downSampleRatio), a = Math.round(this.resolution.y / this.downSampleRatio);
1276
+ this.renderTargetMaskBuffer = new j(this.resolution.x, this.resolution.y), this.renderTargetMaskBuffer.texture.name = "OutlinePass.mask", this.renderTargetMaskBuffer.texture.generateMipmaps = !1, this.depthMaterial = new b(), this.depthMaterial.side = p, this.depthMaterial.depthPacking = ne, this.depthMaterial.blending = x, this.prepareMaskMaterial = this._getPrepareMaskMaterial(), this.prepareMaskMaterial.side = p, this.prepareMaskMaterial.fragmentShader = s(this.prepareMaskMaterial.fragmentShader, this.renderCamera), this.renderTargetDepthBuffer = new j(this.resolution.x, this.resolution.y, { type: g }), this.renderTargetDepthBuffer.texture.name = "OutlinePass.depth", this.renderTargetDepthBuffer.texture.generateMipmaps = !1, this.renderTargetMaskDownSampleBuffer = new j(i, a, { type: g }), this.renderTargetMaskDownSampleBuffer.texture.name = "OutlinePass.depthDownSample", this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = !1, this.renderTargetBlurBuffer1 = new j(i, a, { type: g }), this.renderTargetBlurBuffer1.texture.name = "OutlinePass.blur1", this.renderTargetBlurBuffer1.texture.generateMipmaps = !1, this.renderTargetBlurBuffer2 = new j(Math.round(i / 2), Math.round(a / 2), { type: g }), this.renderTargetBlurBuffer2.texture.name = "OutlinePass.blur2", this.renderTargetBlurBuffer2.texture.generateMipmaps = !1, this.edgeDetectionMaterial = this._getEdgeDetectionMaterial(), this.renderTargetEdgeBuffer1 = new j(i, a, { type: g }), this.renderTargetEdgeBuffer1.texture.name = "OutlinePass.edge1", this.renderTargetEdgeBuffer1.texture.generateMipmaps = !1, this.renderTargetEdgeBuffer2 = new j(Math.round(i / 2), Math.round(a / 2), { type: g }), this.renderTargetEdgeBuffer2.texture.name = "OutlinePass.edge2", this.renderTargetEdgeBuffer2.texture.generateMipmaps = !1, this.separableBlurMaterial1 = this._getSeparableBlurMaterial(4), this.separableBlurMaterial1.uniforms.texSize.value.set(i, a), this.separableBlurMaterial1.uniforms.kernelRadius.value = 1, this.separableBlurMaterial2 = this._getSeparableBlurMaterial(4), this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(i / 2), Math.round(a / 2)), this.separableBlurMaterial2.uniforms.kernelRadius.value = 4, this.overlayMaterial = this._getOverlayMaterial();
1277
+ let o = Le;
1278
+ this.copyUniforms = ae.clone(o.uniforms), this.materialCopy = new D({
1279
+ uniforms: this.copyUniforms,
1280
+ vertexShader: o.vertexShader,
1281
+ fragmentShader: o.fragmentShader,
1282
+ blending: x,
1283
+ depthTest: !1,
1284
+ depthWrite: !1
1285
+ }), this.enabled = !0, this.needsSwap = !1, this._oldClearColor = new u(), this.oldClearAlpha = 1, this._fsQuad = new Ie(null), this.tempPulseColor1 = new u(), this.tempPulseColor2 = new u(), this.textureMatrix = new v();
1286
+ function s(e, t) {
1287
+ let n = t.isPerspectiveCamera ? "perspective" : "orthographic";
1288
+ return e.replace(/DEPTH_TO_VIEW_Z/g, n + "DepthToViewZ");
1289
+ }
1290
+ }
1291
+ dispose() {
1292
+ this.renderTargetMaskBuffer.dispose(), this.renderTargetDepthBuffer.dispose(), this.renderTargetMaskDownSampleBuffer.dispose(), this.renderTargetBlurBuffer1.dispose(), this.renderTargetBlurBuffer2.dispose(), this.renderTargetEdgeBuffer1.dispose(), this.renderTargetEdgeBuffer2.dispose(), this.depthMaterial.dispose(), this.prepareMaskMaterial.dispose(), this.edgeDetectionMaterial.dispose(), this.separableBlurMaterial1.dispose(), this.separableBlurMaterial2.dispose(), this.overlayMaterial.dispose(), this.materialCopy.dispose(), this._fsQuad.dispose();
1293
+ }
1294
+ setSize(e, t) {
1295
+ this.renderTargetMaskBuffer.setSize(e, t), this.renderTargetDepthBuffer.setSize(e, t);
1296
+ let n = Math.round(e / this.downSampleRatio), r = Math.round(t / this.downSampleRatio);
1297
+ this.renderTargetMaskDownSampleBuffer.setSize(n, r), this.renderTargetBlurBuffer1.setSize(n, r), this.renderTargetEdgeBuffer1.setSize(n, r), this.separableBlurMaterial1.uniforms.texSize.value.set(n, r), n = Math.round(n / 2), r = Math.round(r / 2), this.renderTargetBlurBuffer2.setSize(n, r), this.renderTargetEdgeBuffer2.setSize(n, r), this.separableBlurMaterial2.uniforms.texSize.value.set(n, r);
1298
+ }
1299
+ render(t, n, r, i, a) {
1300
+ if (this.selectedObjects.length > 0) {
1301
+ t.getClearColor(this._oldClearColor), this.oldClearAlpha = t.getClearAlpha();
1302
+ let n = t.autoClear;
1303
+ t.autoClear = !1, a && t.state.buffers.stencil.setTest(!1), t.setClearColor(16777215, 1), this._updateSelectionCache(), this._changeVisibilityOfSelectedObjects(!1);
1304
+ let i = this.renderScene.background, o = this.renderScene.overrideMaterial;
1305
+ if (this.renderScene.background = null, this.renderScene.overrideMaterial = this.depthMaterial, t.setRenderTarget(this.renderTargetDepthBuffer), t.clear(), t.render(this.renderScene, this.renderCamera), this._changeVisibilityOfSelectedObjects(!0), this._visibilityCache.clear(), this._updateTextureMatrix(), this._changeVisibilityOfNonSelectedObjects(!1), this.renderScene.overrideMaterial = this.prepareMaskMaterial, this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near, this.renderCamera.far), this.prepareMaskMaterial.uniforms.depthTexture.value = this.renderTargetDepthBuffer.texture, this.prepareMaskMaterial.uniforms.textureMatrix.value = this.textureMatrix, t.setRenderTarget(this.renderTargetMaskBuffer), t.clear(), t.render(this.renderScene, this.renderCamera), this._changeVisibilityOfNonSelectedObjects(!0), this._visibilityCache.clear(), this._selectionCache.clear(), this.renderScene.background = i, this.renderScene.overrideMaterial = o, this._fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = this.renderTargetMaskBuffer.texture, t.setRenderTarget(this.renderTargetMaskDownSampleBuffer), t.clear(), this._fsQuad.render(t), this.tempPulseColor1.copy(this.visibleEdgeColor), this.tempPulseColor2.copy(this.hiddenEdgeColor), this.pulsePeriod > 0) {
1306
+ let e = 1.25 / 2 + Math.cos(performance.now() * .01 / this.pulsePeriod) * .75 / 2;
1307
+ this.tempPulseColor1.multiplyScalar(e), this.tempPulseColor2.multiplyScalar(e);
1308
+ }
1309
+ this._fsQuad.material = this.edgeDetectionMaterial, this.edgeDetectionMaterial.uniforms.maskTexture.value = this.renderTargetMaskDownSampleBuffer.texture, this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height), this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value = this.tempPulseColor1, this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value = this.tempPulseColor2, t.setRenderTarget(this.renderTargetEdgeBuffer1), t.clear(), this._fsQuad.render(t), this._fsQuad.material = this.separableBlurMaterial1, this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = e.BlurDirectionX, this.separableBlurMaterial1.uniforms.kernelRadius.value = this.edgeThickness, t.setRenderTarget(this.renderTargetBlurBuffer1), t.clear(), this._fsQuad.render(t), this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetBlurBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = e.BlurDirectionY, t.setRenderTarget(this.renderTargetEdgeBuffer1), t.clear(), this._fsQuad.render(t), this._fsQuad.material = this.separableBlurMaterial2, this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial2.uniforms.direction.value = e.BlurDirectionX, t.setRenderTarget(this.renderTargetBlurBuffer2), t.clear(), this._fsQuad.render(t), this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetBlurBuffer2.texture, this.separableBlurMaterial2.uniforms.direction.value = e.BlurDirectionY, t.setRenderTarget(this.renderTargetEdgeBuffer2), t.clear(), this._fsQuad.render(t), this._fsQuad.material = this.overlayMaterial, this.overlayMaterial.uniforms.maskTexture.value = this.renderTargetMaskBuffer.texture, this.overlayMaterial.uniforms.edgeTexture1.value = this.renderTargetEdgeBuffer1.texture, this.overlayMaterial.uniforms.edgeTexture2.value = this.renderTargetEdgeBuffer2.texture, this.overlayMaterial.uniforms.patternTexture.value = this.patternTexture, this.overlayMaterial.uniforms.edgeStrength.value = this.edgeStrength, this.overlayMaterial.uniforms.edgeGlow.value = this.edgeGlow, this.overlayMaterial.uniforms.usePatternTexture.value = this.usePatternTexture, a && t.state.buffers.stencil.setTest(!0), t.setRenderTarget(r), this._fsQuad.render(t), t.setClearColor(this._oldClearColor, this.oldClearAlpha), t.autoClear = n;
1310
+ }
1311
+ this.renderToScreen && (this._fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = r.texture, t.setRenderTarget(null), this._fsQuad.render(t));
1312
+ }
1313
+ _updateSelectionCache() {
1314
+ let e = this._selectionCache;
1315
+ function t(t) {
1316
+ t.isMesh && e.add(t);
1317
+ }
1318
+ e.clear();
1319
+ for (let e = 0; e < this.selectedObjects.length; e++) this.selectedObjects[e].traverse(t);
1320
+ }
1321
+ _changeVisibilityOfSelectedObjects(e) {
1322
+ let t = this._visibilityCache;
1323
+ for (let n of this._selectionCache) e === !0 ? n.visible = t.get(n) : (t.set(n, n.visible), n.visible = e);
1324
+ }
1325
+ _changeVisibilityOfNonSelectedObjects(e) {
1326
+ let t = this._visibilityCache, n = this._selectionCache;
1327
+ function r(r) {
1328
+ if (r.isPoints || r.isLine || r.isLine2) e === !0 ? r.visible = t.get(r) : (t.set(r, r.visible), r.visible = e);
1329
+ else if ((r.isMesh || r.isSprite) && !n.has(r)) {
1330
+ let n = r.visible;
1331
+ (e === !1 || t.get(r) === !0) && (r.visible = e), t.set(r, n);
1332
+ }
1333
+ }
1334
+ this.renderScene.traverse(r);
1335
+ }
1336
+ _updateTextureMatrix() {
1337
+ this.textureMatrix.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), this.textureMatrix.multiply(this.renderCamera.projectionMatrix), this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse);
1338
+ }
1339
+ _getPrepareMaskMaterial() {
1340
+ return new D({
1341
+ uniforms: {
1342
+ depthTexture: { value: null },
1343
+ cameraNearFar: { value: new k(.5, .5) },
1344
+ textureMatrix: { value: null }
1345
+ },
1346
+ vertexShader: "#include <batching_pars_vertex>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n\n varying vec4 projTexCoord;\n varying vec4 vPosition;\n uniform mat4 textureMatrix;\n\n void main() {\n\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n\n vPosition = mvPosition;\n\n vec4 worldPosition = vec4( transformed, 1.0 );\n\n #ifdef USE_INSTANCING\n\n worldPosition = instanceMatrix * worldPosition;\n\n #endif\n\n worldPosition = modelMatrix * worldPosition;\n\n projTexCoord = textureMatrix * worldPosition;\n\n }",
1347
+ fragmentShader: "#include <packing>\n varying vec4 vPosition;\n varying vec4 projTexCoord;\n uniform sampler2D depthTexture;\n uniform vec2 cameraNearFar;\n\n void main() {\n\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n }"
1348
+ });
1349
+ }
1350
+ _getEdgeDetectionMaterial() {
1351
+ return new D({
1352
+ uniforms: {
1353
+ maskTexture: { value: null },
1354
+ texSize: { value: new k(.5, .5) },
1355
+ visibleEdgeColor: { value: new A(1, 1, 1) },
1356
+ hiddenEdgeColor: { value: new A(1, 1, 1) }
1357
+ },
1358
+ vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
1359
+ fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform vec2 texSize;\n uniform vec3 visibleEdgeColor;\n uniform vec3 hiddenEdgeColor;\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n float diff1 = (c1.r - c2.r)*0.5;\n float diff2 = (c3.r - c4.r)*0.5;\n float d = length( vec2(diff1, diff2) );\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibilityFactor = min(a1, a2);\n vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n }"
1360
+ });
1361
+ }
1362
+ _getSeparableBlurMaterial(e) {
1363
+ return new D({
1364
+ defines: { MAX_RADIUS: e },
1365
+ uniforms: {
1366
+ colorTexture: { value: null },
1367
+ texSize: { value: new k(.5, .5) },
1368
+ direction: { value: new k(.5, .5) },
1369
+ kernelRadius: { value: 1 }
1370
+ },
1371
+ vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
1372
+ fragmentShader: "#include <common>\n varying vec2 vUv;\n uniform sampler2D colorTexture;\n uniform vec2 texSize;\n uniform vec2 direction;\n uniform float kernelRadius;\n\n float gaussianPdf(in float x, in float sigma) {\n return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n }\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n float sigma = kernelRadius/2.0;\n float weightSum = gaussianPdf(0.0, sigma);\n vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n vec2 uvOffset = delta;\n for( int i = 1; i <= MAX_RADIUS; i ++ ) {\n float x = kernelRadius * float(i) / float(MAX_RADIUS);\n float w = gaussianPdf(x, sigma);\n vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n diffuseSum += ((sample1 + sample2) * w);\n weightSum += (2.0 * w);\n uvOffset += delta;\n }\n gl_FragColor = diffuseSum/weightSum;\n }"
1373
+ });
1374
+ }
1375
+ _getOverlayMaterial() {
1376
+ return new D({
1377
+ uniforms: {
1378
+ maskTexture: { value: null },
1379
+ edgeTexture1: { value: null },
1380
+ edgeTexture2: { value: null },
1381
+ patternTexture: { value: null },
1382
+ edgeStrength: { value: 1 },
1383
+ edgeGlow: { value: 1 },
1384
+ usePatternTexture: { value: 0 }
1385
+ },
1386
+ vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
1387
+ fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform sampler2D edgeTexture1;\n uniform sampler2D edgeTexture2;\n uniform sampler2D patternTexture;\n uniform float edgeStrength;\n uniform float edgeGlow;\n uniform bool usePatternTexture;\n\n void main() {\n vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n vec4 maskColor = texture2D(maskTexture, vUv);\n vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n if(usePatternTexture)\n finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n gl_FragColor = finalColor;\n }",
1388
+ blending: s,
1389
+ depthTest: !1,
1390
+ depthWrite: !1,
1391
+ transparent: !0
1392
+ });
1393
+ }
1394
+ };
1395
+ Re.BlurDirectionX = new k(1, 0), Re.BlurDirectionY = new k(0, 1);
1396
+ // src/Editor/demoScene.ts
1397
+ var Q = "main";
1398
+ function $(e, t, n, r) {
1399
+ return {
1400
+ id: e,
1401
+ type: t,
1402
+ transform: {
1403
+ position: n,
1404
+ rotation: [
1405
+ 0,
1406
+ 0,
1407
+ 0
1408
+ ],
1409
+ scale: [
1410
+ 1,
1411
+ 1,
1412
+ 1
1413
+ ]
1414
+ },
1415
+ ...r ? { props: r } : {}
1416
+ };
1417
+ }
1418
+ function ze() {
1419
+ let e = 5 * .707, t = (e, t, n) => $(e, N(t), n, { castShadow: !0 });
1420
+ return {
1421
+ version: oe,
1422
+ name: Q,
1423
+ settings: {},
1424
+ objects: [
1425
+ $("ambient_light", M("AmbientLight"), [
1426
+ 0,
1427
+ 5,
1428
+ 0
1429
+ ]),
1430
+ $("sun", M("DirectionalLightShadow"), [
1431
+ 10,
1432
+ 15,
1433
+ 5
1434
+ ], {
1435
+ intensity: 5,
1436
+ castShadow: !0
1437
+ }),
1438
+ $("ground", N("Plane"), [
1439
+ 0,
1440
+ 0,
1441
+ 0
1442
+ ], {
1443
+ width: 50,
1444
+ height: 50,
1445
+ color: "#ffbe6f",
1446
+ receiveShadow: !0
1447
+ }),
1448
+ t("box", "Box", [
1449
+ 5,
1450
+ .5,
1451
+ 0
1452
+ ]),
1453
+ t("sphere", "Sphere", [
1454
+ e,
1455
+ 1,
1456
+ e
1457
+ ]),
1458
+ t("cone", "Cone", [
1459
+ 0,
1460
+ .5,
1461
+ 5
1462
+ ]),
1463
+ t("cylinder", "Cylinder", [
1464
+ -3.5349999999999997,
1465
+ .5,
1466
+ e
1467
+ ]),
1468
+ t("octahedron", "Octahedron", [
1469
+ -5,
1470
+ 1,
1471
+ 0
1472
+ ]),
1473
+ t("dodecahedron", "Dodecahedron", [
1474
+ -3.5349999999999997,
1475
+ 1,
1476
+ -3.5349999999999997
1477
+ ]),
1478
+ t("capsule", "Capsule", [
1479
+ 0,
1480
+ 1,
1481
+ -5
1482
+ ]),
1483
+ t("icosahedron", "Icosahedron", [
1484
+ e,
1485
+ 1,
1486
+ -3.5349999999999997
1487
+ ]),
1488
+ t("torus_knot", "TorusKnot", [
1489
+ 0,
1490
+ 3.5,
1491
+ 0
1492
+ ])
1493
+ ]
1494
+ };
1495
+ }
1496
+ // src/Editor.ts
1497
+ var Be = class s extends o {
1498
+ static registerPanel(e) {
1499
+ return n(e);
1500
+ }
1501
+ static registerListener() {
1502
+ i.instance().input.on("keydown", (e) => {
1503
+ (e.code === "Insert" || e.code === "Period") && (i.instance().editor = new s());
1504
+ });
1505
+ }
1506
+ constructor() {
1507
+ super(), this.activeToolMode = "translate", this.shadeMode = "solid", this.originalMaterials = /* @__PURE__ */ new Map(), this.shadeOverrideMaterials = /* @__PURE__ */ new Map(), this.flatColors = /* @__PURE__ */ new Map(), this.helpers = [], this.lightHelpers = [], this._showHelpers = !0, this.abort = new AbortController(), this.activeAssetCategory = "Object", i.instance().editor = this, i.instance().logger?.info("Booting Editor"), i.instance().trigger("editorBoot", this), i.instance().trigger("uiDestroy", this);
1508
+ let e = i.instance().activeScene;
1509
+ e ? e.rebuild() : this.clearGame(), this.initEditorScene(), e || this.openDefaultScene(), i.instance().contextMenuAbort.abort(), i.instance().uiRoot.innerHTML = "", i.instance().uiRoot.style.opacity = "1", document.title = "MavonEngine | Editor", document.getElementsByTagName("body")[0].removeAttribute("onContextMenu"), Promise.all([import("./mount-CnirMLg0.mjs"), import("./global-l94NfB94.mjs").then((e) => e.t)]).then(([{ mountEditorUI: e }]) => {
1510
+ this.reactRoot = e(i.instance().uiRoot);
1511
+ });
1512
+ }
1513
+ initEditorScene() {
1514
+ i.instance().camera.instance.position.set(20, 10, 20), i.instance().camera.instance.rotation.set(0, 0, 0), i.instance().camera.instance.rotateY(Math.PI / 360 * 90), i.instance().camera.instance.rotateX(Math.PI / 360 * -45), this.outlinePass = new Re(new k(i.instance().sizes.width, i.instance().sizes.height), i.instance().scene, i.instance().camera.instance), i.instance().renderer.composer.addPass(this.outlinePass), this.initFlyControls(), this.watchScene(i.instance().activeScene), i.instance().on("sceneLoaded", (e) => {
1515
+ this.deselect(), this.watchScene(e), this.trigger("sceneChanged");
1516
+ }), window.addEventListener("keydown", (e) => {
1517
+ (e.ctrlKey || e.metaKey) && e.code === "KeyS" && (e.preventDefault(), this.saveScene());
1518
+ }, { signal: this.abort.signal }), this.trigger("sceneChanged"), i.instance().input.on("mousedown", (e) => {
1519
+ e.target === i.instance().canvas && this.handleCanvasClick(e);
1520
+ }), i.instance().input.on("keydown", (e) => {
1521
+ e.code === "Escape" && this.activeItem && this.deselect();
1522
+ }), this.handleItemDelete(), this.on("setTransformMode", (e) => {
1523
+ this.activeToolMode = e, this.transformControls?.setMode(e), i.instance().logger?.info(`Setting editor tool mode: ${e}`);
1524
+ }), this.on("setShadeMode", (e) => {
1525
+ this.applyShadeMode(e);
1526
+ }), this.on("assetDropped", () => {
1527
+ this.shadeMode !== "solid" && this.applyShadeMode(this.shadeMode);
1528
+ }), this.initAssetsFilter();
1529
+ }
1530
+ initAssetsFilter() {
1531
+ this.availableAssetCategories = [...new Set(Object.entries(i.instance().resources.items).map(([e, t]) => t.constructor.name))];
1532
+ }
1533
+ setActiveAssetCategory(e) {
1534
+ this.activeAssetCategory = e;
1535
+ }
1536
+ applyShadeMode(e) {
1537
+ this.shadeMode = e, t(i.instance().scene, e, this.originalMaterials, this.shadeOverrideMaterials, this.flatColors);
1538
+ }
1539
+ initFlyControls() {
1540
+ this.flyControls = new le(i.instance().camera.instance, i.instance().canvas), this.flyControls.autoForward = !1, this.flyControls.dragToLook = !0, this.flyControls.movementSpeed = 10, this.flyControls.rollSpeed = .5;
1541
+ }
1542
+ handleItemDelete() {
1543
+ i.instance().input.on("keydown", (e) => {
1544
+ if (e.code === "Delete" && this.activeItem) {
1545
+ let e = this.activeItem;
1546
+ for (; e.parent && e.parent !== i.instance().scene;) e = e.parent;
1547
+ e.traverse((e) => {
1548
+ e instanceof y && (e.geometry?.dispose(), Array.isArray(e.material) ? e.material.forEach((e) => e.dispose()) : e.material?.dispose());
1549
+ }), this.deselect();
1550
+ let t = r.from(e), n = i.instance().activeScene, a = n?.entryOfObject3D(e) ?? (t?.owner && n?.getEntries().find((e) => e.object === t.owner));
1551
+ n && a ? n.remove(a.data.id) : t?.owner ? t.owner.destroy() : (t && (t.dispose(), this.helpers = this.helpers.filter((e) => e !== t)), i.instance().scene.remove(e)), this.trigger("sceneChanged");
1552
+ }
1553
+ });
1554
+ }
1555
+ deselect() {
1556
+ this.transformControls?.detach(), this.outlinePass.selectedObjects = [], this.activeItem = null, this.trigger("objectDeselected");
1557
+ }
1558
+ selectObject(e) {
1559
+ this.activeItem = e, this.trigger("objectSelected", this.activeItem), this.outlinePass.selectedObjects = [this.activeItem], this.handleHelperTool();
1560
+ }
1561
+ handleCanvasClick(e) {
1562
+ if (e.button === 0) {
1563
+ if (this.transformControls && (this.transformControls.dragging || this.transformControls.axis !== null)) return;
1564
+ let e = i.instance().input.getPointerWorldPosition(void 0, null, !0);
1565
+ e instanceof S ? this.selectObject(e) : this.deselect();
1566
+ }
1567
+ }
1568
+ handleHelperTool() {
1569
+ if (!this.transformControls) {
1570
+ this.transformControls = new xe(i.instance().camera.instance, i.instance().canvas), this.transformControls.addEventListener("dragging-changed", (e) => {
1571
+ this.flyControls.enabled = !e.value, e.value || this.initFlyControls();
1572
+ });
1573
+ let e = this.transformControls.getHelper();
1574
+ e.userData.isEditorInternal = !0, i.instance().scene.add(e);
1575
+ }
1576
+ this.transformControls.setMode(this.activeToolMode), this.transformControls.attach(this.activeItem);
1577
+ }
1578
+ addPanel(e) {
1579
+ return n(e);
1580
+ }
1581
+ removePanel(t) {
1582
+ e(t);
1583
+ }
1584
+ saveScene(e = fetch) {
1585
+ let t = i.instance().activeScene;
1586
+ if (!t) return i.instance().logger?.warn("No scene to save"), Promise.resolve(!1);
1587
+ if (this.saving) return this.saving;
1588
+ let n = t.source ?? "main", r = t.serialize();
1589
+ this.trigger("sceneSaving", { name: n });
1590
+ let o = (e) => (i.instance().logger?.error(`Could not save scene ${n}: ${e}`), this.trigger("sceneSaveFailed", {
1591
+ name: n,
1592
+ error: e
1593
+ }), !1);
1594
+ return this.saving = e(a, {
1595
+ method: "POST",
1596
+ headers: { "Content-Type": "application/json" },
1597
+ body: JSON.stringify({
1598
+ name: n,
1599
+ scene: r
1600
+ })
1601
+ }).then(async (e) => {
1602
+ let a = await e.json().catch(() => ({}));
1603
+ return e.ok ? (t.source = n, t.markSaved(r), i.instance().logger?.info(`Saved scene ${n} to ${a.file ?? n}`), this.trigger("sceneSaved", {
1604
+ name: n,
1605
+ file: a.file
1606
+ }), !0) : o(a.error ?? `${e.status} ${e.statusText}`);
1607
+ }, (e) => o(e.message)).finally(() => {
1608
+ this.saving = void 0;
1609
+ }), this.saving;
1610
+ }
1611
+ async openDefaultScene() {
1612
+ try {
1613
+ await i.instance().openScene(Q);
1614
+ } catch {
1615
+ i.instance().logger?.info(`No scenes/${Q}.json yet, opening a demo scene. Save it with Ctrl+S`), i.instance().loadScene(ze(), Q);
1616
+ }
1617
+ }
1618
+ watchScene(e) {
1619
+ e?.on("changed", () => this.trigger("sceneChanged"));
1620
+ }
1621
+ clearGame() {
1622
+ i.instance().world.destroy(), i.instance().world.entities.items.clear(), i.instance().scene.traverse((e) => {
1623
+ e instanceof y && (e.geometry?.dispose(), Array.isArray(e.material) ? e.material.forEach((e) => e.dispose()) : e.material?.dispose());
1624
+ }), i.instance().scene.clear();
1625
+ }
1626
+ addHelper(e) {
1627
+ this.helpers.push(e), this._showHelpers || (e.mesh.visible = !1, e.label.domElement.style.display = "none");
1628
+ }
1629
+ removeHelper(e) {
1630
+ this.helpers = this.helpers.filter((t) => t !== e);
1631
+ }
1632
+ addLightHelper(e) {
1633
+ this.lightHelpers.push(e), this._showHelpers || (e.visible = !1);
1634
+ }
1635
+ removeLightHelper(e) {
1636
+ this.lightHelpers = this.lightHelpers.filter((t) => t !== e);
1637
+ }
1638
+ setShowHelpers(e) {
1639
+ this._showHelpers = e, this.helpers.forEach((t) => {
1640
+ t.mesh.visible = e, t.label.domElement.style.display = e ? "" : "none";
1641
+ }), this.lightHelpers.forEach((t) => t.visible = e);
1642
+ }
1643
+ update(e) {
1644
+ this.updateCamera(e), this.helpers.forEach((t) => t.update(e));
1645
+ }
1646
+ updateCamera(e) {
1647
+ this.flyControls.update(e);
1648
+ let t = i.instance().camera.instance, n = new A();
1649
+ t.getWorldDirection(n), t.quaternion.setFromRotationMatrix(new v().lookAt(new A(), n, new A(0, 1, 0)));
1650
+ }
1651
+ destroy() {
1652
+ this.abort.abort(), this.reactRoot.unmount(), this.outlinePass.dispose(), this.shadeOverrideMaterials.forEach((e) => e.dispose()), this.shadeOverrideMaterials.clear(), this.originalMaterials.clear(), this.flatColors.clear();
1653
+ }
1654
+ };
1655
+ export { Be as default, n as registerEditorPanel, e as unregisterEditorPanel };