@ridp/threejs 1.4.7 → 1.5.1
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/README.md +378 -11
- package/dist/{PredictiveLoader-VyluUQ_9.js → PredictiveLoader-C9zJlZEQ.js} +853 -779
- package/dist/PredictiveLoader-Xy5S4HBr.cjs +2 -0
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +2 -2
- package/dist/{objectQuery-DV6aOB66.js → objectQuery-BfHUGPET.js} +1 -1
- package/dist/{objectQuery-E6g-_2wI.cjs → objectQuery-DNtwsgY8.cjs} +1 -1
- package/dist/threejs.cjs +2 -2
- package/dist/threejs.js +212 -169
- package/dist/{useBatchGLTFLoader-CaIsPkER.js → useBatchGLTFLoader-C1C8R5Ss.js} +1 -1
- package/dist/{useBatchGLTFLoader-DQt14QwC.cjs → useBatchGLTFLoader-DHJyQcpJ.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/PredictiveLoader-Tnm0gRZR.cjs +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as A from "three";
|
|
2
|
-
import { Controls as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
2
|
+
import { Controls as mt, Vector3 as S, MOUSE as z, TOUCH as Y, Quaternion as le, Spherical as je, Vector2 as I, Ray as gt, Plane as yt, MathUtils as st, TrianglesDrawMode as _t, TriangleFanDrawMode as Ce, TriangleStripDrawMode as nt, Loader as it, FileLoader as fe, SRGBColorSpace as $, LinearSRGBColorSpace as j, BufferGeometry as ot, BufferAttribute as oe, Color as q, ColorManagement as Pe, LoaderUtils as re, MeshPhysicalMaterial as G, SpotLight as Tt, PointLight as wt, DirectionalLight as bt, Matrix4 as se, InstancedMesh as Et, InstancedBufferAttribute as xt, Object3D as He, TextureLoader as At, ImageBitmapLoader as Rt, InterleavedBuffer as Mt, InterleavedBufferAttribute as St, LinearMipmapLinearFilter as rt, NearestMipmapLinearFilter as Lt, LinearMipmapNearestFilter as Dt, NearestMipmapNearestFilter as Ct, LinearFilter as Oe, NearestFilter as at, RepeatWrapping as Ie, MirroredRepeatWrapping as Pt, ClampToEdgeWrapping as Ot, PointsMaterial as It, Material as we, LineBasicMaterial as kt, MeshStandardMaterial as ct, DoubleSide as Nt, MeshBasicMaterial as ie, PropertyBinding as vt, SkinnedMesh as Ht, Mesh as Ft, LineSegments as Ut, Line as jt, LineLoop as Gt, Points as Bt, Group as be, PerspectiveCamera as zt, OrthographicCamera as Kt, Skeleton as Wt, AnimationClip as Vt, Bone as Xt, InterpolateDiscrete as Yt, InterpolateLinear as lt, Texture as Ge, VectorKeyframeTrack as Be, NumberKeyframeTrack as ze, QuaternionKeyframeTrack as Ke, FrontSide as $t, Interpolant as qt, Box3 as Zt, Sphere as Qt, CameraHelper as Jt, GridHelper as es, BoxHelper as ts, Raycaster as ss, AxesHelper as ns, ArrowHelper as is } from "three";
|
|
3
|
+
import os from "dexie";
|
|
4
|
+
const We = { type: "change" }, Fe = { type: "start" }, ht = { type: "end" }, ue = new gt(), Ve = new yt(), rs = Math.cos(70 * st.DEG2RAD), L = new S(), O = 2 * Math.PI, R = {
|
|
5
5
|
NONE: -1,
|
|
6
6
|
ROTATE: 0,
|
|
7
7
|
DOLLY: 1,
|
|
@@ -10,8 +10,8 @@ const Ke = { type: "change" }, He = { type: "start" }, ut = { type: "end" }, ue
|
|
|
10
10
|
TOUCH_PAN: 4,
|
|
11
11
|
TOUCH_DOLLY_PAN: 5,
|
|
12
12
|
TOUCH_DOLLY_ROTATE: 6
|
|
13
|
-
},
|
|
14
|
-
class
|
|
13
|
+
}, Ee = 1e-6;
|
|
14
|
+
class ut extends mt {
|
|
15
15
|
/**
|
|
16
16
|
* Constructs a new controls instance.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ class dt extends gt {
|
|
|
19
19
|
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
20
20
|
*/
|
|
21
21
|
constructor(e, t = null) {
|
|
22
|
-
super(e, t), this.state = R.NONE, this.target = new S(), this.cursor = new S(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT:
|
|
22
|
+
super(e, t), this.state = R.NONE, this.target = new S(), this.cursor = new S(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: z.ROTATE, MIDDLE: z.DOLLY, RIGHT: z.PAN }, this.touches = { ONE: Y.ROTATE, TWO: Y.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new S(), this._lastQuaternion = new le(), this._lastTargetPosition = new S(), this._quat = new le().setFromUnitVectors(e.up, new S(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new je(), this._sphericalDelta = new je(), this._scale = 1, this._panOffset = new S(), this._rotateStart = new I(), this._rotateEnd = new I(), this._rotateDelta = new I(), this._panStart = new I(), this._panEnd = new I(), this._panDelta = new I(), this._dollyStart = new I(), this._dollyEnd = new I(), this._dollyDelta = new I(), this._dollyDirection = new S(), this._mouse = new I(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = cs.bind(this), this._onPointerDown = as.bind(this), this._onPointerUp = ls.bind(this), this._onContextMenu = gs.bind(this), this._onMouseWheel = ds.bind(this), this._onKeyDown = fs.bind(this), this._onTouchStart = ps.bind(this), this._onTouchMove = ms.bind(this), this._onMouseDown = hs.bind(this), this._onMouseMove = us.bind(this), this._interceptControlDown = ys.bind(this), this._interceptControlUp = _s.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
23
23
|
}
|
|
24
24
|
connect(e) {
|
|
25
25
|
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
|
|
@@ -80,42 +80,42 @@ class dt extends gt {
|
|
|
80
80
|
* was called, or the initial state.
|
|
81
81
|
*/
|
|
82
82
|
reset() {
|
|
83
|
-
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(
|
|
83
|
+
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(We), this.update(), this.state = R.NONE;
|
|
84
84
|
}
|
|
85
85
|
update(e = null) {
|
|
86
86
|
const t = this.object.position;
|
|
87
87
|
L.copy(t).sub(this.target), L.applyQuaternion(this._quat), this._spherical.setFromVector3(L), this.autoRotate && this.state === R.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
|
|
88
88
|
let n = this.minAzimuthAngle, s = this.maxAzimuthAngle;
|
|
89
89
|
isFinite(n) && isFinite(s) && (n < -Math.PI ? n += O : n > Math.PI && (n -= O), s < -Math.PI ? s += O : s > Math.PI && (s -= O), n <= s ? this._spherical.theta = Math.max(n, Math.min(s, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + s) / 2 ? Math.max(n, this._spherical.theta) : Math.min(s, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
|
|
90
|
-
let
|
|
90
|
+
let o = !1;
|
|
91
91
|
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
|
|
92
92
|
this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
93
93
|
else {
|
|
94
|
-
const
|
|
95
|
-
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale),
|
|
94
|
+
const i = this._spherical.radius;
|
|
95
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), o = i != this._spherical.radius;
|
|
96
96
|
}
|
|
97
97
|
if (L.setFromSpherical(this._spherical), L.applyQuaternion(this._quatInverse), t.copy(this.target).add(L), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
|
|
98
|
-
let
|
|
98
|
+
let i = null;
|
|
99
99
|
if (this.object.isPerspectiveCamera) {
|
|
100
100
|
const c = L.length();
|
|
101
|
-
|
|
102
|
-
const a = c -
|
|
103
|
-
this.object.position.addScaledVector(this._dollyDirection, a), this.object.updateMatrixWorld(),
|
|
101
|
+
i = this._clampDistance(c * this._scale);
|
|
102
|
+
const a = c - i;
|
|
103
|
+
this.object.position.addScaledVector(this._dollyDirection, a), this.object.updateMatrixWorld(), o = !!a;
|
|
104
104
|
} else if (this.object.isOrthographicCamera) {
|
|
105
105
|
const c = new S(this._mouse.x, this._mouse.y, 0);
|
|
106
106
|
c.unproject(this.object);
|
|
107
107
|
const a = this.object.zoom;
|
|
108
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(),
|
|
108
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), o = a !== this.object.zoom;
|
|
109
109
|
const l = new S(this._mouse.x, this._mouse.y, 0);
|
|
110
|
-
l.unproject(this.object), this.object.position.sub(l).add(c), this.object.updateMatrixWorld(),
|
|
110
|
+
l.unproject(this.object), this.object.position.sub(l).add(c), this.object.updateMatrixWorld(), i = L.length();
|
|
111
111
|
} else
|
|
112
112
|
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
|
|
113
|
-
|
|
113
|
+
i !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(i).add(this.object.position) : (ue.origin.copy(this.object.position), ue.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(ue.direction)) < rs ? this.object.lookAt(this.target) : (Ve.setFromNormalAndCoplanarPoint(this.object.up, this.target), ue.intersectPlane(Ve, this.target))));
|
|
114
114
|
} else if (this.object.isOrthographicCamera) {
|
|
115
|
-
const
|
|
116
|
-
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)),
|
|
115
|
+
const i = this.object.zoom;
|
|
116
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), i !== this.object.zoom && (this.object.updateProjectionMatrix(), o = !0);
|
|
117
117
|
}
|
|
118
|
-
return this._scale = 1, this._performCursorZoom = !1,
|
|
118
|
+
return this._scale = 1, this._performCursorZoom = !1, o || this._lastPosition.distanceToSquared(this.object.position) > Ee || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Ee || this._lastTargetPosition.distanceToSquared(this.target) > Ee ? (this.dispatchEvent(We), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
|
|
119
119
|
}
|
|
120
120
|
_getAutoRotationAngle(e) {
|
|
121
121
|
return e !== null ? O / 60 * this.autoRotateSpeed * e : O / 60 / 60 * this.autoRotateSpeed;
|
|
@@ -142,8 +142,8 @@ class dt extends gt {
|
|
|
142
142
|
if (this.object.isPerspectiveCamera) {
|
|
143
143
|
const s = this.object.position;
|
|
144
144
|
L.copy(s).sub(this.target);
|
|
145
|
-
let
|
|
146
|
-
|
|
145
|
+
let o = L.length();
|
|
146
|
+
o *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * o / n.clientHeight, this.object.matrix), this._panUp(2 * t * o / n.clientHeight, this.object.matrix);
|
|
147
147
|
} else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
|
|
148
148
|
}
|
|
149
149
|
_dollyOut(e) {
|
|
@@ -156,8 +156,8 @@ class dt extends gt {
|
|
|
156
156
|
if (!this.zoomToCursor)
|
|
157
157
|
return;
|
|
158
158
|
this._performCursorZoom = !0;
|
|
159
|
-
const n = this.domElement.getBoundingClientRect(), s = e - n.left,
|
|
160
|
-
this._mouse.x = s /
|
|
159
|
+
const n = this.domElement.getBoundingClientRect(), s = e - n.left, o = t - n.top, i = n.width, c = n.height;
|
|
160
|
+
this._mouse.x = s / i * 2 - 1, this._mouse.y = -(o / c) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
161
161
|
}
|
|
162
162
|
_clampDistance(e) {
|
|
163
163
|
return Math.max(this.minDistance, Math.min(this.maxDistance, e));
|
|
@@ -223,8 +223,8 @@ class dt extends gt {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
_handleTouchStartDolly(e) {
|
|
226
|
-
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y,
|
|
227
|
-
this._dollyStart.set(0,
|
|
226
|
+
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, o = Math.sqrt(n * n + s * s);
|
|
227
|
+
this._dollyStart.set(0, o);
|
|
228
228
|
}
|
|
229
229
|
_handleTouchStartDollyPan(e) {
|
|
230
230
|
this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
|
|
@@ -236,8 +236,8 @@ class dt extends gt {
|
|
|
236
236
|
if (this._pointers.length == 1)
|
|
237
237
|
this._rotateEnd.set(e.pageX, e.pageY);
|
|
238
238
|
else {
|
|
239
|
-
const n = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + n.x),
|
|
240
|
-
this._rotateEnd.set(s,
|
|
239
|
+
const n = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + n.x), o = 0.5 * (e.pageY + n.y);
|
|
240
|
+
this._rotateEnd.set(s, o);
|
|
241
241
|
}
|
|
242
242
|
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
243
243
|
const t = this.domElement;
|
|
@@ -253,10 +253,10 @@ class dt extends gt {
|
|
|
253
253
|
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
|
|
254
254
|
}
|
|
255
255
|
_handleTouchMoveDolly(e) {
|
|
256
|
-
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y,
|
|
257
|
-
this._dollyEnd.set(0,
|
|
258
|
-
const
|
|
259
|
-
this._updateZoomParameters(
|
|
256
|
+
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, o = Math.sqrt(n * n + s * s);
|
|
257
|
+
this._dollyEnd.set(0, o), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
|
|
258
|
+
const i = (e.pageX + t.x) * 0.5, c = (e.pageY + t.y) * 0.5;
|
|
259
|
+
this._updateZoomParameters(i, c);
|
|
260
260
|
}
|
|
261
261
|
_handleTouchMoveDollyPan(e) {
|
|
262
262
|
this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
|
|
@@ -283,7 +283,7 @@ class dt extends gt {
|
|
|
283
283
|
}
|
|
284
284
|
_trackPointer(e) {
|
|
285
285
|
let t = this._pointerPositions[e.pointerId];
|
|
286
|
-
t === void 0 && (t = new
|
|
286
|
+
t === void 0 && (t = new I(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
|
|
287
287
|
}
|
|
288
288
|
_getSecondPointerPosition(e) {
|
|
289
289
|
const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
@@ -307,16 +307,16 @@ class dt extends gt {
|
|
|
307
307
|
return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function as(r) {
|
|
311
311
|
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(r.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(r) && (this._addPointer(r), r.pointerType === "touch" ? this._onTouchStart(r) : this._onMouseDown(r)));
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function cs(r) {
|
|
314
314
|
this.enabled !== !1 && (r.pointerType === "touch" ? this._onTouchMove(r) : this._onMouseMove(r));
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function ls(r) {
|
|
317
317
|
switch (this._removePointer(r), this._pointers.length) {
|
|
318
318
|
case 0:
|
|
319
|
-
this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(
|
|
319
|
+
this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(ht), this.state = R.NONE;
|
|
320
320
|
break;
|
|
321
321
|
case 1:
|
|
322
322
|
const e = this._pointers[0], t = this._pointerPositions[e];
|
|
@@ -324,7 +324,7 @@ function hs(r) {
|
|
|
324
324
|
break;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
function
|
|
327
|
+
function hs(r) {
|
|
328
328
|
let e;
|
|
329
329
|
switch (r.button) {
|
|
330
330
|
case 0:
|
|
@@ -340,11 +340,11 @@ function us(r) {
|
|
|
340
340
|
e = -1;
|
|
341
341
|
}
|
|
342
342
|
switch (e) {
|
|
343
|
-
case
|
|
343
|
+
case z.DOLLY:
|
|
344
344
|
if (this.enableZoom === !1) return;
|
|
345
345
|
this._handleMouseDownDolly(r), this.state = R.DOLLY;
|
|
346
346
|
break;
|
|
347
|
-
case
|
|
347
|
+
case z.ROTATE:
|
|
348
348
|
if (r.ctrlKey || r.metaKey || r.shiftKey) {
|
|
349
349
|
if (this.enablePan === !1) return;
|
|
350
350
|
this._handleMouseDownPan(r), this.state = R.PAN;
|
|
@@ -353,7 +353,7 @@ function us(r) {
|
|
|
353
353
|
this._handleMouseDownRotate(r), this.state = R.ROTATE;
|
|
354
354
|
}
|
|
355
355
|
break;
|
|
356
|
-
case
|
|
356
|
+
case z.PAN:
|
|
357
357
|
if (r.ctrlKey || r.metaKey || r.shiftKey) {
|
|
358
358
|
if (this.enableRotate === !1) return;
|
|
359
359
|
this._handleMouseDownRotate(r), this.state = R.ROTATE;
|
|
@@ -365,9 +365,9 @@ function us(r) {
|
|
|
365
365
|
default:
|
|
366
366
|
this.state = R.NONE;
|
|
367
367
|
}
|
|
368
|
-
this.state !== R.NONE && this.dispatchEvent(
|
|
368
|
+
this.state !== R.NONE && this.dispatchEvent(Fe);
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function us(r) {
|
|
371
371
|
switch (this.state) {
|
|
372
372
|
case R.ROTATE:
|
|
373
373
|
if (this.enableRotate === !1) return;
|
|
@@ -383,21 +383,21 @@ function ds(r) {
|
|
|
383
383
|
break;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
function
|
|
387
|
-
this.enabled === !1 || this.enableZoom === !1 || this.state !== R.NONE || (r.preventDefault(), this.dispatchEvent(
|
|
386
|
+
function ds(r) {
|
|
387
|
+
this.enabled === !1 || this.enableZoom === !1 || this.state !== R.NONE || (r.preventDefault(), this.dispatchEvent(Fe), this._handleMouseWheel(this._customWheelEvent(r)), this.dispatchEvent(ht));
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function fs(r) {
|
|
390
390
|
this.enabled !== !1 && this._handleKeyDown(r);
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function ps(r) {
|
|
393
393
|
switch (this._trackPointer(r), this._pointers.length) {
|
|
394
394
|
case 1:
|
|
395
395
|
switch (this.touches.ONE) {
|
|
396
|
-
case
|
|
396
|
+
case Y.ROTATE:
|
|
397
397
|
if (this.enableRotate === !1) return;
|
|
398
398
|
this._handleTouchStartRotate(r), this.state = R.TOUCH_ROTATE;
|
|
399
399
|
break;
|
|
400
|
-
case
|
|
400
|
+
case Y.PAN:
|
|
401
401
|
if (this.enablePan === !1) return;
|
|
402
402
|
this._handleTouchStartPan(r), this.state = R.TOUCH_PAN;
|
|
403
403
|
break;
|
|
@@ -407,11 +407,11 @@ function ms(r) {
|
|
|
407
407
|
break;
|
|
408
408
|
case 2:
|
|
409
409
|
switch (this.touches.TWO) {
|
|
410
|
-
case
|
|
410
|
+
case Y.DOLLY_PAN:
|
|
411
411
|
if (this.enableZoom === !1 && this.enablePan === !1) return;
|
|
412
412
|
this._handleTouchStartDollyPan(r), this.state = R.TOUCH_DOLLY_PAN;
|
|
413
413
|
break;
|
|
414
|
-
case
|
|
414
|
+
case Y.DOLLY_ROTATE:
|
|
415
415
|
if (this.enableZoom === !1 && this.enableRotate === !1) return;
|
|
416
416
|
this._handleTouchStartDollyRotate(r), this.state = R.TOUCH_DOLLY_ROTATE;
|
|
417
417
|
break;
|
|
@@ -422,9 +422,9 @@ function ms(r) {
|
|
|
422
422
|
default:
|
|
423
423
|
this.state = R.NONE;
|
|
424
424
|
}
|
|
425
|
-
this.state !== R.NONE && this.dispatchEvent(
|
|
425
|
+
this.state !== R.NONE && this.dispatchEvent(Fe);
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function ms(r) {
|
|
428
428
|
switch (this._trackPointer(r), this.state) {
|
|
429
429
|
case R.TOUCH_ROTATE:
|
|
430
430
|
if (this.enableRotate === !1) return;
|
|
@@ -446,49 +446,49 @@ function gs(r) {
|
|
|
446
446
|
this.state = R.NONE;
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function gs(r) {
|
|
450
450
|
this.enabled !== !1 && r.preventDefault();
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function ys(r) {
|
|
453
453
|
r.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function _s(r) {
|
|
456
456
|
r.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
|
|
457
457
|
}
|
|
458
|
-
class
|
|
458
|
+
class Ts extends ut {
|
|
459
459
|
constructor(e, t) {
|
|
460
|
-
super(e, t), this.screenSpacePanning = !1, this.mouseButtons = { LEFT:
|
|
460
|
+
super(e, t), this.screenSpacePanning = !1, this.mouseButtons = { LEFT: z.PAN, MIDDLE: z.DOLLY, RIGHT: z.ROTATE }, this.touches = { ONE: Y.PAN, TWO: Y.DOLLY_ROTATE };
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
function Xe(r, e) {
|
|
464
|
-
if (e ===
|
|
464
|
+
if (e === _t)
|
|
465
465
|
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), r;
|
|
466
|
-
if (e ===
|
|
466
|
+
if (e === Ce || e === nt) {
|
|
467
467
|
let t = r.getIndex();
|
|
468
468
|
if (t === null) {
|
|
469
|
-
const
|
|
469
|
+
const i = [], c = r.getAttribute("position");
|
|
470
470
|
if (c !== void 0) {
|
|
471
471
|
for (let a = 0; a < c.count; a++)
|
|
472
|
-
|
|
473
|
-
r.setIndex(
|
|
472
|
+
i.push(a);
|
|
473
|
+
r.setIndex(i), t = r.getIndex();
|
|
474
474
|
} else
|
|
475
475
|
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), r;
|
|
476
476
|
}
|
|
477
477
|
const n = t.count - 2, s = [];
|
|
478
|
-
if (e ===
|
|
479
|
-
for (let
|
|
480
|
-
s.push(t.getX(0)), s.push(t.getX(
|
|
478
|
+
if (e === Ce)
|
|
479
|
+
for (let i = 1; i <= n; i++)
|
|
480
|
+
s.push(t.getX(0)), s.push(t.getX(i)), s.push(t.getX(i + 1));
|
|
481
481
|
else
|
|
482
|
-
for (let
|
|
483
|
-
|
|
482
|
+
for (let i = 0; i < n; i++)
|
|
483
|
+
i % 2 === 0 ? (s.push(t.getX(i)), s.push(t.getX(i + 1)), s.push(t.getX(i + 2))) : (s.push(t.getX(i + 2)), s.push(t.getX(i + 1)), s.push(t.getX(i)));
|
|
484
484
|
s.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
485
|
-
const
|
|
486
|
-
return
|
|
485
|
+
const o = r.clone();
|
|
486
|
+
return o.setIndex(s), o.clearGroups(), o;
|
|
487
487
|
} else
|
|
488
488
|
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), r;
|
|
489
489
|
}
|
|
490
|
-
const
|
|
491
|
-
class
|
|
490
|
+
const xe = /* @__PURE__ */ new WeakMap();
|
|
491
|
+
class ws extends it {
|
|
492
492
|
/**
|
|
493
493
|
* Constructs a new Draco loader.
|
|
494
494
|
*
|
|
@@ -545,9 +545,9 @@ class bs extends ot {
|
|
|
545
545
|
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
546
546
|
*/
|
|
547
547
|
load(e, t, n, s) {
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
this.parse(
|
|
548
|
+
const o = new fe(this.manager);
|
|
549
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, (i) => {
|
|
550
|
+
this.parse(i, t, s);
|
|
551
551
|
}, n, s);
|
|
552
552
|
}
|
|
553
553
|
/**
|
|
@@ -559,23 +559,23 @@ class bs extends ot {
|
|
|
559
559
|
*/
|
|
560
560
|
parse(e, t, n = () => {
|
|
561
561
|
}) {
|
|
562
|
-
this.decodeDracoFile(e, t, null, null,
|
|
562
|
+
this.decodeDracoFile(e, t, null, null, $, n).catch(n);
|
|
563
563
|
}
|
|
564
564
|
//
|
|
565
|
-
decodeDracoFile(e, t, n, s,
|
|
565
|
+
decodeDracoFile(e, t, n, s, o = j, i = () => {
|
|
566
566
|
}) {
|
|
567
567
|
const c = {
|
|
568
568
|
attributeIDs: n || this.defaultAttributeIDs,
|
|
569
569
|
attributeTypes: s || this.defaultAttributeTypes,
|
|
570
570
|
useUniqueIDs: !!n,
|
|
571
|
-
vertexColorSpace:
|
|
571
|
+
vertexColorSpace: o
|
|
572
572
|
};
|
|
573
|
-
return this.decodeGeometry(e, c).then(t).catch(
|
|
573
|
+
return this.decodeGeometry(e, c).then(t).catch(i);
|
|
574
574
|
}
|
|
575
575
|
decodeGeometry(e, t) {
|
|
576
576
|
const n = JSON.stringify(t);
|
|
577
|
-
if (
|
|
578
|
-
const a =
|
|
577
|
+
if (xe.has(e)) {
|
|
578
|
+
const a = xe.get(e);
|
|
579
579
|
if (a.key === n)
|
|
580
580
|
return a.promise;
|
|
581
581
|
if (e.byteLength === 0)
|
|
@@ -584,35 +584,35 @@ class bs extends ot {
|
|
|
584
584
|
);
|
|
585
585
|
}
|
|
586
586
|
let s;
|
|
587
|
-
const
|
|
588
|
-
s._callbacks[
|
|
587
|
+
const o = this.workerNextTaskID++, i = e.byteLength, c = this._getWorker(o, i).then((a) => (s = a, new Promise((l, u) => {
|
|
588
|
+
s._callbacks[o] = { resolve: l, reject: u }, s.postMessage({ type: "decode", id: o, taskConfig: t, buffer: e }, [e]);
|
|
589
589
|
}))).then((a) => this._createGeometry(a.geometry));
|
|
590
590
|
return c.catch(() => !0).then(() => {
|
|
591
|
-
s &&
|
|
592
|
-
}),
|
|
591
|
+
s && o && this._releaseTask(s, o);
|
|
592
|
+
}), xe.set(e, {
|
|
593
593
|
key: n,
|
|
594
594
|
promise: c
|
|
595
595
|
}), c;
|
|
596
596
|
}
|
|
597
597
|
_createGeometry(e) {
|
|
598
|
-
const t = new
|
|
598
|
+
const t = new ot();
|
|
599
599
|
e.index && t.setIndex(new oe(e.index.array, 1));
|
|
600
600
|
for (let n = 0; n < e.attributes.length; n++) {
|
|
601
|
-
const s = e.attributes[n],
|
|
602
|
-
|
|
601
|
+
const s = e.attributes[n], o = s.name, i = s.array, c = s.itemSize, a = new oe(i, c);
|
|
602
|
+
o === "color" && (this._assignVertexColorSpace(a, s.vertexColorSpace), a.normalized = !(i instanceof Float32Array)), t.setAttribute(o, a);
|
|
603
603
|
}
|
|
604
604
|
return t;
|
|
605
605
|
}
|
|
606
606
|
_assignVertexColorSpace(e, t) {
|
|
607
|
-
if (t !==
|
|
607
|
+
if (t !== $) return;
|
|
608
608
|
const n = new q();
|
|
609
|
-
for (let s = 0,
|
|
610
|
-
n.fromBufferAttribute(e, s),
|
|
609
|
+
for (let s = 0, o = e.count; s < o; s++)
|
|
610
|
+
n.fromBufferAttribute(e, s), Pe.colorSpaceToWorking(n, $), e.setXYZ(s, n.r, n.g, n.b);
|
|
611
611
|
}
|
|
612
612
|
_loadLibrary(e, t) {
|
|
613
|
-
const n = new
|
|
614
|
-
return n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((s,
|
|
615
|
-
n.load(e, s, void 0,
|
|
613
|
+
const n = new fe(this.manager);
|
|
614
|
+
return n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((s, o) => {
|
|
615
|
+
n.load(e, s, void 0, o);
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
preload() {
|
|
@@ -624,37 +624,37 @@ class bs extends ot {
|
|
|
624
624
|
return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((n) => {
|
|
625
625
|
const s = n[0];
|
|
626
626
|
e || (this.decoderConfig.wasmBinary = n[1]);
|
|
627
|
-
const
|
|
627
|
+
const o = bs.toString(), i = [
|
|
628
628
|
"/* draco decoder */",
|
|
629
629
|
s,
|
|
630
630
|
"",
|
|
631
631
|
"/* worker */",
|
|
632
|
-
|
|
632
|
+
o.substring(o.indexOf("{") + 1, o.lastIndexOf("}"))
|
|
633
633
|
].join(`
|
|
634
634
|
`);
|
|
635
|
-
this.workerSourceURL = URL.createObjectURL(new Blob([
|
|
635
|
+
this.workerSourceURL = URL.createObjectURL(new Blob([i]));
|
|
636
636
|
}), this.decoderPending;
|
|
637
637
|
}
|
|
638
638
|
_getWorker(e, t) {
|
|
639
639
|
return this._initDecoder().then(() => {
|
|
640
640
|
if (this.workerPool.length < this.workerLimit) {
|
|
641
641
|
const s = new Worker(this.workerSourceURL);
|
|
642
|
-
s._callbacks = {}, s._taskCosts = {}, s._taskLoad = 0, s.postMessage({ type: "init", decoderConfig: this.decoderConfig }), s.onmessage = function(
|
|
643
|
-
const
|
|
644
|
-
switch (
|
|
642
|
+
s._callbacks = {}, s._taskCosts = {}, s._taskLoad = 0, s.postMessage({ type: "init", decoderConfig: this.decoderConfig }), s.onmessage = function(o) {
|
|
643
|
+
const i = o.data;
|
|
644
|
+
switch (i.type) {
|
|
645
645
|
case "decode":
|
|
646
|
-
s._callbacks[
|
|
646
|
+
s._callbacks[i.id].resolve(i);
|
|
647
647
|
break;
|
|
648
648
|
case "error":
|
|
649
|
-
s._callbacks[
|
|
649
|
+
s._callbacks[i.id].reject(i);
|
|
650
650
|
break;
|
|
651
651
|
default:
|
|
652
|
-
console.error('THREE.DRACOLoader: Unexpected message, "' +
|
|
652
|
+
console.error('THREE.DRACOLoader: Unexpected message, "' + i.type + '"');
|
|
653
653
|
}
|
|
654
654
|
}, this.workerPool.push(s);
|
|
655
655
|
} else
|
|
656
|
-
this.workerPool.sort(function(s,
|
|
657
|
-
return s._taskLoad >
|
|
656
|
+
this.workerPool.sort(function(s, o) {
|
|
657
|
+
return s._taskLoad > o._taskLoad ? -1 : 1;
|
|
658
658
|
});
|
|
659
659
|
const n = this.workerPool[this.workerPool.length - 1];
|
|
660
660
|
return n._taskCosts[e] = t, n._taskLoad += t, n;
|
|
@@ -672,10 +672,10 @@ class bs extends ot {
|
|
|
672
672
|
return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function bs() {
|
|
676
676
|
let r, e;
|
|
677
|
-
onmessage = function(
|
|
678
|
-
const c =
|
|
677
|
+
onmessage = function(i) {
|
|
678
|
+
const c = i.data;
|
|
679
679
|
switch (c.type) {
|
|
680
680
|
case "init":
|
|
681
681
|
r = c.decoderConfig, e = new Promise(function(u) {
|
|
@@ -700,14 +700,14 @@ function Es() {
|
|
|
700
700
|
break;
|
|
701
701
|
}
|
|
702
702
|
};
|
|
703
|
-
function t(
|
|
703
|
+
function t(i, c, a, l) {
|
|
704
704
|
const u = l.attributeIDs, h = l.attributeTypes;
|
|
705
705
|
let p, m;
|
|
706
706
|
const _ = c.GetEncodedGeometryType(a);
|
|
707
|
-
if (_ ===
|
|
708
|
-
p = new
|
|
709
|
-
else if (_ ===
|
|
710
|
-
p = new
|
|
707
|
+
if (_ === i.TRIANGULAR_MESH)
|
|
708
|
+
p = new i.Mesh(), m = c.DecodeArrayToMesh(a, a.byteLength, p);
|
|
709
|
+
else if (_ === i.POINT_CLOUD)
|
|
710
|
+
p = new i.PointCloud(), m = c.DecodeArrayToPointCloud(a, a.byteLength, p);
|
|
711
711
|
else
|
|
712
712
|
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
|
713
713
|
if (!m.ok() || p.ptr === 0)
|
|
@@ -719,50 +719,50 @@ function Es() {
|
|
|
719
719
|
if (l.useUniqueIDs)
|
|
720
720
|
T = u[d], g = c.GetAttributeByUniqueId(p, T);
|
|
721
721
|
else {
|
|
722
|
-
if (T = c.GetAttributeId(p,
|
|
722
|
+
if (T = c.GetAttributeId(p, i[u[d]]), T === -1) continue;
|
|
723
723
|
g = c.GetAttribute(p, T);
|
|
724
724
|
}
|
|
725
|
-
const y = s(
|
|
725
|
+
const y = s(i, c, p, d, f, g);
|
|
726
726
|
d === "color" && (y.vertexColorSpace = l.vertexColorSpace), w.attributes.push(y);
|
|
727
727
|
}
|
|
728
|
-
return _ ===
|
|
728
|
+
return _ === i.TRIANGULAR_MESH && (w.index = n(i, c, p)), i.destroy(p), w;
|
|
729
729
|
}
|
|
730
|
-
function n(
|
|
731
|
-
const u = a.num_faces() * 3, h = u * 4, p =
|
|
730
|
+
function n(i, c, a) {
|
|
731
|
+
const u = a.num_faces() * 3, h = u * 4, p = i._malloc(h);
|
|
732
732
|
c.GetTrianglesUInt32Array(a, h, p);
|
|
733
|
-
const m = new Uint32Array(
|
|
734
|
-
return
|
|
733
|
+
const m = new Uint32Array(i.HEAPF32.buffer, p, u).slice();
|
|
734
|
+
return i._free(p), { array: m, itemSize: 1 };
|
|
735
735
|
}
|
|
736
|
-
function s(
|
|
737
|
-
const p = h.num_components(), _ = a.num_points() * p, w = _ * u.BYTES_PER_ELEMENT, d = i
|
|
736
|
+
function s(i, c, a, l, u, h) {
|
|
737
|
+
const p = h.num_components(), _ = a.num_points() * p, w = _ * u.BYTES_PER_ELEMENT, d = o(i, u), f = i._malloc(w);
|
|
738
738
|
c.GetAttributeDataArrayForAllPoints(a, h, d, w, f);
|
|
739
|
-
const g = new u(
|
|
740
|
-
return
|
|
739
|
+
const g = new u(i.HEAPF32.buffer, f, _).slice();
|
|
740
|
+
return i._free(f), {
|
|
741
741
|
name: l,
|
|
742
742
|
array: g,
|
|
743
743
|
itemSize: p
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
|
-
function i
|
|
746
|
+
function o(i, c) {
|
|
747
747
|
switch (c) {
|
|
748
748
|
case Float32Array:
|
|
749
|
-
return
|
|
749
|
+
return i.DT_FLOAT32;
|
|
750
750
|
case Int8Array:
|
|
751
|
-
return
|
|
751
|
+
return i.DT_INT8;
|
|
752
752
|
case Int16Array:
|
|
753
|
-
return
|
|
753
|
+
return i.DT_INT16;
|
|
754
754
|
case Int32Array:
|
|
755
|
-
return
|
|
755
|
+
return i.DT_INT32;
|
|
756
756
|
case Uint8Array:
|
|
757
|
-
return
|
|
757
|
+
return i.DT_UINT8;
|
|
758
758
|
case Uint16Array:
|
|
759
|
-
return
|
|
759
|
+
return i.DT_UINT16;
|
|
760
760
|
case Uint32Array:
|
|
761
|
-
return
|
|
761
|
+
return i.DT_UINT32;
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
class
|
|
765
|
+
class Es extends it {
|
|
766
766
|
/**
|
|
767
767
|
* Constructs a new glTF loader.
|
|
768
768
|
*
|
|
@@ -770,39 +770,39 @@ class xs extends ot {
|
|
|
770
770
|
*/
|
|
771
771
|
constructor(e) {
|
|
772
772
|
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
773
|
+
return new Ss(t);
|
|
774
|
+
}), this.register(function(t) {
|
|
773
775
|
return new Ls(t);
|
|
774
776
|
}), this.register(function(t) {
|
|
775
|
-
return new
|
|
777
|
+
return new Hs(t);
|
|
776
778
|
}), this.register(function(t) {
|
|
777
779
|
return new Fs(t);
|
|
778
780
|
}), this.register(function(t) {
|
|
779
781
|
return new Us(t);
|
|
780
|
-
}), this.register(function(t) {
|
|
781
|
-
return new js(t);
|
|
782
782
|
}), this.register(function(t) {
|
|
783
783
|
return new Cs(t);
|
|
784
784
|
}), this.register(function(t) {
|
|
785
|
-
return new
|
|
785
|
+
return new Ps(t);
|
|
786
786
|
}), this.register(function(t) {
|
|
787
|
-
return new
|
|
787
|
+
return new Os(t);
|
|
788
788
|
}), this.register(function(t) {
|
|
789
789
|
return new Is(t);
|
|
790
790
|
}), this.register(function(t) {
|
|
791
|
-
return new
|
|
791
|
+
return new Ms(t);
|
|
792
792
|
}), this.register(function(t) {
|
|
793
|
-
return new
|
|
793
|
+
return new ks(t);
|
|
794
794
|
}), this.register(function(t) {
|
|
795
795
|
return new Ds(t);
|
|
796
|
-
}), this.register(function(t) {
|
|
797
|
-
return new Hs(t);
|
|
798
796
|
}), this.register(function(t) {
|
|
799
797
|
return new vs(t);
|
|
800
798
|
}), this.register(function(t) {
|
|
801
|
-
return new
|
|
799
|
+
return new Ns(t);
|
|
802
800
|
}), this.register(function(t) {
|
|
803
|
-
return new
|
|
801
|
+
return new As(t);
|
|
804
802
|
}), this.register(function(t) {
|
|
805
|
-
return new
|
|
803
|
+
return new js(t);
|
|
804
|
+
}), this.register(function(t) {
|
|
805
|
+
return new Gs(t);
|
|
806
806
|
});
|
|
807
807
|
}
|
|
808
808
|
/**
|
|
@@ -815,23 +815,23 @@ class xs extends ot {
|
|
|
815
815
|
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
816
816
|
*/
|
|
817
817
|
load(e, t, n, s) {
|
|
818
|
-
const
|
|
819
|
-
let
|
|
818
|
+
const o = this;
|
|
819
|
+
let i;
|
|
820
820
|
if (this.resourcePath !== "")
|
|
821
|
-
|
|
821
|
+
i = this.resourcePath;
|
|
822
822
|
else if (this.path !== "") {
|
|
823
823
|
const l = re.extractUrlBase(e);
|
|
824
|
-
|
|
824
|
+
i = re.resolveURL(l, this.path);
|
|
825
825
|
} else
|
|
826
|
-
|
|
826
|
+
i = re.extractUrlBase(e);
|
|
827
827
|
this.manager.itemStart(e);
|
|
828
828
|
const c = function(l) {
|
|
829
|
-
s ? s(l) : console.error(l),
|
|
830
|
-
}, a = new
|
|
829
|
+
s ? s(l) : console.error(l), o.manager.itemError(e), o.manager.itemEnd(e);
|
|
830
|
+
}, a = new fe(this.manager);
|
|
831
831
|
a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(l) {
|
|
832
832
|
try {
|
|
833
|
-
|
|
834
|
-
t(u),
|
|
833
|
+
o.parse(l, i, function(u) {
|
|
834
|
+
t(u), o.manager.itemEnd(e);
|
|
835
835
|
}, c);
|
|
836
836
|
} catch (u) {
|
|
837
837
|
c(u);
|
|
@@ -897,28 +897,28 @@ class xs extends ot {
|
|
|
897
897
|
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
898
898
|
*/
|
|
899
899
|
parse(e, t, n, s) {
|
|
900
|
-
let
|
|
901
|
-
const
|
|
900
|
+
let o;
|
|
901
|
+
const i = {}, c = {}, a = new TextDecoder();
|
|
902
902
|
if (typeof e == "string")
|
|
903
|
-
|
|
903
|
+
o = JSON.parse(e);
|
|
904
904
|
else if (e instanceof ArrayBuffer)
|
|
905
|
-
if (a.decode(new Uint8Array(e, 0, 4)) ===
|
|
905
|
+
if (a.decode(new Uint8Array(e, 0, 4)) === dt) {
|
|
906
906
|
try {
|
|
907
|
-
|
|
907
|
+
i[b.KHR_BINARY_GLTF] = new Bs(e);
|
|
908
908
|
} catch (h) {
|
|
909
909
|
s && s(h);
|
|
910
910
|
return;
|
|
911
911
|
}
|
|
912
|
-
|
|
912
|
+
o = JSON.parse(i[b.KHR_BINARY_GLTF].content);
|
|
913
913
|
} else
|
|
914
|
-
|
|
914
|
+
o = JSON.parse(a.decode(e));
|
|
915
915
|
else
|
|
916
|
-
|
|
917
|
-
if (
|
|
916
|
+
o = e;
|
|
917
|
+
if (o.asset === void 0 || o.asset.version[0] < 2) {
|
|
918
918
|
s && s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
919
919
|
return;
|
|
920
920
|
}
|
|
921
|
-
const l = new
|
|
921
|
+
const l = new tn(o, {
|
|
922
922
|
path: t || this.resourcePath || "",
|
|
923
923
|
crossOrigin: this.crossOrigin,
|
|
924
924
|
requestHeader: this.requestHeader,
|
|
@@ -929,29 +929,29 @@ class xs extends ot {
|
|
|
929
929
|
l.fileLoader.setRequestHeader(this.requestHeader);
|
|
930
930
|
for (let u = 0; u < this.pluginCallbacks.length; u++) {
|
|
931
931
|
const h = this.pluginCallbacks[u](l);
|
|
932
|
-
h.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), c[h.name] = h,
|
|
932
|
+
h.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), c[h.name] = h, i[h.name] = !0;
|
|
933
933
|
}
|
|
934
|
-
if (
|
|
935
|
-
for (let u = 0; u <
|
|
936
|
-
const h =
|
|
934
|
+
if (o.extensionsUsed)
|
|
935
|
+
for (let u = 0; u < o.extensionsUsed.length; ++u) {
|
|
936
|
+
const h = o.extensionsUsed[u], p = o.extensionsRequired || [];
|
|
937
937
|
switch (h) {
|
|
938
938
|
case b.KHR_MATERIALS_UNLIT:
|
|
939
|
-
|
|
939
|
+
i[h] = new Rs();
|
|
940
940
|
break;
|
|
941
941
|
case b.KHR_DRACO_MESH_COMPRESSION:
|
|
942
|
-
|
|
942
|
+
i[h] = new zs(o, this.dracoLoader);
|
|
943
943
|
break;
|
|
944
944
|
case b.KHR_TEXTURE_TRANSFORM:
|
|
945
|
-
|
|
945
|
+
i[h] = new Ks();
|
|
946
946
|
break;
|
|
947
947
|
case b.KHR_MESH_QUANTIZATION:
|
|
948
|
-
|
|
948
|
+
i[h] = new Ws();
|
|
949
949
|
break;
|
|
950
950
|
default:
|
|
951
951
|
p.indexOf(h) >= 0 && c[h] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + h + '".');
|
|
952
952
|
}
|
|
953
953
|
}
|
|
954
|
-
l.setExtensions(
|
|
954
|
+
l.setExtensions(i), l.setPlugins(c), l.parse(n, s);
|
|
955
955
|
}
|
|
956
956
|
/**
|
|
957
957
|
* Async version of {@link GLTFLoader#parse}.
|
|
@@ -963,12 +963,12 @@ class xs extends ot {
|
|
|
963
963
|
*/
|
|
964
964
|
parseAsync(e, t) {
|
|
965
965
|
const n = this;
|
|
966
|
-
return new Promise(function(s,
|
|
967
|
-
n.parse(e, t, s,
|
|
966
|
+
return new Promise(function(s, o) {
|
|
967
|
+
n.parse(e, t, s, o);
|
|
968
968
|
});
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
function
|
|
971
|
+
function xs() {
|
|
972
972
|
let r = {};
|
|
973
973
|
return {
|
|
974
974
|
get: function(e) {
|
|
@@ -1009,53 +1009,53 @@ const b = {
|
|
|
1009
1009
|
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
1010
1010
|
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
1011
1011
|
};
|
|
1012
|
-
class
|
|
1012
|
+
class As {
|
|
1013
1013
|
constructor(e) {
|
|
1014
1014
|
this.parser = e, this.name = b.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
1015
1015
|
}
|
|
1016
1016
|
_markDefs() {
|
|
1017
1017
|
const e = this.parser, t = this.parser.json.nodes || [];
|
|
1018
1018
|
for (let n = 0, s = t.length; n < s; n++) {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1019
|
+
const o = t[n];
|
|
1020
|
+
o.extensions && o.extensions[this.name] && o.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, o.extensions[this.name].light);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
_loadLight(e) {
|
|
1024
1024
|
const t = this.parser, n = "light:" + e;
|
|
1025
1025
|
let s = t.cache.get(n);
|
|
1026
1026
|
if (s) return s;
|
|
1027
|
-
const
|
|
1027
|
+
const o = t.json, a = ((o.extensions && o.extensions[this.name] || {}).lights || [])[e];
|
|
1028
1028
|
let l;
|
|
1029
1029
|
const u = new q(16777215);
|
|
1030
|
-
a.color !== void 0 && u.setRGB(a.color[0], a.color[1], a.color[2],
|
|
1030
|
+
a.color !== void 0 && u.setRGB(a.color[0], a.color[1], a.color[2], j);
|
|
1031
1031
|
const h = a.range !== void 0 ? a.range : 0;
|
|
1032
1032
|
switch (a.type) {
|
|
1033
1033
|
case "directional":
|
|
1034
|
-
l = new
|
|
1034
|
+
l = new bt(u), l.target.position.set(0, 0, -1), l.add(l.target);
|
|
1035
1035
|
break;
|
|
1036
1036
|
case "point":
|
|
1037
|
-
l = new
|
|
1037
|
+
l = new wt(u), l.distance = h;
|
|
1038
1038
|
break;
|
|
1039
1039
|
case "spot":
|
|
1040
|
-
l = new
|
|
1040
|
+
l = new Tt(u), l.distance = h, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, l.angle = a.spot.outerConeAngle, l.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, l.target.position.set(0, 0, -1), l.add(l.target);
|
|
1041
1041
|
break;
|
|
1042
1042
|
default:
|
|
1043
1043
|
throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
|
|
1044
1044
|
}
|
|
1045
|
-
return l.position.set(0, 0, 0),
|
|
1045
|
+
return l.position.set(0, 0, 0), B(l, a), a.intensity !== void 0 && (l.intensity = a.intensity), l.name = t.createUniqueName(a.name || "light_" + e), s = Promise.resolve(l), t.cache.add(n, s), s;
|
|
1046
1046
|
}
|
|
1047
1047
|
getDependency(e, t) {
|
|
1048
1048
|
if (e === "light")
|
|
1049
1049
|
return this._loadLight(t);
|
|
1050
1050
|
}
|
|
1051
1051
|
createNodeAttachment(e) {
|
|
1052
|
-
const t = this, n = this.parser,
|
|
1052
|
+
const t = this, n = this.parser, o = n.json.nodes[e], c = (o.extensions && o.extensions[this.name] || {}).light;
|
|
1053
1053
|
return c === void 0 ? null : this._loadLight(c).then(function(a) {
|
|
1054
1054
|
return n._getNodeRef(t.cache, c, a);
|
|
1055
1055
|
});
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
class
|
|
1058
|
+
class Rs {
|
|
1059
1059
|
constructor() {
|
|
1060
1060
|
this.name = b.KHR_MATERIALS_UNLIT;
|
|
1061
1061
|
}
|
|
@@ -1065,18 +1065,18 @@ class Ms {
|
|
|
1065
1065
|
extendParams(e, t, n) {
|
|
1066
1066
|
const s = [];
|
|
1067
1067
|
e.color = new q(1, 1, 1), e.opacity = 1;
|
|
1068
|
-
const
|
|
1069
|
-
if (
|
|
1070
|
-
if (Array.isArray(
|
|
1071
|
-
const
|
|
1072
|
-
e.color.setRGB(
|
|
1068
|
+
const o = t.pbrMetallicRoughness;
|
|
1069
|
+
if (o) {
|
|
1070
|
+
if (Array.isArray(o.baseColorFactor)) {
|
|
1071
|
+
const i = o.baseColorFactor;
|
|
1072
|
+
e.color.setRGB(i[0], i[1], i[2], j), e.opacity = i[3];
|
|
1073
1073
|
}
|
|
1074
|
-
|
|
1074
|
+
o.baseColorTexture !== void 0 && s.push(n.assignTexture(e, "map", o.baseColorTexture, $));
|
|
1075
1075
|
}
|
|
1076
1076
|
return Promise.all(s);
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
|
-
class
|
|
1079
|
+
class Ms {
|
|
1080
1080
|
constructor(e) {
|
|
1081
1081
|
this.parser = e, this.name = b.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
1082
1082
|
}
|
|
@@ -1084,44 +1084,44 @@ class Ss {
|
|
|
1084
1084
|
const s = this.parser.json.materials[e];
|
|
1085
1085
|
if (!s.extensions || !s.extensions[this.name])
|
|
1086
1086
|
return Promise.resolve();
|
|
1087
|
-
const
|
|
1088
|
-
return
|
|
1087
|
+
const o = s.extensions[this.name].emissiveStrength;
|
|
1088
|
+
return o !== void 0 && (t.emissiveIntensity = o), Promise.resolve();
|
|
1089
1089
|
}
|
|
1090
1090
|
}
|
|
1091
|
-
class
|
|
1091
|
+
class Ss {
|
|
1092
1092
|
constructor(e) {
|
|
1093
1093
|
this.parser = e, this.name = b.KHR_MATERIALS_CLEARCOAT;
|
|
1094
1094
|
}
|
|
1095
1095
|
getMaterialType(e) {
|
|
1096
1096
|
const n = this.parser.json.materials[e];
|
|
1097
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1097
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1098
1098
|
}
|
|
1099
1099
|
extendMaterialParams(e, t) {
|
|
1100
1100
|
const n = this.parser, s = n.json.materials[e];
|
|
1101
1101
|
if (!s.extensions || !s.extensions[this.name])
|
|
1102
1102
|
return Promise.resolve();
|
|
1103
|
-
const
|
|
1104
|
-
if (
|
|
1105
|
-
const c =
|
|
1106
|
-
t.clearcoatNormalScale = new
|
|
1103
|
+
const o = [], i = s.extensions[this.name];
|
|
1104
|
+
if (i.clearcoatFactor !== void 0 && (t.clearcoat = i.clearcoatFactor), i.clearcoatTexture !== void 0 && o.push(n.assignTexture(t, "clearcoatMap", i.clearcoatTexture)), i.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = i.clearcoatRoughnessFactor), i.clearcoatRoughnessTexture !== void 0 && o.push(n.assignTexture(t, "clearcoatRoughnessMap", i.clearcoatRoughnessTexture)), i.clearcoatNormalTexture !== void 0 && (o.push(n.assignTexture(t, "clearcoatNormalMap", i.clearcoatNormalTexture)), i.clearcoatNormalTexture.scale !== void 0)) {
|
|
1105
|
+
const c = i.clearcoatNormalTexture.scale;
|
|
1106
|
+
t.clearcoatNormalScale = new I(c, c);
|
|
1107
1107
|
}
|
|
1108
|
-
return Promise.all(
|
|
1108
|
+
return Promise.all(o);
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
class
|
|
1111
|
+
class Ls {
|
|
1112
1112
|
constructor(e) {
|
|
1113
1113
|
this.parser = e, this.name = b.KHR_MATERIALS_DISPERSION;
|
|
1114
1114
|
}
|
|
1115
1115
|
getMaterialType(e) {
|
|
1116
1116
|
const n = this.parser.json.materials[e];
|
|
1117
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1117
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1118
1118
|
}
|
|
1119
1119
|
extendMaterialParams(e, t) {
|
|
1120
1120
|
const s = this.parser.json.materials[e];
|
|
1121
1121
|
if (!s.extensions || !s.extensions[this.name])
|
|
1122
1122
|
return Promise.resolve();
|
|
1123
|
-
const
|
|
1124
|
-
return t.dispersion =
|
|
1123
|
+
const o = s.extensions[this.name];
|
|
1124
|
+
return t.dispersion = o.dispersion !== void 0 ? o.dispersion : 0, Promise.resolve();
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
1127
|
class Ds {
|
|
@@ -1130,14 +1130,14 @@ class Ds {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
getMaterialType(e) {
|
|
1132
1132
|
const n = this.parser.json.materials[e];
|
|
1133
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1133
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1134
1134
|
}
|
|
1135
1135
|
extendMaterialParams(e, t) {
|
|
1136
1136
|
const n = this.parser, s = n.json.materials[e];
|
|
1137
1137
|
if (!s.extensions || !s.extensions[this.name])
|
|
1138
1138
|
return Promise.resolve();
|
|
1139
|
-
const
|
|
1140
|
-
return
|
|
1139
|
+
const o = [], i = s.extensions[this.name];
|
|
1140
|
+
return i.iridescenceFactor !== void 0 && (t.iridescence = i.iridescenceFactor), i.iridescenceTexture !== void 0 && o.push(n.assignTexture(t, "iridescenceMap", i.iridescenceTexture)), i.iridescenceIor !== void 0 && (t.iridescenceIOR = i.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), i.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = i.iridescenceThicknessMinimum), i.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = i.iridescenceThicknessMaximum), i.iridescenceThicknessTexture !== void 0 && o.push(n.assignTexture(t, "iridescenceThicknessMap", i.iridescenceThicknessTexture)), Promise.all(o);
|
|
1141
1141
|
}
|
|
1142
1142
|
}
|
|
1143
1143
|
class Cs {
|
|
@@ -1146,54 +1146,54 @@ class Cs {
|
|
|
1146
1146
|
}
|
|
1147
1147
|
getMaterialType(e) {
|
|
1148
1148
|
const n = this.parser.json.materials[e];
|
|
1149
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1149
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1150
1150
|
}
|
|
1151
1151
|
extendMaterialParams(e, t) {
|
|
1152
1152
|
const n = this.parser, s = n.json.materials[e];
|
|
1153
1153
|
if (!s.extensions || !s.extensions[this.name])
|
|
1154
1154
|
return Promise.resolve();
|
|
1155
|
-
const
|
|
1155
|
+
const o = [];
|
|
1156
1156
|
t.sheenColor = new q(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
|
|
1157
|
-
const
|
|
1158
|
-
if (
|
|
1159
|
-
const c =
|
|
1160
|
-
t.sheenColor.setRGB(c[0], c[1], c[2],
|
|
1157
|
+
const i = s.extensions[this.name];
|
|
1158
|
+
if (i.sheenColorFactor !== void 0) {
|
|
1159
|
+
const c = i.sheenColorFactor;
|
|
1160
|
+
t.sheenColor.setRGB(c[0], c[1], c[2], j);
|
|
1161
1161
|
}
|
|
1162
|
-
return
|
|
1162
|
+
return i.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = i.sheenRoughnessFactor), i.sheenColorTexture !== void 0 && o.push(n.assignTexture(t, "sheenColorMap", i.sheenColorTexture, $)), i.sheenRoughnessTexture !== void 0 && o.push(n.assignTexture(t, "sheenRoughnessMap", i.sheenRoughnessTexture)), Promise.all(o);
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
-
class
|
|
1165
|
+
class Ps {
|
|
1166
1166
|
constructor(e) {
|
|
1167
1167
|
this.parser = e, this.name = b.KHR_MATERIALS_TRANSMISSION;
|
|
1168
1168
|
}
|
|
1169
1169
|
getMaterialType(e) {
|
|
1170
1170
|
const n = this.parser.json.materials[e];
|
|
1171
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1171
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1172
1172
|
}
|
|
1173
1173
|
extendMaterialParams(e, t) {
|
|
1174
1174
|
const n = this.parser, s = n.json.materials[e];
|
|
1175
1175
|
if (!s.extensions || !s.extensions[this.name])
|
|
1176
1176
|
return Promise.resolve();
|
|
1177
|
-
const
|
|
1178
|
-
return
|
|
1177
|
+
const o = [], i = s.extensions[this.name];
|
|
1178
|
+
return i.transmissionFactor !== void 0 && (t.transmission = i.transmissionFactor), i.transmissionTexture !== void 0 && o.push(n.assignTexture(t, "transmissionMap", i.transmissionTexture)), Promise.all(o);
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
|
-
class
|
|
1181
|
+
class Os {
|
|
1182
1182
|
constructor(e) {
|
|
1183
1183
|
this.parser = e, this.name = b.KHR_MATERIALS_VOLUME;
|
|
1184
1184
|
}
|
|
1185
1185
|
getMaterialType(e) {
|
|
1186
1186
|
const n = this.parser.json.materials[e];
|
|
1187
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1187
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1188
1188
|
}
|
|
1189
1189
|
extendMaterialParams(e, t) {
|
|
1190
1190
|
const n = this.parser, s = n.json.materials[e];
|
|
1191
1191
|
if (!s.extensions || !s.extensions[this.name])
|
|
1192
1192
|
return Promise.resolve();
|
|
1193
|
-
const
|
|
1194
|
-
t.thickness =
|
|
1195
|
-
const c =
|
|
1196
|
-
return t.attenuationColor = new q().setRGB(c[0], c[1], c[2],
|
|
1193
|
+
const o = [], i = s.extensions[this.name];
|
|
1194
|
+
t.thickness = i.thicknessFactor !== void 0 ? i.thicknessFactor : 0, i.thicknessTexture !== void 0 && o.push(n.assignTexture(t, "thicknessMap", i.thicknessTexture)), t.attenuationDistance = i.attenuationDistance || 1 / 0;
|
|
1195
|
+
const c = i.attenuationColor || [1, 1, 1];
|
|
1196
|
+
return t.attenuationColor = new q().setRGB(c[0], c[1], c[2], j), Promise.all(o);
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
1199
|
class Is {
|
|
@@ -1202,67 +1202,67 @@ class Is {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
getMaterialType(e) {
|
|
1204
1204
|
const n = this.parser.json.materials[e];
|
|
1205
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1205
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1206
1206
|
}
|
|
1207
1207
|
extendMaterialParams(e, t) {
|
|
1208
1208
|
const s = this.parser.json.materials[e];
|
|
1209
1209
|
if (!s.extensions || !s.extensions[this.name])
|
|
1210
1210
|
return Promise.resolve();
|
|
1211
|
-
const
|
|
1212
|
-
return t.ior =
|
|
1211
|
+
const o = s.extensions[this.name];
|
|
1212
|
+
return t.ior = o.ior !== void 0 ? o.ior : 1.5, Promise.resolve();
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
|
-
class
|
|
1215
|
+
class ks {
|
|
1216
1216
|
constructor(e) {
|
|
1217
1217
|
this.parser = e, this.name = b.KHR_MATERIALS_SPECULAR;
|
|
1218
1218
|
}
|
|
1219
1219
|
getMaterialType(e) {
|
|
1220
1220
|
const n = this.parser.json.materials[e];
|
|
1221
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1221
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1222
1222
|
}
|
|
1223
1223
|
extendMaterialParams(e, t) {
|
|
1224
1224
|
const n = this.parser, s = n.json.materials[e];
|
|
1225
1225
|
if (!s.extensions || !s.extensions[this.name])
|
|
1226
1226
|
return Promise.resolve();
|
|
1227
|
-
const
|
|
1228
|
-
t.specularIntensity =
|
|
1229
|
-
const c =
|
|
1230
|
-
return t.specularColor = new q().setRGB(c[0], c[1], c[2],
|
|
1227
|
+
const o = [], i = s.extensions[this.name];
|
|
1228
|
+
t.specularIntensity = i.specularFactor !== void 0 ? i.specularFactor : 1, i.specularTexture !== void 0 && o.push(n.assignTexture(t, "specularIntensityMap", i.specularTexture));
|
|
1229
|
+
const c = i.specularColorFactor || [1, 1, 1];
|
|
1230
|
+
return t.specularColor = new q().setRGB(c[0], c[1], c[2], j), i.specularColorTexture !== void 0 && o.push(n.assignTexture(t, "specularColorMap", i.specularColorTexture, $)), Promise.all(o);
|
|
1231
1231
|
}
|
|
1232
1232
|
}
|
|
1233
|
-
class
|
|
1233
|
+
class Ns {
|
|
1234
1234
|
constructor(e) {
|
|
1235
1235
|
this.parser = e, this.name = b.EXT_MATERIALS_BUMP;
|
|
1236
1236
|
}
|
|
1237
1237
|
getMaterialType(e) {
|
|
1238
1238
|
const n = this.parser.json.materials[e];
|
|
1239
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1239
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1240
1240
|
}
|
|
1241
1241
|
extendMaterialParams(e, t) {
|
|
1242
1242
|
const n = this.parser, s = n.json.materials[e];
|
|
1243
1243
|
if (!s.extensions || !s.extensions[this.name])
|
|
1244
1244
|
return Promise.resolve();
|
|
1245
|
-
const
|
|
1246
|
-
return t.bumpScale =
|
|
1245
|
+
const o = [], i = s.extensions[this.name];
|
|
1246
|
+
return t.bumpScale = i.bumpFactor !== void 0 ? i.bumpFactor : 1, i.bumpTexture !== void 0 && o.push(n.assignTexture(t, "bumpMap", i.bumpTexture)), Promise.all(o);
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
class
|
|
1249
|
+
class vs {
|
|
1250
1250
|
constructor(e) {
|
|
1251
1251
|
this.parser = e, this.name = b.KHR_MATERIALS_ANISOTROPY;
|
|
1252
1252
|
}
|
|
1253
1253
|
getMaterialType(e) {
|
|
1254
1254
|
const n = this.parser.json.materials[e];
|
|
1255
|
-
return !n.extensions || !n.extensions[this.name] ? null :
|
|
1255
|
+
return !n.extensions || !n.extensions[this.name] ? null : G;
|
|
1256
1256
|
}
|
|
1257
1257
|
extendMaterialParams(e, t) {
|
|
1258
1258
|
const n = this.parser, s = n.json.materials[e];
|
|
1259
1259
|
if (!s.extensions || !s.extensions[this.name])
|
|
1260
1260
|
return Promise.resolve();
|
|
1261
|
-
const
|
|
1262
|
-
return
|
|
1261
|
+
const o = [], i = s.extensions[this.name];
|
|
1262
|
+
return i.anisotropyStrength !== void 0 && (t.anisotropy = i.anisotropyStrength), i.anisotropyRotation !== void 0 && (t.anisotropyRotation = i.anisotropyRotation), i.anisotropyTexture !== void 0 && o.push(n.assignTexture(t, "anisotropyMap", i.anisotropyTexture)), Promise.all(o);
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
|
-
class
|
|
1265
|
+
class Hs {
|
|
1266
1266
|
constructor(e) {
|
|
1267
1267
|
this.parser = e, this.name = b.KHR_TEXTURE_BASISU;
|
|
1268
1268
|
}
|
|
@@ -1270,76 +1270,76 @@ class Fs {
|
|
|
1270
1270
|
const t = this.parser, n = t.json, s = n.textures[e];
|
|
1271
1271
|
if (!s.extensions || !s.extensions[this.name])
|
|
1272
1272
|
return null;
|
|
1273
|
-
const
|
|
1274
|
-
if (!
|
|
1273
|
+
const o = s.extensions[this.name], i = t.options.ktx2Loader;
|
|
1274
|
+
if (!i) {
|
|
1275
1275
|
if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0)
|
|
1276
1276
|
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
1277
1277
|
return null;
|
|
1278
1278
|
}
|
|
1279
|
-
return t.loadTextureImage(e,
|
|
1279
|
+
return t.loadTextureImage(e, o.source, i);
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
|
-
class
|
|
1282
|
+
class Fs {
|
|
1283
1283
|
constructor(e) {
|
|
1284
1284
|
this.parser = e, this.name = b.EXT_TEXTURE_WEBP;
|
|
1285
1285
|
}
|
|
1286
1286
|
loadTexture(e) {
|
|
1287
|
-
const t = this.name, n = this.parser, s = n.json,
|
|
1288
|
-
if (!
|
|
1287
|
+
const t = this.name, n = this.parser, s = n.json, o = s.textures[e];
|
|
1288
|
+
if (!o.extensions || !o.extensions[t])
|
|
1289
1289
|
return null;
|
|
1290
|
-
const
|
|
1290
|
+
const i = o.extensions[t], c = s.images[i.source];
|
|
1291
1291
|
let a = n.textureLoader;
|
|
1292
1292
|
if (c.uri) {
|
|
1293
1293
|
const l = n.options.manager.getHandler(c.uri);
|
|
1294
1294
|
l !== null && (a = l);
|
|
1295
1295
|
}
|
|
1296
|
-
return n.loadTextureImage(e,
|
|
1296
|
+
return n.loadTextureImage(e, i.source, a);
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
-
class
|
|
1299
|
+
class Us {
|
|
1300
1300
|
constructor(e) {
|
|
1301
1301
|
this.parser = e, this.name = b.EXT_TEXTURE_AVIF;
|
|
1302
1302
|
}
|
|
1303
1303
|
loadTexture(e) {
|
|
1304
|
-
const t = this.name, n = this.parser, s = n.json,
|
|
1305
|
-
if (!
|
|
1304
|
+
const t = this.name, n = this.parser, s = n.json, o = s.textures[e];
|
|
1305
|
+
if (!o.extensions || !o.extensions[t])
|
|
1306
1306
|
return null;
|
|
1307
|
-
const
|
|
1307
|
+
const i = o.extensions[t], c = s.images[i.source];
|
|
1308
1308
|
let a = n.textureLoader;
|
|
1309
1309
|
if (c.uri) {
|
|
1310
1310
|
const l = n.options.manager.getHandler(c.uri);
|
|
1311
1311
|
l !== null && (a = l);
|
|
1312
1312
|
}
|
|
1313
|
-
return n.loadTextureImage(e,
|
|
1313
|
+
return n.loadTextureImage(e, i.source, a);
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
|
-
class
|
|
1316
|
+
class js {
|
|
1317
1317
|
constructor(e) {
|
|
1318
1318
|
this.name = b.EXT_MESHOPT_COMPRESSION, this.parser = e;
|
|
1319
1319
|
}
|
|
1320
1320
|
loadBufferView(e) {
|
|
1321
1321
|
const t = this.parser.json, n = t.bufferViews[e];
|
|
1322
1322
|
if (n.extensions && n.extensions[this.name]) {
|
|
1323
|
-
const s = n.extensions[this.name],
|
|
1324
|
-
if (!
|
|
1323
|
+
const s = n.extensions[this.name], o = this.parser.getDependency("buffer", s.buffer), i = this.parser.options.meshoptDecoder;
|
|
1324
|
+
if (!i || !i.supported) {
|
|
1325
1325
|
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
|
|
1326
1326
|
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
1327
1327
|
return null;
|
|
1328
1328
|
}
|
|
1329
|
-
return
|
|
1329
|
+
return o.then(function(c) {
|
|
1330
1330
|
const a = s.byteOffset || 0, l = s.byteLength || 0, u = s.count, h = s.byteStride, p = new Uint8Array(c, a, l);
|
|
1331
|
-
return
|
|
1331
|
+
return i.decodeGltfBufferAsync ? i.decodeGltfBufferAsync(u, h, p, s.mode, s.filter).then(function(m) {
|
|
1332
1332
|
return m.buffer;
|
|
1333
|
-
}) :
|
|
1333
|
+
}) : i.ready.then(function() {
|
|
1334
1334
|
const m = new ArrayBuffer(u * h);
|
|
1335
|
-
return
|
|
1335
|
+
return i.decodeGltfBuffer(new Uint8Array(m), u, h, p, s.mode, s.filter), m;
|
|
1336
1336
|
});
|
|
1337
1337
|
});
|
|
1338
1338
|
} else
|
|
1339
1339
|
return null;
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
|
-
class
|
|
1342
|
+
class Gs {
|
|
1343
1343
|
constructor(e) {
|
|
1344
1344
|
this.name = b.EXT_MESH_GPU_INSTANCING, this.parser = e;
|
|
1345
1345
|
}
|
|
@@ -1349,30 +1349,30 @@ class Bs {
|
|
|
1349
1349
|
return null;
|
|
1350
1350
|
const s = t.meshes[n.mesh];
|
|
1351
1351
|
for (const l of s.primitives)
|
|
1352
|
-
if (l.mode !==
|
|
1352
|
+
if (l.mode !== k.TRIANGLES && l.mode !== k.TRIANGLE_STRIP && l.mode !== k.TRIANGLE_FAN && l.mode !== void 0)
|
|
1353
1353
|
return null;
|
|
1354
|
-
const
|
|
1355
|
-
for (const l in
|
|
1356
|
-
c.push(this.parser.getDependency("accessor",
|
|
1354
|
+
const i = n.extensions[this.name].attributes, c = [], a = {};
|
|
1355
|
+
for (const l in i)
|
|
1356
|
+
c.push(this.parser.getDependency("accessor", i[l]).then((u) => (a[l] = u, a[l])));
|
|
1357
1357
|
return c.length < 1 ? null : (c.push(this.parser.createNodeMesh(e)), Promise.all(c).then((l) => {
|
|
1358
1358
|
const u = l.pop(), h = u.isGroup ? u.children : [u], p = l[0].count, m = [];
|
|
1359
1359
|
for (const _ of h) {
|
|
1360
|
-
const w = new se(), d = new S(), f = new le(), g = new S(1, 1, 1), T = new
|
|
1360
|
+
const w = new se(), d = new S(), f = new le(), g = new S(1, 1, 1), T = new Et(_.geometry, _.material, p);
|
|
1361
1361
|
for (let y = 0; y < p; y++)
|
|
1362
1362
|
a.TRANSLATION && d.fromBufferAttribute(a.TRANSLATION, y), a.ROTATION && f.fromBufferAttribute(a.ROTATION, y), a.SCALE && g.fromBufferAttribute(a.SCALE, y), T.setMatrixAt(y, w.compose(d, f, g));
|
|
1363
1363
|
for (const y in a)
|
|
1364
1364
|
if (y === "_COLOR_0") {
|
|
1365
1365
|
const E = a[y];
|
|
1366
|
-
T.instanceColor = new
|
|
1366
|
+
T.instanceColor = new xt(E.array, E.itemSize, E.normalized);
|
|
1367
1367
|
} else y !== "TRANSLATION" && y !== "ROTATION" && y !== "SCALE" && _.geometry.setAttribute(y, a[y]);
|
|
1368
|
-
|
|
1368
|
+
He.prototype.copy.call(T, _), this.parser.assignFinalMaterial(T), m.push(T);
|
|
1369
1369
|
}
|
|
1370
1370
|
return u.isGroup ? (u.clear(), u.add(...m), u) : m[0];
|
|
1371
1371
|
}));
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
const
|
|
1375
|
-
class
|
|
1374
|
+
const dt = "glTF", ne = 12, Ye = { JSON: 1313821514, BIN: 5130562 };
|
|
1375
|
+
class Bs {
|
|
1376
1376
|
constructor(e) {
|
|
1377
1377
|
this.name = b.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
1378
1378
|
const t = new DataView(e, 0, ne), n = new TextDecoder();
|
|
@@ -1380,49 +1380,49 @@ class zs {
|
|
|
1380
1380
|
magic: n.decode(new Uint8Array(e.slice(0, 4))),
|
|
1381
1381
|
version: t.getUint32(4, !0),
|
|
1382
1382
|
length: t.getUint32(8, !0)
|
|
1383
|
-
}, this.header.magic !==
|
|
1383
|
+
}, this.header.magic !== dt)
|
|
1384
1384
|
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
1385
1385
|
if (this.header.version < 2)
|
|
1386
1386
|
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
1387
|
-
const s = this.header.length - ne,
|
|
1388
|
-
let
|
|
1389
|
-
for (;
|
|
1390
|
-
const c =
|
|
1391
|
-
|
|
1392
|
-
const a =
|
|
1393
|
-
if (
|
|
1394
|
-
const l = new Uint8Array(e, ne +
|
|
1387
|
+
const s = this.header.length - ne, o = new DataView(e, ne);
|
|
1388
|
+
let i = 0;
|
|
1389
|
+
for (; i < s; ) {
|
|
1390
|
+
const c = o.getUint32(i, !0);
|
|
1391
|
+
i += 4;
|
|
1392
|
+
const a = o.getUint32(i, !0);
|
|
1393
|
+
if (i += 4, a === Ye.JSON) {
|
|
1394
|
+
const l = new Uint8Array(e, ne + i, c);
|
|
1395
1395
|
this.content = n.decode(l);
|
|
1396
|
-
} else if (a ===
|
|
1397
|
-
const l = ne +
|
|
1396
|
+
} else if (a === Ye.BIN) {
|
|
1397
|
+
const l = ne + i;
|
|
1398
1398
|
this.body = e.slice(l, l + c);
|
|
1399
1399
|
}
|
|
1400
|
-
|
|
1400
|
+
i += c;
|
|
1401
1401
|
}
|
|
1402
1402
|
if (this.content === null)
|
|
1403
1403
|
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
|
-
class
|
|
1406
|
+
class zs {
|
|
1407
1407
|
constructor(e, t) {
|
|
1408
1408
|
if (!t)
|
|
1409
1409
|
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
1410
1410
|
this.name = b.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
|
|
1411
1411
|
}
|
|
1412
1412
|
decodePrimitive(e, t) {
|
|
1413
|
-
const n = this.json, s = this.dracoLoader,
|
|
1414
|
-
for (const u in
|
|
1413
|
+
const n = this.json, s = this.dracoLoader, o = e.extensions[this.name].bufferView, i = e.extensions[this.name].attributes, c = {}, a = {}, l = {};
|
|
1414
|
+
for (const u in i) {
|
|
1415
1415
|
const h = ke[u] || u.toLowerCase();
|
|
1416
|
-
c[h] =
|
|
1416
|
+
c[h] = i[u];
|
|
1417
1417
|
}
|
|
1418
1418
|
for (const u in e.attributes) {
|
|
1419
1419
|
const h = ke[u] || u.toLowerCase();
|
|
1420
|
-
if (
|
|
1420
|
+
if (i[u] !== void 0) {
|
|
1421
1421
|
const p = n.accessors[e.attributes[u]], m = te[p.componentType];
|
|
1422
1422
|
l[h] = m.name, a[h] = p.normalized === !0;
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
return t.getDependency("bufferView",
|
|
1425
|
+
return t.getDependency("bufferView", o).then(function(u) {
|
|
1426
1426
|
return new Promise(function(h, p) {
|
|
1427
1427
|
s.decodeDracoFile(u, function(m) {
|
|
1428
1428
|
for (const _ in m.attributes) {
|
|
@@ -1430,12 +1430,12 @@ class Ks {
|
|
|
1430
1430
|
d !== void 0 && (w.normalized = d);
|
|
1431
1431
|
}
|
|
1432
1432
|
h(m);
|
|
1433
|
-
}, c, l,
|
|
1433
|
+
}, c, l, j, p);
|
|
1434
1434
|
});
|
|
1435
1435
|
});
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
|
-
class
|
|
1438
|
+
class Ks {
|
|
1439
1439
|
constructor() {
|
|
1440
1440
|
this.name = b.KHR_TEXTURE_TRANSFORM;
|
|
1441
1441
|
}
|
|
@@ -1443,38 +1443,38 @@ class Ws {
|
|
|
1443
1443
|
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
class
|
|
1446
|
+
class Ws {
|
|
1447
1447
|
constructor() {
|
|
1448
1448
|
this.name = b.KHR_MESH_QUANTIZATION;
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
|
-
class
|
|
1451
|
+
class ft extends qt {
|
|
1452
1452
|
constructor(e, t, n, s) {
|
|
1453
1453
|
super(e, t, n, s);
|
|
1454
1454
|
}
|
|
1455
1455
|
copySampleValue_(e) {
|
|
1456
|
-
const t = this.resultBuffer, n = this.sampleValues, s = this.valueSize,
|
|
1457
|
-
for (let
|
|
1458
|
-
t[
|
|
1456
|
+
const t = this.resultBuffer, n = this.sampleValues, s = this.valueSize, o = e * s * 3 + s;
|
|
1457
|
+
for (let i = 0; i !== s; i++)
|
|
1458
|
+
t[i] = n[o + i];
|
|
1459
1459
|
return t;
|
|
1460
1460
|
}
|
|
1461
1461
|
interpolate_(e, t, n, s) {
|
|
1462
|
-
const
|
|
1462
|
+
const o = this.resultBuffer, i = this.sampleValues, c = this.valueSize, a = c * 2, l = c * 3, u = s - t, h = (n - t) / u, p = h * h, m = p * h, _ = e * l, w = _ - l, d = -2 * m + 3 * p, f = m - p, g = 1 - d, T = f - p + h;
|
|
1463
1463
|
for (let y = 0; y !== c; y++) {
|
|
1464
|
-
const E =
|
|
1465
|
-
|
|
1464
|
+
const E = i[w + y + c], x = i[w + y + a] * u, M = i[_ + y + c], C = i[_ + y] * u;
|
|
1465
|
+
o[y] = g * E + T * x + d * M + f * C;
|
|
1466
1466
|
}
|
|
1467
|
-
return
|
|
1467
|
+
return o;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
1470
|
const Vs = new le();
|
|
1471
|
-
class
|
|
1471
|
+
class Xs extends ft {
|
|
1472
1472
|
interpolate_(e, t, n, s) {
|
|
1473
|
-
const
|
|
1474
|
-
return Vs.fromArray(
|
|
1473
|
+
const o = super.interpolate_(e, t, n, s);
|
|
1474
|
+
return Vs.fromArray(o).normalize().toArray(o), o;
|
|
1475
1475
|
}
|
|
1476
1476
|
}
|
|
1477
|
-
const
|
|
1477
|
+
const k = {
|
|
1478
1478
|
POINTS: 0,
|
|
1479
1479
|
LINES: 1,
|
|
1480
1480
|
LINE_LOOP: 2,
|
|
@@ -1489,18 +1489,18 @@ const I = {
|
|
|
1489
1489
|
5123: Uint16Array,
|
|
1490
1490
|
5125: Uint32Array,
|
|
1491
1491
|
5126: Float32Array
|
|
1492
|
-
},
|
|
1493
|
-
9728:
|
|
1494
|
-
9729:
|
|
1492
|
+
}, $e = {
|
|
1493
|
+
9728: at,
|
|
1494
|
+
9729: Oe,
|
|
1495
1495
|
9984: Ct,
|
|
1496
1496
|
9985: Dt,
|
|
1497
|
-
9986:
|
|
1498
|
-
9987:
|
|
1497
|
+
9986: Lt,
|
|
1498
|
+
9987: rt
|
|
1499
1499
|
}, qe = {
|
|
1500
|
-
33071:
|
|
1501
|
-
33648:
|
|
1502
|
-
10497:
|
|
1503
|
-
},
|
|
1500
|
+
33071: Ot,
|
|
1501
|
+
33648: Pt,
|
|
1502
|
+
10497: Ie
|
|
1503
|
+
}, Ae = {
|
|
1504
1504
|
SCALAR: 1,
|
|
1505
1505
|
VEC2: 2,
|
|
1506
1506
|
VEC3: 3,
|
|
@@ -1519,24 +1519,24 @@ const I = {
|
|
|
1519
1519
|
COLOR_0: "color",
|
|
1520
1520
|
WEIGHTS_0: "skinWeight",
|
|
1521
1521
|
JOINTS_0: "skinIndex"
|
|
1522
|
-
},
|
|
1522
|
+
}, W = {
|
|
1523
1523
|
scale: "scale",
|
|
1524
1524
|
translation: "position",
|
|
1525
1525
|
rotation: "quaternion",
|
|
1526
1526
|
weights: "morphTargetInfluences"
|
|
1527
|
-
},
|
|
1527
|
+
}, Ys = {
|
|
1528
1528
|
CUBICSPLINE: void 0,
|
|
1529
1529
|
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
1530
1530
|
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
1531
|
-
LINEAR:
|
|
1532
|
-
STEP:
|
|
1533
|
-
},
|
|
1531
|
+
LINEAR: lt,
|
|
1532
|
+
STEP: Yt
|
|
1533
|
+
}, Re = {
|
|
1534
1534
|
OPAQUE: "OPAQUE",
|
|
1535
1535
|
MASK: "MASK",
|
|
1536
1536
|
BLEND: "BLEND"
|
|
1537
1537
|
};
|
|
1538
1538
|
function $s(r) {
|
|
1539
|
-
return r.DefaultMaterial === void 0 && (r.DefaultMaterial = new
|
|
1539
|
+
return r.DefaultMaterial === void 0 && (r.DefaultMaterial = new ct({
|
|
1540
1540
|
color: 16777215,
|
|
1541
1541
|
emissive: 0,
|
|
1542
1542
|
metalness: 1,
|
|
@@ -1546,46 +1546,46 @@ function $s(r) {
|
|
|
1546
1546
|
side: $t
|
|
1547
1547
|
})), r.DefaultMaterial;
|
|
1548
1548
|
}
|
|
1549
|
-
function
|
|
1549
|
+
function Q(r, e, t) {
|
|
1550
1550
|
for (const n in t.extensions)
|
|
1551
1551
|
r[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]);
|
|
1552
1552
|
}
|
|
1553
|
-
function
|
|
1553
|
+
function B(r, e) {
|
|
1554
1554
|
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(r.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
|
|
1555
1555
|
}
|
|
1556
|
-
function
|
|
1557
|
-
let n = !1, s = !1,
|
|
1556
|
+
function qs(r, e, t) {
|
|
1557
|
+
let n = !1, s = !1, o = !1;
|
|
1558
1558
|
for (let l = 0, u = e.length; l < u; l++) {
|
|
1559
1559
|
const h = e[l];
|
|
1560
|
-
if (h.POSITION !== void 0 && (n = !0), h.NORMAL !== void 0 && (s = !0), h.COLOR_0 !== void 0 && (
|
|
1560
|
+
if (h.POSITION !== void 0 && (n = !0), h.NORMAL !== void 0 && (s = !0), h.COLOR_0 !== void 0 && (o = !0), n && s && o) break;
|
|
1561
1561
|
}
|
|
1562
|
-
if (!n && !s && !
|
|
1563
|
-
const
|
|
1562
|
+
if (!n && !s && !o) return Promise.resolve(r);
|
|
1563
|
+
const i = [], c = [], a = [];
|
|
1564
1564
|
for (let l = 0, u = e.length; l < u; l++) {
|
|
1565
1565
|
const h = e[l];
|
|
1566
1566
|
if (n) {
|
|
1567
1567
|
const p = h.POSITION !== void 0 ? t.getDependency("accessor", h.POSITION) : r.attributes.position;
|
|
1568
|
-
|
|
1568
|
+
i.push(p);
|
|
1569
1569
|
}
|
|
1570
1570
|
if (s) {
|
|
1571
1571
|
const p = h.NORMAL !== void 0 ? t.getDependency("accessor", h.NORMAL) : r.attributes.normal;
|
|
1572
1572
|
c.push(p);
|
|
1573
1573
|
}
|
|
1574
|
-
if (
|
|
1574
|
+
if (o) {
|
|
1575
1575
|
const p = h.COLOR_0 !== void 0 ? t.getDependency("accessor", h.COLOR_0) : r.attributes.color;
|
|
1576
1576
|
a.push(p);
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
1579
|
return Promise.all([
|
|
1580
|
-
Promise.all(
|
|
1580
|
+
Promise.all(i),
|
|
1581
1581
|
Promise.all(c),
|
|
1582
1582
|
Promise.all(a)
|
|
1583
1583
|
]).then(function(l) {
|
|
1584
1584
|
const u = l[0], h = l[1], p = l[2];
|
|
1585
|
-
return n && (r.morphAttributes.position = u), s && (r.morphAttributes.normal = h),
|
|
1585
|
+
return n && (r.morphAttributes.position = u), s && (r.morphAttributes.normal = h), o && (r.morphAttributes.color = p), r.morphTargetsRelative = !0, r;
|
|
1586
1586
|
});
|
|
1587
1587
|
}
|
|
1588
|
-
function
|
|
1588
|
+
function Zs(r, e) {
|
|
1589
1589
|
if (r.updateMorphTargets(), e.weights !== void 0)
|
|
1590
1590
|
for (let t = 0, n = e.weights.length; t < n; t++)
|
|
1591
1591
|
r.morphTargetInfluences[t] = e.weights[t];
|
|
@@ -1599,22 +1599,22 @@ function Qs(r, e) {
|
|
|
1599
1599
|
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
1602
|
+
function Qs(r) {
|
|
1603
1603
|
let e;
|
|
1604
1604
|
const t = r.extensions && r.extensions[b.KHR_DRACO_MESH_COMPRESSION];
|
|
1605
|
-
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" +
|
|
1605
|
+
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + Me(t.attributes) : e = r.indices + ":" + Me(r.attributes) + ":" + r.mode, r.targets !== void 0)
|
|
1606
1606
|
for (let n = 0, s = r.targets.length; n < s; n++)
|
|
1607
|
-
e += ":" +
|
|
1607
|
+
e += ":" + Me(r.targets[n]);
|
|
1608
1608
|
return e;
|
|
1609
1609
|
}
|
|
1610
|
-
function
|
|
1610
|
+
function Me(r) {
|
|
1611
1611
|
let e = "";
|
|
1612
1612
|
const t = Object.keys(r).sort();
|
|
1613
1613
|
for (let n = 0, s = t.length; n < s; n++)
|
|
1614
1614
|
e += t[n] + ":" + r[t[n]] + ";";
|
|
1615
1615
|
return e;
|
|
1616
1616
|
}
|
|
1617
|
-
function
|
|
1617
|
+
function Ne(r) {
|
|
1618
1618
|
switch (r) {
|
|
1619
1619
|
case Int8Array:
|
|
1620
1620
|
return 1 / 127;
|
|
@@ -1628,21 +1628,21 @@ function Ie(r) {
|
|
|
1628
1628
|
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1631
|
+
function Js(r) {
|
|
1632
1632
|
return r.search(/\.jpe?g($|\?)/i) > 0 || r.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : r.search(/\.webp($|\?)/i) > 0 || r.search(/^data\:image\/webp/) === 0 ? "image/webp" : r.search(/\.ktx2($|\?)/i) > 0 || r.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
1633
1633
|
}
|
|
1634
|
-
const
|
|
1635
|
-
class
|
|
1634
|
+
const en = new se();
|
|
1635
|
+
class tn {
|
|
1636
1636
|
constructor(e = {}, t = {}) {
|
|
1637
|
-
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new
|
|
1638
|
-
let n = !1, s = -1,
|
|
1637
|
+
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new xs(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
1638
|
+
let n = !1, s = -1, o = !1, i = -1;
|
|
1639
1639
|
if (typeof navigator < "u") {
|
|
1640
1640
|
const c = navigator.userAgent;
|
|
1641
1641
|
n = /^((?!chrome|android).)*safari/i.test(c) === !0;
|
|
1642
1642
|
const a = c.match(/Version\/(\d+)/);
|
|
1643
|
-
s = n && a ? parseInt(a[1], 10) : -1,
|
|
1643
|
+
s = n && a ? parseInt(a[1], 10) : -1, o = c.indexOf("Firefox") > -1, i = o ? c.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
1644
1644
|
}
|
|
1645
|
-
typeof createImageBitmap > "u" || n && s < 17 ||
|
|
1645
|
+
typeof createImageBitmap > "u" || n && s < 17 || o && i < 98 ? this.textureLoader = new At(this.options.manager) : this.textureLoader = new Rt(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new fe(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
1646
1646
|
}
|
|
1647
1647
|
setExtensions(e) {
|
|
1648
1648
|
this.extensions = e;
|
|
@@ -1651,28 +1651,28 @@ class sn {
|
|
|
1651
1651
|
this.plugins = e;
|
|
1652
1652
|
}
|
|
1653
1653
|
parse(e, t) {
|
|
1654
|
-
const n = this, s = this.json,
|
|
1655
|
-
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(
|
|
1656
|
-
return
|
|
1657
|
-
}), Promise.all(this._invokeAll(function(
|
|
1658
|
-
return
|
|
1654
|
+
const n = this, s = this.json, o = this.extensions;
|
|
1655
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(i) {
|
|
1656
|
+
return i._markDefs && i._markDefs();
|
|
1657
|
+
}), Promise.all(this._invokeAll(function(i) {
|
|
1658
|
+
return i.beforeRoot && i.beforeRoot();
|
|
1659
1659
|
})).then(function() {
|
|
1660
1660
|
return Promise.all([
|
|
1661
1661
|
n.getDependencies("scene"),
|
|
1662
1662
|
n.getDependencies("animation"),
|
|
1663
1663
|
n.getDependencies("camera")
|
|
1664
1664
|
]);
|
|
1665
|
-
}).then(function(
|
|
1665
|
+
}).then(function(i) {
|
|
1666
1666
|
const c = {
|
|
1667
|
-
scene:
|
|
1668
|
-
scenes:
|
|
1669
|
-
animations:
|
|
1670
|
-
cameras:
|
|
1667
|
+
scene: i[0][s.scene || 0],
|
|
1668
|
+
scenes: i[0],
|
|
1669
|
+
animations: i[1],
|
|
1670
|
+
cameras: i[2],
|
|
1671
1671
|
asset: s.asset,
|
|
1672
1672
|
parser: n,
|
|
1673
1673
|
userData: {}
|
|
1674
1674
|
};
|
|
1675
|
-
return
|
|
1675
|
+
return Q(o, c, s), B(c, s), Promise.all(n._invokeAll(function(a) {
|
|
1676
1676
|
return a.afterRoot && a.afterRoot(c);
|
|
1677
1677
|
})).then(function() {
|
|
1678
1678
|
for (const a of c.scenes)
|
|
@@ -1688,14 +1688,14 @@ class sn {
|
|
|
1688
1688
|
*/
|
|
1689
1689
|
_markDefs() {
|
|
1690
1690
|
const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
|
|
1691
|
-
for (let s = 0,
|
|
1692
|
-
const
|
|
1693
|
-
for (let c = 0, a =
|
|
1694
|
-
e[
|
|
1691
|
+
for (let s = 0, o = t.length; s < o; s++) {
|
|
1692
|
+
const i = t[s].joints;
|
|
1693
|
+
for (let c = 0, a = i.length; c < a; c++)
|
|
1694
|
+
e[i[c]].isBone = !0;
|
|
1695
1695
|
}
|
|
1696
|
-
for (let s = 0,
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1696
|
+
for (let s = 0, o = e.length; s < o; s++) {
|
|
1697
|
+
const i = e[s];
|
|
1698
|
+
i.mesh !== void 0 && (this._addNodeRef(this.meshCache, i.mesh), i.skin !== void 0 && (n[i.mesh].isSkinnedMesh = !0)), i.camera !== void 0 && this._addNodeRef(this.cameraCache, i.camera);
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
1701
1701
|
/**
|
|
@@ -1725,13 +1725,13 @@ class sn {
|
|
|
1725
1725
|
*/
|
|
1726
1726
|
_getNodeRef(e, t, n) {
|
|
1727
1727
|
if (e.refs[t] <= 1) return n;
|
|
1728
|
-
const s = n.clone(),
|
|
1729
|
-
const a = this.associations.get(
|
|
1728
|
+
const s = n.clone(), o = (i, c) => {
|
|
1729
|
+
const a = this.associations.get(i);
|
|
1730
1730
|
a != null && this.associations.set(c, a);
|
|
1731
|
-
for (const [l, u] of
|
|
1732
|
-
|
|
1731
|
+
for (const [l, u] of i.children.entries())
|
|
1732
|
+
o(u, c.children[l]);
|
|
1733
1733
|
};
|
|
1734
|
-
return
|
|
1734
|
+
return o(n, s), s.name += "_instance_" + e.uses[t]++, s;
|
|
1735
1735
|
}
|
|
1736
1736
|
_invokeOne(e) {
|
|
1737
1737
|
const t = Object.values(this.plugins);
|
|
@@ -1747,8 +1747,8 @@ class sn {
|
|
|
1747
1747
|
t.unshift(this);
|
|
1748
1748
|
const n = [];
|
|
1749
1749
|
for (let s = 0; s < t.length; s++) {
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1750
|
+
const o = e(t[s]);
|
|
1751
|
+
o && n.push(o);
|
|
1752
1752
|
}
|
|
1753
1753
|
return n;
|
|
1754
1754
|
}
|
|
@@ -1769,50 +1769,50 @@ class sn {
|
|
|
1769
1769
|
s = this.loadScene(t);
|
|
1770
1770
|
break;
|
|
1771
1771
|
case "node":
|
|
1772
|
-
s = this._invokeOne(function(
|
|
1773
|
-
return
|
|
1772
|
+
s = this._invokeOne(function(o) {
|
|
1773
|
+
return o.loadNode && o.loadNode(t);
|
|
1774
1774
|
});
|
|
1775
1775
|
break;
|
|
1776
1776
|
case "mesh":
|
|
1777
|
-
s = this._invokeOne(function(
|
|
1778
|
-
return
|
|
1777
|
+
s = this._invokeOne(function(o) {
|
|
1778
|
+
return o.loadMesh && o.loadMesh(t);
|
|
1779
1779
|
});
|
|
1780
1780
|
break;
|
|
1781
1781
|
case "accessor":
|
|
1782
1782
|
s = this.loadAccessor(t);
|
|
1783
1783
|
break;
|
|
1784
1784
|
case "bufferView":
|
|
1785
|
-
s = this._invokeOne(function(
|
|
1786
|
-
return
|
|
1785
|
+
s = this._invokeOne(function(o) {
|
|
1786
|
+
return o.loadBufferView && o.loadBufferView(t);
|
|
1787
1787
|
});
|
|
1788
1788
|
break;
|
|
1789
1789
|
case "buffer":
|
|
1790
1790
|
s = this.loadBuffer(t);
|
|
1791
1791
|
break;
|
|
1792
1792
|
case "material":
|
|
1793
|
-
s = this._invokeOne(function(
|
|
1794
|
-
return
|
|
1793
|
+
s = this._invokeOne(function(o) {
|
|
1794
|
+
return o.loadMaterial && o.loadMaterial(t);
|
|
1795
1795
|
});
|
|
1796
1796
|
break;
|
|
1797
1797
|
case "texture":
|
|
1798
|
-
s = this._invokeOne(function(
|
|
1799
|
-
return
|
|
1798
|
+
s = this._invokeOne(function(o) {
|
|
1799
|
+
return o.loadTexture && o.loadTexture(t);
|
|
1800
1800
|
});
|
|
1801
1801
|
break;
|
|
1802
1802
|
case "skin":
|
|
1803
1803
|
s = this.loadSkin(t);
|
|
1804
1804
|
break;
|
|
1805
1805
|
case "animation":
|
|
1806
|
-
s = this._invokeOne(function(
|
|
1807
|
-
return
|
|
1806
|
+
s = this._invokeOne(function(o) {
|
|
1807
|
+
return o.loadAnimation && o.loadAnimation(t);
|
|
1808
1808
|
});
|
|
1809
1809
|
break;
|
|
1810
1810
|
case "camera":
|
|
1811
1811
|
s = this.loadCamera(t);
|
|
1812
1812
|
break;
|
|
1813
1813
|
default:
|
|
1814
|
-
if (s = this._invokeOne(function(
|
|
1815
|
-
return
|
|
1814
|
+
if (s = this._invokeOne(function(o) {
|
|
1815
|
+
return o != this && o.getDependency && o.getDependency(e, t);
|
|
1816
1816
|
}), !s)
|
|
1817
1817
|
throw new Error("Unknown type: " + e);
|
|
1818
1818
|
break;
|
|
@@ -1832,8 +1832,8 @@ class sn {
|
|
|
1832
1832
|
let t = this.cache.get(e);
|
|
1833
1833
|
if (!t) {
|
|
1834
1834
|
const n = this, s = this.json[e + (e === "mesh" ? "es" : "s")] || [];
|
|
1835
|
-
t = Promise.all(s.map(function(
|
|
1836
|
-
return n.getDependency(e,
|
|
1835
|
+
t = Promise.all(s.map(function(o, i) {
|
|
1836
|
+
return n.getDependency(e, i);
|
|
1837
1837
|
})), this.cache.add(e, t);
|
|
1838
1838
|
}
|
|
1839
1839
|
return t;
|
|
@@ -1852,9 +1852,9 @@ class sn {
|
|
|
1852
1852
|
if (t.uri === void 0 && e === 0)
|
|
1853
1853
|
return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);
|
|
1854
1854
|
const s = this.options;
|
|
1855
|
-
return new Promise(function(
|
|
1856
|
-
n.load(re.resolveURL(t.uri, s.path),
|
|
1857
|
-
|
|
1855
|
+
return new Promise(function(o, i) {
|
|
1856
|
+
n.load(re.resolveURL(t.uri, s.path), o, void 0, function() {
|
|
1857
|
+
i(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
|
|
1858
1858
|
});
|
|
1859
1859
|
});
|
|
1860
1860
|
}
|
|
@@ -1868,8 +1868,8 @@ class sn {
|
|
|
1868
1868
|
loadBufferView(e) {
|
|
1869
1869
|
const t = this.json.bufferViews[e];
|
|
1870
1870
|
return this.getDependency("buffer", t.buffer).then(function(n) {
|
|
1871
|
-
const s = t.byteLength || 0,
|
|
1872
|
-
return n.slice(
|
|
1871
|
+
const s = t.byteLength || 0, o = t.byteOffset || 0;
|
|
1872
|
+
return n.slice(o, o + s);
|
|
1873
1873
|
});
|
|
1874
1874
|
}
|
|
1875
1875
|
/**
|
|
@@ -1882,25 +1882,25 @@ class sn {
|
|
|
1882
1882
|
loadAccessor(e) {
|
|
1883
1883
|
const t = this, n = this.json, s = this.json.accessors[e];
|
|
1884
1884
|
if (s.bufferView === void 0 && s.sparse === void 0) {
|
|
1885
|
-
const
|
|
1886
|
-
return Promise.resolve(new oe(l,
|
|
1885
|
+
const i = Ae[s.type], c = te[s.componentType], a = s.normalized === !0, l = new c(s.count * i);
|
|
1886
|
+
return Promise.resolve(new oe(l, i, a));
|
|
1887
1887
|
}
|
|
1888
|
-
const
|
|
1889
|
-
return s.bufferView !== void 0 ?
|
|
1890
|
-
const c =
|
|
1888
|
+
const o = [];
|
|
1889
|
+
return s.bufferView !== void 0 ? o.push(this.getDependency("bufferView", s.bufferView)) : o.push(null), s.sparse !== void 0 && (o.push(this.getDependency("bufferView", s.sparse.indices.bufferView)), o.push(this.getDependency("bufferView", s.sparse.values.bufferView))), Promise.all(o).then(function(i) {
|
|
1890
|
+
const c = i[0], a = Ae[s.type], l = te[s.componentType], u = l.BYTES_PER_ELEMENT, h = u * a, p = s.byteOffset || 0, m = s.bufferView !== void 0 ? n.bufferViews[s.bufferView].byteStride : void 0, _ = s.normalized === !0;
|
|
1891
1891
|
let w, d;
|
|
1892
1892
|
if (m && m !== h) {
|
|
1893
1893
|
const f = Math.floor(p / m), g = "InterleavedBuffer:" + s.bufferView + ":" + s.componentType + ":" + f + ":" + s.count;
|
|
1894
1894
|
let T = t.cache.get(g);
|
|
1895
|
-
T || (w = new l(c, f * m, s.count * m / u), T = new
|
|
1895
|
+
T || (w = new l(c, f * m, s.count * m / u), T = new Mt(w, m / u), t.cache.add(g, T)), d = new St(T, a, p % m / u, _);
|
|
1896
1896
|
} else
|
|
1897
1897
|
c === null ? w = new l(s.count * a) : w = new l(c, p, s.count * a), d = new oe(w, a, _);
|
|
1898
1898
|
if (s.sparse !== void 0) {
|
|
1899
|
-
const f =
|
|
1899
|
+
const f = Ae.SCALAR, g = te[s.sparse.indices.componentType], T = s.sparse.indices.byteOffset || 0, y = s.sparse.values.byteOffset || 0, E = new g(i[1], T, s.sparse.count * f), x = new l(i[2], y, s.sparse.count * a);
|
|
1900
1900
|
c !== null && (d = new oe(d.array.slice(), d.itemSize, d.normalized)), d.normalized = !1;
|
|
1901
|
-
for (let M = 0,
|
|
1902
|
-
const
|
|
1903
|
-
if (d.setX(
|
|
1901
|
+
for (let M = 0, C = E.length; M < C; M++) {
|
|
1902
|
+
const P = E[M];
|
|
1903
|
+
if (d.setX(P, x[M * a]), a >= 2 && d.setY(P, x[M * a + 1]), a >= 3 && d.setZ(P, x[M * a + 2]), a >= 4 && d.setW(P, x[M * a + 3]), a >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1904
1904
|
}
|
|
1905
1905
|
d.normalized = _;
|
|
1906
1906
|
}
|
|
@@ -1915,51 +1915,51 @@ class sn {
|
|
|
1915
1915
|
* @return {Promise<THREE.Texture|null>}
|
|
1916
1916
|
*/
|
|
1917
1917
|
loadTexture(e) {
|
|
1918
|
-
const t = this.json, n = this.options,
|
|
1918
|
+
const t = this.json, n = this.options, o = t.textures[e].source, i = t.images[o];
|
|
1919
1919
|
let c = this.textureLoader;
|
|
1920
|
-
if (
|
|
1921
|
-
const a = n.manager.getHandler(
|
|
1920
|
+
if (i.uri) {
|
|
1921
|
+
const a = n.manager.getHandler(i.uri);
|
|
1922
1922
|
a !== null && (c = a);
|
|
1923
1923
|
}
|
|
1924
|
-
return this.loadTextureImage(e,
|
|
1924
|
+
return this.loadTextureImage(e, o, c);
|
|
1925
1925
|
}
|
|
1926
1926
|
loadTextureImage(e, t, n) {
|
|
1927
|
-
const s = this,
|
|
1927
|
+
const s = this, o = this.json, i = o.textures[e], c = o.images[t], a = (c.uri || c.bufferView) + ":" + i.sampler;
|
|
1928
1928
|
if (this.textureCache[a])
|
|
1929
1929
|
return this.textureCache[a];
|
|
1930
1930
|
const l = this.loadImageSource(t, n).then(function(u) {
|
|
1931
|
-
u.flipY = !1, u.name =
|
|
1932
|
-
const p = (
|
|
1933
|
-
return u.magFilter =
|
|
1931
|
+
u.flipY = !1, u.name = i.name || c.name || "", u.name === "" && typeof c.uri == "string" && c.uri.startsWith("data:image/") === !1 && (u.name = c.uri);
|
|
1932
|
+
const p = (o.samplers || {})[i.sampler] || {};
|
|
1933
|
+
return u.magFilter = $e[p.magFilter] || Oe, u.minFilter = $e[p.minFilter] || rt, u.wrapS = qe[p.wrapS] || Ie, u.wrapT = qe[p.wrapT] || Ie, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== at && u.minFilter !== Oe, s.associations.set(u, { textures: e }), u;
|
|
1934
1934
|
}).catch(function() {
|
|
1935
1935
|
return null;
|
|
1936
1936
|
});
|
|
1937
1937
|
return this.textureCache[a] = l, l;
|
|
1938
1938
|
}
|
|
1939
1939
|
loadImageSource(e, t) {
|
|
1940
|
-
const n = this, s = this.json,
|
|
1940
|
+
const n = this, s = this.json, o = this.options;
|
|
1941
1941
|
if (this.sourceCache[e] !== void 0)
|
|
1942
1942
|
return this.sourceCache[e].then((h) => h.clone());
|
|
1943
|
-
const
|
|
1944
|
-
let a =
|
|
1945
|
-
if (
|
|
1946
|
-
a = n.getDependency("bufferView",
|
|
1943
|
+
const i = s.images[e], c = self.URL || self.webkitURL;
|
|
1944
|
+
let a = i.uri || "", l = !1;
|
|
1945
|
+
if (i.bufferView !== void 0)
|
|
1946
|
+
a = n.getDependency("bufferView", i.bufferView).then(function(h) {
|
|
1947
1947
|
l = !0;
|
|
1948
|
-
const p = new Blob([h], { type:
|
|
1948
|
+
const p = new Blob([h], { type: i.mimeType });
|
|
1949
1949
|
return a = c.createObjectURL(p), a;
|
|
1950
1950
|
});
|
|
1951
|
-
else if (
|
|
1951
|
+
else if (i.uri === void 0)
|
|
1952
1952
|
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
|
|
1953
1953
|
const u = Promise.resolve(a).then(function(h) {
|
|
1954
1954
|
return new Promise(function(p, m) {
|
|
1955
1955
|
let _ = p;
|
|
1956
1956
|
t.isImageBitmapLoader === !0 && (_ = function(w) {
|
|
1957
|
-
const d = new
|
|
1957
|
+
const d = new Ge(w);
|
|
1958
1958
|
d.needsUpdate = !0, p(d);
|
|
1959
|
-
}), t.load(re.resolveURL(h,
|
|
1959
|
+
}), t.load(re.resolveURL(h, o.path), _, void 0, m);
|
|
1960
1960
|
});
|
|
1961
1961
|
}).then(function(h) {
|
|
1962
|
-
return l === !0 && c.revokeObjectURL(a),
|
|
1962
|
+
return l === !0 && c.revokeObjectURL(a), B(h, i), h.userData.mimeType = i.mimeType || Js(i.uri), h;
|
|
1963
1963
|
}).catch(function(h) {
|
|
1964
1964
|
throw console.error("THREE.GLTFLoader: Couldn't load texture", a), h;
|
|
1965
1965
|
});
|
|
@@ -1976,17 +1976,17 @@ class sn {
|
|
|
1976
1976
|
* @return {Promise<Texture>}
|
|
1977
1977
|
*/
|
|
1978
1978
|
assignTexture(e, t, n, s) {
|
|
1979
|
-
const
|
|
1980
|
-
return this.getDependency("texture", n.index).then(function(
|
|
1981
|
-
if (!
|
|
1982
|
-
if (n.texCoord !== void 0 && n.texCoord > 0 && (
|
|
1979
|
+
const o = this;
|
|
1980
|
+
return this.getDependency("texture", n.index).then(function(i) {
|
|
1981
|
+
if (!i) return null;
|
|
1982
|
+
if (n.texCoord !== void 0 && n.texCoord > 0 && (i = i.clone(), i.channel = n.texCoord), o.extensions[b.KHR_TEXTURE_TRANSFORM]) {
|
|
1983
1983
|
const c = n.extensions !== void 0 ? n.extensions[b.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1984
1984
|
if (c) {
|
|
1985
|
-
const a =
|
|
1986
|
-
|
|
1985
|
+
const a = o.associations.get(i);
|
|
1986
|
+
i = o.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(i, c), o.associations.set(i, a);
|
|
1987
1987
|
}
|
|
1988
1988
|
}
|
|
1989
|
-
return s !== void 0 && (
|
|
1989
|
+
return s !== void 0 && (i.colorSpace = s), e[t] = i, i;
|
|
1990
1990
|
});
|
|
1991
1991
|
}
|
|
1992
1992
|
/**
|
|
@@ -2002,26 +2002,26 @@ class sn {
|
|
|
2002
2002
|
assignFinalMaterial(e) {
|
|
2003
2003
|
const t = e.geometry;
|
|
2004
2004
|
let n = e.material;
|
|
2005
|
-
const s = t.attributes.tangent === void 0,
|
|
2005
|
+
const s = t.attributes.tangent === void 0, o = t.attributes.color !== void 0, i = t.attributes.normal === void 0;
|
|
2006
2006
|
if (e.isPoints) {
|
|
2007
2007
|
const c = "PointsMaterial:" + n.uuid;
|
|
2008
2008
|
let a = this.cache.get(c);
|
|
2009
|
-
a || (a = new It(),
|
|
2009
|
+
a || (a = new It(), we.prototype.copy.call(a, n), a.color.copy(n.color), a.map = n.map, a.sizeAttenuation = !1, this.cache.add(c, a)), n = a;
|
|
2010
2010
|
} else if (e.isLine) {
|
|
2011
2011
|
const c = "LineBasicMaterial:" + n.uuid;
|
|
2012
2012
|
let a = this.cache.get(c);
|
|
2013
|
-
a || (a = new
|
|
2013
|
+
a || (a = new kt(), we.prototype.copy.call(a, n), a.color.copy(n.color), a.map = n.map, this.cache.add(c, a)), n = a;
|
|
2014
2014
|
}
|
|
2015
|
-
if (s ||
|
|
2015
|
+
if (s || o || i) {
|
|
2016
2016
|
let c = "ClonedMaterial:" + n.uuid + ":";
|
|
2017
|
-
s && (c += "derivative-tangents:"),
|
|
2017
|
+
s && (c += "derivative-tangents:"), o && (c += "vertex-colors:"), i && (c += "flat-shading:");
|
|
2018
2018
|
let a = this.cache.get(c);
|
|
2019
|
-
a || (a = n.clone(),
|
|
2019
|
+
a || (a = n.clone(), o && (a.vertexColors = !0), i && (a.flatShading = !0), s && (a.normalScale && (a.normalScale.y *= -1), a.clearcoatNormalScale && (a.clearcoatNormalScale.y *= -1)), this.cache.add(c, a), this.associations.set(a, this.associations.get(n))), n = a;
|
|
2020
2020
|
}
|
|
2021
2021
|
e.material = n;
|
|
2022
2022
|
}
|
|
2023
2023
|
getMaterialType() {
|
|
2024
|
-
return
|
|
2024
|
+
return ct;
|
|
2025
2025
|
}
|
|
2026
2026
|
/**
|
|
2027
2027
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
@@ -2031,37 +2031,37 @@ class sn {
|
|
|
2031
2031
|
* @return {Promise<Material>}
|
|
2032
2032
|
*/
|
|
2033
2033
|
loadMaterial(e) {
|
|
2034
|
-
const t = this, n = this.json, s = this.extensions,
|
|
2035
|
-
let
|
|
2036
|
-
const c = {}, a =
|
|
2034
|
+
const t = this, n = this.json, s = this.extensions, o = n.materials[e];
|
|
2035
|
+
let i;
|
|
2036
|
+
const c = {}, a = o.extensions || {}, l = [];
|
|
2037
2037
|
if (a[b.KHR_MATERIALS_UNLIT]) {
|
|
2038
2038
|
const h = s[b.KHR_MATERIALS_UNLIT];
|
|
2039
|
-
|
|
2039
|
+
i = h.getMaterialType(), l.push(h.extendParams(c, o, t));
|
|
2040
2040
|
} else {
|
|
2041
|
-
const h =
|
|
2041
|
+
const h = o.pbrMetallicRoughness || {};
|
|
2042
2042
|
if (c.color = new q(1, 1, 1), c.opacity = 1, Array.isArray(h.baseColorFactor)) {
|
|
2043
2043
|
const p = h.baseColorFactor;
|
|
2044
|
-
c.color.setRGB(p[0], p[1], p[2],
|
|
2044
|
+
c.color.setRGB(p[0], p[1], p[2], j), c.opacity = p[3];
|
|
2045
2045
|
}
|
|
2046
|
-
h.baseColorTexture !== void 0 && l.push(t.assignTexture(c, "map", h.baseColorTexture,
|
|
2046
|
+
h.baseColorTexture !== void 0 && l.push(t.assignTexture(c, "map", h.baseColorTexture, $)), c.metalness = h.metallicFactor !== void 0 ? h.metallicFactor : 1, c.roughness = h.roughnessFactor !== void 0 ? h.roughnessFactor : 1, h.metallicRoughnessTexture !== void 0 && (l.push(t.assignTexture(c, "metalnessMap", h.metallicRoughnessTexture)), l.push(t.assignTexture(c, "roughnessMap", h.metallicRoughnessTexture))), i = this._invokeOne(function(p) {
|
|
2047
2047
|
return p.getMaterialType && p.getMaterialType(e);
|
|
2048
2048
|
}), l.push(Promise.all(this._invokeAll(function(p) {
|
|
2049
2049
|
return p.extendMaterialParams && p.extendMaterialParams(e, c);
|
|
2050
2050
|
})));
|
|
2051
2051
|
}
|
|
2052
|
-
|
|
2053
|
-
const u =
|
|
2054
|
-
if (u ===
|
|
2055
|
-
const h =
|
|
2052
|
+
o.doubleSided === !0 && (c.side = Nt);
|
|
2053
|
+
const u = o.alphaMode || Re.OPAQUE;
|
|
2054
|
+
if (u === Re.BLEND ? (c.transparent = !0, c.depthWrite = !1) : (c.transparent = !1, u === Re.MASK && (c.alphaTest = o.alphaCutoff !== void 0 ? o.alphaCutoff : 0.5)), o.normalTexture !== void 0 && i !== ie && (l.push(t.assignTexture(c, "normalMap", o.normalTexture)), c.normalScale = new I(1, 1), o.normalTexture.scale !== void 0)) {
|
|
2055
|
+
const h = o.normalTexture.scale;
|
|
2056
2056
|
c.normalScale.set(h, h);
|
|
2057
2057
|
}
|
|
2058
|
-
if (
|
|
2059
|
-
const h =
|
|
2060
|
-
c.emissive = new q().setRGB(h[0], h[1], h[2],
|
|
2058
|
+
if (o.occlusionTexture !== void 0 && i !== ie && (l.push(t.assignTexture(c, "aoMap", o.occlusionTexture)), o.occlusionTexture.strength !== void 0 && (c.aoMapIntensity = o.occlusionTexture.strength)), o.emissiveFactor !== void 0 && i !== ie) {
|
|
2059
|
+
const h = o.emissiveFactor;
|
|
2060
|
+
c.emissive = new q().setRGB(h[0], h[1], h[2], j);
|
|
2061
2061
|
}
|
|
2062
|
-
return
|
|
2063
|
-
const h = new
|
|
2064
|
-
return
|
|
2062
|
+
return o.emissiveTexture !== void 0 && i !== ie && l.push(t.assignTexture(c, "emissiveMap", o.emissiveTexture, $)), Promise.all(l).then(function() {
|
|
2063
|
+
const h = new i(c);
|
|
2064
|
+
return o.name && (h.name = o.name), B(h, o), t.associations.set(h, { materials: e }), o.extensions && Q(s, h, o), h;
|
|
2065
2065
|
});
|
|
2066
2066
|
}
|
|
2067
2067
|
/**
|
|
@@ -2072,7 +2072,7 @@ class sn {
|
|
|
2072
2072
|
* @return {string}
|
|
2073
2073
|
*/
|
|
2074
2074
|
createUniqueName(e) {
|
|
2075
|
-
const t =
|
|
2075
|
+
const t = vt.sanitizeNodeName(e || "");
|
|
2076
2076
|
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
|
|
2077
2077
|
}
|
|
2078
2078
|
/**
|
|
@@ -2086,22 +2086,22 @@ class sn {
|
|
|
2086
2086
|
*/
|
|
2087
2087
|
loadGeometries(e) {
|
|
2088
2088
|
const t = this, n = this.extensions, s = this.primitiveCache;
|
|
2089
|
-
function
|
|
2089
|
+
function o(c) {
|
|
2090
2090
|
return n[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c, t).then(function(a) {
|
|
2091
|
-
return
|
|
2091
|
+
return Ze(a, c, t);
|
|
2092
2092
|
});
|
|
2093
2093
|
}
|
|
2094
|
-
const
|
|
2094
|
+
const i = [];
|
|
2095
2095
|
for (let c = 0, a = e.length; c < a; c++) {
|
|
2096
|
-
const l = e[c], u =
|
|
2096
|
+
const l = e[c], u = Qs(l), h = s[u];
|
|
2097
2097
|
if (h)
|
|
2098
|
-
|
|
2098
|
+
i.push(h.promise);
|
|
2099
2099
|
else {
|
|
2100
2100
|
let p;
|
|
2101
|
-
l.extensions && l.extensions[b.KHR_DRACO_MESH_COMPRESSION] ? p =
|
|
2101
|
+
l.extensions && l.extensions[b.KHR_DRACO_MESH_COMPRESSION] ? p = o(l) : p = Ze(new ot(), l, t), s[u] = { primitive: l, promise: p }, i.push(p);
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
2104
|
-
return Promise.all(
|
|
2104
|
+
return Promise.all(i);
|
|
2105
2105
|
}
|
|
2106
2106
|
/**
|
|
2107
2107
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
@@ -2111,30 +2111,30 @@ class sn {
|
|
|
2111
2111
|
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
2112
2112
|
*/
|
|
2113
2113
|
loadMesh(e) {
|
|
2114
|
-
const t = this, n = this.json, s = this.extensions,
|
|
2115
|
-
for (let a = 0, l =
|
|
2116
|
-
const u =
|
|
2114
|
+
const t = this, n = this.json, s = this.extensions, o = n.meshes[e], i = o.primitives, c = [];
|
|
2115
|
+
for (let a = 0, l = i.length; a < l; a++) {
|
|
2116
|
+
const u = i[a].material === void 0 ? $s(this.cache) : this.getDependency("material", i[a].material);
|
|
2117
2117
|
c.push(u);
|
|
2118
2118
|
}
|
|
2119
|
-
return c.push(t.loadGeometries(
|
|
2119
|
+
return c.push(t.loadGeometries(i)), Promise.all(c).then(function(a) {
|
|
2120
2120
|
const l = a.slice(0, a.length - 1), u = a[a.length - 1], h = [];
|
|
2121
2121
|
for (let m = 0, _ = u.length; m < _; m++) {
|
|
2122
|
-
const w = u[m], d =
|
|
2122
|
+
const w = u[m], d = i[m];
|
|
2123
2123
|
let f;
|
|
2124
2124
|
const g = l[m];
|
|
2125
|
-
if (d.mode ===
|
|
2126
|
-
f =
|
|
2127
|
-
else if (d.mode ===
|
|
2125
|
+
if (d.mode === k.TRIANGLES || d.mode === k.TRIANGLE_STRIP || d.mode === k.TRIANGLE_FAN || d.mode === void 0)
|
|
2126
|
+
f = o.isSkinnedMesh === !0 ? new Ht(w, g) : new Ft(w, g), f.isSkinnedMesh === !0 && f.normalizeSkinWeights(), d.mode === k.TRIANGLE_STRIP ? f.geometry = Xe(f.geometry, nt) : d.mode === k.TRIANGLE_FAN && (f.geometry = Xe(f.geometry, Ce));
|
|
2127
|
+
else if (d.mode === k.LINES)
|
|
2128
|
+
f = new Ut(w, g);
|
|
2129
|
+
else if (d.mode === k.LINE_STRIP)
|
|
2128
2130
|
f = new jt(w, g);
|
|
2129
|
-
else if (d.mode ===
|
|
2131
|
+
else if (d.mode === k.LINE_LOOP)
|
|
2130
2132
|
f = new Gt(w, g);
|
|
2131
|
-
else if (d.mode ===
|
|
2133
|
+
else if (d.mode === k.POINTS)
|
|
2132
2134
|
f = new Bt(w, g);
|
|
2133
|
-
else if (d.mode === I.POINTS)
|
|
2134
|
-
f = new zt(w, g);
|
|
2135
2135
|
else
|
|
2136
2136
|
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + d.mode);
|
|
2137
|
-
Object.keys(f.geometry.morphAttributes).length > 0 &&
|
|
2137
|
+
Object.keys(f.geometry.morphAttributes).length > 0 && Zs(f, o), f.name = t.createUniqueName(o.name || "mesh_" + e), B(f, o), d.extensions && Q(s, f, d), t.assignFinalMaterial(f), h.push(f);
|
|
2138
2138
|
}
|
|
2139
2139
|
for (let m = 0, _ = h.length; m < _; m++)
|
|
2140
2140
|
t.associations.set(h[m], {
|
|
@@ -2142,9 +2142,9 @@ class sn {
|
|
|
2142
2142
|
primitives: m
|
|
2143
2143
|
});
|
|
2144
2144
|
if (h.length === 1)
|
|
2145
|
-
return
|
|
2146
|
-
const p = new
|
|
2147
|
-
|
|
2145
|
+
return o.extensions && Q(s, h[0], o), h[0];
|
|
2146
|
+
const p = new be();
|
|
2147
|
+
o.extensions && Q(s, p, o), t.associations.set(p, { meshes: e });
|
|
2148
2148
|
for (let m = 0, _ = h.length; m < _; m++)
|
|
2149
2149
|
p.add(h[m]);
|
|
2150
2150
|
return p;
|
|
@@ -2164,7 +2164,7 @@ class sn {
|
|
|
2164
2164
|
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
2165
2165
|
return;
|
|
2166
2166
|
}
|
|
2167
|
-
return n.type === "perspective" ? t = new
|
|
2167
|
+
return n.type === "perspective" ? t = new zt(st.radToDeg(s.yfov), s.aspectRatio || 1, s.znear || 1, s.zfar || 2e6) : n.type === "orthographic" && (t = new Kt(-s.xmag, s.xmag, s.ymag, -s.ymag, s.znear, s.zfar)), n.name && (t.name = this.createUniqueName(n.name)), B(t, n), Promise.resolve(t);
|
|
2168
2168
|
}
|
|
2169
2169
|
/**
|
|
2170
2170
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
@@ -2175,20 +2175,20 @@ class sn {
|
|
|
2175
2175
|
*/
|
|
2176
2176
|
loadSkin(e) {
|
|
2177
2177
|
const t = this.json.skins[e], n = [];
|
|
2178
|
-
for (let s = 0,
|
|
2178
|
+
for (let s = 0, o = t.joints.length; s < o; s++)
|
|
2179
2179
|
n.push(this._loadNodeShallow(t.joints[s]));
|
|
2180
2180
|
return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(s) {
|
|
2181
|
-
const
|
|
2182
|
-
for (let l = 0, u =
|
|
2183
|
-
const h =
|
|
2181
|
+
const o = s.pop(), i = s, c = [], a = [];
|
|
2182
|
+
for (let l = 0, u = i.length; l < u; l++) {
|
|
2183
|
+
const h = i[l];
|
|
2184
2184
|
if (h) {
|
|
2185
2185
|
c.push(h);
|
|
2186
2186
|
const p = new se();
|
|
2187
|
-
|
|
2187
|
+
o !== null && p.fromArray(o.array, l * 16), a.push(p);
|
|
2188
2188
|
} else
|
|
2189
2189
|
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[l]);
|
|
2190
2190
|
}
|
|
2191
|
-
return new
|
|
2191
|
+
return new Wt(c, a);
|
|
2192
2192
|
});
|
|
2193
2193
|
}
|
|
2194
2194
|
/**
|
|
@@ -2199,13 +2199,13 @@ class sn {
|
|
|
2199
2199
|
* @return {Promise<AnimationClip>}
|
|
2200
2200
|
*/
|
|
2201
2201
|
loadAnimation(e) {
|
|
2202
|
-
const t = this.json, n = this, s = t.animations[e],
|
|
2202
|
+
const t = this.json, n = this, s = t.animations[e], o = s.name ? s.name : "animation_" + e, i = [], c = [], a = [], l = [], u = [];
|
|
2203
2203
|
for (let h = 0, p = s.channels.length; h < p; h++) {
|
|
2204
2204
|
const m = s.channels[h], _ = s.samplers[m.sampler], w = m.target, d = w.node, f = s.parameters !== void 0 ? s.parameters[_.input] : _.input, g = s.parameters !== void 0 ? s.parameters[_.output] : _.output;
|
|
2205
|
-
w.node !== void 0 && (
|
|
2205
|
+
w.node !== void 0 && (i.push(this.getDependency("node", d)), c.push(this.getDependency("accessor", f)), a.push(this.getDependency("accessor", g)), l.push(_), u.push(w));
|
|
2206
2206
|
}
|
|
2207
2207
|
return Promise.all([
|
|
2208
|
-
Promise.all(
|
|
2208
|
+
Promise.all(i),
|
|
2209
2209
|
Promise.all(c),
|
|
2210
2210
|
Promise.all(a),
|
|
2211
2211
|
Promise.all(l),
|
|
@@ -2213,26 +2213,26 @@ class sn {
|
|
|
2213
2213
|
]).then(function(h) {
|
|
2214
2214
|
const p = h[0], m = h[1], _ = h[2], w = h[3], d = h[4], f = [];
|
|
2215
2215
|
for (let g = 0, T = p.length; g < T; g++) {
|
|
2216
|
-
const y = p[g], E = m[g], x = _[g], M = w[g],
|
|
2216
|
+
const y = p[g], E = m[g], x = _[g], M = w[g], C = d[g];
|
|
2217
2217
|
if (y === void 0) continue;
|
|
2218
2218
|
y.updateMatrix && y.updateMatrix();
|
|
2219
|
-
const
|
|
2220
|
-
if (
|
|
2221
|
-
for (let
|
|
2222
|
-
f.push(
|
|
2219
|
+
const P = n._createAnimationTracks(y, E, x, M, C);
|
|
2220
|
+
if (P)
|
|
2221
|
+
for (let K = 0; K < P.length; K++)
|
|
2222
|
+
f.push(P[K]);
|
|
2223
2223
|
}
|
|
2224
|
-
return new Vt(
|
|
2224
|
+
return new Vt(o, void 0, f);
|
|
2225
2225
|
});
|
|
2226
2226
|
}
|
|
2227
2227
|
createNodeMesh(e) {
|
|
2228
2228
|
const t = this.json, n = this, s = t.nodes[e];
|
|
2229
|
-
return s.mesh === void 0 ? null : n.getDependency("mesh", s.mesh).then(function(
|
|
2230
|
-
const
|
|
2231
|
-
return s.weights !== void 0 &&
|
|
2229
|
+
return s.mesh === void 0 ? null : n.getDependency("mesh", s.mesh).then(function(o) {
|
|
2230
|
+
const i = n._getNodeRef(n.meshCache, s.mesh, o);
|
|
2231
|
+
return s.weights !== void 0 && i.traverse(function(c) {
|
|
2232
2232
|
if (c.isMesh)
|
|
2233
2233
|
for (let a = 0, l = s.weights.length; a < l; a++)
|
|
2234
2234
|
c.morphTargetInfluences[a] = s.weights[a];
|
|
2235
|
-
}),
|
|
2235
|
+
}), i;
|
|
2236
2236
|
});
|
|
2237
2237
|
}
|
|
2238
2238
|
/**
|
|
@@ -2243,18 +2243,18 @@ class sn {
|
|
|
2243
2243
|
* @return {Promise<Object3D>}
|
|
2244
2244
|
*/
|
|
2245
2245
|
loadNode(e) {
|
|
2246
|
-
const t = this.json, n = this, s = t.nodes[e],
|
|
2246
|
+
const t = this.json, n = this, s = t.nodes[e], o = n._loadNodeShallow(e), i = [], c = s.children || [];
|
|
2247
2247
|
for (let l = 0, u = c.length; l < u; l++)
|
|
2248
|
-
|
|
2248
|
+
i.push(n.getDependency("node", c[l]));
|
|
2249
2249
|
const a = s.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", s.skin);
|
|
2250
2250
|
return Promise.all([
|
|
2251
|
-
|
|
2252
|
-
Promise.all(
|
|
2251
|
+
o,
|
|
2252
|
+
Promise.all(i),
|
|
2253
2253
|
a
|
|
2254
2254
|
]).then(function(l) {
|
|
2255
2255
|
const u = l[0], h = l[1], p = l[2];
|
|
2256
2256
|
p !== null && u.traverse(function(m) {
|
|
2257
|
-
m.isSkinnedMesh && m.bind(p,
|
|
2257
|
+
m.isSkinnedMesh && m.bind(p, en);
|
|
2258
2258
|
});
|
|
2259
2259
|
for (let m = 0, _ = h.length; m < _; m++)
|
|
2260
2260
|
u.add(h[m]);
|
|
@@ -2267,28 +2267,28 @@ class sn {
|
|
|
2267
2267
|
const t = this.json, n = this.extensions, s = this;
|
|
2268
2268
|
if (this.nodeCache[e] !== void 0)
|
|
2269
2269
|
return this.nodeCache[e];
|
|
2270
|
-
const
|
|
2270
|
+
const o = t.nodes[e], i = o.name ? s.createUniqueName(o.name) : "", c = [], a = s._invokeOne(function(l) {
|
|
2271
2271
|
return l.createNodeMesh && l.createNodeMesh(e);
|
|
2272
2272
|
});
|
|
2273
|
-
return a && c.push(a),
|
|
2274
|
-
return s._getNodeRef(s.cameraCache,
|
|
2273
|
+
return a && c.push(a), o.camera !== void 0 && c.push(s.getDependency("camera", o.camera).then(function(l) {
|
|
2274
|
+
return s._getNodeRef(s.cameraCache, o.camera, l);
|
|
2275
2275
|
})), s._invokeAll(function(l) {
|
|
2276
2276
|
return l.createNodeAttachment && l.createNodeAttachment(e);
|
|
2277
2277
|
}).forEach(function(l) {
|
|
2278
2278
|
c.push(l);
|
|
2279
2279
|
}), this.nodeCache[e] = Promise.all(c).then(function(l) {
|
|
2280
2280
|
let u;
|
|
2281
|
-
if (
|
|
2281
|
+
if (o.isBone === !0 ? u = new Xt() : l.length > 1 ? u = new be() : l.length === 1 ? u = l[0] : u = new He(), u !== l[0])
|
|
2282
2282
|
for (let h = 0, p = l.length; h < p; h++)
|
|
2283
2283
|
u.add(l[h]);
|
|
2284
|
-
if (
|
|
2284
|
+
if (o.name && (u.userData.name = o.name, u.name = i), B(u, o), o.extensions && Q(n, u, o), o.matrix !== void 0) {
|
|
2285
2285
|
const h = new se();
|
|
2286
|
-
h.fromArray(
|
|
2286
|
+
h.fromArray(o.matrix), u.applyMatrix4(h);
|
|
2287
2287
|
} else
|
|
2288
|
-
|
|
2288
|
+
o.translation !== void 0 && u.position.fromArray(o.translation), o.rotation !== void 0 && u.quaternion.fromArray(o.rotation), o.scale !== void 0 && u.scale.fromArray(o.scale);
|
|
2289
2289
|
if (!s.associations.has(u))
|
|
2290
2290
|
s.associations.set(u, {});
|
|
2291
|
-
else if (
|
|
2291
|
+
else if (o.mesh !== void 0 && s.meshCache.refs[o.mesh] > 1) {
|
|
2292
2292
|
const h = s.associations.get(u);
|
|
2293
2293
|
s.associations.set(u, { ...h });
|
|
2294
2294
|
}
|
|
@@ -2303,87 +2303,87 @@ class sn {
|
|
|
2303
2303
|
* @return {Promise<Group>}
|
|
2304
2304
|
*/
|
|
2305
2305
|
loadScene(e) {
|
|
2306
|
-
const t = this.extensions, n = this.json.scenes[e], s = this,
|
|
2307
|
-
n.name && (
|
|
2308
|
-
const
|
|
2309
|
-
for (let a = 0, l =
|
|
2310
|
-
c.push(s.getDependency("node",
|
|
2306
|
+
const t = this.extensions, n = this.json.scenes[e], s = this, o = new be();
|
|
2307
|
+
n.name && (o.name = s.createUniqueName(n.name)), B(o, n), n.extensions && Q(t, o, n);
|
|
2308
|
+
const i = n.nodes || [], c = [];
|
|
2309
|
+
for (let a = 0, l = i.length; a < l; a++)
|
|
2310
|
+
c.push(s.getDependency("node", i[a]));
|
|
2311
2311
|
return Promise.all(c).then(function(a) {
|
|
2312
2312
|
for (let u = 0, h = a.length; u < h; u++)
|
|
2313
|
-
|
|
2313
|
+
o.add(a[u]);
|
|
2314
2314
|
const l = (u) => {
|
|
2315
2315
|
const h = /* @__PURE__ */ new Map();
|
|
2316
2316
|
for (const [p, m] of s.associations)
|
|
2317
|
-
(p instanceof
|
|
2317
|
+
(p instanceof we || p instanceof Ge) && h.set(p, m);
|
|
2318
2318
|
return u.traverse((p) => {
|
|
2319
2319
|
const m = s.associations.get(p);
|
|
2320
2320
|
m != null && h.set(p, m);
|
|
2321
2321
|
}), h;
|
|
2322
2322
|
};
|
|
2323
|
-
return s.associations = l(
|
|
2323
|
+
return s.associations = l(o), o;
|
|
2324
2324
|
});
|
|
2325
2325
|
}
|
|
2326
|
-
_createAnimationTracks(e, t, n, s,
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2326
|
+
_createAnimationTracks(e, t, n, s, o) {
|
|
2327
|
+
const i = [], c = e.name ? e.name : e.uuid, a = [];
|
|
2328
|
+
W[o.path] === W.weights ? e.traverse(function(p) {
|
|
2329
2329
|
p.morphTargetInfluences && a.push(p.name ? p.name : p.uuid);
|
|
2330
2330
|
}) : a.push(c);
|
|
2331
2331
|
let l;
|
|
2332
|
-
switch (
|
|
2333
|
-
case
|
|
2334
|
-
l = Be;
|
|
2335
|
-
break;
|
|
2336
|
-
case K.rotation:
|
|
2332
|
+
switch (W[o.path]) {
|
|
2333
|
+
case W.weights:
|
|
2337
2334
|
l = ze;
|
|
2338
2335
|
break;
|
|
2339
|
-
case
|
|
2340
|
-
|
|
2341
|
-
|
|
2336
|
+
case W.rotation:
|
|
2337
|
+
l = Ke;
|
|
2338
|
+
break;
|
|
2339
|
+
case W.translation:
|
|
2340
|
+
case W.scale:
|
|
2341
|
+
l = Be;
|
|
2342
2342
|
break;
|
|
2343
2343
|
default:
|
|
2344
2344
|
switch (n.itemSize) {
|
|
2345
2345
|
case 1:
|
|
2346
|
-
l =
|
|
2346
|
+
l = ze;
|
|
2347
2347
|
break;
|
|
2348
2348
|
case 2:
|
|
2349
2349
|
case 3:
|
|
2350
2350
|
default:
|
|
2351
|
-
l =
|
|
2351
|
+
l = Be;
|
|
2352
2352
|
break;
|
|
2353
2353
|
}
|
|
2354
2354
|
break;
|
|
2355
2355
|
}
|
|
2356
|
-
const u = s.interpolation !== void 0 ?
|
|
2356
|
+
const u = s.interpolation !== void 0 ? Ys[s.interpolation] : lt, h = this._getArrayFromAccessor(n);
|
|
2357
2357
|
for (let p = 0, m = a.length; p < m; p++) {
|
|
2358
2358
|
const _ = new l(
|
|
2359
|
-
a[p] + "." +
|
|
2359
|
+
a[p] + "." + W[o.path],
|
|
2360
2360
|
t.array,
|
|
2361
2361
|
h,
|
|
2362
2362
|
u
|
|
2363
2363
|
);
|
|
2364
|
-
s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(_),
|
|
2364
|
+
s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(_), i.push(_);
|
|
2365
2365
|
}
|
|
2366
|
-
return
|
|
2366
|
+
return i;
|
|
2367
2367
|
}
|
|
2368
2368
|
_getArrayFromAccessor(e) {
|
|
2369
2369
|
let t = e.array;
|
|
2370
2370
|
if (e.normalized) {
|
|
2371
|
-
const n =
|
|
2372
|
-
for (let
|
|
2373
|
-
s[
|
|
2371
|
+
const n = Ne(t.constructor), s = new Float32Array(t.length);
|
|
2372
|
+
for (let o = 0, i = t.length; o < i; o++)
|
|
2373
|
+
s[o] = t[o] * n;
|
|
2374
2374
|
t = s;
|
|
2375
2375
|
}
|
|
2376
2376
|
return t;
|
|
2377
2377
|
}
|
|
2378
2378
|
_createCubicSplineTrackInterpolant(e) {
|
|
2379
2379
|
e.createInterpolant = function(n) {
|
|
2380
|
-
const s = this instanceof
|
|
2380
|
+
const s = this instanceof Ke ? Xs : ft;
|
|
2381
2381
|
return new s(this.times, this.values, this.getValueSize() / 3, n);
|
|
2382
2382
|
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
2383
2383
|
}
|
|
2384
2384
|
}
|
|
2385
|
-
function
|
|
2386
|
-
const n = e.attributes, s = new
|
|
2385
|
+
function sn(r, e, t) {
|
|
2386
|
+
const n = e.attributes, s = new Zt();
|
|
2387
2387
|
if (n.POSITION !== void 0) {
|
|
2388
2388
|
const c = t.json.accessors[n.POSITION], a = c.min, l = c.max;
|
|
2389
2389
|
if (a !== void 0 && l !== void 0) {
|
|
@@ -2391,7 +2391,7 @@ function nn(r, e, t) {
|
|
|
2391
2391
|
new S(a[0], a[1], a[2]),
|
|
2392
2392
|
new S(l[0], l[1], l[2])
|
|
2393
2393
|
), c.normalized) {
|
|
2394
|
-
const u =
|
|
2394
|
+
const u = Ne(te[c.componentType]);
|
|
2395
2395
|
s.min.multiplyScalar(u), s.max.multiplyScalar(u);
|
|
2396
2396
|
}
|
|
2397
2397
|
} else {
|
|
@@ -2400,16 +2400,16 @@ function nn(r, e, t) {
|
|
|
2400
2400
|
}
|
|
2401
2401
|
} else
|
|
2402
2402
|
return;
|
|
2403
|
-
const
|
|
2404
|
-
if (
|
|
2403
|
+
const o = e.targets;
|
|
2404
|
+
if (o !== void 0) {
|
|
2405
2405
|
const c = new S(), a = new S();
|
|
2406
|
-
for (let l = 0, u =
|
|
2407
|
-
const h =
|
|
2406
|
+
for (let l = 0, u = o.length; l < u; l++) {
|
|
2407
|
+
const h = o[l];
|
|
2408
2408
|
if (h.POSITION !== void 0) {
|
|
2409
2409
|
const p = t.json.accessors[h.POSITION], m = p.min, _ = p.max;
|
|
2410
2410
|
if (m !== void 0 && _ !== void 0) {
|
|
2411
2411
|
if (a.setX(Math.max(Math.abs(m[0]), Math.abs(_[0]))), a.setY(Math.max(Math.abs(m[1]), Math.abs(_[1]))), a.setZ(Math.max(Math.abs(m[2]), Math.abs(_[2]))), p.normalized) {
|
|
2412
|
-
const w =
|
|
2412
|
+
const w = Ne(te[p.componentType]);
|
|
2413
2413
|
a.multiplyScalar(w);
|
|
2414
2414
|
}
|
|
2415
2415
|
c.max(a);
|
|
@@ -2420,32 +2420,32 @@ function nn(r, e, t) {
|
|
|
2420
2420
|
s.expandByVector(c);
|
|
2421
2421
|
}
|
|
2422
2422
|
r.boundingBox = s;
|
|
2423
|
-
const
|
|
2424
|
-
s.getCenter(
|
|
2423
|
+
const i = new Qt();
|
|
2424
|
+
s.getCenter(i.center), i.radius = s.min.distanceTo(s.max) / 2, r.boundingSphere = i;
|
|
2425
2425
|
}
|
|
2426
|
-
function
|
|
2426
|
+
function Ze(r, e, t) {
|
|
2427
2427
|
const n = e.attributes, s = [];
|
|
2428
|
-
function i
|
|
2429
|
-
return t.getDependency("accessor",
|
|
2428
|
+
function o(i, c) {
|
|
2429
|
+
return t.getDependency("accessor", i).then(function(a) {
|
|
2430
2430
|
r.setAttribute(c, a);
|
|
2431
2431
|
});
|
|
2432
2432
|
}
|
|
2433
|
-
for (const
|
|
2434
|
-
const c = ke[
|
|
2435
|
-
c in r.attributes || s.push(
|
|
2433
|
+
for (const i in n) {
|
|
2434
|
+
const c = ke[i] || i.toLowerCase();
|
|
2435
|
+
c in r.attributes || s.push(o(n[i], c));
|
|
2436
2436
|
}
|
|
2437
2437
|
if (e.indices !== void 0 && !r.index) {
|
|
2438
|
-
const
|
|
2438
|
+
const i = t.getDependency("accessor", e.indices).then(function(c) {
|
|
2439
2439
|
r.setIndex(c);
|
|
2440
2440
|
});
|
|
2441
|
-
s.push(
|
|
2441
|
+
s.push(i);
|
|
2442
2442
|
}
|
|
2443
|
-
return
|
|
2444
|
-
return e.targets !== void 0 ?
|
|
2443
|
+
return Pe.workingColorSpace !== j && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Pe.workingColorSpace}" not supported.`), B(r, e), sn(r, e, t), Promise.all(s).then(function() {
|
|
2444
|
+
return e.targets !== void 0 ? qs(r, e.targets, t) : r;
|
|
2445
2445
|
});
|
|
2446
2446
|
}
|
|
2447
|
-
const
|
|
2448
|
-
class
|
|
2447
|
+
const Qe = new S(), nn = new le(), Je = new S();
|
|
2448
|
+
class on extends He {
|
|
2449
2449
|
/**
|
|
2450
2450
|
* Constructs a new CSS3D object.
|
|
2451
2451
|
*
|
|
@@ -2462,7 +2462,7 @@ class rn extends ve {
|
|
|
2462
2462
|
return super.copy(e, t), this.element = e.element.cloneNode(!0), this;
|
|
2463
2463
|
}
|
|
2464
2464
|
}
|
|
2465
|
-
class Tn extends
|
|
2465
|
+
class Tn extends on {
|
|
2466
2466
|
/**
|
|
2467
2467
|
* Constructs a new CSS3D sprite object.
|
|
2468
2468
|
*
|
|
@@ -2475,7 +2475,7 @@ class Tn extends rn {
|
|
|
2475
2475
|
return super.copy(e, t), this.rotation2D = e.rotation2D, this;
|
|
2476
2476
|
}
|
|
2477
2477
|
}
|
|
2478
|
-
const F = new se(),
|
|
2478
|
+
const F = new se(), rn = new se();
|
|
2479
2479
|
class wn {
|
|
2480
2480
|
/**
|
|
2481
2481
|
* Constructs a new CSS3D renderer.
|
|
@@ -2484,7 +2484,7 @@ class wn {
|
|
|
2484
2484
|
*/
|
|
2485
2485
|
constructor(e = {}) {
|
|
2486
2486
|
const t = this;
|
|
2487
|
-
let n, s,
|
|
2487
|
+
let n, s, o, i;
|
|
2488
2488
|
const c = {
|
|
2489
2489
|
camera: { style: "" },
|
|
2490
2490
|
objects: /* @__PURE__ */ new WeakMap()
|
|
@@ -2499,14 +2499,14 @@ class wn {
|
|
|
2499
2499
|
height: s
|
|
2500
2500
|
};
|
|
2501
2501
|
}, this.render = function(d, f) {
|
|
2502
|
-
const g = f.projectionMatrix.elements[5] *
|
|
2502
|
+
const g = f.projectionMatrix.elements[5] * i;
|
|
2503
2503
|
f.view && f.view.enabled ? (l.style.transform = `translate( ${-f.view.offsetX * (n / f.view.width)}px, ${-f.view.offsetY * (s / f.view.height)}px )`, l.style.transform += `scale( ${f.view.fullWidth / f.view.width}, ${f.view.fullHeight / f.view.height} )`) : l.style.transform = "", d.matrixWorldAutoUpdate === !0 && d.updateMatrixWorld(), f.parent === null && f.matrixWorldAutoUpdate === !0 && f.updateMatrixWorld();
|
|
2504
2504
|
let T, y;
|
|
2505
2505
|
f.isOrthographicCamera && (T = -(f.right + f.left) / 2, y = (f.top + f.bottom) / 2);
|
|
2506
|
-
const E = f.view && f.view.enabled ? f.view.height / f.view.fullHeight : 1, x = f.isOrthographicCamera ? `scale( ${E} )scale(` + g + ")translate(" + h(T) + "px," + h(y) + "px)" + p(f.matrixWorldInverse) : `scale( ${E} )translateZ(` + g + "px)" + p(f.matrixWorldInverse),
|
|
2507
|
-
c.camera.style !==
|
|
2506
|
+
const E = f.view && f.view.enabled ? f.view.height / f.view.fullHeight : 1, x = f.isOrthographicCamera ? `scale( ${E} )scale(` + g + ")translate(" + h(T) + "px," + h(y) + "px)" + p(f.matrixWorldInverse) : `scale( ${E} )translateZ(` + g + "px)" + p(f.matrixWorldInverse), C = (f.isPerspectiveCamera ? "perspective(" + g + "px) " : "") + x + "translate(" + o + "px," + i + "px)";
|
|
2507
|
+
c.camera.style !== C && (u.style.transform = C, c.camera.style = C), w(d, d, f);
|
|
2508
2508
|
}, this.setSize = function(d, f) {
|
|
2509
|
-
n = d, s = f,
|
|
2509
|
+
n = d, s = f, o = n / 2, i = s / 2, a.style.width = d + "px", a.style.height = f + "px", l.style.width = d + "px", l.style.height = f + "px", u.style.width = d + "px", u.style.height = f + "px";
|
|
2510
2510
|
};
|
|
2511
2511
|
function h(d) {
|
|
2512
2512
|
return Math.abs(d) < 1e-10 ? 0 : d;
|
|
@@ -2534,12 +2534,12 @@ class wn {
|
|
|
2534
2534
|
if (E.style.display = y === !0 ? "" : "none", y === !0) {
|
|
2535
2535
|
d.onBeforeRender(t, f, g);
|
|
2536
2536
|
let x;
|
|
2537
|
-
d.isCSS3DSprite ? (F.copy(g.matrixWorldInverse), F.transpose(), d.rotation2D !== 0 && F.multiply(
|
|
2537
|
+
d.isCSS3DSprite ? (F.copy(g.matrixWorldInverse), F.transpose(), d.rotation2D !== 0 && F.multiply(rn.makeRotationZ(d.rotation2D)), d.matrixWorld.decompose(Qe, nn, Je), F.setPosition(Qe), F.scale(Je), F.elements[3] = 0, F.elements[7] = 0, F.elements[11] = 0, F.elements[15] = 1, x = m(F)) : x = m(d.matrixWorld);
|
|
2538
2538
|
const M = c.objects.get(d);
|
|
2539
2539
|
if (M === void 0 || M.style !== x) {
|
|
2540
2540
|
E.style.transform = x;
|
|
2541
|
-
const
|
|
2542
|
-
c.objects.set(d,
|
|
2541
|
+
const C = { style: x };
|
|
2542
|
+
c.objects.set(d, C);
|
|
2543
2543
|
}
|
|
2544
2544
|
E.parentNode !== u && u.appendChild(E), d.onAfterRender(t, f, g);
|
|
2545
2545
|
}
|
|
@@ -2562,7 +2562,7 @@ var ae = function() {
|
|
|
2562
2562
|
e.children[h].style.display = h === u ? "block" : "none";
|
|
2563
2563
|
r = u;
|
|
2564
2564
|
}
|
|
2565
|
-
var s = (performance || Date).now(),
|
|
2565
|
+
var s = (performance || Date).now(), o = s, i = 0, c = t(new ae.Panel("FPS", "#0ff", "#002")), a = t(new ae.Panel("MS", "#0f0", "#020"));
|
|
2566
2566
|
if (self.performance && self.performance.memory)
|
|
2567
2567
|
var l = t(new ae.Panel("MB", "#f08", "#201"));
|
|
2568
2568
|
return n(0), {
|
|
@@ -2574,9 +2574,9 @@ var ae = function() {
|
|
|
2574
2574
|
s = (performance || Date).now();
|
|
2575
2575
|
},
|
|
2576
2576
|
end: function() {
|
|
2577
|
-
|
|
2577
|
+
i++;
|
|
2578
2578
|
var u = (performance || Date).now();
|
|
2579
|
-
if (a.update(u - s, 200), u >=
|
|
2579
|
+
if (a.update(u - s, 200), u >= o + 1e3 && (c.update(i * 1e3 / (u - o), 100), o = u, i = 0, l)) {
|
|
2580
2580
|
var h = performance.memory;
|
|
2581
2581
|
l.update(h.usedJSHeapSize / 1048576, h.jsHeapSizeLimit / 1048576);
|
|
2582
2582
|
}
|
|
@@ -2591,60 +2591,60 @@ var ae = function() {
|
|
|
2591
2591
|
};
|
|
2592
2592
|
};
|
|
2593
2593
|
ae.Panel = function(r, e, t) {
|
|
2594
|
-
var n = 1 / 0, s = 0,
|
|
2594
|
+
var n = 1 / 0, s = 0, o = Math.round, i = o(window.devicePixelRatio || 1), c = 80 * i, a = 48 * i, l = 3 * i, u = 2 * i, h = 3 * i, p = 15 * i, m = 74 * i, _ = 30 * i, w = document.createElement("canvas");
|
|
2595
2595
|
w.width = c, w.height = a, w.style.cssText = "width:80px;height:48px";
|
|
2596
2596
|
var d = w.getContext("2d");
|
|
2597
|
-
return d.font = "bold " + 9 *
|
|
2597
|
+
return d.font = "bold " + 9 * i + "px Helvetica,Arial,sans-serif", d.textBaseline = "top", d.fillStyle = t, d.fillRect(0, 0, c, a), d.fillStyle = e, d.fillText(r, l, u), d.fillRect(h, p, m, _), d.fillStyle = t, d.globalAlpha = 0.9, d.fillRect(h, p, m, _), {
|
|
2598
2598
|
dom: w,
|
|
2599
2599
|
update: function(f, g) {
|
|
2600
|
-
n = Math.min(n, f), s = Math.max(s, f), d.fillStyle = t, d.globalAlpha = 1, d.fillRect(0, 0, c, p), d.fillStyle = e, d.fillText(
|
|
2600
|
+
n = Math.min(n, f), s = Math.max(s, f), d.fillStyle = t, d.globalAlpha = 1, d.fillRect(0, 0, c, p), d.fillStyle = e, d.fillText(o(f) + " " + r + " (" + o(n) + "-" + o(s) + ")", l, u), d.drawImage(w, h + i, p, m - i, _, h, p, m - i, _), d.fillRect(h + m - i, p, i, _), d.fillStyle = t, d.globalAlpha = 0.9, d.fillRect(h + m - i, p, i, o((1 - f / g) * _));
|
|
2601
2601
|
}
|
|
2602
2602
|
};
|
|
2603
2603
|
};
|
|
2604
2604
|
function bn(r) {
|
|
2605
|
-
return new
|
|
2605
|
+
return new Jt(r);
|
|
2606
2606
|
}
|
|
2607
2607
|
function En(r = 150, ...e) {
|
|
2608
|
-
return new
|
|
2608
|
+
return new es(r, r / 10, ...e);
|
|
2609
2609
|
}
|
|
2610
2610
|
function xn(r) {
|
|
2611
|
-
return new
|
|
2611
|
+
return new ts(r, 16776960);
|
|
2612
2612
|
}
|
|
2613
2613
|
function An(r, e) {
|
|
2614
|
-
return new
|
|
2614
|
+
return new ut(r, e);
|
|
2615
2615
|
}
|
|
2616
2616
|
function Rn(r, e) {
|
|
2617
|
-
return new
|
|
2617
|
+
return new Ts(r, e);
|
|
2618
2618
|
}
|
|
2619
2619
|
function Mn() {
|
|
2620
|
-
const r = new
|
|
2620
|
+
const r = new ss(), e = new I(0, 0);
|
|
2621
2621
|
return {
|
|
2622
2622
|
raycaster: r,
|
|
2623
2623
|
pointer: e
|
|
2624
2624
|
};
|
|
2625
2625
|
}
|
|
2626
2626
|
function Sn(r = 10) {
|
|
2627
|
-
return new
|
|
2627
|
+
return new ns(r);
|
|
2628
2628
|
}
|
|
2629
2629
|
function Ln(r = new S(1, 1, 1), e = new S(10, 10, 10), t = 5, n = 16776960) {
|
|
2630
|
-
return r.normalize(), new
|
|
2630
|
+
return r.normalize(), new is(r, e, t, n);
|
|
2631
2631
|
}
|
|
2632
|
-
function
|
|
2632
|
+
function Dn() {
|
|
2633
2633
|
const r = new ae();
|
|
2634
2634
|
return r.dom.style.cssText = "position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", r;
|
|
2635
2635
|
}
|
|
2636
|
-
const
|
|
2636
|
+
const an = (r) => {
|
|
2637
2637
|
r.geometry && r.geometry.dispose(), r.material && (Array.isArray(r.material) ? r.material.forEach((e) => {
|
|
2638
|
-
|
|
2639
|
-
}) :
|
|
2638
|
+
et(e);
|
|
2639
|
+
}) : et(r.material)), r.children && r.children.forEach((e) => an(e));
|
|
2640
2640
|
};
|
|
2641
|
-
function
|
|
2641
|
+
function et(r) {
|
|
2642
2642
|
for (const e in r)
|
|
2643
2643
|
r[e] && r[e].isTexture && r[e].dispose();
|
|
2644
2644
|
r.dispose();
|
|
2645
2645
|
}
|
|
2646
|
-
const
|
|
2647
|
-
async function
|
|
2646
|
+
const Se = {};
|
|
2647
|
+
async function Cn(r, e = 50) {
|
|
2648
2648
|
const t = {
|
|
2649
2649
|
type: r.type,
|
|
2650
2650
|
name: r.name,
|
|
@@ -2657,12 +2657,12 @@ async function Dn(r, e = 50) {
|
|
|
2657
2657
|
material: null,
|
|
2658
2658
|
userData: r.userData
|
|
2659
2659
|
};
|
|
2660
|
-
r.isMesh && (t.geometry =
|
|
2660
|
+
r.isMesh && (t.geometry = pe(r.geometry), t.material = ge(r.material));
|
|
2661
2661
|
const n = [{ object: r, parentData: t }];
|
|
2662
2662
|
let s = 0;
|
|
2663
2663
|
for (; n.length > 0; ) {
|
|
2664
|
-
const { object:
|
|
2665
|
-
for (const c of
|
|
2664
|
+
const { object: o, parentData: i } = n.pop();
|
|
2665
|
+
for (const c of o.children) {
|
|
2666
2666
|
const a = {
|
|
2667
2667
|
type: c.type,
|
|
2668
2668
|
name: c.name,
|
|
@@ -2675,12 +2675,12 @@ async function Dn(r, e = 50) {
|
|
|
2675
2675
|
material: null,
|
|
2676
2676
|
userData: c.userData
|
|
2677
2677
|
};
|
|
2678
|
-
c.isMesh && (a.geometry =
|
|
2678
|
+
c.isMesh && (a.geometry = pe(c.geometry), a.material = ge(c.material)), i.children.push(a), n.push({ object: c, parentData: a }), s++, s % e === 0 && await new Promise((l) => requestAnimationFrame(l));
|
|
2679
2679
|
}
|
|
2680
2680
|
}
|
|
2681
2681
|
return t;
|
|
2682
2682
|
}
|
|
2683
|
-
function
|
|
2683
|
+
function Pn(r) {
|
|
2684
2684
|
const e = {
|
|
2685
2685
|
type: r.type,
|
|
2686
2686
|
name: r.name,
|
|
@@ -2693,35 +2693,35 @@ function Cn(r) {
|
|
|
2693
2693
|
material: null,
|
|
2694
2694
|
userData: r.userData
|
|
2695
2695
|
};
|
|
2696
|
-
r.isMesh && (e.geometry =
|
|
2696
|
+
r.isMesh && (e.geometry = pe(r.geometry), e.material = ge(r.material));
|
|
2697
2697
|
const t = [{ object: r, parentData: e }];
|
|
2698
2698
|
for (; t.length > 0; ) {
|
|
2699
2699
|
const { object: n, parentData: s } = t.pop();
|
|
2700
|
-
for (const
|
|
2701
|
-
const
|
|
2702
|
-
type:
|
|
2703
|
-
name:
|
|
2704
|
-
position:
|
|
2705
|
-
rotation:
|
|
2706
|
-
scale:
|
|
2707
|
-
visible:
|
|
2700
|
+
for (const o of n.children) {
|
|
2701
|
+
const i = {
|
|
2702
|
+
type: o.type,
|
|
2703
|
+
name: o.name,
|
|
2704
|
+
position: o.position.toArray(),
|
|
2705
|
+
rotation: o.rotation.toArray(),
|
|
2706
|
+
scale: o.scale.toArray(),
|
|
2707
|
+
visible: o.visible,
|
|
2708
2708
|
children: [],
|
|
2709
2709
|
geometry: null,
|
|
2710
2710
|
material: null,
|
|
2711
|
-
userData:
|
|
2711
|
+
userData: o.userData
|
|
2712
2712
|
};
|
|
2713
|
-
|
|
2713
|
+
o.isMesh && (i.geometry = pe(o.geometry), i.material = ge(o.material)), s.children.push(i), t.push({ object: o, parentData: i });
|
|
2714
2714
|
}
|
|
2715
2715
|
}
|
|
2716
2716
|
return e;
|
|
2717
2717
|
}
|
|
2718
|
-
async function
|
|
2718
|
+
async function cn(r, e = 50) {
|
|
2719
2719
|
const t = [];
|
|
2720
2720
|
let n;
|
|
2721
2721
|
switch (r.type) {
|
|
2722
2722
|
case "Mesh":
|
|
2723
|
-
const
|
|
2724
|
-
n = new A.Mesh(
|
|
2723
|
+
const o = me(r.geometry), i = ye(r.material);
|
|
2724
|
+
n = new A.Mesh(o, i);
|
|
2725
2725
|
break;
|
|
2726
2726
|
case "Group":
|
|
2727
2727
|
n = new A.Group();
|
|
@@ -2735,12 +2735,12 @@ async function ln(r, e = 50) {
|
|
|
2735
2735
|
n.name = r.name, n.position.fromArray(r.position), n.rotation.fromArray(r.rotation), n.scale.fromArray(r.scale), n.visible = r.visible, n.userData = r.userData, t.push({ data: r, object: n });
|
|
2736
2736
|
let s = 0;
|
|
2737
2737
|
for (; t.length > 0; ) {
|
|
2738
|
-
const { data:
|
|
2739
|
-
for (const c of [...
|
|
2738
|
+
const { data: o, object: i } = t.pop();
|
|
2739
|
+
for (const c of [...o.children].reverse()) {
|
|
2740
2740
|
let a;
|
|
2741
2741
|
switch (c.type) {
|
|
2742
2742
|
case "Mesh":
|
|
2743
|
-
const l =
|
|
2743
|
+
const l = me(c.geometry), u = ye(c.material);
|
|
2744
2744
|
a = new A.Mesh(l, u);
|
|
2745
2745
|
break;
|
|
2746
2746
|
case "Group":
|
|
@@ -2753,7 +2753,7 @@ async function ln(r, e = 50) {
|
|
|
2753
2753
|
console.warn(`Unsupported object type: ${c.type}`);
|
|
2754
2754
|
continue;
|
|
2755
2755
|
}
|
|
2756
|
-
a && (a.name = c.name, a.position.fromArray(c.position), a.rotation.fromArray(c.rotation), a.scale.fromArray(c.scale), a.visible = c.visible, a.userData = c.userData,
|
|
2756
|
+
a && (a.name = c.name, a.position.fromArray(c.position), a.rotation.fromArray(c.rotation), a.scale.fromArray(c.scale), a.visible = c.visible, a.userData = c.userData, i.add(a), t.push({ data: c, object: a }), s++, s % e === 0 && await new Promise((l) => requestAnimationFrame(l)));
|
|
2757
2757
|
}
|
|
2758
2758
|
}
|
|
2759
2759
|
return n;
|
|
@@ -2763,7 +2763,7 @@ function On(r) {
|
|
|
2763
2763
|
let t;
|
|
2764
2764
|
switch (r.type) {
|
|
2765
2765
|
case "Mesh":
|
|
2766
|
-
const n =
|
|
2766
|
+
const n = me(r.geometry), s = ye(r.material);
|
|
2767
2767
|
t = new A.Mesh(n, s);
|
|
2768
2768
|
break;
|
|
2769
2769
|
case "Group":
|
|
@@ -2777,29 +2777,29 @@ function On(r) {
|
|
|
2777
2777
|
}
|
|
2778
2778
|
for (t.name = r.name, t.position.fromArray(r.position), t.rotation.fromArray(r.rotation), t.scale.fromArray(r.scale), t.visible = r.visible, t.userData = r.userData, e.push({ data: r, object: t }); e.length > 0; ) {
|
|
2779
2779
|
const { data: n, object: s } = e.pop();
|
|
2780
|
-
for (const
|
|
2781
|
-
let
|
|
2782
|
-
switch (
|
|
2780
|
+
for (const o of [...n.children].reverse()) {
|
|
2781
|
+
let i;
|
|
2782
|
+
switch (o.type) {
|
|
2783
2783
|
case "Mesh":
|
|
2784
|
-
const c =
|
|
2785
|
-
|
|
2784
|
+
const c = me(o.geometry), a = ye(o.material);
|
|
2785
|
+
i = new A.Mesh(c, a);
|
|
2786
2786
|
break;
|
|
2787
2787
|
case "Group":
|
|
2788
|
-
|
|
2788
|
+
i = new A.Group();
|
|
2789
2789
|
break;
|
|
2790
2790
|
case "Object3D":
|
|
2791
|
-
|
|
2791
|
+
i = new A.Object3D();
|
|
2792
2792
|
break;
|
|
2793
2793
|
default:
|
|
2794
|
-
console.warn(`Unsupported object type: ${
|
|
2794
|
+
console.warn(`Unsupported object type: ${o.type}`);
|
|
2795
2795
|
continue;
|
|
2796
2796
|
}
|
|
2797
|
-
|
|
2797
|
+
i && (i.name = o.name, i.position.fromArray(o.position), i.rotation.fromArray(o.rotation), i.scale.fromArray(o.scale), i.visible = o.visible, i.userData = o.userData, s.add(i), e.push({ data: o, object: i }));
|
|
2798
2798
|
}
|
|
2799
2799
|
}
|
|
2800
2800
|
return t;
|
|
2801
2801
|
}
|
|
2802
|
-
function
|
|
2802
|
+
function pe(r) {
|
|
2803
2803
|
const e = {}, { attributes: t, index: n, type: s } = r;
|
|
2804
2804
|
t.position && (e.position = {
|
|
2805
2805
|
type: "Float32Array",
|
|
@@ -2814,29 +2814,29 @@ function fe(r) {
|
|
|
2814
2814
|
array: Array.from(t.uv.array),
|
|
2815
2815
|
itemSize: 2
|
|
2816
2816
|
});
|
|
2817
|
-
const
|
|
2817
|
+
const o = {
|
|
2818
2818
|
type: s,
|
|
2819
2819
|
attributes: e
|
|
2820
2820
|
};
|
|
2821
|
-
return n && n.array && (
|
|
2821
|
+
return n && n.array && (o.index = {
|
|
2822
2822
|
type: "Uint32Array",
|
|
2823
2823
|
array: Array.from(n.array),
|
|
2824
2824
|
itemSize: 1
|
|
2825
|
-
}),
|
|
2825
|
+
}), o;
|
|
2826
2826
|
}
|
|
2827
|
-
function
|
|
2827
|
+
function me(r) {
|
|
2828
2828
|
const { type: e, attributes: t, index: n } = r, s = new A.BufferGeometry();
|
|
2829
|
-
for (const
|
|
2830
|
-
if (t.hasOwnProperty(
|
|
2831
|
-
const { type:
|
|
2829
|
+
for (const o in t)
|
|
2830
|
+
if (t.hasOwnProperty(o)) {
|
|
2831
|
+
const { type: i, array: c, itemSize: a } = t[o];
|
|
2832
2832
|
s.setAttribute(
|
|
2833
|
-
|
|
2833
|
+
o,
|
|
2834
2834
|
new A.BufferAttribute(new Float32Array(c), a)
|
|
2835
2835
|
);
|
|
2836
2836
|
}
|
|
2837
2837
|
return n && s.setIndex(n.array), s;
|
|
2838
2838
|
}
|
|
2839
|
-
function
|
|
2839
|
+
function ge(r) {
|
|
2840
2840
|
return {
|
|
2841
2841
|
type: r.type,
|
|
2842
2842
|
color: r.color.getHex(),
|
|
@@ -2852,16 +2852,16 @@ function me(r) {
|
|
|
2852
2852
|
emissive: r.emissive.getHex()
|
|
2853
2853
|
};
|
|
2854
2854
|
}
|
|
2855
|
-
function
|
|
2856
|
-
if (
|
|
2855
|
+
function ye(r) {
|
|
2856
|
+
if (Se[r.name]) return Se[r.name];
|
|
2857
2857
|
const { type: e, ...t } = r, n = e || "MeshStandardMaterial", s = new A[n]({ ...t });
|
|
2858
2858
|
if (r.map) {
|
|
2859
|
-
const
|
|
2860
|
-
s.map =
|
|
2859
|
+
const o = new A.TextureLoader().load(r.map);
|
|
2860
|
+
s.map = o;
|
|
2861
2861
|
}
|
|
2862
|
-
return s.needsUpdate = !0,
|
|
2862
|
+
return s.needsUpdate = !0, Se[r.name] = s, s;
|
|
2863
2863
|
}
|
|
2864
|
-
class
|
|
2864
|
+
class ln {
|
|
2865
2865
|
constructor() {
|
|
2866
2866
|
this.stats = {
|
|
2867
2867
|
hits: 0,
|
|
@@ -2981,8 +2981,8 @@ class hn {
|
|
|
2981
2981
|
}), console.groupEnd();
|
|
2982
2982
|
}
|
|
2983
2983
|
}
|
|
2984
|
-
const
|
|
2985
|
-
class
|
|
2984
|
+
const V = new ln();
|
|
2985
|
+
class _e {
|
|
2986
2986
|
/**
|
|
2987
2987
|
* 异步操作并支持重试
|
|
2988
2988
|
* @param {Function} operation - 要执行的异步操作
|
|
@@ -2993,9 +2993,9 @@ class ye {
|
|
|
2993
2993
|
const {
|
|
2994
2994
|
maxRetries: n = 3,
|
|
2995
2995
|
initialDelay: s = 1e3,
|
|
2996
|
-
maxDelay:
|
|
2997
|
-
backoffFactor:
|
|
2998
|
-
shouldRetry: c =
|
|
2996
|
+
maxDelay: o = 1e4,
|
|
2997
|
+
backoffFactor: i = 2,
|
|
2998
|
+
shouldRetry: c = _e.defaultShouldRetry
|
|
2999
2999
|
} = t;
|
|
3000
3000
|
let a, l = s;
|
|
3001
3001
|
for (let u = 0; u <= n; u++)
|
|
@@ -3007,7 +3007,7 @@ class ye {
|
|
|
3007
3007
|
console.warn(
|
|
3008
3008
|
`[ RetryHelper ] 操作失败,第 ${u + 1} 次尝试失败,${l}ms 后进行第 ${u + 2} 次尝试...`,
|
|
3009
3009
|
h
|
|
3010
|
-
), await
|
|
3010
|
+
), await _e.delay(l), l = Math.min(l * i, o);
|
|
3011
3011
|
}
|
|
3012
3012
|
throw a;
|
|
3013
3013
|
}
|
|
@@ -3038,7 +3038,7 @@ class ye {
|
|
|
3038
3038
|
return new Promise((t) => setTimeout(t, e));
|
|
3039
3039
|
}
|
|
3040
3040
|
}
|
|
3041
|
-
const
|
|
3041
|
+
const Le = {
|
|
3042
3042
|
NETWORK: "NETWORK",
|
|
3043
3043
|
// 网络错误
|
|
3044
3044
|
PARSE: "PARSE",
|
|
@@ -3058,7 +3058,7 @@ class ce extends Error {
|
|
|
3058
3058
|
static networkError(e, t) {
|
|
3059
3059
|
return new ce(
|
|
3060
3060
|
`网络加载失败: ${e}`,
|
|
3061
|
-
|
|
3061
|
+
Le.NETWORK,
|
|
3062
3062
|
e,
|
|
3063
3063
|
t
|
|
3064
3064
|
);
|
|
@@ -3069,7 +3069,7 @@ class ce extends Error {
|
|
|
3069
3069
|
static parseError(e, t) {
|
|
3070
3070
|
return new ce(
|
|
3071
3071
|
`模型解析失败: ${e}`,
|
|
3072
|
-
|
|
3072
|
+
Le.PARSE,
|
|
3073
3073
|
e,
|
|
3074
3074
|
t
|
|
3075
3075
|
);
|
|
@@ -3080,20 +3080,20 @@ class ce extends Error {
|
|
|
3080
3080
|
static versionMismatchError(e, t, n) {
|
|
3081
3081
|
return new ce(
|
|
3082
3082
|
`版本不匹配: ${e} (期望: ${t}, 实际: ${n})`,
|
|
3083
|
-
|
|
3083
|
+
Le.VERSION_MISMATCH,
|
|
3084
3084
|
e
|
|
3085
3085
|
);
|
|
3086
3086
|
}
|
|
3087
3087
|
}
|
|
3088
|
-
const
|
|
3089
|
-
class
|
|
3088
|
+
const hn = 5;
|
|
3089
|
+
class de {
|
|
3090
3090
|
/**
|
|
3091
3091
|
* 构造函数
|
|
3092
3092
|
* @param {string} dbName - 数据库名称
|
|
3093
3093
|
* @param {CacheOptions} options - 缓存配置选项
|
|
3094
3094
|
*/
|
|
3095
3095
|
constructor(e = "threeJsIDBCache", t = {}) {
|
|
3096
|
-
this.version =
|
|
3096
|
+
this.version = hn, this.dbName = e, this.options = {
|
|
3097
3097
|
maxSize: t.maxSize || 500 * 1024 * 1024,
|
|
3098
3098
|
// 默认 500MB
|
|
3099
3099
|
maxEntries: t.maxEntries || 50,
|
|
@@ -3103,13 +3103,16 @@ class tt {
|
|
|
3103
3103
|
}, this.dbInit();
|
|
3104
3104
|
}
|
|
3105
3105
|
dbInit() {
|
|
3106
|
-
this.db = new
|
|
3107
|
-
models: "&path, version, timestamp, accessCount, size"
|
|
3106
|
+
this.db = new os(this.dbName), this.db.version(this.version).stores({
|
|
3107
|
+
models: "&path, version, timestamp, accessCount, size, format"
|
|
3108
3108
|
}).upgrade(async (e) => {
|
|
3109
|
-
console.log("[ IDBCache 版本更新 ] ====>
|
|
3109
|
+
console.log("[ IDBCache 版本更新 ] ====> 从旧版本升级到 v5");
|
|
3110
3110
|
const t = e.table("models"), n = await t.toArray();
|
|
3111
|
-
|
|
3112
|
-
|
|
3111
|
+
console.log(`[ IDBCache ] 发现 ${n.length} 条旧缓存记录,开始验证...`);
|
|
3112
|
+
let s = 0, o = 0;
|
|
3113
|
+
for (const i of n)
|
|
3114
|
+
i.data instanceof ArrayBuffer ? (await t.update(i.path, { format: "arraybuffer" }), s++) : i.data && typeof i.data == "object" ? i.data.metadata || i.data.type === "Object3D" || i.data.uuid ? (console.warn(`[ IDBCache ] 检测到旧版本序列化格式: ${i.path},标记为待删除`), await t.delete(i.path), o++) : (console.warn(`[ IDBCache ] 检测到无法识别的数据格式: ${i.path},删除`), await t.delete(i.path), o++) : (console.warn(`[ IDBCache ] 检测到无效数据: ${i.path},删除`), await t.delete(i.path), o++);
|
|
3115
|
+
console.log(`[ IDBCache ] 升级完成: 保留 ${s} 条,删除 ${o} 条旧格式记录`);
|
|
3113
3116
|
});
|
|
3114
3117
|
}
|
|
3115
3118
|
/**
|
|
@@ -3120,13 +3123,19 @@ class tt {
|
|
|
3120
3123
|
return this.db;
|
|
3121
3124
|
}
|
|
3122
3125
|
async saveModel(e, t, n) {
|
|
3126
|
+
if (!n || !(n instanceof ArrayBuffer))
|
|
3127
|
+
throw new Error(`[ IDBCache ] 无效的 ArrayBuffer: ${e}`);
|
|
3128
|
+
if (n.byteLength === 0)
|
|
3129
|
+
throw new Error(`[ IDBCache ] ArrayBuffer 为空: ${e}`);
|
|
3123
3130
|
await this.ensureCapacity(n.byteLength), await this.db.table("models").put({
|
|
3124
3131
|
path: e,
|
|
3125
3132
|
version: t,
|
|
3126
3133
|
data: n,
|
|
3127
3134
|
size: n.byteLength,
|
|
3128
3135
|
timestamp: Date.now(),
|
|
3129
|
-
accessCount: 0
|
|
3136
|
+
accessCount: 0,
|
|
3137
|
+
format: "arraybuffer"
|
|
3138
|
+
// 标记数据格式
|
|
3130
3139
|
});
|
|
3131
3140
|
}
|
|
3132
3141
|
/**
|
|
@@ -3134,25 +3143,27 @@ class tt {
|
|
|
3134
3143
|
* @param {number} requiredSize - 需要的额外空间(字节)
|
|
3135
3144
|
*/
|
|
3136
3145
|
async ensureCapacity(e) {
|
|
3137
|
-
const t = await this.db.table("models").toArray(), n = t.reduce((c, a) => c + (a.size || 0), 0), s = t.length,
|
|
3138
|
-
(
|
|
3146
|
+
const t = await this.db.table("models").toArray(), n = t.reduce((c, a) => c + (a.size || 0), 0), s = t.length, o = n + e > this.options.maxSize, i = s >= this.options.maxEntries;
|
|
3147
|
+
(o || i) && (console.log(`[ IDBCache ] ====> 容量不足,开始 LRU 淘汰. 总大小: ${(n / 1024 / 1024).toFixed(2)}MB, 条目数: ${s}`), await this.evictLRU(t));
|
|
3139
3148
|
}
|
|
3140
3149
|
/**
|
|
3141
3150
|
* 执行 LRU 淘汰策略
|
|
3142
3151
|
* @param {Array} models - 所有缓存记录
|
|
3143
3152
|
*/
|
|
3144
3153
|
async evictLRU(e) {
|
|
3145
|
-
const t = e.sort((c, a) => (c.accessCount || 0) !== (a.accessCount || 0) ? (c.accessCount || 0) - (a.accessCount || 0) : (c.timestamp || 0) - (a.timestamp || 0)), n = Math.max(1, Math.floor(t.length * this.options.evictRatio)), s = t.slice(0, n),
|
|
3146
|
-
await this.db.table("models").bulkDelete(
|
|
3147
|
-
const
|
|
3148
|
-
console.log(`[ IDBCache ] ====> LRU 淘汰完成. 删除 ${n} 个条目,释放 ${(
|
|
3154
|
+
const t = e.sort((c, a) => (c.accessCount || 0) !== (a.accessCount || 0) ? (c.accessCount || 0) - (a.accessCount || 0) : (c.timestamp || 0) - (a.timestamp || 0)), n = Math.max(1, Math.floor(t.length * this.options.evictRatio)), s = t.slice(0, n), o = s.map((c) => c.path);
|
|
3155
|
+
await this.db.table("models").bulkDelete(o);
|
|
3156
|
+
const i = s.reduce((c, a) => c + (a.size || 0), 0);
|
|
3157
|
+
console.log(`[ IDBCache ] ====> LRU 淘汰完成. 删除 ${n} 个条目,释放 ${(i / 1024 / 1024).toFixed(2)}MB`);
|
|
3149
3158
|
}
|
|
3150
3159
|
async getModel(e, t) {
|
|
3151
3160
|
const n = await this.db.table("models").get(e);
|
|
3152
|
-
return n ? n.version !== t ? (console.log(
|
|
3161
|
+
return n ? n.version !== t ? (console.log(`[ IDBCache ] 模型版本不一致,清除当前记录 (缓存: ${n.version}, 请求: ${t})`), await this.db.table("models").delete(e), null) : n.data ? n.data instanceof ArrayBuffer ? n.data.byteLength === 0 ? (console.warn(`[ IDBCache ] ArrayBuffer 为空,删除记录: ${e}`), await this.db.table("models").delete(e), null) : (await this.db.table("models").update(e, {
|
|
3153
3162
|
accessCount: (n.accessCount || 0) + 1,
|
|
3154
|
-
timestamp: Date.now()
|
|
3155
|
-
|
|
3163
|
+
timestamp: Date.now(),
|
|
3164
|
+
format: "arraybuffer"
|
|
3165
|
+
// 确保格式字段存在
|
|
3166
|
+
}), n.data) : (console.warn(`[ IDBCache ] 检测到旧版本序列化格式,删除记录: ${e}`), await this.db.table("models").delete(e), null) : (console.warn(`[ IDBCache ] 数据为空,删除记录: ${e}`), await this.db.table("models").delete(e), null) : (console.warn(`Model "${e}" not found in table models`), null);
|
|
3156
3167
|
}
|
|
3157
3168
|
// ---------------------------- ---------------------------------
|
|
3158
3169
|
/**
|
|
@@ -3196,7 +3207,7 @@ class tt {
|
|
|
3196
3207
|
* @returns {Promise<Object>} 缓存统计数据
|
|
3197
3208
|
*/
|
|
3198
3209
|
async getStats() {
|
|
3199
|
-
const e = await this.db.table("models").toArray(), t = e.reduce((s,
|
|
3210
|
+
const e = await this.db.table("models").toArray(), t = e.reduce((s, o) => s + (o.size || 0), 0), n = e.reduce((s, o) => s + (o.accessCount || 0), 0);
|
|
3200
3211
|
return {
|
|
3201
3212
|
count: e.length,
|
|
3202
3213
|
totalSize: t,
|
|
@@ -3221,25 +3232,69 @@ class tt {
|
|
|
3221
3232
|
async deleteModel(e) {
|
|
3222
3233
|
await this.db.table("models").delete(e);
|
|
3223
3234
|
}
|
|
3235
|
+
/**
|
|
3236
|
+
* 清理所有旧版本格式的缓存数据
|
|
3237
|
+
* 适用于手动清理,不需要等待版本升级
|
|
3238
|
+
* @returns {Promise<Object>} 清理统计信息
|
|
3239
|
+
*/
|
|
3240
|
+
async cleanLegacyFormats() {
|
|
3241
|
+
console.log("[ IDBCache ] 开始清理旧版本格式的缓存...");
|
|
3242
|
+
const e = await this.db.table("models").toArray();
|
|
3243
|
+
let t = 0, n = 0;
|
|
3244
|
+
const s = [];
|
|
3245
|
+
for (const i of e) {
|
|
3246
|
+
let c = !1;
|
|
3247
|
+
i.data ? i.data instanceof ArrayBuffer ? i.data.byteLength === 0 && (c = !0, console.warn(`[ IDBCache ] 清理空 ArrayBuffer: ${i.path}`)) : (c = !0, console.warn(`[ IDBCache ] 清理非 ArrayBuffer 格式: ${i.path}`)) : (c = !0, console.warn(`[ IDBCache ] 清理空数据: ${i.path}`)), c ? (await this.db.table("models").delete(i.path), t++, s.push(i.path)) : (n++, i.format || await this.db.table("models").update(i.path, { format: "arraybuffer" }));
|
|
3248
|
+
}
|
|
3249
|
+
const o = {
|
|
3250
|
+
total: e.length,
|
|
3251
|
+
deleted: t,
|
|
3252
|
+
kept: n,
|
|
3253
|
+
deletedPaths: s
|
|
3254
|
+
};
|
|
3255
|
+
return console.log("[ IDBCache ] 清理完成:", o), o;
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* 验证缓存完整性并修复问题
|
|
3259
|
+
* @returns {Promise<Object>} 验证结果
|
|
3260
|
+
*/
|
|
3261
|
+
async validateAndRepair() {
|
|
3262
|
+
console.log("[ IDBCache ] 开始验证缓存完整性...");
|
|
3263
|
+
const e = await this.db.table("models").toArray();
|
|
3264
|
+
let t = 0, n = 0;
|
|
3265
|
+
const s = [];
|
|
3266
|
+
for (const i of e) {
|
|
3267
|
+
let c = !0;
|
|
3268
|
+
const a = [];
|
|
3269
|
+
i.data || (c = !1, a.push("missing_data")), i.data && !(i.data instanceof ArrayBuffer) && (c = !1, a.push("invalid_format")), i.data && i.data.byteLength === 0 && (c = !1, a.push("empty_buffer")), i.version || (c = !1, a.push("missing_version")), i.format || (s.push({ path: i.path, action: "add_format_field" }), await this.db.table("models").update(i.path, { format: "arraybuffer" })), c ? t++ : (console.warn(`[ IDBCache ] 发现无效记录: ${i.path}`, a), await this.db.table("models").delete(i.path), n++);
|
|
3270
|
+
}
|
|
3271
|
+
const o = {
|
|
3272
|
+
total: e.length,
|
|
3273
|
+
valid: t,
|
|
3274
|
+
invalid: n,
|
|
3275
|
+
repairs: s.length
|
|
3276
|
+
};
|
|
3277
|
+
return console.log("[ IDBCache ] 验证完成:", o), o;
|
|
3278
|
+
}
|
|
3224
3279
|
}
|
|
3225
|
-
function
|
|
3280
|
+
function pt(r) {
|
|
3226
3281
|
const { geometries: e, materials: t, hierarchy: n } = r, s = /* @__PURE__ */ new Map();
|
|
3227
3282
|
e.forEach((a, l) => {
|
|
3228
3283
|
const u = un(a);
|
|
3229
3284
|
s.set(l, u);
|
|
3230
3285
|
});
|
|
3231
|
-
const
|
|
3286
|
+
const o = /* @__PURE__ */ new Map();
|
|
3232
3287
|
t.forEach((a, l) => {
|
|
3233
3288
|
const u = dn(a);
|
|
3234
|
-
|
|
3289
|
+
o.set(l, u);
|
|
3235
3290
|
});
|
|
3236
|
-
const
|
|
3237
|
-
|
|
3291
|
+
const i = new A.Group();
|
|
3292
|
+
i.name = "Scene";
|
|
3238
3293
|
const c = /* @__PURE__ */ new Map();
|
|
3239
3294
|
return n.forEach((a) => {
|
|
3240
3295
|
let l;
|
|
3241
3296
|
if (a.type === "Mesh") {
|
|
3242
|
-
const u = a.geometryIndex >= 0 ? s.get(a.geometryIndex) : null, h = a.materialIndex >= 0 ?
|
|
3297
|
+
const u = a.geometryIndex >= 0 ? s.get(a.geometryIndex) : null, h = a.materialIndex >= 0 ? o.get(a.materialIndex) : null;
|
|
3243
3298
|
l = new A.Mesh(u, h);
|
|
3244
3299
|
} else a.type === "Group" ? l = new A.Group() : a.type === "Object3D" ? l = new A.Object3D() : l = new A.Object3D();
|
|
3245
3300
|
l.name = a.name, l.position.fromArray(a.position), l.rotation.fromArray(a.rotation), l.scale.fromArray(a.scale), l.visible = a.visible, l.userData = a.userData || {}, c.set(a.id, l);
|
|
@@ -3249,14 +3304,14 @@ function mt(r) {
|
|
|
3249
3304
|
const u = c.get(a.parentId);
|
|
3250
3305
|
u && u.add(l);
|
|
3251
3306
|
} else
|
|
3252
|
-
|
|
3253
|
-
}),
|
|
3307
|
+
i.add(l);
|
|
3308
|
+
}), i;
|
|
3254
3309
|
}
|
|
3255
3310
|
function un(r) {
|
|
3256
3311
|
const e = new A.BufferGeometry();
|
|
3257
3312
|
for (const t in r.attributes) {
|
|
3258
3313
|
const n = r.attributes[t], s = n.array;
|
|
3259
|
-
let
|
|
3314
|
+
let o;
|
|
3260
3315
|
if (s.byteLength === 0) {
|
|
3261
3316
|
console.warn(`[ sceneRebuilder ] 属性 ${t} 的数组为空`);
|
|
3262
3317
|
continue;
|
|
@@ -3265,9 +3320,9 @@ function un(r) {
|
|
|
3265
3320
|
console.warn(`[ sceneRebuilder ] 属性 ${t} 的 buffer 已被转移,尝试重建`);
|
|
3266
3321
|
continue;
|
|
3267
3322
|
}
|
|
3268
|
-
|
|
3269
|
-
const
|
|
3270
|
-
|
|
3323
|
+
o = s;
|
|
3324
|
+
const i = new A.BufferAttribute(o, n.itemSize);
|
|
3325
|
+
i.normalized = n.normalized, e.setAttribute(t, i);
|
|
3271
3326
|
}
|
|
3272
3327
|
if (r.index) {
|
|
3273
3328
|
const t = r.index, n = t.array;
|
|
@@ -3322,7 +3377,7 @@ function dn(r) {
|
|
|
3322
3377
|
}
|
|
3323
3378
|
return e.uuid = r.uuid, e;
|
|
3324
3379
|
}
|
|
3325
|
-
class
|
|
3380
|
+
class In {
|
|
3326
3381
|
constructor() {
|
|
3327
3382
|
this.geometries = [], this.materials = [], this.hierarchy = [], this.geometryMap = /* @__PURE__ */ new Map(), this.materialMap = /* @__PURE__ */ new Map();
|
|
3328
3383
|
}
|
|
@@ -3347,7 +3402,7 @@ class kn {
|
|
|
3347
3402
|
materials: this.materials,
|
|
3348
3403
|
hierarchy: this.hierarchy
|
|
3349
3404
|
};
|
|
3350
|
-
return
|
|
3405
|
+
return pt(e);
|
|
3351
3406
|
}
|
|
3352
3407
|
/**
|
|
3353
3408
|
* 完成构建
|
|
@@ -3372,22 +3427,22 @@ function pn(r) {
|
|
|
3372
3427
|
}
|
|
3373
3428
|
);
|
|
3374
3429
|
}
|
|
3375
|
-
let
|
|
3376
|
-
const
|
|
3377
|
-
let
|
|
3430
|
+
let U;
|
|
3431
|
+
const De = "/draco/";
|
|
3432
|
+
let J, ee, tt = 0;
|
|
3378
3433
|
const X = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map();
|
|
3379
|
-
function
|
|
3434
|
+
function ve(r) {
|
|
3380
3435
|
const e = r.clone(!1);
|
|
3381
3436
|
r.userData && typeof r.userData == "object" ? e.userData = JSON.parse(JSON.stringify(r.userData)) : e.userData = r.userData;
|
|
3382
3437
|
for (const t of r.children) {
|
|
3383
|
-
const n =
|
|
3438
|
+
const n = ve(t);
|
|
3384
3439
|
e.add(n);
|
|
3385
3440
|
}
|
|
3386
3441
|
return e;
|
|
3387
3442
|
}
|
|
3388
3443
|
const mn = (r = {}) => {
|
|
3389
|
-
const { debug: e = !1 } = r, t = new
|
|
3390
|
-
n.setDecoderPath(
|
|
3444
|
+
const { debug: e = !1 } = r, t = new Es(), n = new ws();
|
|
3445
|
+
n.setDecoderPath(De), t.setDRACOLoader(n);
|
|
3391
3446
|
const s = {
|
|
3392
3447
|
info: (...d) => e && console.log(...d),
|
|
3393
3448
|
warn: (...d) => e && console.warn(...d),
|
|
@@ -3396,10 +3451,10 @@ const mn = (r = {}) => {
|
|
|
3396
3451
|
time: (d) => e && console.time(d),
|
|
3397
3452
|
timeEnd: (d) => e && console.timeEnd(d)
|
|
3398
3453
|
};
|
|
3399
|
-
function
|
|
3454
|
+
function o(d, f, g, T) {
|
|
3400
3455
|
return t.load(d, f, g, T);
|
|
3401
3456
|
}
|
|
3402
|
-
function
|
|
3457
|
+
function i(d, f) {
|
|
3403
3458
|
return new Promise((g, T) => {
|
|
3404
3459
|
t.load(d, g, f, T);
|
|
3405
3460
|
});
|
|
@@ -3410,63 +3465,63 @@ const mn = (r = {}) => {
|
|
|
3410
3465
|
const {
|
|
3411
3466
|
maxRetries: x = 3,
|
|
3412
3467
|
optimizeMaterials: M = !1,
|
|
3413
|
-
simplifyGeometry:
|
|
3414
|
-
simplifyRatio:
|
|
3415
|
-
simplifyOptions:
|
|
3468
|
+
simplifyGeometry: C = !1,
|
|
3469
|
+
simplifyRatio: P = 0.5,
|
|
3470
|
+
simplifyOptions: K = {},
|
|
3416
3471
|
useMemoryCache: he = !0
|
|
3417
3472
|
// 是否使用内存缓存(默认 true)
|
|
3418
3473
|
} = T;
|
|
3419
3474
|
if (he) {
|
|
3420
|
-
const
|
|
3421
|
-
if (
|
|
3422
|
-
const N =
|
|
3475
|
+
const D = H.get(d);
|
|
3476
|
+
if (D && D.has(f)) {
|
|
3477
|
+
const N = D.get(f);
|
|
3423
3478
|
s.info(`[ 内存缓存命中 ] ${d} (version: ${f})`), s.time("[ 内存缓存克隆耗时 ]");
|
|
3424
|
-
const
|
|
3425
|
-
return s.timeEnd("[ 内存缓存克隆耗时 ]"),
|
|
3479
|
+
const Z = ve(N);
|
|
3480
|
+
return s.timeEnd("[ 内存缓存克隆耗时 ]"), V.recordHit(performance.now() - y), Z;
|
|
3426
3481
|
}
|
|
3427
3482
|
}
|
|
3428
3483
|
try {
|
|
3429
|
-
let
|
|
3430
|
-
if (
|
|
3484
|
+
let D = await l(d, f);
|
|
3485
|
+
if (D)
|
|
3431
3486
|
s.info(`[ asyncFetch ] ====> IndexedDB 缓存命中: ${d}`), E = !0;
|
|
3432
3487
|
else {
|
|
3433
|
-
s.info(`[ asyncFetch ] ====> 缓存未命中: ${d}`), s.time("[ fetchArrayBuffer ] 加载模型耗时"),
|
|
3488
|
+
s.info(`[ asyncFetch ] ====> 缓存未命中: ${d}`), s.time("[ fetchArrayBuffer ] 加载模型耗时"), D = await _e.retry(
|
|
3434
3489
|
() => a(d, g),
|
|
3435
3490
|
{
|
|
3436
3491
|
maxRetries: x,
|
|
3437
|
-
shouldRetry: (
|
|
3492
|
+
shouldRetry: (Ue) => !!(Ue.name === "TypeError" || Ue.message.includes("HTTP error! status: 5"))
|
|
3438
3493
|
}
|
|
3439
3494
|
), s.timeEnd("[ fetchArrayBuffer ] 加载模型耗时");
|
|
3440
3495
|
const v = performance.now();
|
|
3441
|
-
await
|
|
3442
|
-
const
|
|
3443
|
-
|
|
3496
|
+
await U.saveModel(d, f, D);
|
|
3497
|
+
const Te = performance.now() - v;
|
|
3498
|
+
V.recordCacheSave(Te), E = !1;
|
|
3444
3499
|
}
|
|
3445
3500
|
s.time("[ 解析模型耗时 ]");
|
|
3446
|
-
let N = await u(
|
|
3501
|
+
let N = await u(D);
|
|
3447
3502
|
if (s.timeEnd("[ 解析模型耗时 ]"), s.time("[ 模型优化耗时 ]"), M) {
|
|
3448
3503
|
s.info("🔧 [ 材质优化 ] 开始合并相同材质...");
|
|
3449
3504
|
const { modelOptimizer: v } = await import("./modelOptimizer-D6fRg-DF.js");
|
|
3450
3505
|
N = v.optimizeMaterials(N);
|
|
3451
3506
|
}
|
|
3452
|
-
if (
|
|
3453
|
-
s.info(`🔧 [ 几何体简化 ] 开始简化模型 (比例: ${
|
|
3454
|
-
const { modelOptimizer: v } = await import("./modelOptimizer-D6fRg-DF.js"),
|
|
3507
|
+
if (C) {
|
|
3508
|
+
s.info(`🔧 [ 几何体简化 ] 开始简化模型 (比例: ${P})...`);
|
|
3509
|
+
const { modelOptimizer: v } = await import("./modelOptimizer-D6fRg-DF.js"), Te = {
|
|
3455
3510
|
minFaceCount: 100,
|
|
3456
3511
|
preserveUVs: !0,
|
|
3457
|
-
...
|
|
3512
|
+
...K
|
|
3458
3513
|
};
|
|
3459
|
-
N = v.simplifyModel(N,
|
|
3514
|
+
N = v.simplifyModel(N, P, Te);
|
|
3460
3515
|
}
|
|
3461
3516
|
if (s.timeEnd("[ 模型优化耗时 ]"), he) {
|
|
3462
3517
|
H.has(d) || H.set(d, /* @__PURE__ */ new Map());
|
|
3463
3518
|
const v = H.get(d);
|
|
3464
|
-
v.has(f) || (s.info(`[ 内存缓存 ] 存储模型 ${d} (version: ${f})`), v.set(f,
|
|
3519
|
+
v.has(f) || (s.info(`[ 内存缓存 ] 存储模型 ${d} (version: ${f})`), v.set(f, ve(N)));
|
|
3465
3520
|
}
|
|
3466
|
-
const
|
|
3467
|
-
return E ?
|
|
3468
|
-
} catch (
|
|
3469
|
-
throw s.error(`加载模型 ${d} 失败:`,
|
|
3521
|
+
const Z = performance.now() - y;
|
|
3522
|
+
return E ? V.recordHit(Z) : V.recordMiss(Z), N;
|
|
3523
|
+
} catch (D) {
|
|
3524
|
+
throw s.error(`加载模型 ${d} 失败:`, D), V.recordError(d, D), D.name === "TypeError" && D.message.includes("fetch") ? ce.networkError(d, D) : D;
|
|
3470
3525
|
}
|
|
3471
3526
|
}
|
|
3472
3527
|
async function a(d, f) {
|
|
@@ -3479,21 +3534,21 @@ const mn = (r = {}) => {
|
|
|
3479
3534
|
const E = y.headers.get("content-length"), x = E ? parseInt(E, 10) : 0;
|
|
3480
3535
|
if (f && x > 0) {
|
|
3481
3536
|
const M = y.body.getReader();
|
|
3482
|
-
let
|
|
3483
|
-
const
|
|
3484
|
-
M.read().then(({ done: he, value:
|
|
3537
|
+
let C = 0;
|
|
3538
|
+
const P = [], K = () => {
|
|
3539
|
+
M.read().then(({ done: he, value: D }) => {
|
|
3485
3540
|
if (he) {
|
|
3486
|
-
const N = new Uint8Array(
|
|
3487
|
-
let
|
|
3488
|
-
for (const v of
|
|
3489
|
-
N.set(v,
|
|
3541
|
+
const N = new Uint8Array(C);
|
|
3542
|
+
let Z = 0;
|
|
3543
|
+
for (const v of P)
|
|
3544
|
+
N.set(v, Z), Z += v.length;
|
|
3490
3545
|
g(N.buffer);
|
|
3491
3546
|
return;
|
|
3492
3547
|
}
|
|
3493
|
-
|
|
3548
|
+
P.push(D), C += D.length, f(Math.round(C / x * 100)), K();
|
|
3494
3549
|
}).catch(T);
|
|
3495
3550
|
};
|
|
3496
|
-
|
|
3551
|
+
K();
|
|
3497
3552
|
} else
|
|
3498
3553
|
return y.arrayBuffer();
|
|
3499
3554
|
}).then((y) => g(y)).catch((y) => {
|
|
@@ -3502,7 +3557,7 @@ const mn = (r = {}) => {
|
|
|
3502
3557
|
});
|
|
3503
3558
|
}
|
|
3504
3559
|
async function l(d, f) {
|
|
3505
|
-
return
|
|
3560
|
+
return U || (U = new de()), U.getModel(d, f);
|
|
3506
3561
|
}
|
|
3507
3562
|
async function u(d, f = {}) {
|
|
3508
3563
|
if (!d) return null;
|
|
@@ -3513,7 +3568,7 @@ const mn = (r = {}) => {
|
|
|
3513
3568
|
try {
|
|
3514
3569
|
s.time("[ 优化解析 ] 使用 Transferable Objects 解析");
|
|
3515
3570
|
const M = await m(x, d, T);
|
|
3516
|
-
return s.timeEnd("[ 优化解析 ] 使用 Transferable Objects 解析"),
|
|
3571
|
+
return s.timeEnd("[ 优化解析 ] 使用 Transferable Objects 解析"), pt(M);
|
|
3517
3572
|
} catch (M) {
|
|
3518
3573
|
s.warn("[ 优化解析 ] 失败,回退到标准解析", M);
|
|
3519
3574
|
}
|
|
@@ -3522,7 +3577,7 @@ const mn = (r = {}) => {
|
|
|
3522
3577
|
if (y)
|
|
3523
3578
|
try {
|
|
3524
3579
|
const x = await _(y, d);
|
|
3525
|
-
return
|
|
3580
|
+
return cn(x);
|
|
3526
3581
|
} catch (x) {
|
|
3527
3582
|
s.warn("[ GLTF Worker ] ====> 解析失败,回退到主线程解析", x);
|
|
3528
3583
|
}
|
|
@@ -3531,81 +3586,81 @@ const mn = (r = {}) => {
|
|
|
3531
3586
|
const h = () => {
|
|
3532
3587
|
if (typeof window > "u" || typeof Worker > "u")
|
|
3533
3588
|
return null;
|
|
3534
|
-
if (!
|
|
3589
|
+
if (!J)
|
|
3535
3590
|
try {
|
|
3536
|
-
s.info("[GLTF Worker] 使用 ?worker 工厂函数创建 Worker..."),
|
|
3591
|
+
s.info("[GLTF Worker] 使用 ?worker 工厂函数创建 Worker..."), J = fn(), s.info("[GLTF Worker] Worker 创建成功:", J), J.onmessage = (d) => {
|
|
3537
3592
|
const { id: f, data: g, error: T } = d.data || {};
|
|
3538
3593
|
if (!f || !X.has(f)) return;
|
|
3539
3594
|
const { resolve: y, reject: E } = X.get(f);
|
|
3540
3595
|
X.delete(f), T ? E(new Error(T)) : y(g);
|
|
3541
|
-
},
|
|
3596
|
+
}, J.onmessageerror = (d) => {
|
|
3542
3597
|
console.error("[ GLTF Worker ] ====> 消息解析失败", d);
|
|
3543
|
-
},
|
|
3598
|
+
}, J.onerror = (d) => {
|
|
3544
3599
|
console.error("[ GLTF Worker ] ====> 运行错误", d);
|
|
3545
3600
|
};
|
|
3546
3601
|
} catch (d) {
|
|
3547
3602
|
console.error("[GLTF Worker] 创建 Worker 失败:", d), console.error("[GLTF Worker] 错误堆栈:", d.stack);
|
|
3548
3603
|
}
|
|
3549
|
-
return
|
|
3604
|
+
return J;
|
|
3550
3605
|
}, p = () => {
|
|
3551
3606
|
if (typeof window > "u" || typeof Worker > "u")
|
|
3552
3607
|
return null;
|
|
3553
|
-
if (!
|
|
3608
|
+
if (!ee)
|
|
3554
3609
|
try {
|
|
3555
|
-
s.info("[Optimized Worker] 使用 ?worker 工厂函数创建 Worker..."),
|
|
3610
|
+
s.info("[Optimized Worker] 使用 ?worker 工厂函数创建 Worker..."), ee = pn(), s.info("[Optimized Worker] Worker 创建成功:", ee), ee.onmessage = (d) => {
|
|
3556
3611
|
const { id: f, data: g, error: T, type: y } = d.data || {};
|
|
3557
3612
|
if (!f || !X.has(f) || y === "progress")
|
|
3558
3613
|
return;
|
|
3559
3614
|
const { resolve: E, reject: x } = X.get(f);
|
|
3560
3615
|
X.delete(f), T ? x(new Error(T)) : E(g);
|
|
3561
|
-
},
|
|
3616
|
+
}, ee.onmessageerror = (d) => {
|
|
3562
3617
|
console.error("[ 优化 Worker ] ====> 消息解析失败", d);
|
|
3563
|
-
},
|
|
3618
|
+
}, ee.onerror = (d) => {
|
|
3564
3619
|
console.error("[ 优化 Worker ] ====> 运行错误", d);
|
|
3565
3620
|
};
|
|
3566
3621
|
} catch (d) {
|
|
3567
3622
|
return s.warn("[ 优化 Worker ] ====> 创建失败,可能不支持模块化 Worker", d), null;
|
|
3568
3623
|
}
|
|
3569
|
-
return
|
|
3624
|
+
return ee;
|
|
3570
3625
|
}, m = (d, f, g = !1) => new Promise((T, y) => {
|
|
3571
|
-
const E = ++
|
|
3626
|
+
const E = ++tt;
|
|
3572
3627
|
X.set(E, { resolve: T, reject: y });
|
|
3573
3628
|
const x = {
|
|
3574
3629
|
id: E,
|
|
3575
3630
|
arrayBuffer: f,
|
|
3576
|
-
dracoPath:
|
|
3631
|
+
dracoPath: De,
|
|
3577
3632
|
mode: g ? "progressive" : "standard"
|
|
3578
3633
|
};
|
|
3579
3634
|
d.postMessage(x, [f]);
|
|
3580
3635
|
}), _ = (d, f) => new Promise((g, T) => {
|
|
3581
|
-
const y = ++
|
|
3582
|
-
X.set(y, { resolve: g, reject: T }), d.postMessage({ id: y, arrayBuffer: f, dracoPath:
|
|
3636
|
+
const y = ++tt;
|
|
3637
|
+
X.set(y, { resolve: g, reject: T }), d.postMessage({ id: y, arrayBuffer: f, dracoPath: De });
|
|
3583
3638
|
}), w = (d) => new Promise((f, g) => {
|
|
3584
3639
|
t.parse(d, "", f, g);
|
|
3585
3640
|
});
|
|
3586
3641
|
return {
|
|
3587
|
-
load:
|
|
3588
|
-
asyncLoad:
|
|
3642
|
+
load: o,
|
|
3643
|
+
asyncLoad: i,
|
|
3589
3644
|
asyncCacheLoad: c,
|
|
3590
3645
|
asyncFetch: c,
|
|
3591
3646
|
/**
|
|
3592
3647
|
* 获取缓存统计信息
|
|
3593
3648
|
* @returns {Object} 统计数据
|
|
3594
3649
|
*/
|
|
3595
|
-
getCacheStats: () =>
|
|
3650
|
+
getCacheStats: () => V.getStats(),
|
|
3596
3651
|
/**
|
|
3597
3652
|
* 获取缓存实例
|
|
3598
3653
|
* @returns {IDBCache} 缓存实例
|
|
3599
3654
|
*/
|
|
3600
|
-
getCache: () =>
|
|
3655
|
+
getCache: () => U || (U = new de()),
|
|
3601
3656
|
/**
|
|
3602
3657
|
* 打印缓存性能报告
|
|
3603
3658
|
*/
|
|
3604
|
-
logCacheReport: () =>
|
|
3659
|
+
logCacheReport: () => V.logReport(),
|
|
3605
3660
|
/**
|
|
3606
3661
|
* 重置缓存统计
|
|
3607
3662
|
*/
|
|
3608
|
-
resetCacheStats: () =>
|
|
3663
|
+
resetCacheStats: () => V.reset(),
|
|
3609
3664
|
/**
|
|
3610
3665
|
* 清空内存缓存
|
|
3611
3666
|
* 释放已缓存的 3D 模型对象内存
|
|
@@ -3658,7 +3713,26 @@ const mn = (r = {}) => {
|
|
|
3658
3713
|
const T = g.size;
|
|
3659
3714
|
return H.delete(d), s.info(`[ 内存缓存 ] 删除模型 ${d} 及其所有版本 (共 ${T} 个)`), T > 0;
|
|
3660
3715
|
}
|
|
3661
|
-
}
|
|
3716
|
+
},
|
|
3717
|
+
/**
|
|
3718
|
+
* 清理旧版本格式的缓存数据
|
|
3719
|
+
* 手动触发清理,不需要等待数据库版本升级
|
|
3720
|
+
* @returns {Promise<Object>} 清理结果
|
|
3721
|
+
* @returns {number} returns.total - 总记录数
|
|
3722
|
+
* @returns {number} returns.deleted - 删除的记录数
|
|
3723
|
+
* @returns {number} returns.kept - 保留的记录数
|
|
3724
|
+
* @returns {Array} returns.deletedPaths - 被删除的路径列表
|
|
3725
|
+
*/
|
|
3726
|
+
cleanLegacyCache: async () => await (U || (U = new de())).cleanLegacyFormats(),
|
|
3727
|
+
/**
|
|
3728
|
+
* 验证并修复缓存
|
|
3729
|
+
* @returns {Promise<Object>} 验证结果
|
|
3730
|
+
* @returns {number} returns.total - 总记录数
|
|
3731
|
+
* @returns {number} returns.valid - 有效记录数
|
|
3732
|
+
* @returns {number} returns.invalid - 无效记录数
|
|
3733
|
+
* @returns {number} returns.repairs - 修复的操作数
|
|
3734
|
+
*/
|
|
3735
|
+
validateCache: async () => await (U || (U = new de())).validateAndRepair()
|
|
3662
3736
|
};
|
|
3663
3737
|
};
|
|
3664
3738
|
class gn {
|
|
@@ -3690,10 +3764,10 @@ class gn {
|
|
|
3690
3764
|
_learnAssociations(e) {
|
|
3691
3765
|
const n = this.loadSequence.length - 1;
|
|
3692
3766
|
for (let s = Math.max(0, n - 10); s < n; s++) {
|
|
3693
|
-
const { path:
|
|
3694
|
-
if (this.loadSequence[n].timestamp - this.loadSequence[s].timestamp < 5 * 60 * 1e3 &&
|
|
3695
|
-
this.associations.has(
|
|
3696
|
-
const c = this.associations.get(
|
|
3767
|
+
const { path: o } = this.loadSequence[s];
|
|
3768
|
+
if (this.loadSequence[n].timestamp - this.loadSequence[s].timestamp < 5 * 60 * 1e3 && o !== e) {
|
|
3769
|
+
this.associations.has(o) || this.associations.set(o, /* @__PURE__ */ new Map());
|
|
3770
|
+
const c = this.associations.get(o), a = c.get(e) || 0;
|
|
3697
3771
|
c.set(e, a + 1);
|
|
3698
3772
|
}
|
|
3699
3773
|
}
|
|
@@ -3727,8 +3801,8 @@ class gn {
|
|
|
3727
3801
|
t.set(a, (t.get(a) || 0) + l);
|
|
3728
3802
|
}
|
|
3729
3803
|
});
|
|
3730
|
-
const
|
|
3731
|
-
return new Set(
|
|
3804
|
+
const o = this.loadSequence.slice(-10);
|
|
3805
|
+
return new Set(o.map((c) => c.path)).forEach((c) => {
|
|
3732
3806
|
c !== e && t.set(c, (t.get(c) || 0) + 0.5);
|
|
3733
3807
|
}), Array.from(t.entries()).sort((c, a) => a[1] - c[1]).slice(0, this.options.maxPreloadCount).map(([c]) => c);
|
|
3734
3808
|
}
|
|
@@ -3741,14 +3815,14 @@ class gn {
|
|
|
3741
3815
|
if (this.isPreloading)
|
|
3742
3816
|
return;
|
|
3743
3817
|
this.isPreloading = !0;
|
|
3744
|
-
const { asyncFetch: n } = this.getLoader(), s = e.filter((
|
|
3745
|
-
this.preloadQueue.add(
|
|
3818
|
+
const { asyncFetch: n } = this.getLoader(), s = e.filter((o) => !this.preloadQueue.has(o)).slice(0, this.options.maxPreloadCount).map(async (o) => {
|
|
3819
|
+
this.preloadQueue.add(o);
|
|
3746
3820
|
try {
|
|
3747
|
-
console.log(`[ 智能预加载 ] 开始预加载: ${
|
|
3748
|
-
} catch (
|
|
3749
|
-
console.warn(`[ 智能预加载 ] 失败: ${
|
|
3821
|
+
console.log(`[ 智能预加载 ] 开始预加载: ${o}`), await n(o, t), console.log(`[ 智能预加载 ] 完成: ${o}`);
|
|
3822
|
+
} catch (i) {
|
|
3823
|
+
console.warn(`[ 智能预加载 ] 失败: ${o}`, i);
|
|
3750
3824
|
} finally {
|
|
3751
|
-
this.preloadQueue.delete(
|
|
3825
|
+
this.preloadQueue.delete(o);
|
|
3752
3826
|
}
|
|
3753
3827
|
});
|
|
3754
3828
|
await Promise.all(s), this.isPreloading = !1;
|
|
@@ -3762,8 +3836,8 @@ class gn {
|
|
|
3762
3836
|
this.associations.has(e) || this.associations.set(e, /* @__PURE__ */ new Map());
|
|
3763
3837
|
const n = this.associations.get(e);
|
|
3764
3838
|
t.forEach((s) => {
|
|
3765
|
-
const
|
|
3766
|
-
n.set(s,
|
|
3839
|
+
const o = n.get(s) || 0;
|
|
3840
|
+
n.set(s, o + 10);
|
|
3767
3841
|
});
|
|
3768
3842
|
}
|
|
3769
3843
|
/**
|
|
@@ -3810,14 +3884,14 @@ class gn {
|
|
|
3810
3884
|
});
|
|
3811
3885
|
}
|
|
3812
3886
|
}
|
|
3813
|
-
const
|
|
3887
|
+
const kn = new gn();
|
|
3814
3888
|
export {
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3889
|
+
ln as C,
|
|
3890
|
+
Le as E,
|
|
3891
|
+
de as I,
|
|
3818
3892
|
ce as M,
|
|
3819
3893
|
gn as P,
|
|
3820
|
-
|
|
3894
|
+
_e as R,
|
|
3821
3895
|
ae as S,
|
|
3822
3896
|
En as a,
|
|
3823
3897
|
xn as b,
|
|
@@ -3827,16 +3901,16 @@ export {
|
|
|
3827
3901
|
Mn as f,
|
|
3828
3902
|
Sn as g,
|
|
3829
3903
|
Ln as h,
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3904
|
+
Dn as i,
|
|
3905
|
+
an as j,
|
|
3906
|
+
Pn as k,
|
|
3907
|
+
cn as l,
|
|
3834
3908
|
On as m,
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3909
|
+
V as n,
|
|
3910
|
+
Cn as o,
|
|
3911
|
+
kn as p,
|
|
3912
|
+
In as q,
|
|
3913
|
+
pt as r,
|
|
3840
3914
|
wn as s,
|
|
3841
3915
|
Tn as t,
|
|
3842
3916
|
mn as u
|