@mavonengine/editor 0.0.8 → 0.0.10
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.
- package/dist/Editor/Network/NetworkOverlay.d.ts +54 -0
- package/dist/Editor/Network/SyncStore.d.ts +22 -0
- package/dist/Editor/Network/serverApi.d.ts +14 -0
- package/dist/Editor/Plugins/pluginsApi.d.ts +49 -0
- package/dist/Editor/Server/routesApi.d.ts +23 -0
- package/dist/Editor/UI/ActivityBar.d.ts +6 -1
- package/dist/Editor/UI/Assets/AssetStats.d.ts +3 -3
- package/dist/Editor/UI/Assets/Assets.d.ts +1 -1
- package/dist/Editor/UI/Assets/AudioPlayer.d.ts +1 -1
- package/dist/Editor/UI/Assets/ModelViewer.d.ts +3 -3
- package/dist/Editor/UI/Assets/ParticleViewer.d.ts +3 -3
- package/dist/Editor/UI/Assets/TextureViewer.d.ts +3 -3
- package/dist/Editor/UI/CanvasPanel.d.ts +1 -1
- package/dist/Editor/UI/CanvasToolbar.d.ts +1 -1
- package/dist/Editor/UI/Controllers/ControllerDebug.d.ts +1 -0
- package/dist/Editor/UI/Controllers/GamepadDiagram.d.ts +5 -0
- package/dist/Editor/UI/Controllers/useGamepads.d.ts +6 -0
- package/dist/Editor/UI/DockArea.d.ts +17 -0
- package/dist/Editor/UI/Editor.d.ts +1 -1
- package/dist/Editor/UI/Network/NetworkPanel.d.ts +5 -0
- package/dist/Editor/UI/Network/Timeline.d.ts +14 -0
- package/dist/Editor/UI/Network/format.d.ts +14 -0
- package/dist/Editor/UI/Network/useRecords.d.ts +13 -0
- package/dist/Editor/UI/PanelHeader.d.ts +1 -1
- package/dist/Editor/UI/Plugins/InstallDialog.d.ts +22 -0
- package/dist/Editor/UI/Plugins/Markdown.d.ts +3 -0
- package/dist/Editor/UI/Plugins/PluginsPanel.d.ts +8 -0
- package/dist/Editor/UI/PropertiesPanel.d.ts +1 -1
- package/dist/Editor/UI/SceneExplorer.d.ts +1 -1
- package/dist/Editor/UI/ScenePanel.d.ts +1 -0
- package/dist/Editor/UI/Server/ServerPanel.d.ts +9 -0
- package/dist/Editor/UI/ShadeModeButtons.d.ts +1 -1
- package/dist/Editor/UI/StatusBar.d.ts +1 -1
- package/dist/Editor/UI/TabBar.d.ts +1 -1
- package/dist/Editor/UI/Window.d.ts +1 -1
- package/dist/Editor/builtinPrefabs.d.ts +4 -0
- package/dist/Editor/demoScene.d.ts +7 -0
- package/dist/Editor/panels.d.ts +22 -0
- package/dist/Editor/recordPrefabUsage.d.ts +7 -0
- package/dist/Editor.css +2 -1
- package/dist/Editor.d.ts +29 -2
- package/dist/Editor.mjs +1815 -9
- package/dist/global-l94NfB94.mjs +22 -0
- package/dist/mount-BfaV9yI_.mjs +37038 -0
- package/dist/panels-DFsnKBKK.mjs +75 -0
- package/package.json +12 -12
- package/dist/Editor-CUEoQ8jG.mjs +0 -1352
- package/dist/mount-Da8g-2BI.mjs +0 -40805
package/dist/Editor-CUEoQ8jG.mjs
DELETED
|
@@ -1,1352 +0,0 @@
|
|
|
1
|
-
import Le from "@mavonengine/core/Editor/EditorHelper";
|
|
2
|
-
import c from "@mavonengine/core/Game";
|
|
3
|
-
import { AmbientLightPrimitive as Xe, DirectionalLightShadowPrimitive as Oe } from "@mavonengine/core/Prefab/Lights/index";
|
|
4
|
-
import { PlanePrimitive as He, BoxPrimitive as Ye, SpherePrimitive as Ze, ConePrimitive as Ue, CylinderPrimitive as je, OctahedronPrimitive as Fe, DodecahedronPrimitive as Ve, CapsulePrimitive as Ge, IcosahedronPrimitive as We, TorusKnotPrimitive as qe } from "@mavonengine/core/Prefab/Primitives/index";
|
|
5
|
-
import Ke from "@mavonengine/core/Utils/EventEmitter";
|
|
6
|
-
import { Quaternion as x, Controls as Ee, Vector3 as l, Raycaster as Ne, Object3D as le, MeshBasicMaterial as me, LineBasicMaterial as $e, CylinderGeometry as g, BoxGeometry as v, BufferGeometry as pe, Float32BufferAttribute as he, Mesh as o, OctahedronGeometry as se, Line as A, TorusGeometry as F, SphereGeometry as Je, Euler as et, Matrix4 as ce, PlaneGeometry as tt, DoubleSide as fe, OrthographicCamera as it, Color as V, Vector2 as D, WebGLRenderTarget as X, MeshDepthMaterial as st, RGBADepthPacking as nt, NoBlending as we, HalfFloatType as j, UniformsUtils as at, ShaderMaterial as G, AdditiveBlending as rt } from "three";
|
|
7
|
-
const ot = { type: "change" }, ge = 1e-6, ye = new x();
|
|
8
|
-
class lt extends Ee {
|
|
9
|
-
/**
|
|
10
|
-
* Constructs a new controls instance.
|
|
11
|
-
*
|
|
12
|
-
* @param {Object3D} object - The object that is managed by the controls.
|
|
13
|
-
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
14
|
-
*/
|
|
15
|
-
constructor(e, t = null) {
|
|
16
|
-
super(e, t), this.movementSpeed = 1, this.rollSpeed = 5e-3, this.dragToLook = !1, this.autoForward = !1, this._moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0, pitchUp: 0, pitchDown: 0, yawLeft: 0, yawRight: 0, rollLeft: 0, rollRight: 0 }, this._moveVector = new l(0, 0, 0), this._rotationVector = new l(0, 0, 0), this._lastQuaternion = new x(), this._lastPosition = new l(), this._status = 0, this._onKeyDown = ht.bind(this), this._onKeyUp = ct.bind(this), this._onPointerMove = dt.bind(this), this._onPointerDown = ut.bind(this), this._onPointerUp = pt.bind(this), this._onPointerCancel = ft.bind(this), this._onContextMenu = mt.bind(this), t !== null && this.connect(t);
|
|
17
|
-
}
|
|
18
|
-
connect(e) {
|
|
19
|
-
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";
|
|
20
|
-
}
|
|
21
|
-
disconnect() {
|
|
22
|
-
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 = "";
|
|
23
|
-
}
|
|
24
|
-
dispose() {
|
|
25
|
-
this.disconnect();
|
|
26
|
-
}
|
|
27
|
-
update(e) {
|
|
28
|
-
if (this.enabled === !1) return;
|
|
29
|
-
const t = this.object, n = e * this.movementSpeed, s = e * this.rollSpeed;
|
|
30
|
-
t.translateX(this._moveVector.x * n), t.translateY(this._moveVector.y * n), t.translateZ(this._moveVector.z * n), ye.set(this._rotationVector.x * s, this._rotationVector.y * s, this._rotationVector.z * s, 1).normalize(), t.quaternion.multiply(ye), (this._lastPosition.distanceToSquared(t.position) > ge || 8 * (1 - this._lastQuaternion.dot(t.quaternion)) > ge) && (this.dispatchEvent(ot), this._lastQuaternion.copy(t.quaternion), this._lastPosition.copy(t.position));
|
|
31
|
-
}
|
|
32
|
-
// private
|
|
33
|
-
_updateMovementVector() {
|
|
34
|
-
const e = this._moveState.forward || this.autoForward && !this._moveState.back ? 1 : 0;
|
|
35
|
-
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;
|
|
36
|
-
}
|
|
37
|
-
_updateRotationVector() {
|
|
38
|
-
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;
|
|
39
|
-
}
|
|
40
|
-
_getContainerDimensions() {
|
|
41
|
-
return this.domElement != document ? {
|
|
42
|
-
size: [this.domElement.offsetWidth, this.domElement.offsetHeight],
|
|
43
|
-
offset: [this.domElement.offsetLeft, this.domElement.offsetTop]
|
|
44
|
-
} : {
|
|
45
|
-
size: [window.innerWidth, window.innerHeight],
|
|
46
|
-
offset: [0, 0]
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function ht(h) {
|
|
51
|
-
if (!(h.altKey || this.enabled === !1)) {
|
|
52
|
-
switch (h.code) {
|
|
53
|
-
case "ShiftLeft":
|
|
54
|
-
case "ShiftRight":
|
|
55
|
-
this.movementSpeedMultiplier = 0.1;
|
|
56
|
-
break;
|
|
57
|
-
case "KeyW":
|
|
58
|
-
this._moveState.forward = 1;
|
|
59
|
-
break;
|
|
60
|
-
case "KeyS":
|
|
61
|
-
this._moveState.back = 1;
|
|
62
|
-
break;
|
|
63
|
-
case "KeyA":
|
|
64
|
-
this._moveState.left = 1;
|
|
65
|
-
break;
|
|
66
|
-
case "KeyD":
|
|
67
|
-
this._moveState.right = 1;
|
|
68
|
-
break;
|
|
69
|
-
case "KeyR":
|
|
70
|
-
this._moveState.up = 1;
|
|
71
|
-
break;
|
|
72
|
-
case "KeyF":
|
|
73
|
-
this._moveState.down = 1;
|
|
74
|
-
break;
|
|
75
|
-
case "ArrowUp":
|
|
76
|
-
this._moveState.pitchUp = 1;
|
|
77
|
-
break;
|
|
78
|
-
case "ArrowDown":
|
|
79
|
-
this._moveState.pitchDown = 1;
|
|
80
|
-
break;
|
|
81
|
-
case "ArrowLeft":
|
|
82
|
-
this._moveState.yawLeft = 1;
|
|
83
|
-
break;
|
|
84
|
-
case "ArrowRight":
|
|
85
|
-
this._moveState.yawRight = 1;
|
|
86
|
-
break;
|
|
87
|
-
case "KeyQ":
|
|
88
|
-
this._moveState.rollLeft = 1;
|
|
89
|
-
break;
|
|
90
|
-
case "KeyE":
|
|
91
|
-
this._moveState.rollRight = 1;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
this._updateMovementVector(), this._updateRotationVector();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function ct(h) {
|
|
98
|
-
if (this.enabled !== !1) {
|
|
99
|
-
switch (h.code) {
|
|
100
|
-
case "ShiftLeft":
|
|
101
|
-
case "ShiftRight":
|
|
102
|
-
this.movementSpeedMultiplier = 1;
|
|
103
|
-
break;
|
|
104
|
-
case "KeyW":
|
|
105
|
-
this._moveState.forward = 0;
|
|
106
|
-
break;
|
|
107
|
-
case "KeyS":
|
|
108
|
-
this._moveState.back = 0;
|
|
109
|
-
break;
|
|
110
|
-
case "KeyA":
|
|
111
|
-
this._moveState.left = 0;
|
|
112
|
-
break;
|
|
113
|
-
case "KeyD":
|
|
114
|
-
this._moveState.right = 0;
|
|
115
|
-
break;
|
|
116
|
-
case "KeyR":
|
|
117
|
-
this._moveState.up = 0;
|
|
118
|
-
break;
|
|
119
|
-
case "KeyF":
|
|
120
|
-
this._moveState.down = 0;
|
|
121
|
-
break;
|
|
122
|
-
case "ArrowUp":
|
|
123
|
-
this._moveState.pitchUp = 0;
|
|
124
|
-
break;
|
|
125
|
-
case "ArrowDown":
|
|
126
|
-
this._moveState.pitchDown = 0;
|
|
127
|
-
break;
|
|
128
|
-
case "ArrowLeft":
|
|
129
|
-
this._moveState.yawLeft = 0;
|
|
130
|
-
break;
|
|
131
|
-
case "ArrowRight":
|
|
132
|
-
this._moveState.yawRight = 0;
|
|
133
|
-
break;
|
|
134
|
-
case "KeyQ":
|
|
135
|
-
this._moveState.rollLeft = 0;
|
|
136
|
-
break;
|
|
137
|
-
case "KeyE":
|
|
138
|
-
this._moveState.rollRight = 0;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
this._updateMovementVector(), this._updateRotationVector();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function ut(h) {
|
|
145
|
-
if (this.enabled !== !1)
|
|
146
|
-
if (this.dragToLook)
|
|
147
|
-
this._status++;
|
|
148
|
-
else {
|
|
149
|
-
switch (h.button) {
|
|
150
|
-
case 0:
|
|
151
|
-
this._moveState.forward = 1;
|
|
152
|
-
break;
|
|
153
|
-
case 2:
|
|
154
|
-
this._moveState.back = 1;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
this._updateMovementVector();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function dt(h) {
|
|
161
|
-
if (this.enabled !== !1 && (!this.dragToLook || this._status > 0)) {
|
|
162
|
-
const e = this._getContainerDimensions(), t = e.size[0] / 2, n = e.size[1] / 2;
|
|
163
|
-
this._moveState.yawLeft = -(h.pageX - e.offset[0] - t) / t, this._moveState.pitchDown = (h.pageY - e.offset[1] - n) / n, this._updateRotationVector();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function pt(h) {
|
|
167
|
-
if (this.enabled !== !1) {
|
|
168
|
-
if (this.dragToLook)
|
|
169
|
-
this._status--, this._moveState.yawLeft = this._moveState.pitchDown = 0;
|
|
170
|
-
else {
|
|
171
|
-
switch (h.button) {
|
|
172
|
-
case 0:
|
|
173
|
-
this._moveState.forward = 0;
|
|
174
|
-
break;
|
|
175
|
-
case 2:
|
|
176
|
-
this._moveState.back = 0;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
this._updateMovementVector();
|
|
180
|
-
}
|
|
181
|
-
this._updateRotationVector();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function ft() {
|
|
185
|
-
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());
|
|
186
|
-
}
|
|
187
|
-
function mt(h) {
|
|
188
|
-
this.enabled !== !1 && h.preventDefault();
|
|
189
|
-
}
|
|
190
|
-
const O = new Ne(), m = new l(), I = new l(), p = new x(), _e = {
|
|
191
|
-
X: new l(1, 0, 0),
|
|
192
|
-
Y: new l(0, 1, 0),
|
|
193
|
-
Z: new l(0, 0, 1)
|
|
194
|
-
}, ue = { type: "change" }, xe = { type: "mouseDown", mode: null }, Me = { type: "mouseUp", mode: null }, Se = { type: "objectChange" };
|
|
195
|
-
class vt extends Ee {
|
|
196
|
-
/**
|
|
197
|
-
* Constructs a new controls instance.
|
|
198
|
-
*
|
|
199
|
-
* @param {Camera} camera - The camera of the rendered scene.
|
|
200
|
-
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
201
|
-
*/
|
|
202
|
-
constructor(e, t = null) {
|
|
203
|
-
super(void 0, t);
|
|
204
|
-
const n = new Mt(this);
|
|
205
|
-
this._root = n;
|
|
206
|
-
const s = new St();
|
|
207
|
-
this._gizmo = s, n.add(s);
|
|
208
|
-
const a = new bt();
|
|
209
|
-
this._plane = a, n.add(a);
|
|
210
|
-
const i = this;
|
|
211
|
-
function r(y, Q) {
|
|
212
|
-
let Z = Q;
|
|
213
|
-
Object.defineProperty(i, y, {
|
|
214
|
-
get: function() {
|
|
215
|
-
return Z !== void 0 ? Z : Q;
|
|
216
|
-
},
|
|
217
|
-
set: function(L) {
|
|
218
|
-
Z !== L && (Z = L, a[y] = L, s[y] = L, i.dispatchEvent({ type: y + "-changed", value: L }), i.dispatchEvent(ue));
|
|
219
|
-
}
|
|
220
|
-
}), i[y] = Q, a[y] = Q, s[y] = Q;
|
|
221
|
-
}
|
|
222
|
-
r("camera", e), r("object", void 0), r("enabled", !0), r("axis", null), r("mode", "translate"), r("translationSnap", null), r("rotationSnap", null), r("scaleSnap", null), r("space", "world"), r("size", 1), r("dragging", !1), r("showX", !0), r("showY", !0), r("showZ", !0), r("showXY", !0), r("showYZ", !0), r("showXZ", !0), r("minX", -1 / 0), r("maxX", 1 / 0), r("minY", -1 / 0), r("maxY", 1 / 0), r("minZ", -1 / 0), r("maxZ", 1 / 0);
|
|
223
|
-
const u = new l(), f = new l(), P = new x(), z = new x(), B = new l(), Y = new x(), $ = new l(), T = new l(), E = new l(), S = 0, C = new l();
|
|
224
|
-
r("worldPosition", u), r("worldPositionStart", f), r("worldQuaternion", P), r("worldQuaternionStart", z), r("cameraPosition", B), r("cameraQuaternion", Y), r("pointStart", $), r("pointEnd", T), r("rotationAxis", E), r("rotationAngle", S), r("eye", C), this._offset = new l(), this._startNorm = new l(), this._endNorm = new l(), this._cameraScale = new l(), this._parentPosition = new l(), this._parentQuaternion = new x(), this._parentQuaternionInv = new x(), this._parentScale = new l(), this._worldScaleStart = new l(), this._worldQuaternionInv = new x(), this._worldScale = new l(), this._positionStart = new l(), this._quaternionStart = new x(), this._scaleStart = new l(), this._getPointer = wt.bind(this), this._onPointerDown = yt.bind(this), this._onPointerHover = gt.bind(this), this._onPointerMove = _t.bind(this), this._onPointerUp = xt.bind(this), t !== null && this.connect(t);
|
|
225
|
-
}
|
|
226
|
-
connect(e) {
|
|
227
|
-
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";
|
|
228
|
-
}
|
|
229
|
-
disconnect() {
|
|
230
|
-
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 = "";
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Returns the visual representation of the controls. Add the helper to your scene to
|
|
234
|
-
* visually transform the attached 3D object.
|
|
235
|
-
*
|
|
236
|
-
* @return {TransformControlsRoot} The helper.
|
|
237
|
-
*/
|
|
238
|
-
getHelper() {
|
|
239
|
-
return this._root;
|
|
240
|
-
}
|
|
241
|
-
pointerHover(e) {
|
|
242
|
-
if (this.object === void 0 || this.dragging === !0) return;
|
|
243
|
-
e !== null && O.setFromCamera(e, this.camera);
|
|
244
|
-
const t = de(this._gizmo.picker[this.mode], O);
|
|
245
|
-
t ? this.axis = t.object.name : this.axis = null;
|
|
246
|
-
}
|
|
247
|
-
pointerDown(e) {
|
|
248
|
-
if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
|
|
249
|
-
e !== null && O.setFromCamera(e, this.camera);
|
|
250
|
-
const t = de(this._plane, O, !0);
|
|
251
|
-
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, xe.mode = this.mode, this.dispatchEvent(xe);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
pointerMove(e) {
|
|
255
|
-
const t = this.axis, n = this.mode, s = this.object;
|
|
256
|
-
let a = this.space;
|
|
257
|
-
if (n === "scale" ? a = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (a = "world"), s === void 0 || t === null || this.dragging === !1 || e !== null && e.button !== -1) return;
|
|
258
|
-
e !== null && O.setFromCamera(e, this.camera);
|
|
259
|
-
const i = de(this._plane, O, !0);
|
|
260
|
-
if (i) {
|
|
261
|
-
if (this.pointEnd.copy(i.point).sub(this.worldPositionStart), n === "translate")
|
|
262
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart), a === "local" && t !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), t.indexOf("X") === -1 && (this._offset.x = 0), t.indexOf("Y") === -1 && (this._offset.y = 0), t.indexOf("Z") === -1 && (this._offset.z = 0), a === "local" && t !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), s.position.copy(this._offset).add(this._positionStart), this.translationSnap && (a === "local" && (s.position.applyQuaternion(p.copy(this._quaternionStart).invert()), t.search("X") !== -1 && (s.position.x = Math.round(s.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (s.position.y = Math.round(s.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (s.position.z = Math.round(s.position.z / this.translationSnap) * this.translationSnap), s.position.applyQuaternion(this._quaternionStart)), a === "world" && (s.parent && s.position.add(m.setFromMatrixPosition(s.parent.matrixWorld)), t.search("X") !== -1 && (s.position.x = Math.round(s.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (s.position.y = Math.round(s.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (s.position.z = Math.round(s.position.z / this.translationSnap) * this.translationSnap), s.parent && s.position.sub(m.setFromMatrixPosition(s.parent.matrixWorld)))), s.position.x = Math.max(this.minX, Math.min(this.maxX, s.position.x)), s.position.y = Math.max(this.minY, Math.min(this.maxY, s.position.y)), s.position.z = Math.max(this.minZ, Math.min(this.maxZ, s.position.z));
|
|
263
|
-
else if (n === "scale") {
|
|
264
|
-
if (t.search("XYZ") !== -1) {
|
|
265
|
-
let r = this.pointEnd.length() / this.pointStart.length();
|
|
266
|
-
this.pointEnd.dot(this.pointStart) < 0 && (r *= -1), I.set(r, r, r);
|
|
267
|
-
} else
|
|
268
|
-
m.copy(this.pointStart), I.copy(this.pointEnd), m.applyQuaternion(this._worldQuaternionInv), I.applyQuaternion(this._worldQuaternionInv), I.divide(m), t.search("X") === -1 && (I.x = 1), t.search("Y") === -1 && (I.y = 1), t.search("Z") === -1 && (I.z = 1);
|
|
269
|
-
s.scale.copy(this._scaleStart).multiply(I), this.scaleSnap && (t.search("X") !== -1 && (s.scale.x = Math.round(s.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (s.scale.y = Math.round(s.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (s.scale.z = Math.round(s.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
270
|
-
} else if (n === "rotate") {
|
|
271
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
272
|
-
const r = 20 / this.worldPosition.distanceTo(m.setFromMatrixPosition(this.camera.matrixWorld));
|
|
273
|
-
let u = !1;
|
|
274
|
-
t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(m.copy(this.rotationAxis).cross(this.eye)) * r) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(_e[t]), m.copy(_e[t]), a === "local" && m.applyQuaternion(this.worldQuaternion), m.cross(this.eye), m.length() === 0 ? u = !0 : this.rotationAngle = this._offset.dot(m.normalize()) * r), (t === "E" || u) && (this.rotationAxis.copy(this.eye), this.rotationAngle = this.pointEnd.angleTo(this.pointStart), this._startNorm.copy(this.pointStart).normalize(), this._endNorm.copy(this.pointEnd).normalize(), this.rotationAngle *= this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1), this.rotationSnap && (this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap), a === "local" && t !== "E" && t !== "XYZE" ? (s.quaternion.copy(this._quaternionStart), s.quaternion.multiply(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), s.quaternion.copy(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), s.quaternion.multiply(this._quaternionStart).normalize());
|
|
275
|
-
}
|
|
276
|
-
this.dispatchEvent(ue), this.dispatchEvent(Se);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
pointerUp(e) {
|
|
280
|
-
e !== null && e.button !== 0 || (this.dragging && this.axis !== null && (Me.mode = this.mode, this.dispatchEvent(Me)), this.dragging = !1, this.axis = null);
|
|
281
|
-
}
|
|
282
|
-
dispose() {
|
|
283
|
-
this.disconnect(), this._root.dispose();
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Sets the 3D object that should be transformed and ensures the controls UI is visible.
|
|
287
|
-
*
|
|
288
|
-
* @param {Object3D} object - The 3D object that should be transformed.
|
|
289
|
-
* @return {TransformControls} A reference to this controls.
|
|
290
|
-
*/
|
|
291
|
-
attach(e) {
|
|
292
|
-
return this.object = e, this._root.visible = !0, this;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Removes the current 3D object from the controls and makes the helper UI invisible.
|
|
296
|
-
*
|
|
297
|
-
* @return {TransformControls} A reference to this controls.
|
|
298
|
-
*/
|
|
299
|
-
detach() {
|
|
300
|
-
return this.object = void 0, this.axis = null, this._root.visible = !1, this;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Resets the object's position, rotation and scale to when the current transform began.
|
|
304
|
-
*/
|
|
305
|
-
reset() {
|
|
306
|
-
this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(ue), this.dispatchEvent(Se), this.pointStart.copy(this.pointEnd));
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Returns the raycaster that is used for user interaction. This object is shared between all
|
|
310
|
-
* instances of `TransformControls`.
|
|
311
|
-
*
|
|
312
|
-
* @returns {Raycaster} The internal raycaster.
|
|
313
|
-
*/
|
|
314
|
-
getRaycaster() {
|
|
315
|
-
return O;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Returns the transformation mode.
|
|
319
|
-
*
|
|
320
|
-
* @returns {'translate'|'rotate'|'scale'} The transformation mode.
|
|
321
|
-
*/
|
|
322
|
-
getMode() {
|
|
323
|
-
return this.mode;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Sets the given transformation mode.
|
|
327
|
-
*
|
|
328
|
-
* @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
|
|
329
|
-
*/
|
|
330
|
-
setMode(e) {
|
|
331
|
-
this.mode = e;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Sets the translation snap.
|
|
335
|
-
*
|
|
336
|
-
* @param {?number} translationSnap - The translation snap to set.
|
|
337
|
-
*/
|
|
338
|
-
setTranslationSnap(e) {
|
|
339
|
-
this.translationSnap = e;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Sets the rotation snap.
|
|
343
|
-
*
|
|
344
|
-
* @param {?number} rotationSnap - The rotation snap to set.
|
|
345
|
-
*/
|
|
346
|
-
setRotationSnap(e) {
|
|
347
|
-
this.rotationSnap = e;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Sets the scale snap.
|
|
351
|
-
*
|
|
352
|
-
* @param {?number} scaleSnap - The scale snap to set.
|
|
353
|
-
*/
|
|
354
|
-
setScaleSnap(e) {
|
|
355
|
-
this.scaleSnap = e;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Sets the size of the helper UI.
|
|
359
|
-
*
|
|
360
|
-
* @param {number} size - The size to set.
|
|
361
|
-
*/
|
|
362
|
-
setSize(e) {
|
|
363
|
-
this.size = e;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Sets the coordinate space in which transformations are applied.
|
|
367
|
-
*
|
|
368
|
-
* @param {'world'|'local'} space - The space to set.
|
|
369
|
-
*/
|
|
370
|
-
setSpace(e) {
|
|
371
|
-
this.space = e;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Sets the colors of the control's gizmo.
|
|
375
|
-
*
|
|
376
|
-
* @param {number|Color|string} xAxis - The x-axis color.
|
|
377
|
-
* @param {number|Color|string} yAxis - The y-axis color.
|
|
378
|
-
* @param {number|Color|string} zAxis - The z-axis color.
|
|
379
|
-
* @param {number|Color|string} active - The color for active elements.
|
|
380
|
-
*/
|
|
381
|
-
setColors(e, t, n, s) {
|
|
382
|
-
const a = this._gizmo.materialLib;
|
|
383
|
-
a.xAxis.color.set(e), a.yAxis.color.set(t), a.zAxis.color.set(n), a.active.color.set(s), a.xAxisTransparent.color.set(e), a.yAxisTransparent.color.set(t), a.zAxisTransparent.color.set(n), a.activeTransparent.color.set(s), a.xAxis._color && a.xAxis._color.set(e), a.yAxis._color && a.yAxis._color.set(t), a.zAxis._color && a.zAxis._color.set(n), a.active._color && a.active._color.set(s), a.xAxisTransparent._color && a.xAxisTransparent._color.set(e), a.yAxisTransparent._color && a.yAxisTransparent._color.set(t), a.zAxisTransparent._color && a.zAxisTransparent._color.set(n), a.activeTransparent._color && a.activeTransparent._color.set(s);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
function wt(h) {
|
|
387
|
-
if (this.domElement.ownerDocument.pointerLockElement)
|
|
388
|
-
return {
|
|
389
|
-
x: 0,
|
|
390
|
-
y: 0,
|
|
391
|
-
button: h.button
|
|
392
|
-
};
|
|
393
|
-
{
|
|
394
|
-
const e = this.domElement.getBoundingClientRect();
|
|
395
|
-
return {
|
|
396
|
-
x: (h.clientX - e.left) / e.width * 2 - 1,
|
|
397
|
-
y: -(h.clientY - e.top) / e.height * 2 + 1,
|
|
398
|
-
button: h.button
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
function gt(h) {
|
|
403
|
-
if (this.enabled)
|
|
404
|
-
switch (h.pointerType) {
|
|
405
|
-
case "mouse":
|
|
406
|
-
case "pen":
|
|
407
|
-
this.pointerHover(this._getPointer(h));
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
function yt(h) {
|
|
412
|
-
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(h.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(h)), this.pointerDown(this._getPointer(h)));
|
|
413
|
-
}
|
|
414
|
-
function _t(h) {
|
|
415
|
-
this.enabled && this.pointerMove(this._getPointer(h));
|
|
416
|
-
}
|
|
417
|
-
function xt(h) {
|
|
418
|
-
this.enabled && (this.domElement.releasePointerCapture(h.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(h)));
|
|
419
|
-
}
|
|
420
|
-
function de(h, e, t) {
|
|
421
|
-
const n = e.intersectObject(h, !0);
|
|
422
|
-
for (let s = 0; s < n.length; s++)
|
|
423
|
-
if (n[s].object.visible || t)
|
|
424
|
-
return n[s];
|
|
425
|
-
return !1;
|
|
426
|
-
}
|
|
427
|
-
const ne = new et(), d = new l(0, 1, 0), be = new l(0, 0, 0), Pe = new ce(), ae = new x(), oe = new x(), b = new l(), Te = new ce(), K = new l(1, 0, 0), H = new l(0, 1, 0), N = new l(0, 0, 1), re = new l(), W = new l(), q = new l();
|
|
428
|
-
class Mt extends le {
|
|
429
|
-
constructor(e) {
|
|
430
|
-
super(), this.isTransformControlsRoot = !0, this.controls = e, this.visible = !1;
|
|
431
|
-
}
|
|
432
|
-
// updateMatrixWorld updates key transformation variables
|
|
433
|
-
updateMatrixWorld(e) {
|
|
434
|
-
const t = this.controls;
|
|
435
|
-
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);
|
|
436
|
-
}
|
|
437
|
-
dispose() {
|
|
438
|
-
this.traverse(function(e) {
|
|
439
|
-
e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
class St extends le {
|
|
444
|
-
constructor() {
|
|
445
|
-
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
446
|
-
const e = new me({
|
|
447
|
-
depthTest: !1,
|
|
448
|
-
depthWrite: !1,
|
|
449
|
-
fog: !1,
|
|
450
|
-
toneMapped: !1,
|
|
451
|
-
transparent: !0
|
|
452
|
-
}), t = new $e({
|
|
453
|
-
depthTest: !1,
|
|
454
|
-
depthWrite: !1,
|
|
455
|
-
fog: !1,
|
|
456
|
-
toneMapped: !1,
|
|
457
|
-
transparent: !0
|
|
458
|
-
}), n = e.clone();
|
|
459
|
-
n.opacity = 0.15;
|
|
460
|
-
const s = t.clone();
|
|
461
|
-
s.opacity = 0.5;
|
|
462
|
-
const a = e.clone();
|
|
463
|
-
a.color.setHex(16711680);
|
|
464
|
-
const i = e.clone();
|
|
465
|
-
i.color.setHex(65280);
|
|
466
|
-
const r = e.clone();
|
|
467
|
-
r.color.setHex(255);
|
|
468
|
-
const u = e.clone();
|
|
469
|
-
u.color.setHex(16711680), u.opacity = 0.5;
|
|
470
|
-
const f = e.clone();
|
|
471
|
-
f.color.setHex(65280), f.opacity = 0.5;
|
|
472
|
-
const P = e.clone();
|
|
473
|
-
P.color.setHex(255), P.opacity = 0.5;
|
|
474
|
-
const z = e.clone();
|
|
475
|
-
z.opacity = 0.25;
|
|
476
|
-
const B = e.clone();
|
|
477
|
-
B.color.setHex(16776960), B.opacity = 0.25;
|
|
478
|
-
const Y = e.clone();
|
|
479
|
-
Y.color.setHex(16776960);
|
|
480
|
-
const $ = e.clone();
|
|
481
|
-
$.color.setHex(7895160), this.materialLib = {
|
|
482
|
-
xAxis: a,
|
|
483
|
-
yAxis: i,
|
|
484
|
-
zAxis: r,
|
|
485
|
-
active: Y,
|
|
486
|
-
xAxisTransparent: u,
|
|
487
|
-
yAxisTransparent: f,
|
|
488
|
-
zAxisTransparent: P,
|
|
489
|
-
activeTransparent: B
|
|
490
|
-
};
|
|
491
|
-
const T = new g(0, 0.04, 0.1, 12);
|
|
492
|
-
T.translate(0, 0.05, 0);
|
|
493
|
-
const E = new v(0.08, 0.08, 0.08);
|
|
494
|
-
E.translate(0, 0.04, 0);
|
|
495
|
-
const S = new pe();
|
|
496
|
-
S.setAttribute("position", new he([0, 0, 0, 1, 0, 0], 3));
|
|
497
|
-
const C = new g(75e-4, 75e-4, 0.5, 3);
|
|
498
|
-
C.translate(0, 0.25, 0);
|
|
499
|
-
function y(_, J) {
|
|
500
|
-
const M = new F(_, 75e-4, 3, 64, J * Math.PI * 2);
|
|
501
|
-
return M.rotateY(Math.PI / 2), M.rotateX(Math.PI / 2), M;
|
|
502
|
-
}
|
|
503
|
-
function Q() {
|
|
504
|
-
const _ = new pe();
|
|
505
|
-
return _.setAttribute("position", new he([0, 0, 0, 1, 1, 1], 3)), _;
|
|
506
|
-
}
|
|
507
|
-
const Z = {
|
|
508
|
-
X: [
|
|
509
|
-
[new o(T, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
510
|
-
[new o(T, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
511
|
-
[new o(C, a), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
512
|
-
],
|
|
513
|
-
Y: [
|
|
514
|
-
[new o(T, i), [0, 0.5, 0]],
|
|
515
|
-
[new o(T, i), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
516
|
-
[new o(C, i)]
|
|
517
|
-
],
|
|
518
|
-
Z: [
|
|
519
|
-
[new o(T, r), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
520
|
-
[new o(T, r), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
521
|
-
[new o(C, r), null, [Math.PI / 2, 0, 0]]
|
|
522
|
-
],
|
|
523
|
-
XYZ: [
|
|
524
|
-
[new o(new se(0.1, 0), z), [0, 0, 0]]
|
|
525
|
-
],
|
|
526
|
-
XY: [
|
|
527
|
-
[new o(new v(0.15, 0.15, 0.01), P), [0.15, 0.15, 0]]
|
|
528
|
-
],
|
|
529
|
-
YZ: [
|
|
530
|
-
[new o(new v(0.15, 0.15, 0.01), u), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
531
|
-
],
|
|
532
|
-
XZ: [
|
|
533
|
-
[new o(new v(0.15, 0.15, 0.01), f), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
534
|
-
]
|
|
535
|
-
}, L = {
|
|
536
|
-
X: [
|
|
537
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
538
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
539
|
-
],
|
|
540
|
-
Y: [
|
|
541
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0.3, 0]],
|
|
542
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
543
|
-
],
|
|
544
|
-
Z: [
|
|
545
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
546
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
547
|
-
],
|
|
548
|
-
XYZ: [
|
|
549
|
-
[new o(new se(0.2, 0), n)]
|
|
550
|
-
],
|
|
551
|
-
XY: [
|
|
552
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0.15, 0.15, 0]]
|
|
553
|
-
],
|
|
554
|
-
YZ: [
|
|
555
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
556
|
-
],
|
|
557
|
-
XZ: [
|
|
558
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
559
|
-
]
|
|
560
|
-
}, ke = {
|
|
561
|
-
START: [
|
|
562
|
-
[new o(new se(0.01, 2), s), null, null, null, "helper"]
|
|
563
|
-
],
|
|
564
|
-
END: [
|
|
565
|
-
[new o(new se(0.01, 2), s), null, null, null, "helper"]
|
|
566
|
-
],
|
|
567
|
-
DELTA: [
|
|
568
|
-
[new A(Q(), s), null, null, null, "helper"]
|
|
569
|
-
],
|
|
570
|
-
X: [
|
|
571
|
-
[new A(S, s), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
572
|
-
],
|
|
573
|
-
Y: [
|
|
574
|
-
[new A(S, s), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
575
|
-
],
|
|
576
|
-
Z: [
|
|
577
|
-
[new A(S, s), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
578
|
-
]
|
|
579
|
-
}, De = {
|
|
580
|
-
XYZE: [
|
|
581
|
-
[new o(y(0.5, 1), $), null, [0, Math.PI / 2, 0]]
|
|
582
|
-
],
|
|
583
|
-
X: [
|
|
584
|
-
[new o(y(0.5, 0.5), a)]
|
|
585
|
-
],
|
|
586
|
-
Y: [
|
|
587
|
-
[new o(y(0.5, 0.5), i), null, [0, 0, -Math.PI / 2]]
|
|
588
|
-
],
|
|
589
|
-
Z: [
|
|
590
|
-
[new o(y(0.5, 0.5), r), null, [0, Math.PI / 2, 0]]
|
|
591
|
-
],
|
|
592
|
-
E: [
|
|
593
|
-
[new o(y(0.75, 1), B), null, [0, Math.PI / 2, 0]]
|
|
594
|
-
]
|
|
595
|
-
}, Be = {
|
|
596
|
-
AXIS: [
|
|
597
|
-
[new A(S, s), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
598
|
-
]
|
|
599
|
-
}, Ae = {
|
|
600
|
-
XYZE: [
|
|
601
|
-
[new o(new Je(0.25, 10, 8), n)]
|
|
602
|
-
],
|
|
603
|
-
X: [
|
|
604
|
-
[new o(new F(0.5, 0.1, 4, 24), n), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
605
|
-
],
|
|
606
|
-
Y: [
|
|
607
|
-
[new o(new F(0.5, 0.1, 4, 24), n), [0, 0, 0], [Math.PI / 2, 0, 0]]
|
|
608
|
-
],
|
|
609
|
-
Z: [
|
|
610
|
-
[new o(new F(0.5, 0.1, 4, 24), n), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
611
|
-
],
|
|
612
|
-
E: [
|
|
613
|
-
[new o(new F(0.75, 0.1, 2, 24), n)]
|
|
614
|
-
]
|
|
615
|
-
}, Ie = {
|
|
616
|
-
X: [
|
|
617
|
-
[new o(E, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
618
|
-
[new o(C, a), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
619
|
-
[new o(E, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
|
|
620
|
-
],
|
|
621
|
-
Y: [
|
|
622
|
-
[new o(E, i), [0, 0.5, 0]],
|
|
623
|
-
[new o(C, i)],
|
|
624
|
-
[new o(E, i), [0, -0.5, 0], [0, 0, Math.PI]]
|
|
625
|
-
],
|
|
626
|
-
Z: [
|
|
627
|
-
[new o(E, r), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
628
|
-
[new o(C, r), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
629
|
-
[new o(E, r), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
630
|
-
],
|
|
631
|
-
XY: [
|
|
632
|
-
[new o(new v(0.15, 0.15, 0.01), P), [0.15, 0.15, 0]]
|
|
633
|
-
],
|
|
634
|
-
YZ: [
|
|
635
|
-
[new o(new v(0.15, 0.15, 0.01), u), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
636
|
-
],
|
|
637
|
-
XZ: [
|
|
638
|
-
[new o(new v(0.15, 0.15, 0.01), f), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
639
|
-
],
|
|
640
|
-
XYZ: [
|
|
641
|
-
[new o(new v(0.1, 0.1, 0.1), z)]
|
|
642
|
-
]
|
|
643
|
-
}, Re = {
|
|
644
|
-
X: [
|
|
645
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
646
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
647
|
-
],
|
|
648
|
-
Y: [
|
|
649
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0.3, 0]],
|
|
650
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
651
|
-
],
|
|
652
|
-
Z: [
|
|
653
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
654
|
-
[new o(new g(0.2, 0, 0.6, 4), n), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
655
|
-
],
|
|
656
|
-
XY: [
|
|
657
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0.15, 0.15, 0]]
|
|
658
|
-
],
|
|
659
|
-
YZ: [
|
|
660
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
661
|
-
],
|
|
662
|
-
XZ: [
|
|
663
|
-
[new o(new v(0.2, 0.2, 0.01), n), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
664
|
-
],
|
|
665
|
-
XYZ: [
|
|
666
|
-
[new o(new v(0.2, 0.2, 0.2), n), [0, 0, 0]]
|
|
667
|
-
]
|
|
668
|
-
}, ze = {
|
|
669
|
-
X: [
|
|
670
|
-
[new A(S, s), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
671
|
-
],
|
|
672
|
-
Y: [
|
|
673
|
-
[new A(S, s), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
674
|
-
],
|
|
675
|
-
Z: [
|
|
676
|
-
[new A(S, s), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
677
|
-
]
|
|
678
|
-
};
|
|
679
|
-
function k(_) {
|
|
680
|
-
const J = new le();
|
|
681
|
-
for (const M in _)
|
|
682
|
-
for (let U = _[M].length; U--; ) {
|
|
683
|
-
const w = _[M][U][0].clone(), ee = _[M][U][1], te = _[M][U][2], ie = _[M][U][3], Qe = _[M][U][4];
|
|
684
|
-
w.name = M, w.tag = Qe, ee && w.position.set(ee[0], ee[1], ee[2]), te && w.rotation.set(te[0], te[1], te[2]), ie && w.scale.set(ie[0], ie[1], ie[2]), w.updateMatrix();
|
|
685
|
-
const ve = w.geometry.clone();
|
|
686
|
-
ve.applyMatrix4(w.matrix), w.geometry = ve, w.renderOrder = 1 / 0, w.position.set(0, 0, 0), w.rotation.set(0, 0, 0), w.scale.set(1, 1, 1), J.add(w);
|
|
687
|
-
}
|
|
688
|
-
return J;
|
|
689
|
-
}
|
|
690
|
-
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = k(Z)), this.add(this.gizmo.rotate = k(De)), this.add(this.gizmo.scale = k(Ie)), this.add(this.picker.translate = k(L)), this.add(this.picker.rotate = k(Ae)), this.add(this.picker.scale = k(Re)), this.add(this.helper.translate = k(ke)), this.add(this.helper.rotate = k(Be)), this.add(this.helper.scale = k(ze)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
691
|
-
}
|
|
692
|
-
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
693
|
-
updateMatrixWorld(e) {
|
|
694
|
-
const n = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : oe;
|
|
695
|
-
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";
|
|
696
|
-
let s = [];
|
|
697
|
-
s = s.concat(this.picker[this.mode].children), s = s.concat(this.gizmo[this.mode].children), s = s.concat(this.helper[this.mode].children);
|
|
698
|
-
for (let a = 0; a < s.length; a++) {
|
|
699
|
-
const i = s[a];
|
|
700
|
-
i.visible = !0, i.rotation.set(0, 0, 0), i.position.copy(this.worldPosition);
|
|
701
|
-
let r;
|
|
702
|
-
if (this.camera.isOrthographicCamera ? r = (this.camera.top - this.camera.bottom) / this.camera.zoom : r = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), i.scale.set(1, 1, 1).multiplyScalar(r * this.size / 4), i.tag === "helper") {
|
|
703
|
-
i.visible = !1, i.name === "AXIS" ? (i.visible = !!this.axis, this.axis === "X" && (p.setFromEuler(ne.set(0, 0, 0)), i.quaternion.copy(n).multiply(p), Math.abs(d.copy(K).applyQuaternion(n).dot(this.eye)) > 0.9 && (i.visible = !1)), this.axis === "Y" && (p.setFromEuler(ne.set(0, 0, Math.PI / 2)), i.quaternion.copy(n).multiply(p), Math.abs(d.copy(H).applyQuaternion(n).dot(this.eye)) > 0.9 && (i.visible = !1)), this.axis === "Z" && (p.setFromEuler(ne.set(0, Math.PI / 2, 0)), i.quaternion.copy(n).multiply(p), Math.abs(d.copy(N).applyQuaternion(n).dot(this.eye)) > 0.9 && (i.visible = !1)), this.axis === "XYZE" && (p.setFromEuler(ne.set(0, Math.PI / 2, 0)), d.copy(this.rotationAxis), i.quaternion.setFromRotationMatrix(Pe.lookAt(be, d, H)), i.quaternion.multiply(p), i.visible = this.dragging), this.axis === "E" && (i.visible = !1)) : i.name === "START" ? (i.position.copy(this.worldPositionStart), i.visible = this.dragging) : i.name === "END" ? (i.position.copy(this.worldPosition), i.visible = this.dragging) : i.name === "DELTA" ? (i.position.copy(this.worldPositionStart), i.quaternion.copy(this.worldQuaternionStart), m.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), m.applyQuaternion(this.worldQuaternionStart.clone().invert()), i.scale.copy(m), i.visible = this.dragging) : (i.quaternion.copy(n), this.dragging ? i.position.copy(this.worldPositionStart) : i.position.copy(this.worldPosition), this.axis && (i.visible = this.axis.search(i.name) !== -1));
|
|
704
|
-
continue;
|
|
705
|
-
}
|
|
706
|
-
i.quaternion.copy(n), this.mode === "translate" || this.mode === "scale" ? (i.name === "X" && Math.abs(d.copy(K).applyQuaternion(n).dot(this.eye)) > 0.99 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1), i.name === "Y" && Math.abs(d.copy(H).applyQuaternion(n).dot(this.eye)) > 0.99 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1), i.name === "Z" && Math.abs(d.copy(N).applyQuaternion(n).dot(this.eye)) > 0.99 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1), i.name === "XY" && Math.abs(d.copy(N).applyQuaternion(n).dot(this.eye)) < 0.2 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1), i.name === "YZ" && Math.abs(d.copy(K).applyQuaternion(n).dot(this.eye)) < 0.2 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1), i.name === "XZ" && Math.abs(d.copy(H).applyQuaternion(n).dot(this.eye)) < 0.2 && (i.scale.set(1e-10, 1e-10, 1e-10), i.visible = !1)) : this.mode === "rotate" && (ae.copy(n), d.copy(this.eye).applyQuaternion(p.copy(n).invert()), i.name.search("E") !== -1 && i.quaternion.setFromRotationMatrix(Pe.lookAt(this.eye, be, H)), i.name === "X" && (p.setFromAxisAngle(K, Math.atan2(-d.y, d.z)), p.multiplyQuaternions(ae, p), i.quaternion.copy(p)), i.name === "Y" && (p.setFromAxisAngle(H, Math.atan2(d.x, d.z)), p.multiplyQuaternions(ae, p), i.quaternion.copy(p)), i.name === "Z" && (p.setFromAxisAngle(N, Math.atan2(d.y, d.x)), p.multiplyQuaternions(ae, p), i.quaternion.copy(p))), i.visible = i.visible && (i.name.indexOf("X") === -1 || this.showX), i.visible = i.visible && (i.name.indexOf("Y") === -1 || this.showY), i.visible = i.visible && (i.name.indexOf("Z") === -1 || this.showZ), i.visible = i.visible && (i.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), i.visible = i.visible && (i.name.indexOf("XY") === -1 || this.showXY), i.visible = i.visible && (i.name.indexOf("YZ") === -1 || this.showYZ), i.visible = i.visible && (i.name.indexOf("XZ") === -1 || this.showXZ), i.material._color = i.material._color || i.material.color.clone(), i.material._opacity = i.material._opacity || i.material.opacity, i.material.color.copy(i.material._color), i.material.opacity = i.material._opacity, this.enabled && this.axis && (i.name === this.axis ? (i.material.color.copy(this.materialLib.active.color), i.material.opacity = 1) : this.axis.split("").some(function(u) {
|
|
707
|
-
return i.name === u;
|
|
708
|
-
}) && (i.material.color.copy(this.materialLib.active.color), i.material.opacity = 1));
|
|
709
|
-
}
|
|
710
|
-
super.updateMatrixWorld(e);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
class bt extends o {
|
|
714
|
-
constructor() {
|
|
715
|
-
super(
|
|
716
|
-
new tt(1e5, 1e5, 2, 2),
|
|
717
|
-
new me({ visible: !1, wireframe: !0, side: fe, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
718
|
-
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
719
|
-
}
|
|
720
|
-
updateMatrixWorld(e) {
|
|
721
|
-
let t = this.space;
|
|
722
|
-
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), re.copy(K).applyQuaternion(t === "local" ? this.worldQuaternion : oe), W.copy(H).applyQuaternion(t === "local" ? this.worldQuaternion : oe), q.copy(N).applyQuaternion(t === "local" ? this.worldQuaternion : oe), d.copy(W), this.mode) {
|
|
723
|
-
case "translate":
|
|
724
|
-
case "scale":
|
|
725
|
-
switch (this.axis) {
|
|
726
|
-
case "X":
|
|
727
|
-
d.copy(this.eye).cross(re), b.copy(re).cross(d);
|
|
728
|
-
break;
|
|
729
|
-
case "Y":
|
|
730
|
-
d.copy(this.eye).cross(W), b.copy(W).cross(d);
|
|
731
|
-
break;
|
|
732
|
-
case "Z":
|
|
733
|
-
d.copy(this.eye).cross(q), b.copy(q).cross(d);
|
|
734
|
-
break;
|
|
735
|
-
case "XY":
|
|
736
|
-
b.copy(q);
|
|
737
|
-
break;
|
|
738
|
-
case "YZ":
|
|
739
|
-
b.copy(re);
|
|
740
|
-
break;
|
|
741
|
-
case "XZ":
|
|
742
|
-
d.copy(q), b.copy(W);
|
|
743
|
-
break;
|
|
744
|
-
case "XYZ":
|
|
745
|
-
case "E":
|
|
746
|
-
b.set(0, 0, 0);
|
|
747
|
-
break;
|
|
748
|
-
}
|
|
749
|
-
break;
|
|
750
|
-
case "rotate":
|
|
751
|
-
default:
|
|
752
|
-
b.set(0, 0, 0);
|
|
753
|
-
}
|
|
754
|
-
b.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (Te.lookAt(m.set(0, 0, 0), b, d), this.quaternion.setFromRotationMatrix(Te)), super.updateMatrixWorld(e);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
class Pt {
|
|
758
|
-
/**
|
|
759
|
-
* Constructs a new pass.
|
|
760
|
-
*/
|
|
761
|
-
constructor() {
|
|
762
|
-
this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Sets the size of the pass.
|
|
766
|
-
*
|
|
767
|
-
* @abstract
|
|
768
|
-
* @param {number} width - The width to set.
|
|
769
|
-
* @param {number} height - The height to set.
|
|
770
|
-
*/
|
|
771
|
-
setSize() {
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* This method holds the render logic of a pass. It must be implemented in all derived classes.
|
|
775
|
-
*
|
|
776
|
-
* @abstract
|
|
777
|
-
* @param {WebGLRenderer} renderer - The renderer.
|
|
778
|
-
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
779
|
-
* destination for the pass.
|
|
780
|
-
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
781
|
-
* previous pass from this buffer.
|
|
782
|
-
* @param {number} deltaTime - The delta time in seconds.
|
|
783
|
-
* @param {boolean} maskActive - Whether masking is active or not.
|
|
784
|
-
*/
|
|
785
|
-
render() {
|
|
786
|
-
console.error("THREE.Pass: .render() must be implemented in derived pass.");
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Frees the GPU-related resources allocated by this instance. Call this
|
|
790
|
-
* method whenever the pass is no longer used in your app.
|
|
791
|
-
*
|
|
792
|
-
* @abstract
|
|
793
|
-
*/
|
|
794
|
-
dispose() {
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
const Tt = new it(-1, 1, 1, -1, 0, 1);
|
|
798
|
-
class Et extends pe {
|
|
799
|
-
constructor() {
|
|
800
|
-
super(), this.setAttribute("position", new he([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new he([0, 2, 0, 0, 2, 0], 2));
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
const Ct = new Et();
|
|
804
|
-
class kt {
|
|
805
|
-
/**
|
|
806
|
-
* Constructs a new full screen quad.
|
|
807
|
-
*
|
|
808
|
-
* @param {?Material} material - The material to render te full screen quad with.
|
|
809
|
-
*/
|
|
810
|
-
constructor(e) {
|
|
811
|
-
this._mesh = new o(Ct, e);
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Frees the GPU-related resources allocated by this instance. Call this
|
|
815
|
-
* method whenever the instance is no longer used in your app.
|
|
816
|
-
*/
|
|
817
|
-
dispose() {
|
|
818
|
-
this._mesh.geometry.dispose();
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Renders the full screen quad.
|
|
822
|
-
*
|
|
823
|
-
* @param {WebGLRenderer} renderer - The renderer.
|
|
824
|
-
*/
|
|
825
|
-
render(e) {
|
|
826
|
-
e.render(this._mesh, Tt);
|
|
827
|
-
}
|
|
828
|
-
/**
|
|
829
|
-
* The quad's material.
|
|
830
|
-
*
|
|
831
|
-
* @type {?Material}
|
|
832
|
-
*/
|
|
833
|
-
get material() {
|
|
834
|
-
return this._mesh.material;
|
|
835
|
-
}
|
|
836
|
-
set material(e) {
|
|
837
|
-
this._mesh.material = e;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
const Dt = {
|
|
841
|
-
uniforms: {
|
|
842
|
-
tDiffuse: { value: null },
|
|
843
|
-
opacity: { value: 1 }
|
|
844
|
-
},
|
|
845
|
-
vertexShader: (
|
|
846
|
-
/* glsl */
|
|
847
|
-
`
|
|
848
|
-
|
|
849
|
-
varying vec2 vUv;
|
|
850
|
-
|
|
851
|
-
void main() {
|
|
852
|
-
|
|
853
|
-
vUv = uv;
|
|
854
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
855
|
-
|
|
856
|
-
}`
|
|
857
|
-
),
|
|
858
|
-
fragmentShader: (
|
|
859
|
-
/* glsl */
|
|
860
|
-
`
|
|
861
|
-
|
|
862
|
-
uniform float opacity;
|
|
863
|
-
|
|
864
|
-
uniform sampler2D tDiffuse;
|
|
865
|
-
|
|
866
|
-
varying vec2 vUv;
|
|
867
|
-
|
|
868
|
-
void main() {
|
|
869
|
-
|
|
870
|
-
vec4 texel = texture2D( tDiffuse, vUv );
|
|
871
|
-
gl_FragColor = opacity * texel;
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}`
|
|
875
|
-
)
|
|
876
|
-
};
|
|
877
|
-
class R extends Pt {
|
|
878
|
-
/**
|
|
879
|
-
* Constructs a new outline pass.
|
|
880
|
-
*
|
|
881
|
-
* @param {Vector2} [resolution] - The effect's resolution.
|
|
882
|
-
* @param {Scene} scene - The scene to render.
|
|
883
|
-
* @param {Camera} camera - The camera.
|
|
884
|
-
* @param {Array<Object3D>} [selectedObjects] - The selected 3D objects that should receive an outline.
|
|
885
|
-
*
|
|
886
|
-
*/
|
|
887
|
-
constructor(e, t, n, s) {
|
|
888
|
-
super(), this.renderScene = t, this.renderCamera = n, this.selectedObjects = s !== void 0 ? s : [], this.visibleEdgeColor = new V(1, 1, 1), this.hiddenEdgeColor = new V(0.1, 0.04, 0.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 D(e.x, e.y) : new D(256, 256);
|
|
889
|
-
const a = Math.round(this.resolution.x / this.downSampleRatio), i = Math.round(this.resolution.y / this.downSampleRatio);
|
|
890
|
-
this.renderTargetMaskBuffer = new X(this.resolution.x, this.resolution.y), this.renderTargetMaskBuffer.texture.name = "OutlinePass.mask", this.renderTargetMaskBuffer.texture.generateMipmaps = !1, this.depthMaterial = new st(), this.depthMaterial.side = fe, this.depthMaterial.depthPacking = nt, this.depthMaterial.blending = we, this.prepareMaskMaterial = this._getPrepareMaskMaterial(), this.prepareMaskMaterial.side = fe, this.prepareMaskMaterial.fragmentShader = P(this.prepareMaskMaterial.fragmentShader, this.renderCamera), this.renderTargetDepthBuffer = new X(this.resolution.x, this.resolution.y, { type: j }), this.renderTargetDepthBuffer.texture.name = "OutlinePass.depth", this.renderTargetDepthBuffer.texture.generateMipmaps = !1, this.renderTargetMaskDownSampleBuffer = new X(a, i, { type: j }), this.renderTargetMaskDownSampleBuffer.texture.name = "OutlinePass.depthDownSample", this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = !1, this.renderTargetBlurBuffer1 = new X(a, i, { type: j }), this.renderTargetBlurBuffer1.texture.name = "OutlinePass.blur1", this.renderTargetBlurBuffer1.texture.generateMipmaps = !1, this.renderTargetBlurBuffer2 = new X(Math.round(a / 2), Math.round(i / 2), { type: j }), this.renderTargetBlurBuffer2.texture.name = "OutlinePass.blur2", this.renderTargetBlurBuffer2.texture.generateMipmaps = !1, this.edgeDetectionMaterial = this._getEdgeDetectionMaterial(), this.renderTargetEdgeBuffer1 = new X(a, i, { type: j }), this.renderTargetEdgeBuffer1.texture.name = "OutlinePass.edge1", this.renderTargetEdgeBuffer1.texture.generateMipmaps = !1, this.renderTargetEdgeBuffer2 = new X(Math.round(a / 2), Math.round(i / 2), { type: j }), this.renderTargetEdgeBuffer2.texture.name = "OutlinePass.edge2", this.renderTargetEdgeBuffer2.texture.generateMipmaps = !1;
|
|
891
|
-
const r = 4, u = 4;
|
|
892
|
-
this.separableBlurMaterial1 = this._getSeparableBlurMaterial(r), this.separableBlurMaterial1.uniforms.texSize.value.set(a, i), this.separableBlurMaterial1.uniforms.kernelRadius.value = 1, this.separableBlurMaterial2 = this._getSeparableBlurMaterial(u), this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(a / 2), Math.round(i / 2)), this.separableBlurMaterial2.uniforms.kernelRadius.value = u, this.overlayMaterial = this._getOverlayMaterial();
|
|
893
|
-
const f = Dt;
|
|
894
|
-
this.copyUniforms = at.clone(f.uniforms), this.materialCopy = new G({
|
|
895
|
-
uniforms: this.copyUniforms,
|
|
896
|
-
vertexShader: f.vertexShader,
|
|
897
|
-
fragmentShader: f.fragmentShader,
|
|
898
|
-
blending: we,
|
|
899
|
-
depthTest: !1,
|
|
900
|
-
depthWrite: !1
|
|
901
|
-
}), this.enabled = !0, this.needsSwap = !1, this._oldClearColor = new V(), this.oldClearAlpha = 1, this._fsQuad = new kt(null), this.tempPulseColor1 = new V(), this.tempPulseColor2 = new V(), this.textureMatrix = new ce();
|
|
902
|
-
function P(z, B) {
|
|
903
|
-
const Y = B.isPerspectiveCamera ? "perspective" : "orthographic";
|
|
904
|
-
return z.replace(/DEPTH_TO_VIEW_Z/g, Y + "DepthToViewZ");
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Frees the GPU-related resources allocated by this instance. Call this
|
|
909
|
-
* method whenever the pass is no longer used in your app.
|
|
910
|
-
*/
|
|
911
|
-
dispose() {
|
|
912
|
-
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();
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Sets the size of the pass.
|
|
916
|
-
*
|
|
917
|
-
* @param {number} width - The width to set.
|
|
918
|
-
* @param {number} height - The height to set.
|
|
919
|
-
*/
|
|
920
|
-
setSize(e, t) {
|
|
921
|
-
this.renderTargetMaskBuffer.setSize(e, t), this.renderTargetDepthBuffer.setSize(e, t);
|
|
922
|
-
let n = Math.round(e / this.downSampleRatio), s = Math.round(t / this.downSampleRatio);
|
|
923
|
-
this.renderTargetMaskDownSampleBuffer.setSize(n, s), this.renderTargetBlurBuffer1.setSize(n, s), this.renderTargetEdgeBuffer1.setSize(n, s), this.separableBlurMaterial1.uniforms.texSize.value.set(n, s), n = Math.round(n / 2), s = Math.round(s / 2), this.renderTargetBlurBuffer2.setSize(n, s), this.renderTargetEdgeBuffer2.setSize(n, s), this.separableBlurMaterial2.uniforms.texSize.value.set(n, s);
|
|
924
|
-
}
|
|
925
|
-
/**
|
|
926
|
-
* Performs the Outline pass.
|
|
927
|
-
*
|
|
928
|
-
* @param {WebGLRenderer} renderer - The renderer.
|
|
929
|
-
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
930
|
-
* destination for the pass.
|
|
931
|
-
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
932
|
-
* previous pass from this buffer.
|
|
933
|
-
* @param {number} deltaTime - The delta time in seconds.
|
|
934
|
-
* @param {boolean} maskActive - Whether masking is active or not.
|
|
935
|
-
*/
|
|
936
|
-
render(e, t, n, s, a) {
|
|
937
|
-
if (this.selectedObjects.length > 0) {
|
|
938
|
-
e.getClearColor(this._oldClearColor), this.oldClearAlpha = e.getClearAlpha();
|
|
939
|
-
const i = e.autoClear;
|
|
940
|
-
e.autoClear = !1, a && e.state.buffers.stencil.setTest(!1), e.setClearColor(16777215, 1), this._updateSelectionCache(), this._changeVisibilityOfSelectedObjects(!1);
|
|
941
|
-
const r = this.renderScene.background, u = this.renderScene.overrideMaterial;
|
|
942
|
-
if (this.renderScene.background = null, this.renderScene.overrideMaterial = this.depthMaterial, e.setRenderTarget(this.renderTargetDepthBuffer), e.clear(), e.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, e.setRenderTarget(this.renderTargetMaskBuffer), e.clear(), e.render(this.renderScene, this.renderCamera), this._changeVisibilityOfNonSelectedObjects(!0), this._visibilityCache.clear(), this._selectionCache.clear(), this.renderScene.background = r, this.renderScene.overrideMaterial = u, this._fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = this.renderTargetMaskBuffer.texture, e.setRenderTarget(this.renderTargetMaskDownSampleBuffer), e.clear(), this._fsQuad.render(e), this.tempPulseColor1.copy(this.visibleEdgeColor), this.tempPulseColor2.copy(this.hiddenEdgeColor), this.pulsePeriod > 0) {
|
|
943
|
-
const f = 0.625 + Math.cos(performance.now() * 0.01 / this.pulsePeriod) * 0.75 / 2;
|
|
944
|
-
this.tempPulseColor1.multiplyScalar(f), this.tempPulseColor2.multiplyScalar(f);
|
|
945
|
-
}
|
|
946
|
-
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, e.setRenderTarget(this.renderTargetEdgeBuffer1), e.clear(), this._fsQuad.render(e), this._fsQuad.material = this.separableBlurMaterial1, this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = R.BlurDirectionX, this.separableBlurMaterial1.uniforms.kernelRadius.value = this.edgeThickness, e.setRenderTarget(this.renderTargetBlurBuffer1), e.clear(), this._fsQuad.render(e), this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetBlurBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = R.BlurDirectionY, e.setRenderTarget(this.renderTargetEdgeBuffer1), e.clear(), this._fsQuad.render(e), this._fsQuad.material = this.separableBlurMaterial2, this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial2.uniforms.direction.value = R.BlurDirectionX, e.setRenderTarget(this.renderTargetBlurBuffer2), e.clear(), this._fsQuad.render(e), this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetBlurBuffer2.texture, this.separableBlurMaterial2.uniforms.direction.value = R.BlurDirectionY, e.setRenderTarget(this.renderTargetEdgeBuffer2), e.clear(), this._fsQuad.render(e), 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 && e.state.buffers.stencil.setTest(!0), e.setRenderTarget(n), this._fsQuad.render(e), e.setClearColor(this._oldClearColor, this.oldClearAlpha), e.autoClear = i;
|
|
947
|
-
}
|
|
948
|
-
this.renderToScreen && (this._fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = n.texture, e.setRenderTarget(null), this._fsQuad.render(e));
|
|
949
|
-
}
|
|
950
|
-
// internals
|
|
951
|
-
_updateSelectionCache() {
|
|
952
|
-
const e = this._selectionCache;
|
|
953
|
-
function t(n) {
|
|
954
|
-
n.isMesh && e.add(n);
|
|
955
|
-
}
|
|
956
|
-
e.clear();
|
|
957
|
-
for (let n = 0; n < this.selectedObjects.length; n++)
|
|
958
|
-
this.selectedObjects[n].traverse(t);
|
|
959
|
-
}
|
|
960
|
-
_changeVisibilityOfSelectedObjects(e) {
|
|
961
|
-
const t = this._visibilityCache;
|
|
962
|
-
for (const n of this._selectionCache)
|
|
963
|
-
e === !0 ? n.visible = t.get(n) : (t.set(n, n.visible), n.visible = e);
|
|
964
|
-
}
|
|
965
|
-
_changeVisibilityOfNonSelectedObjects(e) {
|
|
966
|
-
const t = this._visibilityCache, n = this._selectionCache;
|
|
967
|
-
function s(a) {
|
|
968
|
-
if (a.isPoints || a.isLine || a.isLine2)
|
|
969
|
-
e === !0 ? a.visible = t.get(a) : (t.set(a, a.visible), a.visible = e);
|
|
970
|
-
else if ((a.isMesh || a.isSprite) && !n.has(a)) {
|
|
971
|
-
const i = a.visible;
|
|
972
|
-
(e === !1 || t.get(a) === !0) && (a.visible = e), t.set(a, i);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
this.renderScene.traverse(s);
|
|
976
|
-
}
|
|
977
|
-
_updateTextureMatrix() {
|
|
978
|
-
this.textureMatrix.set(
|
|
979
|
-
0.5,
|
|
980
|
-
0,
|
|
981
|
-
0,
|
|
982
|
-
0.5,
|
|
983
|
-
0,
|
|
984
|
-
0.5,
|
|
985
|
-
0,
|
|
986
|
-
0.5,
|
|
987
|
-
0,
|
|
988
|
-
0,
|
|
989
|
-
0.5,
|
|
990
|
-
0.5,
|
|
991
|
-
0,
|
|
992
|
-
0,
|
|
993
|
-
0,
|
|
994
|
-
1
|
|
995
|
-
), this.textureMatrix.multiply(this.renderCamera.projectionMatrix), this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse);
|
|
996
|
-
}
|
|
997
|
-
_getPrepareMaskMaterial() {
|
|
998
|
-
return new G({
|
|
999
|
-
uniforms: {
|
|
1000
|
-
depthTexture: { value: null },
|
|
1001
|
-
cameraNearFar: { value: new D(0.5, 0.5) },
|
|
1002
|
-
textureMatrix: { value: null }
|
|
1003
|
-
},
|
|
1004
|
-
vertexShader: `#include <batching_pars_vertex>
|
|
1005
|
-
#include <morphtarget_pars_vertex>
|
|
1006
|
-
#include <skinning_pars_vertex>
|
|
1007
|
-
|
|
1008
|
-
varying vec4 projTexCoord;
|
|
1009
|
-
varying vec4 vPosition;
|
|
1010
|
-
uniform mat4 textureMatrix;
|
|
1011
|
-
|
|
1012
|
-
void main() {
|
|
1013
|
-
|
|
1014
|
-
#include <batching_vertex>
|
|
1015
|
-
#include <skinbase_vertex>
|
|
1016
|
-
#include <begin_vertex>
|
|
1017
|
-
#include <morphtarget_vertex>
|
|
1018
|
-
#include <skinning_vertex>
|
|
1019
|
-
#include <project_vertex>
|
|
1020
|
-
|
|
1021
|
-
vPosition = mvPosition;
|
|
1022
|
-
|
|
1023
|
-
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
1024
|
-
|
|
1025
|
-
#ifdef USE_INSTANCING
|
|
1026
|
-
|
|
1027
|
-
worldPosition = instanceMatrix * worldPosition;
|
|
1028
|
-
|
|
1029
|
-
#endif
|
|
1030
|
-
|
|
1031
|
-
worldPosition = modelMatrix * worldPosition;
|
|
1032
|
-
|
|
1033
|
-
projTexCoord = textureMatrix * worldPosition;
|
|
1034
|
-
|
|
1035
|
-
}`,
|
|
1036
|
-
fragmentShader: `#include <packing>
|
|
1037
|
-
varying vec4 vPosition;
|
|
1038
|
-
varying vec4 projTexCoord;
|
|
1039
|
-
uniform sampler2D depthTexture;
|
|
1040
|
-
uniform vec2 cameraNearFar;
|
|
1041
|
-
|
|
1042
|
-
void main() {
|
|
1043
|
-
|
|
1044
|
-
float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
|
|
1045
|
-
float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
|
|
1046
|
-
float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
|
|
1047
|
-
gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
|
|
1048
|
-
|
|
1049
|
-
}`
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
_getEdgeDetectionMaterial() {
|
|
1053
|
-
return new G({
|
|
1054
|
-
uniforms: {
|
|
1055
|
-
maskTexture: { value: null },
|
|
1056
|
-
texSize: { value: new D(0.5, 0.5) },
|
|
1057
|
-
visibleEdgeColor: { value: new l(1, 1, 1) },
|
|
1058
|
-
hiddenEdgeColor: { value: new l(1, 1, 1) }
|
|
1059
|
-
},
|
|
1060
|
-
vertexShader: `varying vec2 vUv;
|
|
1061
|
-
|
|
1062
|
-
void main() {
|
|
1063
|
-
vUv = uv;
|
|
1064
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1065
|
-
}`,
|
|
1066
|
-
fragmentShader: `varying vec2 vUv;
|
|
1067
|
-
|
|
1068
|
-
uniform sampler2D maskTexture;
|
|
1069
|
-
uniform vec2 texSize;
|
|
1070
|
-
uniform vec3 visibleEdgeColor;
|
|
1071
|
-
uniform vec3 hiddenEdgeColor;
|
|
1072
|
-
|
|
1073
|
-
void main() {
|
|
1074
|
-
vec2 invSize = 1.0 / texSize;
|
|
1075
|
-
vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
|
|
1076
|
-
vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
|
|
1077
|
-
vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
|
|
1078
|
-
vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
|
|
1079
|
-
vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
|
|
1080
|
-
float diff1 = (c1.r - c2.r)*0.5;
|
|
1081
|
-
float diff2 = (c3.r - c4.r)*0.5;
|
|
1082
|
-
float d = length( vec2(diff1, diff2) );
|
|
1083
|
-
float a1 = min(c1.g, c2.g);
|
|
1084
|
-
float a2 = min(c3.g, c4.g);
|
|
1085
|
-
float visibilityFactor = min(a1, a2);
|
|
1086
|
-
vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
|
|
1087
|
-
gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
|
|
1088
|
-
}`
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
_getSeparableBlurMaterial(e) {
|
|
1092
|
-
return new G({
|
|
1093
|
-
defines: {
|
|
1094
|
-
MAX_RADIUS: e
|
|
1095
|
-
},
|
|
1096
|
-
uniforms: {
|
|
1097
|
-
colorTexture: { value: null },
|
|
1098
|
-
texSize: { value: new D(0.5, 0.5) },
|
|
1099
|
-
direction: { value: new D(0.5, 0.5) },
|
|
1100
|
-
kernelRadius: { value: 1 }
|
|
1101
|
-
},
|
|
1102
|
-
vertexShader: `varying vec2 vUv;
|
|
1103
|
-
|
|
1104
|
-
void main() {
|
|
1105
|
-
vUv = uv;
|
|
1106
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1107
|
-
}`,
|
|
1108
|
-
fragmentShader: `#include <common>
|
|
1109
|
-
varying vec2 vUv;
|
|
1110
|
-
uniform sampler2D colorTexture;
|
|
1111
|
-
uniform vec2 texSize;
|
|
1112
|
-
uniform vec2 direction;
|
|
1113
|
-
uniform float kernelRadius;
|
|
1114
|
-
|
|
1115
|
-
float gaussianPdf(in float x, in float sigma) {
|
|
1116
|
-
return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
void main() {
|
|
1120
|
-
vec2 invSize = 1.0 / texSize;
|
|
1121
|
-
float sigma = kernelRadius/2.0;
|
|
1122
|
-
float weightSum = gaussianPdf(0.0, sigma);
|
|
1123
|
-
vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
|
|
1124
|
-
vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
|
|
1125
|
-
vec2 uvOffset = delta;
|
|
1126
|
-
for( int i = 1; i <= MAX_RADIUS; i ++ ) {
|
|
1127
|
-
float x = kernelRadius * float(i) / float(MAX_RADIUS);
|
|
1128
|
-
float w = gaussianPdf(x, sigma);
|
|
1129
|
-
vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
|
|
1130
|
-
vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
|
|
1131
|
-
diffuseSum += ((sample1 + sample2) * w);
|
|
1132
|
-
weightSum += (2.0 * w);
|
|
1133
|
-
uvOffset += delta;
|
|
1134
|
-
}
|
|
1135
|
-
gl_FragColor = diffuseSum/weightSum;
|
|
1136
|
-
}`
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
_getOverlayMaterial() {
|
|
1140
|
-
return new G({
|
|
1141
|
-
uniforms: {
|
|
1142
|
-
maskTexture: { value: null },
|
|
1143
|
-
edgeTexture1: { value: null },
|
|
1144
|
-
edgeTexture2: { value: null },
|
|
1145
|
-
patternTexture: { value: null },
|
|
1146
|
-
edgeStrength: { value: 1 },
|
|
1147
|
-
edgeGlow: { value: 1 },
|
|
1148
|
-
usePatternTexture: { value: 0 }
|
|
1149
|
-
},
|
|
1150
|
-
vertexShader: `varying vec2 vUv;
|
|
1151
|
-
|
|
1152
|
-
void main() {
|
|
1153
|
-
vUv = uv;
|
|
1154
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1155
|
-
}`,
|
|
1156
|
-
fragmentShader: `varying vec2 vUv;
|
|
1157
|
-
|
|
1158
|
-
uniform sampler2D maskTexture;
|
|
1159
|
-
uniform sampler2D edgeTexture1;
|
|
1160
|
-
uniform sampler2D edgeTexture2;
|
|
1161
|
-
uniform sampler2D patternTexture;
|
|
1162
|
-
uniform float edgeStrength;
|
|
1163
|
-
uniform float edgeGlow;
|
|
1164
|
-
uniform bool usePatternTexture;
|
|
1165
|
-
|
|
1166
|
-
void main() {
|
|
1167
|
-
vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
|
|
1168
|
-
vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
|
|
1169
|
-
vec4 maskColor = texture2D(maskTexture, vUv);
|
|
1170
|
-
vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
|
|
1171
|
-
float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
|
|
1172
|
-
vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
|
|
1173
|
-
vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
|
|
1174
|
-
if(usePatternTexture)
|
|
1175
|
-
finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
|
|
1176
|
-
gl_FragColor = finalColor;
|
|
1177
|
-
}`,
|
|
1178
|
-
blending: rt,
|
|
1179
|
-
depthTest: !1,
|
|
1180
|
-
depthWrite: !1,
|
|
1181
|
-
transparent: !0
|
|
1182
|
-
});
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
R.BlurDirectionX = new D(1, 0);
|
|
1186
|
-
R.BlurDirectionY = new D(0, 1);
|
|
1187
|
-
function Bt(h, e, t, n, s) {
|
|
1188
|
-
h.traverse((a) => {
|
|
1189
|
-
var i, r;
|
|
1190
|
-
if (a instanceof o)
|
|
1191
|
-
if (e === "solid") {
|
|
1192
|
-
(i = n.get(a.uuid)) == null || i.dispose(), n.delete(a.uuid);
|
|
1193
|
-
const u = t.get(a.uuid);
|
|
1194
|
-
u && (a.material = u, t.delete(a.uuid));
|
|
1195
|
-
} else {
|
|
1196
|
-
t.has(a.uuid) || t.set(a.uuid, a.material), (r = n.get(a.uuid)) == null || r.dispose(), s.has(a.uuid) || s.set(a.uuid, Math.random() * 16777215);
|
|
1197
|
-
const u = s.get(a.uuid), f = new me(
|
|
1198
|
-
e === "wireframe" ? { wireframe: !0, color: u } : { color: u }
|
|
1199
|
-
);
|
|
1200
|
-
n.set(a.uuid, f), a.material = f;
|
|
1201
|
-
}
|
|
1202
|
-
});
|
|
1203
|
-
}
|
|
1204
|
-
class Ce extends Ke {
|
|
1205
|
-
constructor() {
|
|
1206
|
-
var e;
|
|
1207
|
-
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.activeAssetCategory = "Object", c.instance().editor = this, (e = c.instance().logger) == null || e.info("Booting Editor"), c.instance().trigger("editorBoot", this), c.instance().trigger("uiDestroy", this), c.instance().world.destroy(), c.instance().scene.traverse((t) => {
|
|
1208
|
-
var n, s;
|
|
1209
|
-
t instanceof o && ((n = t.geometry) == null || n.dispose(), Array.isArray(t.material) ? t.material.forEach((a) => a.dispose()) : (s = t.material) == null || s.dispose());
|
|
1210
|
-
}), c.instance().scene.clear(), this.initEditorScene(), c.instance().contextMenuAbort.abort(), c.instance().uiRoot.innerHTML = "", c.instance().uiRoot.style.opacity = "1", document.title = "MavonEngine | Editor", document.getElementsByTagName("body")[0].removeAttribute("onContextMenu"), Promise.all([
|
|
1211
|
-
import("./mount-Da8g-2BI.mjs"),
|
|
1212
|
-
Promise.resolve({ })
|
|
1213
|
-
]).then(([{ mountEditorUI: t }]) => {
|
|
1214
|
-
this.reactRoot = t(c.instance().uiRoot);
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* The editor should only be instantiated when button is pressed
|
|
1219
|
-
*/
|
|
1220
|
-
static registerListener() {
|
|
1221
|
-
c.instance().input.on("keydown", (e) => {
|
|
1222
|
-
(e.code === "Insert" || e.code === "Period") && (c.instance().editor = new Ce());
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
initEditorScene() {
|
|
1226
|
-
c.instance().camera.instance.position.set(20, 10, 20), c.instance().camera.instance.rotation.set(0, 0, 0), c.instance().camera.instance.rotateY(Math.PI / 360 * 90), c.instance().camera.instance.rotateX(Math.PI / 360 * -45), this.outlinePass = new R(
|
|
1227
|
-
new D(c.instance().sizes.width, c.instance().sizes.height),
|
|
1228
|
-
c.instance().scene,
|
|
1229
|
-
c.instance().camera.instance
|
|
1230
|
-
), c.instance().renderer.composer.addPass(this.outlinePass), this.initFlyControls();
|
|
1231
|
-
const e = new Xe(new l(0, 5, 0)), t = new Oe(new l(10, 15, 5));
|
|
1232
|
-
t.instance.intensity = 5;
|
|
1233
|
-
const n = new He(new l(0, 0, 0), 50, 50);
|
|
1234
|
-
n.setReceiveShadow(!0), n.instance instanceof o && n.instance.material.color.set("#ffbe6f");
|
|
1235
|
-
const s = 5, a = [
|
|
1236
|
-
new Ye(new l(s, 0.5, 0)),
|
|
1237
|
-
new Ze(new l(s * 0.707, 1, s * 0.707)),
|
|
1238
|
-
new Ue(new l(0, 0.5, s)),
|
|
1239
|
-
new je(new l(-s * 0.707, 0.5, s * 0.707)),
|
|
1240
|
-
new Fe(new l(-s, 1, 0)),
|
|
1241
|
-
new Ve(new l(-s * 0.707, 1, -s * 0.707)),
|
|
1242
|
-
new Ge(new l(0, 1, -s)),
|
|
1243
|
-
new We(new l(s * 0.707, 1, -s * 0.707)),
|
|
1244
|
-
new qe(new l(0, 3.5, 0))
|
|
1245
|
-
];
|
|
1246
|
-
a.forEach((r) => r.setCastShadow(!0));
|
|
1247
|
-
const i = {};
|
|
1248
|
-
[e, t, n, ...a].forEach((r) => i[r.id] = r), c.instance().world.add(i), this.trigger("sceneChanged"), c.instance().input.on("mousedown", (r) => {
|
|
1249
|
-
r.target === c.instance().canvas && this.handleCanvasClick(r);
|
|
1250
|
-
}), c.instance().input.on("keydown", (r) => {
|
|
1251
|
-
r.code === "Escape" && this.activeItem && this.deselect();
|
|
1252
|
-
}), this.handleItemDelete(), this.on("setTransformMode", (r) => {
|
|
1253
|
-
var u, f;
|
|
1254
|
-
this.activeToolMode = r, (u = this.transformControls) == null || u.setMode(r), (f = c.instance().logger) == null || f.info(`Setting editor tool mode: ${r}`);
|
|
1255
|
-
}), this.on("setShadeMode", (r) => {
|
|
1256
|
-
this.applyShadeMode(r);
|
|
1257
|
-
}), this.on("assetDropped", () => {
|
|
1258
|
-
this.shadeMode !== "solid" && this.applyShadeMode(this.shadeMode);
|
|
1259
|
-
}), this.initAssetsFilter();
|
|
1260
|
-
}
|
|
1261
|
-
initAssetsFilter() {
|
|
1262
|
-
this.availableAssetCategories = [
|
|
1263
|
-
...new Set(Object.entries(c.instance().resources.items).map(([e, t]) => t.constructor.name))
|
|
1264
|
-
];
|
|
1265
|
-
}
|
|
1266
|
-
setActiveAssetCategory(e) {
|
|
1267
|
-
this.activeAssetCategory = e;
|
|
1268
|
-
}
|
|
1269
|
-
applyShadeMode(e) {
|
|
1270
|
-
this.shadeMode = e, Bt(c.instance().scene, e, this.originalMaterials, this.shadeOverrideMaterials, this.flatColors);
|
|
1271
|
-
}
|
|
1272
|
-
initFlyControls() {
|
|
1273
|
-
this.flyControls = new lt(c.instance().camera.instance, c.instance().canvas), this.flyControls.autoForward = !1, this.flyControls.dragToLook = !0, this.flyControls.movementSpeed = 10, this.flyControls.rollSpeed = 0.5;
|
|
1274
|
-
}
|
|
1275
|
-
handleItemDelete() {
|
|
1276
|
-
c.instance().input.on("keydown", (e) => {
|
|
1277
|
-
if (e.code === "Delete" && this.activeItem) {
|
|
1278
|
-
let t = this.activeItem;
|
|
1279
|
-
for (; t.parent && t.parent !== c.instance().scene; )
|
|
1280
|
-
t = t.parent;
|
|
1281
|
-
t.traverse((s) => {
|
|
1282
|
-
var a, i;
|
|
1283
|
-
s instanceof o && ((a = s.geometry) == null || a.dispose(), Array.isArray(s.material) ? s.material.forEach((r) => r.dispose()) : (i = s.material) == null || i.dispose());
|
|
1284
|
-
}), this.deselect();
|
|
1285
|
-
const n = Le.from(t);
|
|
1286
|
-
n != null && n.owner ? n.owner.destroy() : (n && (n.dispose(), this.helpers = this.helpers.filter((s) => s !== n)), c.instance().scene.remove(t)), this.trigger("sceneChanged");
|
|
1287
|
-
}
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
deselect() {
|
|
1291
|
-
var e;
|
|
1292
|
-
(e = this.transformControls) == null || e.detach(), this.outlinePass.selectedObjects = [], this.activeItem = null, this.trigger("objectDeselected");
|
|
1293
|
-
}
|
|
1294
|
-
selectObject(e) {
|
|
1295
|
-
this.activeItem = e, this.trigger("objectSelected", this.activeItem), this.outlinePass.selectedObjects = [this.activeItem], this.handleHelperTool();
|
|
1296
|
-
}
|
|
1297
|
-
handleCanvasClick(e) {
|
|
1298
|
-
if (e.button === 0) {
|
|
1299
|
-
if (this.transformControls && (this.transformControls.dragging || this.transformControls.axis !== null))
|
|
1300
|
-
return;
|
|
1301
|
-
const t = c.instance().input.getPointerWorldPosition(void 0, null, !0);
|
|
1302
|
-
t instanceof le ? this.selectObject(t) : this.deselect();
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
handleHelperTool() {
|
|
1306
|
-
if (!this.transformControls) {
|
|
1307
|
-
this.transformControls = new vt(
|
|
1308
|
-
c.instance().camera.instance,
|
|
1309
|
-
c.instance().canvas
|
|
1310
|
-
), this.transformControls.addEventListener("dragging-changed", (t) => {
|
|
1311
|
-
this.flyControls.enabled = !t.value, t.value || this.initFlyControls();
|
|
1312
|
-
});
|
|
1313
|
-
const e = this.transformControls.getHelper();
|
|
1314
|
-
e.userData.isEditorInternal = !0, c.instance().scene.add(e);
|
|
1315
|
-
}
|
|
1316
|
-
this.transformControls.setMode(this.activeToolMode), this.transformControls.attach(this.activeItem);
|
|
1317
|
-
}
|
|
1318
|
-
addHelper(e) {
|
|
1319
|
-
this.helpers.push(e), this._showHelpers || (e.mesh.visible = !1, e.label.domElement.style.display = "none");
|
|
1320
|
-
}
|
|
1321
|
-
removeHelper(e) {
|
|
1322
|
-
this.helpers = this.helpers.filter((t) => t !== e);
|
|
1323
|
-
}
|
|
1324
|
-
addLightHelper(e) {
|
|
1325
|
-
this.lightHelpers.push(e), this._showHelpers || (e.visible = !1);
|
|
1326
|
-
}
|
|
1327
|
-
removeLightHelper(e) {
|
|
1328
|
-
this.lightHelpers = this.lightHelpers.filter((t) => t !== e);
|
|
1329
|
-
}
|
|
1330
|
-
setShowHelpers(e) {
|
|
1331
|
-
this._showHelpers = e, this.helpers.forEach((t) => {
|
|
1332
|
-
t.mesh.visible = e, t.label.domElement.style.display = e ? "" : "none";
|
|
1333
|
-
}), this.lightHelpers.forEach((t) => t.visible = e);
|
|
1334
|
-
}
|
|
1335
|
-
update(e) {
|
|
1336
|
-
this.updateCamera(e), this.helpers.forEach((t) => t.update(e));
|
|
1337
|
-
}
|
|
1338
|
-
updateCamera(e) {
|
|
1339
|
-
this.flyControls.update(e);
|
|
1340
|
-
const t = c.instance().camera.instance, n = new l();
|
|
1341
|
-
t.getWorldDirection(n), t.quaternion.setFromRotationMatrix(
|
|
1342
|
-
new ce().lookAt(new l(), n, new l(0, 1, 0))
|
|
1343
|
-
);
|
|
1344
|
-
}
|
|
1345
|
-
destroy() {
|
|
1346
|
-
this.reactRoot.unmount(), this.outlinePass.dispose(), this.shadeOverrideMaterials.forEach((e) => e.dispose()), this.shadeOverrideMaterials.clear(), this.originalMaterials.clear(), this.flatColors.clear();
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
export {
|
|
1350
|
-
Ce as E,
|
|
1351
|
-
Bt as a
|
|
1352
|
-
};
|