@planara/core 2.4.0 → 2.5.0
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/index.es.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import * as
|
|
3
|
-
import { Controls as
|
|
4
|
-
import { FigureType as
|
|
5
|
-
import { SymmetricAxesHelper as
|
|
6
|
-
import { injectable as
|
|
7
|
-
import { EventEmitter as
|
|
8
|
-
import { makeAutoObservable as
|
|
9
|
-
const
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
2
|
+
import * as a from "three";
|
|
3
|
+
import { Controls as xe, Vector3 as E, MOUSE as T, TOUCH as D, Quaternion as me, Spherical as fe, Vector2 as v, Ray as Ie, Plane as He, MathUtils as ke } from "three";
|
|
4
|
+
import { FigureType as y, SelectMode as M, Figure as Ne, DisplayMode as R, ToolType as O, SceneMode as j } from "@planara/types";
|
|
5
|
+
import { SymmetricAxesHelper as Ye, OrbitWithState as Ue, CameraAxesGizmo as $e, ModelingTransformControls as ze } from "@planara/three";
|
|
6
|
+
import { injectable as u, inject as l, injectAll as k, container as Fe } from "tsyringe";
|
|
7
|
+
import { EventEmitter as We } from "events";
|
|
8
|
+
import { makeAutoObservable as Ze } from "mobx";
|
|
9
|
+
const Be = {
|
|
10
|
+
[y.Plane]: () => new a.PlaneGeometry(1, 1, 1, 1),
|
|
11
|
+
[y.Cube]: () => new a.BoxGeometry(1, 1, 1, 1, 1, 1),
|
|
12
|
+
[y.UVSphere]: () => new a.SphereGeometry(0.5, 32, 16),
|
|
13
|
+
[y.Icosphere]: () => new a.IcosahedronGeometry(0.5, 0),
|
|
14
|
+
[y.Cylinder]: () => new a.CylinderGeometry(0.5, 0.5, 1, 32, 1, !1),
|
|
15
|
+
[y.Cone]: () => new a.ConeGeometry(0.5, 1, 32, 1, !1),
|
|
16
|
+
[y.Torus]: () => new a.TorusGeometry(0.5, 0.2, 16, 64),
|
|
17
|
+
[y.Circle]: () => new a.CircleGeometry(0.5, 32),
|
|
18
|
+
[y.Sphere]: () => new a.SphereGeometry(0.5, 32, 16),
|
|
19
|
+
[y.Custom]: function() {
|
|
20
20
|
throw new Error("Custom geometry is not generated here.");
|
|
21
21
|
}
|
|
22
|
-
},
|
|
22
|
+
}, Le = new a.MeshStandardMaterial({
|
|
23
23
|
color: 12566463,
|
|
24
24
|
metalness: 0,
|
|
25
25
|
roughness: 0.6
|
|
26
26
|
});
|
|
27
|
-
class
|
|
27
|
+
class Ce {
|
|
28
28
|
/** Корневой объект сцены */
|
|
29
29
|
scene;
|
|
30
30
|
/** Камера для сцены */
|
|
@@ -40,15 +40,15 @@ class Mt {
|
|
|
40
40
|
* @param canvas - HTMLCanvasElement для рендеринга
|
|
41
41
|
*/
|
|
42
42
|
constructor(e) {
|
|
43
|
-
this.canvas = e, this.scene = new
|
|
43
|
+
this.canvas = e, this.scene = new a.Scene(), this.scene.background = new a.Color(1710618), this.camera = new a.PerspectiveCamera(
|
|
44
44
|
45,
|
|
45
45
|
e.clientWidth / e.clientHeight,
|
|
46
46
|
0.1,
|
|
47
47
|
1e3
|
|
48
|
-
), this.camera.position.set(1, 1, 7), this.renderer = new
|
|
49
|
-
const s = new
|
|
48
|
+
), this.camera.position.set(1, 1, 7), this.renderer = new a.WebGLRenderer({ canvas: e, antialias: !0 }), this.renderer.setSize(e.clientWidth, e.clientHeight);
|
|
49
|
+
const s = new a.AmbientLight(16777215, 0.5);
|
|
50
50
|
this.scene.add(s);
|
|
51
|
-
const i = new
|
|
51
|
+
const i = new a.DirectionalLight(16777215, 1);
|
|
52
52
|
i.position.set(5, 10, 7), this.scene.add(i);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -79,9 +79,9 @@ class Mt {
|
|
|
79
79
|
* @param figure - Данные фигуры: position, normal, uv
|
|
80
80
|
*/
|
|
81
81
|
addFigure(e) {
|
|
82
|
-
const s = new
|
|
83
|
-
s.setAttribute("position", new
|
|
84
|
-
const i = new
|
|
82
|
+
const s = new a.BufferGeometry();
|
|
83
|
+
s.setAttribute("position", new a.Float32BufferAttribute(e.position, 3)), e.normal && s.setAttribute("normal", new a.Float32BufferAttribute(e.normal, 3)), e.uv && s.setAttribute("uv", new a.Float32BufferAttribute(e.uv, 2));
|
|
84
|
+
const i = new a.Mesh(s, Le);
|
|
85
85
|
return this.scene.add(i), this.meshes.push(i), i;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -172,582 +172,15 @@ class Mt {
|
|
|
172
172
|
this.meshes && (this.meshes.length = 0, this.meshes = []), this.scene = null, this.camera = null, this.renderer?.dispose(), this.canvas = null;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}, Me = { type: "change" }, et = { type: "mouseDown", mode: null }, tt = { type: "mouseUp", mode: null }, st = { type: "objectChange" };
|
|
180
|
-
class qt extends yt {
|
|
181
|
-
/**
|
|
182
|
-
* Constructs a new controls instance.
|
|
183
|
-
*
|
|
184
|
-
* @param {Camera} camera - The camera of the rendered scene.
|
|
185
|
-
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
186
|
-
*/
|
|
187
|
-
constructor(e, s = null) {
|
|
188
|
-
super(void 0, s);
|
|
189
|
-
const i = new ts(this);
|
|
190
|
-
this._root = i;
|
|
191
|
-
const o = new ss();
|
|
192
|
-
this._gizmo = o, i.add(o);
|
|
193
|
-
const r = new is();
|
|
194
|
-
this._plane = r, i.add(r);
|
|
195
|
-
const n = this;
|
|
196
|
-
function a(T, Q) {
|
|
197
|
-
let B = Q;
|
|
198
|
-
Object.defineProperty(n, T, {
|
|
199
|
-
get: function() {
|
|
200
|
-
return B !== void 0 ? B : Q;
|
|
201
|
-
},
|
|
202
|
-
set: function(U) {
|
|
203
|
-
B !== U && (B = U, r[T] = U, o[T] = U, n.dispatchEvent({ type: T + "-changed", value: U }), n.dispatchEvent(Me));
|
|
204
|
-
}
|
|
205
|
-
}), n[T] = Q, r[T] = Q, o[T] = Q;
|
|
206
|
-
}
|
|
207
|
-
a("camera", e), a("object", void 0), a("enabled", !0), a("axis", null), a("mode", "translate"), a("translationSnap", null), a("rotationSnap", null), a("scaleSnap", null), a("space", "world"), a("size", 1), a("dragging", !1), a("showX", !0), a("showY", !0), a("showZ", !0), a("minX", -1 / 0), a("maxX", 1 / 0), a("minY", -1 / 0), a("maxY", 1 / 0), a("minZ", -1 / 0), a("maxZ", 1 / 0);
|
|
208
|
-
const d = new c(), g = new c(), b = new O(), H = new O(), x = new c(), q = new O(), le = new c(), k = new c(), Y = new c(), j = 0, Z = new c();
|
|
209
|
-
a("worldPosition", d), a("worldPositionStart", g), a("worldQuaternion", b), a("worldQuaternionStart", H), a("cameraPosition", x), a("cameraQuaternion", q), a("pointStart", le), a("pointEnd", k), a("rotationAxis", Y), a("rotationAngle", j), a("eye", Z), this._offset = new c(), this._startNorm = new c(), this._endNorm = new c(), this._cameraScale = new c(), this._parentPosition = new c(), this._parentQuaternion = new O(), this._parentQuaternionInv = new O(), this._parentScale = new c(), this._worldScaleStart = new c(), this._worldQuaternionInv = new O(), this._worldScale = new c(), this._positionStart = new c(), this._quaternionStart = new O(), this._scaleStart = new c(), this._getPointer = Bt.bind(this), this._onPointerDown = Vt.bind(this), this._onPointerHover = Kt.bind(this), this._onPointerMove = Jt.bind(this), this._onPointerUp = es.bind(this), s !== null && this.connect(s);
|
|
210
|
-
}
|
|
211
|
-
connect(e) {
|
|
212
|
-
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";
|
|
213
|
-
}
|
|
214
|
-
disconnect() {
|
|
215
|
-
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 = "auto";
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Returns the visual representation of the controls. Add the helper to your scene to
|
|
219
|
-
* visually transform the attached 3D object.
|
|
220
|
-
*
|
|
221
|
-
* @return {TransformControlsRoot} The helper.
|
|
222
|
-
*/
|
|
223
|
-
getHelper() {
|
|
224
|
-
return this._root;
|
|
225
|
-
}
|
|
226
|
-
pointerHover(e) {
|
|
227
|
-
if (this.object === void 0 || this.dragging === !0) return;
|
|
228
|
-
e !== null && W.setFromCamera(e, this.camera);
|
|
229
|
-
const s = Pe(this._gizmo.picker[this.mode], W);
|
|
230
|
-
s ? this.axis = s.object.name : this.axis = null;
|
|
231
|
-
}
|
|
232
|
-
pointerDown(e) {
|
|
233
|
-
if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
|
|
234
|
-
e !== null && W.setFromCamera(e, this.camera);
|
|
235
|
-
const s = Pe(this._plane, W, !0);
|
|
236
|
-
s && (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(s.point).sub(this.worldPositionStart)), this.dragging = !0, et.mode = this.mode, this.dispatchEvent(et);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
pointerMove(e) {
|
|
240
|
-
const s = this.axis, i = this.mode, o = this.object;
|
|
241
|
-
let r = this.space;
|
|
242
|
-
if (i === "scale" ? r = "local" : (s === "E" || s === "XYZE" || s === "XYZ") && (r = "world"), o === void 0 || s === null || this.dragging === !1 || e !== null && e.button !== -1) return;
|
|
243
|
-
e !== null && W.setFromCamera(e, this.camera);
|
|
244
|
-
const n = Pe(this._plane, W, !0);
|
|
245
|
-
if (n) {
|
|
246
|
-
if (this.pointEnd.copy(n.point).sub(this.worldPositionStart), i === "translate")
|
|
247
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart), r === "local" && s !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), s.indexOf("X") === -1 && (this._offset.x = 0), s.indexOf("Y") === -1 && (this._offset.y = 0), s.indexOf("Z") === -1 && (this._offset.z = 0), r === "local" && s !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), o.position.copy(this._offset).add(this._positionStart), this.translationSnap && (r === "local" && (o.position.applyQuaternion(m.copy(this._quaternionStart).invert()), s.search("X") !== -1 && (o.position.x = Math.round(o.position.x / this.translationSnap) * this.translationSnap), s.search("Y") !== -1 && (o.position.y = Math.round(o.position.y / this.translationSnap) * this.translationSnap), s.search("Z") !== -1 && (o.position.z = Math.round(o.position.z / this.translationSnap) * this.translationSnap), o.position.applyQuaternion(this._quaternionStart)), r === "world" && (o.parent && o.position.add(v.setFromMatrixPosition(o.parent.matrixWorld)), s.search("X") !== -1 && (o.position.x = Math.round(o.position.x / this.translationSnap) * this.translationSnap), s.search("Y") !== -1 && (o.position.y = Math.round(o.position.y / this.translationSnap) * this.translationSnap), s.search("Z") !== -1 && (o.position.z = Math.round(o.position.z / this.translationSnap) * this.translationSnap), o.parent && o.position.sub(v.setFromMatrixPosition(o.parent.matrixWorld)))), o.position.x = Math.max(this.minX, Math.min(this.maxX, o.position.x)), o.position.y = Math.max(this.minY, Math.min(this.maxY, o.position.y)), o.position.z = Math.max(this.minZ, Math.min(this.maxZ, o.position.z));
|
|
248
|
-
else if (i === "scale") {
|
|
249
|
-
if (s.search("XYZ") !== -1) {
|
|
250
|
-
let a = this.pointEnd.length() / this.pointStart.length();
|
|
251
|
-
this.pointEnd.dot(this.pointStart) < 0 && (a *= -1), F.set(a, a, a);
|
|
252
|
-
} else
|
|
253
|
-
v.copy(this.pointStart), F.copy(this.pointEnd), v.applyQuaternion(this._worldQuaternionInv), F.applyQuaternion(this._worldQuaternionInv), F.divide(v), s.search("X") === -1 && (F.x = 1), s.search("Y") === -1 && (F.y = 1), s.search("Z") === -1 && (F.z = 1);
|
|
254
|
-
o.scale.copy(this._scaleStart).multiply(F), this.scaleSnap && (s.search("X") !== -1 && (o.scale.x = Math.round(o.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), s.search("Y") !== -1 && (o.scale.y = Math.round(o.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), s.search("Z") !== -1 && (o.scale.z = Math.round(o.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
255
|
-
} else if (i === "rotate") {
|
|
256
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
257
|
-
const a = 20 / this.worldPosition.distanceTo(v.setFromMatrixPosition(this.camera.matrixWorld));
|
|
258
|
-
let d = !1;
|
|
259
|
-
s === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(v.copy(this.rotationAxis).cross(this.eye)) * a) : (s === "X" || s === "Y" || s === "Z") && (this.rotationAxis.copy(Je[s]), v.copy(Je[s]), r === "local" && v.applyQuaternion(this.worldQuaternion), v.cross(this.eye), v.length() === 0 ? d = !0 : this.rotationAngle = this._offset.dot(v.normalize()) * a), (s === "E" || d) && (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), r === "local" && s !== "E" && s !== "XYZE" ? (o.quaternion.copy(this._quaternionStart), o.quaternion.multiply(m.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), o.quaternion.copy(m.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), o.quaternion.multiply(this._quaternionStart).normalize());
|
|
260
|
-
}
|
|
261
|
-
this.dispatchEvent(Me), this.dispatchEvent(st);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
pointerUp(e) {
|
|
265
|
-
e !== null && e.button !== 0 || (this.dragging && this.axis !== null && (tt.mode = this.mode, this.dispatchEvent(tt)), this.dragging = !1, this.axis = null);
|
|
266
|
-
}
|
|
267
|
-
dispose() {
|
|
268
|
-
this.disconnect(), this._root.dispose();
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Sets the 3D object that should be transformed and ensures the controls UI is visible.
|
|
272
|
-
*
|
|
273
|
-
* @param {Object3D} object - The 3D object that should be transformed.
|
|
274
|
-
* @return {TransformControls} A reference to this controls.
|
|
275
|
-
*/
|
|
276
|
-
attach(e) {
|
|
277
|
-
return this.object = e, this._root.visible = !0, this;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Removes the current 3D object from the controls and makes the helper UI invisible.
|
|
281
|
-
*
|
|
282
|
-
* @return {TransformControls} A reference to this controls.
|
|
283
|
-
*/
|
|
284
|
-
detach() {
|
|
285
|
-
return this.object = void 0, this.axis = null, this._root.visible = !1, this;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Resets the object's position, rotation and scale to when the current transform began.
|
|
289
|
-
*/
|
|
290
|
-
reset() {
|
|
291
|
-
this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(Me), this.dispatchEvent(st), this.pointStart.copy(this.pointEnd));
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Returns the raycaster that is used for user interaction. This object is shared between all
|
|
295
|
-
* instances of `TransformControls`.
|
|
296
|
-
*
|
|
297
|
-
* @returns {Raycaster} The internal raycaster.
|
|
298
|
-
*/
|
|
299
|
-
getRaycaster() {
|
|
300
|
-
return W;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Returns the transformation mode.
|
|
304
|
-
*
|
|
305
|
-
* @returns {'translate'|'rotate'|'scale'} The transformation mode.
|
|
306
|
-
*/
|
|
307
|
-
getMode() {
|
|
308
|
-
return this.mode;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Sets the given transformation mode.
|
|
312
|
-
*
|
|
313
|
-
* @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
|
|
314
|
-
*/
|
|
315
|
-
setMode(e) {
|
|
316
|
-
this.mode = e;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Sets the translation snap.
|
|
320
|
-
*
|
|
321
|
-
* @param {?number} translationSnap - The translation snap to set.
|
|
322
|
-
*/
|
|
323
|
-
setTranslationSnap(e) {
|
|
324
|
-
this.translationSnap = e;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Sets the rotation snap.
|
|
328
|
-
*
|
|
329
|
-
* @param {?number} rotationSnap - The rotation snap to set.
|
|
330
|
-
*/
|
|
331
|
-
setRotationSnap(e) {
|
|
332
|
-
this.rotationSnap = e;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Sets the scale snap.
|
|
336
|
-
*
|
|
337
|
-
* @param {?number} scaleSnap - The scale snap to set.
|
|
338
|
-
*/
|
|
339
|
-
setScaleSnap(e) {
|
|
340
|
-
this.scaleSnap = e;
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Sets the size of the helper UI.
|
|
344
|
-
*
|
|
345
|
-
* @param {number} size - The size to set.
|
|
346
|
-
*/
|
|
347
|
-
setSize(e) {
|
|
348
|
-
this.size = e;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Sets the coordinate space in which transformations are applied.
|
|
352
|
-
*
|
|
353
|
-
* @param {'world'|'local'} space - The space to set.
|
|
354
|
-
*/
|
|
355
|
-
setSpace(e) {
|
|
356
|
-
this.space = e;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Sets the colors of the control's gizmo.
|
|
360
|
-
*
|
|
361
|
-
* @param {number|Color|string} xAxis - The x-axis color.
|
|
362
|
-
* @param {number|Color|string} yAxis - The y-axis color.
|
|
363
|
-
* @param {number|Color|string} zAxis - The z-axis color.
|
|
364
|
-
* @param {number|Color|string} active - The color for active elements.
|
|
365
|
-
*/
|
|
366
|
-
setColors(e, s, i, o) {
|
|
367
|
-
const r = this._gizmo.materialLib;
|
|
368
|
-
r.xAxis.color.set(e), r.yAxis.color.set(s), r.zAxis.color.set(i), r.active.color.set(o), r.xAxisTransparent.color.set(e), r.yAxisTransparent.color.set(s), r.zAxisTransparent.color.set(i), r.activeTransparent.color.set(o), r.xAxis._color && r.xAxis._color.set(e), r.yAxis._color && r.yAxis._color.set(s), r.zAxis._color && r.zAxis._color.set(i), r.active._color && r.active._color.set(o), r.xAxisTransparent._color && r.xAxisTransparent._color.set(e), r.yAxisTransparent._color && r.yAxisTransparent._color.set(s), r.zAxisTransparent._color && r.zAxisTransparent._color.set(i), r.activeTransparent._color && r.activeTransparent._color.set(o);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function Bt(t) {
|
|
372
|
-
if (this.domElement.ownerDocument.pointerLockElement)
|
|
373
|
-
return {
|
|
374
|
-
x: 0,
|
|
375
|
-
y: 0,
|
|
376
|
-
button: t.button
|
|
377
|
-
};
|
|
378
|
-
{
|
|
379
|
-
const e = this.domElement.getBoundingClientRect();
|
|
380
|
-
return {
|
|
381
|
-
x: (t.clientX - e.left) / e.width * 2 - 1,
|
|
382
|
-
y: -(t.clientY - e.top) / e.height * 2 + 1,
|
|
383
|
-
button: t.button
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function Kt(t) {
|
|
388
|
-
if (this.enabled)
|
|
389
|
-
switch (t.pointerType) {
|
|
390
|
-
case "mouse":
|
|
391
|
-
case "pen":
|
|
392
|
-
this.pointerHover(this._getPointer(t));
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
function Vt(t) {
|
|
397
|
-
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(t.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(t)), this.pointerDown(this._getPointer(t)));
|
|
398
|
-
}
|
|
399
|
-
function Jt(t) {
|
|
400
|
-
this.enabled && this.pointerMove(this._getPointer(t));
|
|
401
|
-
}
|
|
402
|
-
function es(t) {
|
|
403
|
-
this.enabled && (this.domElement.releasePointerCapture(t.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(t)));
|
|
404
|
-
}
|
|
405
|
-
function Pe(t, e, s) {
|
|
406
|
-
const i = e.intersectObject(t, !0);
|
|
407
|
-
for (let o = 0; o < i.length; o++)
|
|
408
|
-
if (i[o].object.visible || s)
|
|
409
|
-
return i[o];
|
|
410
|
-
return !1;
|
|
411
|
-
}
|
|
412
|
-
const me = new Rt(), _ = new c(0, 1, 0), it = new c(0, 0, 0), ot = new wt(), fe = new O(), we = new O(), R = new c(), nt = new wt(), ne = new c(1, 0, 0), $ = new c(0, 1, 0), re = new c(0, 0, 1), ge = new c(), se = new c(), ie = new c();
|
|
413
|
-
class ts extends xe {
|
|
414
|
-
constructor(e) {
|
|
415
|
-
super(), this.isTransformControlsRoot = !0, this.controls = e, this.visible = !1;
|
|
416
|
-
}
|
|
417
|
-
// updateMatrixWorld updates key transformation variables
|
|
418
|
-
updateMatrixWorld(e) {
|
|
419
|
-
const s = this.controls;
|
|
420
|
-
s.object !== void 0 && (s.object.updateMatrixWorld(), s.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : s.object.parent.matrixWorld.decompose(s._parentPosition, s._parentQuaternion, s._parentScale), s.object.matrixWorld.decompose(s.worldPosition, s.worldQuaternion, s._worldScale), s._parentQuaternionInv.copy(s._parentQuaternion).invert(), s._worldQuaternionInv.copy(s.worldQuaternion).invert()), s.camera.updateMatrixWorld(), s.camera.matrixWorld.decompose(s.cameraPosition, s.cameraQuaternion, s._cameraScale), s.camera.isOrthographicCamera ? s.camera.getWorldDirection(s.eye).negate() : s.eye.copy(s.cameraPosition).sub(s.worldPosition).normalize(), super.updateMatrixWorld(e);
|
|
421
|
-
}
|
|
422
|
-
dispose() {
|
|
423
|
-
this.traverse(function(e) {
|
|
424
|
-
e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
class ss extends xe {
|
|
429
|
-
constructor() {
|
|
430
|
-
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
431
|
-
const e = new bt({
|
|
432
|
-
depthTest: !1,
|
|
433
|
-
depthWrite: !1,
|
|
434
|
-
fog: !1,
|
|
435
|
-
toneMapped: !1,
|
|
436
|
-
transparent: !0
|
|
437
|
-
}), s = new It({
|
|
438
|
-
depthTest: !1,
|
|
439
|
-
depthWrite: !1,
|
|
440
|
-
fog: !1,
|
|
441
|
-
toneMapped: !1,
|
|
442
|
-
transparent: !0
|
|
443
|
-
}), i = e.clone();
|
|
444
|
-
i.opacity = 0.15;
|
|
445
|
-
const o = s.clone();
|
|
446
|
-
o.opacity = 0.5;
|
|
447
|
-
const r = e.clone();
|
|
448
|
-
r.color.setHex(16711680);
|
|
449
|
-
const n = e.clone();
|
|
450
|
-
n.color.setHex(65280);
|
|
451
|
-
const a = e.clone();
|
|
452
|
-
a.color.setHex(255);
|
|
453
|
-
const d = e.clone();
|
|
454
|
-
d.color.setHex(16711680), d.opacity = 0.5;
|
|
455
|
-
const g = e.clone();
|
|
456
|
-
g.color.setHex(65280), g.opacity = 0.5;
|
|
457
|
-
const b = e.clone();
|
|
458
|
-
b.color.setHex(255), b.opacity = 0.5;
|
|
459
|
-
const H = e.clone();
|
|
460
|
-
H.opacity = 0.25;
|
|
461
|
-
const x = e.clone();
|
|
462
|
-
x.color.setHex(16776960), x.opacity = 0.25;
|
|
463
|
-
const q = e.clone();
|
|
464
|
-
q.color.setHex(16776960);
|
|
465
|
-
const le = e.clone();
|
|
466
|
-
le.color.setHex(7895160), this.materialLib = {
|
|
467
|
-
xAxis: r,
|
|
468
|
-
yAxis: n,
|
|
469
|
-
zAxis: a,
|
|
470
|
-
active: q,
|
|
471
|
-
xAxisTransparent: d,
|
|
472
|
-
yAxisTransparent: g,
|
|
473
|
-
zAxisTransparent: b,
|
|
474
|
-
activeTransparent: x
|
|
475
|
-
};
|
|
476
|
-
const k = new S(0, 0.04, 0.1, 12);
|
|
477
|
-
k.translate(0, 0.05, 0);
|
|
478
|
-
const Y = new M(0.08, 0.08, 0.08);
|
|
479
|
-
Y.translate(0, 0.04, 0);
|
|
480
|
-
const j = new Be();
|
|
481
|
-
j.setAttribute("position", new Ke([0, 0, 0, 1, 0, 0], 3));
|
|
482
|
-
const Z = new S(75e-4, 75e-4, 0.5, 3);
|
|
483
|
-
Z.translate(0, 0.25, 0);
|
|
484
|
-
function T(D, ce) {
|
|
485
|
-
const A = new te(D, 75e-4, 3, 64, ce * Math.PI * 2);
|
|
486
|
-
return A.rotateY(Math.PI / 2), A.rotateX(Math.PI / 2), A;
|
|
487
|
-
}
|
|
488
|
-
function Q() {
|
|
489
|
-
const D = new Be();
|
|
490
|
-
return D.setAttribute("position", new Ke([0, 0, 0, 1, 1, 1], 3)), D;
|
|
491
|
-
}
|
|
492
|
-
const B = {
|
|
493
|
-
X: [
|
|
494
|
-
[new h(k, r), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
495
|
-
[new h(k, r), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
496
|
-
[new h(Z, r), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
497
|
-
],
|
|
498
|
-
Y: [
|
|
499
|
-
[new h(k, n), [0, 0.5, 0]],
|
|
500
|
-
[new h(k, n), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
501
|
-
[new h(Z, n)]
|
|
502
|
-
],
|
|
503
|
-
Z: [
|
|
504
|
-
[new h(k, a), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
505
|
-
[new h(k, a), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
506
|
-
[new h(Z, a), null, [Math.PI / 2, 0, 0]]
|
|
507
|
-
],
|
|
508
|
-
XYZ: [
|
|
509
|
-
[new h(new ue(0.1, 0), H), [0, 0, 0]]
|
|
510
|
-
],
|
|
511
|
-
XY: [
|
|
512
|
-
[new h(new M(0.15, 0.15, 0.01), b), [0.15, 0.15, 0]]
|
|
513
|
-
],
|
|
514
|
-
YZ: [
|
|
515
|
-
[new h(new M(0.15, 0.15, 0.01), d), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
516
|
-
],
|
|
517
|
-
XZ: [
|
|
518
|
-
[new h(new M(0.15, 0.15, 0.01), g), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
519
|
-
]
|
|
520
|
-
}, U = {
|
|
521
|
-
X: [
|
|
522
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
523
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
524
|
-
],
|
|
525
|
-
Y: [
|
|
526
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
|
|
527
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
528
|
-
],
|
|
529
|
-
Z: [
|
|
530
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
531
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
532
|
-
],
|
|
533
|
-
XYZ: [
|
|
534
|
-
[new h(new ue(0.2, 0), i)]
|
|
535
|
-
],
|
|
536
|
-
XY: [
|
|
537
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
|
|
538
|
-
],
|
|
539
|
-
YZ: [
|
|
540
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
541
|
-
],
|
|
542
|
-
XZ: [
|
|
543
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
544
|
-
]
|
|
545
|
-
}, St = {
|
|
546
|
-
START: [
|
|
547
|
-
[new h(new ue(0.01, 2), o), null, null, null, "helper"]
|
|
548
|
-
],
|
|
549
|
-
END: [
|
|
550
|
-
[new h(new ue(0.01, 2), o), null, null, null, "helper"]
|
|
551
|
-
],
|
|
552
|
-
DELTA: [
|
|
553
|
-
[new N(Q(), o), null, null, null, "helper"]
|
|
554
|
-
],
|
|
555
|
-
X: [
|
|
556
|
-
[new N(j, o), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
557
|
-
],
|
|
558
|
-
Y: [
|
|
559
|
-
[new N(j, o), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
560
|
-
],
|
|
561
|
-
Z: [
|
|
562
|
-
[new N(j, o), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
563
|
-
]
|
|
564
|
-
}, Et = {
|
|
565
|
-
XYZE: [
|
|
566
|
-
[new h(T(0.5, 1), le), null, [0, Math.PI / 2, 0]]
|
|
567
|
-
],
|
|
568
|
-
X: [
|
|
569
|
-
[new h(T(0.5, 0.5), r)]
|
|
570
|
-
],
|
|
571
|
-
Y: [
|
|
572
|
-
[new h(T(0.5, 0.5), n), null, [0, 0, -Math.PI / 2]]
|
|
573
|
-
],
|
|
574
|
-
Z: [
|
|
575
|
-
[new h(T(0.5, 0.5), a), null, [0, Math.PI / 2, 0]]
|
|
576
|
-
],
|
|
577
|
-
E: [
|
|
578
|
-
[new h(T(0.75, 1), x), null, [0, Math.PI / 2, 0]]
|
|
579
|
-
]
|
|
580
|
-
}, xt = {
|
|
581
|
-
AXIS: [
|
|
582
|
-
[new N(j, o), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
583
|
-
]
|
|
584
|
-
}, Tt = {
|
|
585
|
-
XYZE: [
|
|
586
|
-
[new h(new jt(0.25, 10, 8), i)]
|
|
587
|
-
],
|
|
588
|
-
X: [
|
|
589
|
-
[new h(new te(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
590
|
-
],
|
|
591
|
-
Y: [
|
|
592
|
-
[new h(new te(0.5, 0.1, 4, 24), i), [0, 0, 0], [Math.PI / 2, 0, 0]]
|
|
593
|
-
],
|
|
594
|
-
Z: [
|
|
595
|
-
[new h(new te(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
596
|
-
],
|
|
597
|
-
E: [
|
|
598
|
-
[new h(new te(0.75, 0.1, 2, 24), i)]
|
|
599
|
-
]
|
|
600
|
-
}, Dt = {
|
|
601
|
-
X: [
|
|
602
|
-
[new h(Y, r), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
603
|
-
[new h(Z, r), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
604
|
-
[new h(Y, r), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
|
|
605
|
-
],
|
|
606
|
-
Y: [
|
|
607
|
-
[new h(Y, n), [0, 0.5, 0]],
|
|
608
|
-
[new h(Z, n)],
|
|
609
|
-
[new h(Y, n), [0, -0.5, 0], [0, 0, Math.PI]]
|
|
610
|
-
],
|
|
611
|
-
Z: [
|
|
612
|
-
[new h(Y, a), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
613
|
-
[new h(Z, a), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
614
|
-
[new h(Y, a), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
615
|
-
],
|
|
616
|
-
XY: [
|
|
617
|
-
[new h(new M(0.15, 0.15, 0.01), b), [0.15, 0.15, 0]]
|
|
618
|
-
],
|
|
619
|
-
YZ: [
|
|
620
|
-
[new h(new M(0.15, 0.15, 0.01), d), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
621
|
-
],
|
|
622
|
-
XZ: [
|
|
623
|
-
[new h(new M(0.15, 0.15, 0.01), g), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
624
|
-
],
|
|
625
|
-
XYZ: [
|
|
626
|
-
[new h(new M(0.1, 0.1, 0.1), H)]
|
|
627
|
-
]
|
|
628
|
-
}, Ot = {
|
|
629
|
-
X: [
|
|
630
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
631
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
632
|
-
],
|
|
633
|
-
Y: [
|
|
634
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
|
|
635
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
636
|
-
],
|
|
637
|
-
Z: [
|
|
638
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
639
|
-
[new h(new S(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
640
|
-
],
|
|
641
|
-
XY: [
|
|
642
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
|
|
643
|
-
],
|
|
644
|
-
YZ: [
|
|
645
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
646
|
-
],
|
|
647
|
-
XZ: [
|
|
648
|
-
[new h(new M(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
649
|
-
],
|
|
650
|
-
XYZ: [
|
|
651
|
-
[new h(new M(0.2, 0.2, 0.2), i), [0, 0, 0]]
|
|
652
|
-
]
|
|
653
|
-
}, At = {
|
|
654
|
-
X: [
|
|
655
|
-
[new N(j, o), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
656
|
-
],
|
|
657
|
-
Y: [
|
|
658
|
-
[new N(j, o), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
659
|
-
],
|
|
660
|
-
Z: [
|
|
661
|
-
[new N(j, o), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
662
|
-
]
|
|
663
|
-
};
|
|
664
|
-
function z(D) {
|
|
665
|
-
const ce = new xe();
|
|
666
|
-
for (const A in D)
|
|
667
|
-
for (let K = D[A].length; K--; ) {
|
|
668
|
-
const P = D[A][K][0].clone(), de = D[A][K][1], pe = D[A][K][2], _e = D[A][K][3], Lt = D[A][K][4];
|
|
669
|
-
P.name = A, P.tag = Lt, de && P.position.set(de[0], de[1], de[2]), pe && P.rotation.set(pe[0], pe[1], pe[2]), _e && P.scale.set(_e[0], _e[1], _e[2]), P.updateMatrix();
|
|
670
|
-
const qe = P.geometry.clone();
|
|
671
|
-
qe.applyMatrix4(P.matrix), P.geometry = qe, P.renderOrder = 1 / 0, P.position.set(0, 0, 0), P.rotation.set(0, 0, 0), P.scale.set(1, 1, 1), ce.add(P);
|
|
672
|
-
}
|
|
673
|
-
return ce;
|
|
674
|
-
}
|
|
675
|
-
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = z(B)), this.add(this.gizmo.rotate = z(Et)), this.add(this.gizmo.scale = z(Dt)), this.add(this.picker.translate = z(U)), this.add(this.picker.rotate = z(Tt)), this.add(this.picker.scale = z(Ot)), this.add(this.helper.translate = z(St)), this.add(this.helper.rotate = z(xt)), this.add(this.helper.scale = z(At)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
676
|
-
}
|
|
677
|
-
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
678
|
-
updateMatrixWorld(e) {
|
|
679
|
-
const i = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : we;
|
|
680
|
-
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";
|
|
681
|
-
let o = [];
|
|
682
|
-
o = o.concat(this.picker[this.mode].children), o = o.concat(this.gizmo[this.mode].children), o = o.concat(this.helper[this.mode].children);
|
|
683
|
-
for (let r = 0; r < o.length; r++) {
|
|
684
|
-
const n = o[r];
|
|
685
|
-
n.visible = !0, n.rotation.set(0, 0, 0), n.position.copy(this.worldPosition);
|
|
686
|
-
let a;
|
|
687
|
-
if (this.camera.isOrthographicCamera ? a = (this.camera.top - this.camera.bottom) / this.camera.zoom : a = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), n.scale.set(1, 1, 1).multiplyScalar(a * this.size / 4), n.tag === "helper") {
|
|
688
|
-
n.visible = !1, n.name === "AXIS" ? (n.visible = !!this.axis, this.axis === "X" && (m.setFromEuler(me.set(0, 0, 0)), n.quaternion.copy(i).multiply(m), Math.abs(_.copy(ne).applyQuaternion(i).dot(this.eye)) > 0.9 && (n.visible = !1)), this.axis === "Y" && (m.setFromEuler(me.set(0, 0, Math.PI / 2)), n.quaternion.copy(i).multiply(m), Math.abs(_.copy($).applyQuaternion(i).dot(this.eye)) > 0.9 && (n.visible = !1)), this.axis === "Z" && (m.setFromEuler(me.set(0, Math.PI / 2, 0)), n.quaternion.copy(i).multiply(m), Math.abs(_.copy(re).applyQuaternion(i).dot(this.eye)) > 0.9 && (n.visible = !1)), this.axis === "XYZE" && (m.setFromEuler(me.set(0, Math.PI / 2, 0)), _.copy(this.rotationAxis), n.quaternion.setFromRotationMatrix(ot.lookAt(it, _, $)), n.quaternion.multiply(m), n.visible = this.dragging), this.axis === "E" && (n.visible = !1)) : n.name === "START" ? (n.position.copy(this.worldPositionStart), n.visible = this.dragging) : n.name === "END" ? (n.position.copy(this.worldPosition), n.visible = this.dragging) : n.name === "DELTA" ? (n.position.copy(this.worldPositionStart), n.quaternion.copy(this.worldQuaternionStart), v.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), v.applyQuaternion(this.worldQuaternionStart.clone().invert()), n.scale.copy(v), n.visible = this.dragging) : (n.quaternion.copy(i), this.dragging ? n.position.copy(this.worldPositionStart) : n.position.copy(this.worldPosition), this.axis && (n.visible = this.axis.search(n.name) !== -1));
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
n.quaternion.copy(i), this.mode === "translate" || this.mode === "scale" ? (n.name === "X" && Math.abs(_.copy(ne).applyQuaternion(i).dot(this.eye)) > 0.99 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1), n.name === "Y" && Math.abs(_.copy($).applyQuaternion(i).dot(this.eye)) > 0.99 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1), n.name === "Z" && Math.abs(_.copy(re).applyQuaternion(i).dot(this.eye)) > 0.99 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1), n.name === "XY" && Math.abs(_.copy(re).applyQuaternion(i).dot(this.eye)) < 0.2 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1), n.name === "YZ" && Math.abs(_.copy(ne).applyQuaternion(i).dot(this.eye)) < 0.2 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1), n.name === "XZ" && Math.abs(_.copy($).applyQuaternion(i).dot(this.eye)) < 0.2 && (n.scale.set(1e-10, 1e-10, 1e-10), n.visible = !1)) : this.mode === "rotate" && (fe.copy(i), _.copy(this.eye).applyQuaternion(m.copy(i).invert()), n.name.search("E") !== -1 && n.quaternion.setFromRotationMatrix(ot.lookAt(this.eye, it, $)), n.name === "X" && (m.setFromAxisAngle(ne, Math.atan2(-_.y, _.z)), m.multiplyQuaternions(fe, m), n.quaternion.copy(m)), n.name === "Y" && (m.setFromAxisAngle($, Math.atan2(_.x, _.z)), m.multiplyQuaternions(fe, m), n.quaternion.copy(m)), n.name === "Z" && (m.setFromAxisAngle(re, Math.atan2(_.y, _.x)), m.multiplyQuaternions(fe, m), n.quaternion.copy(m))), n.visible = n.visible && (n.name.indexOf("X") === -1 || this.showX), n.visible = n.visible && (n.name.indexOf("Y") === -1 || this.showY), n.visible = n.visible && (n.name.indexOf("Z") === -1 || this.showZ), n.visible = n.visible && (n.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), n.material._color = n.material._color || n.material.color.clone(), n.material._opacity = n.material._opacity || n.material.opacity, n.material.color.copy(n.material._color), n.material.opacity = n.material._opacity, this.enabled && this.axis && (n.name === this.axis ? (n.material.color.copy(this.materialLib.active.color), n.material.opacity = 1) : this.axis.split("").some(function(d) {
|
|
692
|
-
return n.name === d;
|
|
693
|
-
}) && (n.material.color.copy(this.materialLib.active.color), n.material.opacity = 1));
|
|
694
|
-
}
|
|
695
|
-
super.updateMatrixWorld(e);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
class is extends h {
|
|
699
|
-
constructor() {
|
|
700
|
-
super(
|
|
701
|
-
new Ht(1e5, 1e5, 2, 2),
|
|
702
|
-
new bt({ visible: !1, wireframe: !0, side: kt, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
703
|
-
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
704
|
-
}
|
|
705
|
-
updateMatrixWorld(e) {
|
|
706
|
-
let s = this.space;
|
|
707
|
-
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (s = "local"), ge.copy(ne).applyQuaternion(s === "local" ? this.worldQuaternion : we), se.copy($).applyQuaternion(s === "local" ? this.worldQuaternion : we), ie.copy(re).applyQuaternion(s === "local" ? this.worldQuaternion : we), _.copy(se), this.mode) {
|
|
708
|
-
case "translate":
|
|
709
|
-
case "scale":
|
|
710
|
-
switch (this.axis) {
|
|
711
|
-
case "X":
|
|
712
|
-
_.copy(this.eye).cross(ge), R.copy(ge).cross(_);
|
|
713
|
-
break;
|
|
714
|
-
case "Y":
|
|
715
|
-
_.copy(this.eye).cross(se), R.copy(se).cross(_);
|
|
716
|
-
break;
|
|
717
|
-
case "Z":
|
|
718
|
-
_.copy(this.eye).cross(ie), R.copy(ie).cross(_);
|
|
719
|
-
break;
|
|
720
|
-
case "XY":
|
|
721
|
-
R.copy(ie);
|
|
722
|
-
break;
|
|
723
|
-
case "YZ":
|
|
724
|
-
R.copy(ge);
|
|
725
|
-
break;
|
|
726
|
-
case "XZ":
|
|
727
|
-
_.copy(ie), R.copy(se);
|
|
728
|
-
break;
|
|
729
|
-
case "XYZ":
|
|
730
|
-
case "E":
|
|
731
|
-
R.set(0, 0, 0);
|
|
732
|
-
break;
|
|
733
|
-
}
|
|
734
|
-
break;
|
|
735
|
-
case "rotate":
|
|
736
|
-
default:
|
|
737
|
-
R.set(0, 0, 0);
|
|
738
|
-
}
|
|
739
|
-
R.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (nt.lookAt(v.set(0, 0, 0), R, _), this.quaternion.setFromRotationMatrix(nt)), super.updateMatrixWorld(e);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
var os = Object.getOwnPropertyDescriptor, ns = (t, e, s, i) => {
|
|
743
|
-
for (var o = i > 1 ? void 0 : i ? os(e, s) : e, r = t.length - 1, n; r >= 0; r--)
|
|
744
|
-
(n = t[r]) && (o = n(o) || o);
|
|
745
|
-
return o;
|
|
175
|
+
var Xe = Object.getOwnPropertyDescriptor, Ve = (t, e, s, i) => {
|
|
176
|
+
for (var r = i > 1 ? void 0 : i ? Xe(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
177
|
+
(n = t[o]) && (r = n(r) || r);
|
|
178
|
+
return r;
|
|
746
179
|
};
|
|
747
|
-
let
|
|
180
|
+
let $ = class {
|
|
748
181
|
_emitter;
|
|
749
182
|
constructor() {
|
|
750
|
-
this._emitter = new
|
|
183
|
+
this._emitter = new We();
|
|
751
184
|
}
|
|
752
185
|
/** Публикация события */
|
|
753
186
|
emit(t, e) {
|
|
@@ -762,28 +195,28 @@ let Te = class {
|
|
|
762
195
|
this._emitter.off(t, e);
|
|
763
196
|
}
|
|
764
197
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
],
|
|
768
|
-
var
|
|
769
|
-
const
|
|
770
|
-
var
|
|
771
|
-
for (var
|
|
772
|
-
(n = t[
|
|
773
|
-
return
|
|
774
|
-
},
|
|
775
|
-
let
|
|
198
|
+
$ = Ve([
|
|
199
|
+
u()
|
|
200
|
+
], $);
|
|
201
|
+
var L = /* @__PURE__ */ ((t) => (t.SelectHover = "select.hover", t.SelectClick = "select.click", t.ToolSelect = "tool.select", t))(L || {});
|
|
202
|
+
const Ke = 0.03, Ge = 10;
|
|
203
|
+
var qe = Object.getOwnPropertyDescriptor, Qe = (t, e, s, i) => {
|
|
204
|
+
for (var r = i > 1 ? void 0 : i ? qe(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
205
|
+
(n = t[o]) && (r = n(r) || r);
|
|
206
|
+
return r;
|
|
207
|
+
}, ge = (t, e) => (s, i) => e(s, i, t);
|
|
208
|
+
let z = class extends Ce {
|
|
776
209
|
constructor(t, e) {
|
|
777
210
|
super(t), this._canvas = t, this._bus = e;
|
|
778
|
-
const s = new
|
|
211
|
+
const s = new a.GridHelper(10, 10);
|
|
779
212
|
s.position.y = -1e-3, this.scene.add(s);
|
|
780
|
-
const i = new
|
|
781
|
-
this.scene.add(i), this._orbit = new
|
|
213
|
+
const i = new Ye(6);
|
|
214
|
+
this.scene.add(i), this._orbit = new Ue(this.camera, this.renderer.domElement), this._orbit.enableDamping = !0, this._orbit.dampingFactor = 0.05, this._cameraGizmo = new $e(this.renderer, this.camera, {
|
|
782
215
|
size: 96,
|
|
783
216
|
// Размер квадрата
|
|
784
217
|
margin: 36
|
|
785
218
|
// Отступы по сторонам (снизу и справа)
|
|
786
|
-
}), this._raycaster = new
|
|
219
|
+
}), this._raycaster = new a.Raycaster(), this._mouse = new a.Vector2(), this.scene.add(new a.HemisphereLight(16777215, 4473924, 0.6)), this.camera.layers.enable(0), this.camera.layers.enable(1), this._transform = new ze(this.camera, this.renderer.domElement), this._transformHelper = this._transform.getHelper(), this.scene.add(this._transformHelper), this._isEventListenersAdded || this._initMouseListeners();
|
|
787
220
|
}
|
|
788
221
|
/** Orbit-контроллер для управления камерой */
|
|
789
222
|
_orbit;
|
|
@@ -813,9 +246,9 @@ let De = class extends Mt {
|
|
|
813
246
|
addFigure(t) {
|
|
814
247
|
const e = super.addFigure(t);
|
|
815
248
|
e.layers.enable(0);
|
|
816
|
-
const s = new
|
|
249
|
+
const s = new a.EdgesGeometry(e.geometry), i = new a.LineSegments(
|
|
817
250
|
s,
|
|
818
|
-
new
|
|
251
|
+
new a.LineBasicMaterial({ color: 8947848, linewidth: 1 })
|
|
819
252
|
);
|
|
820
253
|
return i.layers.set(1), e.add(i), e;
|
|
821
254
|
}
|
|
@@ -849,15 +282,15 @@ let De = class extends Mt {
|
|
|
849
282
|
setRaycastMode(t) {
|
|
850
283
|
const e = this._raycaster;
|
|
851
284
|
switch (e.params.Line.threshold = 0, e.params.Points.threshold = 0, t) {
|
|
852
|
-
case
|
|
853
|
-
case
|
|
285
|
+
case M.Mesh:
|
|
286
|
+
case M.Face:
|
|
854
287
|
e.layers.set(0);
|
|
855
288
|
break;
|
|
856
|
-
case
|
|
857
|
-
e.layers.set(1), e.params.Line.threshold =
|
|
289
|
+
case M.Edge:
|
|
290
|
+
e.layers.set(1), e.params.Line.threshold = Ke;
|
|
858
291
|
break;
|
|
859
|
-
case
|
|
860
|
-
e.layers.set(2), e.params.Points.threshold =
|
|
292
|
+
case M.Vertex:
|
|
293
|
+
e.layers.set(2), e.params.Points.threshold = Ge;
|
|
861
294
|
break;
|
|
862
295
|
}
|
|
863
296
|
}
|
|
@@ -877,27 +310,27 @@ let De = class extends Mt {
|
|
|
877
310
|
}
|
|
878
311
|
/** Обработчик события для hover */
|
|
879
312
|
_handleMouseMove = (t) => {
|
|
880
|
-
this._processRaycastEvent(t,
|
|
313
|
+
this._processRaycastEvent(t, L.SelectHover, !0);
|
|
881
314
|
};
|
|
882
315
|
/** Обработчик события на click */
|
|
883
316
|
_handleMouseClick = (t) => {
|
|
884
|
-
this._processRaycastEvent(t,
|
|
317
|
+
this._processRaycastEvent(t, L.SelectClick, !1);
|
|
885
318
|
};
|
|
886
319
|
/** Вспомогательный метод для получения модели, которую выбрали и отправки события в event bus */
|
|
887
320
|
_processRaycastEvent(t, e, s) {
|
|
888
321
|
if (this._orbit.isInteracting || this._transform.dragging) return;
|
|
889
322
|
const i = this._canvas.getBoundingClientRect();
|
|
890
323
|
this._mouse.x = (t.clientX - i.left) / i.width * 2 - 1, this._mouse.y = -((t.clientY - i.top) / i.height) * 2 + 1, this._raycaster.setFromCamera(this._mouse, this.camera);
|
|
891
|
-
const
|
|
892
|
-
s ? n !== this._lastHovered && (this.meshes.forEach((
|
|
324
|
+
const o = this._raycaster.intersectObjects(this.meshes, !0)[0] ?? null, n = o?.object ?? null;
|
|
325
|
+
s ? n !== this._lastHovered && (this.meshes.forEach((c) => c.userData.isHit = !1), n && (n.userData.isHit = !0), this._lastHovered = n, this._bus.emit(e, o ? { intersection: o } : null)) : this._bus.emit(e, o ? { intersection: o } : null);
|
|
893
326
|
}
|
|
894
327
|
};
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
],
|
|
900
|
-
const
|
|
328
|
+
z = Qe([
|
|
329
|
+
u(),
|
|
330
|
+
ge(0, l("Canvas")),
|
|
331
|
+
ge(1, l("EventBus"))
|
|
332
|
+
], z);
|
|
333
|
+
const be = { type: "change" }, oe = { type: "start" }, Ae = { type: "end" }, I = new Ie(), ve = new He(), Je = Math.cos(70 * ke.DEG2RAD), _ = new E(), m = 2 * Math.PI, h = {
|
|
901
334
|
NONE: -1,
|
|
902
335
|
ROTATE: 0,
|
|
903
336
|
DOLLY: 1,
|
|
@@ -906,8 +339,8 @@ const at = { type: "change" }, Ue = { type: "start" }, Pt = { type: "end" }, ye
|
|
|
906
339
|
TOUCH_PAN: 4,
|
|
907
340
|
TOUCH_DOLLY_PAN: 5,
|
|
908
341
|
TOUCH_DOLLY_ROTATE: 6
|
|
909
|
-
},
|
|
910
|
-
class
|
|
342
|
+
}, Y = 1e-6;
|
|
343
|
+
class et extends xe {
|
|
911
344
|
/**
|
|
912
345
|
* Constructs a new controls instance.
|
|
913
346
|
*
|
|
@@ -915,7 +348,7 @@ class ds extends yt {
|
|
|
915
348
|
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
916
349
|
*/
|
|
917
350
|
constructor(e, s = null) {
|
|
918
|
-
super(e, s), this.state =
|
|
351
|
+
super(e, s), this.state = h.NONE, this.target = new E(), this.cursor = new E(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: T.ROTATE, MIDDLE: T.DOLLY, RIGHT: T.PAN }, this.touches = { ONE: D.ROTATE, TWO: D.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new E(), this._lastQuaternion = new me(), this._lastTargetPosition = new E(), this._quat = new me().setFromUnitVectors(e.up, new E(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new fe(), this._sphericalDelta = new fe(), this._scale = 1, this._panOffset = new E(), this._rotateStart = new v(), this._rotateEnd = new v(), this._rotateDelta = new v(), this._panStart = new v(), this._panEnd = new v(), this._panDelta = new v(), this._dollyStart = new v(), this._dollyEnd = new v(), this._dollyDelta = new v(), this._dollyDirection = new E(), this._mouse = new v(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = st.bind(this), this._onPointerDown = tt.bind(this), this._onPointerUp = it.bind(this), this._onContextMenu = ct.bind(this), this._onMouseWheel = nt.bind(this), this._onKeyDown = at.bind(this), this._onTouchStart = ht.bind(this), this._onTouchMove = lt.bind(this), this._onMouseDown = rt.bind(this), this._onMouseMove = ot.bind(this), this._interceptControlDown = dt.bind(this), this._interceptControlUp = _t.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
919
352
|
}
|
|
920
353
|
connect(e) {
|
|
921
354
|
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
|
|
@@ -976,45 +409,45 @@ class ds extends yt {
|
|
|
976
409
|
* was called, or the initial state.
|
|
977
410
|
*/
|
|
978
411
|
reset() {
|
|
979
|
-
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(
|
|
412
|
+
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(be), this.update(), this.state = h.NONE;
|
|
980
413
|
}
|
|
981
414
|
update(e = null) {
|
|
982
415
|
const s = this.object.position;
|
|
983
|
-
|
|
984
|
-
let i = this.minAzimuthAngle,
|
|
985
|
-
isFinite(i) && isFinite(
|
|
986
|
-
let
|
|
416
|
+
_.copy(s).sub(this.target), _.applyQuaternion(this._quat), this._spherical.setFromVector3(_), this.autoRotate && this.state === h.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
|
|
417
|
+
let i = this.minAzimuthAngle, r = this.maxAzimuthAngle;
|
|
418
|
+
isFinite(i) && isFinite(r) && (i < -Math.PI ? i += m : i > Math.PI && (i -= m), r < -Math.PI ? r += m : r > Math.PI && (r -= m), i <= r ? this._spherical.theta = Math.max(i, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (i + r) / 2 ? Math.max(i, this._spherical.theta) : Math.min(r, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
|
|
419
|
+
let o = !1;
|
|
987
420
|
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
|
|
988
421
|
this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
989
422
|
else {
|
|
990
423
|
const n = this._spherical.radius;
|
|
991
|
-
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale),
|
|
424
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), o = n != this._spherical.radius;
|
|
992
425
|
}
|
|
993
|
-
if (
|
|
426
|
+
if (_.setFromSpherical(this._spherical), _.applyQuaternion(this._quatInverse), s.copy(this.target).add(_), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
|
|
994
427
|
let n = null;
|
|
995
428
|
if (this.object.isPerspectiveCamera) {
|
|
996
|
-
const
|
|
997
|
-
n = this._clampDistance(
|
|
998
|
-
const
|
|
999
|
-
this.object.position.addScaledVector(this._dollyDirection,
|
|
429
|
+
const c = _.length();
|
|
430
|
+
n = this._clampDistance(c * this._scale);
|
|
431
|
+
const p = c - n;
|
|
432
|
+
this.object.position.addScaledVector(this._dollyDirection, p), this.object.updateMatrixWorld(), o = !!p;
|
|
1000
433
|
} else if (this.object.isOrthographicCamera) {
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1003
|
-
const
|
|
1004
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(),
|
|
1005
|
-
const
|
|
1006
|
-
|
|
434
|
+
const c = new E(this._mouse.x, this._mouse.y, 0);
|
|
435
|
+
c.unproject(this.object);
|
|
436
|
+
const p = this.object.zoom;
|
|
437
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), o = p !== this.object.zoom;
|
|
438
|
+
const f = new E(this._mouse.x, this._mouse.y, 0);
|
|
439
|
+
f.unproject(this.object), this.object.position.sub(f).add(c), this.object.updateMatrixWorld(), n = _.length();
|
|
1007
440
|
} else
|
|
1008
441
|
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
|
|
1009
|
-
n !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position) : (
|
|
442
|
+
n !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position) : (I.origin.copy(this.object.position), I.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(I.direction)) < Je ? this.object.lookAt(this.target) : (ve.setFromNormalAndCoplanarPoint(this.object.up, this.target), I.intersectPlane(ve, this.target))));
|
|
1010
443
|
} else if (this.object.isOrthographicCamera) {
|
|
1011
444
|
const n = this.object.zoom;
|
|
1012
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), n !== this.object.zoom && (this.object.updateProjectionMatrix(),
|
|
445
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), n !== this.object.zoom && (this.object.updateProjectionMatrix(), o = !0);
|
|
1013
446
|
}
|
|
1014
|
-
return this._scale = 1, this._performCursorZoom = !1,
|
|
447
|
+
return this._scale = 1, this._performCursorZoom = !1, o || this._lastPosition.distanceToSquared(this.object.position) > Y || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Y || this._lastTargetPosition.distanceToSquared(this.target) > Y ? (this.dispatchEvent(be), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
|
|
1015
448
|
}
|
|
1016
449
|
_getAutoRotationAngle(e) {
|
|
1017
|
-
return e !== null ?
|
|
450
|
+
return e !== null ? m / 60 * this.autoRotateSpeed * e : m / 60 / 60 * this.autoRotateSpeed;
|
|
1018
451
|
}
|
|
1019
452
|
_getZoomScale(e) {
|
|
1020
453
|
const s = Math.abs(e * 0.01);
|
|
@@ -1027,19 +460,19 @@ class ds extends yt {
|
|
|
1027
460
|
this._sphericalDelta.phi -= e;
|
|
1028
461
|
}
|
|
1029
462
|
_panLeft(e, s) {
|
|
1030
|
-
|
|
463
|
+
_.setFromMatrixColumn(s, 0), _.multiplyScalar(-e), this._panOffset.add(_);
|
|
1031
464
|
}
|
|
1032
465
|
_panUp(e, s) {
|
|
1033
|
-
this.screenSpacePanning === !0 ?
|
|
466
|
+
this.screenSpacePanning === !0 ? _.setFromMatrixColumn(s, 1) : (_.setFromMatrixColumn(s, 0), _.crossVectors(this.object.up, _)), _.multiplyScalar(e), this._panOffset.add(_);
|
|
1034
467
|
}
|
|
1035
468
|
// deltaX and deltaY are in pixels; right and down are positive
|
|
1036
469
|
_pan(e, s) {
|
|
1037
470
|
const i = this.domElement;
|
|
1038
471
|
if (this.object.isPerspectiveCamera) {
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
let
|
|
1042
|
-
|
|
472
|
+
const r = this.object.position;
|
|
473
|
+
_.copy(r).sub(this.target);
|
|
474
|
+
let o = _.length();
|
|
475
|
+
o *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * o / i.clientHeight, this.object.matrix), this._panUp(2 * s * o / i.clientHeight, this.object.matrix);
|
|
1043
476
|
} else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / i.clientWidth, this.object.matrix), this._panUp(s * (this.object.top - this.object.bottom) / this.object.zoom / i.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
|
|
1044
477
|
}
|
|
1045
478
|
_dollyOut(e) {
|
|
@@ -1052,8 +485,8 @@ class ds extends yt {
|
|
|
1052
485
|
if (!this.zoomToCursor)
|
|
1053
486
|
return;
|
|
1054
487
|
this._performCursorZoom = !0;
|
|
1055
|
-
const i = this.domElement.getBoundingClientRect(),
|
|
1056
|
-
this._mouse.x =
|
|
488
|
+
const i = this.domElement.getBoundingClientRect(), r = e - i.left, o = s - i.top, n = i.width, c = i.height;
|
|
489
|
+
this._mouse.x = r / n * 2 - 1, this._mouse.y = -(o / c) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
1057
490
|
}
|
|
1058
491
|
_clampDistance(e) {
|
|
1059
492
|
return Math.max(this.minDistance, Math.min(this.maxDistance, e));
|
|
@@ -1073,7 +506,7 @@ class ds extends yt {
|
|
|
1073
506
|
_handleMouseMoveRotate(e) {
|
|
1074
507
|
this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1075
508
|
const s = this.domElement;
|
|
1076
|
-
this._rotateLeft(
|
|
509
|
+
this._rotateLeft(m * this._rotateDelta.x / s.clientHeight), this._rotateUp(m * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
|
|
1077
510
|
}
|
|
1078
511
|
_handleMouseMoveDolly(e) {
|
|
1079
512
|
this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
|
|
@@ -1088,16 +521,16 @@ class ds extends yt {
|
|
|
1088
521
|
let s = !1;
|
|
1089
522
|
switch (e.code) {
|
|
1090
523
|
case this.keys.UP:
|
|
1091
|
-
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(
|
|
524
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(m * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), s = !0;
|
|
1092
525
|
break;
|
|
1093
526
|
case this.keys.BOTTOM:
|
|
1094
|
-
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-
|
|
527
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-m * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), s = !0;
|
|
1095
528
|
break;
|
|
1096
529
|
case this.keys.LEFT:
|
|
1097
|
-
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(
|
|
530
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(m * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), s = !0;
|
|
1098
531
|
break;
|
|
1099
532
|
case this.keys.RIGHT:
|
|
1100
|
-
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-
|
|
533
|
+
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-m * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), s = !0;
|
|
1101
534
|
break;
|
|
1102
535
|
}
|
|
1103
536
|
s && (e.preventDefault(), this.update());
|
|
@@ -1106,21 +539,21 @@ class ds extends yt {
|
|
|
1106
539
|
if (this._pointers.length === 1)
|
|
1107
540
|
this._rotateStart.set(e.pageX, e.pageY);
|
|
1108
541
|
else {
|
|
1109
|
-
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x),
|
|
1110
|
-
this._rotateStart.set(i,
|
|
542
|
+
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x), r = 0.5 * (e.pageY + s.y);
|
|
543
|
+
this._rotateStart.set(i, r);
|
|
1111
544
|
}
|
|
1112
545
|
}
|
|
1113
546
|
_handleTouchStartPan(e) {
|
|
1114
547
|
if (this._pointers.length === 1)
|
|
1115
548
|
this._panStart.set(e.pageX, e.pageY);
|
|
1116
549
|
else {
|
|
1117
|
-
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x),
|
|
1118
|
-
this._panStart.set(i,
|
|
550
|
+
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x), r = 0.5 * (e.pageY + s.y);
|
|
551
|
+
this._panStart.set(i, r);
|
|
1119
552
|
}
|
|
1120
553
|
}
|
|
1121
554
|
_handleTouchStartDolly(e) {
|
|
1122
|
-
const s = this._getSecondPointerPosition(e), i = e.pageX - s.x,
|
|
1123
|
-
this._dollyStart.set(0,
|
|
555
|
+
const s = this._getSecondPointerPosition(e), i = e.pageX - s.x, r = e.pageY - s.y, o = Math.sqrt(i * i + r * r);
|
|
556
|
+
this._dollyStart.set(0, o);
|
|
1124
557
|
}
|
|
1125
558
|
_handleTouchStartDollyPan(e) {
|
|
1126
559
|
this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
|
|
@@ -1132,27 +565,27 @@ class ds extends yt {
|
|
|
1132
565
|
if (this._pointers.length == 1)
|
|
1133
566
|
this._rotateEnd.set(e.pageX, e.pageY);
|
|
1134
567
|
else {
|
|
1135
|
-
const i = this._getSecondPointerPosition(e),
|
|
1136
|
-
this._rotateEnd.set(
|
|
568
|
+
const i = this._getSecondPointerPosition(e), r = 0.5 * (e.pageX + i.x), o = 0.5 * (e.pageY + i.y);
|
|
569
|
+
this._rotateEnd.set(r, o);
|
|
1137
570
|
}
|
|
1138
571
|
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1139
572
|
const s = this.domElement;
|
|
1140
|
-
this._rotateLeft(
|
|
573
|
+
this._rotateLeft(m * this._rotateDelta.x / s.clientHeight), this._rotateUp(m * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd);
|
|
1141
574
|
}
|
|
1142
575
|
_handleTouchMovePan(e) {
|
|
1143
576
|
if (this._pointers.length === 1)
|
|
1144
577
|
this._panEnd.set(e.pageX, e.pageY);
|
|
1145
578
|
else {
|
|
1146
|
-
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x),
|
|
1147
|
-
this._panEnd.set(i,
|
|
579
|
+
const s = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + s.x), r = 0.5 * (e.pageY + s.y);
|
|
580
|
+
this._panEnd.set(i, r);
|
|
1148
581
|
}
|
|
1149
582
|
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
|
|
1150
583
|
}
|
|
1151
584
|
_handleTouchMoveDolly(e) {
|
|
1152
|
-
const s = this._getSecondPointerPosition(e), i = e.pageX - s.x,
|
|
1153
|
-
this._dollyEnd.set(0,
|
|
1154
|
-
const n = (e.pageX + s.x) * 0.5,
|
|
1155
|
-
this._updateZoomParameters(n,
|
|
585
|
+
const s = this._getSecondPointerPosition(e), i = e.pageX - s.x, r = e.pageY - s.y, o = Math.sqrt(i * i + r * r);
|
|
586
|
+
this._dollyEnd.set(0, o), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
|
|
587
|
+
const n = (e.pageX + s.x) * 0.5, c = (e.pageY + s.y) * 0.5;
|
|
588
|
+
this._updateZoomParameters(n, c);
|
|
1156
589
|
}
|
|
1157
590
|
_handleTouchMoveDollyPan(e) {
|
|
1158
591
|
this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
|
|
@@ -1179,7 +612,7 @@ class ds extends yt {
|
|
|
1179
612
|
}
|
|
1180
613
|
_trackPointer(e) {
|
|
1181
614
|
let s = this._pointerPositions[e.pointerId];
|
|
1182
|
-
s === void 0 && (s = new
|
|
615
|
+
s === void 0 && (s = new v(), this._pointerPositions[e.pointerId] = s), s.set(e.pageX, e.pageY);
|
|
1183
616
|
}
|
|
1184
617
|
_getSecondPointerPosition(e) {
|
|
1185
618
|
const s = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
@@ -1203,16 +636,16 @@ class ds extends yt {
|
|
|
1203
636
|
return e.ctrlKey && !this._controlActive && (i.deltaY *= 10), i;
|
|
1204
637
|
}
|
|
1205
638
|
}
|
|
1206
|
-
function
|
|
639
|
+
function tt(t) {
|
|
1207
640
|
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(t.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(t) && (this._addPointer(t), t.pointerType === "touch" ? this._onTouchStart(t) : this._onMouseDown(t)));
|
|
1208
641
|
}
|
|
1209
|
-
function
|
|
642
|
+
function st(t) {
|
|
1210
643
|
this.enabled !== !1 && (t.pointerType === "touch" ? this._onTouchMove(t) : this._onMouseMove(t));
|
|
1211
644
|
}
|
|
1212
|
-
function
|
|
645
|
+
function it(t) {
|
|
1213
646
|
switch (this._removePointer(t), this._pointers.length) {
|
|
1214
647
|
case 0:
|
|
1215
|
-
this.domElement.releasePointerCapture(t.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(
|
|
648
|
+
this.domElement.releasePointerCapture(t.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(Ae), this.state = h.NONE;
|
|
1216
649
|
break;
|
|
1217
650
|
case 1:
|
|
1218
651
|
const e = this._pointers[0], s = this._pointerPositions[e];
|
|
@@ -1220,7 +653,7 @@ function us(t) {
|
|
|
1220
653
|
break;
|
|
1221
654
|
}
|
|
1222
655
|
}
|
|
1223
|
-
function
|
|
656
|
+
function rt(t) {
|
|
1224
657
|
let e;
|
|
1225
658
|
switch (t.button) {
|
|
1226
659
|
case 0:
|
|
@@ -1236,126 +669,126 @@ function ms(t) {
|
|
|
1236
669
|
e = -1;
|
|
1237
670
|
}
|
|
1238
671
|
switch (e) {
|
|
1239
|
-
case
|
|
672
|
+
case T.DOLLY:
|
|
1240
673
|
if (this.enableZoom === !1) return;
|
|
1241
|
-
this._handleMouseDownDolly(t), this.state =
|
|
674
|
+
this._handleMouseDownDolly(t), this.state = h.DOLLY;
|
|
1242
675
|
break;
|
|
1243
|
-
case
|
|
676
|
+
case T.ROTATE:
|
|
1244
677
|
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1245
678
|
if (this.enablePan === !1) return;
|
|
1246
|
-
this._handleMouseDownPan(t), this.state =
|
|
679
|
+
this._handleMouseDownPan(t), this.state = h.PAN;
|
|
1247
680
|
} else {
|
|
1248
681
|
if (this.enableRotate === !1) return;
|
|
1249
|
-
this._handleMouseDownRotate(t), this.state =
|
|
682
|
+
this._handleMouseDownRotate(t), this.state = h.ROTATE;
|
|
1250
683
|
}
|
|
1251
684
|
break;
|
|
1252
|
-
case
|
|
685
|
+
case T.PAN:
|
|
1253
686
|
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1254
687
|
if (this.enableRotate === !1) return;
|
|
1255
|
-
this._handleMouseDownRotate(t), this.state =
|
|
688
|
+
this._handleMouseDownRotate(t), this.state = h.ROTATE;
|
|
1256
689
|
} else {
|
|
1257
690
|
if (this.enablePan === !1) return;
|
|
1258
|
-
this._handleMouseDownPan(t), this.state =
|
|
691
|
+
this._handleMouseDownPan(t), this.state = h.PAN;
|
|
1259
692
|
}
|
|
1260
693
|
break;
|
|
1261
694
|
default:
|
|
1262
|
-
this.state =
|
|
695
|
+
this.state = h.NONE;
|
|
1263
696
|
}
|
|
1264
|
-
this.state !==
|
|
697
|
+
this.state !== h.NONE && this.dispatchEvent(oe);
|
|
1265
698
|
}
|
|
1266
|
-
function
|
|
699
|
+
function ot(t) {
|
|
1267
700
|
switch (this.state) {
|
|
1268
|
-
case
|
|
701
|
+
case h.ROTATE:
|
|
1269
702
|
if (this.enableRotate === !1) return;
|
|
1270
703
|
this._handleMouseMoveRotate(t);
|
|
1271
704
|
break;
|
|
1272
|
-
case
|
|
705
|
+
case h.DOLLY:
|
|
1273
706
|
if (this.enableZoom === !1) return;
|
|
1274
707
|
this._handleMouseMoveDolly(t);
|
|
1275
708
|
break;
|
|
1276
|
-
case
|
|
709
|
+
case h.PAN:
|
|
1277
710
|
if (this.enablePan === !1) return;
|
|
1278
711
|
this._handleMouseMovePan(t);
|
|
1279
712
|
break;
|
|
1280
713
|
}
|
|
1281
714
|
}
|
|
1282
|
-
function
|
|
1283
|
-
this.enabled === !1 || this.enableZoom === !1 || this.state !==
|
|
715
|
+
function nt(t) {
|
|
716
|
+
this.enabled === !1 || this.enableZoom === !1 || this.state !== h.NONE || (t.preventDefault(), this.dispatchEvent(oe), this._handleMouseWheel(this._customWheelEvent(t)), this.dispatchEvent(Ae));
|
|
1284
717
|
}
|
|
1285
|
-
function
|
|
718
|
+
function at(t) {
|
|
1286
719
|
this.enabled !== !1 && this._handleKeyDown(t);
|
|
1287
720
|
}
|
|
1288
|
-
function
|
|
721
|
+
function ht(t) {
|
|
1289
722
|
switch (this._trackPointer(t), this._pointers.length) {
|
|
1290
723
|
case 1:
|
|
1291
724
|
switch (this.touches.ONE) {
|
|
1292
|
-
case
|
|
725
|
+
case D.ROTATE:
|
|
1293
726
|
if (this.enableRotate === !1) return;
|
|
1294
|
-
this._handleTouchStartRotate(t), this.state =
|
|
727
|
+
this._handleTouchStartRotate(t), this.state = h.TOUCH_ROTATE;
|
|
1295
728
|
break;
|
|
1296
|
-
case
|
|
729
|
+
case D.PAN:
|
|
1297
730
|
if (this.enablePan === !1) return;
|
|
1298
|
-
this._handleTouchStartPan(t), this.state =
|
|
731
|
+
this._handleTouchStartPan(t), this.state = h.TOUCH_PAN;
|
|
1299
732
|
break;
|
|
1300
733
|
default:
|
|
1301
|
-
this.state =
|
|
734
|
+
this.state = h.NONE;
|
|
1302
735
|
}
|
|
1303
736
|
break;
|
|
1304
737
|
case 2:
|
|
1305
738
|
switch (this.touches.TWO) {
|
|
1306
|
-
case
|
|
739
|
+
case D.DOLLY_PAN:
|
|
1307
740
|
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
1308
|
-
this._handleTouchStartDollyPan(t), this.state =
|
|
741
|
+
this._handleTouchStartDollyPan(t), this.state = h.TOUCH_DOLLY_PAN;
|
|
1309
742
|
break;
|
|
1310
|
-
case
|
|
743
|
+
case D.DOLLY_ROTATE:
|
|
1311
744
|
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
1312
|
-
this._handleTouchStartDollyRotate(t), this.state =
|
|
745
|
+
this._handleTouchStartDollyRotate(t), this.state = h.TOUCH_DOLLY_ROTATE;
|
|
1313
746
|
break;
|
|
1314
747
|
default:
|
|
1315
|
-
this.state =
|
|
748
|
+
this.state = h.NONE;
|
|
1316
749
|
}
|
|
1317
750
|
break;
|
|
1318
751
|
default:
|
|
1319
|
-
this.state =
|
|
752
|
+
this.state = h.NONE;
|
|
1320
753
|
}
|
|
1321
|
-
this.state !==
|
|
754
|
+
this.state !== h.NONE && this.dispatchEvent(oe);
|
|
1322
755
|
}
|
|
1323
|
-
function
|
|
756
|
+
function lt(t) {
|
|
1324
757
|
switch (this._trackPointer(t), this.state) {
|
|
1325
|
-
case
|
|
758
|
+
case h.TOUCH_ROTATE:
|
|
1326
759
|
if (this.enableRotate === !1) return;
|
|
1327
760
|
this._handleTouchMoveRotate(t), this.update();
|
|
1328
761
|
break;
|
|
1329
|
-
case
|
|
762
|
+
case h.TOUCH_PAN:
|
|
1330
763
|
if (this.enablePan === !1) return;
|
|
1331
764
|
this._handleTouchMovePan(t), this.update();
|
|
1332
765
|
break;
|
|
1333
|
-
case
|
|
766
|
+
case h.TOUCH_DOLLY_PAN:
|
|
1334
767
|
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
1335
768
|
this._handleTouchMoveDollyPan(t), this.update();
|
|
1336
769
|
break;
|
|
1337
|
-
case
|
|
770
|
+
case h.TOUCH_DOLLY_ROTATE:
|
|
1338
771
|
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
1339
772
|
this._handleTouchMoveDollyRotate(t), this.update();
|
|
1340
773
|
break;
|
|
1341
774
|
default:
|
|
1342
|
-
this.state =
|
|
775
|
+
this.state = h.NONE;
|
|
1343
776
|
}
|
|
1344
777
|
}
|
|
1345
|
-
function
|
|
778
|
+
function ct(t) {
|
|
1346
779
|
this.enabled !== !1 && t.preventDefault();
|
|
1347
780
|
}
|
|
1348
|
-
function
|
|
781
|
+
function dt(t) {
|
|
1349
782
|
t.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
1350
783
|
}
|
|
1351
|
-
function
|
|
784
|
+
function _t(t) {
|
|
1352
785
|
t.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
1353
786
|
}
|
|
1354
|
-
class
|
|
787
|
+
class ns extends Ce {
|
|
1355
788
|
/** Orbit-контроллер для управления камерой */
|
|
1356
789
|
_orbit;
|
|
1357
790
|
constructor(e) {
|
|
1358
|
-
super(e), this.camera.position.set(1, 1, 7), this.camera.lookAt(0, 0, 0), this._orbit = new
|
|
791
|
+
super(e), this.camera.position.set(1, 1, 7), this.camera.lookAt(0, 0, 0), this._orbit = new et(this.camera, this.canvas), this._orbit.target.set(0, 0, 0), this._orbit.minPolarAngle = Math.PI / 2, this._orbit.maxPolarAngle = Math.PI / 2, this._orbit.enableRotate = !0, this._orbit.enableZoom = !1, this._orbit.enablePan = !1;
|
|
1359
792
|
}
|
|
1360
793
|
/**
|
|
1361
794
|
* Обновление состояния рендерера.
|
|
@@ -1364,7 +797,7 @@ class gi extends Mt {
|
|
|
1364
797
|
this._orbit?.update();
|
|
1365
798
|
}
|
|
1366
799
|
}
|
|
1367
|
-
class
|
|
800
|
+
class as {
|
|
1368
801
|
/** Позиции вершин */
|
|
1369
802
|
_positions = [];
|
|
1370
803
|
/** Нормали вершин */
|
|
@@ -1382,31 +815,31 @@ class yi {
|
|
|
1382
815
|
load(e) {
|
|
1383
816
|
const s = e.split(`
|
|
1384
817
|
`);
|
|
1385
|
-
for (const
|
|
1386
|
-
if (!
|
|
1387
|
-
const
|
|
1388
|
-
switch (
|
|
818
|
+
for (const r of s) {
|
|
819
|
+
if (!r.trim() || r.startsWith("#")) continue;
|
|
820
|
+
const o = r.trim().split(/\s+/);
|
|
821
|
+
switch (o[0]) {
|
|
1389
822
|
case "v":
|
|
1390
|
-
this._tmpPositions.push(
|
|
823
|
+
this._tmpPositions.push(o.slice(1).map(Number));
|
|
1391
824
|
break;
|
|
1392
825
|
case "vn":
|
|
1393
|
-
this._tmpNormals.push(
|
|
826
|
+
this._tmpNormals.push(o.slice(1).map(Number));
|
|
1394
827
|
break;
|
|
1395
828
|
case "vt":
|
|
1396
|
-
this._tmpUVs.push(
|
|
829
|
+
this._tmpUVs.push(o.slice(1).map(Number));
|
|
1397
830
|
break;
|
|
1398
831
|
case "f":
|
|
1399
|
-
this.processFaceLine(
|
|
832
|
+
this.processFaceLine(o);
|
|
1400
833
|
break;
|
|
1401
834
|
}
|
|
1402
835
|
}
|
|
1403
836
|
const i = {
|
|
1404
|
-
type:
|
|
837
|
+
type: y.Custom,
|
|
1405
838
|
position: this._positions,
|
|
1406
839
|
...this._normals.length > 0 && { normal: this._normals },
|
|
1407
840
|
...this._uvs.length > 0 && { uv: this._uvs }
|
|
1408
841
|
};
|
|
1409
|
-
return new
|
|
842
|
+
return new Ne(i);
|
|
1410
843
|
}
|
|
1411
844
|
/**
|
|
1412
845
|
* Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
|
|
@@ -1415,60 +848,60 @@ class yi {
|
|
|
1415
848
|
for (let s = 1; s < e.length; s++) {
|
|
1416
849
|
const i = e[s];
|
|
1417
850
|
if (!i) continue;
|
|
1418
|
-
const [
|
|
1419
|
-
if (
|
|
1420
|
-
const
|
|
1421
|
-
|
|
851
|
+
const [r, o, n] = i.split("/"), c = r ? parseInt(r, 10) : void 0, p = o ? parseInt(o, 10) : void 0, f = n ? parseInt(n, 10) : void 0;
|
|
852
|
+
if (c !== void 0) {
|
|
853
|
+
const g = this._tmpPositions[c - 1];
|
|
854
|
+
g && this._positions.push(...g);
|
|
1422
855
|
}
|
|
1423
|
-
if (
|
|
1424
|
-
const
|
|
1425
|
-
|
|
856
|
+
if (p !== void 0) {
|
|
857
|
+
const g = this._tmpUVs[p - 1];
|
|
858
|
+
g && this._uvs.push(...g);
|
|
1426
859
|
}
|
|
1427
|
-
if (
|
|
1428
|
-
const
|
|
1429
|
-
|
|
860
|
+
if (f !== void 0) {
|
|
861
|
+
const g = this._tmpNormals[f - 1];
|
|
862
|
+
g && this._normals.push(...g);
|
|
1430
863
|
}
|
|
1431
864
|
}
|
|
1432
865
|
}
|
|
1433
866
|
}
|
|
1434
|
-
var
|
|
1435
|
-
for (var
|
|
1436
|
-
(n = t[
|
|
1437
|
-
return
|
|
1438
|
-
},
|
|
1439
|
-
let
|
|
867
|
+
var pt = Object.getOwnPropertyDescriptor, ut = (t, e, s, i) => {
|
|
868
|
+
for (var r = i > 1 ? void 0 : i ? pt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
869
|
+
(n = t[o]) && (r = n(r) || r);
|
|
870
|
+
return r;
|
|
871
|
+
}, ye = (t, e) => (s, i) => e(s, i, t);
|
|
872
|
+
let F = class {
|
|
1440
873
|
constructor(t, e) {
|
|
1441
874
|
this._store = e, this._handlers = new Map(t.map((s) => [s.mode, s]));
|
|
1442
875
|
}
|
|
1443
876
|
/** Текущий режим отображения */
|
|
1444
|
-
_currentMode =
|
|
877
|
+
_currentMode = R.Plane;
|
|
1445
878
|
/** Хендлеры, которые управляют отображением */
|
|
1446
879
|
_handlers;
|
|
1447
880
|
/** Установка режима отображения */
|
|
1448
881
|
manage(t) {
|
|
1449
|
-
t !== this._currentMode && (this._handlers.get(this._currentMode)?.rollback(), t !==
|
|
882
|
+
t !== this._currentMode && (this._handlers.get(this._currentMode)?.rollback(), t !== R.Plane && this._handlers.get(t)?.handle(), this._currentMode = t, this._store.setDisplayMode(this._currentMode));
|
|
1450
883
|
}
|
|
1451
884
|
/** Освобождает ресурсы менеджера. */
|
|
1452
885
|
dispose() {
|
|
1453
|
-
this._handlers && this._handlers.clear(), this._currentMode =
|
|
886
|
+
this._handlers && this._handlers.clear(), this._currentMode = R.Plane, this._store.setDisplayMode(this._currentMode);
|
|
1454
887
|
}
|
|
1455
888
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
],
|
|
1461
|
-
var
|
|
1462
|
-
for (var
|
|
1463
|
-
(n = t[
|
|
1464
|
-
return
|
|
1465
|
-
},
|
|
1466
|
-
let
|
|
889
|
+
F = ut([
|
|
890
|
+
u(),
|
|
891
|
+
ye(0, k("IDisplayHandler")),
|
|
892
|
+
ye(1, l("IEditorStore"))
|
|
893
|
+
], F);
|
|
894
|
+
var S = /* @__PURE__ */ ((t) => (t.Hover = "hover", t.Click = "click", t))(S || {}), mt = Object.getOwnPropertyDescriptor, ft = (t, e, s, i) => {
|
|
895
|
+
for (var r = i > 1 ? void 0 : i ? mt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
896
|
+
(n = t[o]) && (r = n(r) || r);
|
|
897
|
+
return r;
|
|
898
|
+
}, U = (t, e) => (s, i) => e(s, i, t);
|
|
899
|
+
let W = class {
|
|
1467
900
|
constructor(t, e, s) {
|
|
1468
|
-
this._eventBus = t, this._store = s, this._handlers = new Map(e.map((i) => [i.mode, i])), this._eventBus.on(
|
|
901
|
+
this._eventBus = t, this._store = s, this._handlers = new Map(e.map((i) => [i.mode, i])), this._eventBus.on(L.SelectHover, this._onHover), this._eventBus.on(L.SelectClick, this._onClick);
|
|
1469
902
|
}
|
|
1470
903
|
/** Текущий режим выборки */
|
|
1471
|
-
_currentMode =
|
|
904
|
+
_currentMode = M.Mesh;
|
|
1472
905
|
/** Хендлеры, которые управляют выборкой */
|
|
1473
906
|
_handlers;
|
|
1474
907
|
/** Переключает режим выбора */
|
|
@@ -1477,36 +910,36 @@ let Ae = class {
|
|
|
1477
910
|
}
|
|
1478
911
|
/** Обработчик события наведения на модель */
|
|
1479
912
|
_onHover = (t) => {
|
|
1480
|
-
this._handlers.get(this._currentMode)?.handle(t,
|
|
913
|
+
this._handlers.get(this._currentMode)?.handle(t, S.Hover);
|
|
1481
914
|
};
|
|
1482
915
|
/** Обработчик события клика на модель */
|
|
1483
916
|
_onClick = (t) => {
|
|
1484
|
-
this._handlers.get(this._currentMode)?.handle(t,
|
|
917
|
+
this._handlers.get(this._currentMode)?.handle(t, S.Click);
|
|
1485
918
|
};
|
|
1486
919
|
/** Освобождает ресурсы менеджера. */
|
|
1487
920
|
dispose() {
|
|
1488
|
-
this._handlers && this._handlers.clear(), this._eventBus.off(
|
|
921
|
+
this._handlers && this._handlers.clear(), this._eventBus.off(L.SelectHover, this._onHover), this._currentMode = M.Mesh, this._store.setSelectMode(this._currentMode);
|
|
1489
922
|
}
|
|
1490
923
|
};
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
],
|
|
1497
|
-
var
|
|
1498
|
-
for (var
|
|
1499
|
-
(n = t[
|
|
1500
|
-
return
|
|
1501
|
-
},
|
|
1502
|
-
let
|
|
924
|
+
W = ft([
|
|
925
|
+
u(),
|
|
926
|
+
U(0, l("EventBus")),
|
|
927
|
+
U(1, k("ISelectHandler")),
|
|
928
|
+
U(2, l("IEditorStore"))
|
|
929
|
+
], W);
|
|
930
|
+
var gt = Object.getOwnPropertyDescriptor, bt = (t, e, s, i) => {
|
|
931
|
+
for (var r = i > 1 ? void 0 : i ? gt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
932
|
+
(n = t[o]) && (r = n(r) || r);
|
|
933
|
+
return r;
|
|
934
|
+
}, Me = (t, e) => (s, i) => e(s, i, t);
|
|
935
|
+
let Z = class {
|
|
1503
936
|
constructor(t, e) {
|
|
1504
937
|
this._store = e, this._handlers = new Map(t.map((s) => [s.mode, s])), this._unsubSelected = this._store.onSelectedObjectChange(() => {
|
|
1505
938
|
this._handlers.get(this._currentTool)?.handle();
|
|
1506
939
|
});
|
|
1507
940
|
}
|
|
1508
941
|
/** Текущий выбранный инструмент */
|
|
1509
|
-
_currentTool =
|
|
942
|
+
_currentTool = O.Translate;
|
|
1510
943
|
/** Хендлеры, которые управляют инструментами */
|
|
1511
944
|
_handlers;
|
|
1512
945
|
_unsubSelected;
|
|
@@ -1515,22 +948,22 @@ let Le = class {
|
|
|
1515
948
|
}
|
|
1516
949
|
/** Освобождает ресурсы менеджера. */
|
|
1517
950
|
dispose() {
|
|
1518
|
-
this._unsubSelected?.(), this._handlers && this._handlers.clear(), this._currentTool =
|
|
951
|
+
this._unsubSelected?.(), this._handlers && this._handlers.clear(), this._currentTool = O.Translate, this._store.setToolType(this._currentTool);
|
|
1519
952
|
}
|
|
1520
953
|
};
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
],
|
|
1526
|
-
var
|
|
1527
|
-
for (var
|
|
1528
|
-
(n = t[
|
|
1529
|
-
return
|
|
1530
|
-
},
|
|
1531
|
-
let
|
|
954
|
+
Z = bt([
|
|
955
|
+
u(),
|
|
956
|
+
Me(0, k("IToolHandler")),
|
|
957
|
+
Me(1, l("IEditorStore"))
|
|
958
|
+
], Z);
|
|
959
|
+
var vt = Object.getOwnPropertyDescriptor, yt = (t, e, s, i) => {
|
|
960
|
+
for (var r = i > 1 ? void 0 : i ? vt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
961
|
+
(n = t[o]) && (r = n(r) || r);
|
|
962
|
+
return r;
|
|
963
|
+
}, Mt = (t, e) => (s, i) => e(s, i, t);
|
|
964
|
+
let B = class {
|
|
1532
965
|
/** Текущий режим редактирования сцены */
|
|
1533
|
-
_currentMode =
|
|
966
|
+
_currentMode = j.AddFigure;
|
|
1534
967
|
/** Хендлеры, которые управляют отображением */
|
|
1535
968
|
_handlers;
|
|
1536
969
|
constructor(t) {
|
|
@@ -1538,35 +971,35 @@ let Ce = class {
|
|
|
1538
971
|
}
|
|
1539
972
|
/** Установка режима редактирования сцены */
|
|
1540
973
|
manage(t, e) {
|
|
1541
|
-
console.log("manage", t), t ===
|
|
974
|
+
console.log("manage", t), t === j.AddFigure ? this._handlers.get(t)?.handle(e) : this._handlers.get(t)?.handle(), this._currentMode = t;
|
|
1542
975
|
}
|
|
1543
976
|
/** Освобождает ресурсы менеджера. */
|
|
1544
977
|
dispose() {
|
|
1545
|
-
this._handlers && this._handlers.clear(), this._currentMode =
|
|
978
|
+
this._handlers && this._handlers.clear(), this._currentMode = j.AddFigure;
|
|
1546
979
|
}
|
|
1547
980
|
};
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
],
|
|
1552
|
-
var
|
|
1553
|
-
for (var
|
|
1554
|
-
(n = t[
|
|
1555
|
-
return
|
|
1556
|
-
},
|
|
1557
|
-
let
|
|
981
|
+
B = yt([
|
|
982
|
+
u(),
|
|
983
|
+
Mt(0, k("ISceneHandler"))
|
|
984
|
+
], B);
|
|
985
|
+
var Et = Object.getOwnPropertyDescriptor, wt = (t, e, s, i) => {
|
|
986
|
+
for (var r = i > 1 ? void 0 : i ? Et(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
987
|
+
(n = t[o]) && (r = n(r) || r);
|
|
988
|
+
return r;
|
|
989
|
+
}, St = (t, e) => (s, i) => e(s, i, t);
|
|
990
|
+
let X = class {
|
|
1558
991
|
constructor(t) {
|
|
1559
992
|
this._api = t;
|
|
1560
993
|
}
|
|
1561
994
|
/** Режим отображения. */
|
|
1562
|
-
mode =
|
|
995
|
+
mode = R.Wireframe;
|
|
1563
996
|
/** Сохраняем предыдущие значения wireframe для отката. */
|
|
1564
997
|
_prevWireframe = /* @__PURE__ */ new Map();
|
|
1565
998
|
/** Сохраняем исходные цвета материалов для отката */
|
|
1566
999
|
_prevColorMesh = /* @__PURE__ */ new Map();
|
|
1567
1000
|
_prevColorLines = /* @__PURE__ */ new Map();
|
|
1568
1001
|
/** Цвет ребер для wireframe-режима. */
|
|
1569
|
-
_wireColor = new
|
|
1002
|
+
_wireColor = new a.Color(65535);
|
|
1570
1003
|
/** Применяет wireframe-режим к сцене. */
|
|
1571
1004
|
handle() {
|
|
1572
1005
|
const t = this._api.getMeshes();
|
|
@@ -1575,13 +1008,13 @@ let Ie = class {
|
|
|
1575
1008
|
for (const i of s) this._enableWireframeOnMaterial(i);
|
|
1576
1009
|
e.traverse((i) => {
|
|
1577
1010
|
if (i.isLineSegments) {
|
|
1578
|
-
const
|
|
1579
|
-
if (!this._prevColorLines.has(
|
|
1580
|
-
const n =
|
|
1011
|
+
const r = i;
|
|
1012
|
+
if (!this._prevColorLines.has(r.material)) {
|
|
1013
|
+
const n = r.material;
|
|
1581
1014
|
this._prevColorLines.set(n, n.color.clone());
|
|
1582
1015
|
}
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1016
|
+
const o = r.material;
|
|
1017
|
+
o.color.copy(this._wireColor), o.needsUpdate = !0;
|
|
1585
1018
|
}
|
|
1586
1019
|
});
|
|
1587
1020
|
}
|
|
@@ -1610,35 +1043,35 @@ let Ie = class {
|
|
|
1610
1043
|
"wireframe" in e && !this._prevWireframe.has(t) && (this._prevWireframe.set(t, !!e.wireframe), e.wireframe = !0, t.needsUpdate = !0), e.color?.isColor && (this._prevColorMesh.has(t) || this._prevColorMesh.set(t, e.color.clone()), e.color.copy(this._wireColor));
|
|
1611
1044
|
}
|
|
1612
1045
|
};
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
],
|
|
1617
|
-
const
|
|
1618
|
-
var
|
|
1619
|
-
for (var
|
|
1620
|
-
(n = t[
|
|
1621
|
-
return
|
|
1622
|
-
},
|
|
1623
|
-
let
|
|
1046
|
+
X = wt([
|
|
1047
|
+
u(),
|
|
1048
|
+
St(0, l("RendererApi"))
|
|
1049
|
+
], X);
|
|
1050
|
+
const ne = 16776960, ae = 16755200, Pt = 2236962;
|
|
1051
|
+
var Ot = Object.getOwnPropertyDescriptor, Dt = (t, e, s, i) => {
|
|
1052
|
+
for (var r = i > 1 ? void 0 : i ? Ot(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1053
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1054
|
+
return r;
|
|
1055
|
+
}, Ee = (t, e) => (s, i) => e(s, i, t);
|
|
1056
|
+
let V = class {
|
|
1624
1057
|
constructor(t, e) {
|
|
1625
1058
|
this._api = t, this._store = e;
|
|
1626
1059
|
}
|
|
1627
1060
|
/** Режим, которым управляет хендлер, нужен только менеджеру */
|
|
1628
|
-
mode =
|
|
1061
|
+
mode = M.Mesh;
|
|
1629
1062
|
/** Фигура, на которую навелись в данный момент */
|
|
1630
1063
|
_hoveredMesh = null;
|
|
1631
1064
|
/** Фигура, которую выбрали в данный момент */
|
|
1632
1065
|
_selectedMesh = null;
|
|
1633
1066
|
// Цвета, необходимые для переключения
|
|
1634
1067
|
/** Цвет ребер для фигуры, на которую навелись */
|
|
1635
|
-
_hoverColor =
|
|
1068
|
+
_hoverColor = ne;
|
|
1636
1069
|
/** Цвет ребер для выделенной фигуры */
|
|
1637
|
-
_selectColor =
|
|
1070
|
+
_selectColor = ae;
|
|
1638
1071
|
/** Исходные цвета материалов линий для отката */
|
|
1639
1072
|
_origLineColors = /* @__PURE__ */ new WeakMap();
|
|
1640
1073
|
handle(t, e) {
|
|
1641
|
-
if (this._api.setRaycastMode(this.mode), e ===
|
|
1074
|
+
if (this._api.setRaycastMode(this.mode), e === S.Hover) {
|
|
1642
1075
|
if (!t) {
|
|
1643
1076
|
this._hoveredMesh && this._hoveredMesh !== this._selectedMesh && this._restoreEdgesColor(this._hoveredMesh), this._hoveredMesh = null;
|
|
1644
1077
|
return;
|
|
@@ -1646,7 +1079,7 @@ let je = class {
|
|
|
1646
1079
|
const s = t.intersection.object;
|
|
1647
1080
|
this._hoveredMesh !== s && (this._hoveredMesh && this._hoveredMesh !== this._selectedMesh && this._restoreEdgesColor(this._hoveredMesh), s !== this._selectedMesh && this._paintEdges(s, this._hoverColor), this._hoveredMesh = s);
|
|
1648
1081
|
}
|
|
1649
|
-
if (e ===
|
|
1082
|
+
if (e === S.Click) {
|
|
1650
1083
|
if (!t) {
|
|
1651
1084
|
this._selectedMesh && (this._restoreEdgesColor(this._selectedMesh), this._selectedMesh = null, this._store.setSelectedObject(null));
|
|
1652
1085
|
return;
|
|
@@ -1669,8 +1102,8 @@ let je = class {
|
|
|
1669
1102
|
t.children.forEach((s) => {
|
|
1670
1103
|
const i = s;
|
|
1671
1104
|
if (i.isLineSegments && i.material) {
|
|
1672
|
-
const
|
|
1673
|
-
this._origLineColors.has(i) || this._origLineColors.set(i,
|
|
1105
|
+
const r = i.material;
|
|
1106
|
+
this._origLineColors.has(i) || this._origLineColors.set(i, r.color.clone()), r.color.setHex(e), r.needsUpdate = !0;
|
|
1674
1107
|
}
|
|
1675
1108
|
});
|
|
1676
1109
|
}
|
|
@@ -1684,42 +1117,42 @@ let je = class {
|
|
|
1684
1117
|
if (s.isLineSegments && s.material) {
|
|
1685
1118
|
const i = this._origLineColors.get(s);
|
|
1686
1119
|
if (i) {
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1120
|
+
const r = s.material;
|
|
1121
|
+
r.color.copy(i), r.needsUpdate = !0;
|
|
1689
1122
|
}
|
|
1690
1123
|
}
|
|
1691
1124
|
});
|
|
1692
1125
|
}
|
|
1693
1126
|
};
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
],
|
|
1699
|
-
var
|
|
1700
|
-
for (var
|
|
1701
|
-
(n = t[
|
|
1702
|
-
return
|
|
1703
|
-
},
|
|
1704
|
-
let
|
|
1127
|
+
V = Dt([
|
|
1128
|
+
u(),
|
|
1129
|
+
Ee(0, l("RendererApi")),
|
|
1130
|
+
Ee(1, l("IEditorStore"))
|
|
1131
|
+
], V);
|
|
1132
|
+
var Tt = Object.getOwnPropertyDescriptor, Lt = (t, e, s, i) => {
|
|
1133
|
+
for (var r = i > 1 ? void 0 : i ? Tt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1134
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1135
|
+
return r;
|
|
1136
|
+
}, Ct = (t, e) => (s, i) => e(s, i, t);
|
|
1137
|
+
let K = class {
|
|
1705
1138
|
constructor(t) {
|
|
1706
1139
|
this._api = t;
|
|
1707
1140
|
}
|
|
1708
1141
|
/** Режим, которым управляет хендлер, нужен только менеджеру */
|
|
1709
|
-
mode =
|
|
1142
|
+
mode = M.Face;
|
|
1710
1143
|
/** Текущая наведённая грань */
|
|
1711
1144
|
_hovered = null;
|
|
1712
1145
|
/** Текущая выбранная грань */
|
|
1713
1146
|
_selected = null;
|
|
1714
1147
|
// Цвета, необходимые для переключения
|
|
1715
1148
|
/** Цвет грани, на которую навелись */
|
|
1716
|
-
_hoverColor =
|
|
1149
|
+
_hoverColor = ne;
|
|
1717
1150
|
/** Цвет выделенной граней */
|
|
1718
|
-
_selectColor =
|
|
1151
|
+
_selectColor = ae;
|
|
1719
1152
|
/** Изначальный цвет граней у модели, перед наложением эффектов*/
|
|
1720
1153
|
_defaultColor = 2236962;
|
|
1721
1154
|
handle(t, e) {
|
|
1722
|
-
this._api.setRaycastMode(this.mode), e ===
|
|
1155
|
+
this._api.setRaycastMode(this.mode), e === S.Hover && console.log(t), e === S.Click && console.log(t);
|
|
1723
1156
|
}
|
|
1724
1157
|
rollback() {
|
|
1725
1158
|
throw new Error("Method not implemented.");
|
|
@@ -1729,11 +1162,11 @@ let Re = class {
|
|
|
1729
1162
|
throw new Error("Method not implemented.");
|
|
1730
1163
|
}
|
|
1731
1164
|
};
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
],
|
|
1736
|
-
class
|
|
1165
|
+
K = Lt([
|
|
1166
|
+
u(),
|
|
1167
|
+
Ct(0, l("RendererApi"))
|
|
1168
|
+
], K);
|
|
1169
|
+
class he {
|
|
1737
1170
|
constructor(e, s) {
|
|
1738
1171
|
this.api = e, this.store = s;
|
|
1739
1172
|
}
|
|
@@ -1757,69 +1190,69 @@ class Ge {
|
|
|
1757
1190
|
this.rollback();
|
|
1758
1191
|
}
|
|
1759
1192
|
}
|
|
1760
|
-
var
|
|
1761
|
-
for (var
|
|
1762
|
-
(n = t[
|
|
1763
|
-
return
|
|
1764
|
-
},
|
|
1765
|
-
let
|
|
1193
|
+
var At = Object.getOwnPropertyDescriptor, Rt = (t, e, s, i) => {
|
|
1194
|
+
for (var r = i > 1 ? void 0 : i ? At(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1195
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1196
|
+
return r;
|
|
1197
|
+
}, we = (t, e) => (s, i) => e(s, i, t);
|
|
1198
|
+
let G = class extends he {
|
|
1766
1199
|
/** Инструмент, которым управляет хендлер, нужен только менеджеру */
|
|
1767
|
-
mode =
|
|
1200
|
+
mode = O.Translate;
|
|
1768
1201
|
constructor(t, e) {
|
|
1769
1202
|
super(t, e);
|
|
1770
1203
|
}
|
|
1771
1204
|
};
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
],
|
|
1777
|
-
var
|
|
1778
|
-
for (var
|
|
1779
|
-
(n = t[
|
|
1780
|
-
return
|
|
1781
|
-
},
|
|
1782
|
-
let
|
|
1205
|
+
G = Rt([
|
|
1206
|
+
u(),
|
|
1207
|
+
we(0, l("RendererApi")),
|
|
1208
|
+
we(1, l("IEditorStore"))
|
|
1209
|
+
], G);
|
|
1210
|
+
var jt = Object.getOwnPropertyDescriptor, xt = (t, e, s, i) => {
|
|
1211
|
+
for (var r = i > 1 ? void 0 : i ? jt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1212
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1213
|
+
return r;
|
|
1214
|
+
}, Se = (t, e) => (s, i) => e(s, i, t);
|
|
1215
|
+
let q = class extends he {
|
|
1783
1216
|
/** Инструмент, которым управляет хендлер, нужен только менеджеру */
|
|
1784
|
-
mode =
|
|
1217
|
+
mode = O.Scale;
|
|
1785
1218
|
constructor(t, e) {
|
|
1786
1219
|
super(t, e);
|
|
1787
1220
|
}
|
|
1788
1221
|
};
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
],
|
|
1794
|
-
var
|
|
1795
|
-
for (var
|
|
1796
|
-
(n = t[
|
|
1797
|
-
return
|
|
1798
|
-
},
|
|
1799
|
-
let
|
|
1222
|
+
q = xt([
|
|
1223
|
+
u(),
|
|
1224
|
+
Se(0, l("RendererApi")),
|
|
1225
|
+
Se(1, l("IEditorStore"))
|
|
1226
|
+
], q);
|
|
1227
|
+
var It = Object.getOwnPropertyDescriptor, Ht = (t, e, s, i) => {
|
|
1228
|
+
for (var r = i > 1 ? void 0 : i ? It(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1229
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1230
|
+
return r;
|
|
1231
|
+
}, Pe = (t, e) => (s, i) => e(s, i, t);
|
|
1232
|
+
let Q = class extends he {
|
|
1800
1233
|
/** Инструмент, которым управляет хендлер, нужен только менеджеру */
|
|
1801
|
-
mode =
|
|
1234
|
+
mode = O.Rotate;
|
|
1802
1235
|
constructor(t, e) {
|
|
1803
1236
|
super(t, e);
|
|
1804
1237
|
}
|
|
1805
1238
|
};
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
],
|
|
1811
|
-
const
|
|
1812
|
-
var
|
|
1813
|
-
for (var
|
|
1814
|
-
(n = t[
|
|
1815
|
-
return
|
|
1816
|
-
},
|
|
1817
|
-
let
|
|
1239
|
+
Q = Ht([
|
|
1240
|
+
u(),
|
|
1241
|
+
Pe(0, l("RendererApi")),
|
|
1242
|
+
Pe(1, l("IEditorStore"))
|
|
1243
|
+
], Q);
|
|
1244
|
+
const H = 31;
|
|
1245
|
+
var kt = Object.getOwnPropertyDescriptor, Nt = (t, e, s, i) => {
|
|
1246
|
+
for (var r = i > 1 ? void 0 : i ? kt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1247
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1248
|
+
return r;
|
|
1249
|
+
}, Oe = (t, e) => (s, i) => e(s, i, t);
|
|
1250
|
+
let J = class {
|
|
1818
1251
|
constructor(t, e) {
|
|
1819
|
-
this._api = t, this._store = e, this._api.enableCameraLayer(
|
|
1252
|
+
this._api = t, this._store = e, this._api.enableCameraLayer(H), this._hoverLine = this._makeOverlayLine(this._hoverColor), this._selectLine = this._makeOverlayLine(this._selectColor), this._api.addObject(this._hoverLine, H), this._api.addObject(this._selectLine, H);
|
|
1820
1253
|
}
|
|
1821
1254
|
/** Режим, которым управляет хендлер, нужен только менеджеру */
|
|
1822
|
-
mode =
|
|
1255
|
+
mode = M.Edge;
|
|
1823
1256
|
/** Текущее наведённое ребро. */
|
|
1824
1257
|
_hoverLine;
|
|
1825
1258
|
/** Текущее выбранное ребро. */
|
|
@@ -1830,33 +1263,33 @@ let Ze = class {
|
|
|
1830
1263
|
_selected = null;
|
|
1831
1264
|
// Цвета, необходимые для переключения
|
|
1832
1265
|
/** Цвет ребра, на которое навелись */
|
|
1833
|
-
_hoverColor =
|
|
1266
|
+
_hoverColor = ne;
|
|
1834
1267
|
/** Цвет выделенного ребра */
|
|
1835
|
-
_selectColor =
|
|
1268
|
+
_selectColor = ae;
|
|
1836
1269
|
/** Обработка текущего режима выборки. */
|
|
1837
1270
|
handle(t, e) {
|
|
1838
|
-
if (this._api.setRaycastMode(this.mode), e ===
|
|
1271
|
+
if (this._api.setRaycastMode(this.mode), e === S.Hover) {
|
|
1839
1272
|
if (!t) {
|
|
1840
1273
|
this._hoverLine.visible = !1, this._hovered = null;
|
|
1841
1274
|
return;
|
|
1842
1275
|
}
|
|
1843
1276
|
const s = t.intersection.object;
|
|
1844
1277
|
if (!s?.isLineSegments) return;
|
|
1845
|
-
const i = s,
|
|
1846
|
-
if (
|
|
1847
|
-
this._selected && this._same({ lines: i, seg:
|
|
1278
|
+
const i = s, r = Math.floor((t.intersection.index ?? -1) / 2);
|
|
1279
|
+
if (r < 0) return;
|
|
1280
|
+
this._selected && this._same({ lines: i, seg: r }, this._selected) ? this._hoverLine.visible = !1 : (this._writeWorldSegment(this._hoverLine, i, r), this._hoverLine.visible = !0), this._hovered = { lines: i, seg: r };
|
|
1848
1281
|
return;
|
|
1849
1282
|
}
|
|
1850
|
-
if (e ===
|
|
1283
|
+
if (e === S.Click) {
|
|
1851
1284
|
if (!t) {
|
|
1852
1285
|
this._selectLine.visible = !1, this._selected = null, this._store.setSelectedObject(null);
|
|
1853
1286
|
return;
|
|
1854
1287
|
}
|
|
1855
1288
|
const s = t.intersection.object;
|
|
1856
1289
|
if (!s?.isLineSegments) return;
|
|
1857
|
-
const i = s,
|
|
1858
|
-
if (
|
|
1859
|
-
this._writeWorldSegment(this._selectLine, i,
|
|
1290
|
+
const i = s, r = Math.floor((t.intersection.index ?? -1) / 2);
|
|
1291
|
+
if (r < 0) return;
|
|
1292
|
+
this._writeWorldSegment(this._selectLine, i, r), this._centerAndOrientLineOnSegment(this._selectLine, i, r), this._selectLine.visible = !0, this._prepareEdgeMetadata(i, r), this._store.setSelectedObject(this._selectLine), this._selected = { lines: i, seg: r }, this._hovered && this._same(this._hovered, this._selected) && (this._hoverLine.visible = !1);
|
|
1860
1293
|
}
|
|
1861
1294
|
}
|
|
1862
1295
|
/** Откат текущего режима выборки */
|
|
@@ -1867,77 +1300,114 @@ let Ze = class {
|
|
|
1867
1300
|
dispose() {
|
|
1868
1301
|
this.rollback(), this._api.removeObject(this._hoverLine), this._api.removeObject(this._selectLine), this._hoverLine.geometry.dispose(), this._hoverLine.material.dispose(), this._selectLine.geometry.dispose(), this._selectLine.material.dispose();
|
|
1869
1302
|
}
|
|
1303
|
+
/** Инициализация буферных линий для режима (hover и click).
|
|
1304
|
+
* На весь режим будет использовано 2 глобальных линии на сцене,
|
|
1305
|
+
* использоваться они будут только для обозначения геометрии ребер конкретной фигуры.
|
|
1306
|
+
*/
|
|
1870
1307
|
_makeOverlayLine(t) {
|
|
1871
|
-
const e = new
|
|
1872
|
-
e.setAttribute("position", new
|
|
1873
|
-
const s = new
|
|
1308
|
+
const e = new a.BufferGeometry();
|
|
1309
|
+
e.setAttribute("position", new a.Float32BufferAttribute(6, 3));
|
|
1310
|
+
const s = new a.LineBasicMaterial({
|
|
1874
1311
|
color: t,
|
|
1875
1312
|
depthTest: !1,
|
|
1876
1313
|
depthWrite: !1,
|
|
1877
1314
|
transparent: !0,
|
|
1878
1315
|
opacity: 1
|
|
1879
|
-
}), i = new
|
|
1316
|
+
}), i = new a.Line(e, s);
|
|
1880
1317
|
return i.renderOrder = 1e3, i.raycast = () => {
|
|
1881
|
-
}, i.layers.set(
|
|
1318
|
+
}, i.layers.set(H), i.visible = !1, i;
|
|
1882
1319
|
}
|
|
1883
1320
|
/** Локальные точки сегмента переводим в target (который висит на сцене) */
|
|
1884
1321
|
_writeWorldSegment(t, e, s) {
|
|
1885
|
-
const i = e.geometry.getAttribute("position"),
|
|
1322
|
+
const i = e.geometry.getAttribute("position"), r = s * 2, o = r + 1, n = new a.Vector3(i.getX(r), i.getY(r), i.getZ(r)).applyMatrix4(
|
|
1886
1323
|
e.matrixWorld
|
|
1887
|
-
),
|
|
1324
|
+
), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
|
|
1888
1325
|
e.matrixWorld
|
|
1889
|
-
),
|
|
1890
|
-
|
|
1326
|
+
), p = t.geometry.getAttribute("position");
|
|
1327
|
+
p.setXYZ(0, n.x, n.y, n.z), p.setXYZ(1, c.x, c.y, c.z), p.needsUpdate = !0;
|
|
1891
1328
|
}
|
|
1892
1329
|
_same(t, e) {
|
|
1893
1330
|
return !!t && !!e && t.lines === e.lines && t.seg === e.seg;
|
|
1894
1331
|
}
|
|
1895
1332
|
/** Центрует `THREE.Line` на сегменте и ориентирует её вдоль ребра */
|
|
1896
1333
|
_centerAndOrientLineOnSegment(t, e, s) {
|
|
1897
|
-
const i = e.geometry.getAttribute("position"),
|
|
1334
|
+
const i = e.geometry.getAttribute("position"), r = s * 2, o = r + 1, n = new a.Vector3(i.getX(r), i.getY(r), i.getZ(r)).applyMatrix4(
|
|
1898
1335
|
e.matrixWorld
|
|
1899
|
-
),
|
|
1336
|
+
), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
|
|
1900
1337
|
e.matrixWorld
|
|
1901
|
-
),
|
|
1902
|
-
if (!isFinite(
|
|
1903
|
-
const
|
|
1904
|
-
t.position.copy(
|
|
1905
|
-
const
|
|
1906
|
-
let
|
|
1907
|
-
(!
|
|
1908
|
-
const
|
|
1909
|
-
t.quaternion.copy(
|
|
1338
|
+
), p = new a.Vector3().subVectors(c, n), f = p.length();
|
|
1339
|
+
if (!isFinite(f) || f === 0) return;
|
|
1340
|
+
const g = new a.Vector3().addVectors(n, c).multiplyScalar(0.5);
|
|
1341
|
+
t.position.copy(g);
|
|
1342
|
+
const x = t.geometry;
|
|
1343
|
+
let w = x.getAttribute("position");
|
|
1344
|
+
(!w || w.count < 2) && (x.setAttribute("position", new a.BufferAttribute(new Float32Array(6), 3)), w = x.getAttribute("position")), w.setXYZ(0, -f / 2, 0, 0), w.setXYZ(1, f / 2, 0, 0), w.needsUpdate = !0, p.normalize();
|
|
1345
|
+
const C = new a.Quaternion().setFromUnitVectors(new a.Vector3(1, 0, 0), p);
|
|
1346
|
+
t.quaternion.copy(C), t.updateMatrixWorld(!0);
|
|
1347
|
+
}
|
|
1348
|
+
/** Поиск родителя ребер (сама фигура) */
|
|
1349
|
+
_findParentMesh(t) {
|
|
1350
|
+
let e = t;
|
|
1351
|
+
for (; e; ) {
|
|
1352
|
+
if (e.isMesh) return e;
|
|
1353
|
+
e = e.parent;
|
|
1354
|
+
}
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
/** Запись метаданных выбранного ребра для использования инструментов */
|
|
1358
|
+
_prepareEdgeMetadata(t, e) {
|
|
1359
|
+
const s = this._findParentMesh(t);
|
|
1360
|
+
if (!s) return;
|
|
1361
|
+
const i = t.geometry.getAttribute("position"), r = e * 2, o = r + 1, n = new a.Vector3(i.getX(r), i.getY(r), i.getZ(r)).applyMatrix4(
|
|
1362
|
+
t.matrixWorld
|
|
1363
|
+
), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
|
|
1364
|
+
t.matrixWorld
|
|
1365
|
+
), p = new a.Matrix4().copy(s.matrixWorld).invert(), f = n.clone().applyMatrix4(p), g = c.clone().applyMatrix4(p), w = s.geometry.getAttribute("position"), C = new a.Vector3(), P = 1e-6, le = [], ce = [];
|
|
1366
|
+
for (let b = 0; b < w.count; b++)
|
|
1367
|
+
C.fromBufferAttribute(w, b), C.distanceToSquared(f) < P * P ? le.push(b) : C.distanceToSquared(g) < P * P && ce.push(b);
|
|
1368
|
+
const de = new a.Matrix4().copy(t.matrixWorld).invert(), Re = n.clone().applyMatrix4(de), je = c.clone().applyMatrix4(de), _e = t.geometry.getAttribute("position"), N = new a.Vector3(), pe = [], ue = [];
|
|
1369
|
+
for (let b = 0; b < _e.count; b++)
|
|
1370
|
+
N.fromBufferAttribute(_e, b), N.distanceToSquared(Re) < P * P ? pe.push(b) : N.distanceToSquared(je) < P * P && ue.push(b);
|
|
1371
|
+
this._selectLine.userData.edgeInfo = {
|
|
1372
|
+
lines: t,
|
|
1373
|
+
seg: e,
|
|
1374
|
+
mesh: s,
|
|
1375
|
+
aIndices: le,
|
|
1376
|
+
bIndices: ce,
|
|
1377
|
+
aEdgeIndices: pe,
|
|
1378
|
+
bEdgeIndices: ue
|
|
1379
|
+
};
|
|
1910
1380
|
}
|
|
1911
1381
|
};
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
],
|
|
1917
|
-
var
|
|
1918
|
-
for (var
|
|
1919
|
-
(n = t[
|
|
1920
|
-
return
|
|
1921
|
-
},
|
|
1922
|
-
let
|
|
1382
|
+
J = Nt([
|
|
1383
|
+
u(),
|
|
1384
|
+
Oe(0, l("RendererApi")),
|
|
1385
|
+
Oe(1, l("IEditorStore"))
|
|
1386
|
+
], J);
|
|
1387
|
+
var Yt = Object.getOwnPropertyDescriptor, Ut = (t, e, s, i) => {
|
|
1388
|
+
for (var r = i > 1 ? void 0 : i ? Yt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1389
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1390
|
+
return r;
|
|
1391
|
+
}, $t = (t, e) => (s, i) => e(s, i, t);
|
|
1392
|
+
let ee = class {
|
|
1923
1393
|
constructor(t) {
|
|
1924
1394
|
this._api = t;
|
|
1925
1395
|
}
|
|
1926
1396
|
/** Режим редактирования сцены */
|
|
1927
|
-
mode =
|
|
1397
|
+
mode = j.AddFigure;
|
|
1928
1398
|
/** Последняя добавленная фигура, нужно для отката через `ctrl + z`. */
|
|
1929
1399
|
_lastAddedMesh = null;
|
|
1930
1400
|
/** Добавление базовых фигур на сцену, которые приписаны в `FigureType`. */
|
|
1931
1401
|
handle(t) {
|
|
1932
|
-
const e =
|
|
1933
|
-
s && s.setUsage && s.setUsage(
|
|
1934
|
-
const i = new
|
|
1402
|
+
const e = Be[t](), s = e.getAttribute("position");
|
|
1403
|
+
s && s.setUsage && s.setUsage(a.DynamicDrawUsage);
|
|
1404
|
+
const i = new a.Mesh(e, Le);
|
|
1935
1405
|
i.layers.enable(0);
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
new
|
|
1406
|
+
const r = new a.EdgesGeometry(i.geometry), o = new a.LineSegments(
|
|
1407
|
+
r,
|
|
1408
|
+
new a.LineBasicMaterial({ color: Pt, linewidth: 1 })
|
|
1939
1409
|
);
|
|
1940
|
-
|
|
1410
|
+
o.layers.set(1), i.add(o), this._api.addMesh(i), this._lastAddedMesh = i;
|
|
1941
1411
|
}
|
|
1942
1412
|
/** Срабатывает только на `ctrl + z`. */
|
|
1943
1413
|
rollback() {
|
|
@@ -1948,27 +1418,27 @@ let ze = class {
|
|
|
1948
1418
|
this._lastAddedMesh = null;
|
|
1949
1419
|
}
|
|
1950
1420
|
};
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
],
|
|
1955
|
-
const
|
|
1956
|
-
var
|
|
1957
|
-
for (var
|
|
1958
|
-
(n = t[
|
|
1959
|
-
return
|
|
1960
|
-
},
|
|
1961
|
-
let
|
|
1421
|
+
ee = Ut([
|
|
1422
|
+
u(),
|
|
1423
|
+
$t(0, l("RendererApi"))
|
|
1424
|
+
], ee);
|
|
1425
|
+
const zt = (t) => !!t && t.isMesh;
|
|
1426
|
+
var Ft = Object.getOwnPropertyDescriptor, Wt = (t, e, s, i) => {
|
|
1427
|
+
for (var r = i > 1 ? void 0 : i ? Ft(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1428
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1429
|
+
return r;
|
|
1430
|
+
}, De = (t, e) => (s, i) => e(s, i, t);
|
|
1431
|
+
let te = class {
|
|
1962
1432
|
constructor(t, e) {
|
|
1963
1433
|
this._api = t, this._store = e;
|
|
1964
1434
|
}
|
|
1965
1435
|
/** Режим редактирования сцены */
|
|
1966
|
-
mode =
|
|
1436
|
+
mode = j.DeleteFigure;
|
|
1967
1437
|
/** Последняя удаленная фигура, сохраняем для отката через `ctrl + z` */
|
|
1968
1438
|
_lastDeletedMesh = null;
|
|
1969
1439
|
handle() {
|
|
1970
1440
|
const t = this._store.getSelectedObject();
|
|
1971
|
-
|
|
1441
|
+
zt(t) && (this._api.removeMesh(t), this._store.setSelectedObject(null), this._lastDeletedMesh = t);
|
|
1972
1442
|
}
|
|
1973
1443
|
/** Срабатывает только на `ctrl + z`. */
|
|
1974
1444
|
rollback() {
|
|
@@ -1979,17 +1449,17 @@ let Xe = class {
|
|
|
1979
1449
|
this._lastDeletedMesh = null;
|
|
1980
1450
|
}
|
|
1981
1451
|
};
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
],
|
|
1987
|
-
var
|
|
1988
|
-
for (var
|
|
1989
|
-
(n = t[
|
|
1990
|
-
return
|
|
1991
|
-
},
|
|
1992
|
-
let
|
|
1452
|
+
te = Wt([
|
|
1453
|
+
u(),
|
|
1454
|
+
De(0, l("RendererApi")),
|
|
1455
|
+
De(1, l("IEditorStore"))
|
|
1456
|
+
], te);
|
|
1457
|
+
var Zt = Object.getOwnPropertyDescriptor, Bt = (t, e, s, i) => {
|
|
1458
|
+
for (var r = i > 1 ? void 0 : i ? Zt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1459
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1460
|
+
return r;
|
|
1461
|
+
}, Xt = (t, e) => (s, i) => e(s, i, t);
|
|
1462
|
+
let se = class {
|
|
1993
1463
|
constructor(t) {
|
|
1994
1464
|
this._renderer = t;
|
|
1995
1465
|
}
|
|
@@ -2044,18 +1514,18 @@ let Ne = class {
|
|
|
2044
1514
|
this._renderer.enableCameraLayer(t);
|
|
2045
1515
|
}
|
|
2046
1516
|
};
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
],
|
|
2051
|
-
var
|
|
2052
|
-
for (var
|
|
2053
|
-
(n = t[
|
|
2054
|
-
return
|
|
2055
|
-
},
|
|
2056
|
-
let
|
|
2057
|
-
constructor(t, e, s, i,
|
|
2058
|
-
this._displayManager = t, this._selectManager = e, this._toolManager = s, this._sceneManager = i, this._renderer =
|
|
1517
|
+
se = Bt([
|
|
1518
|
+
u(),
|
|
1519
|
+
Xt(0, l("EditorRenderer"))
|
|
1520
|
+
], se);
|
|
1521
|
+
var Vt = Object.getOwnPropertyDescriptor, Kt = (t, e, s, i) => {
|
|
1522
|
+
for (var r = i > 1 ? void 0 : i ? Vt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1523
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1524
|
+
return r;
|
|
1525
|
+
}, A = (t, e) => (s, i) => e(s, i, t);
|
|
1526
|
+
let ie = class {
|
|
1527
|
+
constructor(t, e, s, i, r) {
|
|
1528
|
+
this._displayManager = t, this._selectManager = e, this._toolManager = s, this._sceneManager = i, this._renderer = r, this.setSelectMode(M.Mesh), this.setToolMode(O.Translate);
|
|
2059
1529
|
}
|
|
2060
1530
|
setDisplayMode(t) {
|
|
2061
1531
|
this._displayManager.manage(t);
|
|
@@ -2082,32 +1552,32 @@ let Fe = class {
|
|
|
2082
1552
|
this._displayManager.dispose(), this._selectManager.dispose(), this._renderer.dispose();
|
|
2083
1553
|
}
|
|
2084
1554
|
};
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
],
|
|
2093
|
-
var
|
|
2094
|
-
for (var
|
|
2095
|
-
(n = t[
|
|
2096
|
-
return
|
|
1555
|
+
ie = Kt([
|
|
1556
|
+
u(),
|
|
1557
|
+
A(0, l("IDisplayManager")),
|
|
1558
|
+
A(1, l("ISelectManager")),
|
|
1559
|
+
A(2, l("IToolManager")),
|
|
1560
|
+
A(3, l("ISceneManager")),
|
|
1561
|
+
A(4, l("EditorRenderer"))
|
|
1562
|
+
], ie);
|
|
1563
|
+
var Gt = Object.getOwnPropertyDescriptor, qt = (t, e, s, i) => {
|
|
1564
|
+
for (var r = i > 1 ? void 0 : i ? Gt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
1565
|
+
(n = t[o]) && (r = n(r) || r);
|
|
1566
|
+
return r;
|
|
2097
1567
|
};
|
|
2098
|
-
let
|
|
1568
|
+
let re = class {
|
|
2099
1569
|
/** Текущий режим выборки. */
|
|
2100
|
-
_selectMode =
|
|
1570
|
+
_selectMode = M.Mesh;
|
|
2101
1571
|
/** Текущий выбранный инструмент. */
|
|
2102
|
-
_toolType =
|
|
1572
|
+
_toolType = O.Translate;
|
|
2103
1573
|
/** Выбранный режим отображения. */
|
|
2104
|
-
_displayMode =
|
|
1574
|
+
_displayMode = R.Plane;
|
|
2105
1575
|
/** Выбранный объект на сцене. */
|
|
2106
1576
|
_selectedObject = null;
|
|
2107
1577
|
/** Слушатели событий по изменению выбранного объекта. */
|
|
2108
1578
|
_selectedListeners = /* @__PURE__ */ new Set();
|
|
2109
1579
|
constructor() {
|
|
2110
|
-
|
|
1580
|
+
Ze(this, {}, { autoBind: !0 });
|
|
2111
1581
|
}
|
|
2112
1582
|
/** @inheritdoc */
|
|
2113
1583
|
getSelectMode() {
|
|
@@ -2149,24 +1619,24 @@ let Qe = class {
|
|
|
2149
1619
|
return this._selectedListeners.add(t), () => this._selectedListeners.delete(t);
|
|
2150
1620
|
}
|
|
2151
1621
|
};
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
],
|
|
2155
|
-
let
|
|
2156
|
-
const
|
|
2157
|
-
function
|
|
2158
|
-
return
|
|
1622
|
+
re = qt([
|
|
1623
|
+
u()
|
|
1624
|
+
], re);
|
|
1625
|
+
let Te = !1;
|
|
1626
|
+
const d = Fe.createChildContainer();
|
|
1627
|
+
function Qt(t) {
|
|
1628
|
+
return Te || (d.registerInstance("Canvas", t), d.registerSingleton("EventBus", $), d.registerSingleton("EditorRenderer", z), d.registerSingleton("RendererApi", se), d.registerSingleton("IDisplayHandler", X), d.registerSingleton("ISelectHandler", V), d.registerSingleton("ISelectHandler", K), d.registerSingleton("ISelectHandler", J), d.registerSingleton("IToolHandler", G), d.registerSingleton("IToolHandler", q), d.registerSingleton("IToolHandler", Q), d.registerSingleton("ISceneHandler", ee), d.registerSingleton("ISceneHandler", te), d.registerSingleton("IDisplayManager", F), d.registerSingleton("ISelectManager", W), d.registerSingleton("IToolManager", Z), d.registerSingleton("ISceneManager", B), d.registerSingleton("EditorHub", ie), d.registerSingleton("IEditorStore", re), Te = !0), d;
|
|
2159
1629
|
}
|
|
2160
|
-
function
|
|
2161
|
-
return
|
|
1630
|
+
function hs(t) {
|
|
1631
|
+
return Qt(t).resolve("EditorHub");
|
|
2162
1632
|
}
|
|
2163
1633
|
export {
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
1634
|
+
ie as EditorHub,
|
|
1635
|
+
z as EditorRenderer,
|
|
1636
|
+
$ as EventBus,
|
|
1637
|
+
L as EventTopics,
|
|
1638
|
+
as as ObjLoader,
|
|
1639
|
+
ns as PreviewRenderer,
|
|
1640
|
+
Ce as Renderer,
|
|
1641
|
+
hs as createAppHub
|
|
2172
1642
|
};
|