@planara/core 2.5.0 → 2.6.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
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() {
3
+ import { Controls as Ye, Vector3 as D, MOUSE as j, TOUCH as x, Quaternion as be, Spherical as ve, Vector2 as E, Ray as Ue, Plane as We, MathUtils as ze } from "three";
4
+ import { FigureType as P, SelectMode as v, Figure as Ze, DisplayMode as k, ToolType as C, SceneMode as V } from "@planara/types";
5
+ import { SymmetricAxesHelper as $e, OrbitWithState as Fe, CameraAxesGizmo as Be, ModelingTransformControls as Xe } from "@planara/three";
6
+ import { injectable as u, inject as h, injectAll as W, container as Ge } from "tsyringe";
7
+ import { EventEmitter as Ke } from "events";
8
+ import { makeAutoObservable as qe } from "mobx";
9
+ const Qe = {
10
+ [P.Plane]: () => new a.PlaneGeometry(1, 1, 1, 1),
11
+ [P.Cube]: () => new a.BoxGeometry(1, 1, 1, 1, 1, 1),
12
+ [P.UVSphere]: () => new a.SphereGeometry(0.5, 32, 16),
13
+ [P.Icosphere]: () => new a.IcosahedronGeometry(0.5, 0),
14
+ [P.Cylinder]: () => new a.CylinderGeometry(0.5, 0.5, 1, 32, 1, !1),
15
+ [P.Cone]: () => new a.ConeGeometry(0.5, 1, 32, 1, !1),
16
+ [P.Torus]: () => new a.TorusGeometry(0.5, 0.2, 16, 64),
17
+ [P.Circle]: () => new a.CircleGeometry(0.5, 32),
18
+ [P.Sphere]: () => new a.SphereGeometry(0.5, 32, 16),
19
+ [P.Custom]: function() {
20
20
  throw new Error("Custom geometry is not generated here.");
21
21
  }
22
- }, Le = new a.MeshStandardMaterial({
22
+ }, je = new a.MeshStandardMaterial({
23
23
  color: 12566463,
24
24
  metalness: 0,
25
25
  roughness: 0.6
26
- });
27
- class Ce {
26
+ }), Je = 8;
27
+ class Re {
28
28
  /** Корневой объект сцены */
29
29
  scene;
30
30
  /** Камера для сцены */
@@ -81,7 +81,7 @@ class Ce {
81
81
  addFigure(e) {
82
82
  const s = new a.BufferGeometry();
83
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);
84
+ const i = new a.Mesh(s, je);
85
85
  return this.scene.add(i), this.meshes.push(i), i;
86
86
  }
87
87
  /**
@@ -172,15 +172,15 @@ class Ce {
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
- 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--)
175
+ var et = Object.getOwnPropertyDescriptor, tt = (t, e, s, i) => {
176
+ for (var r = i > 1 ? void 0 : i ? et(e, s) : e, o = t.length - 1, n; o >= 0; o--)
177
177
  (n = t[o]) && (r = n(r) || r);
178
178
  return r;
179
179
  };
180
- let $ = class {
180
+ let X = class {
181
181
  _emitter;
182
182
  constructor() {
183
- this._emitter = new We();
183
+ this._emitter = new Ke();
184
184
  }
185
185
  /** Публикация события */
186
186
  emit(t, e) {
@@ -195,28 +195,54 @@ let $ = class {
195
195
  this._emitter.off(t, e);
196
196
  }
197
197
  };
198
- $ = Ve([
198
+ X = tt([
199
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--)
200
+ ], X);
201
+ var R = /* @__PURE__ */ ((t) => (t.SelectHover = "select.hover", t.SelectClick = "select.click", t.ToolSelect = "tool.select", t))(R || {});
202
+ const st = 0.03, it = 0.05, Ie = 0, rt = 1, ot = 2, L = 31, z = 16776960, Z = 16755200, nt = 2236962, at = 2236962, ht = (t) => !!t && t.isMesh, He = (t) => {
203
+ let e = t;
204
+ for (; e; ) {
205
+ if (e.isMesh) return e;
206
+ e = e.parent;
207
+ }
208
+ return null;
209
+ }, ke = (t) => {
210
+ const e = new a.BufferGeometry();
211
+ e.setAttribute("position", t.getAttribute("position")), e.computeBoundingSphere(), e.computeBoundingBox();
212
+ const s = new a.PointsMaterial({
213
+ color: at,
214
+ size: 6,
215
+ sizeAttenuation: !1,
216
+ depthTest: !1,
217
+ depthWrite: !1,
218
+ transparent: !0,
219
+ opacity: 0.9
220
+ }), i = new a.Points(e, s);
221
+ return i.layers.set(ot), i.renderOrder = 1e3, i.visible = !1, i;
222
+ }, Ve = (t) => {
223
+ const e = new a.EdgesGeometry(t), s = new a.LineSegments(
224
+ e,
225
+ new a.LineBasicMaterial({ color: nt, linewidth: 1 })
226
+ );
227
+ return s.layers.set(rt), s;
228
+ };
229
+ var lt = Object.getOwnPropertyDescriptor, ct = (t, e, s, i) => {
230
+ for (var r = i > 1 ? void 0 : i ? lt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
205
231
  (n = t[o]) && (r = n(r) || r);
206
232
  return r;
207
- }, ge = (t, e) => (s, i) => e(s, i, t);
208
- let z = class extends Ce {
233
+ }, ye = (t, e) => (s, i) => e(s, i, t);
234
+ let G = class extends Re {
209
235
  constructor(t, e) {
210
236
  super(t), this._canvas = t, this._bus = e;
211
237
  const s = new a.GridHelper(10, 10);
212
238
  s.position.y = -1e-3, this.scene.add(s);
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, {
239
+ const i = new $e(6);
240
+ this.scene.add(i), this._orbit = new Fe(this.camera, this.renderer.domElement), this._orbit.enableDamping = !0, this._orbit.dampingFactor = 0.05, this._cameraGizmo = new Be(this.renderer, this.camera, {
215
241
  size: 96,
216
242
  // Размер квадрата
217
243
  margin: 36
218
244
  // Отступы по сторонам (снизу и справа)
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();
245
+ }), 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 Xe(this.camera, this.renderer.domElement), this._transformHelper = this._transform.getHelper(), this.scene.add(this._transformHelper), this._isEventListenersAdded || this._initMouseListeners();
220
246
  }
221
247
  /** Orbit-контроллер для управления камерой */
222
248
  _orbit;
@@ -245,12 +271,11 @@ let z = class extends Ce {
245
271
  /** Добавление фигуры на сцену */
246
272
  addFigure(t) {
247
273
  const e = super.addFigure(t);
248
- e.layers.enable(0);
249
- const s = new a.EdgesGeometry(e.geometry), i = new a.LineSegments(
250
- s,
251
- new a.LineBasicMaterial({ color: 8947848, linewidth: 1 })
252
- );
253
- return i.layers.set(1), e.add(i), e;
274
+ e.layers.enable(Ie);
275
+ const s = Ve(e.geometry);
276
+ e.add(s);
277
+ const i = ke(e.geometry);
278
+ return e.add(i), e;
254
279
  }
255
280
  /**
256
281
  * Смена отображения `TransformControls` в зависимости от типа инструмента.
@@ -282,15 +307,15 @@ let z = class extends Ce {
282
307
  setRaycastMode(t) {
283
308
  const e = this._raycaster;
284
309
  switch (e.params.Line.threshold = 0, e.params.Points.threshold = 0, t) {
285
- case M.Mesh:
286
- case M.Face:
310
+ case v.Mesh:
311
+ case v.Face:
287
312
  e.layers.set(0);
288
313
  break;
289
- case M.Edge:
290
- e.layers.set(1), e.params.Line.threshold = Ke;
314
+ case v.Edge:
315
+ e.layers.set(1), e.params.Line.threshold = st;
291
316
  break;
292
- case M.Vertex:
293
- e.layers.set(2), e.params.Points.threshold = Ge;
317
+ case v.Vertex:
318
+ e.layers.set(2), e.params.Points.threshold = it;
294
319
  break;
295
320
  }
296
321
  }
@@ -310,11 +335,11 @@ let z = class extends Ce {
310
335
  }
311
336
  /** Обработчик события для hover */
312
337
  _handleMouseMove = (t) => {
313
- this._processRaycastEvent(t, L.SelectHover, !0);
338
+ this._processRaycastEvent(t, R.SelectHover, !0);
314
339
  };
315
340
  /** Обработчик события на click */
316
341
  _handleMouseClick = (t) => {
317
- this._processRaycastEvent(t, L.SelectClick, !1);
342
+ this._processRaycastEvent(t, R.SelectClick, !1);
318
343
  };
319
344
  /** Вспомогательный метод для получения модели, которую выбрали и отправки события в event bus */
320
345
  _processRaycastEvent(t, e, s) {
@@ -325,12 +350,12 @@ let z = class extends Ce {
325
350
  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);
326
351
  }
327
352
  };
328
- z = Qe([
353
+ G = ct([
329
354
  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 = {
355
+ ye(0, h("Canvas")),
356
+ ye(1, h("EventBus"))
357
+ ], G);
358
+ const Me = { type: "change" }, pe = { type: "start" }, Ne = { type: "end" }, U = new Ue(), we = new We(), dt = Math.cos(70 * ze.DEG2RAD), p = new D(), g = 2 * Math.PI, l = {
334
359
  NONE: -1,
335
360
  ROTATE: 0,
336
361
  DOLLY: 1,
@@ -339,8 +364,8 @@ const be = { type: "change" }, oe = { type: "start" }, Ae = { type: "end" }, I =
339
364
  TOUCH_PAN: 4,
340
365
  TOUCH_DOLLY_PAN: 5,
341
366
  TOUCH_DOLLY_ROTATE: 6
342
- }, Y = 1e-6;
343
- class et extends xe {
367
+ }, F = 1e-6;
368
+ class _t extends Ye {
344
369
  /**
345
370
  * Constructs a new controls instance.
346
371
  *
@@ -348,7 +373,7 @@ class et extends xe {
348
373
  * @param {?HTMLElement} domElement - The HTML element used for event listeners.
349
374
  */
350
375
  constructor(e, s = null) {
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();
376
+ super(e, s), this.state = l.NONE, this.target = new D(), this.cursor = new D(), 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: j.ROTATE, MIDDLE: j.DOLLY, RIGHT: j.PAN }, this.touches = { ONE: x.ROTATE, TWO: x.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new D(), this._lastQuaternion = new be(), this._lastTargetPosition = new D(), this._quat = new be().setFromUnitVectors(e.up, new D(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new ve(), this._sphericalDelta = new ve(), this._scale = 1, this._panOffset = new D(), this._rotateStart = new E(), this._rotateEnd = new E(), this._rotateDelta = new E(), this._panStart = new E(), this._panEnd = new E(), this._panDelta = new E(), this._dollyStart = new E(), this._dollyEnd = new E(), this._dollyDelta = new E(), this._dollyDirection = new D(), this._mouse = new E(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = ut.bind(this), this._onPointerDown = pt.bind(this), this._onPointerUp = mt.bind(this), this._onContextMenu = wt.bind(this), this._onMouseWheel = bt.bind(this), this._onKeyDown = vt.bind(this), this._onTouchStart = yt.bind(this), this._onTouchMove = Mt.bind(this), this._onMouseDown = ft.bind(this), this._onMouseMove = gt.bind(this), this._interceptControlDown = Et.bind(this), this._interceptControlUp = Pt.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
352
377
  }
353
378
  connect(e) {
354
379
  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";
@@ -409,13 +434,13 @@ class et extends xe {
409
434
  * was called, or the initial state.
410
435
  */
411
436
  reset() {
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;
437
+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Me), this.update(), this.state = l.NONE;
413
438
  }
414
439
  update(e = null) {
415
440
  const s = this.object.position;
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);
441
+ p.copy(s).sub(this.target), p.applyQuaternion(this._quat), this._spherical.setFromVector3(p), this.autoRotate && this.state === l.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
442
  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);
443
+ isFinite(i) && isFinite(r) && (i < -Math.PI ? i += g : i > Math.PI && (i -= g), r < -Math.PI ? r += g : r > Math.PI && (r -= g), 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
444
  let o = !1;
420
445
  if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
421
446
  this._spherical.radius = this._clampDistance(this._spherical.radius);
@@ -423,31 +448,31 @@ class et extends xe {
423
448
  const n = this._spherical.radius;
424
449
  this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), o = n != this._spherical.radius;
425
450
  }
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) {
451
+ if (p.setFromSpherical(this._spherical), p.applyQuaternion(this._quatInverse), s.copy(this.target).add(p), 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) {
427
452
  let n = null;
428
453
  if (this.object.isPerspectiveCamera) {
429
- const c = _.length();
454
+ const c = p.length();
430
455
  n = this._clampDistance(c * this._scale);
431
- const p = c - n;
432
- this.object.position.addScaledVector(this._dollyDirection, p), this.object.updateMatrixWorld(), o = !!p;
456
+ const _ = c - n;
457
+ this.object.position.addScaledVector(this._dollyDirection, _), this.object.updateMatrixWorld(), o = !!_;
433
458
  } else if (this.object.isOrthographicCamera) {
434
- const c = new E(this._mouse.x, this._mouse.y, 0);
459
+ const c = new D(this._mouse.x, this._mouse.y, 0);
435
460
  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();
461
+ const _ = this.object.zoom;
462
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), o = _ !== this.object.zoom;
463
+ const m = new D(this._mouse.x, this._mouse.y, 0);
464
+ m.unproject(this.object), this.object.position.sub(m).add(c), this.object.updateMatrixWorld(), n = p.length();
440
465
  } else
441
466
  console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
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))));
467
+ n !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position) : (U.origin.copy(this.object.position), U.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(U.direction)) < dt ? this.object.lookAt(this.target) : (we.setFromNormalAndCoplanarPoint(this.object.up, this.target), U.intersectPlane(we, this.target))));
443
468
  } else if (this.object.isOrthographicCamera) {
444
469
  const n = this.object.zoom;
445
470
  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);
446
471
  }
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;
472
+ return this._scale = 1, this._performCursorZoom = !1, o || this._lastPosition.distanceToSquared(this.object.position) > F || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > F || this._lastTargetPosition.distanceToSquared(this.target) > F ? (this.dispatchEvent(Me), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
448
473
  }
449
474
  _getAutoRotationAngle(e) {
450
- return e !== null ? m / 60 * this.autoRotateSpeed * e : m / 60 / 60 * this.autoRotateSpeed;
475
+ return e !== null ? g / 60 * this.autoRotateSpeed * e : g / 60 / 60 * this.autoRotateSpeed;
451
476
  }
452
477
  _getZoomScale(e) {
453
478
  const s = Math.abs(e * 0.01);
@@ -460,18 +485,18 @@ class et extends xe {
460
485
  this._sphericalDelta.phi -= e;
461
486
  }
462
487
  _panLeft(e, s) {
463
- _.setFromMatrixColumn(s, 0), _.multiplyScalar(-e), this._panOffset.add(_);
488
+ p.setFromMatrixColumn(s, 0), p.multiplyScalar(-e), this._panOffset.add(p);
464
489
  }
465
490
  _panUp(e, s) {
466
- this.screenSpacePanning === !0 ? _.setFromMatrixColumn(s, 1) : (_.setFromMatrixColumn(s, 0), _.crossVectors(this.object.up, _)), _.multiplyScalar(e), this._panOffset.add(_);
491
+ this.screenSpacePanning === !0 ? p.setFromMatrixColumn(s, 1) : (p.setFromMatrixColumn(s, 0), p.crossVectors(this.object.up, p)), p.multiplyScalar(e), this._panOffset.add(p);
467
492
  }
468
493
  // deltaX and deltaY are in pixels; right and down are positive
469
494
  _pan(e, s) {
470
495
  const i = this.domElement;
471
496
  if (this.object.isPerspectiveCamera) {
472
497
  const r = this.object.position;
473
- _.copy(r).sub(this.target);
474
- let o = _.length();
498
+ p.copy(r).sub(this.target);
499
+ let o = p.length();
475
500
  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);
476
501
  } 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);
477
502
  }
@@ -506,7 +531,7 @@ class et extends xe {
506
531
  _handleMouseMoveRotate(e) {
507
532
  this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
508
533
  const s = this.domElement;
509
- this._rotateLeft(m * this._rotateDelta.x / s.clientHeight), this._rotateUp(m * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
534
+ this._rotateLeft(g * this._rotateDelta.x / s.clientHeight), this._rotateUp(g * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
510
535
  }
511
536
  _handleMouseMoveDolly(e) {
512
537
  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();
@@ -521,16 +546,16 @@ class et extends xe {
521
546
  let s = !1;
522
547
  switch (e.code) {
523
548
  case this.keys.UP:
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;
549
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(g * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), s = !0;
525
550
  break;
526
551
  case this.keys.BOTTOM:
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;
552
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-g * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), s = !0;
528
553
  break;
529
554
  case this.keys.LEFT:
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;
555
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(g * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), s = !0;
531
556
  break;
532
557
  case this.keys.RIGHT:
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;
558
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-g * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), s = !0;
534
559
  break;
535
560
  }
536
561
  s && (e.preventDefault(), this.update());
@@ -570,7 +595,7 @@ class et extends xe {
570
595
  }
571
596
  this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
572
597
  const s = this.domElement;
573
- this._rotateLeft(m * this._rotateDelta.x / s.clientHeight), this._rotateUp(m * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd);
598
+ this._rotateLeft(g * this._rotateDelta.x / s.clientHeight), this._rotateUp(g * this._rotateDelta.y / s.clientHeight), this._rotateStart.copy(this._rotateEnd);
574
599
  }
575
600
  _handleTouchMovePan(e) {
576
601
  if (this._pointers.length === 1)
@@ -612,7 +637,7 @@ class et extends xe {
612
637
  }
613
638
  _trackPointer(e) {
614
639
  let s = this._pointerPositions[e.pointerId];
615
- s === void 0 && (s = new v(), this._pointerPositions[e.pointerId] = s), s.set(e.pageX, e.pageY);
640
+ s === void 0 && (s = new E(), this._pointerPositions[e.pointerId] = s), s.set(e.pageX, e.pageY);
616
641
  }
617
642
  _getSecondPointerPosition(e) {
618
643
  const s = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
@@ -636,16 +661,16 @@ class et extends xe {
636
661
  return e.ctrlKey && !this._controlActive && (i.deltaY *= 10), i;
637
662
  }
638
663
  }
639
- function tt(t) {
664
+ function pt(t) {
640
665
  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)));
641
666
  }
642
- function st(t) {
667
+ function ut(t) {
643
668
  this.enabled !== !1 && (t.pointerType === "touch" ? this._onTouchMove(t) : this._onMouseMove(t));
644
669
  }
645
- function it(t) {
670
+ function mt(t) {
646
671
  switch (this._removePointer(t), this._pointers.length) {
647
672
  case 0:
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;
673
+ this.domElement.releasePointerCapture(t.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(Ne), this.state = l.NONE;
649
674
  break;
650
675
  case 1:
651
676
  const e = this._pointers[0], s = this._pointerPositions[e];
@@ -653,7 +678,7 @@ function it(t) {
653
678
  break;
654
679
  }
655
680
  }
656
- function rt(t) {
681
+ function ft(t) {
657
682
  let e;
658
683
  switch (t.button) {
659
684
  case 0:
@@ -669,126 +694,126 @@ function rt(t) {
669
694
  e = -1;
670
695
  }
671
696
  switch (e) {
672
- case T.DOLLY:
697
+ case j.DOLLY:
673
698
  if (this.enableZoom === !1) return;
674
- this._handleMouseDownDolly(t), this.state = h.DOLLY;
699
+ this._handleMouseDownDolly(t), this.state = l.DOLLY;
675
700
  break;
676
- case T.ROTATE:
701
+ case j.ROTATE:
677
702
  if (t.ctrlKey || t.metaKey || t.shiftKey) {
678
703
  if (this.enablePan === !1) return;
679
- this._handleMouseDownPan(t), this.state = h.PAN;
704
+ this._handleMouseDownPan(t), this.state = l.PAN;
680
705
  } else {
681
706
  if (this.enableRotate === !1) return;
682
- this._handleMouseDownRotate(t), this.state = h.ROTATE;
707
+ this._handleMouseDownRotate(t), this.state = l.ROTATE;
683
708
  }
684
709
  break;
685
- case T.PAN:
710
+ case j.PAN:
686
711
  if (t.ctrlKey || t.metaKey || t.shiftKey) {
687
712
  if (this.enableRotate === !1) return;
688
- this._handleMouseDownRotate(t), this.state = h.ROTATE;
713
+ this._handleMouseDownRotate(t), this.state = l.ROTATE;
689
714
  } else {
690
715
  if (this.enablePan === !1) return;
691
- this._handleMouseDownPan(t), this.state = h.PAN;
716
+ this._handleMouseDownPan(t), this.state = l.PAN;
692
717
  }
693
718
  break;
694
719
  default:
695
- this.state = h.NONE;
720
+ this.state = l.NONE;
696
721
  }
697
- this.state !== h.NONE && this.dispatchEvent(oe);
722
+ this.state !== l.NONE && this.dispatchEvent(pe);
698
723
  }
699
- function ot(t) {
724
+ function gt(t) {
700
725
  switch (this.state) {
701
- case h.ROTATE:
726
+ case l.ROTATE:
702
727
  if (this.enableRotate === !1) return;
703
728
  this._handleMouseMoveRotate(t);
704
729
  break;
705
- case h.DOLLY:
730
+ case l.DOLLY:
706
731
  if (this.enableZoom === !1) return;
707
732
  this._handleMouseMoveDolly(t);
708
733
  break;
709
- case h.PAN:
734
+ case l.PAN:
710
735
  if (this.enablePan === !1) return;
711
736
  this._handleMouseMovePan(t);
712
737
  break;
713
738
  }
714
739
  }
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));
740
+ function bt(t) {
741
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== l.NONE || (t.preventDefault(), this.dispatchEvent(pe), this._handleMouseWheel(this._customWheelEvent(t)), this.dispatchEvent(Ne));
717
742
  }
718
- function at(t) {
743
+ function vt(t) {
719
744
  this.enabled !== !1 && this._handleKeyDown(t);
720
745
  }
721
- function ht(t) {
746
+ function yt(t) {
722
747
  switch (this._trackPointer(t), this._pointers.length) {
723
748
  case 1:
724
749
  switch (this.touches.ONE) {
725
- case D.ROTATE:
750
+ case x.ROTATE:
726
751
  if (this.enableRotate === !1) return;
727
- this._handleTouchStartRotate(t), this.state = h.TOUCH_ROTATE;
752
+ this._handleTouchStartRotate(t), this.state = l.TOUCH_ROTATE;
728
753
  break;
729
- case D.PAN:
754
+ case x.PAN:
730
755
  if (this.enablePan === !1) return;
731
- this._handleTouchStartPan(t), this.state = h.TOUCH_PAN;
756
+ this._handleTouchStartPan(t), this.state = l.TOUCH_PAN;
732
757
  break;
733
758
  default:
734
- this.state = h.NONE;
759
+ this.state = l.NONE;
735
760
  }
736
761
  break;
737
762
  case 2:
738
763
  switch (this.touches.TWO) {
739
- case D.DOLLY_PAN:
764
+ case x.DOLLY_PAN:
740
765
  if (this.enableZoom === !1 && this.enablePan === !1) return;
741
- this._handleTouchStartDollyPan(t), this.state = h.TOUCH_DOLLY_PAN;
766
+ this._handleTouchStartDollyPan(t), this.state = l.TOUCH_DOLLY_PAN;
742
767
  break;
743
- case D.DOLLY_ROTATE:
768
+ case x.DOLLY_ROTATE:
744
769
  if (this.enableZoom === !1 && this.enableRotate === !1) return;
745
- this._handleTouchStartDollyRotate(t), this.state = h.TOUCH_DOLLY_ROTATE;
770
+ this._handleTouchStartDollyRotate(t), this.state = l.TOUCH_DOLLY_ROTATE;
746
771
  break;
747
772
  default:
748
- this.state = h.NONE;
773
+ this.state = l.NONE;
749
774
  }
750
775
  break;
751
776
  default:
752
- this.state = h.NONE;
777
+ this.state = l.NONE;
753
778
  }
754
- this.state !== h.NONE && this.dispatchEvent(oe);
779
+ this.state !== l.NONE && this.dispatchEvent(pe);
755
780
  }
756
- function lt(t) {
781
+ function Mt(t) {
757
782
  switch (this._trackPointer(t), this.state) {
758
- case h.TOUCH_ROTATE:
783
+ case l.TOUCH_ROTATE:
759
784
  if (this.enableRotate === !1) return;
760
785
  this._handleTouchMoveRotate(t), this.update();
761
786
  break;
762
- case h.TOUCH_PAN:
787
+ case l.TOUCH_PAN:
763
788
  if (this.enablePan === !1) return;
764
789
  this._handleTouchMovePan(t), this.update();
765
790
  break;
766
- case h.TOUCH_DOLLY_PAN:
791
+ case l.TOUCH_DOLLY_PAN:
767
792
  if (this.enableZoom === !1 && this.enablePan === !1) return;
768
793
  this._handleTouchMoveDollyPan(t), this.update();
769
794
  break;
770
- case h.TOUCH_DOLLY_ROTATE:
795
+ case l.TOUCH_DOLLY_ROTATE:
771
796
  if (this.enableZoom === !1 && this.enableRotate === !1) return;
772
797
  this._handleTouchMoveDollyRotate(t), this.update();
773
798
  break;
774
799
  default:
775
- this.state = h.NONE;
800
+ this.state = l.NONE;
776
801
  }
777
802
  }
778
- function ct(t) {
803
+ function wt(t) {
779
804
  this.enabled !== !1 && t.preventDefault();
780
805
  }
781
- function dt(t) {
806
+ function Et(t) {
782
807
  t.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
783
808
  }
784
- function _t(t) {
809
+ function Pt(t) {
785
810
  t.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
786
811
  }
787
- class ns extends Ce {
812
+ class bs extends Re {
788
813
  /** Orbit-контроллер для управления камерой */
789
814
  _orbit;
790
815
  constructor(e) {
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;
816
+ super(e), this.camera.position.set(1, 1, 7), this.camera.lookAt(0, 0, 0), this._orbit = new _t(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;
792
817
  }
793
818
  /**
794
819
  * Обновление состояния рендерера.
@@ -797,7 +822,7 @@ class ns extends Ce {
797
822
  this._orbit?.update();
798
823
  }
799
824
  }
800
- class as {
825
+ class vs {
801
826
  /** Позиции вершин */
802
827
  _positions = [];
803
828
  /** Нормали вершин */
@@ -834,12 +859,12 @@ class as {
834
859
  }
835
860
  }
836
861
  const i = {
837
- type: y.Custom,
862
+ type: P.Custom,
838
863
  position: this._positions,
839
864
  ...this._normals.length > 0 && { normal: this._normals },
840
865
  ...this._uvs.length > 0 && { uv: this._uvs }
841
866
  };
842
- return new Ne(i);
867
+ return new Ze(i);
843
868
  }
844
869
  /**
845
870
  * Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
@@ -848,60 +873,60 @@ class as {
848
873
  for (let s = 1; s < e.length; s++) {
849
874
  const i = e[s];
850
875
  if (!i) continue;
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;
876
+ const [r, o, n] = i.split("/"), c = r ? parseInt(r, 10) : void 0, _ = o ? parseInt(o, 10) : void 0, m = n ? parseInt(n, 10) : void 0;
852
877
  if (c !== void 0) {
853
- const g = this._tmpPositions[c - 1];
854
- g && this._positions.push(...g);
878
+ const f = this._tmpPositions[c - 1];
879
+ f && this._positions.push(...f);
855
880
  }
856
- if (p !== void 0) {
857
- const g = this._tmpUVs[p - 1];
858
- g && this._uvs.push(...g);
881
+ if (_ !== void 0) {
882
+ const f = this._tmpUVs[_ - 1];
883
+ f && this._uvs.push(...f);
859
884
  }
860
- if (f !== void 0) {
861
- const g = this._tmpNormals[f - 1];
862
- g && this._normals.push(...g);
885
+ if (m !== void 0) {
886
+ const f = this._tmpNormals[m - 1];
887
+ f && this._normals.push(...f);
863
888
  }
864
889
  }
865
890
  }
866
891
  }
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--)
892
+ var St = Object.getOwnPropertyDescriptor, Ot = (t, e, s, i) => {
893
+ for (var r = i > 1 ? void 0 : i ? St(e, s) : e, o = t.length - 1, n; o >= 0; o--)
869
894
  (n = t[o]) && (r = n(r) || r);
870
895
  return r;
871
- }, ye = (t, e) => (s, i) => e(s, i, t);
872
- let F = class {
896
+ }, Ee = (t, e) => (s, i) => e(s, i, t);
897
+ let K = class {
873
898
  constructor(t, e) {
874
899
  this._store = e, this._handlers = new Map(t.map((s) => [s.mode, s]));
875
900
  }
876
901
  /** Текущий режим отображения */
877
- _currentMode = R.Plane;
902
+ _currentMode = k.Plane;
878
903
  /** Хендлеры, которые управляют отображением */
879
904
  _handlers;
880
905
  /** Установка режима отображения */
881
906
  manage(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));
907
+ t !== this._currentMode && (this._handlers.get(this._currentMode)?.rollback(), t !== k.Plane && this._handlers.get(t)?.handle(), this._currentMode = t, this._store.setDisplayMode(this._currentMode));
883
908
  }
884
909
  /** Освобождает ресурсы менеджера. */
885
910
  dispose() {
886
- this._handlers && this._handlers.clear(), this._currentMode = R.Plane, this._store.setDisplayMode(this._currentMode);
911
+ this._handlers && this._handlers.clear(), this._currentMode = k.Plane, this._store.setDisplayMode(this._currentMode);
887
912
  }
888
913
  };
889
- F = ut([
914
+ K = Ot([
890
915
  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--)
916
+ Ee(0, W("IDisplayHandler")),
917
+ Ee(1, h("IEditorStore"))
918
+ ], K);
919
+ var S = /* @__PURE__ */ ((t) => (t.Hover = "hover", t.Click = "click", t))(S || {}), Dt = Object.getOwnPropertyDescriptor, Lt = (t, e, s, i) => {
920
+ for (var r = i > 1 ? void 0 : i ? Dt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
896
921
  (n = t[o]) && (r = n(r) || r);
897
922
  return r;
898
- }, U = (t, e) => (s, i) => e(s, i, t);
899
- let W = class {
923
+ }, B = (t, e) => (s, i) => e(s, i, t);
924
+ let q = class {
900
925
  constructor(t, e, s) {
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);
926
+ this._eventBus = t, this._store = s, this._handlers = new Map(e.map((i) => [i.mode, i])), this._eventBus.on(R.SelectHover, this._onHover), this._eventBus.on(R.SelectClick, this._onClick);
902
927
  }
903
928
  /** Текущий режим выборки */
904
- _currentMode = M.Mesh;
929
+ _currentMode = v.Mesh;
905
930
  /** Хендлеры, которые управляют выборкой */
906
931
  _handlers;
907
932
  /** Переключает режим выбора */
@@ -918,28 +943,28 @@ let W = class {
918
943
  };
919
944
  /** Освобождает ресурсы менеджера. */
920
945
  dispose() {
921
- this._handlers && this._handlers.clear(), this._eventBus.off(L.SelectHover, this._onHover), this._currentMode = M.Mesh, this._store.setSelectMode(this._currentMode);
946
+ this._handlers && this._handlers.clear(), this._eventBus.off(R.SelectHover, this._onHover), this._currentMode = v.Mesh, this._store.setSelectMode(this._currentMode);
922
947
  }
923
948
  };
924
- W = ft([
949
+ q = Lt([
925
950
  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--)
951
+ B(0, h("EventBus")),
952
+ B(1, W("ISelectHandler")),
953
+ B(2, h("IEditorStore"))
954
+ ], q);
955
+ var Tt = Object.getOwnPropertyDescriptor, Ct = (t, e, s, i) => {
956
+ for (var r = i > 1 ? void 0 : i ? Tt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
932
957
  (n = t[o]) && (r = n(r) || r);
933
958
  return r;
934
- }, Me = (t, e) => (s, i) => e(s, i, t);
935
- let Z = class {
959
+ }, Pe = (t, e) => (s, i) => e(s, i, t);
960
+ let Q = class {
936
961
  constructor(t, e) {
937
962
  this._store = e, this._handlers = new Map(t.map((s) => [s.mode, s])), this._unsubSelected = this._store.onSelectedObjectChange(() => {
938
963
  this._handlers.get(this._currentTool)?.handle();
939
964
  });
940
965
  }
941
966
  /** Текущий выбранный инструмент */
942
- _currentTool = O.Translate;
967
+ _currentTool = C.Translate;
943
968
  /** Хендлеры, которые управляют инструментами */
944
969
  _handlers;
945
970
  _unsubSelected;
@@ -948,22 +973,22 @@ let Z = class {
948
973
  }
949
974
  /** Освобождает ресурсы менеджера. */
950
975
  dispose() {
951
- this._unsubSelected?.(), this._handlers && this._handlers.clear(), this._currentTool = O.Translate, this._store.setToolType(this._currentTool);
976
+ this._unsubSelected?.(), this._handlers && this._handlers.clear(), this._currentTool = C.Translate, this._store.setToolType(this._currentTool);
952
977
  }
953
978
  };
954
- Z = bt([
979
+ Q = Ct([
955
980
  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--)
981
+ Pe(0, W("IToolHandler")),
982
+ Pe(1, h("IEditorStore"))
983
+ ], Q);
984
+ var At = Object.getOwnPropertyDescriptor, xt = (t, e, s, i) => {
985
+ for (var r = i > 1 ? void 0 : i ? At(e, s) : e, o = t.length - 1, n; o >= 0; o--)
961
986
  (n = t[o]) && (r = n(r) || r);
962
987
  return r;
963
- }, Mt = (t, e) => (s, i) => e(s, i, t);
964
- let B = class {
988
+ }, jt = (t, e) => (s, i) => e(s, i, t);
989
+ let J = class {
965
990
  /** Текущий режим редактирования сцены */
966
- _currentMode = j.AddFigure;
991
+ _currentMode = V.AddFigure;
967
992
  /** Хендлеры, которые управляют отображением */
968
993
  _handlers;
969
994
  constructor(t) {
@@ -971,28 +996,28 @@ let B = class {
971
996
  }
972
997
  /** Установка режима редактирования сцены */
973
998
  manage(t, e) {
974
- console.log("manage", t), t === j.AddFigure ? this._handlers.get(t)?.handle(e) : this._handlers.get(t)?.handle(), this._currentMode = t;
999
+ console.log("manage", t), t === V.AddFigure ? this._handlers.get(t)?.handle(e) : this._handlers.get(t)?.handle(), this._currentMode = t;
975
1000
  }
976
1001
  /** Освобождает ресурсы менеджера. */
977
1002
  dispose() {
978
- this._handlers && this._handlers.clear(), this._currentMode = j.AddFigure;
1003
+ this._handlers && this._handlers.clear(), this._currentMode = V.AddFigure;
979
1004
  }
980
1005
  };
981
- B = yt([
1006
+ J = xt([
982
1007
  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--)
1008
+ jt(0, W("ISceneHandler"))
1009
+ ], J);
1010
+ var Rt = Object.getOwnPropertyDescriptor, It = (t, e, s, i) => {
1011
+ for (var r = i > 1 ? void 0 : i ? Rt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
987
1012
  (n = t[o]) && (r = n(r) || r);
988
1013
  return r;
989
- }, St = (t, e) => (s, i) => e(s, i, t);
990
- let X = class {
1014
+ }, Ht = (t, e) => (s, i) => e(s, i, t);
1015
+ let ee = class {
991
1016
  constructor(t) {
992
1017
  this._api = t;
993
1018
  }
994
1019
  /** Режим отображения. */
995
- mode = R.Wireframe;
1020
+ mode = k.Wireframe;
996
1021
  /** Сохраняем предыдущие значения wireframe для отката. */
997
1022
  _prevWireframe = /* @__PURE__ */ new Map();
998
1023
  /** Сохраняем исходные цвета материалов для отката */
@@ -1043,31 +1068,30 @@ let X = class {
1043
1068
  "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));
1044
1069
  }
1045
1070
  };
1046
- X = wt([
1071
+ ee = It([
1047
1072
  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--)
1073
+ Ht(0, h("RendererApi"))
1074
+ ], ee);
1075
+ var kt = Object.getOwnPropertyDescriptor, Vt = (t, e, s, i) => {
1076
+ for (var r = i > 1 ? void 0 : i ? kt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1053
1077
  (n = t[o]) && (r = n(r) || r);
1054
1078
  return r;
1055
- }, Ee = (t, e) => (s, i) => e(s, i, t);
1056
- let V = class {
1079
+ }, Se = (t, e) => (s, i) => e(s, i, t);
1080
+ let te = class {
1057
1081
  constructor(t, e) {
1058
1082
  this._api = t, this._store = e;
1059
1083
  }
1060
1084
  /** Режим, которым управляет хендлер, нужен только менеджеру */
1061
- mode = M.Mesh;
1085
+ mode = v.Mesh;
1062
1086
  /** Фигура, на которую навелись в данный момент */
1063
1087
  _hoveredMesh = null;
1064
1088
  /** Фигура, которую выбрали в данный момент */
1065
1089
  _selectedMesh = null;
1066
1090
  // Цвета, необходимые для переключения
1067
1091
  /** Цвет ребер для фигуры, на которую навелись */
1068
- _hoverColor = ne;
1092
+ _hoverColor = z;
1069
1093
  /** Цвет ребер для выделенной фигуры */
1070
- _selectColor = ae;
1094
+ _selectColor = Z;
1071
1095
  /** Исходные цвета материалов линий для отката */
1072
1096
  _origLineColors = /* @__PURE__ */ new WeakMap();
1073
1097
  handle(t, e) {
@@ -1124,31 +1148,31 @@ let V = class {
1124
1148
  });
1125
1149
  }
1126
1150
  };
1127
- V = Dt([
1151
+ te = Vt([
1128
1152
  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--)
1153
+ Se(0, h("RendererApi")),
1154
+ Se(1, h("IEditorStore"))
1155
+ ], te);
1156
+ var Nt = Object.getOwnPropertyDescriptor, Yt = (t, e, s, i) => {
1157
+ for (var r = i > 1 ? void 0 : i ? Nt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1134
1158
  (n = t[o]) && (r = n(r) || r);
1135
1159
  return r;
1136
- }, Ct = (t, e) => (s, i) => e(s, i, t);
1137
- let K = class {
1160
+ }, Ut = (t, e) => (s, i) => e(s, i, t);
1161
+ let se = class {
1138
1162
  constructor(t) {
1139
1163
  this._api = t;
1140
1164
  }
1141
1165
  /** Режим, которым управляет хендлер, нужен только менеджеру */
1142
- mode = M.Face;
1166
+ mode = v.Face;
1143
1167
  /** Текущая наведённая грань */
1144
1168
  _hovered = null;
1145
1169
  /** Текущая выбранная грань */
1146
1170
  _selected = null;
1147
1171
  // Цвета, необходимые для переключения
1148
1172
  /** Цвет грани, на которую навелись */
1149
- _hoverColor = ne;
1173
+ _hoverColor = z;
1150
1174
  /** Цвет выделенной граней */
1151
- _selectColor = ae;
1175
+ _selectColor = Z;
1152
1176
  /** Изначальный цвет граней у модели, перед наложением эффектов*/
1153
1177
  _defaultColor = 2236962;
1154
1178
  handle(t, e) {
@@ -1162,11 +1186,137 @@ let K = class {
1162
1186
  throw new Error("Method not implemented.");
1163
1187
  }
1164
1188
  };
1165
- K = Lt([
1189
+ se = Yt([
1166
1190
  u(),
1167
- Ct(0, l("RendererApi"))
1168
- ], K);
1169
- class he {
1191
+ Ut(0, h("RendererApi"))
1192
+ ], se);
1193
+ var Wt = Object.getOwnPropertyDescriptor, zt = (t, e, s, i) => {
1194
+ for (var r = i > 1 ? void 0 : i ? Wt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1195
+ (n = t[o]) && (r = n(r) || r);
1196
+ return r;
1197
+ }, Oe = (t, e) => (s, i) => e(s, i, t);
1198
+ let ie = class {
1199
+ constructor(t, e) {
1200
+ this._api = t, this._store = e, this._api.enableCameraLayer(L), this._hoverVertex = this._makeOverlayVertex(this._hoverColor), this._selectVertex = this._makeOverlayVertex(this._selectColor), this._api.addObject(this._hoverVertex, L), this._api.addObject(this._selectVertex, L);
1201
+ }
1202
+ /** Режим, которым управляет хендлер, нужен только менеджеру */
1203
+ mode = v.Vertex;
1204
+ _hovered = null;
1205
+ _selected = null;
1206
+ /** Текущая наведённая вершина. */
1207
+ _hoverVertex;
1208
+ /** Текущая выбранная вершина. */
1209
+ _selectVertex;
1210
+ // Цвета, необходимые для переключения
1211
+ /** Цвет ребра, на которое навелись */
1212
+ _hoverColor = z;
1213
+ /** Цвет выделенного ребра */
1214
+ _selectColor = Z;
1215
+ handle(t, e) {
1216
+ if (this._api.setRaycastMode(this.mode), e === S.Hover) {
1217
+ if (!t) {
1218
+ this._hoverVertex.visible = !1, this._hovered = null;
1219
+ return;
1220
+ }
1221
+ const s = t.intersection.object;
1222
+ if (!s?.isPoints) return;
1223
+ const i = s, r = t.intersection.index ?? -1;
1224
+ if (r < 0) return;
1225
+ this._selected && this._same({ points: i, index: r }, this._selected) ? this._hoverVertex.visible = !1 : (this._writeWorldVertex(this._hoverVertex, i, r), this._hoverVertex.visible = !0);
1226
+ return;
1227
+ }
1228
+ if (e === S.Click) {
1229
+ if (!t) {
1230
+ this._selectVertex.visible = !1, this._selected = null, this._store.setSelectedObject(null);
1231
+ return;
1232
+ }
1233
+ const s = t.intersection.object;
1234
+ if (!s?.isPoints) return;
1235
+ const i = s, r = t.intersection.index ?? -1;
1236
+ if (r < 0) return;
1237
+ this._writeWorldVertex(this._selectVertex, i, r), this._centerVertexOnPoint(this._selectVertex, i, r), this._selectVertex.visible = !0, this._prepareVertexMetadata(i, r), this._store.setSelectedObject(this._selectVertex), this._selected = { points: i, index: r }, this._hovered && this._same(this._hovered, this._selected) && (this._hoverVertex.visible = !1);
1238
+ return;
1239
+ }
1240
+ }
1241
+ rollback() {
1242
+ this._hoverVertex.visible = !1, this._selectVertex.visible = !1, this._hovered = this._selected = null;
1243
+ }
1244
+ dispose() {
1245
+ this.rollback(), this._api.removeObject(this._hoverVertex), this._api.removeObject(this._selectVertex), this._hoverVertex.geometry.dispose(), this._hoverVertex.material.dispose(), this._selectVertex.geometry.dispose(), this._selectVertex.material.dispose();
1246
+ }
1247
+ _makeOverlayVertex(t, e = Je) {
1248
+ const s = new a.BufferGeometry();
1249
+ s.setAttribute("position", new a.Float32BufferAttribute([0, 0, 0], 3));
1250
+ const i = new a.PointsMaterial({
1251
+ color: t,
1252
+ size: e,
1253
+ sizeAttenuation: !1,
1254
+ depthTest: !1,
1255
+ depthWrite: !1,
1256
+ transparent: !0,
1257
+ opacity: 1
1258
+ }), r = new a.Points(s, i);
1259
+ return r.renderOrder = 1e3, r.raycast = () => {
1260
+ }, r.layers.set(L), r.visible = !1, r;
1261
+ }
1262
+ /** Локальную вершину points переводим в world и пишем в target (прокси-точку) */
1263
+ _writeWorldVertex(t, e, s) {
1264
+ const i = e.geometry.getAttribute("position"), r = new a.Vector3(
1265
+ i.getX(s),
1266
+ i.getY(s),
1267
+ i.getZ(s)
1268
+ ).applyMatrix4(e.matrixWorld), o = t.geometry.getAttribute("position");
1269
+ o.setXYZ(0, r.x, r.y, r.z), o.needsUpdate = !0;
1270
+ }
1271
+ _same(t, e) {
1272
+ return !!t && !!e && t.points === e.points && t.index === e.index;
1273
+ }
1274
+ /** Готовит метаданные для выбранной вершины и пишет их в _selectVertex.userData */
1275
+ _prepareVertexMetadata(t, e) {
1276
+ const s = He(t);
1277
+ if (!s) return;
1278
+ const i = t.geometry.getAttribute("position"), r = new a.Vector3(
1279
+ i.getX(e),
1280
+ i.getY(e),
1281
+ i.getZ(e)
1282
+ ).applyMatrix4(t.matrixWorld), o = new a.Matrix4().copy(s.matrixWorld).invert(), n = r.clone().applyMatrix4(o), _ = s.geometry.getAttribute("position"), m = 1e-6, f = m * m, T = new a.Vector3(), b = [];
1283
+ for (let M = 0; M < _.count; M++)
1284
+ T.fromBufferAttribute(_, M), T.distanceToSquared(n) < f && b.push(M);
1285
+ const O = s.children.find((M) => M?.isLineSegments);
1286
+ let y = [];
1287
+ if (O) {
1288
+ const M = new a.Matrix4().copy(O.matrixWorld).invert(), N = r.clone().applyMatrix4(M), I = O.geometry.getAttribute("position"), Y = new a.Vector3();
1289
+ for (let A = 0; A < I.count; A++)
1290
+ Y.fromBufferAttribute(I, A), Y.distanceToSquared(N) < f && y.push(A);
1291
+ }
1292
+ this._selectVertex.userData.vertexInfo = {
1293
+ points: t,
1294
+ index: e,
1295
+ mesh: s,
1296
+ vertexIndices: b,
1297
+ lines: O ?? null,
1298
+ edgeVertexIndices: y
1299
+ };
1300
+ }
1301
+ /** Центрует прокси-вершину на выбранной точке */
1302
+ _centerVertexOnPoint(t, e, s) {
1303
+ const i = e.geometry.getAttribute("position"), r = new a.Vector3(
1304
+ i.getX(s),
1305
+ i.getY(s),
1306
+ i.getZ(s)
1307
+ ).applyMatrix4(e.matrixWorld);
1308
+ t.position.copy(r);
1309
+ const o = t.geometry;
1310
+ let n = o.getAttribute("position");
1311
+ (!n || n.count < 1) && (o.setAttribute("position", new a.BufferAttribute(new Float32Array(3), 3)), n = o.getAttribute("position")), n.setXYZ(0, 0, 0, 0), n.needsUpdate = !0, t.quaternion.identity(), t.scale.set(1, 1, 1), t.updateMatrixWorld(!0);
1312
+ }
1313
+ };
1314
+ ie = zt([
1315
+ u(),
1316
+ Oe(0, h("RendererApi")),
1317
+ Oe(1, h("IEditorStore"))
1318
+ ], ie);
1319
+ class ue {
1170
1320
  constructor(e, s) {
1171
1321
  this.api = e, this.store = s;
1172
1322
  }
@@ -1190,69 +1340,68 @@ class he {
1190
1340
  this.rollback();
1191
1341
  }
1192
1342
  }
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--)
1343
+ var Zt = Object.getOwnPropertyDescriptor, $t = (t, e, s, i) => {
1344
+ for (var r = i > 1 ? void 0 : i ? Zt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1195
1345
  (n = t[o]) && (r = n(r) || r);
1196
1346
  return r;
1197
- }, we = (t, e) => (s, i) => e(s, i, t);
1198
- let G = class extends he {
1347
+ }, De = (t, e) => (s, i) => e(s, i, t);
1348
+ let re = class extends ue {
1199
1349
  /** Инструмент, которым управляет хендлер, нужен только менеджеру */
1200
- mode = O.Translate;
1350
+ mode = C.Translate;
1201
1351
  constructor(t, e) {
1202
1352
  super(t, e);
1203
1353
  }
1204
1354
  };
1205
- G = Rt([
1355
+ re = $t([
1206
1356
  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--)
1357
+ De(0, h("RendererApi")),
1358
+ De(1, h("IEditorStore"))
1359
+ ], re);
1360
+ var Ft = Object.getOwnPropertyDescriptor, Bt = (t, e, s, i) => {
1361
+ for (var r = i > 1 ? void 0 : i ? Ft(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1212
1362
  (n = t[o]) && (r = n(r) || r);
1213
1363
  return r;
1214
- }, Se = (t, e) => (s, i) => e(s, i, t);
1215
- let q = class extends he {
1364
+ }, Le = (t, e) => (s, i) => e(s, i, t);
1365
+ let oe = class extends ue {
1216
1366
  /** Инструмент, которым управляет хендлер, нужен только менеджеру */
1217
- mode = O.Scale;
1367
+ mode = C.Scale;
1218
1368
  constructor(t, e) {
1219
1369
  super(t, e);
1220
1370
  }
1221
1371
  };
1222
- q = xt([
1372
+ oe = Bt([
1223
1373
  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--)
1374
+ Le(0, h("RendererApi")),
1375
+ Le(1, h("IEditorStore"))
1376
+ ], oe);
1377
+ var Xt = Object.getOwnPropertyDescriptor, Gt = (t, e, s, i) => {
1378
+ for (var r = i > 1 ? void 0 : i ? Xt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1229
1379
  (n = t[o]) && (r = n(r) || r);
1230
1380
  return r;
1231
- }, Pe = (t, e) => (s, i) => e(s, i, t);
1232
- let Q = class extends he {
1381
+ }, Te = (t, e) => (s, i) => e(s, i, t);
1382
+ let ne = class extends ue {
1233
1383
  /** Инструмент, которым управляет хендлер, нужен только менеджеру */
1234
- mode = O.Rotate;
1384
+ mode = C.Rotate;
1235
1385
  constructor(t, e) {
1236
1386
  super(t, e);
1237
1387
  }
1238
1388
  };
1239
- Q = Ht([
1389
+ ne = Gt([
1240
1390
  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--)
1391
+ Te(0, h("RendererApi")),
1392
+ Te(1, h("IEditorStore"))
1393
+ ], ne);
1394
+ var Kt = Object.getOwnPropertyDescriptor, qt = (t, e, s, i) => {
1395
+ for (var r = i > 1 ? void 0 : i ? Kt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1247
1396
  (n = t[o]) && (r = n(r) || r);
1248
1397
  return r;
1249
- }, Oe = (t, e) => (s, i) => e(s, i, t);
1250
- let J = class {
1398
+ }, Ce = (t, e) => (s, i) => e(s, i, t);
1399
+ let ae = class {
1251
1400
  constructor(t, e) {
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);
1401
+ this._api = t, this._store = e, this._api.enableCameraLayer(L), this._hoverLine = this._makeOverlayLine(this._hoverColor), this._selectLine = this._makeOverlayLine(this._selectColor), this._api.addObject(this._hoverLine, L), this._api.addObject(this._selectLine, L);
1253
1402
  }
1254
1403
  /** Режим, которым управляет хендлер, нужен только менеджеру */
1255
- mode = M.Edge;
1404
+ mode = v.Edge;
1256
1405
  /** Текущее наведённое ребро. */
1257
1406
  _hoverLine;
1258
1407
  /** Текущее выбранное ребро. */
@@ -1263,9 +1412,9 @@ let J = class {
1263
1412
  _selected = null;
1264
1413
  // Цвета, необходимые для переключения
1265
1414
  /** Цвет ребра, на которое навелись */
1266
- _hoverColor = ne;
1415
+ _hoverColor = z;
1267
1416
  /** Цвет выделенного ребра */
1268
- _selectColor = ae;
1417
+ _selectColor = Z;
1269
1418
  /** Обработка текущего режима выборки. */
1270
1419
  handle(t, e) {
1271
1420
  if (this._api.setRaycastMode(this.mode), e === S.Hover) {
@@ -1315,7 +1464,7 @@ let J = class {
1315
1464
  opacity: 1
1316
1465
  }), i = new a.Line(e, s);
1317
1466
  return i.renderOrder = 1e3, i.raycast = () => {
1318
- }, i.layers.set(H), i.visible = !1, i;
1467
+ }, i.layers.set(L), i.visible = !1, i;
1319
1468
  }
1320
1469
  /** Локальные точки сегмента переводим в target (который висит на сцене) */
1321
1470
  _writeWorldSegment(t, e, s) {
@@ -1323,8 +1472,8 @@ let J = class {
1323
1472
  e.matrixWorld
1324
1473
  ), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
1325
1474
  e.matrixWorld
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;
1475
+ ), _ = t.geometry.getAttribute("position");
1476
+ _.setXYZ(0, n.x, n.y, n.z), _.setXYZ(1, c.x, c.y, c.z), _.needsUpdate = !0;
1328
1477
  }
1329
1478
  _same(t, e) {
1330
1479
  return !!t && !!e && t.lines === e.lines && t.seg === e.seg;
@@ -1335,79 +1484,69 @@ let J = class {
1335
1484
  e.matrixWorld
1336
1485
  ), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
1337
1486
  e.matrixWorld
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;
1487
+ ), _ = new a.Vector3().subVectors(c, n), m = _.length();
1488
+ if (!isFinite(m) || m === 0) return;
1489
+ const f = new a.Vector3().addVectors(n, c).multiplyScalar(0.5);
1490
+ t.position.copy(f);
1491
+ const T = t.geometry;
1492
+ let b = T.getAttribute("position");
1493
+ (!b || b.count < 2) && (T.setAttribute("position", new a.BufferAttribute(new Float32Array(6), 3)), b = T.getAttribute("position")), b.setXYZ(0, -m / 2, 0, 0), b.setXYZ(1, m / 2, 0, 0), b.needsUpdate = !0, _.normalize();
1494
+ const O = new a.Quaternion().setFromUnitVectors(new a.Vector3(1, 0, 0), _);
1495
+ t.quaternion.copy(O), t.updateMatrixWorld(!0);
1356
1496
  }
1357
1497
  /** Запись метаданных выбранного ребра для использования инструментов */
1358
1498
  _prepareEdgeMetadata(t, e) {
1359
- const s = this._findParentMesh(t);
1499
+ const s = He(t);
1360
1500
  if (!s) return;
1361
1501
  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
1502
  t.matrixWorld
1363
1503
  ), c = new a.Vector3(i.getX(o), i.getY(o), i.getZ(o)).applyMatrix4(
1364
1504
  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);
1505
+ ), _ = new a.Matrix4().copy(s.matrixWorld).invert(), m = n.clone().applyMatrix4(_), f = c.clone().applyMatrix4(_), b = s.geometry.getAttribute("position"), O = new a.Vector3(), y = 1e-6, M = [], N = [];
1506
+ for (let w = 0; w < b.count; w++)
1507
+ O.fromBufferAttribute(b, w), O.distanceToSquared(m) < y * y ? M.push(w) : O.distanceToSquared(f) < y * y && N.push(w);
1508
+ const I = new a.Matrix4().copy(t.matrixWorld).invert(), Y = n.clone().applyMatrix4(I), A = c.clone().applyMatrix4(I), me = t.geometry.getAttribute("position"), $ = new a.Vector3(), fe = [], ge = [];
1509
+ for (let w = 0; w < me.count; w++)
1510
+ $.fromBufferAttribute(me, w), $.distanceToSquared(Y) < y * y ? fe.push(w) : $.distanceToSquared(A) < y * y && ge.push(w);
1371
1511
  this._selectLine.userData.edgeInfo = {
1372
1512
  lines: t,
1373
1513
  seg: e,
1374
1514
  mesh: s,
1375
- aIndices: le,
1376
- bIndices: ce,
1377
- aEdgeIndices: pe,
1378
- bEdgeIndices: ue
1515
+ aIndices: M,
1516
+ bIndices: N,
1517
+ aEdgeIndices: fe,
1518
+ bEdgeIndices: ge
1379
1519
  };
1380
1520
  }
1381
1521
  };
1382
- J = Nt([
1522
+ ae = qt([
1383
1523
  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--)
1524
+ Ce(0, h("RendererApi")),
1525
+ Ce(1, h("IEditorStore"))
1526
+ ], ae);
1527
+ var Qt = Object.getOwnPropertyDescriptor, Jt = (t, e, s, i) => {
1528
+ for (var r = i > 1 ? void 0 : i ? Qt(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1389
1529
  (n = t[o]) && (r = n(r) || r);
1390
1530
  return r;
1391
- }, $t = (t, e) => (s, i) => e(s, i, t);
1392
- let ee = class {
1531
+ }, es = (t, e) => (s, i) => e(s, i, t);
1532
+ let he = class {
1393
1533
  constructor(t) {
1394
1534
  this._api = t;
1395
1535
  }
1396
1536
  /** Режим редактирования сцены */
1397
- mode = j.AddFigure;
1537
+ mode = V.AddFigure;
1398
1538
  /** Последняя добавленная фигура, нужно для отката через `ctrl + z`. */
1399
1539
  _lastAddedMesh = null;
1400
1540
  /** Добавление базовых фигур на сцену, которые приписаны в `FigureType`. */
1401
1541
  handle(t) {
1402
- const e = Be[t](), s = e.getAttribute("position");
1542
+ const e = Qe[t](), s = e.getAttribute("position");
1403
1543
  s && s.setUsage && s.setUsage(a.DynamicDrawUsage);
1404
- const i = new a.Mesh(e, Le);
1405
- i.layers.enable(0);
1406
- const r = new a.EdgesGeometry(i.geometry), o = new a.LineSegments(
1407
- r,
1408
- new a.LineBasicMaterial({ color: Pt, linewidth: 1 })
1409
- );
1410
- o.layers.set(1), i.add(o), this._api.addMesh(i), this._lastAddedMesh = i;
1544
+ const i = new a.Mesh(e, je);
1545
+ i.layers.enable(Ie);
1546
+ const r = Ve(i.geometry);
1547
+ i.add(r);
1548
+ const o = ke(i.geometry);
1549
+ i.add(o), this._api.addMesh(i), this._lastAddedMesh = i;
1411
1550
  }
1412
1551
  /** Срабатывает только на `ctrl + z`. */
1413
1552
  rollback() {
@@ -1418,27 +1557,26 @@ let ee = class {
1418
1557
  this._lastAddedMesh = null;
1419
1558
  }
1420
1559
  };
1421
- ee = Ut([
1560
+ he = Jt([
1422
1561
  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--)
1562
+ es(0, h("RendererApi"))
1563
+ ], he);
1564
+ var ts = Object.getOwnPropertyDescriptor, ss = (t, e, s, i) => {
1565
+ for (var r = i > 1 ? void 0 : i ? ts(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1428
1566
  (n = t[o]) && (r = n(r) || r);
1429
1567
  return r;
1430
- }, De = (t, e) => (s, i) => e(s, i, t);
1431
- let te = class {
1568
+ }, Ae = (t, e) => (s, i) => e(s, i, t);
1569
+ let le = class {
1432
1570
  constructor(t, e) {
1433
1571
  this._api = t, this._store = e;
1434
1572
  }
1435
1573
  /** Режим редактирования сцены */
1436
- mode = j.DeleteFigure;
1574
+ mode = V.DeleteFigure;
1437
1575
  /** Последняя удаленная фигура, сохраняем для отката через `ctrl + z` */
1438
1576
  _lastDeletedMesh = null;
1439
1577
  handle() {
1440
1578
  const t = this._store.getSelectedObject();
1441
- zt(t) && (this._api.removeMesh(t), this._store.setSelectedObject(null), this._lastDeletedMesh = t);
1579
+ ht(t) && (this._api.removeMesh(t), this._store.setSelectedObject(null), this._lastDeletedMesh = t);
1442
1580
  }
1443
1581
  /** Срабатывает только на `ctrl + z`. */
1444
1582
  rollback() {
@@ -1449,17 +1587,17 @@ let te = class {
1449
1587
  this._lastDeletedMesh = null;
1450
1588
  }
1451
1589
  };
1452
- te = Wt([
1590
+ le = ss([
1453
1591
  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--)
1592
+ Ae(0, h("RendererApi")),
1593
+ Ae(1, h("IEditorStore"))
1594
+ ], le);
1595
+ var is = Object.getOwnPropertyDescriptor, rs = (t, e, s, i) => {
1596
+ for (var r = i > 1 ? void 0 : i ? is(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1459
1597
  (n = t[o]) && (r = n(r) || r);
1460
1598
  return r;
1461
- }, Xt = (t, e) => (s, i) => e(s, i, t);
1462
- let se = class {
1599
+ }, os = (t, e) => (s, i) => e(s, i, t);
1600
+ let ce = class {
1463
1601
  constructor(t) {
1464
1602
  this._renderer = t;
1465
1603
  }
@@ -1514,18 +1652,18 @@ let se = class {
1514
1652
  this._renderer.enableCameraLayer(t);
1515
1653
  }
1516
1654
  };
1517
- se = Bt([
1655
+ ce = rs([
1518
1656
  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--)
1657
+ os(0, h("EditorRenderer"))
1658
+ ], ce);
1659
+ var ns = Object.getOwnPropertyDescriptor, as = (t, e, s, i) => {
1660
+ for (var r = i > 1 ? void 0 : i ? ns(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1523
1661
  (n = t[o]) && (r = n(r) || r);
1524
1662
  return r;
1525
- }, A = (t, e) => (s, i) => e(s, i, t);
1526
- let ie = class {
1663
+ }, H = (t, e) => (s, i) => e(s, i, t);
1664
+ let de = class {
1527
1665
  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);
1666
+ this._displayManager = t, this._selectManager = e, this._toolManager = s, this._sceneManager = i, this._renderer = r, this.setSelectMode(v.Mesh), this.setToolMode(C.Translate);
1529
1667
  }
1530
1668
  setDisplayMode(t) {
1531
1669
  this._displayManager.manage(t);
@@ -1552,32 +1690,32 @@ let ie = class {
1552
1690
  this._displayManager.dispose(), this._selectManager.dispose(), this._renderer.dispose();
1553
1691
  }
1554
1692
  };
1555
- ie = Kt([
1693
+ de = as([
1556
1694
  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--)
1695
+ H(0, h("IDisplayManager")),
1696
+ H(1, h("ISelectManager")),
1697
+ H(2, h("IToolManager")),
1698
+ H(3, h("ISceneManager")),
1699
+ H(4, h("EditorRenderer"))
1700
+ ], de);
1701
+ var hs = Object.getOwnPropertyDescriptor, ls = (t, e, s, i) => {
1702
+ for (var r = i > 1 ? void 0 : i ? hs(e, s) : e, o = t.length - 1, n; o >= 0; o--)
1565
1703
  (n = t[o]) && (r = n(r) || r);
1566
1704
  return r;
1567
1705
  };
1568
- let re = class {
1706
+ let _e = class {
1569
1707
  /** Текущий режим выборки. */
1570
- _selectMode = M.Mesh;
1708
+ _selectMode = v.Mesh;
1571
1709
  /** Текущий выбранный инструмент. */
1572
- _toolType = O.Translate;
1710
+ _toolType = C.Translate;
1573
1711
  /** Выбранный режим отображения. */
1574
- _displayMode = R.Plane;
1712
+ _displayMode = k.Plane;
1575
1713
  /** Выбранный объект на сцене. */
1576
1714
  _selectedObject = null;
1577
1715
  /** Слушатели событий по изменению выбранного объекта. */
1578
1716
  _selectedListeners = /* @__PURE__ */ new Set();
1579
1717
  constructor() {
1580
- Ze(this, {}, { autoBind: !0 });
1718
+ qe(this, {}, { autoBind: !0 });
1581
1719
  }
1582
1720
  /** @inheritdoc */
1583
1721
  getSelectMode() {
@@ -1619,24 +1757,24 @@ let re = class {
1619
1757
  return this._selectedListeners.add(t), () => this._selectedListeners.delete(t);
1620
1758
  }
1621
1759
  };
1622
- re = qt([
1760
+ _e = ls([
1623
1761
  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;
1762
+ ], _e);
1763
+ let xe = !1;
1764
+ const d = Ge.createChildContainer();
1765
+ function cs(t) {
1766
+ return xe || (d.registerInstance("Canvas", t), d.registerSingleton("EventBus", X), d.registerSingleton("EditorRenderer", G), d.registerSingleton("RendererApi", ce), d.registerSingleton("IDisplayHandler", ee), d.registerSingleton("ISelectHandler", te), d.registerSingleton("ISelectHandler", se), d.registerSingleton("ISelectHandler", ae), d.registerSingleton("ISelectHandler", ie), d.registerSingleton("IToolHandler", re), d.registerSingleton("IToolHandler", oe), d.registerSingleton("IToolHandler", ne), d.registerSingleton("ISceneHandler", he), d.registerSingleton("ISceneHandler", le), d.registerSingleton("IDisplayManager", K), d.registerSingleton("ISelectManager", q), d.registerSingleton("IToolManager", Q), d.registerSingleton("ISceneManager", J), d.registerSingleton("EditorHub", de), d.registerSingleton("IEditorStore", _e), xe = !0), d;
1629
1767
  }
1630
- function hs(t) {
1631
- return Qt(t).resolve("EditorHub");
1768
+ function ys(t) {
1769
+ return cs(t).resolve("EditorHub");
1632
1770
  }
1633
1771
  export {
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
1772
+ de as EditorHub,
1773
+ G as EditorRenderer,
1774
+ X as EventBus,
1775
+ R as EventTopics,
1776
+ vs as ObjLoader,
1777
+ bs as PreviewRenderer,
1778
+ Re as Renderer,
1779
+ ys as createAppHub
1642
1780
  };