gl-draw 0.15.0-beta.3 → 0.15.0-beta.30
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/constants.d.ts +1 -0
- package/dist/core/BaseObject/PointerEvent.d.ts +13 -0
- package/dist/core/BaseObject/UseMaterial.d.ts +23 -0
- package/dist/core/{BaseObject.d.ts → BaseObject/index.d.ts} +24 -29
- package/dist/core/Composer.d.ts +5 -5
- package/dist/core/Lead/Lead.d.ts +17 -10
- package/dist/core/Lead/Pick.d.ts +2 -1
- package/dist/core/MList/MList.d.ts +11 -5
- package/dist/core/Pencil.d.ts +12 -10
- package/dist/core/Renderer.d.ts +0 -1
- package/dist/core/ResourceTracker.d.ts +4 -6
- package/dist/index.js +23 -23
- package/dist/index.module.js +1702 -1562
- package/dist/index.module2.js +641 -787
- package/dist/index2.js +130 -140
- package/dist/objects/conicPolygon/geometry/index.d.ts +4 -4
- package/dist/objects/extrudePolygon/ExtrudeGeometry.d.ts +1 -1
- package/dist/objects/extrudePolygon/createGeometry.d.ts +9 -13
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +811 -783
- package/dist/objects/line/createGeometry.d.ts +2 -2
- package/dist/objects/line/index.d.ts +4 -4
- package/dist/objects/line/meshLine/MeshLineGeometry.d.ts +16 -35
- package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +59 -40
- package/dist/objects/line/meshLine/fragment.d.ts +1 -0
- package/dist/objects/line/meshLine/utils.d.ts +4 -0
- package/dist/objects/line/meshLine/vertex.d.ts +1 -0
- package/dist/objects/line2/WebGPULineSegments2.d.ts +1 -1
- package/dist/objects/line2/createGeometry.d.ts +1 -1
- package/dist/objects/pie/index.d.ts +9 -13
- package/dist/plugins/Worker/createGeometry.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +36 -36
- package/dist/utils/Sprite2Points.d.ts +1 -1
- package/dist/utils/setInstancedAttr.d.ts +6 -0
- package/package.json +1 -1
- package/dist/objects/scene/index.d.ts +0 -11
package/dist/index.module.js
CHANGED
|
@@ -1,48 +1,41 @@
|
|
|
1
|
-
var
|
|
1
|
+
var At = Object.defineProperty, St = Object.defineProperties;
|
|
2
2
|
var Mt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Me = Object.getOwnPropertySymbols;
|
|
4
4
|
var Rt = Object.prototype.hasOwnProperty, Dt = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Re = (h, e, t) => e in h ?
|
|
5
|
+
var Re = (h, e, t) => e in h ? At(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t, U = (h, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
7
|
Rt.call(e, t) && Re(h, t, e[t]);
|
|
8
8
|
if (Me)
|
|
9
9
|
for (var t of Me(e))
|
|
10
10
|
Dt.call(e, t) && Re(h, t, e[t]);
|
|
11
11
|
return h;
|
|
12
|
-
}, te = (h, e) =>
|
|
12
|
+
}, te = (h, e) => St(h, Mt(e));
|
|
13
13
|
var se = (h, e, t) => new Promise((s, i) => {
|
|
14
|
-
var r = (
|
|
14
|
+
var r = (a) => {
|
|
15
15
|
try {
|
|
16
|
-
n(t.next(
|
|
17
|
-
} catch (
|
|
18
|
-
i(
|
|
16
|
+
n(t.next(a));
|
|
17
|
+
} catch (c) {
|
|
18
|
+
i(c);
|
|
19
19
|
}
|
|
20
|
-
}, o = (
|
|
20
|
+
}, o = (a) => {
|
|
21
21
|
try {
|
|
22
|
-
n(t.throw(
|
|
23
|
-
} catch (
|
|
24
|
-
i(
|
|
22
|
+
n(t.throw(a));
|
|
23
|
+
} catch (c) {
|
|
24
|
+
i(c);
|
|
25
25
|
}
|
|
26
|
-
}, n = (
|
|
26
|
+
}, n = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(r, o);
|
|
27
27
|
n((t = t.apply(h, e)).next());
|
|
28
28
|
});
|
|
29
|
-
import { WebGLRenderer as Ut, Vector2 as B, Vector3 as I, PerspectiveCamera as zt, Matrix4 as W, Scene as nt, AxesHelper as De, CameraHelper as kt, PointLightHelper as Ft, DirectionalLightHelper as Nt, SpotLightHelper as Ht, HemisphereLightHelper as It, Box3 as at, Box3Helper as Ue, MathUtils as jt, Vector4 as Bt, Quaternion as lt, Spherical as Vt, Sphere as Yt, Raycaster as ht, REVISION as Zt, Object3D as Wt, UniformsUtils as Gt, RawShaderMaterial as Kt, ShaderMaterial as Xt, MeshBasicMaterial as $t, PointsMaterial as ct, SpriteMaterial as dt, Layers as qt, WebGLRenderTarget as Qt, HalfFloatType as Jt, Loader as pt, Texture as fe, VideoTexture as mt, FileLoader as Se, LoadingManager as es, DataTexture as ts, Mesh as ss, BufferGeometry as is } from "three";
|
|
30
|
-
import { Timer as rs } from "three/examples/jsm/misc/Timer";
|
|
31
29
|
import * as Ce from "@tweenjs/tween.js";
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import { ViewHelper as ps } from "three/examples/jsm/helpers/ViewHelper";
|
|
38
|
-
import { TransformControls as ms } from "three/examples/jsm/controls/TransformControls";
|
|
30
|
+
import Ut from "deepmerge";
|
|
31
|
+
import zt from "stats-gl";
|
|
32
|
+
import { Vector3 as j, PerspectiveCamera as kt, Matrix4 as W, ShaderMaterial as Ft, UniformsUtils as Nt, RawShaderMaterial as It, MeshBasicMaterial as jt, PointsMaterial as nt, SpriteMaterial as at, Layers as Ht, Vector2 as B, WebGLRenderTarget as Bt, HalfFloatType as Vt, MathUtils as Yt, Vector4 as Zt, Quaternion as lt, Spherical as Wt, Box3 as ht, Sphere as Kt, Raycaster as ct, AxesHelper as De, CameraHelper as $t, PointLightHelper as Gt, DirectionalLightHelper as Xt, SpotLightHelper as qt, HemisphereLightHelper as Qt, Box3Helper as Ue, Scene as dt, Group as ze, Camera as Jt, Loader as mt, Texture as ue, VideoTexture as pt, FileLoader as Ae, LoadingManager as es, DataTexture as ts, WebGLRenderer as ss, REVISION as is, Object3D as rs } from "three";
|
|
33
|
+
import { Timer as os } from "three/examples/jsm/misc/Timer";
|
|
34
|
+
import { M as ft, B as Oe, a as ns, R as Pe, I as he } from "./index.module2.js";
|
|
39
35
|
import { EffectComposer as ke } from "three/examples/jsm/postprocessing/EffectComposer";
|
|
40
|
-
import { RenderPass as
|
|
41
|
-
import { SSAOPass as
|
|
42
|
-
import {
|
|
43
|
-
import { OutputPass as _s } from "three/examples/jsm/postprocessing/OutputPass";
|
|
44
|
-
import { ShaderPass as gs } from "three/examples/jsm/postprocessing/ShaderPass";
|
|
45
|
-
import { UnrealBloomPass as vs } from "three/examples/jsm/postprocessing/UnrealBloomPass";
|
|
36
|
+
import { RenderPass as as } from "three/examples/jsm/postprocessing/RenderPass";
|
|
37
|
+
import { SSAOPass as ls } from "three/examples/jsm/postprocessing/SSAOPass";
|
|
38
|
+
import { UnrealBloomPass as hs } from "three/examples/jsm/postprocessing/UnrealBloomPass";
|
|
46
39
|
import "three/examples/jsm/renderers/CSS2DRenderer";
|
|
47
40
|
import "three/examples/jsm/renderers/CSS3DRenderer";
|
|
48
41
|
import "d3-geo";
|
|
@@ -53,16 +46,23 @@ import "three/examples/jsm/lines/LineSegments2";
|
|
|
53
46
|
import "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
54
47
|
import "three/examples/jsm/lines/LineMaterial";
|
|
55
48
|
import "three-bvh-csg";
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
49
|
+
import { ShaderPass as cs } from "three/examples/jsm/postprocessing/ShaderPass";
|
|
50
|
+
import { FullScreenQuad as Fe } from "three/examples/jsm/postprocessing/Pass";
|
|
51
|
+
import { OutputPass as ds } from "three/examples/jsm/postprocessing/OutputPass";
|
|
52
|
+
import { RectAreaLightHelper as ms } from "three/examples/jsm/helpers/RectAreaLightHelper";
|
|
53
|
+
import { ViewHelper as ps } from "three/examples/jsm/helpers/ViewHelper";
|
|
54
|
+
import { generateUUID as Ne, makePromiseCreator as fs } from "esus-lite";
|
|
55
|
+
import { GLTFLoader as Ie } from "three/examples/jsm/loaders/GLTFLoader";
|
|
56
|
+
import { DRACOLoader as us } from "three/examples/jsm/loaders/DRACOLoader";
|
|
57
|
+
import { EXRLoader as _s } from "three/examples/jsm/loaders/EXRLoader";
|
|
58
|
+
import { LottieLoader as gs } from "three/examples/jsm/loaders/LottieLoader";
|
|
59
|
+
import { c as ys, C as vs, i as Cs } from "./isPlainObject.module.js";
|
|
60
|
+
import { TransformControls as Os } from "three/examples/jsm/controls/TransformControls";
|
|
61
61
|
const M = {
|
|
62
62
|
LEFT: 1,
|
|
63
63
|
RIGHT: 2,
|
|
64
64
|
MIDDLE: 4
|
|
65
|
-
},
|
|
65
|
+
}, d = Object.freeze({
|
|
66
66
|
NONE: 0,
|
|
67
67
|
ROTATE: 1,
|
|
68
68
|
TRUCK: 2,
|
|
@@ -84,7 +84,7 @@ const M = {
|
|
|
84
84
|
TOUCH_SCREEN_PAN: 131072,
|
|
85
85
|
TOUCH_DOLLY_SCREEN_PAN: 262144,
|
|
86
86
|
TOUCH_ZOOM_SCREEN_PAN: 524288
|
|
87
|
-
}),
|
|
87
|
+
}), K = {
|
|
88
88
|
NONE: 0,
|
|
89
89
|
IN: 1,
|
|
90
90
|
OUT: -1
|
|
@@ -92,20 +92,20 @@ const M = {
|
|
|
92
92
|
function Y(h) {
|
|
93
93
|
return h.isPerspectiveCamera;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function H(h) {
|
|
96
96
|
return h.isOrthographicCamera;
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const $ = Math.PI * 2, je = Math.PI / 2, ut = 1e-5, ie = Math.PI / 180;
|
|
99
99
|
function k(h, e, t) {
|
|
100
100
|
return Math.max(e, Math.min(t, h));
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function S(h, e = ut) {
|
|
103
103
|
return Math.abs(h) < e;
|
|
104
104
|
}
|
|
105
|
-
function P(h, e, t =
|
|
106
|
-
return
|
|
105
|
+
function P(h, e, t = ut) {
|
|
106
|
+
return S(h - e, t);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function He(h, e) {
|
|
109
109
|
return Math.round(h / e) * e;
|
|
110
110
|
}
|
|
111
111
|
function re(h) {
|
|
@@ -114,41 +114,41 @@ function re(h) {
|
|
|
114
114
|
function oe(h) {
|
|
115
115
|
return Math.abs(h) < Number.MAX_VALUE ? h : h * (1 / 0);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ce(h, e, t, s, i = 1 / 0, r) {
|
|
118
118
|
s = Math.max(1e-4, s);
|
|
119
|
-
const o = 2 / s, n = o * r,
|
|
120
|
-
let
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
t.value = (t.value - o *
|
|
125
|
-
let
|
|
126
|
-
return
|
|
119
|
+
const o = 2 / s, n = o * r, a = 1 / (1 + n + 0.48 * n * n + 0.235 * n * n * n);
|
|
120
|
+
let c = h - e;
|
|
121
|
+
const u = e, m = i * s;
|
|
122
|
+
c = k(c, -m, m), e = h - c;
|
|
123
|
+
const v = (t.value + o * c) * r;
|
|
124
|
+
t.value = (t.value - o * v) * a;
|
|
125
|
+
let p = e + (c + v) * a;
|
|
126
|
+
return u - h > 0 == p > u && (p = u, t.value = (p - u) / r), p;
|
|
127
127
|
}
|
|
128
128
|
function Be(h, e, t, s, i = 1 / 0, r, o) {
|
|
129
129
|
s = Math.max(1e-4, s);
|
|
130
|
-
const n = 2 / s,
|
|
131
|
-
let
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
t.x = (t.x - n *
|
|
140
|
-
const V =
|
|
141
|
-
return V * xt + le * Lt +
|
|
130
|
+
const n = 2 / s, a = n * r, c = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
|
|
131
|
+
let u = e.x, m = e.y, v = e.z, p = h.x - u, f = h.y - m, g = h.z - v;
|
|
132
|
+
const y = u, l = m, _ = v, O = i * s, C = O * O, w = p * p + f * f + g * g;
|
|
133
|
+
if (w > C) {
|
|
134
|
+
const ve = Math.sqrt(w);
|
|
135
|
+
p = p / ve * O, f = f / ve * O, g = g / ve * O;
|
|
136
|
+
}
|
|
137
|
+
u = h.x - p, m = h.y - f, v = h.z - g;
|
|
138
|
+
const E = (t.x + n * p) * r, x = (t.y + n * f) * r, R = (t.z + n * g) * r;
|
|
139
|
+
t.x = (t.x - n * E) * c, t.y = (t.y - n * x) * c, t.z = (t.z - n * R) * c, o.x = u + (p + E) * c, o.y = m + (f + x) * c, o.z = v + (g + R) * c;
|
|
140
|
+
const V = y - h.x, le = l - h.y, bt = _ - h.z, xt = o.x - y, Lt = o.y - l, Pt = o.z - _;
|
|
141
|
+
return V * xt + le * Lt + bt * Pt > 0 && (o.x = y, o.y = l, o.z = _, t.x = (o.x - y) / r, t.y = (o.y - l) / r, t.z = (o.z - _) / r), o;
|
|
142
142
|
}
|
|
143
143
|
function Ee(h, e) {
|
|
144
144
|
e.set(0, 0), h.forEach((t) => {
|
|
145
145
|
e.x += t.clientX, e.y += t.clientY;
|
|
146
146
|
}), e.x /= h.length, e.y /= h.length;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
148
|
+
function Te(h, e) {
|
|
149
|
+
return H(h) ? (console.warn(`${e} is not supported in OrthographicCamera`), !0) : !1;
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class Es {
|
|
152
152
|
constructor() {
|
|
153
153
|
this._listeners = {};
|
|
154
154
|
}
|
|
@@ -212,18 +212,18 @@ class Ts {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
let T, Ve,
|
|
217
|
-
class J extends
|
|
215
|
+
const de = 1 / 8, Ts = /Mac/.test(navigator.platform);
|
|
216
|
+
let T, Ve, me, we, D, b, L, G, ne, F, N, Z, Ye, Ze, z, ae, X, We, be, Ke, xe, Le, pe;
|
|
217
|
+
class J extends Es {
|
|
218
218
|
static install(e) {
|
|
219
|
-
T = e.THREE, Ve = Object.freeze(new T.Vector3(0, 0, 0)),
|
|
219
|
+
T = e.THREE, Ve = Object.freeze(new T.Vector3(0, 0, 0)), me = Object.freeze(new T.Vector3(0, 1, 0)), we = Object.freeze(new T.Vector3(0, 0, 1)), D = new T.Vector2(), b = new T.Vector3(), L = new T.Vector3(), G = new T.Vector3(), ne = new T.Vector3(), F = new T.Vector3(), N = new T.Vector3(), Z = new T.Vector3(), Ye = new T.Vector3(), Ze = new T.Vector3(), z = new T.Spherical(), ae = new T.Spherical(), X = new T.Box3(), We = new T.Box3(), be = new T.Sphere(), Ke = new T.Quaternion(), xe = new T.Quaternion(), Le = new T.Matrix4(), pe = new T.Raycaster();
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* list all ACTIONs
|
|
223
223
|
* @category Statics
|
|
224
224
|
*/
|
|
225
225
|
static get ACTION() {
|
|
226
|
-
return
|
|
226
|
+
return d;
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
229
|
* Creates a `CameraControls` instance.
|
|
@@ -244,47 +244,47 @@ class J extends Ts {
|
|
|
244
244
|
*/
|
|
245
245
|
constructor(e, t) {
|
|
246
246
|
super(), this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.minDistance = Number.EPSILON, this.maxDistance = 1 / 0, this.infinityDolly = !1, this.minZoom = 0.01, this.maxZoom = 1 / 0, this.smoothTime = 0.25, this.draggingSmoothTime = 0.125, this.maxSpeed = 1 / 0, this.azimuthRotateSpeed = 1, this.polarRotateSpeed = 1, this.dollySpeed = 1, this.dollyDragInverted = !1, this.truckSpeed = 2, this.dollyToCursor = !1, this.dragToOffset = !1, this.boundaryFriction = 0, this.restThreshold = 0.01, this.colliderMeshes = [], this.cancel = () => {
|
|
247
|
-
}, this._enabled = !0, this._state =
|
|
248
|
-
let
|
|
247
|
+
}, this._enabled = !0, this._state = d.NONE, this._viewport = null, this._changedDolly = 0, this._changedZoom = 0, this._hasRested = !0, this._boundaryEnclosesCamera = !1, this._needsUpdate = !0, this._updatedLastTime = !1, this._elementRect = new DOMRect(), this._isDragging = !1, this._dragNeedsUpdate = !0, this._activePointers = [], this._lockedPointer = null, this._interactiveArea = new DOMRect(0, 0, 1, 1), this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._isUserControllingOffset = !1, this._isUserControllingZoom = !1, this._lastDollyDirection = K.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new T.Vector3(), this._focalOffsetVelocity = new T.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (l, _, O, C) => {
|
|
248
|
+
let w, E;
|
|
249
249
|
if (Y(this._camera)) {
|
|
250
|
-
const x =
|
|
251
|
-
|
|
252
|
-
} else if (
|
|
250
|
+
const x = b.copy(this._camera.position).sub(this._target), R = this._camera.getEffectiveFOV() * ie, V = x.length() * Math.tan(R * 0.5);
|
|
251
|
+
w = this.truckSpeed * l * V / this._elementRect.height, E = this.truckSpeed * _ * V / this._elementRect.height;
|
|
252
|
+
} else if (H(this._camera)) {
|
|
253
253
|
const x = this._camera;
|
|
254
|
-
|
|
254
|
+
w = this.truckSpeed * l * (x.right - x.left) / x.zoom / this._elementRect.width, E = this.truckSpeed * _ * (x.top - x.bottom) / x.zoom / this._elementRect.height;
|
|
255
255
|
} else
|
|
256
256
|
return;
|
|
257
|
-
|
|
258
|
-
this._focalOffsetEnd.x +
|
|
257
|
+
C ? (O ? this.setFocalOffset(
|
|
258
|
+
this._focalOffsetEnd.x + w,
|
|
259
259
|
this._focalOffsetEnd.y,
|
|
260
260
|
this._focalOffsetEnd.z,
|
|
261
261
|
!0
|
|
262
|
-
) : this.truck(
|
|
263
|
-
this._focalOffsetEnd.x +
|
|
264
|
-
this._focalOffsetEnd.y +
|
|
262
|
+
) : this.truck(w, 0, !0), this.forward(-E, !0)) : O ? this.setFocalOffset(
|
|
263
|
+
this._focalOffsetEnd.x + w,
|
|
264
|
+
this._focalOffsetEnd.y + E,
|
|
265
265
|
this._focalOffsetEnd.z,
|
|
266
266
|
!0
|
|
267
|
-
) : this.truck(
|
|
268
|
-
}, this._rotateInternal = (
|
|
269
|
-
const
|
|
270
|
-
this.rotate(
|
|
271
|
-
}, this._dollyInternal = (
|
|
272
|
-
const
|
|
273
|
-
|
|
267
|
+
) : this.truck(w, E, !0);
|
|
268
|
+
}, this._rotateInternal = (l, _) => {
|
|
269
|
+
const O = $ * this.azimuthRotateSpeed * l / this._elementRect.height, C = $ * this.polarRotateSpeed * _ / this._elementRect.height;
|
|
270
|
+
this.rotate(O, C, !0);
|
|
271
|
+
}, this._dollyInternal = (l, _, O) => {
|
|
272
|
+
const C = Math.pow(0.95, -l * this.dollySpeed), w = this._sphericalEnd.radius, E = this._sphericalEnd.radius * C, x = k(
|
|
273
|
+
E,
|
|
274
274
|
this.minDistance,
|
|
275
275
|
this.maxDistance
|
|
276
|
-
), R = x -
|
|
277
|
-
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(
|
|
278
|
-
}, this._zoomInternal = (
|
|
279
|
-
const
|
|
280
|
-
this.zoomTo(
|
|
276
|
+
), R = x - E;
|
|
277
|
+
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(E, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(x, !0)) : this._dollyToNoClamp(x, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? E : x) - w, this._dollyControlCoord.set(_, O)), this._lastDollyDirection = Math.sign(-l);
|
|
278
|
+
}, this._zoomInternal = (l, _, O) => {
|
|
279
|
+
const C = Math.pow(0.95, l * this.dollySpeed), w = this._zoom, E = this._zoom * C;
|
|
280
|
+
this.zoomTo(E, !0), this.dollyToCursor && (this._changedZoom += E - w, this._dollyControlCoord.set(_, O));
|
|
281
281
|
}, typeof T == "undefined" && console.error(
|
|
282
282
|
"camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."
|
|
283
283
|
), this._camera = e, this._yAxisUpSpace = new T.Quaternion().setFromUnitVectors(
|
|
284
284
|
this._camera.up,
|
|
285
|
-
|
|
286
|
-
), this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone().invert(), this._state =
|
|
287
|
-
|
|
285
|
+
me
|
|
286
|
+
), this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone().invert(), this._state = d.NONE, this._target = new T.Vector3(), this._targetEnd = this._target.clone(), this._focalOffset = new T.Vector3(), this._focalOffsetEnd = this._focalOffset.clone(), this._spherical = new T.Spherical().setFromVector3(
|
|
287
|
+
b.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)
|
|
288
288
|
), this._sphericalEnd = this._spherical.clone(), this._lastDistance = this._spherical.radius, this._zoom = this._camera.zoom, this._zoomEnd = this._zoom, this._lastZoom = this._zoom, this._nearPlaneCorners = [
|
|
289
289
|
new T.Vector3(),
|
|
290
290
|
new T.Vector3(),
|
|
@@ -294,54 +294,54 @@ class J extends Ts {
|
|
|
294
294
|
new T.Vector3(-1 / 0, -1 / 0, -1 / 0),
|
|
295
295
|
new T.Vector3(1 / 0, 1 / 0, 1 / 0)
|
|
296
296
|
), this._cameraUp0 = this._camera.up.clone(), this._target0 = this._target.clone(), this._position0 = this._camera.position.clone(), this._zoom0 = this._zoom, this._focalOffset0 = this._focalOffset.clone(), this._dollyControlCoord = new T.Vector2(), this.mouseButtons = {
|
|
297
|
-
left:
|
|
298
|
-
middle:
|
|
299
|
-
right:
|
|
300
|
-
wheel: Y(this._camera) ?
|
|
297
|
+
left: d.ROTATE,
|
|
298
|
+
middle: d.DOLLY,
|
|
299
|
+
right: d.TRUCK,
|
|
300
|
+
wheel: Y(this._camera) ? d.DOLLY : H(this._camera) ? d.ZOOM : d.NONE
|
|
301
301
|
}, this.touches = {
|
|
302
|
-
one:
|
|
303
|
-
two: Y(this._camera) ?
|
|
304
|
-
three:
|
|
302
|
+
one: d.TOUCH_ROTATE,
|
|
303
|
+
two: Y(this._camera) ? d.TOUCH_DOLLY_TRUCK : H(this._camera) ? d.TOUCH_ZOOM_TRUCK : d.NONE,
|
|
304
|
+
three: d.TOUCH_TRUCK
|
|
305
305
|
};
|
|
306
|
-
const s = new T.Vector2(), i = new T.Vector2(), r = new T.Vector2(), o = (
|
|
306
|
+
const s = new T.Vector2(), i = new T.Vector2(), r = new T.Vector2(), o = (l) => {
|
|
307
307
|
if (!this._enabled || !this._domElement) return;
|
|
308
308
|
if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
309
|
+
const C = this._domElement.getBoundingClientRect(), w = (l.clientX - C.left) / (C.right - C.left), E = (l.clientY - C.top) / (C.bottom - C.top);
|
|
310
|
+
if (w < this._interactiveArea.left || w > this._interactiveArea.right || E < this._interactiveArea.top || E > this._interactiveArea.bottom)
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
|
|
313
|
+
const _ = l.pointerType !== "mouse" ? null : (l.buttons & M.LEFT) === M.LEFT ? M.LEFT : (l.buttons & M.MIDDLE) === M.MIDDLE ? M.MIDDLE : (l.buttons & M.RIGHT) === M.RIGHT ? M.RIGHT : null;
|
|
314
|
+
if (_ !== null) {
|
|
315
|
+
const C = this._findPointerByMouseButton(_);
|
|
316
|
+
C && this._disposePointer(C);
|
|
317
317
|
}
|
|
318
|
-
if ((
|
|
318
|
+
if ((l.buttons & M.LEFT) === M.LEFT && this._lockedPointer)
|
|
319
319
|
return;
|
|
320
|
-
const
|
|
321
|
-
pointerId:
|
|
322
|
-
clientX:
|
|
323
|
-
clientY:
|
|
320
|
+
const O = {
|
|
321
|
+
pointerId: l.pointerId,
|
|
322
|
+
clientX: l.clientX,
|
|
323
|
+
clientY: l.clientY,
|
|
324
324
|
deltaX: 0,
|
|
325
325
|
deltaY: 0,
|
|
326
|
-
mouseButton:
|
|
326
|
+
mouseButton: _
|
|
327
327
|
};
|
|
328
|
-
this._activePointers.push(
|
|
328
|
+
this._activePointers.push(O), this._domElement.ownerDocument.removeEventListener(
|
|
329
329
|
"pointermove",
|
|
330
330
|
n,
|
|
331
331
|
{ passive: !1 }
|
|
332
332
|
), this._domElement.ownerDocument.removeEventListener(
|
|
333
333
|
"pointerup",
|
|
334
|
-
|
|
334
|
+
a
|
|
335
335
|
), this._domElement.ownerDocument.addEventListener(
|
|
336
336
|
"pointermove",
|
|
337
337
|
n,
|
|
338
338
|
{ passive: !1 }
|
|
339
|
-
), this._domElement.ownerDocument.addEventListener("pointerup",
|
|
340
|
-
}, n = (
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
if (
|
|
344
|
-
if (
|
|
339
|
+
), this._domElement.ownerDocument.addEventListener("pointerup", a), this._isDragging = !0, v(l);
|
|
340
|
+
}, n = (l) => {
|
|
341
|
+
l.cancelable && l.preventDefault();
|
|
342
|
+
const _ = l.pointerId, O = this._lockedPointer || this._findPointerById(_);
|
|
343
|
+
if (O) {
|
|
344
|
+
if (O.clientX = l.clientX, O.clientY = l.clientY, O.deltaX = l.movementX, O.deltaY = l.movementY, this._state = 0, l.pointerType === "touch")
|
|
345
345
|
switch (this._activePointers.length) {
|
|
346
346
|
case 1:
|
|
347
347
|
this._state = this.touches.one;
|
|
@@ -354,16 +354,16 @@ class J extends Ts {
|
|
|
354
354
|
break;
|
|
355
355
|
}
|
|
356
356
|
else
|
|
357
|
-
(!this._isDragging && this._lockedPointer || this._isDragging && (
|
|
358
|
-
|
|
357
|
+
(!this._isDragging && this._lockedPointer || this._isDragging && (l.buttons & M.LEFT) === M.LEFT) && (this._state = this._state | this.mouseButtons.left), this._isDragging && (l.buttons & M.MIDDLE) === M.MIDDLE && (this._state = this._state | this.mouseButtons.middle), this._isDragging && (l.buttons & M.RIGHT) === M.RIGHT && (this._state = this._state | this.mouseButtons.right);
|
|
358
|
+
p();
|
|
359
359
|
}
|
|
360
|
-
},
|
|
361
|
-
const
|
|
362
|
-
if (!(
|
|
363
|
-
if (
|
|
360
|
+
}, a = (l) => {
|
|
361
|
+
const _ = this._findPointerById(l.pointerId);
|
|
362
|
+
if (!(_ && _ === this._lockedPointer)) {
|
|
363
|
+
if (_ && this._disposePointer(_), l.pointerType === "touch")
|
|
364
364
|
switch (this._activePointers.length) {
|
|
365
365
|
case 0:
|
|
366
|
-
this._state =
|
|
366
|
+
this._state = d.NONE;
|
|
367
367
|
break;
|
|
368
368
|
case 1:
|
|
369
369
|
this._state = this.touches.one;
|
|
@@ -376,77 +376,77 @@ class J extends Ts {
|
|
|
376
376
|
break;
|
|
377
377
|
}
|
|
378
378
|
else
|
|
379
|
-
this._state =
|
|
380
|
-
|
|
379
|
+
this._state = d.NONE;
|
|
380
|
+
f();
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
|
-
let
|
|
384
|
-
const
|
|
385
|
-
if (!this._domElement || !this._enabled || this.mouseButtons.wheel ===
|
|
383
|
+
let c = -1;
|
|
384
|
+
const u = (l) => {
|
|
385
|
+
if (!this._domElement || !this._enabled || this.mouseButtons.wheel === d.NONE) return;
|
|
386
386
|
if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
|
|
387
|
-
const
|
|
387
|
+
const E = this._domElement.getBoundingClientRect(), x = (l.clientX - E.left) / (E.right - E.left), R = (l.clientY - E.top) / (E.bottom - E.top);
|
|
388
388
|
if (x < this._interactiveArea.left || x > this._interactiveArea.right || R < this._interactiveArea.top || R > this._interactiveArea.bottom)
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
|
|
391
|
+
if (l.preventDefault(), this.dollyToCursor || this.mouseButtons.wheel === d.ROTATE || this.mouseButtons.wheel === d.TRUCK) {
|
|
392
|
+
const E = performance.now();
|
|
393
|
+
c - E < 1e3 && this._getClientRect(this._elementRect), c = E;
|
|
394
394
|
}
|
|
395
|
-
const
|
|
395
|
+
const _ = Ts ? -1 : -3, O = l.deltaMode === 1 || l.ctrlKey ? l.deltaY / _ : l.deltaY / (_ * 10), C = this.dollyToCursor ? (l.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, w = this.dollyToCursor ? (l.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
|
|
396
396
|
switch (this.mouseButtons.wheel) {
|
|
397
|
-
case
|
|
398
|
-
this._rotateInternal(
|
|
397
|
+
case d.ROTATE: {
|
|
398
|
+
this._rotateInternal(l.deltaX, l.deltaY), this._isUserControllingRotate = !0;
|
|
399
399
|
break;
|
|
400
400
|
}
|
|
401
|
-
case
|
|
402
|
-
this._truckInternal(
|
|
401
|
+
case d.TRUCK: {
|
|
402
|
+
this._truckInternal(l.deltaX, l.deltaY, !1, !1), this._isUserControllingTruck = !0;
|
|
403
403
|
break;
|
|
404
404
|
}
|
|
405
|
-
case
|
|
406
|
-
this._truckInternal(
|
|
405
|
+
case d.SCREEN_PAN: {
|
|
406
|
+
this._truckInternal(l.deltaX, l.deltaY, !1, !0), this._isUserControllingTruck = !0;
|
|
407
407
|
break;
|
|
408
408
|
}
|
|
409
|
-
case
|
|
410
|
-
this._truckInternal(
|
|
409
|
+
case d.OFFSET: {
|
|
410
|
+
this._truckInternal(l.deltaX, l.deltaY, !0, !1), this._isUserControllingOffset = !0;
|
|
411
411
|
break;
|
|
412
412
|
}
|
|
413
|
-
case
|
|
414
|
-
this._dollyInternal(-
|
|
413
|
+
case d.DOLLY: {
|
|
414
|
+
this._dollyInternal(-O, C, w), this._isUserControllingDolly = !0;
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
|
-
case
|
|
418
|
-
this._zoomInternal(-
|
|
417
|
+
case d.ZOOM: {
|
|
418
|
+
this._zoomInternal(-O, C, w), this._isUserControllingZoom = !0;
|
|
419
419
|
break;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
this.dispatchEvent({ type: "control" });
|
|
423
|
-
},
|
|
423
|
+
}, m = (l) => {
|
|
424
424
|
if (!(!this._domElement || !this._enabled)) {
|
|
425
425
|
if (this.mouseButtons.right === J.ACTION.NONE) {
|
|
426
|
-
const
|
|
427
|
-
|
|
426
|
+
const _ = l instanceof PointerEvent ? l.pointerId : 0, O = this._findPointerById(_);
|
|
427
|
+
O && this._disposePointer(O), this._domElement.ownerDocument.removeEventListener(
|
|
428
428
|
"pointermove",
|
|
429
429
|
n,
|
|
430
430
|
{ passive: !1 }
|
|
431
431
|
), this._domElement.ownerDocument.removeEventListener(
|
|
432
432
|
"pointerup",
|
|
433
|
-
|
|
433
|
+
a
|
|
434
434
|
);
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
|
|
437
|
+
l.preventDefault();
|
|
438
438
|
}
|
|
439
|
-
},
|
|
439
|
+
}, v = (l) => {
|
|
440
440
|
if (!this._enabled) return;
|
|
441
441
|
if (Ee(this._activePointers, D), this._getClientRect(this._elementRect), s.copy(D), i.copy(D), this._activePointers.length >= 2) {
|
|
442
|
-
const
|
|
443
|
-
r.set(0,
|
|
444
|
-
const
|
|
445
|
-
i.set(
|
|
442
|
+
const O = D.x - this._activePointers[1].clientX, C = D.y - this._activePointers[1].clientY, w = Math.sqrt(O * O + C * C);
|
|
443
|
+
r.set(0, w);
|
|
444
|
+
const E = (this._activePointers[0].clientX + this._activePointers[1].clientX) * 0.5, x = (this._activePointers[0].clientY + this._activePointers[1].clientY) * 0.5;
|
|
445
|
+
i.set(E, x);
|
|
446
446
|
}
|
|
447
|
-
if (this._state = 0, !
|
|
447
|
+
if (this._state = 0, !l)
|
|
448
448
|
this._lockedPointer && (this._state = this._state | this.mouseButtons.left);
|
|
449
|
-
else if ("pointerType" in
|
|
449
|
+
else if ("pointerType" in l && l.pointerType === "touch")
|
|
450
450
|
switch (this._activePointers.length) {
|
|
451
451
|
case 1:
|
|
452
452
|
this._state = this.touches.one;
|
|
@@ -459,39 +459,39 @@ class J extends Ts {
|
|
|
459
459
|
break;
|
|
460
460
|
}
|
|
461
461
|
else
|
|
462
|
-
!this._lockedPointer && (
|
|
463
|
-
((this._state &
|
|
464
|
-
},
|
|
462
|
+
!this._lockedPointer && (l.buttons & M.LEFT) === M.LEFT && (this._state = this._state | this.mouseButtons.left), (l.buttons & M.MIDDLE) === M.MIDDLE && (this._state = this._state | this.mouseButtons.middle), (l.buttons & M.RIGHT) === M.RIGHT && (this._state = this._state | this.mouseButtons.right);
|
|
463
|
+
((this._state & d.ROTATE) === d.ROTATE || (this._state & d.TOUCH_ROTATE) === d.TOUCH_ROTATE || (this._state & d.TOUCH_DOLLY_ROTATE) === d.TOUCH_DOLLY_ROTATE || (this._state & d.TOUCH_ZOOM_ROTATE) === d.TOUCH_ZOOM_ROTATE) && (this._sphericalEnd.theta = this._spherical.theta, this._sphericalEnd.phi = this._spherical.phi, this._thetaVelocity.value = 0, this._phiVelocity.value = 0), ((this._state & d.TRUCK) === d.TRUCK || (this._state & d.SCREEN_PAN) === d.SCREEN_PAN || (this._state & d.TOUCH_TRUCK) === d.TOUCH_TRUCK || (this._state & d.TOUCH_SCREEN_PAN) === d.TOUCH_SCREEN_PAN || (this._state & d.TOUCH_DOLLY_TRUCK) === d.TOUCH_DOLLY_TRUCK || (this._state & d.TOUCH_DOLLY_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN || (this._state & d.TOUCH_ZOOM_TRUCK) === d.TOUCH_ZOOM_TRUCK || (this._state & d.TOUCH_ZOOM_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN) && (this._targetEnd.copy(this._target), this._targetVelocity.set(0, 0, 0)), ((this._state & d.DOLLY) === d.DOLLY || (this._state & d.TOUCH_DOLLY) === d.TOUCH_DOLLY || (this._state & d.TOUCH_DOLLY_TRUCK) === d.TOUCH_DOLLY_TRUCK || (this._state & d.TOUCH_DOLLY_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN || (this._state & d.TOUCH_DOLLY_OFFSET) === d.TOUCH_DOLLY_OFFSET || (this._state & d.TOUCH_DOLLY_ROTATE) === d.TOUCH_DOLLY_ROTATE) && (this._sphericalEnd.radius = this._spherical.radius, this._radiusVelocity.value = 0), ((this._state & d.ZOOM) === d.ZOOM || (this._state & d.TOUCH_ZOOM) === d.TOUCH_ZOOM || (this._state & d.TOUCH_ZOOM_TRUCK) === d.TOUCH_ZOOM_TRUCK || (this._state & d.TOUCH_ZOOM_SCREEN_PAN) === d.TOUCH_ZOOM_SCREEN_PAN || (this._state & d.TOUCH_ZOOM_OFFSET) === d.TOUCH_ZOOM_OFFSET || (this._state & d.TOUCH_ZOOM_ROTATE) === d.TOUCH_ZOOM_ROTATE) && (this._zoomEnd = this._zoom, this._zoomVelocity.value = 0), ((this._state & d.OFFSET) === d.OFFSET || (this._state & d.TOUCH_OFFSET) === d.TOUCH_OFFSET || (this._state & d.TOUCH_DOLLY_OFFSET) === d.TOUCH_DOLLY_OFFSET || (this._state & d.TOUCH_ZOOM_OFFSET) === d.TOUCH_ZOOM_OFFSET) && (this._focalOffsetEnd.copy(this._focalOffset), this._focalOffsetVelocity.set(0, 0, 0)), this.dispatchEvent({ type: "controlstart" });
|
|
464
|
+
}, p = () => {
|
|
465
465
|
if (!this._enabled || !this._dragNeedsUpdate) return;
|
|
466
466
|
this._dragNeedsUpdate = !1, Ee(this._activePointers, D);
|
|
467
|
-
const
|
|
468
|
-
if (i.copy(D), ((this._state &
|
|
469
|
-
const
|
|
470
|
-
(this._state &
|
|
471
|
-
x *
|
|
472
|
-
|
|
473
|
-
|
|
467
|
+
const _ = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, O = _ ? -_.deltaX : i.x - D.x, C = _ ? -_.deltaY : i.y - D.y;
|
|
468
|
+
if (i.copy(D), ((this._state & d.ROTATE) === d.ROTATE || (this._state & d.TOUCH_ROTATE) === d.TOUCH_ROTATE || (this._state & d.TOUCH_DOLLY_ROTATE) === d.TOUCH_DOLLY_ROTATE || (this._state & d.TOUCH_ZOOM_ROTATE) === d.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(O, C), this._isUserControllingRotate = !0), (this._state & d.DOLLY) === d.DOLLY || (this._state & d.ZOOM) === d.ZOOM) {
|
|
469
|
+
const w = this.dollyToCursor ? (s.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, E = this.dollyToCursor ? (s.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0, x = this.dollyDragInverted ? -1 : 1;
|
|
470
|
+
(this._state & d.DOLLY) === d.DOLLY ? (this._dollyInternal(
|
|
471
|
+
x * C * de,
|
|
472
|
+
w,
|
|
473
|
+
E
|
|
474
474
|
), this._isUserControllingDolly = !0) : (this._zoomInternal(
|
|
475
|
-
x *
|
|
476
|
-
|
|
477
|
-
|
|
475
|
+
x * C * de,
|
|
476
|
+
w,
|
|
477
|
+
E
|
|
478
478
|
), this._isUserControllingZoom = !0);
|
|
479
479
|
}
|
|
480
|
-
if ((this._state &
|
|
481
|
-
const
|
|
480
|
+
if ((this._state & d.TOUCH_DOLLY) === d.TOUCH_DOLLY || (this._state & d.TOUCH_ZOOM) === d.TOUCH_ZOOM || (this._state & d.TOUCH_DOLLY_TRUCK) === d.TOUCH_DOLLY_TRUCK || (this._state & d.TOUCH_ZOOM_TRUCK) === d.TOUCH_ZOOM_TRUCK || (this._state & d.TOUCH_DOLLY_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN || (this._state & d.TOUCH_ZOOM_SCREEN_PAN) === d.TOUCH_ZOOM_SCREEN_PAN || (this._state & d.TOUCH_DOLLY_OFFSET) === d.TOUCH_DOLLY_OFFSET || (this._state & d.TOUCH_ZOOM_OFFSET) === d.TOUCH_ZOOM_OFFSET || (this._state & d.TOUCH_DOLLY_ROTATE) === d.TOUCH_DOLLY_ROTATE || (this._state & d.TOUCH_ZOOM_ROTATE) === d.TOUCH_ZOOM_ROTATE) {
|
|
481
|
+
const w = D.x - this._activePointers[1].clientX, E = D.y - this._activePointers[1].clientY, x = Math.sqrt(w * w + E * E), R = r.y - x;
|
|
482
482
|
r.set(0, x);
|
|
483
483
|
const V = this.dollyToCursor ? (i.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, le = this.dollyToCursor ? (i.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
|
|
484
|
-
(this._state &
|
|
484
|
+
(this._state & d.TOUCH_DOLLY) === d.TOUCH_DOLLY || (this._state & d.TOUCH_DOLLY_ROTATE) === d.TOUCH_DOLLY_ROTATE || (this._state & d.TOUCH_DOLLY_TRUCK) === d.TOUCH_DOLLY_TRUCK || (this._state & d.TOUCH_DOLLY_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN || (this._state & d.TOUCH_DOLLY_OFFSET) === d.TOUCH_DOLLY_OFFSET ? (this._dollyInternal(R * de, V, le), this._isUserControllingDolly = !0) : (this._zoomInternal(R * de, V, le), this._isUserControllingZoom = !0);
|
|
485
485
|
}
|
|
486
|
-
((this._state &
|
|
487
|
-
},
|
|
486
|
+
((this._state & d.TRUCK) === d.TRUCK || (this._state & d.TOUCH_TRUCK) === d.TOUCH_TRUCK || (this._state & d.TOUCH_DOLLY_TRUCK) === d.TOUCH_DOLLY_TRUCK || (this._state & d.TOUCH_ZOOM_TRUCK) === d.TOUCH_ZOOM_TRUCK) && (this._truckInternal(O, C, !1, !1), this._isUserControllingTruck = !0), ((this._state & d.SCREEN_PAN) === d.SCREEN_PAN || (this._state & d.TOUCH_SCREEN_PAN) === d.TOUCH_SCREEN_PAN || (this._state & d.TOUCH_DOLLY_SCREEN_PAN) === d.TOUCH_DOLLY_SCREEN_PAN || (this._state & d.TOUCH_ZOOM_SCREEN_PAN) === d.TOUCH_ZOOM_SCREEN_PAN) && (this._truckInternal(O, C, !1, !0), this._isUserControllingTruck = !0), ((this._state & d.OFFSET) === d.OFFSET || (this._state & d.TOUCH_OFFSET) === d.TOUCH_OFFSET || (this._state & d.TOUCH_DOLLY_OFFSET) === d.TOUCH_DOLLY_OFFSET || (this._state & d.TOUCH_ZOOM_OFFSET) === d.TOUCH_ZOOM_OFFSET) && (this._truckInternal(O, C, !0, !1), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
|
|
487
|
+
}, f = () => {
|
|
488
488
|
Ee(this._activePointers, D), i.copy(D), this._dragNeedsUpdate = !1, (this._activePointers.length === 0 || this._activePointers.length === 1 && this._activePointers[0] === this._lockedPointer) && (this._isDragging = !1), this._activePointers.length === 0 && this._domElement && (this._domElement.ownerDocument.removeEventListener(
|
|
489
489
|
"pointermove",
|
|
490
490
|
n,
|
|
491
491
|
{ passive: !1 }
|
|
492
492
|
), this._domElement.ownerDocument.removeEventListener(
|
|
493
493
|
"pointerup",
|
|
494
|
-
|
|
494
|
+
a
|
|
495
495
|
), this.dispatchEvent({ type: "controlend" }));
|
|
496
496
|
};
|
|
497
497
|
this.lockPointer = () => {
|
|
@@ -508,56 +508,56 @@ class J extends Ts {
|
|
|
508
508
|
{ passive: !1 }
|
|
509
509
|
), this._domElement.ownerDocument.removeEventListener(
|
|
510
510
|
"pointerup",
|
|
511
|
-
|
|
511
|
+
a
|
|
512
512
|
), this._domElement.requestPointerLock(), this._domElement.ownerDocument.addEventListener(
|
|
513
513
|
"pointerlockchange",
|
|
514
|
-
|
|
514
|
+
g
|
|
515
515
|
), this._domElement.ownerDocument.addEventListener(
|
|
516
516
|
"pointerlockerror",
|
|
517
|
-
|
|
517
|
+
y
|
|
518
518
|
), this._domElement.ownerDocument.addEventListener(
|
|
519
519
|
"pointermove",
|
|
520
520
|
n,
|
|
521
521
|
{ passive: !1 }
|
|
522
|
-
), this._domElement.ownerDocument.addEventListener("pointerup",
|
|
522
|
+
), this._domElement.ownerDocument.addEventListener("pointerup", a), v());
|
|
523
523
|
}, this.unlockPointer = () => {
|
|
524
|
-
var
|
|
525
|
-
this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (
|
|
524
|
+
var l, _, O;
|
|
525
|
+
this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (l = this._domElement) === null || l === void 0 || l.ownerDocument.exitPointerLock(), (_ = this._domElement) === null || _ === void 0 || _.ownerDocument.removeEventListener(
|
|
526
526
|
"pointerlockchange",
|
|
527
|
-
|
|
528
|
-
), (
|
|
527
|
+
g
|
|
528
|
+
), (O = this._domElement) === null || O === void 0 || O.ownerDocument.removeEventListener(
|
|
529
529
|
"pointerlockerror",
|
|
530
|
-
|
|
530
|
+
y
|
|
531
531
|
), this.cancel();
|
|
532
532
|
};
|
|
533
|
-
const
|
|
533
|
+
const g = () => {
|
|
534
534
|
this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement || this.unlockPointer();
|
|
535
|
-
},
|
|
535
|
+
}, y = () => {
|
|
536
536
|
this.unlockPointer();
|
|
537
537
|
};
|
|
538
|
-
this._addAllEventListeners = (
|
|
539
|
-
this._domElement =
|
|
538
|
+
this._addAllEventListeners = (l) => {
|
|
539
|
+
this._domElement = l, this._domElement.style.touchAction = "none", this._domElement.style.userSelect = "none", this._domElement.style.webkitUserSelect = "none", this._domElement.addEventListener("pointerdown", o), this._domElement.addEventListener("pointercancel", a), this._domElement.addEventListener("wheel", u, {
|
|
540
540
|
passive: !1
|
|
541
|
-
}), this._domElement.addEventListener("contextmenu",
|
|
541
|
+
}), this._domElement.addEventListener("contextmenu", m);
|
|
542
542
|
}, this._removeAllEventListeners = () => {
|
|
543
|
-
this._domElement && (this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = "", this._domElement.removeEventListener("pointerdown", o), this._domElement.removeEventListener("pointercancel",
|
|
543
|
+
this._domElement && (this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = "", this._domElement.removeEventListener("pointerdown", o), this._domElement.removeEventListener("pointercancel", a), this._domElement.removeEventListener("wheel", u, {
|
|
544
544
|
passive: !1
|
|
545
|
-
}), this._domElement.removeEventListener("contextmenu",
|
|
545
|
+
}), this._domElement.removeEventListener("contextmenu", m), this._domElement.ownerDocument.removeEventListener(
|
|
546
546
|
"pointermove",
|
|
547
547
|
n,
|
|
548
548
|
{ passive: !1 }
|
|
549
549
|
), this._domElement.ownerDocument.removeEventListener(
|
|
550
550
|
"pointerup",
|
|
551
|
-
|
|
551
|
+
a
|
|
552
552
|
), this._domElement.ownerDocument.removeEventListener(
|
|
553
553
|
"pointerlockchange",
|
|
554
|
-
|
|
554
|
+
g
|
|
555
555
|
), this._domElement.ownerDocument.removeEventListener(
|
|
556
556
|
"pointerlockerror",
|
|
557
|
-
|
|
557
|
+
y
|
|
558
558
|
));
|
|
559
559
|
}, this.cancel = () => {
|
|
560
|
-
this._state !==
|
|
560
|
+
this._state !== d.NONE && (this._state = d.NONE, this._activePointers.length = 0, f());
|
|
561
561
|
}, t && this.connect(t), this.update(0);
|
|
562
562
|
}
|
|
563
563
|
/**
|
|
@@ -822,7 +822,7 @@ class J extends Ts {
|
|
|
822
822
|
* @category Methods
|
|
823
823
|
*/
|
|
824
824
|
dollyTo(e, t = !1) {
|
|
825
|
-
return this._isUserControllingDolly = !1, this._lastDollyDirection =
|
|
825
|
+
return this._isUserControllingDolly = !1, this._lastDollyDirection = K.NONE, this._changedDolly = 0, this._dollyToNoClamp(
|
|
826
826
|
k(e, this.minDistance, this.maxDistance),
|
|
827
827
|
t
|
|
828
828
|
);
|
|
@@ -901,7 +901,7 @@ class J extends Ts {
|
|
|
901
901
|
*/
|
|
902
902
|
truck(e, t, s = !1) {
|
|
903
903
|
this._camera.updateMatrix(), F.setFromMatrixColumn(this._camera.matrix, 0), N.setFromMatrixColumn(this._camera.matrix, 1), F.multiplyScalar(e), N.multiplyScalar(-t);
|
|
904
|
-
const i =
|
|
904
|
+
const i = b.copy(F).add(N), r = L.copy(this._targetEnd).add(i);
|
|
905
905
|
return this.moveTo(r.x, r.y, r.z, s);
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
@@ -911,8 +911,8 @@ class J extends Ts {
|
|
|
911
911
|
* @category Methods
|
|
912
912
|
*/
|
|
913
913
|
forward(e, t = !1) {
|
|
914
|
-
|
|
915
|
-
const s = L.copy(this._targetEnd).add(
|
|
914
|
+
b.setFromMatrixColumn(this._camera.matrix, 0), b.crossVectors(this._camera.up, b), b.multiplyScalar(e);
|
|
915
|
+
const s = L.copy(this._targetEnd).add(b);
|
|
916
916
|
return this.moveTo(s.x, s.y, s.z, t);
|
|
917
917
|
}
|
|
918
918
|
/**
|
|
@@ -922,10 +922,10 @@ class J extends Ts {
|
|
|
922
922
|
* @category Methods
|
|
923
923
|
*/
|
|
924
924
|
elevate(e, t = !1) {
|
|
925
|
-
return
|
|
926
|
-
this._targetEnd.x +
|
|
927
|
-
this._targetEnd.y +
|
|
928
|
-
this._targetEnd.z +
|
|
925
|
+
return b.copy(this._camera.up).multiplyScalar(e), this.moveTo(
|
|
926
|
+
this._targetEnd.x + b.x,
|
|
927
|
+
this._targetEnd.y + b.y,
|
|
928
|
+
this._targetEnd.z + b.z,
|
|
929
929
|
t
|
|
930
930
|
);
|
|
931
931
|
}
|
|
@@ -939,7 +939,7 @@ class J extends Ts {
|
|
|
939
939
|
*/
|
|
940
940
|
moveTo(e, t, s, i = !1) {
|
|
941
941
|
this._isUserControllingTruck = !1;
|
|
942
|
-
const r =
|
|
942
|
+
const r = b.set(e, t, s).sub(this._targetEnd);
|
|
943
943
|
this._encloseToBoundary(this._targetEnd, r, this.boundaryFriction), this._needsUpdate = !0, i || this._target.copy(this._targetEnd);
|
|
944
944
|
const o = !i || P(this._target.x, this._targetEnd.x, this.restThreshold) && P(this._target.y, this._targetEnd.y, this.restThreshold) && P(this._target.z, this._targetEnd.z, this.restThreshold);
|
|
945
945
|
return this._createOnRestPromise(o);
|
|
@@ -954,7 +954,7 @@ class J extends Ts {
|
|
|
954
954
|
* @category Methods
|
|
955
955
|
*/
|
|
956
956
|
lookInDirectionOf(e, t, s, i = !1) {
|
|
957
|
-
const n =
|
|
957
|
+
const n = b.set(e, t, s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);
|
|
958
958
|
return this.setPosition(
|
|
959
959
|
n.x,
|
|
960
960
|
n.y,
|
|
@@ -982,34 +982,34 @@ class J extends Ts {
|
|
|
982
982
|
paddingBottom: o = 0,
|
|
983
983
|
paddingTop: n = 0
|
|
984
984
|
} = {}) {
|
|
985
|
-
const
|
|
986
|
-
|
|
985
|
+
const a = [], c = e.isBox3 ? X.copy(e) : X.setFromObject(e);
|
|
986
|
+
c.isEmpty() && (console.warn(
|
|
987
987
|
"camera-controls: fitTo() cannot be used with an empty box. Aborting"
|
|
988
988
|
), Promise.resolve());
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
L.copy(
|
|
995
|
-
const
|
|
989
|
+
const u = He(this._sphericalEnd.theta, je), m = He(this._sphericalEnd.phi, je);
|
|
990
|
+
a.push(this.rotateTo(u, m, t));
|
|
991
|
+
const v = b.setFromSpherical(this._sphericalEnd).normalize(), p = Ke.setFromUnitVectors(v, we), f = P(Math.abs(v.y), 1);
|
|
992
|
+
f && p.multiply(xe.setFromAxisAngle(me, u)), p.multiply(this._yAxisUpSpaceInverse);
|
|
993
|
+
const g = We.makeEmpty();
|
|
994
|
+
L.copy(c.min).applyQuaternion(p), g.expandByPoint(L), L.copy(c.min).setX(c.max.x).applyQuaternion(p), g.expandByPoint(L), L.copy(c.min).setY(c.max.y).applyQuaternion(p), g.expandByPoint(L), L.copy(c.max).setZ(c.min.z).applyQuaternion(p), g.expandByPoint(L), L.copy(c.min).setZ(c.max.z).applyQuaternion(p), g.expandByPoint(L), L.copy(c.max).setY(c.min.y).applyQuaternion(p), g.expandByPoint(L), L.copy(c.max).setX(c.min.x).applyQuaternion(p), g.expandByPoint(L), L.copy(c.max).applyQuaternion(p), g.expandByPoint(L), g.min.x -= i, g.min.y -= o, g.max.x += r, g.max.y += n, p.setFromUnitVectors(we, v), f && p.premultiply(xe.invert()), p.premultiply(this._yAxisUpSpace);
|
|
995
|
+
const y = g.getSize(b), l = g.getCenter(L).applyQuaternion(p);
|
|
996
996
|
if (Y(this._camera)) {
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
997
|
+
const _ = this.getDistanceToFitBox(
|
|
998
|
+
y.x,
|
|
999
|
+
y.y,
|
|
1000
|
+
y.z,
|
|
1001
1001
|
s
|
|
1002
1002
|
);
|
|
1003
|
-
|
|
1004
|
-
this.moveTo(
|
|
1005
|
-
),
|
|
1006
|
-
} else if (
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
this.moveTo(
|
|
1010
|
-
),
|
|
1003
|
+
a.push(
|
|
1004
|
+
this.moveTo(l.x, l.y, l.z, t)
|
|
1005
|
+
), a.push(this.dollyTo(_, t)), a.push(this.setFocalOffset(0, 0, 0, t));
|
|
1006
|
+
} else if (H(this._camera)) {
|
|
1007
|
+
const _ = this._camera, O = _.right - _.left, C = _.top - _.bottom, w = s ? Math.max(O / y.x, C / y.y) : Math.min(O / y.x, C / y.y);
|
|
1008
|
+
a.push(
|
|
1009
|
+
this.moveTo(l.x, l.y, l.z, t)
|
|
1010
|
+
), a.push(this.zoomTo(w, t)), a.push(this.setFocalOffset(0, 0, 0, t));
|
|
1011
1011
|
}
|
|
1012
|
-
return Promise.all(
|
|
1012
|
+
return Promise.all(a);
|
|
1013
1013
|
}
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Fit the viewport to the sphere or the bounding sphere of the object.
|
|
@@ -1029,9 +1029,9 @@ class J extends Ts {
|
|
|
1029
1029
|
), Y(this._camera)) {
|
|
1030
1030
|
const o = this.getDistanceToFitSphere(r.radius);
|
|
1031
1031
|
s.push(this.dollyTo(o, t));
|
|
1032
|
-
} else if (
|
|
1033
|
-
const o = this._camera.right - this._camera.left, n = this._camera.top - this._camera.bottom,
|
|
1034
|
-
s.push(this.zoomTo(
|
|
1032
|
+
} else if (H(this._camera)) {
|
|
1033
|
+
const o = this._camera.right - this._camera.left, n = this._camera.top - this._camera.bottom, a = 2 * r.radius, c = Math.min(o / a, n / a);
|
|
1034
|
+
s.push(this.zoomTo(c, t));
|
|
1035
1035
|
}
|
|
1036
1036
|
return s.push(this.setFocalOffset(0, 0, 0, t)), Promise.all(s);
|
|
1037
1037
|
}
|
|
@@ -1047,12 +1047,12 @@ class J extends Ts {
|
|
|
1047
1047
|
* @category Methods
|
|
1048
1048
|
*/
|
|
1049
1049
|
setLookAt(e, t, s, i, r, o, n = !1) {
|
|
1050
|
-
this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection =
|
|
1051
|
-
const
|
|
1052
|
-
this._targetEnd.copy(
|
|
1053
|
-
|
|
1050
|
+
this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = K.NONE, this._changedDolly = 0;
|
|
1051
|
+
const a = L.set(i, r, o), c = b.set(e, t, s);
|
|
1052
|
+
this._targetEnd.copy(a), this._sphericalEnd.setFromVector3(
|
|
1053
|
+
c.sub(a).applyQuaternion(this._yAxisUpSpace)
|
|
1054
1054
|
), this.normalizeRotations(), this._needsUpdate = !0, n || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
|
|
1055
|
-
const
|
|
1055
|
+
const u = !n || P(this._target.x, this._targetEnd.x, this.restThreshold) && P(this._target.y, this._targetEnd.y, this.restThreshold) && P(this._target.z, this._targetEnd.z, this.restThreshold) && P(
|
|
1056
1056
|
this._spherical.theta,
|
|
1057
1057
|
this._sphericalEnd.theta,
|
|
1058
1058
|
this.restThreshold
|
|
@@ -1065,7 +1065,7 @@ class J extends Ts {
|
|
|
1065
1065
|
this._sphericalEnd.radius,
|
|
1066
1066
|
this.restThreshold
|
|
1067
1067
|
);
|
|
1068
|
-
return this._createOnRestPromise(
|
|
1068
|
+
return this._createOnRestPromise(u);
|
|
1069
1069
|
}
|
|
1070
1070
|
/**
|
|
1071
1071
|
* Similar to setLookAt, but it interpolates between two states.
|
|
@@ -1085,23 +1085,23 @@ class J extends Ts {
|
|
|
1085
1085
|
* @param enableTransition
|
|
1086
1086
|
* @category Methods
|
|
1087
1087
|
*/
|
|
1088
|
-
lerpLookAt(e, t, s, i, r, o, n,
|
|
1089
|
-
this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection =
|
|
1090
|
-
const
|
|
1088
|
+
lerpLookAt(e, t, s, i, r, o, n, a, c, u, m, v, p, f = !1) {
|
|
1089
|
+
this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = K.NONE, this._changedDolly = 0;
|
|
1090
|
+
const g = b.set(i, r, o), y = L.set(e, t, s);
|
|
1091
1091
|
z.setFromVector3(
|
|
1092
|
-
|
|
1092
|
+
y.sub(g).applyQuaternion(this._yAxisUpSpace)
|
|
1093
1093
|
);
|
|
1094
|
-
const
|
|
1094
|
+
const l = G.set(u, m, v), _ = L.set(n, a, c);
|
|
1095
1095
|
ae.setFromVector3(
|
|
1096
|
-
|
|
1097
|
-
), this._targetEnd.copy(
|
|
1098
|
-
const
|
|
1096
|
+
_.sub(l).applyQuaternion(this._yAxisUpSpace)
|
|
1097
|
+
), this._targetEnd.copy(g.lerp(l, p));
|
|
1098
|
+
const O = ae.theta - z.theta, C = ae.phi - z.phi, w = ae.radius - z.radius;
|
|
1099
1099
|
this._sphericalEnd.set(
|
|
1100
|
-
z.radius +
|
|
1101
|
-
z.phi +
|
|
1102
|
-
z.theta +
|
|
1103
|
-
), this.normalizeRotations(), this._needsUpdate = !0,
|
|
1104
|
-
const
|
|
1100
|
+
z.radius + w * p,
|
|
1101
|
+
z.phi + C * p,
|
|
1102
|
+
z.theta + O * p
|
|
1103
|
+
), this.normalizeRotations(), this._needsUpdate = !0, f || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
|
|
1104
|
+
const E = !f || P(this._target.x, this._targetEnd.x, this.restThreshold) && P(this._target.y, this._targetEnd.y, this.restThreshold) && P(this._target.z, this._targetEnd.z, this.restThreshold) && P(
|
|
1105
1105
|
this._spherical.theta,
|
|
1106
1106
|
this._sphericalEnd.theta,
|
|
1107
1107
|
this.restThreshold
|
|
@@ -1114,7 +1114,7 @@ class J extends Ts {
|
|
|
1114
1114
|
this._sphericalEnd.radius,
|
|
1115
1115
|
this.restThreshold
|
|
1116
1116
|
);
|
|
1117
|
-
return this._createOnRestPromise(
|
|
1117
|
+
return this._createOnRestPromise(E);
|
|
1118
1118
|
}
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Set angle and distance by given position.
|
|
@@ -1146,7 +1146,7 @@ class J extends Ts {
|
|
|
1146
1146
|
* @category Methods
|
|
1147
1147
|
*/
|
|
1148
1148
|
setTarget(e, t, s, i = !1) {
|
|
1149
|
-
const r = this.getPosition(
|
|
1149
|
+
const r = this.getPosition(b), o = this.setLookAt(
|
|
1150
1150
|
r.x,
|
|
1151
1151
|
r.y,
|
|
1152
1152
|
r.z,
|
|
@@ -1196,8 +1196,8 @@ class J extends Ts {
|
|
|
1196
1196
|
*/
|
|
1197
1197
|
setOrbitPoint(e, t, s) {
|
|
1198
1198
|
this._camera.updateMatrixWorld(), F.setFromMatrixColumn(this._camera.matrixWorldInverse, 0), N.setFromMatrixColumn(this._camera.matrixWorldInverse, 1), Z.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
|
|
1199
|
-
const i =
|
|
1200
|
-
F.multiplyScalar(o.x), N.multiplyScalar(o.y), Z.multiplyScalar(o.z),
|
|
1199
|
+
const i = b.set(e, t, s), r = i.distanceTo(this._camera.position), o = i.sub(this._camera.position);
|
|
1200
|
+
F.multiplyScalar(o.x), N.multiplyScalar(o.y), Z.multiplyScalar(o.z), b.copy(F).add(N).add(Z), b.z = b.z + r, this.dollyTo(r, !1), this.setFocalOffset(-b.x, b.y, -b.z, !1), this.moveTo(e, t, s, !1);
|
|
1201
1201
|
}
|
|
1202
1202
|
/**
|
|
1203
1203
|
* Set the boundary box that encloses the target of the camera. box3 is in THREE.Box3
|
|
@@ -1236,7 +1236,7 @@ class J extends Ts {
|
|
|
1236
1236
|
* @category Methods
|
|
1237
1237
|
*/
|
|
1238
1238
|
getDistanceToFitBox(e, t, s, i = !1) {
|
|
1239
|
-
if (
|
|
1239
|
+
if (Te(this._camera, "getDistanceToFitBox"))
|
|
1240
1240
|
return this._spherical.radius;
|
|
1241
1241
|
const r = e / t, o = this._camera.getEffectiveFOV() * ie, n = this._camera.aspect;
|
|
1242
1242
|
return ((i ? r > n : r < n) ? t : e / n) * 0.5 / Math.tan(o * 0.5) + s * 0.5;
|
|
@@ -1248,7 +1248,7 @@ class J extends Ts {
|
|
|
1248
1248
|
* @category Methods
|
|
1249
1249
|
*/
|
|
1250
1250
|
getDistanceToFitSphere(e) {
|
|
1251
|
-
if (
|
|
1251
|
+
if (Te(this._camera, "getDistanceToFitSphere"))
|
|
1252
1252
|
return this._spherical.radius;
|
|
1253
1253
|
const t = this._camera.getEffectiveFOV() * ie, s = Math.atan(Math.tan(t * 0.5) * this._camera.aspect) * 2, i = 1 < this._camera.aspect ? t : s;
|
|
1254
1254
|
return e / Math.sin(i * 0.5);
|
|
@@ -1296,7 +1296,7 @@ class J extends Ts {
|
|
|
1296
1296
|
* @category Methods
|
|
1297
1297
|
*/
|
|
1298
1298
|
normalizeRotations() {
|
|
1299
|
-
this._sphericalEnd.theta = this._sphericalEnd.theta %
|
|
1299
|
+
this._sphericalEnd.theta = this._sphericalEnd.theta % $, this._sphericalEnd.theta < 0 && (this._sphericalEnd.theta += $), this._spherical.theta += $ * Math.round((this._sphericalEnd.theta - this._spherical.theta) / $);
|
|
1300
1300
|
}
|
|
1301
1301
|
/**
|
|
1302
1302
|
* stop all transitions.
|
|
@@ -1312,7 +1312,7 @@ class J extends Ts {
|
|
|
1312
1312
|
reset(e = !1) {
|
|
1313
1313
|
if (!P(this._camera.up.x, this._cameraUp0.x) || !P(this._camera.up.y, this._cameraUp0.y) || !P(this._camera.up.z, this._cameraUp0.z)) {
|
|
1314
1314
|
this._camera.up.copy(this._cameraUp0);
|
|
1315
|
-
const s = this.getPosition(
|
|
1315
|
+
const s = this.getPosition(b);
|
|
1316
1316
|
this.updateCameraUp(), this.setPosition(s.x, s.y, s.z);
|
|
1317
1317
|
}
|
|
1318
1318
|
const t = [
|
|
@@ -1348,7 +1348,7 @@ class J extends Ts {
|
|
|
1348
1348
|
* @category Methods
|
|
1349
1349
|
*/
|
|
1350
1350
|
updateCameraUp() {
|
|
1351
|
-
this._yAxisUpSpace.setFromUnitVectors(this._camera.up,
|
|
1351
|
+
this._yAxisUpSpace.setFromUnitVectors(this._camera.up, me), this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert();
|
|
1352
1352
|
}
|
|
1353
1353
|
/**
|
|
1354
1354
|
* Apply current camera-up direction to the camera.
|
|
@@ -1356,9 +1356,9 @@ class J extends Ts {
|
|
|
1356
1356
|
* @category Methods
|
|
1357
1357
|
*/
|
|
1358
1358
|
applyCameraUp() {
|
|
1359
|
-
const e =
|
|
1359
|
+
const e = b.subVectors(this._target, this._camera.position).normalize(), t = L.crossVectors(e, this._camera.up);
|
|
1360
1360
|
this._camera.up.crossVectors(t, e).normalize(), this._camera.updateMatrixWorld();
|
|
1361
|
-
const s = this.getPosition(
|
|
1361
|
+
const s = this.getPosition(b);
|
|
1362
1362
|
this.updateCameraUp(), this.setPosition(s.x, s.y, s.z);
|
|
1363
1363
|
}
|
|
1364
1364
|
/**
|
|
@@ -1373,127 +1373,127 @@ class J extends Ts {
|
|
|
1373
1373
|
this._focalOffsetEnd,
|
|
1374
1374
|
this._focalOffset
|
|
1375
1375
|
), n = this._zoomEnd - this._zoom;
|
|
1376
|
-
if (
|
|
1376
|
+
if (S(t))
|
|
1377
1377
|
this._thetaVelocity.value = 0, this._spherical.theta = this._sphericalEnd.theta;
|
|
1378
1378
|
else {
|
|
1379
|
-
const
|
|
1380
|
-
this._spherical.theta =
|
|
1379
|
+
const m = this._isUserControllingRotate ? this.draggingSmoothTime : this.smoothTime;
|
|
1380
|
+
this._spherical.theta = ce(
|
|
1381
1381
|
this._spherical.theta,
|
|
1382
1382
|
this._sphericalEnd.theta,
|
|
1383
1383
|
this._thetaVelocity,
|
|
1384
|
-
|
|
1384
|
+
m,
|
|
1385
1385
|
1 / 0,
|
|
1386
1386
|
e
|
|
1387
1387
|
), this._needsUpdate = !0;
|
|
1388
1388
|
}
|
|
1389
|
-
if (
|
|
1389
|
+
if (S(s))
|
|
1390
1390
|
this._phiVelocity.value = 0, this._spherical.phi = this._sphericalEnd.phi;
|
|
1391
1391
|
else {
|
|
1392
|
-
const
|
|
1393
|
-
this._spherical.phi =
|
|
1392
|
+
const m = this._isUserControllingRotate ? this.draggingSmoothTime : this.smoothTime;
|
|
1393
|
+
this._spherical.phi = ce(
|
|
1394
1394
|
this._spherical.phi,
|
|
1395
1395
|
this._sphericalEnd.phi,
|
|
1396
1396
|
this._phiVelocity,
|
|
1397
|
-
|
|
1397
|
+
m,
|
|
1398
1398
|
1 / 0,
|
|
1399
1399
|
e
|
|
1400
1400
|
), this._needsUpdate = !0;
|
|
1401
1401
|
}
|
|
1402
|
-
if (
|
|
1402
|
+
if (S(i))
|
|
1403
1403
|
this._radiusVelocity.value = 0, this._spherical.radius = this._sphericalEnd.radius;
|
|
1404
1404
|
else {
|
|
1405
|
-
const
|
|
1406
|
-
this._spherical.radius =
|
|
1405
|
+
const m = this._isUserControllingDolly ? this.draggingSmoothTime : this.smoothTime;
|
|
1406
|
+
this._spherical.radius = ce(
|
|
1407
1407
|
this._spherical.radius,
|
|
1408
1408
|
this._sphericalEnd.radius,
|
|
1409
1409
|
this._radiusVelocity,
|
|
1410
|
-
|
|
1410
|
+
m,
|
|
1411
1411
|
this.maxSpeed,
|
|
1412
1412
|
e
|
|
1413
1413
|
), this._needsUpdate = !0;
|
|
1414
1414
|
}
|
|
1415
|
-
if (
|
|
1415
|
+
if (S(r.x) && S(r.y) && S(r.z))
|
|
1416
1416
|
this._targetVelocity.set(0, 0, 0), this._target.copy(this._targetEnd);
|
|
1417
1417
|
else {
|
|
1418
|
-
const
|
|
1418
|
+
const m = this._isUserControllingTruck ? this.draggingSmoothTime : this.smoothTime;
|
|
1419
1419
|
Be(
|
|
1420
1420
|
this._target,
|
|
1421
1421
|
this._targetEnd,
|
|
1422
1422
|
this._targetVelocity,
|
|
1423
|
-
|
|
1423
|
+
m,
|
|
1424
1424
|
this.maxSpeed,
|
|
1425
1425
|
e,
|
|
1426
1426
|
this._target
|
|
1427
1427
|
), this._needsUpdate = !0;
|
|
1428
1428
|
}
|
|
1429
|
-
if (
|
|
1429
|
+
if (S(o.x) && S(o.y) && S(o.z))
|
|
1430
1430
|
this._focalOffsetVelocity.set(0, 0, 0), this._focalOffset.copy(this._focalOffsetEnd);
|
|
1431
1431
|
else {
|
|
1432
|
-
const
|
|
1432
|
+
const m = this._isUserControllingOffset ? this.draggingSmoothTime : this.smoothTime;
|
|
1433
1433
|
Be(
|
|
1434
1434
|
this._focalOffset,
|
|
1435
1435
|
this._focalOffsetEnd,
|
|
1436
1436
|
this._focalOffsetVelocity,
|
|
1437
|
-
|
|
1437
|
+
m,
|
|
1438
1438
|
this.maxSpeed,
|
|
1439
1439
|
e,
|
|
1440
1440
|
this._focalOffset
|
|
1441
1441
|
), this._needsUpdate = !0;
|
|
1442
1442
|
}
|
|
1443
|
-
if (
|
|
1443
|
+
if (S(n))
|
|
1444
1444
|
this._zoomVelocity.value = 0, this._zoom = this._zoomEnd;
|
|
1445
1445
|
else {
|
|
1446
|
-
const
|
|
1447
|
-
this._zoom =
|
|
1446
|
+
const m = this._isUserControllingZoom ? this.draggingSmoothTime : this.smoothTime;
|
|
1447
|
+
this._zoom = ce(
|
|
1448
1448
|
this._zoom,
|
|
1449
1449
|
this._zoomEnd,
|
|
1450
1450
|
this._zoomVelocity,
|
|
1451
|
-
|
|
1451
|
+
m,
|
|
1452
1452
|
1 / 0,
|
|
1453
1453
|
e
|
|
1454
1454
|
);
|
|
1455
1455
|
}
|
|
1456
1456
|
if (this.dollyToCursor) {
|
|
1457
1457
|
if (Y(this._camera) && this._changedDolly !== 0) {
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
this._dollyControlCoord.x *
|
|
1458
|
+
const m = this._spherical.radius - this._lastDistance, v = this._camera, p = this._getCameraDirection(ne), f = b.copy(p).cross(v.up).normalize();
|
|
1459
|
+
f.lengthSq() === 0 && (f.x = 1);
|
|
1460
|
+
const g = L.crossVectors(f, p), y = this._sphericalEnd.radius * Math.tan(v.getEffectiveFOV() * ie * 0.5), _ = (this._sphericalEnd.radius - m - this._sphericalEnd.radius) / this._sphericalEnd.radius, O = G.copy(this._targetEnd).add(
|
|
1461
|
+
f.multiplyScalar(
|
|
1462
|
+
this._dollyControlCoord.x * y * v.aspect
|
|
1463
1463
|
)
|
|
1464
1464
|
).add(
|
|
1465
|
-
|
|
1466
|
-
),
|
|
1467
|
-
if (this.infinityDolly && (
|
|
1468
|
-
this._sphericalEnd.radius -=
|
|
1469
|
-
const R = L.copy(
|
|
1470
|
-
|
|
1465
|
+
g.multiplyScalar(this._dollyControlCoord.y * y)
|
|
1466
|
+
), C = b.copy(this._targetEnd).lerp(O, _), w = this._lastDollyDirection === K.IN && this._spherical.radius <= this.minDistance, E = this._lastDollyDirection === K.OUT && this.maxDistance <= this._spherical.radius;
|
|
1467
|
+
if (this.infinityDolly && (w || E)) {
|
|
1468
|
+
this._sphericalEnd.radius -= m, this._spherical.radius -= m;
|
|
1469
|
+
const R = L.copy(p).multiplyScalar(-m);
|
|
1470
|
+
C.add(R);
|
|
1471
1471
|
}
|
|
1472
|
-
this._boundary.clampPoint(
|
|
1473
|
-
const x = L.subVectors(
|
|
1474
|
-
this._targetEnd.copy(
|
|
1475
|
-
} else if (
|
|
1476
|
-
const
|
|
1472
|
+
this._boundary.clampPoint(C, C);
|
|
1473
|
+
const x = L.subVectors(C, this._targetEnd);
|
|
1474
|
+
this._targetEnd.copy(C), this._target.add(x), this._changedDolly -= m, S(this._changedDolly) && (this._changedDolly = 0);
|
|
1475
|
+
} else if (H(this._camera) && this._changedZoom !== 0) {
|
|
1476
|
+
const m = this._zoom - this._lastZoom, v = this._camera, p = b.set(
|
|
1477
1477
|
this._dollyControlCoord.x,
|
|
1478
1478
|
this._dollyControlCoord.y,
|
|
1479
|
-
(
|
|
1480
|
-
).unproject(
|
|
1481
|
-
|
|
1479
|
+
(v.near + v.far) / (v.near - v.far)
|
|
1480
|
+
).unproject(v), f = L.set(0, 0, -1).applyQuaternion(v.quaternion), g = G.copy(p).add(f.multiplyScalar(-p.dot(v.up))), l = -(this._zoom - m - this._zoom) / this._zoom, _ = this._getCameraDirection(ne), O = this._targetEnd.dot(_), C = b.copy(this._targetEnd).lerp(g, l), w = C.dot(_), E = _.multiplyScalar(
|
|
1481
|
+
w - O
|
|
1482
1482
|
);
|
|
1483
|
-
|
|
1484
|
-
const x = L.subVectors(
|
|
1485
|
-
this._targetEnd.copy(
|
|
1483
|
+
C.sub(E), this._boundary.clampPoint(C, C);
|
|
1484
|
+
const x = L.subVectors(C, this._targetEnd);
|
|
1485
|
+
this._targetEnd.copy(C), this._target.add(x), this._changedZoom -= m, S(this._changedZoom) && (this._changedZoom = 0);
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
this._camera.zoom !== this._zoom && (this._camera.zoom = this._zoom, this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0), this._dragNeedsUpdate = !0;
|
|
1489
|
-
const
|
|
1490
|
-
this._spherical.radius = Math.min(this._spherical.radius,
|
|
1489
|
+
const a = this._collisionTest();
|
|
1490
|
+
this._spherical.radius = Math.min(this._spherical.radius, a), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), this._camera.lookAt(this._target), (!S(this._focalOffset.x) || !S(this._focalOffset.y) || !S(this._focalOffset.z)) && (F.setFromMatrixColumn(this._camera.matrix, 0), N.setFromMatrixColumn(this._camera.matrix, 1), Z.setFromMatrixColumn(this._camera.matrix, 2), F.multiplyScalar(this._focalOffset.x), N.multiplyScalar(-this._focalOffset.y), Z.multiplyScalar(this._focalOffset.z), b.copy(F).add(N).add(Z), this._camera.position.add(b), this._camera.updateMatrixWorld()), this._boundaryEnclosesCamera && this._encloseToBoundary(
|
|
1491
1491
|
this._camera.position.copy(this._target),
|
|
1492
|
-
|
|
1492
|
+
b.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),
|
|
1493
1493
|
1
|
|
1494
1494
|
);
|
|
1495
|
-
const
|
|
1496
|
-
return
|
|
1495
|
+
const u = this._needsUpdate;
|
|
1496
|
+
return u && !this._updatedLastTime ? (this._hasRested = !1, this.dispatchEvent({ type: "wake" }), this.dispatchEvent({ type: "update" })) : u ? (this.dispatchEvent({ type: "update" }), S(t, this.restThreshold) && S(s, this.restThreshold) && S(i, this.restThreshold) && S(r.x, this.restThreshold) && S(r.y, this.restThreshold) && S(r.z, this.restThreshold) && S(o.x, this.restThreshold) && S(o.y, this.restThreshold) && S(o.z, this.restThreshold) && S(n, this.restThreshold) && !this._hasRested && (this._hasRested = !0, this.dispatchEvent({ type: "rest" }))) : !u && this._updatedLastTime && (this._hasRested || (this._hasRested = !0, this.dispatchEvent({ type: "rest" })), this.dispatchEvent({ type: "sleep" })), this._lastDistance = this._spherical.radius, this._lastZoom = this._zoom, this._updatedLastTime = u, this._needsUpdate = !1, u;
|
|
1497
1497
|
}
|
|
1498
1498
|
/**
|
|
1499
1499
|
* Get all state in JSON string
|
|
@@ -1516,7 +1516,7 @@ class J extends Ts {
|
|
|
1516
1516
|
truckSpeed: this.truckSpeed,
|
|
1517
1517
|
dollyToCursor: this.dollyToCursor,
|
|
1518
1518
|
target: this._targetEnd.toArray(),
|
|
1519
|
-
position:
|
|
1519
|
+
position: b.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),
|
|
1520
1520
|
zoom: this._zoomEnd,
|
|
1521
1521
|
focalOffset: this._focalOffsetEnd.toArray(),
|
|
1522
1522
|
target0: this._target0.toArray(),
|
|
@@ -1534,7 +1534,7 @@ class J extends Ts {
|
|
|
1534
1534
|
fromJSON(e, t = !1) {
|
|
1535
1535
|
const s = JSON.parse(e);
|
|
1536
1536
|
this.enabled = s.enabled, this.minDistance = s.minDistance, this.maxDistance = oe(s.maxDistance), this.minZoom = s.minZoom, this.maxZoom = oe(s.maxZoom), this.minPolarAngle = s.minPolarAngle, this.maxPolarAngle = oe(s.maxPolarAngle), this.minAzimuthAngle = oe(s.minAzimuthAngle), this.maxAzimuthAngle = oe(s.maxAzimuthAngle), this.smoothTime = s.smoothTime, this.draggingSmoothTime = s.draggingSmoothTime, this.dollySpeed = s.dollySpeed, this.truckSpeed = s.truckSpeed, this.dollyToCursor = s.dollyToCursor, this._target0.fromArray(s.target0), this._position0.fromArray(s.position0), this._zoom0 = s.zoom0, this._focalOffset0.fromArray(s.focalOffset0), this.moveTo(s.target[0], s.target[1], s.target[2], t), z.setFromVector3(
|
|
1537
|
-
|
|
1537
|
+
b.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)
|
|
1538
1538
|
), this.rotateTo(z.theta, z.phi, t), this.dollyTo(z.radius, t), this.zoomTo(s.zoom, t), this.setFocalOffset(
|
|
1539
1539
|
s.focalOffset[0],
|
|
1540
1540
|
s.focalOffset[1],
|
|
@@ -1591,23 +1591,23 @@ class J extends Ts {
|
|
|
1591
1591
|
const i = t.lengthSq();
|
|
1592
1592
|
if (i === 0)
|
|
1593
1593
|
return e;
|
|
1594
|
-
const r = L.copy(t).add(e), n = this._boundary.clampPoint(r,
|
|
1595
|
-
if (
|
|
1594
|
+
const r = L.copy(t).add(e), n = this._boundary.clampPoint(r, G).sub(r), a = n.lengthSq();
|
|
1595
|
+
if (a === 0)
|
|
1596
1596
|
return e.add(t);
|
|
1597
|
-
if (
|
|
1597
|
+
if (a === i)
|
|
1598
1598
|
return e;
|
|
1599
1599
|
if (s === 0)
|
|
1600
1600
|
return e.add(t).add(n);
|
|
1601
1601
|
{
|
|
1602
|
-
const
|
|
1603
|
-
return e.add(L.copy(t).multiplyScalar(
|
|
1602
|
+
const c = 1 + s * a / t.dot(n);
|
|
1603
|
+
return e.add(L.copy(t).multiplyScalar(c)).add(n.multiplyScalar(1 - s));
|
|
1604
1604
|
}
|
|
1605
1605
|
}
|
|
1606
1606
|
_updateNearPlaneCorners() {
|
|
1607
1607
|
if (Y(this._camera)) {
|
|
1608
1608
|
const e = this._camera, t = e.near, s = e.getEffectiveFOV() * ie, i = Math.tan(s * 0.5) * t, r = i * e.aspect;
|
|
1609
1609
|
this._nearPlaneCorners[0].set(-r, -i, 0), this._nearPlaneCorners[1].set(r, -i, 0), this._nearPlaneCorners[2].set(r, i, 0), this._nearPlaneCorners[3].set(-r, i, 0);
|
|
1610
|
-
} else if (
|
|
1610
|
+
} else if (H(this._camera)) {
|
|
1611
1611
|
const e = this._camera, t = 1 / e.zoom, s = e.left * t, i = e.right * t, r = e.top * t, o = e.bottom * t;
|
|
1612
1612
|
this._nearPlaneCorners[0].set(s, r, 0), this._nearPlaneCorners[1].set(i, r, 0), this._nearPlaneCorners[2].set(i, o, 0), this._nearPlaneCorners[3].set(s, o, 0);
|
|
1613
1613
|
}
|
|
@@ -1615,14 +1615,14 @@ class J extends Ts {
|
|
|
1615
1615
|
// lateUpdate
|
|
1616
1616
|
_collisionTest() {
|
|
1617
1617
|
let e = 1 / 0;
|
|
1618
|
-
if (!(this.colliderMeshes.length >= 1) ||
|
|
1618
|
+
if (!(this.colliderMeshes.length >= 1) || Te(this._camera, "_collisionTest"))
|
|
1619
1619
|
return e;
|
|
1620
1620
|
const s = this._getTargetDirection(ne);
|
|
1621
|
-
|
|
1621
|
+
Le.lookAt(Ve, s, this._camera.up);
|
|
1622
1622
|
for (let i = 0; i < 4; i++) {
|
|
1623
1623
|
const r = L.copy(this._nearPlaneCorners[i]);
|
|
1624
|
-
r.applyMatrix4(
|
|
1625
|
-
const o =
|
|
1624
|
+
r.applyMatrix4(Le);
|
|
1625
|
+
const o = G.addVectors(this._target, r);
|
|
1626
1626
|
pe.set(o, s), pe.far = this._spherical.radius + 1;
|
|
1627
1627
|
const n = pe.intersectObjects(this.colliderMeshes);
|
|
1628
1628
|
n.length !== 0 && n[0].distance < e && (e = n[0].distance);
|
|
@@ -1692,28 +1692,28 @@ class J extends Ts {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
static createBoundingSphere(e, t = new T.Sphere()) {
|
|
1694
1694
|
const s = t, i = s.center;
|
|
1695
|
-
|
|
1696
|
-
o.isMesh &&
|
|
1697
|
-
}),
|
|
1695
|
+
X.makeEmpty(), e.traverseVisible((o) => {
|
|
1696
|
+
o.isMesh && X.expandByObject(o);
|
|
1697
|
+
}), X.getCenter(i);
|
|
1698
1698
|
let r = 0;
|
|
1699
1699
|
return e.traverseVisible((o) => {
|
|
1700
1700
|
if (!o.isMesh) return;
|
|
1701
1701
|
const n = o;
|
|
1702
1702
|
if (!n.geometry) return;
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1705
|
-
const
|
|
1706
|
-
for (let
|
|
1707
|
-
|
|
1703
|
+
const a = n.geometry.clone();
|
|
1704
|
+
a.applyMatrix4(n.matrixWorld);
|
|
1705
|
+
const u = a.attributes.position;
|
|
1706
|
+
for (let m = 0, v = u.count; m < v; m++)
|
|
1707
|
+
b.fromBufferAttribute(u, m), r = Math.max(r, i.distanceToSquared(b));
|
|
1708
1708
|
}), s.radius = Math.sqrt(r), s;
|
|
1709
1709
|
}
|
|
1710
1710
|
}
|
|
1711
|
-
var
|
|
1711
|
+
var Se = { exports: {} }, Q = typeof Reflect == "object" ? Reflect : null, $e = Q && typeof Q.apply == "function" ? Q.apply : function(e, t, s) {
|
|
1712
1712
|
return Function.prototype.apply.call(e, t, s);
|
|
1713
|
-
},
|
|
1714
|
-
Q && typeof Q.ownKeys == "function" ?
|
|
1713
|
+
}, fe;
|
|
1714
|
+
Q && typeof Q.ownKeys == "function" ? fe = Q.ownKeys : Object.getOwnPropertySymbols ? fe = function(e) {
|
|
1715
1715
|
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
|
|
1716
|
-
} :
|
|
1716
|
+
} : fe = function(e) {
|
|
1717
1717
|
return Object.getOwnPropertyNames(e);
|
|
1718
1718
|
};
|
|
1719
1719
|
function ws(h) {
|
|
@@ -1722,46 +1722,46 @@ function ws(h) {
|
|
|
1722
1722
|
var _t = Number.isNaN || function(e) {
|
|
1723
1723
|
return e !== e;
|
|
1724
1724
|
};
|
|
1725
|
-
function
|
|
1726
|
-
|
|
1725
|
+
function A() {
|
|
1726
|
+
A.init.call(this);
|
|
1727
1727
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
var
|
|
1728
|
+
Se.exports = A;
|
|
1729
|
+
Se.exports.once = Ps;
|
|
1730
|
+
A.EventEmitter = A;
|
|
1731
|
+
A.prototype._events = void 0;
|
|
1732
|
+
A.prototype._eventsCount = 0;
|
|
1733
|
+
A.prototype._maxListeners = void 0;
|
|
1734
|
+
var Ge = 10;
|
|
1735
1735
|
function ge(h) {
|
|
1736
1736
|
if (typeof h != "function")
|
|
1737
1737
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof h);
|
|
1738
1738
|
}
|
|
1739
|
-
Object.defineProperty(
|
|
1739
|
+
Object.defineProperty(A, "defaultMaxListeners", {
|
|
1740
1740
|
enumerable: !0,
|
|
1741
1741
|
get: function() {
|
|
1742
|
-
return
|
|
1742
|
+
return Ge;
|
|
1743
1743
|
},
|
|
1744
1744
|
set: function(h) {
|
|
1745
1745
|
if (typeof h != "number" || h < 0 || _t(h))
|
|
1746
1746
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + h + ".");
|
|
1747
|
-
|
|
1747
|
+
Ge = h;
|
|
1748
1748
|
}
|
|
1749
1749
|
});
|
|
1750
|
-
|
|
1750
|
+
A.init = function() {
|
|
1751
1751
|
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
1752
1752
|
};
|
|
1753
|
-
|
|
1753
|
+
A.prototype.setMaxListeners = function(e) {
|
|
1754
1754
|
if (typeof e != "number" || e < 0 || _t(e))
|
|
1755
1755
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
1756
1756
|
return this._maxListeners = e, this;
|
|
1757
1757
|
};
|
|
1758
1758
|
function gt(h) {
|
|
1759
|
-
return h._maxListeners === void 0 ?
|
|
1759
|
+
return h._maxListeners === void 0 ? A.defaultMaxListeners : h._maxListeners;
|
|
1760
1760
|
}
|
|
1761
|
-
|
|
1761
|
+
A.prototype.getMaxListeners = function() {
|
|
1762
1762
|
return gt(this);
|
|
1763
1763
|
};
|
|
1764
|
-
|
|
1764
|
+
A.prototype.emit = function(e) {
|
|
1765
1765
|
for (var t = [], s = 1; s < arguments.length; s++) t.push(arguments[s]);
|
|
1766
1766
|
var i = e === "error", r = this._events;
|
|
1767
1767
|
if (r !== void 0)
|
|
@@ -1775,17 +1775,17 @@ S.prototype.emit = function(e) {
|
|
|
1775
1775
|
var n = new Error("Unhandled error." + (o ? " (" + o.message + ")" : ""));
|
|
1776
1776
|
throw n.context = o, n;
|
|
1777
1777
|
}
|
|
1778
|
-
var
|
|
1779
|
-
if (
|
|
1778
|
+
var a = r[e];
|
|
1779
|
+
if (a === void 0)
|
|
1780
1780
|
return !1;
|
|
1781
|
-
if (typeof
|
|
1782
|
-
|
|
1781
|
+
if (typeof a == "function")
|
|
1782
|
+
$e(a, this, t);
|
|
1783
1783
|
else
|
|
1784
|
-
for (var
|
|
1785
|
-
|
|
1784
|
+
for (var c = a.length, u = Et(a, c), s = 0; s < c; ++s)
|
|
1785
|
+
$e(u[s], this, t);
|
|
1786
1786
|
return !0;
|
|
1787
1787
|
};
|
|
1788
|
-
function
|
|
1788
|
+
function yt(h, e, t, s) {
|
|
1789
1789
|
var i, r, o;
|
|
1790
1790
|
if (ge(t), r = h._events, r === void 0 ? (r = h._events = /* @__PURE__ */ Object.create(null), h._eventsCount = 0) : (r.newListener !== void 0 && (h.emit(
|
|
1791
1791
|
"newListener",
|
|
@@ -1800,28 +1800,28 @@ function vt(h, e, t, s) {
|
|
|
1800
1800
|
}
|
|
1801
1801
|
return h;
|
|
1802
1802
|
}
|
|
1803
|
-
|
|
1804
|
-
return
|
|
1803
|
+
A.prototype.addListener = function(e, t) {
|
|
1804
|
+
return yt(this, e, t, !1);
|
|
1805
1805
|
};
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
return
|
|
1806
|
+
A.prototype.on = A.prototype.addListener;
|
|
1807
|
+
A.prototype.prependListener = function(e, t) {
|
|
1808
|
+
return yt(this, e, t, !0);
|
|
1809
1809
|
};
|
|
1810
|
-
function
|
|
1810
|
+
function bs() {
|
|
1811
1811
|
if (!this.fired)
|
|
1812
1812
|
return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
1813
1813
|
}
|
|
1814
|
-
function
|
|
1815
|
-
var s = { fired: !1, wrapFn: void 0, target: h, type: e, listener: t }, i =
|
|
1814
|
+
function vt(h, e, t) {
|
|
1815
|
+
var s = { fired: !1, wrapFn: void 0, target: h, type: e, listener: t }, i = bs.bind(s);
|
|
1816
1816
|
return i.listener = t, s.wrapFn = i, i;
|
|
1817
1817
|
}
|
|
1818
|
-
|
|
1819
|
-
return ge(t), this.on(e,
|
|
1818
|
+
A.prototype.once = function(e, t) {
|
|
1819
|
+
return ge(t), this.on(e, vt(this, e, t)), this;
|
|
1820
1820
|
};
|
|
1821
|
-
|
|
1822
|
-
return ge(t), this.prependListener(e,
|
|
1821
|
+
A.prototype.prependOnceListener = function(e, t) {
|
|
1822
|
+
return ge(t), this.prependListener(e, vt(this, e, t)), this;
|
|
1823
1823
|
};
|
|
1824
|
-
|
|
1824
|
+
A.prototype.removeListener = function(e, t) {
|
|
1825
1825
|
var s, i, r, o, n;
|
|
1826
1826
|
if (ge(t), i = this._events, i === void 0)
|
|
1827
1827
|
return this;
|
|
@@ -1837,12 +1837,12 @@ S.prototype.removeListener = function(e, t) {
|
|
|
1837
1837
|
}
|
|
1838
1838
|
if (r < 0)
|
|
1839
1839
|
return this;
|
|
1840
|
-
r === 0 ? s.shift() :
|
|
1840
|
+
r === 0 ? s.shift() : xs(s, r), s.length === 1 && (i[e] = s[0]), i.removeListener !== void 0 && this.emit("removeListener", e, n || t);
|
|
1841
1841
|
}
|
|
1842
1842
|
return this;
|
|
1843
1843
|
};
|
|
1844
|
-
|
|
1845
|
-
|
|
1844
|
+
A.prototype.off = A.prototype.removeListener;
|
|
1845
|
+
A.prototype.removeAllListeners = function(e) {
|
|
1846
1846
|
var t, s, i;
|
|
1847
1847
|
if (s = this._events, s === void 0)
|
|
1848
1848
|
return this;
|
|
@@ -1866,19 +1866,19 @@ function Ct(h, e, t) {
|
|
|
1866
1866
|
if (s === void 0)
|
|
1867
1867
|
return [];
|
|
1868
1868
|
var i = s[e];
|
|
1869
|
-
return i === void 0 ? [] : typeof i == "function" ? t ? [i.listener || i] : [i] : t ?
|
|
1869
|
+
return i === void 0 ? [] : typeof i == "function" ? t ? [i.listener || i] : [i] : t ? Ls(i) : Et(i, i.length);
|
|
1870
1870
|
}
|
|
1871
|
-
|
|
1871
|
+
A.prototype.listeners = function(e) {
|
|
1872
1872
|
return Ct(this, e, !0);
|
|
1873
1873
|
};
|
|
1874
|
-
|
|
1874
|
+
A.prototype.rawListeners = function(e) {
|
|
1875
1875
|
return Ct(this, e, !1);
|
|
1876
1876
|
};
|
|
1877
|
-
|
|
1878
|
-
return typeof h.listenerCount == "function" ? h.listenerCount(e) :
|
|
1877
|
+
A.listenerCount = function(h, e) {
|
|
1878
|
+
return typeof h.listenerCount == "function" ? h.listenerCount(e) : Ot.call(h, e);
|
|
1879
1879
|
};
|
|
1880
|
-
|
|
1881
|
-
function
|
|
1880
|
+
A.prototype.listenerCount = Ot;
|
|
1881
|
+
function Ot(h) {
|
|
1882
1882
|
var e = this._events;
|
|
1883
1883
|
if (e !== void 0) {
|
|
1884
1884
|
var t = e[h];
|
|
@@ -1889,25 +1889,25 @@ function Et(h) {
|
|
|
1889
1889
|
}
|
|
1890
1890
|
return 0;
|
|
1891
1891
|
}
|
|
1892
|
-
|
|
1893
|
-
return this._eventsCount > 0 ?
|
|
1892
|
+
A.prototype.eventNames = function() {
|
|
1893
|
+
return this._eventsCount > 0 ? fe(this._events) : [];
|
|
1894
1894
|
};
|
|
1895
|
-
function
|
|
1895
|
+
function Et(h, e) {
|
|
1896
1896
|
for (var t = new Array(e), s = 0; s < e; ++s)
|
|
1897
1897
|
t[s] = h[s];
|
|
1898
1898
|
return t;
|
|
1899
1899
|
}
|
|
1900
|
-
function
|
|
1900
|
+
function xs(h, e) {
|
|
1901
1901
|
for (; e + 1 < h.length; e++)
|
|
1902
1902
|
h[e] = h[e + 1];
|
|
1903
1903
|
h.pop();
|
|
1904
1904
|
}
|
|
1905
|
-
function
|
|
1905
|
+
function Ls(h) {
|
|
1906
1906
|
for (var e = new Array(h.length), t = 0; t < e.length; ++t)
|
|
1907
1907
|
e[t] = h[t].listener || h[t];
|
|
1908
1908
|
return e;
|
|
1909
1909
|
}
|
|
1910
|
-
function
|
|
1910
|
+
function Ps(h, e) {
|
|
1911
1911
|
return new Promise(function(t, s) {
|
|
1912
1912
|
function i(o) {
|
|
1913
1913
|
h.removeListener(e, r), s(o);
|
|
@@ -1931,96 +1931,8 @@ function Tt(h, e, t, s) {
|
|
|
1931
1931
|
else
|
|
1932
1932
|
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof h);
|
|
1933
1933
|
}
|
|
1934
|
-
var
|
|
1935
|
-
|
|
1936
|
-
antialias: !1,
|
|
1937
|
-
devicePixelRatio: window.devicePixelRatio,
|
|
1938
|
-
powerPreference: "high-performance",
|
|
1939
|
-
toneMappingExposure: 1,
|
|
1940
|
-
alpha: !1,
|
|
1941
|
-
outputColorSpace: as.sRGB,
|
|
1942
|
-
logarithmicDepthBuffer: !1,
|
|
1943
|
-
preserveDrawingBuffer: !1,
|
|
1944
|
-
stencil: !1,
|
|
1945
|
-
depth: !1
|
|
1946
|
-
};
|
|
1947
|
-
class Rs {
|
|
1948
|
-
constructor(e) {
|
|
1949
|
-
this.options = e;
|
|
1950
|
-
const { width: t, height: s, rendererParams: i } = e, {
|
|
1951
|
-
alpha: r,
|
|
1952
|
-
devicePixelRatio: o,
|
|
1953
|
-
antialias: n,
|
|
1954
|
-
powerPreference: l,
|
|
1955
|
-
toneMappingExposure: d,
|
|
1956
|
-
outputColorSpace: _,
|
|
1957
|
-
logarithmicDepthBuffer: p,
|
|
1958
|
-
preserveDrawingBuffer: E,
|
|
1959
|
-
stencil: v,
|
|
1960
|
-
depth: m
|
|
1961
|
-
} = i, u = new Ut({
|
|
1962
|
-
alpha: r,
|
|
1963
|
-
antialias: n,
|
|
1964
|
-
powerPreference: l,
|
|
1965
|
-
logarithmicDepthBuffer: p,
|
|
1966
|
-
preserveDrawingBuffer: E,
|
|
1967
|
-
stencil: v,
|
|
1968
|
-
depth: m
|
|
1969
|
-
});
|
|
1970
|
-
u.setSize(t, s), u.setPixelRatio(o), u.toneMappingExposure = d, u.outputColorSpace = _, this.renderer = u;
|
|
1971
|
-
}
|
|
1972
|
-
setSize(e, t) {
|
|
1973
|
-
this.renderer.setSize(e, t);
|
|
1974
|
-
}
|
|
1975
|
-
setPixelRatio(e) {
|
|
1976
|
-
this.renderer.setPixelRatio(e);
|
|
1977
|
-
}
|
|
1978
|
-
render(e, t) {
|
|
1979
|
-
this.renderer.render(e, t);
|
|
1980
|
-
}
|
|
1981
|
-
setViewport(e) {
|
|
1982
|
-
var l, d;
|
|
1983
|
-
const { x: t, y: s, width: i, height: r } = e, o = (l = e.scissor) != null ? l : !1, n = (d = e.scissorTest) != null ? d : !1;
|
|
1984
|
-
this.renderer.setViewport(t, s, i, r), o && (this.renderer.setScissor(t, s, i, r), this.renderer.setScissorTest(n));
|
|
1985
|
-
}
|
|
1986
|
-
setViewPadding(e = 0, t = 0, s = 0, i = 0) {
|
|
1987
|
-
const { width: r, height: o } = this.renderer.getSize(new B()), n = {
|
|
1988
|
-
x: i,
|
|
1989
|
-
y: s,
|
|
1990
|
-
width: r - i - t,
|
|
1991
|
-
height: o - e - s
|
|
1992
|
-
};
|
|
1993
|
-
this.setViewport(n);
|
|
1994
|
-
}
|
|
1995
|
-
dispose() {
|
|
1996
|
-
var e, t;
|
|
1997
|
-
this.setSize(1, 1), (e = this.renderer) == null || e.clear(), (t = this.renderer) == null || t.dispose();
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
const Ds = {
|
|
2001
|
-
antialias: !0,
|
|
2002
|
-
devicePixelRatio: window.devicePixelRatio
|
|
2003
|
-
};
|
|
2004
|
-
class Us {
|
|
2005
|
-
constructor(e) {
|
|
2006
|
-
this.options = e;
|
|
2007
|
-
const { width: t, height: s, rendererParams: i, renderer: r } = e, { devicePixelRatio: o, antialias: n } = i, l = new r({
|
|
2008
|
-
antialias: n
|
|
2009
|
-
});
|
|
2010
|
-
l.setSize(t, s), l.setPixelRatio(o), this.renderer = l;
|
|
2011
|
-
}
|
|
2012
|
-
setSize(e, t) {
|
|
2013
|
-
this.renderer.setSize(e, t);
|
|
2014
|
-
}
|
|
2015
|
-
render(e, t) {
|
|
2016
|
-
this.renderer.render(e, t);
|
|
2017
|
-
}
|
|
2018
|
-
dispose() {
|
|
2019
|
-
var e, t;
|
|
2020
|
-
this.setSize(1, 1), (e = this.renderer) == null || e.clear(), (t = this.renderer) == null || t.dispose();
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
let zs = class {
|
|
1934
|
+
var ye = Se.exports;
|
|
1935
|
+
let Ss = class {
|
|
2024
1936
|
constructor() {
|
|
2025
1937
|
this.mask = 1;
|
|
2026
1938
|
}
|
|
@@ -2048,10 +1960,10 @@ let zs = class {
|
|
|
2048
1960
|
};
|
|
2049
1961
|
class ee {
|
|
2050
1962
|
constructor() {
|
|
2051
|
-
this.event = new
|
|
1963
|
+
this.event = new ye.EventEmitter(), this.controllerMap = /* @__PURE__ */ new Map(), this.activeIndex = -1, this.activeControllerSet = /* @__PURE__ */ new Set();
|
|
2052
1964
|
}
|
|
2053
1965
|
addController(e, t) {
|
|
2054
|
-
const s = new
|
|
1966
|
+
const s = new Ss();
|
|
2055
1967
|
return s.disableAll(), t !== void 0 && s.set(t), this.controllerMap.set(e, s), t === this.activeIndex && this.activeControllerSet.add(e), e;
|
|
2056
1968
|
}
|
|
2057
1969
|
removePage(e, t) {
|
|
@@ -2060,12 +1972,13 @@ class ee {
|
|
|
2060
1972
|
});
|
|
2061
1973
|
}
|
|
2062
1974
|
setPageActive(e, t) {
|
|
2063
|
-
this.activeIndex = e, this.activeControllerSet.clear()
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
)
|
|
1975
|
+
this.activeIndex = e, this.activeControllerSet.clear();
|
|
1976
|
+
const s = Array.from(this.controllerMap.entries()).map(([i, r]) => {
|
|
1977
|
+
const o = r.isEnabled(e);
|
|
1978
|
+
if (t == null || t(i, o), o)
|
|
1979
|
+
return this.activeControllerSet.add(i), i;
|
|
1980
|
+
}).filter(Boolean);
|
|
1981
|
+
this.controller = s[0], this.event.emit("pageChange", this.controller);
|
|
2069
1982
|
}
|
|
2070
1983
|
update(e, t) {
|
|
2071
1984
|
this.activeControllerSet.forEach((s) => {
|
|
@@ -2079,22 +1992,22 @@ class ee {
|
|
|
2079
1992
|
}), this.removePage(0), this.controllerMap.clear(), this.event.removeAllListeners(), this.activeControllerSet.clear();
|
|
2080
1993
|
}
|
|
2081
1994
|
}
|
|
2082
|
-
const
|
|
1995
|
+
const wt = {
|
|
2083
1996
|
fov: 45,
|
|
2084
1997
|
near: 1,
|
|
2085
1998
|
far: 1e3,
|
|
2086
|
-
up: new
|
|
1999
|
+
up: new j(0, 1, 0)
|
|
2087
2000
|
};
|
|
2088
|
-
class
|
|
2001
|
+
class Ms extends ee {
|
|
2089
2002
|
constructor(e) {
|
|
2090
2003
|
super(), this.width = 0, this.height = 0, this.width = e.width, this.height = e.height;
|
|
2091
2004
|
}
|
|
2092
2005
|
get camera() {
|
|
2093
2006
|
return this.controller;
|
|
2094
2007
|
}
|
|
2095
|
-
addPerspectiveCamera(e =
|
|
2096
|
-
const { fov: s, far: i, near: r, up: o, aspect: n } = e,
|
|
2097
|
-
return
|
|
2008
|
+
addPerspectiveCamera(e = wt, t) {
|
|
2009
|
+
const { fov: s, far: i, near: r, up: o, aspect: n } = e, a = n != null ? n : this.width / this.height, c = new kt(s, a, r, i);
|
|
2010
|
+
return c.up = o, this.addController(c, t);
|
|
2098
2011
|
}
|
|
2099
2012
|
setPageActive(e) {
|
|
2100
2013
|
super.setPageActive(e, (t, s) => {
|
|
@@ -2160,135 +2073,330 @@ class ks extends ee {
|
|
|
2160
2073
|
s[7],
|
|
2161
2074
|
s[11],
|
|
2162
2075
|
s[15]
|
|
2163
|
-
), { width: n, height:
|
|
2164
|
-
(this.camera.fov !== t.fov || this.camera.aspect !==
|
|
2076
|
+
), { width: n, height: a } = this, c = n / a;
|
|
2077
|
+
(this.camera.fov !== t.fov || this.camera.aspect !== c || !this.camera.matrixWorld.equals(r) || !this.camera.matrixWorldInverse.equals(o)) && (this.camera.fov = t.fov, this.camera.updateProjectionMatrix(), this.camera.matrixAutoUpdate = !1, this.camera.matrixWorld.copy(r), this.camera.matrixWorldInverse.copy(o), this.camera.aspect = c, this.camera.updateProjectionMatrix());
|
|
2165
2078
|
}
|
|
2166
2079
|
}
|
|
2167
2080
|
}
|
|
2168
|
-
const
|
|
2169
|
-
|
|
2081
|
+
const Rs = (h) => {
|
|
2082
|
+
const e = new cs(
|
|
2083
|
+
new Ft({
|
|
2084
|
+
uniforms: {
|
|
2085
|
+
baseTexture: { value: null },
|
|
2086
|
+
bloomTexture: { value: h.renderTarget2.texture },
|
|
2087
|
+
bloomAlphaType: { value: 0 }
|
|
2088
|
+
},
|
|
2089
|
+
vertexShader: `
|
|
2090
|
+
varying vec2 vUv;
|
|
2091
|
+
void main() {
|
|
2092
|
+
vUv = uv;
|
|
2093
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
2094
|
+
}
|
|
2095
|
+
`,
|
|
2096
|
+
fragmentShader: `
|
|
2097
|
+
uniform sampler2D baseTexture;
|
|
2098
|
+
uniform sampler2D bloomTexture;
|
|
2099
|
+
uniform float bloomAlphaType;
|
|
2100
|
+
varying vec2 vUv;
|
|
2101
|
+
void main() {
|
|
2102
|
+
vec4 base_color = texture2D(baseTexture, vUv);
|
|
2103
|
+
vec4 bloom_color = texture2D(bloomTexture, vUv);
|
|
2104
|
+
if (bloomAlphaType == 0.0){
|
|
2105
|
+
float lum = 0.21 * bloom_color.r + 0.71 * bloom_color.g + 0.07 * bloom_color.b;
|
|
2106
|
+
gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
|
|
2107
|
+
}else{
|
|
2108
|
+
gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
`,
|
|
2112
|
+
defines: {}
|
|
2113
|
+
}),
|
|
2114
|
+
"baseTexture"
|
|
2115
|
+
);
|
|
2116
|
+
return e.needsSwap = !0, e;
|
|
2117
|
+
}, Ds = {
|
|
2118
|
+
name: "OutputShader",
|
|
2119
|
+
uniforms: {
|
|
2120
|
+
tDiffuse: { value: null },
|
|
2121
|
+
toneMappingExposure: { value: 1 },
|
|
2122
|
+
premultiplieAlpha: {
|
|
2123
|
+
value: 0
|
|
2124
|
+
}
|
|
2125
|
+
},
|
|
2126
|
+
vertexShader: (
|
|
2127
|
+
/* glsl */
|
|
2128
|
+
`
|
|
2129
|
+
precision highp float;
|
|
2130
|
+
|
|
2131
|
+
uniform mat4 modelViewMatrix;
|
|
2132
|
+
uniform mat4 projectionMatrix;
|
|
2133
|
+
|
|
2134
|
+
attribute vec3 position;
|
|
2135
|
+
attribute vec2 uv;
|
|
2136
|
+
|
|
2137
|
+
varying vec2 vUv;
|
|
2138
|
+
|
|
2139
|
+
void main() {
|
|
2140
|
+
|
|
2141
|
+
vUv = uv;
|
|
2142
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
2143
|
+
|
|
2144
|
+
}`
|
|
2145
|
+
),
|
|
2146
|
+
fragmentShader: (
|
|
2147
|
+
/* glsl */
|
|
2148
|
+
`
|
|
2149
|
+
|
|
2150
|
+
precision highp float;
|
|
2151
|
+
|
|
2152
|
+
uniform sampler2D tDiffuse;
|
|
2153
|
+
uniform float premultiplieAlpha;
|
|
2154
|
+
|
|
2155
|
+
#include <tonemapping_pars_fragment>
|
|
2156
|
+
#include <colorspace_pars_fragment>
|
|
2157
|
+
|
|
2158
|
+
varying vec2 vUv;
|
|
2159
|
+
|
|
2160
|
+
void main() {
|
|
2161
|
+
|
|
2162
|
+
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
2163
|
+
|
|
2164
|
+
if (premultiplieAlpha == 1.0) {
|
|
2165
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
// tone mapping
|
|
2169
|
+
|
|
2170
|
+
#ifdef LINEAR_TONE_MAPPING
|
|
2171
|
+
|
|
2172
|
+
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
2173
|
+
|
|
2174
|
+
#elif defined( REINHARD_TONE_MAPPING )
|
|
2175
|
+
|
|
2176
|
+
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
2177
|
+
|
|
2178
|
+
#elif defined( CINEON_TONE_MAPPING )
|
|
2179
|
+
|
|
2180
|
+
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
2181
|
+
|
|
2182
|
+
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
2183
|
+
|
|
2184
|
+
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
2185
|
+
|
|
2186
|
+
#elif defined( AGX_TONE_MAPPING )
|
|
2187
|
+
|
|
2188
|
+
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
2189
|
+
|
|
2190
|
+
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
2191
|
+
|
|
2192
|
+
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
2193
|
+
|
|
2194
|
+
#elif defined( CUSTOM_TONE_MAPPING )
|
|
2195
|
+
|
|
2196
|
+
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
2197
|
+
|
|
2198
|
+
#endif
|
|
2199
|
+
|
|
2200
|
+
// color space
|
|
2201
|
+
|
|
2202
|
+
#ifdef SRGB_TRANSFER
|
|
2203
|
+
|
|
2204
|
+
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
2205
|
+
|
|
2206
|
+
#endif
|
|
2207
|
+
|
|
2208
|
+
}`
|
|
2209
|
+
)
|
|
2170
2210
|
};
|
|
2171
|
-
class
|
|
2172
|
-
|
|
2173
|
-
|
|
2211
|
+
class Us extends ds {
|
|
2212
|
+
constructor() {
|
|
2213
|
+
super();
|
|
2214
|
+
const e = Ds;
|
|
2215
|
+
this.uniforms = Nt.clone(e.uniforms), this.material = new It({
|
|
2216
|
+
name: e.name,
|
|
2217
|
+
uniforms: this.uniforms,
|
|
2218
|
+
vertexShader: e.vertexShader,
|
|
2219
|
+
fragmentShader: e.fragmentShader
|
|
2220
|
+
}), this.fsQuad ? this.fsQuad = new Fe(this.material) : this._fsQuad && (this._fsQuad = new Fe(this.material));
|
|
2174
2221
|
}
|
|
2222
|
+
}
|
|
2223
|
+
const zs = new jt({ color: "black" }), ks = new nt({
|
|
2224
|
+
color: "black",
|
|
2225
|
+
sizeAttenuation: !1
|
|
2226
|
+
}), Fs = new nt({
|
|
2227
|
+
color: "black",
|
|
2228
|
+
sizeAttenuation: !0
|
|
2229
|
+
}), Ns = new at({
|
|
2230
|
+
color: "black",
|
|
2231
|
+
sizeAttenuation: !0
|
|
2232
|
+
}), Is = new at({
|
|
2233
|
+
color: "black",
|
|
2234
|
+
sizeAttenuation: !1
|
|
2235
|
+
}), js = new ft({
|
|
2236
|
+
color: "black",
|
|
2237
|
+
sizeAttenuation: !1,
|
|
2238
|
+
lineWidth: 0
|
|
2239
|
+
}), Hs = {
|
|
2240
|
+
kernelRadius: 8,
|
|
2241
|
+
minDistance: 5e-3,
|
|
2242
|
+
maxDistance: 0.1
|
|
2243
|
+
}, Bs = {
|
|
2244
|
+
threshold: 0,
|
|
2245
|
+
strength: 0.4,
|
|
2246
|
+
radius: 0.1,
|
|
2247
|
+
bloomAlphaType: 0
|
|
2248
|
+
}, Vs = {
|
|
2249
|
+
multisampling: 4,
|
|
2250
|
+
premultiplieAlpha: !1
|
|
2251
|
+
};
|
|
2252
|
+
class Ys {
|
|
2175
2253
|
constructor(e) {
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2254
|
+
this.bloomComposerActive = !1, this.active = !0, this.bloomSelection = /* @__PURE__ */ new Set(), this.bloomLayer = new Ht(), this.bloomMaterials = {}, this.bloomVisible = {}, this.bloomComposerRenderIng = !1, this.pipViewportState = null, this.options = e;
|
|
2255
|
+
const {
|
|
2256
|
+
rendererController: t,
|
|
2257
|
+
sceneController: s,
|
|
2258
|
+
cameraController: i,
|
|
2259
|
+
composerParams: r
|
|
2260
|
+
} = e, { renderer: o } = t;
|
|
2261
|
+
this.renderer = o;
|
|
2262
|
+
const { multisampling: n } = r, { maxSamples: a } = o.capabilities, c = o.getDrawingBufferSize(new B()), u = new Bt(
|
|
2263
|
+
c.width,
|
|
2264
|
+
c.height,
|
|
2265
|
+
{
|
|
2266
|
+
samples: Math.min(n, a),
|
|
2267
|
+
type: Vt
|
|
2268
|
+
}
|
|
2269
|
+
), m = new ke(o, u), v = this.getSize();
|
|
2270
|
+
m.setSize(v.width, v.height);
|
|
2271
|
+
const p = new as(
|
|
2272
|
+
s.scene,
|
|
2273
|
+
i.camera
|
|
2274
|
+
);
|
|
2275
|
+
m.addPass(p), this.scene = s.scene, this.camera = i.camera, this.finalComposer = m, this.renderPass = p, i.event.on("pageChange", (f) => {
|
|
2276
|
+
this.changeCamera(f);
|
|
2277
|
+
}), s.event.on("pageChange", (f) => {
|
|
2278
|
+
this.changeScene(f);
|
|
2186
2279
|
});
|
|
2187
2280
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
t.visible = s;
|
|
2191
|
-
});
|
|
2281
|
+
changeCamera(e) {
|
|
2282
|
+
this.renderPass.camera = e, this.camera = e;
|
|
2192
2283
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
constructor(e) {
|
|
2196
|
-
this.helpers = {}, this.options = e;
|
|
2284
|
+
changeScene(e) {
|
|
2285
|
+
this.renderPass.scene = e, this.ssaoPass && (this.ssaoPass.scene = e), this.scene = e;
|
|
2197
2286
|
}
|
|
2198
|
-
|
|
2199
|
-
const
|
|
2200
|
-
|
|
2201
|
-
if (i === void 0) {
|
|
2202
|
-
if (e.isScene)
|
|
2203
|
-
i = new De(100);
|
|
2204
|
-
else if (e.isCamera)
|
|
2205
|
-
i = new kt(e);
|
|
2206
|
-
else if (e.isPointLight)
|
|
2207
|
-
i = new Ft(e, 1);
|
|
2208
|
-
else if (e.isDirectionalLight)
|
|
2209
|
-
i = new Nt(e, 1);
|
|
2210
|
-
else if (e.isSpotLight)
|
|
2211
|
-
i = new Ht(e);
|
|
2212
|
-
else if (e.isHemisphereLight)
|
|
2213
|
-
i = new It(e, 10);
|
|
2214
|
-
else if (e.isRectAreaLight)
|
|
2215
|
-
i = new ds(e);
|
|
2216
|
-
else {
|
|
2217
|
-
const r = new at();
|
|
2218
|
-
if (r.setFromObject(e, !0), r.isEmpty() === !1) {
|
|
2219
|
-
i = new Ue(r);
|
|
2220
|
-
const o = i.material;
|
|
2221
|
-
o.userData.object = e, o.depthTest = !1, o.transparent = !0;
|
|
2222
|
-
} else
|
|
2223
|
-
return;
|
|
2224
|
-
}
|
|
2225
|
-
s.scene.add(i), this.helpers[t] = i;
|
|
2226
|
-
}
|
|
2287
|
+
addOutputPass() {
|
|
2288
|
+
const { premultiplieAlpha: e } = this.options.composerParams, t = new Us();
|
|
2289
|
+
this.outputPass = t, this.setPremultiplieAlpha(e), this.finalComposer.addPass(t);
|
|
2227
2290
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
t.addEventListener("pointerdown", (i) => {
|
|
2231
|
-
i.preventDefault(), s.handleClick(i);
|
|
2232
|
-
}), this.viewHelper = s;
|
|
2291
|
+
setPremultiplieAlpha(e) {
|
|
2292
|
+
this.outputPass && (this.outputPass.uniforms.premultiplieAlpha.value = e ? 1 : 0);
|
|
2233
2293
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2294
|
+
addSSAOPass(e) {
|
|
2295
|
+
const { scene: t, camera: s, renderer: i } = this, r = i.getSize(new B()), o = r.width, n = r.height, a = new ls(t, s, o, n);
|
|
2296
|
+
a.kernelRadius = e.kernelRadius, a.minDistance = e.minDistance, a.maxDistance = e.maxDistance, this.ssaoPass = a, this.finalComposer.addPass(a);
|
|
2297
|
+
}
|
|
2298
|
+
addBloomPass(e) {
|
|
2299
|
+
const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new hs(
|
|
2300
|
+
new B(window.innerWidth, window.innerHeight),
|
|
2301
|
+
i,
|
|
2302
|
+
r,
|
|
2303
|
+
s
|
|
2304
|
+
);
|
|
2305
|
+
this.bloomPass = n;
|
|
2306
|
+
const a = new ke(t);
|
|
2307
|
+
a.renderToScreen = !1, a.addPass(this.renderPass), a.addPass(n), this.bloomComposer = a;
|
|
2308
|
+
const c = Rs(a);
|
|
2309
|
+
c.uniforms.bloomAlphaType.value = o, this.bloomComposer = a, this.finalComposer.addPass(c), this.mixPass = c, this.bloomLayer.set(Oe);
|
|
2310
|
+
}
|
|
2311
|
+
setBloomSelection(e, t) {
|
|
2312
|
+
if (!this.bloomComposer) {
|
|
2313
|
+
console.warn("err:pencil.options.bloom");
|
|
2314
|
+
return;
|
|
2240
2315
|
}
|
|
2316
|
+
e.traverse((s) => {
|
|
2317
|
+
const { object3d: i } = s;
|
|
2318
|
+
i && (t ? (this.bloomSelection.add(s), i.layers.enable(Oe)) : (this.bloomSelection.delete(s), i.layers.disable(Oe)));
|
|
2319
|
+
}), this.bloomSelection.size === 0 ? this.bloomComposerActive = !1 : this.bloomComposerActive = !0;
|
|
2241
2320
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
this.remove({
|
|
2245
|
-
uuid: e
|
|
2246
|
-
});
|
|
2247
|
-
}), this.helpers = {};
|
|
2321
|
+
enable() {
|
|
2322
|
+
this.active || (this.active = !0);
|
|
2248
2323
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2324
|
+
disable() {
|
|
2325
|
+
this.active && (this.active = !1);
|
|
2326
|
+
}
|
|
2327
|
+
setSize(e, t) {
|
|
2328
|
+
var s;
|
|
2329
|
+
(s = this.bloomComposer) == null || s.setSize(e, t), this.finalComposer.setSize(e, t);
|
|
2330
|
+
}
|
|
2331
|
+
setPixelRatio(e) {
|
|
2332
|
+
var t;
|
|
2333
|
+
(t = this.bloomComposer) == null || t.setPixelRatio(e), this.finalComposer.setPixelRatio(e);
|
|
2334
|
+
}
|
|
2335
|
+
darkenNonBloomed() {
|
|
2336
|
+
const e = [], t = [];
|
|
2337
|
+
this.scene.children.forEach((s) => {
|
|
2338
|
+
s.isTransformControls || s.isTransformControlsRoot || s.type === "RectAreaLightHelper" ? e.push(s) : t.push(s);
|
|
2339
|
+
}), t.forEach((s) => {
|
|
2340
|
+
s.traverse((i) => {
|
|
2341
|
+
var a;
|
|
2342
|
+
const r = i, o = i, n = i;
|
|
2343
|
+
(a = r.material) != null && a.isShadowMaterial ? e.push(r) : r.material && this.bloomLayer.test(r.layers) === !1 && (this.bloomMaterials[r.uuid] = r.material, o.isSprite ? o.material.sizeAttenuation ? o.material = Ns : o.material = Is : r.material instanceof ft ? r.material = js : n.isPoints ? n.material.sizeAttenuation ? n.material = Fs : n.material = ks : r.material = zs);
|
|
2253
2344
|
});
|
|
2345
|
+
}), e.forEach((s) => {
|
|
2346
|
+
this.bloomVisible[s.uuid] = s.visible, s.visible = !1;
|
|
2254
2347
|
});
|
|
2255
2348
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
const l = n.material, { object: d } = l.userData;
|
|
2262
|
-
d && n.box.setFromObject(d, !0);
|
|
2263
|
-
}
|
|
2264
|
-
}), ((r = this.viewHelper) == null ? void 0 : r.animating) === !0 && (this.viewHelper.update(e), (o = t.cameraControls) == null || o.setPosition(
|
|
2265
|
-
...i.camera.position.toArray()
|
|
2266
|
-
), this.viewHelper.center.copy(s));
|
|
2349
|
+
restoreNonBloomed() {
|
|
2350
|
+
this.scene.traverse((e) => {
|
|
2351
|
+
const t = e;
|
|
2352
|
+
this.bloomMaterials[t.uuid] ? (t.material = this.bloomMaterials[t.uuid], delete this.bloomMaterials[t.uuid]) : this.bloomVisible[t.uuid] !== void 0 && (t.visible = this.bloomVisible[t.uuid], delete this.bloomVisible[t.uuid]);
|
|
2353
|
+
});
|
|
2267
2354
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2355
|
+
finalComposerRender() {
|
|
2356
|
+
this.bloomComposerActive && this.bloomComposer ? (this.bloomComposerRenderIng = !0, this.mixPass.enabled = !0, this.darkenNonBloomed(), this.bloomComposer.render(), this.restoreNonBloomed(), this.bloomComposerRenderIng = !1) : this.mixPass && (this.mixPass.enabled = !1), this.finalComposer.render();
|
|
2357
|
+
}
|
|
2358
|
+
getSize() {
|
|
2359
|
+
return this.renderer.getSize(new B());
|
|
2360
|
+
}
|
|
2361
|
+
render() {
|
|
2362
|
+
if (!this.active) return;
|
|
2363
|
+
const { cameraController: e, rendererController: t, sceneController: s } = this.options;
|
|
2364
|
+
if (this.finalComposerRender(), this.pipViewportState) {
|
|
2365
|
+
e.setPageActive(31), e.setAspect(
|
|
2366
|
+
this.pipViewportState.width / this.pipViewportState.height
|
|
2367
|
+
), t.setViewport(te(U({}, this.pipViewportState), {
|
|
2368
|
+
scissor: !0,
|
|
2369
|
+
scissorTest: !0
|
|
2370
|
+
})), this.finalComposerRender(), e.setPageActive(s.activeIndex);
|
|
2371
|
+
const i = this.getSize();
|
|
2372
|
+
t.setViewport({
|
|
2373
|
+
x: 0,
|
|
2374
|
+
y: 0,
|
|
2375
|
+
width: i.width,
|
|
2376
|
+
height: i.height,
|
|
2377
|
+
scissor: !0,
|
|
2378
|
+
scissorTest: !1
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2273
2381
|
}
|
|
2274
2382
|
dispose() {
|
|
2275
2383
|
var e;
|
|
2276
|
-
this.
|
|
2384
|
+
this.bloomMaterials = {}, this.bloomVisible = {}, this.bloomSelection.clear(), this.finalComposer.dispose(), (e = this.bloomComposer) == null || e.dispose();
|
|
2277
2385
|
}
|
|
2278
2386
|
}
|
|
2279
|
-
class
|
|
2387
|
+
class Zs extends ee {
|
|
2280
2388
|
constructor(e) {
|
|
2281
2389
|
super(), this.autoRotateSpeed = 0, this.options = e;
|
|
2282
2390
|
const t = {
|
|
2283
2391
|
Vector2: B,
|
|
2284
|
-
Vector3:
|
|
2285
|
-
Vector4:
|
|
2392
|
+
Vector3: j,
|
|
2393
|
+
Vector4: Zt,
|
|
2286
2394
|
Quaternion: lt,
|
|
2287
2395
|
Matrix4: W,
|
|
2288
|
-
Spherical:
|
|
2289
|
-
Box3:
|
|
2290
|
-
Sphere:
|
|
2291
|
-
Raycaster:
|
|
2396
|
+
Spherical: Wt,
|
|
2397
|
+
Box3: ht,
|
|
2398
|
+
Sphere: Kt,
|
|
2399
|
+
Raycaster: ct
|
|
2292
2400
|
};
|
|
2293
2401
|
J.install({ THREE: t });
|
|
2294
2402
|
}
|
|
@@ -2320,80 +2428,11 @@ class Is extends ee {
|
|
|
2320
2428
|
});
|
|
2321
2429
|
}
|
|
2322
2430
|
update(e, t) {
|
|
2323
|
-
super.update(e, t), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e *
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
class js {
|
|
2327
|
-
constructor(e) {
|
|
2328
|
-
this.event = new ve.EventEmitter();
|
|
2329
|
-
const { renderer: t, scene: s, camera: i } = e, r = new ms(
|
|
2330
|
-
i,
|
|
2331
|
-
t.domElement
|
|
2332
|
-
);
|
|
2333
|
-
if (r.getHelper) {
|
|
2334
|
-
const o = r.getHelper();
|
|
2335
|
-
if (s.add(o), +Zt < 170) {
|
|
2336
|
-
const n = r._root;
|
|
2337
|
-
n.dispose = () => {
|
|
2338
|
-
n.traverse((l) => {
|
|
2339
|
-
l.geometry && l.geometry.dispose(), l.material && l.material.dispose();
|
|
2340
|
-
});
|
|
2341
|
-
}, r.dispose = () => {
|
|
2342
|
-
r.disconnect(), n.dispose();
|
|
2343
|
-
};
|
|
2344
|
-
}
|
|
2345
|
-
} else r instanceof Wt && s.add(r);
|
|
2346
|
-
this.controls = r, this.addEvent();
|
|
2347
|
-
}
|
|
2348
|
-
get detach() {
|
|
2349
|
-
return this.controls.detach.bind(this.controls);
|
|
2350
|
-
}
|
|
2351
|
-
get attach() {
|
|
2352
|
-
return this.controls.attach.bind(this.controls);
|
|
2353
|
-
}
|
|
2354
|
-
addEvent() {
|
|
2355
|
-
let e = null, t = null, s = null;
|
|
2356
|
-
const i = this.controls;
|
|
2357
|
-
i.addEventListener("change", () => {
|
|
2358
|
-
const r = i.object;
|
|
2359
|
-
r !== void 0 && this.event.emit("change", r);
|
|
2360
|
-
}), i.addEventListener("mouseDown", () => {
|
|
2361
|
-
const r = i.object;
|
|
2362
|
-
e = r.position.clone(), t = r.rotation.clone(), s = r.scale.clone(), this.event.emit("mouseDown", r);
|
|
2363
|
-
}), i.addEventListener("mouseUp", () => {
|
|
2364
|
-
const r = i.object;
|
|
2365
|
-
if (r !== void 0)
|
|
2366
|
-
switch (i.getMode()) {
|
|
2367
|
-
case "translate":
|
|
2368
|
-
e.equals(r.position) || this.event.emit(
|
|
2369
|
-
"translate",
|
|
2370
|
-
r,
|
|
2371
|
-
r.position,
|
|
2372
|
-
e
|
|
2373
|
-
);
|
|
2374
|
-
break;
|
|
2375
|
-
case "rotate":
|
|
2376
|
-
t.equals(r.rotation) || this.event.emit(
|
|
2377
|
-
"rotate",
|
|
2378
|
-
r,
|
|
2379
|
-
r.rotation,
|
|
2380
|
-
t
|
|
2381
|
-
);
|
|
2382
|
-
break;
|
|
2383
|
-
case "scale":
|
|
2384
|
-
s.equals(r.scale) || this.event.emit("scale", r, r.scale, s);
|
|
2385
|
-
break;
|
|
2386
|
-
}
|
|
2387
|
-
this.event.emit("mouseUp");
|
|
2388
|
-
});
|
|
2389
|
-
}
|
|
2390
|
-
dispose() {
|
|
2391
|
-
var e;
|
|
2392
|
-
this.event.removeAllListeners(), (e = this.controls) == null || e.dispose();
|
|
2431
|
+
super.update(e, t), this.autoRotateSpeed && this.cameraControls && (this.cameraControls.azimuthAngle += this.autoRotateSpeed * e * Yt.DEG2RAD);
|
|
2393
2432
|
}
|
|
2394
2433
|
}
|
|
2395
|
-
const
|
|
2396
|
-
class
|
|
2434
|
+
const Xe = new j(), Ws = new lt(), qe = new j(), I = new W(), Ks = new W();
|
|
2435
|
+
class $s {
|
|
2397
2436
|
/**
|
|
2398
2437
|
* Constructs a new CSS3D renderer.
|
|
2399
2438
|
*
|
|
@@ -2405,69 +2444,69 @@ class Ys {
|
|
|
2405
2444
|
const n = {
|
|
2406
2445
|
camera: { style: "" },
|
|
2407
2446
|
objects: /* @__PURE__ */ new WeakMap()
|
|
2408
|
-
},
|
|
2409
|
-
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2412
|
-
const
|
|
2413
|
-
|
|
2447
|
+
}, a = e.element !== void 0 ? e.element : document.createElement("div");
|
|
2448
|
+
a.style.overflow = "hidden", this.domElement = a;
|
|
2449
|
+
const c = document.createElement("div");
|
|
2450
|
+
c.style.transformOrigin = "0 0", c.style.pointerEvents = "none", a.appendChild(c);
|
|
2451
|
+
const u = document.createElement("div");
|
|
2452
|
+
u.style.transformStyle = "preserve-3d", c.appendChild(u), this.getSize = function() {
|
|
2414
2453
|
return {
|
|
2415
2454
|
width: s,
|
|
2416
2455
|
height: i
|
|
2417
2456
|
};
|
|
2418
|
-
}, this.render = function(
|
|
2419
|
-
const
|
|
2420
|
-
|
|
2421
|
-
let
|
|
2422
|
-
|
|
2423
|
-
const
|
|
2424
|
-
n.camera.style !== R && (
|
|
2425
|
-
}, this.setSize = function(
|
|
2426
|
-
s =
|
|
2457
|
+
}, this.render = function(y, l) {
|
|
2458
|
+
const _ = l.projectionMatrix.elements[5] * o;
|
|
2459
|
+
l.view && l.view.enabled ? (c.style.transform = `translate( ${-l.view.offsetX * (s / l.view.width)}px, ${-l.view.offsetY * (i / l.view.height)}px )`, c.style.transform += `scale( ${l.view.fullWidth / l.view.width}, ${l.view.fullHeight / l.view.height} )`) : c.style.transform = "", y.matrixWorldAutoUpdate === !0 && y.updateMatrixWorld(), l.parent === null && l.matrixWorldAutoUpdate === !0 && l.updateMatrixWorld();
|
|
2460
|
+
let O, C;
|
|
2461
|
+
l.isOrthographicCamera && (O = -(l.right + l.left) / 2, C = (l.top + l.bottom) / 2);
|
|
2462
|
+
const w = l.view && l.view.enabled ? l.view.height / l.view.fullHeight : 1, E = l.isOrthographicCamera ? `scale( ${w} )scale(` + _ + ")translate(" + m(O) + "px," + m(C) + "px)" + v(l.matrixWorldInverse) : `scale( ${w} )translateZ(` + _ + "px)" + v(l.matrixWorldInverse), R = (l.isPerspectiveCamera ? "perspective(" + _ + "px) " : "") + E + "translate(" + r + "px," + o + "px)";
|
|
2463
|
+
n.camera.style !== R && (u.style.transform = R, n.camera.style = R), g(y, y, l);
|
|
2464
|
+
}, this.setSize = function(y, l) {
|
|
2465
|
+
s = y, i = l, r = s / 2, o = i / 2, a.style.width = y + "px", a.style.height = l + "px", c.style.width = y + "px", c.style.height = l + "px", u.style.width = y + "px", u.style.height = l + "px";
|
|
2427
2466
|
};
|
|
2428
|
-
function
|
|
2429
|
-
return Math.abs(
|
|
2467
|
+
function m(y) {
|
|
2468
|
+
return Math.abs(y) < 1e-10 ? 0 : y;
|
|
2430
2469
|
}
|
|
2431
|
-
function
|
|
2432
|
-
const
|
|
2433
|
-
return "matrix3d(" +
|
|
2470
|
+
function v(y) {
|
|
2471
|
+
const l = y.elements;
|
|
2472
|
+
return "matrix3d(" + m(l[0]) + "," + m(-l[1]) + "," + m(l[2]) + "," + m(l[3]) + "," + m(l[4]) + "," + m(-l[5]) + "," + m(l[6]) + "," + m(l[7]) + "," + m(l[8]) + "," + m(-l[9]) + "," + m(l[10]) + "," + m(l[11]) + "," + m(l[12]) + "," + m(-l[13]) + "," + m(l[14]) + "," + m(l[15]) + ")";
|
|
2434
2473
|
}
|
|
2435
|
-
function
|
|
2436
|
-
const
|
|
2437
|
-
return "translate(-50%,-50%)" + ("matrix3d(" +
|
|
2474
|
+
function p(y) {
|
|
2475
|
+
const l = y.elements;
|
|
2476
|
+
return "translate(-50%,-50%)" + ("matrix3d(" + m(l[0]) + "," + m(l[1]) + "," + m(l[2]) + "," + m(l[3]) + "," + m(-l[4]) + "," + m(-l[5]) + "," + m(-l[6]) + "," + m(-l[7]) + "," + m(l[8]) + "," + m(l[9]) + "," + m(l[10]) + "," + m(l[11]) + "," + m(l[12]) + "," + m(l[13]) + "," + m(l[14]) + "," + m(l[15]) + ")");
|
|
2438
2477
|
}
|
|
2439
|
-
function
|
|
2440
|
-
|
|
2441
|
-
for (let
|
|
2442
|
-
|
|
2478
|
+
function f(y) {
|
|
2479
|
+
y.isCSS3DObject && (y.element.style.display = "none");
|
|
2480
|
+
for (let l = 0, _ = y.children.length; l < _; l++)
|
|
2481
|
+
f(y.children[l]);
|
|
2443
2482
|
}
|
|
2444
|
-
function
|
|
2445
|
-
if (
|
|
2446
|
-
|
|
2483
|
+
function g(y, l, _, O) {
|
|
2484
|
+
if (y.visible === !1) {
|
|
2485
|
+
f(y);
|
|
2447
2486
|
return;
|
|
2448
2487
|
}
|
|
2449
|
-
if (
|
|
2450
|
-
const
|
|
2451
|
-
if (
|
|
2452
|
-
|
|
2453
|
-
let
|
|
2454
|
-
|
|
2455
|
-
const x = n.objects.get(
|
|
2456
|
-
if (x === void 0 || x.style !==
|
|
2457
|
-
|
|
2458
|
-
const R = { style:
|
|
2459
|
-
n.objects.set(
|
|
2488
|
+
if (y.isCSS3DObject) {
|
|
2489
|
+
const C = y.layers.test(_.layers) === !0, w = y.element;
|
|
2490
|
+
if (w.style.display = C === !0 ? "" : "none", C === !0) {
|
|
2491
|
+
y.onBeforeRender(t, l, _);
|
|
2492
|
+
let E;
|
|
2493
|
+
y.isCSS3DSprite ? (I.copy(_.matrixWorldInverse), I.transpose(), y.rotation2D !== 0 && I.multiply(Ks.makeRotationZ(y.rotation2D)), y.matrixWorld.decompose(Xe, Ws, qe), I.setPosition(Xe), I.scale(qe), I.elements[3] = 0, I.elements[7] = 0, I.elements[11] = 0, I.elements[15] = 1, E = p(I)) : E = p(y.matrixWorld);
|
|
2494
|
+
const x = n.objects.get(y);
|
|
2495
|
+
if (x === void 0 || x.style !== E) {
|
|
2496
|
+
w.style.transform = E;
|
|
2497
|
+
const R = { style: E };
|
|
2498
|
+
n.objects.set(y, R);
|
|
2460
2499
|
}
|
|
2461
|
-
|
|
2500
|
+
w.parentNode !== u && u.appendChild(w), y.onAfterRender(t, l, _);
|
|
2462
2501
|
}
|
|
2463
2502
|
}
|
|
2464
|
-
for (let
|
|
2465
|
-
|
|
2503
|
+
for (let C = 0, w = y.children.length; C < w; C++)
|
|
2504
|
+
g(y.children[C], l, _);
|
|
2466
2505
|
}
|
|
2467
2506
|
}
|
|
2468
2507
|
}
|
|
2469
|
-
const q = new
|
|
2470
|
-
class
|
|
2508
|
+
const q = new j(), Qe = new W(), Je = new W(), et = new j(), tt = new j();
|
|
2509
|
+
class Gs {
|
|
2471
2510
|
/**
|
|
2472
2511
|
* Constructs a new CSS2D renderer.
|
|
2473
2512
|
*
|
|
@@ -2478,69 +2517,69 @@ class Zs {
|
|
|
2478
2517
|
let s, i, r, o;
|
|
2479
2518
|
const n = {
|
|
2480
2519
|
objects: /* @__PURE__ */ new WeakMap()
|
|
2481
|
-
},
|
|
2482
|
-
|
|
2520
|
+
}, a = e.element !== void 0 ? e.element : document.createElement("div");
|
|
2521
|
+
a.style.overflow = "hidden", this.domElement = a, this.getSize = function() {
|
|
2483
2522
|
return {
|
|
2484
2523
|
width: s,
|
|
2485
2524
|
height: i
|
|
2486
2525
|
};
|
|
2487
|
-
}, this.render = function(
|
|
2488
|
-
|
|
2489
|
-
}, this.setSize = function(
|
|
2490
|
-
s =
|
|
2526
|
+
}, this.render = function(f, g) {
|
|
2527
|
+
f.matrixWorldAutoUpdate === !0 && f.updateMatrixWorld(), g.parent === null && g.matrixWorldAutoUpdate === !0 && g.updateMatrixWorld(), Qe.copy(g.matrixWorldInverse), Je.multiplyMatrices(g.projectionMatrix, Qe), u(f, f, g), p(f);
|
|
2528
|
+
}, this.setSize = function(f, g) {
|
|
2529
|
+
s = f, i = g, r = s / 2, o = i / 2, a.style.width = f + "px", a.style.height = g + "px";
|
|
2491
2530
|
};
|
|
2492
|
-
function
|
|
2493
|
-
|
|
2494
|
-
for (let
|
|
2495
|
-
|
|
2531
|
+
function c(f) {
|
|
2532
|
+
f.isCSS2DObject && (f.element.style.display = "none");
|
|
2533
|
+
for (let g = 0, y = f.children.length; g < y; g++)
|
|
2534
|
+
c(f.children[g]);
|
|
2496
2535
|
}
|
|
2497
|
-
function
|
|
2498
|
-
if (
|
|
2499
|
-
|
|
2536
|
+
function u(f, g, y) {
|
|
2537
|
+
if (f.visible === !1) {
|
|
2538
|
+
c(f);
|
|
2500
2539
|
return;
|
|
2501
2540
|
}
|
|
2502
|
-
if (
|
|
2503
|
-
q.setFromMatrixPosition(
|
|
2504
|
-
const
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2507
|
-
distanceToCameraSquared:
|
|
2541
|
+
if (f.isCSS2DObject) {
|
|
2542
|
+
q.setFromMatrixPosition(f.matrixWorld), q.applyMatrix4(Je);
|
|
2543
|
+
const l = q.z >= -1 && q.z <= 1 && f.layers.test(y.layers) === !0, _ = f.element;
|
|
2544
|
+
_.style.display = l === !0 ? "" : "none", l === !0 && (f.onBeforeRender(t, g, y), _.style.transform = "translate(" + -100 * f.center.x + "%," + -100 * f.center.y + "%)translate(" + (q.x * r + r) + "px," + (-q.y * o + o) + "px)", _.parentNode !== a && a.appendChild(_), f.onAfterRender(t, g, y));
|
|
2545
|
+
const O = {
|
|
2546
|
+
distanceToCameraSquared: m(y, f)
|
|
2508
2547
|
};
|
|
2509
|
-
n.objects.set(
|
|
2548
|
+
n.objects.set(f, O);
|
|
2510
2549
|
}
|
|
2511
|
-
for (let
|
|
2512
|
-
|
|
2550
|
+
for (let l = 0, _ = f.children.length; l < _; l++)
|
|
2551
|
+
u(f.children[l], g, y);
|
|
2513
2552
|
}
|
|
2514
|
-
function
|
|
2515
|
-
return et.setFromMatrixPosition(
|
|
2553
|
+
function m(f, g) {
|
|
2554
|
+
return et.setFromMatrixPosition(f.matrixWorld), tt.setFromMatrixPosition(g.matrixWorld), et.distanceToSquared(tt);
|
|
2516
2555
|
}
|
|
2517
|
-
function
|
|
2518
|
-
const
|
|
2519
|
-
return
|
|
2520
|
-
|
|
2521
|
-
}),
|
|
2556
|
+
function v(f) {
|
|
2557
|
+
const g = [];
|
|
2558
|
+
return f.traverseVisible(function(y) {
|
|
2559
|
+
y.isCSS2DObject && g.push(y);
|
|
2560
|
+
}), g;
|
|
2522
2561
|
}
|
|
2523
|
-
function
|
|
2524
|
-
const
|
|
2525
|
-
if (
|
|
2526
|
-
return
|
|
2527
|
-
const
|
|
2528
|
-
return
|
|
2529
|
-
}),
|
|
2530
|
-
for (let
|
|
2531
|
-
|
|
2562
|
+
function p(f) {
|
|
2563
|
+
const g = v(f).sort(function(l, _) {
|
|
2564
|
+
if (l.renderOrder !== _.renderOrder)
|
|
2565
|
+
return _.renderOrder - l.renderOrder;
|
|
2566
|
+
const O = n.objects.get(l).distanceToCameraSquared, C = n.objects.get(_).distanceToCameraSquared;
|
|
2567
|
+
return O - C;
|
|
2568
|
+
}), y = g.length;
|
|
2569
|
+
for (let l = 0, _ = g.length; l < _; l++)
|
|
2570
|
+
g[l].element.style.zIndex = y - l;
|
|
2532
2571
|
}
|
|
2533
2572
|
}
|
|
2534
2573
|
}
|
|
2535
2574
|
const st = {
|
|
2536
2575
|
zIndex: "auto"
|
|
2537
2576
|
};
|
|
2538
|
-
class
|
|
2577
|
+
class Xs {
|
|
2539
2578
|
constructor(e) {
|
|
2540
2579
|
this.container = e;
|
|
2541
2580
|
}
|
|
2542
2581
|
addRenderer(e, t) {
|
|
2543
|
-
const s = t.container || this.container, i = s.offsetWidth, r = s.offsetHeight, o = e === "css2d" ? new
|
|
2582
|
+
const s = t.container || this.container, i = s.offsetWidth, r = s.offsetHeight, o = e === "css2d" ? new Gs() : new $s();
|
|
2544
2583
|
o.domElement.style.position = "absolute", o.domElement.style.top = "0", o.domElement.style.pointerEvents = "none", o.domElement.style.zIndex = t.zIndex, o.setSize(i, r), s.appendChild(o.domElement), e === "css2d" ? this.css2Drenderer = o : e === "css3d" && (this.css3Drenderer = o);
|
|
2545
2584
|
}
|
|
2546
2585
|
setSize(e, t) {
|
|
@@ -2556,560 +2595,92 @@ class Ws {
|
|
|
2556
2595
|
(e = this.css2Drenderer) == null || e.domElement.remove(), (t = this.css3Drenderer) == null || t.domElement.remove(), this.css2Drenderer = void 0, this.css3Drenderer = void 0;
|
|
2557
2596
|
}
|
|
2558
2597
|
}
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2598
|
+
class qs {
|
|
2599
|
+
constructor(e) {
|
|
2600
|
+
this.helpers = {}, this.options = e;
|
|
2601
|
+
}
|
|
2602
|
+
add(e) {
|
|
2603
|
+
const t = e.uuid, { sceneController: s } = this.options;
|
|
2604
|
+
let i = this.helpers[t];
|
|
2605
|
+
if (i === void 0) {
|
|
2606
|
+
if (e.isScene)
|
|
2607
|
+
i = new De(100);
|
|
2608
|
+
else if (e.isCamera)
|
|
2609
|
+
i = new $t(e);
|
|
2610
|
+
else if (e.isPointLight)
|
|
2611
|
+
i = new Gt(e, 1);
|
|
2612
|
+
else if (e.isDirectionalLight)
|
|
2613
|
+
i = new Xt(e, 1);
|
|
2614
|
+
else if (e.isSpotLight)
|
|
2615
|
+
i = new qt(e);
|
|
2616
|
+
else if (e.isHemisphereLight)
|
|
2617
|
+
i = new Qt(e, 10);
|
|
2618
|
+
else if (e.isRectAreaLight)
|
|
2619
|
+
i = new ms(e);
|
|
2620
|
+
else {
|
|
2621
|
+
const r = new ht();
|
|
2622
|
+
if (r.setFromObject(e, !0), r.isEmpty() === !1) {
|
|
2623
|
+
i = new Ue(r);
|
|
2624
|
+
const o = i.material;
|
|
2625
|
+
o.userData.object = e, o.depthTest = !1, o.transparent = !0;
|
|
2626
|
+
} else
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2629
|
+
s.scene.add(i), this.helpers[t] = i;
|
|
2566
2630
|
}
|
|
2567
|
-
},
|
|
2568
|
-
vertexShader: (
|
|
2569
|
-
/* glsl */
|
|
2570
|
-
`
|
|
2571
|
-
precision highp float;
|
|
2572
|
-
|
|
2573
|
-
uniform mat4 modelViewMatrix;
|
|
2574
|
-
uniform mat4 projectionMatrix;
|
|
2575
|
-
|
|
2576
|
-
attribute vec3 position;
|
|
2577
|
-
attribute vec2 uv;
|
|
2578
|
-
|
|
2579
|
-
varying vec2 vUv;
|
|
2580
|
-
|
|
2581
|
-
void main() {
|
|
2582
|
-
|
|
2583
|
-
vUv = uv;
|
|
2584
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
2585
|
-
|
|
2586
|
-
}`
|
|
2587
|
-
),
|
|
2588
|
-
fragmentShader: (
|
|
2589
|
-
/* glsl */
|
|
2590
|
-
`
|
|
2591
|
-
|
|
2592
|
-
precision highp float;
|
|
2593
|
-
|
|
2594
|
-
uniform sampler2D tDiffuse;
|
|
2595
|
-
uniform float premultiplieAlpha;
|
|
2596
|
-
|
|
2597
|
-
#include <tonemapping_pars_fragment>
|
|
2598
|
-
#include <colorspace_pars_fragment>
|
|
2599
|
-
|
|
2600
|
-
varying vec2 vUv;
|
|
2601
|
-
|
|
2602
|
-
void main() {
|
|
2603
|
-
|
|
2604
|
-
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
2605
|
-
|
|
2606
|
-
if (premultiplieAlpha == 1.0) {
|
|
2607
|
-
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2608
|
-
}
|
|
2609
|
-
|
|
2610
|
-
// tone mapping
|
|
2611
|
-
|
|
2612
|
-
#ifdef LINEAR_TONE_MAPPING
|
|
2613
|
-
|
|
2614
|
-
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
2615
|
-
|
|
2616
|
-
#elif defined( REINHARD_TONE_MAPPING )
|
|
2617
|
-
|
|
2618
|
-
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
2619
|
-
|
|
2620
|
-
#elif defined( CINEON_TONE_MAPPING )
|
|
2621
|
-
|
|
2622
|
-
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
2623
|
-
|
|
2624
|
-
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
2625
|
-
|
|
2626
|
-
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
2627
|
-
|
|
2628
|
-
#elif defined( AGX_TONE_MAPPING )
|
|
2629
|
-
|
|
2630
|
-
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
2631
|
-
|
|
2632
|
-
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
2633
|
-
|
|
2634
|
-
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
2635
|
-
|
|
2636
|
-
#elif defined( CUSTOM_TONE_MAPPING )
|
|
2637
|
-
|
|
2638
|
-
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
2639
|
-
|
|
2640
|
-
#endif
|
|
2641
|
-
|
|
2642
|
-
// color space
|
|
2643
|
-
|
|
2644
|
-
#ifdef SRGB_TRANSFER
|
|
2645
|
-
|
|
2646
|
-
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
2647
|
-
|
|
2648
|
-
#endif
|
|
2649
|
-
|
|
2650
|
-
}`
|
|
2651
|
-
)
|
|
2652
|
-
};
|
|
2653
|
-
class Ks extends _s {
|
|
2654
|
-
constructor() {
|
|
2655
|
-
super();
|
|
2656
|
-
const e = Gs;
|
|
2657
|
-
this.uniforms = Gt.clone(e.uniforms), this.material = new Kt({
|
|
2658
|
-
name: e.name,
|
|
2659
|
-
uniforms: this.uniforms,
|
|
2660
|
-
vertexShader: e.vertexShader,
|
|
2661
|
-
fragmentShader: e.fragmentShader
|
|
2662
|
-
}), this.fsQuad ? this.fsQuad = new Fe(this.material) : this._fsQuad && (this._fsQuad = new Fe(this.material));
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
const Xs = (h) => {
|
|
2666
|
-
const e = new gs(
|
|
2667
|
-
new Xt({
|
|
2668
|
-
uniforms: {
|
|
2669
|
-
baseTexture: { value: null },
|
|
2670
|
-
bloomTexture: { value: h.renderTarget2.texture },
|
|
2671
|
-
bloomAlphaType: { value: 0 }
|
|
2672
|
-
},
|
|
2673
|
-
vertexShader: `
|
|
2674
|
-
varying vec2 vUv;
|
|
2675
|
-
void main() {
|
|
2676
|
-
vUv = uv;
|
|
2677
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
2678
|
-
}
|
|
2679
|
-
`,
|
|
2680
|
-
fragmentShader: `
|
|
2681
|
-
uniform sampler2D baseTexture;
|
|
2682
|
-
uniform sampler2D bloomTexture;
|
|
2683
|
-
uniform float bloomAlphaType;
|
|
2684
|
-
varying vec2 vUv;
|
|
2685
|
-
void main() {
|
|
2686
|
-
vec4 base_color = texture2D(baseTexture, vUv);
|
|
2687
|
-
vec4 bloom_color = texture2D(bloomTexture, vUv);
|
|
2688
|
-
if (bloomAlphaType == 0.0){
|
|
2689
|
-
float lum = 0.21 * bloom_color.r + 0.71 * bloom_color.g + 0.07 * bloom_color.b;
|
|
2690
|
-
gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
|
|
2691
|
-
}else{
|
|
2692
|
-
gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
`,
|
|
2696
|
-
defines: {}
|
|
2697
|
-
}),
|
|
2698
|
-
"baseTexture"
|
|
2699
|
-
);
|
|
2700
|
-
return e.needsSwap = !0, e;
|
|
2701
|
-
}, Le = 1, me = !1, $s = new $t({ color: "black" }), qs = new ct({
|
|
2702
|
-
color: "black",
|
|
2703
|
-
sizeAttenuation: !1
|
|
2704
|
-
}), Qs = new ct({
|
|
2705
|
-
color: "black",
|
|
2706
|
-
sizeAttenuation: !0
|
|
2707
|
-
}), Js = new dt({
|
|
2708
|
-
color: "black",
|
|
2709
|
-
sizeAttenuation: !0
|
|
2710
|
-
}), ei = new dt({
|
|
2711
|
-
color: "black",
|
|
2712
|
-
sizeAttenuation: !1
|
|
2713
|
-
}), ti = new ut({
|
|
2714
|
-
color: "black",
|
|
2715
|
-
sizeAttenuation: 0,
|
|
2716
|
-
lineWidth: 0
|
|
2717
|
-
}), si = {
|
|
2718
|
-
kernelRadius: 8,
|
|
2719
|
-
minDistance: 5e-3,
|
|
2720
|
-
maxDistance: 0.1
|
|
2721
|
-
}, ii = {
|
|
2722
|
-
threshold: 0,
|
|
2723
|
-
strength: 0.4,
|
|
2724
|
-
radius: 0.1,
|
|
2725
|
-
bloomAlphaType: 0
|
|
2726
|
-
}, ri = {
|
|
2727
|
-
multisampling: 4,
|
|
2728
|
-
premultiplieAlpha: !1
|
|
2729
|
-
};
|
|
2730
|
-
class oi {
|
|
2731
|
-
constructor(e) {
|
|
2732
|
-
this.bloomComposerActive = !1, this.active = !0, this.bloomSelection = /* @__PURE__ */ new Set(), this.bloomLayer = new qt(), this.bloomMaterials = {}, this.bloomVisible = {}, this.bloomComposerRenderIng = !1, this.pipViewportState = null, this.options = e;
|
|
2733
|
-
const {
|
|
2734
|
-
rendererController: t,
|
|
2735
|
-
sceneController: s,
|
|
2736
|
-
cameraController: i,
|
|
2737
|
-
composerParams: r
|
|
2738
|
-
} = e, { renderer: o } = t;
|
|
2739
|
-
this.renderer = o;
|
|
2740
|
-
const { multisampling: n } = r, { maxSamples: l } = o.capabilities, d = o.getDrawingBufferSize(new B()), _ = new Qt(
|
|
2741
|
-
d.width,
|
|
2742
|
-
d.height,
|
|
2743
|
-
{
|
|
2744
|
-
samples: Math.min(n, l),
|
|
2745
|
-
type: Jt
|
|
2746
|
-
}
|
|
2747
|
-
), p = new ke(o, _), E = this.getSize();
|
|
2748
|
-
p.setSize(E.width, E.height);
|
|
2749
|
-
const v = new us(
|
|
2750
|
-
s.scene,
|
|
2751
|
-
i.camera
|
|
2752
|
-
);
|
|
2753
|
-
p.addPass(v), this.scene = s.scene, this.camera = i.camera, this.finalComposer = p, this.renderPass = v, i.event.on("pageChange", (m) => {
|
|
2754
|
-
this.changeCamera(m);
|
|
2755
|
-
}), s.event.on("pageChange", (m) => {
|
|
2756
|
-
this.changeScene(m);
|
|
2757
|
-
});
|
|
2758
|
-
}
|
|
2759
|
-
changeCamera(e) {
|
|
2760
|
-
this.renderPass.camera = e, this.camera = e;
|
|
2761
|
-
}
|
|
2762
|
-
changeScene(e) {
|
|
2763
|
-
this.renderPass.scene = e, this.ssaoPass && (this.ssaoPass.scene = e), this.scene = e;
|
|
2764
|
-
}
|
|
2765
|
-
addOutputPass() {
|
|
2766
|
-
const { premultiplieAlpha: e } = this.options.composerParams, t = new Ks();
|
|
2767
|
-
this.outputPass = t, this.setPremultiplieAlpha(e), this.finalComposer.addPass(t);
|
|
2768
|
-
}
|
|
2769
|
-
setPremultiplieAlpha(e) {
|
|
2770
|
-
this.outputPass && (this.outputPass.uniforms.premultiplieAlpha.value = e ? 1 : 0);
|
|
2771
|
-
}
|
|
2772
|
-
addSSAOPass(e) {
|
|
2773
|
-
const { scene: t, camera: s, renderer: i } = this, r = i.getSize(new B()), o = r.width, n = r.height, l = new fs(t, s, o, n);
|
|
2774
|
-
l.kernelRadius = e.kernelRadius, l.minDistance = e.minDistance, l.maxDistance = e.maxDistance, this.ssaoPass = l, this.finalComposer.addPass(l);
|
|
2775
|
-
}
|
|
2776
|
-
addBloomPass(e) {
|
|
2777
|
-
const { renderer: t } = this, { threshold: s, strength: i, radius: r, bloomAlphaType: o } = e, n = new vs(
|
|
2778
|
-
new B(window.innerWidth, window.innerHeight),
|
|
2779
|
-
i,
|
|
2780
|
-
r,
|
|
2781
|
-
s
|
|
2782
|
-
);
|
|
2783
|
-
this.bloomPass = n;
|
|
2784
|
-
const l = new ke(t);
|
|
2785
|
-
l.renderToScreen = !1, l.addPass(this.renderPass), l.addPass(n), this.bloomComposer = l;
|
|
2786
|
-
const d = Xs(l);
|
|
2787
|
-
d.uniforms.bloomAlphaType.value = o, this.bloomComposer = l, this.finalComposer.addPass(d), this.mixPass = d, this.bloomLayer.set(Le);
|
|
2788
|
-
}
|
|
2789
|
-
setBloomSelection(e, t) {
|
|
2790
|
-
if (!this.bloomComposer) {
|
|
2791
|
-
console.warn("err:pencil.options.bloom");
|
|
2792
|
-
return;
|
|
2793
|
-
}
|
|
2794
|
-
e.traverse((s) => {
|
|
2795
|
-
const { object3d: i } = s;
|
|
2796
|
-
i && (t ? (this.bloomSelection.add(s), i.layers.enable(Le)) : (this.bloomSelection.delete(s), i.layers.disable(Le)));
|
|
2797
|
-
}), this.bloomSelection.size === 0 ? this.bloomComposerActive = !1 : this.bloomComposerActive = !0;
|
|
2798
|
-
}
|
|
2799
|
-
enable() {
|
|
2800
|
-
this.active || (this.active = !0);
|
|
2801
|
-
}
|
|
2802
|
-
disable() {
|
|
2803
|
-
this.active && (this.active = !1);
|
|
2804
|
-
}
|
|
2805
|
-
setSize(e, t) {
|
|
2806
|
-
var s;
|
|
2807
|
-
(s = this.bloomComposer) == null || s.setSize(e, t), this.finalComposer.setSize(e, t);
|
|
2808
|
-
}
|
|
2809
|
-
setPixelRatio(e) {
|
|
2810
|
-
var t;
|
|
2811
|
-
(t = this.bloomComposer) == null || t.setPixelRatio(e), this.finalComposer.setPixelRatio(e);
|
|
2812
|
-
}
|
|
2813
|
-
darkenNonBloomed() {
|
|
2814
|
-
const e = [], t = [];
|
|
2815
|
-
this.scene.children.forEach((s) => {
|
|
2816
|
-
s.isTransformControls || s.isTransformControlsRoot || s.type === "RectAreaLightHelper" ? e.push(s) : t.push(s);
|
|
2817
|
-
}), t.forEach((s) => {
|
|
2818
|
-
s.traverse((i) => {
|
|
2819
|
-
var l;
|
|
2820
|
-
const r = i, o = i, n = i;
|
|
2821
|
-
(l = r.material) != null && l.isShadowMaterial ? e.push(r) : r.material && this.bloomLayer.test(r.layers) === !1 && (this.bloomMaterials[r.uuid] = r.material, o.isSprite ? o.material.sizeAttenuation ? o.material = Js : o.material = ei : r.material instanceof ut ? r.material = ti : n.isPoints ? n.material.sizeAttenuation ? n.material = Qs : n.material = qs : r.material = $s);
|
|
2822
|
-
});
|
|
2823
|
-
}), e.forEach((s) => {
|
|
2824
|
-
this.bloomVisible[s.uuid] = s.visible, s.visible = !1;
|
|
2825
|
-
});
|
|
2826
|
-
}
|
|
2827
|
-
restoreNonBloomed() {
|
|
2828
|
-
this.scene.traverse((e) => {
|
|
2829
|
-
const t = e;
|
|
2830
|
-
this.bloomMaterials[t.uuid] ? (t.material = this.bloomMaterials[t.uuid], delete this.bloomMaterials[t.uuid]) : this.bloomVisible[t.uuid] !== void 0 && (t.visible = this.bloomVisible[t.uuid], delete this.bloomVisible[t.uuid]);
|
|
2831
|
-
});
|
|
2832
|
-
}
|
|
2833
|
-
finalComposerRender() {
|
|
2834
|
-
this.bloomComposerActive && this.bloomComposer ? (this.bloomComposerRenderIng = !0, this.mixPass.enabled = !0, this.darkenNonBloomed(), this.bloomComposer.render(), this.restoreNonBloomed(), this.bloomComposerRenderIng = !1) : this.mixPass && (this.mixPass.enabled = !1), this.finalComposer.render();
|
|
2835
|
-
}
|
|
2836
|
-
getSize() {
|
|
2837
|
-
return this.renderer.getSize(new B());
|
|
2838
|
-
}
|
|
2839
|
-
render() {
|
|
2840
|
-
if (!this.active) return;
|
|
2841
|
-
const { cameraController: e, rendererController: t, sceneController: s } = this.options;
|
|
2842
|
-
if (this.finalComposerRender(), this.pipViewportState) {
|
|
2843
|
-
e.setPageActive(31), e.setAspect(
|
|
2844
|
-
this.pipViewportState.width / this.pipViewportState.height
|
|
2845
|
-
), t.setViewport(te(U({}, this.pipViewportState), {
|
|
2846
|
-
scissor: !0,
|
|
2847
|
-
scissorTest: !0
|
|
2848
|
-
})), this.finalComposerRender(), e.setPageActive(s.activeIndex);
|
|
2849
|
-
const i = this.getSize();
|
|
2850
|
-
t.setViewport({
|
|
2851
|
-
x: 0,
|
|
2852
|
-
y: 0,
|
|
2853
|
-
width: i.width,
|
|
2854
|
-
height: i.height,
|
|
2855
|
-
scissor: !0,
|
|
2856
|
-
scissorTest: !1
|
|
2857
|
-
});
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
dispose() {
|
|
2861
|
-
var e;
|
|
2862
|
-
this.bloomMaterials = {}, this.bloomVisible = {}, this.bloomSelection.clear(), this.finalComposer.dispose(), (e = this.bloomComposer) == null || e.dispose();
|
|
2863
|
-
}
|
|
2864
|
-
}
|
|
2865
|
-
class it extends pt {
|
|
2866
|
-
constructor(e) {
|
|
2867
|
-
super(e), this.options = { type: "image" };
|
|
2868
|
-
}
|
|
2869
|
-
setOptions(e) {
|
|
2870
|
-
return this.options = e, this;
|
|
2871
|
-
}
|
|
2872
|
-
load(e, t, s, i) {
|
|
2873
|
-
let r, o;
|
|
2874
|
-
this.options.type === "image" ? (o = document.createElement("img"), r = new fe(o)) : this.options.type === "video" ? (o = document.createElement("video"), o.preload = "auto", o.autoplay = !1, o.loop = !1, o.muted = !0, o.setAttribute("webkit-playsinline", "webkit-playsinline"), o.setAttribute("playsinline", ""), r = new mt(o)) : r = new fe();
|
|
2875
|
-
const n = new Se(this.manager);
|
|
2876
|
-
return n.setResponseType("blob"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
2877
|
-
e,
|
|
2878
|
-
(l) => {
|
|
2879
|
-
let d = l;
|
|
2880
|
-
const _ = e.split(".").pop(), p = this.options.type === "image" ? `image/${_ || "png"}` : `video/${_ || "mp4"}`;
|
|
2881
|
-
d = d.slice(0, l.size, p);
|
|
2882
|
-
const E = () => {
|
|
2883
|
-
o.removeEventListener("load", v, !1), o.removeEventListener("error", m, !1);
|
|
2884
|
-
}, v = () => {
|
|
2885
|
-
E(), r.needsUpdate = !0, t && t(r);
|
|
2886
|
-
}, m = (f) => {
|
|
2887
|
-
E(), i && i(f), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
2888
|
-
};
|
|
2889
|
-
o.addEventListener("load", v, !1), o.addEventListener("error", m, !1);
|
|
2890
|
-
const u = window.URL.createObjectURL(d);
|
|
2891
|
-
o.src = u;
|
|
2892
|
-
},
|
|
2893
|
-
s,
|
|
2894
|
-
i
|
|
2895
|
-
), r;
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
class ni extends pt {
|
|
2899
|
-
constructor(e) {
|
|
2900
|
-
super(e);
|
|
2901
|
-
}
|
|
2902
|
-
load(e, t, s, i) {
|
|
2903
|
-
const r = new Se(this.manager);
|
|
2904
|
-
r.setResponseType("blob"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
|
|
2905
|
-
e,
|
|
2906
|
-
(o) => {
|
|
2907
|
-
const n = o, l = new DecompressionStream("gzip"), d = n.stream().pipeThrough(l);
|
|
2908
|
-
new Response(d).json().then((p) => {
|
|
2909
|
-
t == null || t(p);
|
|
2910
|
-
}).catch((p) => {
|
|
2911
|
-
i == null || i(p);
|
|
2912
|
-
});
|
|
2913
|
-
},
|
|
2914
|
-
s,
|
|
2915
|
-
i
|
|
2916
|
-
);
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
const ai = {
|
|
2920
|
-
images: ["png", "jpg", "jpeg", "ico", "webp", "avif"],
|
|
2921
|
-
media: ["mp4", "webm", "ogg"],
|
|
2922
|
-
gltf: ["gltf", "glb"],
|
|
2923
|
-
json: ["json", "geojson"],
|
|
2924
|
-
gzipJson: ["json.gzip"],
|
|
2925
|
-
exr: ["exr"],
|
|
2926
|
-
lottie: ["lottie.json"]
|
|
2927
|
-
};
|
|
2928
|
-
class li {
|
|
2929
|
-
constructor(e) {
|
|
2930
|
-
this.loadObj = [], this.delLoadArr = [], this.assets = /* @__PURE__ */ new Map(), this.event = new ve.EventEmitter(), this.options = U({
|
|
2931
|
-
simpleTexture4deleted: !1,
|
|
2932
|
-
prefix: ""
|
|
2933
|
-
}, e), this.loadingManager = new es(
|
|
2934
|
-
() => {
|
|
2935
|
-
},
|
|
2936
|
-
(t, s, i) => {
|
|
2937
|
-
this.emit("progress", s, i);
|
|
2938
|
-
},
|
|
2939
|
-
(t) => {
|
|
2940
|
-
console.warn(`Failed to load ${t}`);
|
|
2941
|
-
}
|
|
2942
|
-
);
|
|
2943
|
-
}
|
|
2944
|
-
emit(e, ...t) {
|
|
2945
|
-
this.event.emit(e, ...t);
|
|
2946
|
-
}
|
|
2947
|
-
on(e, t) {
|
|
2948
|
-
this.event.on(e, t);
|
|
2949
|
-
}
|
|
2950
|
-
getAsset(e) {
|
|
2951
|
-
const t = this.getAssetType(e);
|
|
2952
|
-
if (!t)
|
|
2953
|
-
return;
|
|
2954
|
-
const s = this.assets.get(e);
|
|
2955
|
-
if (!s) {
|
|
2956
|
-
if ((t === "images" || t === "media" || t === "exr") && this.options.simpleTexture4deleted && this.delLoadArr.includes(e))
|
|
2957
|
-
return new fe();
|
|
2958
|
-
console.warn(`Asset ${e} not found`);
|
|
2959
|
-
}
|
|
2960
|
-
return s;
|
|
2961
|
-
}
|
|
2962
|
-
getAssetType(e) {
|
|
2963
|
-
var s;
|
|
2964
|
-
const t = (s = e.split(".").pop()) == null ? void 0 : s.toLowerCase();
|
|
2965
|
-
if (t) {
|
|
2966
|
-
if (e.endsWith("lottie.json"))
|
|
2967
|
-
return "lottie";
|
|
2968
|
-
if (e.endsWith("json.gzip"))
|
|
2969
|
-
return "gzipJson";
|
|
2970
|
-
} else return;
|
|
2971
|
-
for (const [i, r] of Object.entries(ai))
|
|
2972
|
-
if (r.includes(t))
|
|
2973
|
-
return i;
|
|
2974
|
-
}
|
|
2975
|
-
getLoader(e, t) {
|
|
2976
|
-
if (e === "images")
|
|
2977
|
-
return this.textureLoader || (this.textureLoader = new it(this.loadingManager), this.options.prefix && this.textureLoader.setPath(this.options.prefix)), this.textureLoader;
|
|
2978
|
-
if (e === "media")
|
|
2979
|
-
return this.videoTextureLoader || (this.videoTextureLoader = new it(this.loadingManager), this.videoTextureLoader.setOptions({ type: "video" }), this.options.prefix && this.videoTextureLoader.setPath(this.options.prefix)), this.videoTextureLoader;
|
|
2980
|
-
if (e === "gltf" && (t != null && t.dracoPath))
|
|
2981
|
-
return this.dracoGltfLoader || (this.dracoGltfLoader = new Ne(this.loadingManager), this.dracoLoader = new ys(), this.dracoLoader.setDecoderPath(t == null ? void 0 : t.dracoPath), this.dracoGltfLoader.setDRACOLoader(this.dracoLoader), this.options.prefix && this.dracoGltfLoader.setPath(this.options.prefix)), this.dracoGltfLoader;
|
|
2982
|
-
if (e === "gltf")
|
|
2983
|
-
return this.gltfLoader || (this.gltfLoader = new Ne(this.loadingManager), this.options.prefix && this.gltfLoader.setPath(this.options.prefix)), this.gltfLoader;
|
|
2984
|
-
if (e === "lottie")
|
|
2985
|
-
return this.lottieLoader || (this.lottieLoader = new Es(this.loadingManager), this.options.prefix && this.lottieLoader.setPath(this.options.prefix)), this.lottieLoader;
|
|
2986
|
-
if (e === "gzipJson")
|
|
2987
|
-
return this.gzipJsonLoader || (this.gzipJsonLoader = new ni(this.loadingManager), this.options.prefix && this.gzipJsonLoader.setPath(this.options.prefix)), this.gzipJsonLoader;
|
|
2988
|
-
if (e === "json")
|
|
2989
|
-
return this.jsonLoader || (this.jsonLoader = new Se(this.loadingManager), this.jsonLoader.setResponseType("json"), this.options.prefix && this.jsonLoader.setPath(this.options.prefix)), this.jsonLoader;
|
|
2990
|
-
if (e === "exr")
|
|
2991
|
-
return this.exrLoader || (this.exrLoader = new Cs(this.loadingManager), this.options.prefix && this.exrLoader.setPath(this.options.prefix)), this.exrLoader;
|
|
2992
|
-
}
|
|
2993
|
-
add(e, t) {
|
|
2994
|
-
typeof e == "string" && (e = [e]), e.forEach((s) => {
|
|
2995
|
-
const i = U({
|
|
2996
|
-
src: s
|
|
2997
|
-
}, t);
|
|
2998
|
-
this.loadObj.push(i);
|
|
2999
|
-
});
|
|
3000
|
-
}
|
|
3001
|
-
getSrcByAsset(e, t = this.assets) {
|
|
3002
|
-
let s;
|
|
3003
|
-
return t.forEach((i, r) => {
|
|
3004
|
-
i === e && (s = r);
|
|
3005
|
-
}), s;
|
|
3006
|
-
}
|
|
3007
|
-
get textureAssets() {
|
|
3008
|
-
const e = /* @__PURE__ */ new Map();
|
|
3009
|
-
return this.assets.forEach((t, s) => {
|
|
3010
|
-
(t instanceof fe || t instanceof ts || t instanceof mt) && e.set(s, t);
|
|
3011
|
-
}), e;
|
|
3012
|
-
}
|
|
3013
|
-
loadAll() {
|
|
3014
|
-
return se(this, null, function* () {
|
|
3015
|
-
const e = this.loadObj.filter((t) => !this.delLoadArr.includes(t.src));
|
|
3016
|
-
return yield Promise.all(
|
|
3017
|
-
e.map((t) => this.load(t.src, t))
|
|
3018
|
-
);
|
|
3019
|
-
});
|
|
3020
|
-
}
|
|
3021
|
-
load(e, t) {
|
|
3022
|
-
return se(this, null, function* () {
|
|
3023
|
-
var n, l;
|
|
3024
|
-
const s = (n = t == null ? void 0 : t.type) != null ? n : this.getAssetType(e);
|
|
3025
|
-
if (!s)
|
|
3026
|
-
return;
|
|
3027
|
-
const i = (t == null ? void 0 : t.cache) !== !1, r = Os();
|
|
3028
|
-
if (i) {
|
|
3029
|
-
if (this.assets.has(e))
|
|
3030
|
-
return this.assets.get(e);
|
|
3031
|
-
this.assets.set(e, r.promise);
|
|
3032
|
-
}
|
|
3033
|
-
const o = this.getLoader(s, t);
|
|
3034
|
-
try {
|
|
3035
|
-
const d = yield o.loadAsync(e);
|
|
3036
|
-
if (this.assets.set(e, d), r.resolve(d), s === "images" || s === "media" || s === "exr" || s === "lottie") {
|
|
3037
|
-
(t == null ? void 0 : t.colorCorrection) !== !1 && ls({ texture: d });
|
|
3038
|
-
const _ = (l = t == null ? void 0 : t.anisotropy) != null ? l : this.options.anisotropy;
|
|
3039
|
-
d.anisotropy = _;
|
|
3040
|
-
}
|
|
3041
|
-
return d;
|
|
3042
|
-
} catch (d) {
|
|
3043
|
-
r.reject(`Failed to load ${e}`);
|
|
3044
|
-
return;
|
|
3045
|
-
}
|
|
3046
|
-
});
|
|
3047
|
-
}
|
|
3048
|
-
getUnusedAssets() {
|
|
3049
|
-
const { scene: e } = this.options;
|
|
3050
|
-
if (!e)
|
|
3051
|
-
return [...this.delLoadArr];
|
|
3052
|
-
const t = /* @__PURE__ */ new Set(), s = this.textureAssets;
|
|
3053
|
-
e.traverse((r) => {
|
|
3054
|
-
const o = r;
|
|
3055
|
-
o.material && (Array.isArray(o.material) ? o.material : [o.material]).forEach((l) => {
|
|
3056
|
-
[
|
|
3057
|
-
l.map,
|
|
3058
|
-
l.emissiveMap,
|
|
3059
|
-
l.normalMap,
|
|
3060
|
-
l.roughnessMap,
|
|
3061
|
-
l.metalnessMap,
|
|
3062
|
-
l.aoMap
|
|
3063
|
-
].forEach((d) => {
|
|
3064
|
-
if (d) {
|
|
3065
|
-
const _ = this.getSrcByAsset(d, s);
|
|
3066
|
-
_ && t.add(_);
|
|
3067
|
-
}
|
|
3068
|
-
});
|
|
3069
|
-
});
|
|
3070
|
-
});
|
|
3071
|
-
const i = new Set(this.textureAssets.keys());
|
|
3072
|
-
return t.forEach((r) => {
|
|
3073
|
-
i.delete(r);
|
|
3074
|
-
}), [...i, ...this.delLoadArr];
|
|
3075
|
-
}
|
|
3076
|
-
dispose() {
|
|
3077
|
-
var e;
|
|
3078
|
-
this.assets.clear(), (e = this.dracoLoader) == null || e.dispose(), this.event.removeAllListeners(), this.delLoadArr.length = 0, this.loadObj.length = 0;
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
const hi = {
|
|
3082
|
-
prefix: ""
|
|
3083
|
-
};
|
|
3084
|
-
class ci extends ee {
|
|
3085
|
-
get loader() {
|
|
3086
|
-
return this.controller;
|
|
3087
2631
|
}
|
|
3088
|
-
|
|
3089
|
-
|
|
2632
|
+
addViewHelper() {
|
|
2633
|
+
const { cameraController: e, container: t } = this.options, s = new ps(e.camera, t);
|
|
2634
|
+
t.addEventListener("pointerdown", (i) => {
|
|
2635
|
+
i.preventDefault(), s.handleClick(i);
|
|
2636
|
+
}), this.viewHelper = s;
|
|
3090
2637
|
}
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
2638
|
+
remove(e) {
|
|
2639
|
+
var i;
|
|
2640
|
+
const t = e.uuid, { sceneController: s } = this.options;
|
|
2641
|
+
if (this.helpers[t] !== void 0) {
|
|
2642
|
+
const r = this.helpers[t];
|
|
2643
|
+
s.scene.remove(r), delete this.helpers[t], (i = r.dispose) == null || i.call(r);
|
|
2644
|
+
}
|
|
3096
2645
|
}
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
2646
|
+
removeAll() {
|
|
2647
|
+
Object.keys(this.helpers).forEach((e) => {
|
|
2648
|
+
this.remove({
|
|
2649
|
+
uuid: e
|
|
2650
|
+
});
|
|
2651
|
+
}), this.helpers = {};
|
|
2652
|
+
}
|
|
2653
|
+
removeAllExcludeScene() {
|
|
2654
|
+
Object.keys(this.helpers).forEach((e) => {
|
|
2655
|
+
this.helpers[e] instanceof De || this.remove({
|
|
2656
|
+
uuid: e
|
|
2657
|
+
});
|
|
3100
2658
|
});
|
|
3101
2659
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
2660
|
+
update(e, t, s) {
|
|
2661
|
+
var r, o;
|
|
2662
|
+
const { cameraController: i } = this.options;
|
|
2663
|
+
Object.values(this.helpers).forEach((n) => {
|
|
2664
|
+
if (n.update && n.update(), n instanceof Ue) {
|
|
2665
|
+
const a = n.material, { object: c } = a.userData;
|
|
2666
|
+
c && n.box.setFromObject(c, !0);
|
|
2667
|
+
}
|
|
2668
|
+
}), ((r = this.viewHelper) == null ? void 0 : r.animating) === !0 && (this.viewHelper.update(e), (o = t.cameraControls) == null || o.setPosition(
|
|
2669
|
+
...i.camera.position.toArray()
|
|
2670
|
+
), this.viewHelper.center.copy(s));
|
|
2671
|
+
}
|
|
2672
|
+
renderViewHelper(e) {
|
|
2673
|
+
if (!this.viewHelper)
|
|
2674
|
+
return;
|
|
2675
|
+
const t = e.autoClear;
|
|
2676
|
+
e.autoClear = !1, this.viewHelper.render(e), e.autoClear = t;
|
|
3106
2677
|
}
|
|
3107
|
-
|
|
2678
|
+
dispose() {
|
|
3108
2679
|
var e;
|
|
3109
|
-
this.
|
|
2680
|
+
this.helpers = {}, (e = this.viewHelper) == null || e.dispose();
|
|
3110
2681
|
}
|
|
3111
2682
|
}
|
|
3112
|
-
function
|
|
2683
|
+
function it(h) {
|
|
3113
2684
|
let e = !1, t = [];
|
|
3114
2685
|
return function(...s) {
|
|
3115
2686
|
t = s, e || (e = !0, requestAnimationFrame(() => {
|
|
@@ -3117,10 +2688,10 @@ function rt(h) {
|
|
|
3117
2688
|
}));
|
|
3118
2689
|
};
|
|
3119
2690
|
}
|
|
3120
|
-
class
|
|
2691
|
+
class Qs {
|
|
3121
2692
|
constructor(e) {
|
|
3122
2693
|
var t;
|
|
3123
|
-
this.enabled = !0, this.pickFunctionsMap = /* @__PURE__ */ new Map(), this.pickNodeFunctionsMap = /* @__PURE__ */ new Map(), this.pickFunctionsMapIndex = -1, this.pickNodeFunctionsMapIndex = -1, this.activeObjects = /* @__PURE__ */ new Set(), this.prevActiveObjects = /* @__PURE__ */ new Set(), this.objCallbackMap = /* @__PURE__ */ new Map(), this.pickListener = {
|
|
2694
|
+
this.enabled = !0, this.pickFunctionsMap = /* @__PURE__ */ new Map(), this.pickNodeFunctionsMap = /* @__PURE__ */ new Map(), this.pickFunctionsMapIndex = -1, this.pickNodeFunctionsMapIndex = -1, this.activeObjects = /* @__PURE__ */ new Set(), this.activeObject = null, this.prevActiveObjects = /* @__PURE__ */ new Set(), this.objCallbackMap = /* @__PURE__ */ new Map(), this.pickListener = {
|
|
3124
2695
|
move: !1,
|
|
3125
2696
|
down: !1
|
|
3126
2697
|
}, this.pencil = e, this.domElement = ((t = e.options.controls) == null ? void 0 : t.domElement) || e.options.container;
|
|
@@ -3132,53 +2703,43 @@ class pi {
|
|
|
3132
2703
|
return;
|
|
3133
2704
|
r.preventDefault();
|
|
3134
2705
|
const o = e === "move" ? t : s, n = [];
|
|
3135
|
-
if (this.pickFunctionsMap.forEach((
|
|
3136
|
-
o.has(
|
|
3137
|
-
objArr:
|
|
2706
|
+
if (this.pickFunctionsMap.forEach((p) => {
|
|
2707
|
+
o.has(p.type) && n.push(te(U({}, p), {
|
|
2708
|
+
objArr: p.objArr instanceof Function ? p.objArr() : p.objArr
|
|
3138
2709
|
}));
|
|
3139
2710
|
}), n.length === 0) return;
|
|
3140
|
-
this.activeObjects.clear(), this.objCallbackMap.clear();
|
|
3141
|
-
const
|
|
3142
|
-
for (const
|
|
3143
|
-
for (const
|
|
3144
|
-
if (!
|
|
3145
|
-
|
|
3146
|
-
const
|
|
3147
|
-
|
|
2711
|
+
this.activeObjects.clear(), this.objCallbackMap.clear(), this.activeObject = null;
|
|
2712
|
+
const a = this.objCallbackMap;
|
|
2713
|
+
for (const p of n)
|
|
2714
|
+
for (const f of p.objArr) {
|
|
2715
|
+
if (!f.object3d || !f.visibleWithAncestors) continue;
|
|
2716
|
+
a.has(f) || a.set(f, /* @__PURE__ */ new Map());
|
|
2717
|
+
const g = a.get(f);
|
|
2718
|
+
g.has(p.type) || g.set(p.type, []), g.get(p.type).push(p.cb);
|
|
3148
2719
|
}
|
|
3149
|
-
if (
|
|
3150
|
-
const
|
|
3151
|
-
|
|
3152
|
-
m.isGroup && m.traverse((u) => {
|
|
3153
|
-
u instanceof ss && _.push(u);
|
|
3154
|
-
});
|
|
3155
|
-
});
|
|
3156
|
-
const p = (v = this.pencil.pick(r, _, !1)) == null ? void 0 : v.intersects;
|
|
3157
|
-
if (!p || p.length === 0)
|
|
2720
|
+
if (a.size === 0) return;
|
|
2721
|
+
const c = [...a.keys()].map((p) => p.object3d), u = (v = this.pencil.pick(r, c, !0)) == null ? void 0 : v.intersects;
|
|
2722
|
+
if (!u || u.length === 0)
|
|
3158
2723
|
e === "down" ? this.handleDownOutside(r) : e === "move" && this.handleLeaveEvents(r);
|
|
3159
2724
|
else {
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
this.processIntersection(m, r, e);
|
|
2725
|
+
const p = u[0];
|
|
2726
|
+
this.processIntersection(p, r, e);
|
|
3163
2727
|
}
|
|
3164
|
-
const
|
|
3165
|
-
this.prevActiveObjects = this.activeObjects, this.activeObjects =
|
|
2728
|
+
const m = this.prevActiveObjects;
|
|
2729
|
+
this.prevActiveObjects = this.activeObjects, this.activeObjects = m, this.activeObjects.clear();
|
|
3166
2730
|
};
|
|
3167
2731
|
this.domElement.addEventListener(
|
|
3168
2732
|
`pointer${e}`,
|
|
3169
|
-
|
|
2733
|
+
it(i),
|
|
3170
2734
|
{ passive: !1 }
|
|
3171
2735
|
);
|
|
3172
2736
|
}
|
|
3173
|
-
sortIntersections(e) {
|
|
3174
|
-
e.sort((t, s) => t.distance === s.distance ? t.object.getObjectById(s.object.id) ? 1 : s.object.getObjectById(t.object.id) ? -1 : 0 : t.distance - s.distance);
|
|
3175
|
-
}
|
|
3176
2737
|
processIntersection(e, t, s) {
|
|
3177
2738
|
const i = this.objCallbackMap, r = e.index || -1;
|
|
3178
2739
|
let o = e.object;
|
|
3179
2740
|
for (; o; ) {
|
|
3180
2741
|
const n = this.pencil.lead.objMap.get(o);
|
|
3181
|
-
n && i.has(n) && this.activeObjects.add(n), o = o.parent;
|
|
2742
|
+
n && n.visible && (this.activeObject || (this.activeObject = n), i.has(n) && this.activeObjects.add(n)), o = o.parent;
|
|
3182
2743
|
}
|
|
3183
2744
|
s === "move" ? this.handleLeaveEvents(t) : s === "down" && this.handleDownOutside(t), this.processObjectHierarchy(t, s, r);
|
|
3184
2745
|
}
|
|
@@ -3190,53 +2751,57 @@ class pi {
|
|
|
3190
2751
|
};
|
|
3191
2752
|
for (const n of this.activeObjects) {
|
|
3192
2753
|
if (r) break;
|
|
3193
|
-
const
|
|
3194
|
-
if (
|
|
2754
|
+
const a = i.get(n);
|
|
2755
|
+
if (a)
|
|
3195
2756
|
if (t === "move") {
|
|
3196
|
-
const
|
|
3197
|
-
if (
|
|
3198
|
-
for (const
|
|
3199
|
-
|
|
2757
|
+
const c = a.get("enter");
|
|
2758
|
+
if (c && !this.prevActiveObjects.has(n))
|
|
2759
|
+
for (const m of c)
|
|
2760
|
+
m({
|
|
3200
2761
|
baseObject: n,
|
|
2762
|
+
realBaseObject: this.activeObject,
|
|
3201
2763
|
mouseEvent: e,
|
|
3202
2764
|
sp: o,
|
|
3203
2765
|
intersectionIndex: s
|
|
3204
2766
|
});
|
|
3205
|
-
const
|
|
3206
|
-
if (
|
|
3207
|
-
for (const
|
|
3208
|
-
|
|
2767
|
+
const u = a.get("move");
|
|
2768
|
+
if (u)
|
|
2769
|
+
for (const m of u)
|
|
2770
|
+
m({
|
|
3209
2771
|
baseObject: n,
|
|
2772
|
+
realBaseObject: this.activeObject,
|
|
3210
2773
|
mouseEvent: e,
|
|
3211
2774
|
sp: o,
|
|
3212
2775
|
intersectionIndex: s
|
|
3213
2776
|
});
|
|
3214
2777
|
} else {
|
|
3215
|
-
const
|
|
3216
|
-
if (
|
|
3217
|
-
for (const
|
|
3218
|
-
|
|
2778
|
+
const c = a.get("down");
|
|
2779
|
+
if (c)
|
|
2780
|
+
for (const m of c)
|
|
2781
|
+
m({
|
|
3219
2782
|
baseObject: n,
|
|
2783
|
+
realBaseObject: this.activeObject,
|
|
3220
2784
|
mouseEvent: e,
|
|
3221
2785
|
sp: o,
|
|
3222
2786
|
intersectionIndex: s
|
|
3223
2787
|
});
|
|
3224
|
-
const
|
|
3225
|
-
if (
|
|
3226
|
-
const
|
|
3227
|
-
|
|
3228
|
-
const
|
|
3229
|
-
if (!r && Math.abs(
|
|
3230
|
-
for (const
|
|
3231
|
-
|
|
2788
|
+
const u = a.get("click");
|
|
2789
|
+
if (u) {
|
|
2790
|
+
const m = (v) => {
|
|
2791
|
+
v.preventDefault();
|
|
2792
|
+
const p = 5;
|
|
2793
|
+
if (!r && Math.abs(v.clientX - e.clientX) <= p && Math.abs(v.clientY - e.clientY) <= p)
|
|
2794
|
+
for (const f of u)
|
|
2795
|
+
f({
|
|
3232
2796
|
baseObject: n,
|
|
2797
|
+
realBaseObject: this.activeObject,
|
|
3233
2798
|
mouseEvent: e,
|
|
3234
2799
|
sp: o,
|
|
3235
2800
|
intersectionIndex: s
|
|
3236
2801
|
});
|
|
3237
|
-
this.domElement.removeEventListener("pointerup",
|
|
2802
|
+
this.domElement.removeEventListener("pointerup", m);
|
|
3238
2803
|
};
|
|
3239
|
-
this.domElement.addEventListener("pointerup",
|
|
2804
|
+
this.domElement.addEventListener("pointerup", m);
|
|
3240
2805
|
}
|
|
3241
2806
|
}
|
|
3242
2807
|
}
|
|
@@ -3282,15 +2847,15 @@ class pi {
|
|
|
3282
2847
|
this.pickNodeFunctionsMapIndex += 1;
|
|
3283
2848
|
const i = this.pickNodeFunctionsMapIndex, r = e instanceof Function ? e() : e, o = [];
|
|
3284
2849
|
for (const n of r) {
|
|
3285
|
-
const
|
|
3286
|
-
|
|
3287
|
-
const
|
|
3288
|
-
this.enabled && (
|
|
3289
|
-
baseObject:
|
|
3290
|
-
mouseEvent:
|
|
2850
|
+
const a = n;
|
|
2851
|
+
a.element.style.pointerEvents = "auto";
|
|
2852
|
+
const c = (m) => {
|
|
2853
|
+
this.enabled && (m.preventDefault(), s({
|
|
2854
|
+
baseObject: a,
|
|
2855
|
+
mouseEvent: m
|
|
3291
2856
|
}));
|
|
3292
|
-
},
|
|
3293
|
-
|
|
2857
|
+
}, u = `pointer${t}`;
|
|
2858
|
+
a.element.addEventListener(u, it(c), !1), o.push({ arr: a, type: u, listener: c });
|
|
3294
2859
|
}
|
|
3295
2860
|
return this.pickNodeFunctionsMap.set(i, o), i;
|
|
3296
2861
|
}
|
|
@@ -3310,15 +2875,49 @@ class pi {
|
|
|
3310
2875
|
this.pickFunctionsMap.clear(), this.pickNodeFunctionsMap.clear(), this.activeObjects.clear(), this.prevActiveObjects.clear(), this.objCallbackMap.clear();
|
|
3311
2876
|
}
|
|
3312
2877
|
}
|
|
3313
|
-
class
|
|
2878
|
+
class Js extends Qs {
|
|
3314
2879
|
constructor(e, t) {
|
|
3315
|
-
super(e), this.objMap = /* @__PURE__ */ new Map(), this.objects = /* @__PURE__ */ new Map(), this.objectsPm = /* @__PURE__ */ new Map(), this.objectNamesToFactories = /* @__PURE__ */ new Map(), this.scene = new
|
|
3316
|
-
|
|
3317
|
-
|
|
2880
|
+
super(e), this.objMap = /* @__PURE__ */ new Map(), this.objects = /* @__PURE__ */ new Map(), this.objectsPm = /* @__PURE__ */ new Map(), this.objectWrapChindIdMap = /* @__PURE__ */ new Map(), this.objectNamesToFactories = /* @__PURE__ */ new Map(), this.mList = t.mList, this.scene = this.createBaseObject(t.scene || new dt(), {
|
|
2881
|
+
key: "@Scene",
|
|
2882
|
+
name: "场景",
|
|
2883
|
+
mList: !1
|
|
2884
|
+
}), this.group = this.createBaseObject(new ze(), {
|
|
2885
|
+
key: "@Group",
|
|
2886
|
+
name: "物体组",
|
|
2887
|
+
target: this.scene,
|
|
2888
|
+
mList: !1
|
|
2889
|
+
}), this.prefabGroup = this.createBaseObject(new ze(), {
|
|
2890
|
+
key: "@PrefabGroup",
|
|
2891
|
+
name: "预制组",
|
|
2892
|
+
target: this.scene,
|
|
2893
|
+
mList: !1
|
|
2894
|
+
});
|
|
3318
2895
|
}
|
|
3319
2896
|
get objectsPromise() {
|
|
3320
2897
|
return this.objectsPm.values();
|
|
3321
2898
|
}
|
|
2899
|
+
createBaseObject(e, t = {}) {
|
|
2900
|
+
const s = U({
|
|
2901
|
+
mList: !0
|
|
2902
|
+
}, t), i = new ns();
|
|
2903
|
+
if (i.object3d = e, i.pencil = this.pencil, i.lead = this, i.mList = this.mList, s.key)
|
|
2904
|
+
i.key = s.key;
|
|
2905
|
+
else if (s.target) {
|
|
2906
|
+
const r = s.target.key;
|
|
2907
|
+
if (r === "@Scene" && e instanceof Jt)
|
|
2908
|
+
i.key = "@Camera";
|
|
2909
|
+
else {
|
|
2910
|
+
const o = this.objectWrapChindIdMap.get(s.target) ? this.objectWrapChindIdMap.get(s.target) + 1 : 0;
|
|
2911
|
+
this.objectWrapChindIdMap.set(s.target, o), i.key = `${r}__c__${o}`;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
return s.name && (e.name = s.name), s.target && !s.target.object3d.getObjectById(e.id) && s.target.object3d.add(e), this.objects.set(i.key, i), this.objMap.set(i.object3d, i), s.mList && (this.mList.proxyBaseObject(i), this.mList.addBaseObjectMap(i)), e.children && e.children.forEach((r) => {
|
|
2915
|
+
this.createBaseObject(r, {
|
|
2916
|
+
target: i,
|
|
2917
|
+
mList: s.mList
|
|
2918
|
+
});
|
|
2919
|
+
}), i;
|
|
2920
|
+
}
|
|
3322
2921
|
init(e) {
|
|
3323
2922
|
return Object.keys(e).forEach((t) => {
|
|
3324
2923
|
const s = class {
|
|
@@ -3343,23 +2942,23 @@ class mi extends pi {
|
|
|
3343
2942
|
}
|
|
3344
2943
|
draw(e, t, s) {
|
|
3345
2944
|
return se(this, null, function* () {
|
|
3346
|
-
var r, o, n,
|
|
2945
|
+
var r, o, n, a;
|
|
3347
2946
|
const i = this.objectNamesToFactories.get(e);
|
|
3348
2947
|
if (i) {
|
|
3349
2948
|
t || (t = {}), t.target === void 0 && (t.target = s);
|
|
3350
|
-
const
|
|
3351
|
-
let
|
|
3352
|
-
return
|
|
3353
|
-
} :
|
|
3354
|
-
|
|
3355
|
-
}),
|
|
3356
|
-
|
|
2949
|
+
const c = t.target, u = (r = t.onTop) != null ? r : 0, m = (o = t.prefab) != null ? o : !1, v = (n = t.create) != null ? n : !0, p = new i().create(t);
|
|
2950
|
+
let f;
|
|
2951
|
+
return c === null ? f = null : typeof c == "string" ? f = this.objects.get(c) : (a = c == null ? void 0 : c.objectType) != null && a.startsWith("BaseObject") || c ? f = c : m ? f = this.prefabGroup : f = this.group, v === !1 ? p.create = () => {
|
|
2952
|
+
} : v !== !0 && (p.create = () => {
|
|
2953
|
+
v(p);
|
|
2954
|
+
}), p.pencil = this.pencil, p.lead = this, p.mList = this.mList, p.prefab = m, p.objectType = `BaseObject#${e}`, p.objectOptions = t, this.setBaseObjectKey(
|
|
2955
|
+
p,
|
|
3357
2956
|
t.key ? `$t:#${t.key}` : "$t:",
|
|
3358
|
-
|
|
2957
|
+
f == null ? void 0 : f.key
|
|
3359
2958
|
), this.objectsPm.set(
|
|
3360
|
-
|
|
3361
|
-
this.addBaseObject(
|
|
3362
|
-
), yield this.objectsPm.get(
|
|
2959
|
+
p,
|
|
2960
|
+
this.addBaseObject(p, f, u)
|
|
2961
|
+
), yield this.objectsPm.get(p), this.objectsPm.delete(p), p;
|
|
3363
2962
|
}
|
|
3364
2963
|
throw new Error(`Unrecognized:${e}`);
|
|
3365
2964
|
});
|
|
@@ -3371,104 +2970,392 @@ class mi extends pi {
|
|
|
3371
2970
|
const [, n] = s.split("#");
|
|
3372
2971
|
o = o.replace("$p:", n);
|
|
3373
2972
|
}
|
|
3374
|
-
return this.objects.has(o) && (o.includes("#") ? o += `-${
|
|
2973
|
+
return this.objects.has(o) && (o.includes("#") ? o += `-${Ne()}` : o += `#${Ne()}`), e.key = o, this.objects.set(o, e), o;
|
|
3375
2974
|
}
|
|
3376
2975
|
updateBaseObjectKey(e, t) {
|
|
3377
2976
|
var o;
|
|
3378
2977
|
let s;
|
|
3379
|
-
for (const [n,
|
|
3380
|
-
if (
|
|
2978
|
+
for (const [n, a] of this.objects.entries())
|
|
2979
|
+
if (a === e) {
|
|
3381
2980
|
s = n;
|
|
3382
2981
|
break;
|
|
3383
2982
|
}
|
|
3384
|
-
const i = (o = e.parent) == null ? void 0 : o.key, r = this.setBaseObjectKey(e, t, i);
|
|
3385
|
-
return s && this.objects.delete(s), this.pencil.event.emit("updateKey", e, r, s),
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
2983
|
+
const i = (o = e.parent) == null ? void 0 : o.key, r = this.setBaseObjectKey(e, t, i);
|
|
2984
|
+
return s && this.objects.delete(s), this.pencil.event.emit("lead.updateKey", { baseObject: e, key: r, oldKey: s }), e.children.forEach((n, a) => {
|
|
2985
|
+
n.key.includes("__c__") && this.updateBaseObjectKey(n, `${r}__c__${a}`);
|
|
2986
|
+
}), r;
|
|
2987
|
+
}
|
|
2988
|
+
addBaseObject(e, t, s) {
|
|
2989
|
+
return se(this, null, function* () {
|
|
2990
|
+
if (yield e.create(), e.object3d) {
|
|
2991
|
+
const i = e.object3d;
|
|
2992
|
+
i.material && Array.isArray(i.material) && (i.material = i.material.slice()), this.mList.proxyBaseObject(e), this.mList.addBaseObjectMap(e), s && e.setTop(s), t !== null && t.object3d.add(e.object3d), this.objMap.set(e.object3d, e), i.children.forEach((r) => {
|
|
2993
|
+
this.objMap.get(r) || this.createBaseObject(r, {
|
|
2994
|
+
target: e
|
|
2995
|
+
});
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
e.render(), this.pencil.event.emit("lead.draw", { baseObject: e });
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
erase(...e) {
|
|
3002
|
+
this.handleErase(!0, ...e);
|
|
3003
|
+
}
|
|
3004
|
+
eraseWithoutMaterial(...e) {
|
|
3005
|
+
this.handleErase(!1, ...e);
|
|
3006
|
+
}
|
|
3007
|
+
handleErase(e, ...t) {
|
|
3008
|
+
[...t].forEach((s) => {
|
|
3009
|
+
const i = [];
|
|
3010
|
+
if (typeof s == "string") {
|
|
3011
|
+
const [r, o] = s.split("#");
|
|
3012
|
+
i.push(...this.getAllObject(r, { key: o }));
|
|
3013
|
+
} else
|
|
3014
|
+
i.push(s);
|
|
3015
|
+
i.forEach((r) => {
|
|
3016
|
+
r.disposeMaterialIfNotUsed = e, r.dispose();
|
|
3017
|
+
});
|
|
3018
|
+
}), this.pencil.event.emit("lead.erase");
|
|
3019
|
+
}
|
|
3020
|
+
update(e, t) {
|
|
3021
|
+
this.objects.forEach((s) => {
|
|
3022
|
+
s.update(e, t);
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
setSize(e, t) {
|
|
3026
|
+
this.objects.forEach((s) => {
|
|
3027
|
+
s.resize(e, t);
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
eraseAll() {
|
|
3031
|
+
this.group && (this.objects.forEach((e) => {
|
|
3032
|
+
e.key.startsWith("Node") && this.erase(e);
|
|
3033
|
+
}), this.erase(this.group));
|
|
3034
|
+
}
|
|
3035
|
+
dispose() {
|
|
3036
|
+
super.dispose(), this.scene.erase(), this.objects.forEach((e) => {
|
|
3037
|
+
e.erase();
|
|
3038
|
+
}), this.objects.clear(), this.objectsPm.clear(), this.objMap.clear(), this.objectWrapChindIdMap.clear(), this.objectNamesToFactories.clear();
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
class ei extends ee {
|
|
3042
|
+
get lead() {
|
|
3043
|
+
return this.controller;
|
|
3044
|
+
}
|
|
3045
|
+
constructor(e) {
|
|
3046
|
+
super(), this.options = e;
|
|
3047
|
+
}
|
|
3048
|
+
addLead(e, t, s) {
|
|
3049
|
+
const { pencil: i } = this.options, r = new Js(i, {
|
|
3050
|
+
scene: e,
|
|
3051
|
+
mList: t
|
|
3052
|
+
});
|
|
3053
|
+
return this.addController(r, s);
|
|
3054
|
+
}
|
|
3055
|
+
removePage(e) {
|
|
3056
|
+
super.removePage(e, (t) => {
|
|
3057
|
+
t.dispose();
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
setPageActive(e) {
|
|
3061
|
+
super.setPageActive(e, (t, s) => {
|
|
3062
|
+
t.enabled = s;
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
setSize(e, t) {
|
|
3066
|
+
this.controllerMap.forEach((s, i) => {
|
|
3067
|
+
i.setSize(e, t);
|
|
3068
|
+
});
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
class rt extends mt {
|
|
3072
|
+
constructor(e) {
|
|
3073
|
+
super(e), this.options = { type: "image" };
|
|
3074
|
+
}
|
|
3075
|
+
setOptions(e) {
|
|
3076
|
+
return this.options = e, this;
|
|
3077
|
+
}
|
|
3078
|
+
load(e, t, s, i) {
|
|
3079
|
+
let r, o;
|
|
3080
|
+
this.options.type === "image" ? (o = document.createElement("img"), r = new ue(o)) : this.options.type === "video" ? (o = document.createElement("video"), o.preload = "auto", o.autoplay = !1, o.loop = !1, o.muted = !0, o.setAttribute("webkit-playsinline", "webkit-playsinline"), o.setAttribute("playsinline", ""), r = new pt(o)) : r = new ue();
|
|
3081
|
+
const n = new Ae(this.manager);
|
|
3082
|
+
return n.setResponseType("blob"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
3083
|
+
e,
|
|
3084
|
+
(a) => {
|
|
3085
|
+
let c = a;
|
|
3086
|
+
const u = e.split(".").pop(), m = this.options.type === "image" ? `image/${u || "png"}` : `video/${u || "mp4"}`;
|
|
3087
|
+
c = c.slice(0, a.size, m);
|
|
3088
|
+
const v = () => {
|
|
3089
|
+
o.removeEventListener("load", p, !1), o.removeEventListener("error", f, !1);
|
|
3090
|
+
}, p = () => {
|
|
3091
|
+
v(), r.needsUpdate = !0, t && t(r);
|
|
3092
|
+
}, f = (y) => {
|
|
3093
|
+
v(), i && i(y), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
3094
|
+
};
|
|
3095
|
+
o.addEventListener("load", p, !1), o.addEventListener("error", f, !1);
|
|
3096
|
+
const g = window.URL.createObjectURL(c);
|
|
3097
|
+
o.src = g;
|
|
3098
|
+
},
|
|
3099
|
+
s,
|
|
3100
|
+
i
|
|
3101
|
+
), r;
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
class ti extends mt {
|
|
3105
|
+
constructor(e) {
|
|
3106
|
+
super(e);
|
|
3107
|
+
}
|
|
3108
|
+
load(e, t, s, i) {
|
|
3109
|
+
const r = new Ae(this.manager);
|
|
3110
|
+
r.setResponseType("blob"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
|
|
3111
|
+
e,
|
|
3112
|
+
(o) => {
|
|
3113
|
+
const n = o, a = new DecompressionStream("gzip"), c = n.stream().pipeThrough(a);
|
|
3114
|
+
new Response(c).json().then((m) => {
|
|
3115
|
+
t == null || t(m);
|
|
3116
|
+
}).catch((m) => {
|
|
3117
|
+
i == null || i(m);
|
|
3118
|
+
});
|
|
3119
|
+
},
|
|
3120
|
+
s,
|
|
3121
|
+
i
|
|
3122
|
+
);
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
const si = {
|
|
3126
|
+
images: ["png", "jpg", "jpeg", "ico", "webp", "avif"],
|
|
3127
|
+
media: ["mp4", "webm", "ogg"],
|
|
3128
|
+
gltf: ["gltf", "glb"],
|
|
3129
|
+
json: ["json", "geojson"],
|
|
3130
|
+
gzipJson: ["json.gzip"],
|
|
3131
|
+
exr: ["exr"],
|
|
3132
|
+
lottie: ["lottie.json"]
|
|
3133
|
+
};
|
|
3134
|
+
class ii {
|
|
3135
|
+
constructor(e) {
|
|
3136
|
+
this.loadObj = [], this.delLoadArr = [], this.assets = /* @__PURE__ */ new Map(), this.event = new ye.EventEmitter(), this.options = U({
|
|
3137
|
+
simpleTexture4deleted: !1,
|
|
3138
|
+
prefix: ""
|
|
3139
|
+
}, e), this.loadingManager = new es(
|
|
3140
|
+
() => {
|
|
3141
|
+
},
|
|
3142
|
+
(t, s, i) => {
|
|
3143
|
+
this.emit("progress", s, i);
|
|
3144
|
+
},
|
|
3145
|
+
(t) => {
|
|
3146
|
+
console.warn(`Failed to load ${t}`);
|
|
3147
|
+
}
|
|
3148
|
+
);
|
|
3149
|
+
}
|
|
3150
|
+
emit(e, ...t) {
|
|
3151
|
+
this.event.emit(e, ...t);
|
|
3152
|
+
}
|
|
3153
|
+
on(e, t) {
|
|
3154
|
+
this.event.on(e, t);
|
|
3155
|
+
}
|
|
3156
|
+
getAsset(e) {
|
|
3157
|
+
const t = this.getAssetType(e);
|
|
3158
|
+
if (!t)
|
|
3159
|
+
return;
|
|
3160
|
+
const s = this.assets.get(e);
|
|
3161
|
+
if (!s) {
|
|
3162
|
+
if ((t === "images" || t === "media" || t === "exr") && this.options.simpleTexture4deleted && this.delLoadArr.includes(e))
|
|
3163
|
+
return new ue();
|
|
3164
|
+
console.warn(`Asset ${e} not found`);
|
|
3165
|
+
}
|
|
3166
|
+
return s;
|
|
3167
|
+
}
|
|
3168
|
+
getAssetType(e) {
|
|
3169
|
+
var s;
|
|
3170
|
+
const t = (s = e.split(".").pop()) == null ? void 0 : s.toLowerCase();
|
|
3171
|
+
if (t) {
|
|
3172
|
+
if (e.endsWith("lottie.json"))
|
|
3173
|
+
return "lottie";
|
|
3174
|
+
if (e.endsWith("json.gzip"))
|
|
3175
|
+
return "gzipJson";
|
|
3176
|
+
} else return;
|
|
3177
|
+
for (const [i, r] of Object.entries(si))
|
|
3178
|
+
if (r.includes(t))
|
|
3179
|
+
return i;
|
|
3180
|
+
}
|
|
3181
|
+
getLoader(e, t) {
|
|
3182
|
+
if (e === "images")
|
|
3183
|
+
return this.textureLoader || (this.textureLoader = new rt(this.loadingManager), this.options.prefix && this.textureLoader.setPath(this.options.prefix)), this.textureLoader;
|
|
3184
|
+
if (e === "media")
|
|
3185
|
+
return this.videoTextureLoader || (this.videoTextureLoader = new rt(this.loadingManager), this.videoTextureLoader.setOptions({ type: "video" }), this.options.prefix && this.videoTextureLoader.setPath(this.options.prefix)), this.videoTextureLoader;
|
|
3186
|
+
if (e === "gltf" && (t != null && t.dracoPath))
|
|
3187
|
+
return this.dracoGltfLoader || (this.dracoGltfLoader = new Ie(this.loadingManager), this.dracoLoader = new us(), this.dracoLoader.setDecoderPath(t == null ? void 0 : t.dracoPath), this.dracoGltfLoader.setDRACOLoader(this.dracoLoader), this.options.prefix && this.dracoGltfLoader.setPath(this.options.prefix)), this.dracoGltfLoader;
|
|
3188
|
+
if (e === "gltf")
|
|
3189
|
+
return this.gltfLoader || (this.gltfLoader = new Ie(this.loadingManager), this.options.prefix && this.gltfLoader.setPath(this.options.prefix)), this.gltfLoader;
|
|
3190
|
+
if (e === "lottie")
|
|
3191
|
+
return this.lottieLoader || (this.lottieLoader = new gs(this.loadingManager), this.options.prefix && this.lottieLoader.setPath(this.options.prefix)), this.lottieLoader;
|
|
3192
|
+
if (e === "gzipJson")
|
|
3193
|
+
return this.gzipJsonLoader || (this.gzipJsonLoader = new ti(this.loadingManager), this.options.prefix && this.gzipJsonLoader.setPath(this.options.prefix)), this.gzipJsonLoader;
|
|
3194
|
+
if (e === "json")
|
|
3195
|
+
return this.jsonLoader || (this.jsonLoader = new Ae(this.loadingManager), this.jsonLoader.setResponseType("json"), this.options.prefix && this.jsonLoader.setPath(this.options.prefix)), this.jsonLoader;
|
|
3196
|
+
if (e === "exr")
|
|
3197
|
+
return this.exrLoader || (this.exrLoader = new _s(this.loadingManager), this.options.prefix && this.exrLoader.setPath(this.options.prefix)), this.exrLoader;
|
|
3198
|
+
}
|
|
3199
|
+
add(e, t) {
|
|
3200
|
+
typeof e == "string" && (e = [e]), e.forEach((s) => {
|
|
3201
|
+
const i = U({
|
|
3202
|
+
src: s
|
|
3203
|
+
}, t);
|
|
3204
|
+
this.loadObj.push(i);
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
getSrcByAsset(e, t = this.assets) {
|
|
3208
|
+
let s;
|
|
3209
|
+
return t.forEach((i, r) => {
|
|
3210
|
+
i === e && (s = r);
|
|
3211
|
+
}), s;
|
|
3212
|
+
}
|
|
3213
|
+
get textureAssets() {
|
|
3214
|
+
const e = /* @__PURE__ */ new Map();
|
|
3215
|
+
return this.assets.forEach((t, s) => {
|
|
3216
|
+
(t instanceof ue || t instanceof ts || t instanceof pt) && e.set(s, t);
|
|
3217
|
+
}), e;
|
|
3218
|
+
}
|
|
3219
|
+
loadAll() {
|
|
3220
|
+
return se(this, null, function* () {
|
|
3221
|
+
const e = this.loadObj.filter((t) => !this.delLoadArr.includes(t.src));
|
|
3222
|
+
return yield Promise.all(
|
|
3223
|
+
e.map((t) => this.load(t.src, t))
|
|
3224
|
+
);
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
load(e, t) {
|
|
3228
|
+
return se(this, null, function* () {
|
|
3229
|
+
var n, a;
|
|
3230
|
+
const s = (n = t == null ? void 0 : t.type) != null ? n : this.getAssetType(e);
|
|
3231
|
+
if (!s)
|
|
3232
|
+
return;
|
|
3233
|
+
const i = (t == null ? void 0 : t.cache) !== !1, r = fs();
|
|
3234
|
+
if (i) {
|
|
3235
|
+
if (this.assets.has(e))
|
|
3236
|
+
return this.assets.get(e);
|
|
3237
|
+
this.assets.set(e, r.promise);
|
|
3238
|
+
}
|
|
3239
|
+
const o = this.getLoader(s, t);
|
|
3240
|
+
try {
|
|
3241
|
+
const c = yield o.loadAsync(e);
|
|
3242
|
+
if (this.assets.set(e, c), r.resolve(c), s === "images" || s === "media" || s === "exr" || s === "lottie") {
|
|
3243
|
+
(t == null ? void 0 : t.colorCorrection) !== !1 && ys({ texture: c });
|
|
3244
|
+
const u = (a = t == null ? void 0 : t.anisotropy) != null ? a : this.options.anisotropy;
|
|
3245
|
+
c.anisotropy = u;
|
|
3246
|
+
}
|
|
3247
|
+
return c;
|
|
3248
|
+
} catch (c) {
|
|
3249
|
+
r.reject(`Failed to load ${e}`);
|
|
3250
|
+
return;
|
|
3251
|
+
}
|
|
3390
3252
|
});
|
|
3391
3253
|
}
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3254
|
+
getUnusedAssets() {
|
|
3255
|
+
const { scene: e } = this.options;
|
|
3256
|
+
if (!e)
|
|
3257
|
+
return [...this.delLoadArr];
|
|
3258
|
+
const t = /* @__PURE__ */ new Set(), s = this.textureAssets;
|
|
3259
|
+
e.traverse((r) => {
|
|
3260
|
+
const o = r;
|
|
3261
|
+
o.material && (Array.isArray(o.material) ? o.material : [o.material]).forEach((a) => {
|
|
3262
|
+
[
|
|
3263
|
+
a.map,
|
|
3264
|
+
a.emissiveMap,
|
|
3265
|
+
a.normalMap,
|
|
3266
|
+
a.roughnessMap,
|
|
3267
|
+
a.metalnessMap,
|
|
3268
|
+
a.aoMap
|
|
3269
|
+
].forEach((c) => {
|
|
3270
|
+
if (c) {
|
|
3271
|
+
const u = this.getSrcByAsset(c, s);
|
|
3272
|
+
u && t.add(u);
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3402
3275
|
});
|
|
3403
|
-
}), this.pencil.event.emit("erase", ...e);
|
|
3404
|
-
}
|
|
3405
|
-
update(e, t) {
|
|
3406
|
-
this.objects.forEach((s) => {
|
|
3407
|
-
s.update(e, t);
|
|
3408
3276
|
});
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
});
|
|
3414
|
-
}
|
|
3415
|
-
eraseAll() {
|
|
3416
|
-
this.group && (this.objects.forEach((e) => {
|
|
3417
|
-
e.key.startsWith("Node") && this.erase(e);
|
|
3418
|
-
}), this.erase(this.group));
|
|
3277
|
+
const i = new Set(this.textureAssets.keys());
|
|
3278
|
+
return t.forEach((r) => {
|
|
3279
|
+
i.delete(r);
|
|
3280
|
+
}), [...i, ...this.delLoadArr];
|
|
3419
3281
|
}
|
|
3420
3282
|
dispose() {
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
}), this.objects.clear(), this.objectsPm.clear(), this.objMap.clear(), this.objectNamesToFactories.clear();
|
|
3283
|
+
var e;
|
|
3284
|
+
this.assets.clear(), (e = this.dracoLoader) == null || e.dispose(), this.event.removeAllListeners(), this.delLoadArr.length = 0, this.loadObj.length = 0;
|
|
3424
3285
|
}
|
|
3425
3286
|
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3287
|
+
const ri = {
|
|
3288
|
+
prefix: ""
|
|
3289
|
+
};
|
|
3290
|
+
class oi extends ee {
|
|
3291
|
+
get loader() {
|
|
3428
3292
|
return this.controller;
|
|
3429
3293
|
}
|
|
3430
3294
|
constructor(e) {
|
|
3431
3295
|
super(), this.options = e;
|
|
3432
3296
|
}
|
|
3433
|
-
|
|
3434
|
-
const {
|
|
3435
|
-
scene: e
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
return this.addController(r, s);
|
|
3297
|
+
addLoader(e, t) {
|
|
3298
|
+
const { loaderParams: s } = this.options, i = new ii(te(U({}, s), {
|
|
3299
|
+
scene: e
|
|
3300
|
+
}));
|
|
3301
|
+
return this.addController(i, t);
|
|
3439
3302
|
}
|
|
3440
3303
|
removePage(e) {
|
|
3441
3304
|
super.removePage(e, (t) => {
|
|
3442
3305
|
t.dispose();
|
|
3443
3306
|
});
|
|
3444
3307
|
}
|
|
3445
|
-
setPageActive(e) {
|
|
3446
|
-
super.setPageActive(e, (t, s) => {
|
|
3447
|
-
t.enabled = s;
|
|
3448
|
-
});
|
|
3449
|
-
}
|
|
3450
|
-
setSize(e, t) {
|
|
3451
|
-
this.controllerMap.forEach((s, i) => {
|
|
3452
|
-
i.setSize(e, t);
|
|
3453
|
-
});
|
|
3454
|
-
}
|
|
3455
3308
|
}
|
|
3456
|
-
class
|
|
3309
|
+
class ni {
|
|
3457
3310
|
constructor(e) {
|
|
3458
|
-
this.materials = /* @__PURE__ */ new Map(), this.
|
|
3311
|
+
this.materials = /* @__PURE__ */ new Map(), this.fixBaseObjects = /* @__PURE__ */ new Map(), this.materialBaseObjectMap = /* @__PURE__ */ new Map(), this.pencil = e;
|
|
3459
3312
|
}
|
|
3460
3313
|
add(e, t) {
|
|
3461
|
-
this.materials.set(e, t)
|
|
3314
|
+
this.materials.set(e, t);
|
|
3315
|
+
const s = {
|
|
3316
|
+
object3d: new Proxy(
|
|
3317
|
+
{
|
|
3318
|
+
material: t
|
|
3319
|
+
},
|
|
3320
|
+
{
|
|
3321
|
+
set: (i, r, o) => {
|
|
3322
|
+
var n;
|
|
3323
|
+
if (r === "material" && !((n = this.pencil.composerController) != null && n.bloomComposerRenderIng)) {
|
|
3324
|
+
const a = i.material;
|
|
3325
|
+
return i.material = o, this.materials.set(e, o), this.disposeMaterial(a), this.syncChangeMaterial(a, o), !0;
|
|
3326
|
+
}
|
|
3327
|
+
return i[r] = o, !0;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
)
|
|
3331
|
+
};
|
|
3332
|
+
this.fixBaseObjects.set(e, s), this.pencil.event.emit("mList.add", {
|
|
3333
|
+
key: e,
|
|
3334
|
+
material: t,
|
|
3335
|
+
baseObject: s
|
|
3336
|
+
});
|
|
3462
3337
|
}
|
|
3463
3338
|
get(e) {
|
|
3464
3339
|
const t = this.materials.get(e);
|
|
3465
3340
|
return t || console.warn(`Material with key "${e}" not found.`), t;
|
|
3466
3341
|
}
|
|
3342
|
+
getByName(e) {
|
|
3343
|
+
for (const [t, s] of this.materials.entries())
|
|
3344
|
+
if (s.name === e)
|
|
3345
|
+
return s;
|
|
3346
|
+
console.warn(`Material with name "${e}" not found.`);
|
|
3347
|
+
}
|
|
3467
3348
|
getKey(e) {
|
|
3468
3349
|
for (const [t, s] of this.materials.entries())
|
|
3469
3350
|
if (s === e)
|
|
3470
3351
|
return t;
|
|
3471
3352
|
}
|
|
3353
|
+
getKeyByName(e) {
|
|
3354
|
+
for (const [t, s] of this.materials.entries())
|
|
3355
|
+
if (s.name === e)
|
|
3356
|
+
return t;
|
|
3357
|
+
console.warn(`Material key with name "${e}" not found.`);
|
|
3358
|
+
}
|
|
3472
3359
|
addMultiple(e, t) {
|
|
3473
3360
|
for (const [s, i] of Object.entries(t)) {
|
|
3474
3361
|
const r = `${e}#${s}`;
|
|
@@ -3485,92 +3372,160 @@ class fi {
|
|
|
3485
3372
|
}
|
|
3486
3373
|
return i ? t : null;
|
|
3487
3374
|
}
|
|
3375
|
+
copy(e, t, s = {}) {
|
|
3376
|
+
const i = this.get(e);
|
|
3377
|
+
if (!i)
|
|
3378
|
+
return console.warn(`Material with key "${e}" not found.`), null;
|
|
3379
|
+
const r = i.clone();
|
|
3380
|
+
return s.name && (r.name = s.name), this.add(t, r), r;
|
|
3381
|
+
}
|
|
3488
3382
|
copyMultiple(e, t) {
|
|
3489
3383
|
const s = {}, i = `${e}#`;
|
|
3490
3384
|
for (const [r, o] of this.materials.entries())
|
|
3491
3385
|
if (r.startsWith(i)) {
|
|
3492
|
-
const n = r.substring(i.length),
|
|
3493
|
-
s[n] =
|
|
3494
|
-
const
|
|
3495
|
-
this.add(
|
|
3386
|
+
const n = r.substring(i.length), a = o.clone();
|
|
3387
|
+
s[n] = a;
|
|
3388
|
+
const c = `${t}#${n}`;
|
|
3389
|
+
this.add(c, a);
|
|
3496
3390
|
}
|
|
3497
3391
|
return s;
|
|
3498
3392
|
}
|
|
3499
3393
|
disposeMaterial(e) {
|
|
3394
|
+
if (!e) return;
|
|
3500
3395
|
const t = new Pe();
|
|
3501
|
-
t.track([e]), t.dispose();
|
|
3396
|
+
t.track(Array.isArray(e) ? e : [e]), t.dispose();
|
|
3502
3397
|
}
|
|
3503
3398
|
remove(e) {
|
|
3504
3399
|
const t = this.materials.get(e);
|
|
3505
|
-
t && this.disposeMaterial(t), this.materials.delete(e), this.
|
|
3400
|
+
t && this.disposeMaterial(t), this.materials.delete(e), this.fixBaseObjects.delete(e), this.pencil.event.emit("mList.remove", { key: e, material: t });
|
|
3506
3401
|
}
|
|
3507
3402
|
removeByMaterial(e) {
|
|
3508
3403
|
[...this.materials.entries()].some(([t, s]) => s === e ? (this.remove(t), !0) : !1);
|
|
3509
3404
|
}
|
|
3510
3405
|
proxyBaseObject(e) {
|
|
3511
|
-
const t = e.object3d
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3406
|
+
const t = e.object3d;
|
|
3407
|
+
if (!t.material)
|
|
3408
|
+
return;
|
|
3409
|
+
const s = (o) => {
|
|
3410
|
+
if (o.hasOwnProperty("__isProxy"))
|
|
3411
|
+
return o;
|
|
3412
|
+
const n = new Proxy(o, {
|
|
3413
|
+
set: (a, c, u) => {
|
|
3414
|
+
if (typeof c == "string" && !isNaN(Number(c))) {
|
|
3415
|
+
const m = Number(c);
|
|
3416
|
+
if (m >= 0 && m < a.length) {
|
|
3417
|
+
const v = a[m];
|
|
3418
|
+
return this.rmBaseObjectMap(e, v), a[m] = u, u && this.addBaseObjectMap(e), !0;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
return a[c] = u, !0;
|
|
3422
|
+
}
|
|
3423
|
+
});
|
|
3424
|
+
return Object.defineProperty(n, "__isProxy", {
|
|
3425
|
+
value: !0,
|
|
3426
|
+
enumerable: !1
|
|
3427
|
+
}), n;
|
|
3428
|
+
};
|
|
3429
|
+
e.materialList && (e.materialList = new Proxy(e.materialList, {
|
|
3430
|
+
set: (o, n, a) => {
|
|
3431
|
+
if (typeof n == "string") {
|
|
3432
|
+
const c = o[n];
|
|
3433
|
+
return this.rmBaseObjectMap(e, c), o[n] = a, a && this.addBaseObjectMap(e), !0;
|
|
3434
|
+
}
|
|
3435
|
+
return o[n] = a, !0;
|
|
3436
|
+
},
|
|
3437
|
+
get: (o, n) => {
|
|
3438
|
+
if (typeof n == "string" && o[n]) {
|
|
3439
|
+
const a = o[n];
|
|
3440
|
+
if (Array.isArray(a)) {
|
|
3441
|
+
const c = s(a);
|
|
3442
|
+
return c !== a && (o[n] = c), c;
|
|
3518
3443
|
}
|
|
3444
|
+
return a;
|
|
3445
|
+
}
|
|
3446
|
+
return o[n];
|
|
3447
|
+
},
|
|
3448
|
+
deleteProperty: (o, n) => {
|
|
3449
|
+
if (typeof n == "string" && o[n]) {
|
|
3450
|
+
const a = o[n];
|
|
3451
|
+
this.rmBaseObjectMap(e, a);
|
|
3519
3452
|
}
|
|
3520
|
-
return
|
|
3453
|
+
return delete o[n], !0;
|
|
3521
3454
|
}
|
|
3522
|
-
});
|
|
3523
|
-
|
|
3524
|
-
|
|
3455
|
+
}));
|
|
3456
|
+
const i = t.material, r = "_enhancedMaterial";
|
|
3457
|
+
t[r] = i, Object.defineProperty(t, "material", {
|
|
3458
|
+
get: () => {
|
|
3525
3459
|
var n;
|
|
3526
|
-
|
|
3460
|
+
const o = t[r];
|
|
3461
|
+
if (!((n = this.pencil.composerController) != null && n.bloomComposerRenderIng) && Array.isArray(o)) {
|
|
3462
|
+
const a = s(o);
|
|
3463
|
+
return a !== o && (t[r] = a), a;
|
|
3464
|
+
}
|
|
3465
|
+
return o;
|
|
3527
3466
|
},
|
|
3528
|
-
|
|
3529
|
-
var
|
|
3530
|
-
if (
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
enumerable: !1
|
|
3537
|
-
}), i.material = l;
|
|
3467
|
+
set: (o) => {
|
|
3468
|
+
var n;
|
|
3469
|
+
if ((n = this.pencil.composerController) != null && n.bloomComposerRenderIng)
|
|
3470
|
+
t[r] = o;
|
|
3471
|
+
else {
|
|
3472
|
+
if (e.materialList && Object.values(e.materialList).includes(o)) {
|
|
3473
|
+
t[r] = o;
|
|
3474
|
+
return;
|
|
3538
3475
|
}
|
|
3476
|
+
this.rmBaseObjectMap(e), t[r] = o, this.addBaseObjectMap(e);
|
|
3539
3477
|
}
|
|
3540
|
-
|
|
3541
|
-
|
|
3478
|
+
},
|
|
3479
|
+
enumerable: !0,
|
|
3480
|
+
configurable: !0
|
|
3542
3481
|
});
|
|
3543
3482
|
}
|
|
3483
|
+
material2array(e) {
|
|
3484
|
+
return Array.isArray(e) ? e : [e];
|
|
3485
|
+
}
|
|
3544
3486
|
addBaseObjectMap(e) {
|
|
3545
3487
|
const t = e.object3d;
|
|
3546
|
-
t.material && (
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3488
|
+
t.material && ([...Object.values(e.materialList), t.material].forEach(
|
|
3489
|
+
(s) => {
|
|
3490
|
+
s && this.material2array(s).forEach((r) => {
|
|
3491
|
+
const o = this.materialBaseObjectMap.get(r);
|
|
3492
|
+
o ? o.add(e) : this.materialBaseObjectMap.set(r, /* @__PURE__ */ new Set([e]));
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
), this.pencil.event.emit("mList.addBaseObjectMap"));
|
|
3496
|
+
}
|
|
3497
|
+
rmBaseObjectMap(e, t, s = !0) {
|
|
3498
|
+
const i = t && this.material2array(t);
|
|
3499
|
+
this.materialBaseObjectMap.forEach((r, o) => {
|
|
3500
|
+
i && !i.includes(o) || r.has(e) && (r.delete(e), r.size === 0 && s && (this.materialBaseObjectMap.delete(o), this.disposeMaterial(o)));
|
|
3501
|
+
}), this.pencil.event.emit("mList.rmBaseObjectMap");
|
|
3502
|
+
}
|
|
3503
|
+
getBaseObjectMap(e) {
|
|
3504
|
+
return this.materialBaseObjectMap.get(e) || /* @__PURE__ */ new Set();
|
|
3505
|
+
}
|
|
3506
|
+
syncChangeMaterial(e, t) {
|
|
3507
|
+
const s = this.materialBaseObjectMap.get(e);
|
|
3508
|
+
s && s.forEach((i) => {
|
|
3509
|
+
const r = i.object3d, o = r.material;
|
|
3510
|
+
if (Array.isArray(o)) {
|
|
3511
|
+
const n = o.indexOf(e);
|
|
3512
|
+
n !== -1 && (o[n] = t);
|
|
3513
|
+
} else o === e && (r.material = t);
|
|
3514
|
+
i.materialList && Object.keys(i.materialList).forEach((n) => {
|
|
3515
|
+
const a = i.materialList[n];
|
|
3516
|
+
if (Array.isArray(a)) {
|
|
3517
|
+
const c = a.indexOf(e);
|
|
3518
|
+
c !== -1 && (a[c] = t);
|
|
3519
|
+
} else a === e && (i.materialList[n] = t);
|
|
3561
3520
|
});
|
|
3562
|
-
})
|
|
3563
|
-
}
|
|
3564
|
-
emitObject3dChange() {
|
|
3565
|
-
var e;
|
|
3566
|
-
(e = this.pencil) == null || e.event.emit("baseObjectListChange");
|
|
3521
|
+
});
|
|
3567
3522
|
}
|
|
3568
3523
|
dispose() {
|
|
3569
3524
|
const e = new Pe();
|
|
3570
|
-
e.track([...this.materials.values()]), e.dispose(), this.
|
|
3525
|
+
e.track([...this.materials.values()]), e.dispose(), this.materials.clear(), this.fixBaseObjects.clear(), this.materialBaseObjectMap.clear();
|
|
3571
3526
|
}
|
|
3572
3527
|
}
|
|
3573
|
-
class
|
|
3528
|
+
class ai extends ee {
|
|
3574
3529
|
get mList() {
|
|
3575
3530
|
return this.controller;
|
|
3576
3531
|
}
|
|
@@ -3578,7 +3533,7 @@ class _i extends ee {
|
|
|
3578
3533
|
super(), this.options = e;
|
|
3579
3534
|
}
|
|
3580
3535
|
addMList(e, t) {
|
|
3581
|
-
const { pencil: s } = this.options, i = new
|
|
3536
|
+
const { pencil: s } = this.options, i = new ni(s);
|
|
3582
3537
|
return this.addController(i, t);
|
|
3583
3538
|
}
|
|
3584
3539
|
removePage(e) {
|
|
@@ -3587,11 +3542,185 @@ class _i extends ee {
|
|
|
3587
3542
|
});
|
|
3588
3543
|
}
|
|
3589
3544
|
}
|
|
3545
|
+
const li = {
|
|
3546
|
+
antialias: !1,
|
|
3547
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
3548
|
+
powerPreference: "high-performance",
|
|
3549
|
+
toneMappingExposure: 1,
|
|
3550
|
+
alpha: !1,
|
|
3551
|
+
outputColorSpace: vs.sRGB,
|
|
3552
|
+
logarithmicDepthBuffer: !1,
|
|
3553
|
+
preserveDrawingBuffer: !1,
|
|
3554
|
+
stencil: !1,
|
|
3555
|
+
depth: !1
|
|
3556
|
+
};
|
|
3557
|
+
class hi {
|
|
3558
|
+
constructor(e) {
|
|
3559
|
+
this.options = e;
|
|
3560
|
+
const { width: t, height: s, rendererParams: i } = e, {
|
|
3561
|
+
alpha: r,
|
|
3562
|
+
devicePixelRatio: o,
|
|
3563
|
+
antialias: n,
|
|
3564
|
+
powerPreference: a,
|
|
3565
|
+
toneMappingExposure: c,
|
|
3566
|
+
outputColorSpace: u,
|
|
3567
|
+
logarithmicDepthBuffer: m,
|
|
3568
|
+
preserveDrawingBuffer: v,
|
|
3569
|
+
stencil: p,
|
|
3570
|
+
depth: f
|
|
3571
|
+
} = i, g = new ss({
|
|
3572
|
+
alpha: r,
|
|
3573
|
+
antialias: n,
|
|
3574
|
+
powerPreference: a,
|
|
3575
|
+
logarithmicDepthBuffer: m,
|
|
3576
|
+
preserveDrawingBuffer: v,
|
|
3577
|
+
stencil: p,
|
|
3578
|
+
depth: f
|
|
3579
|
+
});
|
|
3580
|
+
g.setSize(t, s), g.setPixelRatio(o), g.toneMappingExposure = c, g.outputColorSpace = u, this.renderer = g;
|
|
3581
|
+
}
|
|
3582
|
+
setSize(e, t) {
|
|
3583
|
+
this.renderer.setSize(e, t);
|
|
3584
|
+
}
|
|
3585
|
+
setPixelRatio(e) {
|
|
3586
|
+
this.renderer.setPixelRatio(e);
|
|
3587
|
+
}
|
|
3588
|
+
render(e, t) {
|
|
3589
|
+
this.renderer.render(e, t);
|
|
3590
|
+
}
|
|
3591
|
+
setViewport(e) {
|
|
3592
|
+
var a, c;
|
|
3593
|
+
const { x: t, y: s, width: i, height: r } = e, o = (a = e.scissor) != null ? a : !1, n = (c = e.scissorTest) != null ? c : !1;
|
|
3594
|
+
this.renderer.setViewport(t, s, i, r), o && (this.renderer.setScissor(t, s, i, r), this.renderer.setScissorTest(n));
|
|
3595
|
+
}
|
|
3596
|
+
dispose() {
|
|
3597
|
+
var e, t;
|
|
3598
|
+
this.setSize(1, 1), (e = this.renderer) == null || e.clear(), (t = this.renderer) == null || t.dispose();
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
const ci = {
|
|
3602
|
+
background: null
|
|
3603
|
+
};
|
|
3604
|
+
class di extends ee {
|
|
3605
|
+
get scene() {
|
|
3606
|
+
return this.controller;
|
|
3607
|
+
}
|
|
3608
|
+
constructor(e) {
|
|
3609
|
+
super(), this.options = e;
|
|
3610
|
+
}
|
|
3611
|
+
addScene(e, t) {
|
|
3612
|
+
const s = new dt();
|
|
3613
|
+
return e != null && e.background && (s.background = e.background), this.addController(s, t);
|
|
3614
|
+
}
|
|
3615
|
+
removePage(e) {
|
|
3616
|
+
super.removePage(e, (t) => {
|
|
3617
|
+
const s = new Pe();
|
|
3618
|
+
s.track(t), s.dispose();
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
setPageActive(e) {
|
|
3622
|
+
super.setPageActive(e, (t, s) => {
|
|
3623
|
+
t.visible = s;
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
class mi {
|
|
3628
|
+
constructor(e) {
|
|
3629
|
+
this.event = new ye.EventEmitter();
|
|
3630
|
+
const { renderer: t, scene: s, camera: i } = e, r = new Os(
|
|
3631
|
+
i,
|
|
3632
|
+
t.domElement
|
|
3633
|
+
);
|
|
3634
|
+
if (r.getHelper) {
|
|
3635
|
+
const o = r.getHelper();
|
|
3636
|
+
if (s.add(o), +is < 170) {
|
|
3637
|
+
const n = r._root;
|
|
3638
|
+
n.dispose = () => {
|
|
3639
|
+
n.traverse((a) => {
|
|
3640
|
+
a.geometry && a.geometry.dispose(), a.material && a.material.dispose();
|
|
3641
|
+
});
|
|
3642
|
+
}, r.dispose = () => {
|
|
3643
|
+
r.disconnect(), n.dispose();
|
|
3644
|
+
};
|
|
3645
|
+
}
|
|
3646
|
+
} else r instanceof rs && s.add(r);
|
|
3647
|
+
this.controls = r, this.addEvent();
|
|
3648
|
+
}
|
|
3649
|
+
get detach() {
|
|
3650
|
+
return this.controls.detach.bind(this.controls);
|
|
3651
|
+
}
|
|
3652
|
+
get attach() {
|
|
3653
|
+
return this.controls.attach.bind(this.controls);
|
|
3654
|
+
}
|
|
3655
|
+
addEvent() {
|
|
3656
|
+
let e = null, t = null, s = null;
|
|
3657
|
+
const i = this.controls;
|
|
3658
|
+
i.addEventListener("change", () => {
|
|
3659
|
+
const r = i.object;
|
|
3660
|
+
r !== void 0 && this.event.emit("change", r);
|
|
3661
|
+
}), i.addEventListener("mouseDown", () => {
|
|
3662
|
+
const r = i.object;
|
|
3663
|
+
e = r.position.clone(), t = r.rotation.clone(), s = r.scale.clone(), this.event.emit("mouseDown", r);
|
|
3664
|
+
}), i.addEventListener("mouseUp", () => {
|
|
3665
|
+
const r = i.object;
|
|
3666
|
+
if (r !== void 0)
|
|
3667
|
+
switch (i.getMode()) {
|
|
3668
|
+
case "translate":
|
|
3669
|
+
e.equals(r.position) || this.event.emit(
|
|
3670
|
+
"translate",
|
|
3671
|
+
r,
|
|
3672
|
+
r.position,
|
|
3673
|
+
e
|
|
3674
|
+
);
|
|
3675
|
+
break;
|
|
3676
|
+
case "rotate":
|
|
3677
|
+
t.equals(r.rotation) || this.event.emit(
|
|
3678
|
+
"rotate",
|
|
3679
|
+
r,
|
|
3680
|
+
r.rotation,
|
|
3681
|
+
t
|
|
3682
|
+
);
|
|
3683
|
+
break;
|
|
3684
|
+
case "scale":
|
|
3685
|
+
s.equals(r.scale) || this.event.emit("scale", r, r.scale, s);
|
|
3686
|
+
break;
|
|
3687
|
+
}
|
|
3688
|
+
this.event.emit("mouseUp");
|
|
3689
|
+
});
|
|
3690
|
+
}
|
|
3691
|
+
dispose() {
|
|
3692
|
+
var e;
|
|
3693
|
+
this.event.removeAllListeners(), (e = this.controls) == null || e.dispose();
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
const pi = {
|
|
3697
|
+
antialias: !0,
|
|
3698
|
+
devicePixelRatio: window.devicePixelRatio
|
|
3699
|
+
};
|
|
3700
|
+
class fi {
|
|
3701
|
+
constructor(e) {
|
|
3702
|
+
this.options = e;
|
|
3703
|
+
const { width: t, height: s, rendererParams: i, renderer: r } = e, { devicePixelRatio: o, antialias: n } = i, a = new r({
|
|
3704
|
+
antialias: n
|
|
3705
|
+
});
|
|
3706
|
+
a.setSize(t, s), a.setPixelRatio(o), this.renderer = a;
|
|
3707
|
+
}
|
|
3708
|
+
setSize(e, t) {
|
|
3709
|
+
this.renderer.setSize(e, t);
|
|
3710
|
+
}
|
|
3711
|
+
render(e, t) {
|
|
3712
|
+
this.renderer.render(e, t);
|
|
3713
|
+
}
|
|
3714
|
+
dispose() {
|
|
3715
|
+
var e, t;
|
|
3716
|
+
this.setSize(1, 1), (e = this.renderer) == null || e.clear(), (t = this.renderer) == null || t.dispose();
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3590
3719
|
const _e = class _e {
|
|
3591
3720
|
constructor(e) {
|
|
3592
3721
|
var r, o;
|
|
3593
|
-
this.raycaster = new
|
|
3594
|
-
isMergeableObject:
|
|
3722
|
+
this.raycaster = new ct(), this.maxBackufferArea = 5760 * 5760, this.installPlugins = /* @__PURE__ */ new Map(), this._cameraPositon = new j(), this._cameraTarget = new j(), this.event = new ye.EventEmitter(), this.timer = new os(), this.userData = {}, this.pageActiveIndex = 0, this.pageCountIndex = 0, this.userSetDprCache = 1, this.viewPadding = [0, 0, 0, 0], this.event.setMaxListeners(1 / 0), (o = (r = this.timer).connect) == null || o.call(r, document), this.options = Ut(_e.options, e, {
|
|
3723
|
+
isMergeableObject: Cs
|
|
3595
3724
|
}), this.userSetDprCache = this.options.renderer.devicePixelRatio;
|
|
3596
3725
|
const {
|
|
3597
3726
|
container: t,
|
|
@@ -3599,7 +3728,7 @@ const _e = class _e {
|
|
|
3599
3728
|
transformControls: i
|
|
3600
3729
|
} = this.options;
|
|
3601
3730
|
if (this.init(), this.options.WebGPUTHREE || this.initComposer(), this.initCSSRenderer(), i && this.initTransformControls(), s) {
|
|
3602
|
-
const n = new
|
|
3731
|
+
const n = new zt({
|
|
3603
3732
|
horizontal: !1
|
|
3604
3733
|
});
|
|
3605
3734
|
n.dom.style.position = "absolute", n.init(this.renderer), t.appendChild(n.dom), this.stats = n;
|
|
@@ -3667,7 +3796,7 @@ const _e = class _e {
|
|
|
3667
3796
|
this.sceneController.setPageActive(e), t && ((s = this.cssRendererController) == null || s.render(t, this.camera)), this.cameraController.setPageActive(e), this.controlsController.setPageActive(e), this.loaderController.setPageActive(e), this.mListController.setPageActive(e), this.leadController.setPageActive(e), this.pageActiveIndex = e;
|
|
3668
3797
|
}
|
|
3669
3798
|
init() {
|
|
3670
|
-
var
|
|
3799
|
+
var _;
|
|
3671
3800
|
const {
|
|
3672
3801
|
container: e,
|
|
3673
3802
|
WebGPUTHREE: t,
|
|
@@ -3676,47 +3805,47 @@ const _e = class _e {
|
|
|
3676
3805
|
renderer: r,
|
|
3677
3806
|
controls: o,
|
|
3678
3807
|
loader: n
|
|
3679
|
-
} = this.options, { width:
|
|
3680
|
-
width:
|
|
3681
|
-
height:
|
|
3808
|
+
} = this.options, { width: a, height: c } = this.getSize(), u = t ? new fi({
|
|
3809
|
+
width: a,
|
|
3810
|
+
height: c,
|
|
3682
3811
|
renderer: t.WebGPURenderer,
|
|
3683
|
-
rendererParams:
|
|
3684
|
-
}) : new
|
|
3685
|
-
width:
|
|
3686
|
-
height:
|
|
3812
|
+
rendererParams: pi
|
|
3813
|
+
}) : new hi({
|
|
3814
|
+
width: a,
|
|
3815
|
+
height: c,
|
|
3687
3816
|
rendererParams: te(U({}, r), {
|
|
3688
3817
|
antialias: !1
|
|
3689
3818
|
})
|
|
3690
|
-
}),
|
|
3691
|
-
width:
|
|
3692
|
-
height:
|
|
3693
|
-
}),
|
|
3819
|
+
}), m = new Ms({
|
|
3820
|
+
width: a,
|
|
3821
|
+
height: c
|
|
3822
|
+
}), v = new di({}), p = new Zs({
|
|
3694
3823
|
controlsParams: {
|
|
3695
|
-
domElement: (
|
|
3824
|
+
domElement: (_ = o == null ? void 0 : o.domElement) != null ? _ : u.renderer.domElement
|
|
3696
3825
|
}
|
|
3697
|
-
}),
|
|
3826
|
+
}), f = new oi({
|
|
3698
3827
|
loaderParams: U({
|
|
3699
|
-
anisotropy:
|
|
3828
|
+
anisotropy: u.renderer.capabilities.getMaxAnisotropy()
|
|
3700
3829
|
}, n)
|
|
3701
|
-
}),
|
|
3830
|
+
}), g = new ai({
|
|
3702
3831
|
pencil: this
|
|
3703
|
-
}),
|
|
3832
|
+
}), y = new ei({
|
|
3704
3833
|
pencil: this
|
|
3705
3834
|
});
|
|
3706
|
-
this.sceneController =
|
|
3707
|
-
const
|
|
3835
|
+
this.sceneController = v, this.cameraController = m, this.controlsController = p, this.rendererController = u, this.loaderController = f, this.mListController = g, this.leadController = y;
|
|
3836
|
+
const l = this.addPage({
|
|
3708
3837
|
sceneOptions: this.options.scene,
|
|
3709
3838
|
cameraOptions: this.options.camera
|
|
3710
3839
|
});
|
|
3711
|
-
if (this.showPage(
|
|
3712
|
-
const
|
|
3840
|
+
if (this.showPage(l), s) {
|
|
3841
|
+
const O = new qs({
|
|
3713
3842
|
container: e,
|
|
3714
|
-
sceneController:
|
|
3715
|
-
cameraController:
|
|
3843
|
+
sceneController: v,
|
|
3844
|
+
cameraController: m
|
|
3716
3845
|
});
|
|
3717
|
-
|
|
3846
|
+
O.add(v.scene), this.helperController = O, i && O.addViewHelper();
|
|
3718
3847
|
}
|
|
3719
|
-
e.appendChild(
|
|
3848
|
+
e.appendChild(u.renderer.domElement);
|
|
3720
3849
|
}
|
|
3721
3850
|
initComposer() {
|
|
3722
3851
|
const {
|
|
@@ -3725,7 +3854,7 @@ const _e = class _e {
|
|
|
3725
3854
|
ssao: s,
|
|
3726
3855
|
ssaoParams: i,
|
|
3727
3856
|
composer: r
|
|
3728
|
-
} = this.options, o = new
|
|
3857
|
+
} = this.options, o = new Ys({
|
|
3729
3858
|
rendererController: this.rendererController,
|
|
3730
3859
|
sceneController: this.sceneController,
|
|
3731
3860
|
cameraController: this.cameraController,
|
|
@@ -3742,12 +3871,12 @@ const _e = class _e {
|
|
|
3742
3871
|
css3DRendererParams: r
|
|
3743
3872
|
} = this.options;
|
|
3744
3873
|
if (t || s) {
|
|
3745
|
-
const o = new
|
|
3874
|
+
const o = new Xs(e);
|
|
3746
3875
|
t && o.addRenderer("css2d", i), s && o.addRenderer("css3d", r), this.cssRendererController = o;
|
|
3747
3876
|
}
|
|
3748
3877
|
}
|
|
3749
3878
|
initTransformControls() {
|
|
3750
|
-
const e = new
|
|
3879
|
+
const e = new mi({
|
|
3751
3880
|
camera: this.camera,
|
|
3752
3881
|
renderer: this.renderer,
|
|
3753
3882
|
scene: this.scene
|
|
@@ -3784,12 +3913,12 @@ const _e = class _e {
|
|
|
3784
3913
|
cameraController: r,
|
|
3785
3914
|
composerController: o,
|
|
3786
3915
|
cssRendererController: n,
|
|
3787
|
-
leadController:
|
|
3788
|
-
} = this,
|
|
3789
|
-
|
|
3790
|
-
var
|
|
3791
|
-
(
|
|
3792
|
-
}), this.render(), s && this.event.emit("resize", { width: e, height: t }));
|
|
3916
|
+
leadController: a
|
|
3917
|
+
} = this, c = this.renderer.getSize(new B());
|
|
3918
|
+
c.x === e && c.y === t || (r.setSize(e, t), i.setSize(e, t), o == null || o.setSize(e, t), n == null || n.setSize(e, t), a.setSize(e, t), this.installPlugins.forEach((u) => {
|
|
3919
|
+
var m;
|
|
3920
|
+
(m = u.setSize) == null || m.call(u, e, t);
|
|
3921
|
+
}), this.viewPadding.some((u) => u !== 0) && this.setViewPadding(...this.viewPadding), this.render(), s && this.event.emit("resize", { width: e, height: t }));
|
|
3793
3922
|
}
|
|
3794
3923
|
setDevicePixelRatio(e) {
|
|
3795
3924
|
var n;
|
|
@@ -3805,44 +3934,55 @@ const _e = class _e {
|
|
|
3805
3934
|
r
|
|
3806
3935
|
);
|
|
3807
3936
|
const o = this.renderer.getPixelRatio();
|
|
3808
|
-
r !== o && (this.rendererController.setPixelRatio(r), (n = this.composerController) == null || n.setPixelRatio(r));
|
|
3937
|
+
r !== o && (this.rendererController.setPixelRatio(r), (n = this.composerController) == null || n.setPixelRatio(r), this.viewPadding.some((a) => a !== 0) && this.setViewPadding(...this.viewPadding));
|
|
3938
|
+
}
|
|
3939
|
+
setViewPadding(e = 0, t = 0, s = 0, i = 0) {
|
|
3940
|
+
const { width: r, height: o } = this.renderer.getSize(new B()), n = {
|
|
3941
|
+
x: i,
|
|
3942
|
+
y: s,
|
|
3943
|
+
width: r - i - t,
|
|
3944
|
+
height: o - e - s
|
|
3945
|
+
};
|
|
3946
|
+
this.rendererController.setViewport(n), this.cameraController.setAspect(n.width / n.height), this.viewPadding = [e, t, s, i];
|
|
3809
3947
|
}
|
|
3810
3948
|
pick(e, t, s = !0) {
|
|
3811
|
-
const { raycaster: i, options: r } = this, { container: o } = r, n = new B(),
|
|
3812
|
-
if (n.x = (e.clientX -
|
|
3949
|
+
const { raycaster: i, options: r } = this, { container: o } = r, n = new B(), a = o.getBoundingClientRect();
|
|
3950
|
+
if (n.x = (e.clientX - a.left) / (a.right - a.left) * 2 - 1, n.y = -((e.clientY - a.top) / (a.bottom - a.top)) * 2 + 1, this.camera && this.scene) {
|
|
3813
3951
|
i.setFromCamera(n, this.camera);
|
|
3814
|
-
const
|
|
3952
|
+
const c = i.intersectObjects(
|
|
3815
3953
|
t || this.scene.children,
|
|
3816
3954
|
s
|
|
3817
3955
|
);
|
|
3818
|
-
if (
|
|
3956
|
+
if (c.length)
|
|
3819
3957
|
return {
|
|
3820
|
-
object:
|
|
3821
|
-
index:
|
|
3822
|
-
intersects:
|
|
3958
|
+
object: c[0].object,
|
|
3959
|
+
index: c[0].index,
|
|
3960
|
+
intersects: c
|
|
3823
3961
|
};
|
|
3824
3962
|
}
|
|
3825
3963
|
}
|
|
3826
3964
|
render() {
|
|
3827
|
-
var s, i, r, o, n,
|
|
3965
|
+
var s, i, r, o, n, a;
|
|
3828
3966
|
if (!this.camera || !this.scene)
|
|
3829
3967
|
return;
|
|
3830
|
-
this.timer.update(), Ce.update();
|
|
3968
|
+
this.event.emit("beforeRender"), this.timer.update(), Ce.update();
|
|
3831
3969
|
const e = this.timer.getDelta(), t = this.timer.getElapsed();
|
|
3832
|
-
this.controlsController.update(e, t), this.leadController.update(e, t), this.installPlugins.forEach((
|
|
3833
|
-
var
|
|
3834
|
-
(
|
|
3970
|
+
this.controlsController.update(e, t), this.leadController.update(e, t), this.installPlugins.forEach((c) => {
|
|
3971
|
+
var u;
|
|
3972
|
+
(u = c.update) == null || u.call(c, e, t);
|
|
3835
3973
|
}), (s = this.helperController) == null || s.update(
|
|
3836
3974
|
e,
|
|
3837
3975
|
this.controlsController,
|
|
3838
3976
|
this.cameraTarget
|
|
3839
|
-
), (i = this.composerController) != null && i.active ? this.composerController.render() : (r = this.rendererController) == null || r.render(this.scene, this.camera), (o = this.helperController) == null || o.renderViewHelper(this.renderer), (n = this.cssRendererController) == null || n.render(this.scene, this.camera), (
|
|
3977
|
+
), (i = this.composerController) != null && i.active ? this.composerController.render() : (r = this.rendererController) == null || r.render(this.scene, this.camera), (o = this.helperController) == null || o.renderViewHelper(this.renderer), (n = this.cssRendererController) == null || n.render(this.scene, this.camera), (a = this.stats) == null || a.update(), this.event.emit("render", { delta: e, elapsed: t });
|
|
3840
3978
|
}
|
|
3841
3979
|
start() {
|
|
3842
|
-
|
|
3980
|
+
var e;
|
|
3981
|
+
window.cancelAnimationFrame(this.TweenRaf), (e = this.renderer) == null || e.setAnimationLoop(this.render.bind(this)), this.event.emit("start");
|
|
3843
3982
|
}
|
|
3844
3983
|
stop() {
|
|
3845
|
-
|
|
3984
|
+
var e;
|
|
3985
|
+
this.tweenUpdateRaf(), (e = this.renderer) == null || e.setAnimationLoop(null), this.event.emit("stop");
|
|
3846
3986
|
}
|
|
3847
3987
|
autoRotate(e) {
|
|
3848
3988
|
this.controlsController.autoRotateSpeed = e;
|
|
@@ -3874,39 +4014,39 @@ const _e = class _e {
|
|
|
3874
4014
|
}
|
|
3875
4015
|
}
|
|
3876
4016
|
dispose() {
|
|
3877
|
-
var e, t, s, i, r, o, n,
|
|
3878
|
-
this.stop(), this.timer.dispose(), Ce.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.installPlugins.forEach((
|
|
3879
|
-
var
|
|
3880
|
-
(
|
|
3881
|
-
}), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (r = this.sceneController) == null || r.dispose(), (o = this.cameraController) == null || o.dispose(), (n = this.helperController) == null || n.dispose(), (
|
|
4017
|
+
var e, t, s, i, r, o, n, a, c, u, m, v, p, f;
|
|
4018
|
+
this.stop(), this.timer.dispose(), Ce.removeAll(), this.event.removeAllListeners(), (e = this.resizeObserver) == null || e.unobserve(this.options.container), this.installPlugins.forEach((g) => {
|
|
4019
|
+
var y;
|
|
4020
|
+
(y = g.dispose) == null || y.call(g);
|
|
4021
|
+
}), (t = this.controlsController) == null || t.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (r = this.sceneController) == null || r.dispose(), (o = this.cameraController) == null || o.dispose(), (n = this.helperController) == null || n.dispose(), (a = this.composerController) == null || a.dispose(), (c = this.rendererController) == null || c.dispose(), (u = this.loaderController) == null || u.dispose(), (m = this.leadController) == null || m.dispose(), (v = this.mListController) == null || v.dispose(), this.cssRendererController = void 0, this.installPlugins.clear(), (p = this.stats) == null || p.dom.remove(), (f = this.renderer) == null || f.domElement.remove();
|
|
3882
4022
|
}
|
|
3883
4023
|
};
|
|
3884
4024
|
_e.options = {
|
|
3885
|
-
stats:
|
|
3886
|
-
helper:
|
|
3887
|
-
viewHelper:
|
|
4025
|
+
stats: he,
|
|
4026
|
+
helper: he,
|
|
4027
|
+
viewHelper: he,
|
|
3888
4028
|
controls: !0,
|
|
3889
|
-
transformControls:
|
|
3890
|
-
renderer:
|
|
3891
|
-
composer:
|
|
3892
|
-
scene:
|
|
3893
|
-
camera:
|
|
4029
|
+
transformControls: he,
|
|
4030
|
+
renderer: li,
|
|
4031
|
+
composer: Vs,
|
|
4032
|
+
scene: ci,
|
|
4033
|
+
camera: wt,
|
|
3894
4034
|
bloom: !1,
|
|
3895
|
-
bloomParams:
|
|
4035
|
+
bloomParams: Bs,
|
|
3896
4036
|
ssao: !1,
|
|
3897
|
-
loader:
|
|
3898
|
-
ssaoParams:
|
|
4037
|
+
loader: ri,
|
|
4038
|
+
ssaoParams: Hs,
|
|
3899
4039
|
css2DRenderer: !1,
|
|
3900
4040
|
css2DRendererParams: U({}, st),
|
|
3901
4041
|
css3DRenderer: !1,
|
|
3902
4042
|
css3DRendererParams: U({}, st)
|
|
3903
4043
|
};
|
|
3904
4044
|
let ot = _e;
|
|
3905
|
-
const
|
|
4045
|
+
const Gi = J.ACTION;
|
|
3906
4046
|
export {
|
|
3907
|
-
|
|
4047
|
+
ns as BaseObject,
|
|
3908
4048
|
ot as Pencil,
|
|
3909
4049
|
Pe as ResourceTracker,
|
|
3910
|
-
|
|
4050
|
+
Gi as cameraControlsAction,
|
|
3911
4051
|
ot as default
|
|
3912
4052
|
};
|