@ridp/threejs 0.0.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/dist/common-DGdtPI9P.js +28 -0
- package/dist/common-DbWzzhhR.cjs +1 -0
- package/dist/disposeObject-BuI3II7v.cjs +1 -0
- package/dist/disposeObject-CmFSSgi7.js +616 -0
- package/dist/draco/README.md +32 -0
- package/dist/draco/draco_decoder.js +34 -0
- package/dist/draco/draco_decoder.wasm +0 -0
- package/dist/draco/draco_encoder.js +33 -0
- package/dist/draco/draco_wasm_wrapper.js +117 -0
- package/dist/draco/gltf/draco_decoder.js +33 -0
- package/dist/draco/gltf/draco_decoder.wasm +0 -0
- package/dist/draco/gltf/draco_encoder.js +33 -0
- package/dist/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/dist/hdr/slightly_overcast_sky_dome_1k.hdr +0 -0
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.js +11 -0
- package/dist/threejs.cjs +1 -0
- package/dist/threejs.js +24 -0
- package/dist/useGLTFLoader-CkQCsokF.cjs +6 -0
- package/dist/useGLTFLoader-CoqckCZO.js +2641 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.js +15 -0
- package/package.json +26 -0
- package/src/assets/draco/README.md +32 -0
- package/src/assets/draco/draco_decoder.js +34 -0
- package/src/assets/draco/draco_decoder.wasm +0 -0
- package/src/assets/draco/draco_encoder.js +33 -0
- package/src/assets/draco/draco_wasm_wrapper.js +117 -0
- package/src/assets/draco/gltf/draco_decoder.js +33 -0
- package/src/assets/draco/gltf/draco_decoder.wasm +0 -0
- package/src/assets/draco/gltf/draco_encoder.js +33 -0
- package/src/assets/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/src/assets/hdr/slightly_overcast_sky_dome_1k.hdr +0 -0
- package/src/hooks/index.js +5 -0
- package/src/hooks/useGLTFLoader.js +24 -0
- package/src/hooks/useLight.js +25 -0
- package/src/hooks/useObb.js +74 -0
- package/src/hooks/useRaycaster.js +78 -0
- package/src/hooks/useThreeJs.js +280 -0
- package/src/index.js +2 -0
- package/src/utils/common.js +27 -0
- package/src/utils/css3dHelper.js +24 -0
- package/src/utils/disposeObject.js +39 -0
- package/src/utils/helper.js +56 -0
- package/src/utils/index.js +4 -0
- package/vite.config.js +35 -0
|
@@ -0,0 +1,2641 @@
|
|
|
1
|
+
import { TrianglesDrawMode as ht, TriangleFanDrawMode as Ie, TriangleStripDrawMode as Je, Loader as Ze, FileLoader as ye, SRGBColorSpace as te, LinearSRGBColorSpace as K, BufferGeometry as $e, BufferAttribute as ue, Color as V, ColorManagement as Ne, LoaderUtils as de, MeshPhysicalMaterial as X, Vector2 as De, SpotLight as et, PointLight as ft, DirectionalLight as pt, Matrix4 as ae, Vector3 as O, Quaternion as tt, InstancedMesh as mt, InstancedBufferAttribute as gt, Object3D as nt, TextureLoader as At, ImageBitmapLoader as Tt, InterleavedBuffer as yt, InterleavedBufferAttribute as Rt, LinearMipmapLinearFilter as st, NearestMipmapLinearFilter as xt, LinearMipmapNearestFilter as _t, NearestMipmapNearestFilter as Et, LinearFilter as pe, NearestFilter as rt, RepeatWrapping as Ce, MirroredRepeatWrapping as wt, ClampToEdgeWrapping as bt, PointsMaterial as St, Material as _e, LineBasicMaterial as Lt, MeshStandardMaterial as it, DoubleSide as Mt, MeshBasicMaterial as le, PropertyBinding as It, SkinnedMesh as Nt, Mesh as Ct, LineSegments as Ot, Line as Pt, LineLoop as kt, Points as Dt, Group as Te, PerspectiveCamera as ot, MathUtils as he, OrthographicCamera as Ft, Skeleton as Ht, AnimationClip as vt, Bone as Bt, InterpolateDiscrete as Gt, InterpolateLinear as at, Texture as He, VectorKeyframeTrack as ve, NumberKeyframeTrack as Be, QuaternionKeyframeTrack as Ge, FrontSide as Ut, Interpolant as jt, Box3 as Re, Sphere as zt, DataTextureLoader as Kt, HalfFloatType as me, FloatType as Ee, DataUtils as ge, Matrix3 as ct, Ray as Vt, WebGLRenderer as Xt, Scene as Wt, EquirectangularReflectionMapping as qt, Raycaster as Yt, AmbientLight as Qt } from "three";
|
|
2
|
+
import { i as Jt, g as Zt, a as $t, d as en, j as tn } from "./disposeObject-CmFSSgi7.js";
|
|
3
|
+
var fe = function() {
|
|
4
|
+
var h = 0, e = document.createElement("div");
|
|
5
|
+
e.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", e.addEventListener("click", function(l) {
|
|
6
|
+
l.preventDefault(), r(++h % e.children.length);
|
|
7
|
+
}, !1);
|
|
8
|
+
function t(l) {
|
|
9
|
+
return e.appendChild(l.dom), l;
|
|
10
|
+
}
|
|
11
|
+
function r(l) {
|
|
12
|
+
for (var u = 0; u < e.children.length; u++)
|
|
13
|
+
e.children[u].style.display = u === l ? "block" : "none";
|
|
14
|
+
h = l;
|
|
15
|
+
}
|
|
16
|
+
var n = (performance || Date).now(), i = n, s = 0, a = t(new fe.Panel("FPS", "#0ff", "#002")), o = t(new fe.Panel("MS", "#0f0", "#020"));
|
|
17
|
+
if (self.performance && self.performance.memory)
|
|
18
|
+
var c = t(new fe.Panel("MB", "#f08", "#201"));
|
|
19
|
+
return r(0), {
|
|
20
|
+
REVISION: 16,
|
|
21
|
+
dom: e,
|
|
22
|
+
addPanel: t,
|
|
23
|
+
showPanel: r,
|
|
24
|
+
begin: function() {
|
|
25
|
+
n = (performance || Date).now();
|
|
26
|
+
},
|
|
27
|
+
end: function() {
|
|
28
|
+
s++;
|
|
29
|
+
var l = (performance || Date).now();
|
|
30
|
+
if (o.update(l - n, 200), l >= i + 1e3 && (a.update(s * 1e3 / (l - i), 100), i = l, s = 0, c)) {
|
|
31
|
+
var u = performance.memory;
|
|
32
|
+
c.update(u.usedJSHeapSize / 1048576, u.jsHeapSizeLimit / 1048576);
|
|
33
|
+
}
|
|
34
|
+
return l;
|
|
35
|
+
},
|
|
36
|
+
update: function() {
|
|
37
|
+
n = this.end();
|
|
38
|
+
},
|
|
39
|
+
// Backwards Compatibility
|
|
40
|
+
domElement: e,
|
|
41
|
+
setMode: r
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
fe.Panel = function(h, e, t) {
|
|
45
|
+
var r = 1 / 0, n = 0, i = Math.round, s = i(window.devicePixelRatio || 1), a = 80 * s, o = 48 * s, c = 3 * s, l = 2 * s, u = 3 * s, d = 15 * s, f = 74 * s, m = 30 * s, T = document.createElement("canvas");
|
|
46
|
+
T.width = a, T.height = o, T.style.cssText = "width:80px;height:48px";
|
|
47
|
+
var p = T.getContext("2d");
|
|
48
|
+
return p.font = "bold " + 9 * s + "px Helvetica,Arial,sans-serif", p.textBaseline = "top", p.fillStyle = t, p.fillRect(0, 0, a, o), p.fillStyle = e, p.fillText(h, c, l), p.fillRect(u, d, f, m), p.fillStyle = t, p.globalAlpha = 0.9, p.fillRect(u, d, f, m), {
|
|
49
|
+
dom: T,
|
|
50
|
+
update: function(A, x) {
|
|
51
|
+
r = Math.min(r, A), n = Math.max(n, A), p.fillStyle = t, p.globalAlpha = 1, p.fillRect(0, 0, a, d), p.fillStyle = e, p.fillText(i(A) + " " + h + " (" + i(r) + "-" + i(n) + ")", c, l), p.drawImage(T, u + s, d, f - s, m, u, d, f - s, m), p.fillRect(u + f - s, d, s, m), p.fillStyle = t, p.globalAlpha = 0.9, p.fillRect(u + f - s, d, s, i((1 - A / x) * m));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
function Ue(h, e) {
|
|
56
|
+
if (e === ht)
|
|
57
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), h;
|
|
58
|
+
if (e === Ie || e === Je) {
|
|
59
|
+
let t = h.getIndex();
|
|
60
|
+
if (t === null) {
|
|
61
|
+
const s = [], a = h.getAttribute("position");
|
|
62
|
+
if (a !== void 0) {
|
|
63
|
+
for (let o = 0; o < a.count; o++)
|
|
64
|
+
s.push(o);
|
|
65
|
+
h.setIndex(s), t = h.getIndex();
|
|
66
|
+
} else
|
|
67
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), h;
|
|
68
|
+
}
|
|
69
|
+
const r = t.count - 2, n = [];
|
|
70
|
+
if (e === Ie)
|
|
71
|
+
for (let s = 1; s <= r; s++)
|
|
72
|
+
n.push(t.getX(0)), n.push(t.getX(s)), n.push(t.getX(s + 1));
|
|
73
|
+
else
|
|
74
|
+
for (let s = 0; s < r; s++)
|
|
75
|
+
s % 2 === 0 ? (n.push(t.getX(s)), n.push(t.getX(s + 1)), n.push(t.getX(s + 2))) : (n.push(t.getX(s + 2)), n.push(t.getX(s + 1)), n.push(t.getX(s)));
|
|
76
|
+
n.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
77
|
+
const i = h.clone();
|
|
78
|
+
return i.setIndex(n), i.clearGroups(), i;
|
|
79
|
+
} else
|
|
80
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), h;
|
|
81
|
+
}
|
|
82
|
+
const we = /* @__PURE__ */ new WeakMap();
|
|
83
|
+
class nn extends Ze {
|
|
84
|
+
/**
|
|
85
|
+
* Constructs a new Draco loader.
|
|
86
|
+
*
|
|
87
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
88
|
+
*/
|
|
89
|
+
constructor(e) {
|
|
90
|
+
super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
|
|
91
|
+
position: "POSITION",
|
|
92
|
+
normal: "NORMAL",
|
|
93
|
+
color: "COLOR",
|
|
94
|
+
uv: "TEX_COORD"
|
|
95
|
+
}, this.defaultAttributeTypes = {
|
|
96
|
+
position: "Float32Array",
|
|
97
|
+
normal: "Float32Array",
|
|
98
|
+
color: "Float32Array",
|
|
99
|
+
uv: "Float32Array"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} path - The decoder path.
|
|
106
|
+
* @return {DRACOLoader} A reference to this loader.
|
|
107
|
+
*/
|
|
108
|
+
setDecoderPath(e) {
|
|
109
|
+
return this.decoderPath = e, this;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
|
|
113
|
+
*
|
|
114
|
+
* @param {{type:('js'|'wasm')}} config - The decoder config.
|
|
115
|
+
* @return {DRACOLoader} A reference to this loader.
|
|
116
|
+
*/
|
|
117
|
+
setDecoderConfig(e) {
|
|
118
|
+
return this.decoderConfig = e, this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets the maximum number of Web Workers to be used during decoding.
|
|
122
|
+
* A lower limit may be preferable if workers are also for other tasks in the application.
|
|
123
|
+
*
|
|
124
|
+
* @param {number} workerLimit - The worker limit.
|
|
125
|
+
* @return {DRACOLoader} A reference to this loader.
|
|
126
|
+
*/
|
|
127
|
+
setWorkerLimit(e) {
|
|
128
|
+
return this.workerLimit = e, this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Starts loading from the given URL and passes the loaded Draco asset
|
|
132
|
+
* to the `onLoad()` callback.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
135
|
+
* @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.
|
|
136
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
137
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
138
|
+
*/
|
|
139
|
+
load(e, t, r, n) {
|
|
140
|
+
const i = new ye(this.manager);
|
|
141
|
+
i.setPath(this.path), i.setResponseType("arraybuffer"), i.setRequestHeader(this.requestHeader), i.setWithCredentials(this.withCredentials), i.load(e, (s) => {
|
|
142
|
+
this.parse(s, t, n);
|
|
143
|
+
}, r, n);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parses the given Draco data.
|
|
147
|
+
*
|
|
148
|
+
* @param {ArrayBuffer} buffer - The raw Draco data as an array buffer.
|
|
149
|
+
* @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished.
|
|
150
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
151
|
+
*/
|
|
152
|
+
parse(e, t, r = () => {
|
|
153
|
+
}) {
|
|
154
|
+
this.decodeDracoFile(e, t, null, null, te, r).catch(r);
|
|
155
|
+
}
|
|
156
|
+
//
|
|
157
|
+
decodeDracoFile(e, t, r, n, i = K, s = () => {
|
|
158
|
+
}) {
|
|
159
|
+
const a = {
|
|
160
|
+
attributeIDs: r || this.defaultAttributeIDs,
|
|
161
|
+
attributeTypes: n || this.defaultAttributeTypes,
|
|
162
|
+
useUniqueIDs: !!r,
|
|
163
|
+
vertexColorSpace: i
|
|
164
|
+
};
|
|
165
|
+
return this.decodeGeometry(e, a).then(t).catch(s);
|
|
166
|
+
}
|
|
167
|
+
decodeGeometry(e, t) {
|
|
168
|
+
const r = JSON.stringify(t);
|
|
169
|
+
if (we.has(e)) {
|
|
170
|
+
const o = we.get(e);
|
|
171
|
+
if (o.key === r)
|
|
172
|
+
return o.promise;
|
|
173
|
+
if (e.byteLength === 0)
|
|
174
|
+
throw new Error(
|
|
175
|
+
"THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
let n;
|
|
179
|
+
const i = this.workerNextTaskID++, s = e.byteLength, a = this._getWorker(i, s).then((o) => (n = o, new Promise((c, l) => {
|
|
180
|
+
n._callbacks[i] = { resolve: c, reject: l }, n.postMessage({ type: "decode", id: i, taskConfig: t, buffer: e }, [e]);
|
|
181
|
+
}))).then((o) => this._createGeometry(o.geometry));
|
|
182
|
+
return a.catch(() => !0).then(() => {
|
|
183
|
+
n && i && this._releaseTask(n, i);
|
|
184
|
+
}), we.set(e, {
|
|
185
|
+
key: r,
|
|
186
|
+
promise: a
|
|
187
|
+
}), a;
|
|
188
|
+
}
|
|
189
|
+
_createGeometry(e) {
|
|
190
|
+
const t = new $e();
|
|
191
|
+
e.index && t.setIndex(new ue(e.index.array, 1));
|
|
192
|
+
for (let r = 0; r < e.attributes.length; r++) {
|
|
193
|
+
const n = e.attributes[r], i = n.name, s = n.array, a = n.itemSize, o = new ue(s, a);
|
|
194
|
+
i === "color" && (this._assignVertexColorSpace(o, n.vertexColorSpace), o.normalized = !(s instanceof Float32Array)), t.setAttribute(i, o);
|
|
195
|
+
}
|
|
196
|
+
return t;
|
|
197
|
+
}
|
|
198
|
+
_assignVertexColorSpace(e, t) {
|
|
199
|
+
if (t !== te) return;
|
|
200
|
+
const r = new V();
|
|
201
|
+
for (let n = 0, i = e.count; n < i; n++)
|
|
202
|
+
r.fromBufferAttribute(e, n), Ne.toWorkingColorSpace(r, te), e.setXYZ(n, r.r, r.g, r.b);
|
|
203
|
+
}
|
|
204
|
+
_loadLibrary(e, t) {
|
|
205
|
+
const r = new ye(this.manager);
|
|
206
|
+
return r.setPath(this.decoderPath), r.setResponseType(t), r.setWithCredentials(this.withCredentials), new Promise((n, i) => {
|
|
207
|
+
r.load(e, n, void 0, i);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
preload() {
|
|
211
|
+
return this._initDecoder(), this;
|
|
212
|
+
}
|
|
213
|
+
_initDecoder() {
|
|
214
|
+
if (this.decoderPending) return this.decoderPending;
|
|
215
|
+
const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
|
|
216
|
+
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((r) => {
|
|
217
|
+
const n = r[0];
|
|
218
|
+
e || (this.decoderConfig.wasmBinary = r[1]);
|
|
219
|
+
const i = sn.toString(), s = [
|
|
220
|
+
"/* draco decoder */",
|
|
221
|
+
n,
|
|
222
|
+
"",
|
|
223
|
+
"/* worker */",
|
|
224
|
+
i.substring(i.indexOf("{") + 1, i.lastIndexOf("}"))
|
|
225
|
+
].join(`
|
|
226
|
+
`);
|
|
227
|
+
this.workerSourceURL = URL.createObjectURL(new Blob([s]));
|
|
228
|
+
}), this.decoderPending;
|
|
229
|
+
}
|
|
230
|
+
_getWorker(e, t) {
|
|
231
|
+
return this._initDecoder().then(() => {
|
|
232
|
+
if (this.workerPool.length < this.workerLimit) {
|
|
233
|
+
const n = new Worker(this.workerSourceURL);
|
|
234
|
+
n._callbacks = {}, n._taskCosts = {}, n._taskLoad = 0, n.postMessage({ type: "init", decoderConfig: this.decoderConfig }), n.onmessage = function(i) {
|
|
235
|
+
const s = i.data;
|
|
236
|
+
switch (s.type) {
|
|
237
|
+
case "decode":
|
|
238
|
+
n._callbacks[s.id].resolve(s);
|
|
239
|
+
break;
|
|
240
|
+
case "error":
|
|
241
|
+
n._callbacks[s.id].reject(s);
|
|
242
|
+
break;
|
|
243
|
+
default:
|
|
244
|
+
console.error('THREE.DRACOLoader: Unexpected message, "' + s.type + '"');
|
|
245
|
+
}
|
|
246
|
+
}, this.workerPool.push(n);
|
|
247
|
+
} else
|
|
248
|
+
this.workerPool.sort(function(n, i) {
|
|
249
|
+
return n._taskLoad > i._taskLoad ? -1 : 1;
|
|
250
|
+
});
|
|
251
|
+
const r = this.workerPool[this.workerPool.length - 1];
|
|
252
|
+
return r._taskCosts[e] = t, r._taskLoad += t, r;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
_releaseTask(e, t) {
|
|
256
|
+
e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];
|
|
257
|
+
}
|
|
258
|
+
debug() {
|
|
259
|
+
console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));
|
|
260
|
+
}
|
|
261
|
+
dispose() {
|
|
262
|
+
for (let e = 0; e < this.workerPool.length; ++e)
|
|
263
|
+
this.workerPool[e].terminate();
|
|
264
|
+
return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function sn() {
|
|
268
|
+
let h, e;
|
|
269
|
+
onmessage = function(s) {
|
|
270
|
+
const a = s.data;
|
|
271
|
+
switch (a.type) {
|
|
272
|
+
case "init":
|
|
273
|
+
h = a.decoderConfig, e = new Promise(function(l) {
|
|
274
|
+
h.onModuleLoaded = function(u) {
|
|
275
|
+
l({ draco: u });
|
|
276
|
+
}, DracoDecoderModule(h);
|
|
277
|
+
});
|
|
278
|
+
break;
|
|
279
|
+
case "decode":
|
|
280
|
+
const o = a.buffer, c = a.taskConfig;
|
|
281
|
+
e.then((l) => {
|
|
282
|
+
const u = l.draco, d = new u.Decoder();
|
|
283
|
+
try {
|
|
284
|
+
const f = t(u, d, new Int8Array(o), c), m = f.attributes.map((T) => T.array.buffer);
|
|
285
|
+
f.index && m.push(f.index.array.buffer), self.postMessage({ type: "decode", id: a.id, geometry: f }, m);
|
|
286
|
+
} catch (f) {
|
|
287
|
+
console.error(f), self.postMessage({ type: "error", id: a.id, error: f.message });
|
|
288
|
+
} finally {
|
|
289
|
+
u.destroy(d);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
function t(s, a, o, c) {
|
|
296
|
+
const l = c.attributeIDs, u = c.attributeTypes;
|
|
297
|
+
let d, f;
|
|
298
|
+
const m = a.GetEncodedGeometryType(o);
|
|
299
|
+
if (m === s.TRIANGULAR_MESH)
|
|
300
|
+
d = new s.Mesh(), f = a.DecodeArrayToMesh(o, o.byteLength, d);
|
|
301
|
+
else if (m === s.POINT_CLOUD)
|
|
302
|
+
d = new s.PointCloud(), f = a.DecodeArrayToPointCloud(o, o.byteLength, d);
|
|
303
|
+
else
|
|
304
|
+
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
|
305
|
+
if (!f.ok() || d.ptr === 0)
|
|
306
|
+
throw new Error("THREE.DRACOLoader: Decoding failed: " + f.error_msg());
|
|
307
|
+
const T = { index: null, attributes: [] };
|
|
308
|
+
for (const p in l) {
|
|
309
|
+
const A = self[u[p]];
|
|
310
|
+
let x, N;
|
|
311
|
+
if (c.useUniqueIDs)
|
|
312
|
+
N = l[p], x = a.GetAttributeByUniqueId(d, N);
|
|
313
|
+
else {
|
|
314
|
+
if (N = a.GetAttributeId(d, s[l[p]]), N === -1) continue;
|
|
315
|
+
x = a.GetAttribute(d, N);
|
|
316
|
+
}
|
|
317
|
+
const _ = n(s, a, d, p, A, x);
|
|
318
|
+
p === "color" && (_.vertexColorSpace = c.vertexColorSpace), T.attributes.push(_);
|
|
319
|
+
}
|
|
320
|
+
return m === s.TRIANGULAR_MESH && (T.index = r(s, a, d)), s.destroy(d), T;
|
|
321
|
+
}
|
|
322
|
+
function r(s, a, o) {
|
|
323
|
+
const l = o.num_faces() * 3, u = l * 4, d = s._malloc(u);
|
|
324
|
+
a.GetTrianglesUInt32Array(o, u, d);
|
|
325
|
+
const f = new Uint32Array(s.HEAPF32.buffer, d, l).slice();
|
|
326
|
+
return s._free(d), { array: f, itemSize: 1 };
|
|
327
|
+
}
|
|
328
|
+
function n(s, a, o, c, l, u) {
|
|
329
|
+
const d = u.num_components(), m = o.num_points() * d, T = m * l.BYTES_PER_ELEMENT, p = i(s, l), A = s._malloc(T);
|
|
330
|
+
a.GetAttributeDataArrayForAllPoints(o, u, p, T, A);
|
|
331
|
+
const x = new l(s.HEAPF32.buffer, A, m).slice();
|
|
332
|
+
return s._free(A), {
|
|
333
|
+
name: c,
|
|
334
|
+
array: x,
|
|
335
|
+
itemSize: d
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function i(s, a) {
|
|
339
|
+
switch (a) {
|
|
340
|
+
case Float32Array:
|
|
341
|
+
return s.DT_FLOAT32;
|
|
342
|
+
case Int8Array:
|
|
343
|
+
return s.DT_INT8;
|
|
344
|
+
case Int16Array:
|
|
345
|
+
return s.DT_INT16;
|
|
346
|
+
case Int32Array:
|
|
347
|
+
return s.DT_INT32;
|
|
348
|
+
case Uint8Array:
|
|
349
|
+
return s.DT_UINT8;
|
|
350
|
+
case Uint16Array:
|
|
351
|
+
return s.DT_UINT16;
|
|
352
|
+
case Uint32Array:
|
|
353
|
+
return s.DT_UINT32;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
class rn extends Ze {
|
|
358
|
+
/**
|
|
359
|
+
* Constructs a new glTF loader.
|
|
360
|
+
*
|
|
361
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
362
|
+
*/
|
|
363
|
+
constructor(e) {
|
|
364
|
+
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
365
|
+
return new un(t);
|
|
366
|
+
}), this.register(function(t) {
|
|
367
|
+
return new dn(t);
|
|
368
|
+
}), this.register(function(t) {
|
|
369
|
+
return new Rn(t);
|
|
370
|
+
}), this.register(function(t) {
|
|
371
|
+
return new xn(t);
|
|
372
|
+
}), this.register(function(t) {
|
|
373
|
+
return new _n(t);
|
|
374
|
+
}), this.register(function(t) {
|
|
375
|
+
return new fn(t);
|
|
376
|
+
}), this.register(function(t) {
|
|
377
|
+
return new pn(t);
|
|
378
|
+
}), this.register(function(t) {
|
|
379
|
+
return new mn(t);
|
|
380
|
+
}), this.register(function(t) {
|
|
381
|
+
return new gn(t);
|
|
382
|
+
}), this.register(function(t) {
|
|
383
|
+
return new ln(t);
|
|
384
|
+
}), this.register(function(t) {
|
|
385
|
+
return new An(t);
|
|
386
|
+
}), this.register(function(t) {
|
|
387
|
+
return new hn(t);
|
|
388
|
+
}), this.register(function(t) {
|
|
389
|
+
return new yn(t);
|
|
390
|
+
}), this.register(function(t) {
|
|
391
|
+
return new Tn(t);
|
|
392
|
+
}), this.register(function(t) {
|
|
393
|
+
return new an(t);
|
|
394
|
+
}), this.register(function(t) {
|
|
395
|
+
return new En(t);
|
|
396
|
+
}), this.register(function(t) {
|
|
397
|
+
return new wn(t);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
402
|
+
* to the `onLoad()` callback.
|
|
403
|
+
*
|
|
404
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
405
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
406
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
407
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
408
|
+
*/
|
|
409
|
+
load(e, t, r, n) {
|
|
410
|
+
const i = this;
|
|
411
|
+
let s;
|
|
412
|
+
if (this.resourcePath !== "")
|
|
413
|
+
s = this.resourcePath;
|
|
414
|
+
else if (this.path !== "") {
|
|
415
|
+
const c = de.extractUrlBase(e);
|
|
416
|
+
s = de.resolveURL(c, this.path);
|
|
417
|
+
} else
|
|
418
|
+
s = de.extractUrlBase(e);
|
|
419
|
+
this.manager.itemStart(e);
|
|
420
|
+
const a = function(c) {
|
|
421
|
+
n ? n(c) : console.error(c), i.manager.itemError(e), i.manager.itemEnd(e);
|
|
422
|
+
}, o = new ye(this.manager);
|
|
423
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(c) {
|
|
424
|
+
try {
|
|
425
|
+
i.parse(c, s, function(l) {
|
|
426
|
+
t(l), i.manager.itemEnd(e);
|
|
427
|
+
}, a);
|
|
428
|
+
} catch (l) {
|
|
429
|
+
a(l);
|
|
430
|
+
}
|
|
431
|
+
}, r, a);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
435
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
436
|
+
*
|
|
437
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
438
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
439
|
+
*/
|
|
440
|
+
setDRACOLoader(e) {
|
|
441
|
+
return this.dracoLoader = e, this;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
445
|
+
* compressed textures.
|
|
446
|
+
*
|
|
447
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
448
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
449
|
+
*/
|
|
450
|
+
setKTX2Loader(e) {
|
|
451
|
+
return this.ktx2Loader = e, this;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
455
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
456
|
+
*
|
|
457
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
458
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
459
|
+
*/
|
|
460
|
+
setMeshoptDecoder(e) {
|
|
461
|
+
return this.meshoptDecoder = e, this;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
465
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
466
|
+
* to the loader.
|
|
467
|
+
*
|
|
468
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
469
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
470
|
+
*/
|
|
471
|
+
register(e) {
|
|
472
|
+
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Unregisters a plugin callback.
|
|
476
|
+
*
|
|
477
|
+
* @param {Function} callback - The callback function to unregister.
|
|
478
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
479
|
+
*/
|
|
480
|
+
unregister(e) {
|
|
481
|
+
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Parses the given FBX data and returns the resulting group.
|
|
485
|
+
*
|
|
486
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
487
|
+
* @param {string} path - The URL base path.
|
|
488
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
489
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
490
|
+
*/
|
|
491
|
+
parse(e, t, r, n) {
|
|
492
|
+
let i;
|
|
493
|
+
const s = {}, a = {}, o = new TextDecoder();
|
|
494
|
+
if (typeof e == "string")
|
|
495
|
+
i = JSON.parse(e);
|
|
496
|
+
else if (e instanceof ArrayBuffer)
|
|
497
|
+
if (o.decode(new Uint8Array(e, 0, 4)) === lt) {
|
|
498
|
+
try {
|
|
499
|
+
s[E.KHR_BINARY_GLTF] = new bn(e);
|
|
500
|
+
} catch (u) {
|
|
501
|
+
n && n(u);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
i = JSON.parse(s[E.KHR_BINARY_GLTF].content);
|
|
505
|
+
} else
|
|
506
|
+
i = JSON.parse(o.decode(e));
|
|
507
|
+
else
|
|
508
|
+
i = e;
|
|
509
|
+
if (i.asset === void 0 || i.asset.version[0] < 2) {
|
|
510
|
+
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const c = new vn(i, {
|
|
514
|
+
path: t || this.resourcePath || "",
|
|
515
|
+
crossOrigin: this.crossOrigin,
|
|
516
|
+
requestHeader: this.requestHeader,
|
|
517
|
+
manager: this.manager,
|
|
518
|
+
ktx2Loader: this.ktx2Loader,
|
|
519
|
+
meshoptDecoder: this.meshoptDecoder
|
|
520
|
+
});
|
|
521
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
522
|
+
for (let l = 0; l < this.pluginCallbacks.length; l++) {
|
|
523
|
+
const u = this.pluginCallbacks[l](c);
|
|
524
|
+
u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[u.name] = u, s[u.name] = !0;
|
|
525
|
+
}
|
|
526
|
+
if (i.extensionsUsed)
|
|
527
|
+
for (let l = 0; l < i.extensionsUsed.length; ++l) {
|
|
528
|
+
const u = i.extensionsUsed[l], d = i.extensionsRequired || [];
|
|
529
|
+
switch (u) {
|
|
530
|
+
case E.KHR_MATERIALS_UNLIT:
|
|
531
|
+
s[u] = new cn();
|
|
532
|
+
break;
|
|
533
|
+
case E.KHR_DRACO_MESH_COMPRESSION:
|
|
534
|
+
s[u] = new Sn(i, this.dracoLoader);
|
|
535
|
+
break;
|
|
536
|
+
case E.KHR_TEXTURE_TRANSFORM:
|
|
537
|
+
s[u] = new Ln();
|
|
538
|
+
break;
|
|
539
|
+
case E.KHR_MESH_QUANTIZATION:
|
|
540
|
+
s[u] = new Mn();
|
|
541
|
+
break;
|
|
542
|
+
default:
|
|
543
|
+
d.indexOf(u) >= 0 && a[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
c.setExtensions(s), c.setPlugins(a), c.parse(r, n);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
550
|
+
*
|
|
551
|
+
* @async
|
|
552
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
553
|
+
* @param {string} path - The URL base path.
|
|
554
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
555
|
+
*/
|
|
556
|
+
parseAsync(e, t) {
|
|
557
|
+
const r = this;
|
|
558
|
+
return new Promise(function(n, i) {
|
|
559
|
+
r.parse(e, t, n, i);
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function on() {
|
|
564
|
+
let h = {};
|
|
565
|
+
return {
|
|
566
|
+
get: function(e) {
|
|
567
|
+
return h[e];
|
|
568
|
+
},
|
|
569
|
+
add: function(e, t) {
|
|
570
|
+
h[e] = t;
|
|
571
|
+
},
|
|
572
|
+
remove: function(e) {
|
|
573
|
+
delete h[e];
|
|
574
|
+
},
|
|
575
|
+
removeAll: function() {
|
|
576
|
+
h = {};
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
const E = {
|
|
581
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
582
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
583
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
584
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
585
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
586
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
587
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
588
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
589
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
590
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
591
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
592
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
593
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
594
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
595
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
596
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
597
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
598
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
599
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
600
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
601
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
602
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
603
|
+
};
|
|
604
|
+
class an {
|
|
605
|
+
constructor(e) {
|
|
606
|
+
this.parser = e, this.name = E.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
607
|
+
}
|
|
608
|
+
_markDefs() {
|
|
609
|
+
const e = this.parser, t = this.parser.json.nodes || [];
|
|
610
|
+
for (let r = 0, n = t.length; r < n; r++) {
|
|
611
|
+
const i = t[r];
|
|
612
|
+
i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, i.extensions[this.name].light);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
_loadLight(e) {
|
|
616
|
+
const t = this.parser, r = "light:" + e;
|
|
617
|
+
let n = t.cache.get(r);
|
|
618
|
+
if (n) return n;
|
|
619
|
+
const i = t.json, o = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e];
|
|
620
|
+
let c;
|
|
621
|
+
const l = new V(16777215);
|
|
622
|
+
o.color !== void 0 && l.setRGB(o.color[0], o.color[1], o.color[2], K);
|
|
623
|
+
const u = o.range !== void 0 ? o.range : 0;
|
|
624
|
+
switch (o.type) {
|
|
625
|
+
case "directional":
|
|
626
|
+
c = new pt(l), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
627
|
+
break;
|
|
628
|
+
case "point":
|
|
629
|
+
c = new ft(l), c.distance = u;
|
|
630
|
+
break;
|
|
631
|
+
case "spot":
|
|
632
|
+
c = new et(l), c.distance = u, o.spot = o.spot || {}, o.spot.innerConeAngle = o.spot.innerConeAngle !== void 0 ? o.spot.innerConeAngle : 0, o.spot.outerConeAngle = o.spot.outerConeAngle !== void 0 ? o.spot.outerConeAngle : Math.PI / 4, c.angle = o.spot.outerConeAngle, c.penumbra = 1 - o.spot.innerConeAngle / o.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
|
|
633
|
+
break;
|
|
634
|
+
default:
|
|
635
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + o.type);
|
|
636
|
+
}
|
|
637
|
+
return c.position.set(0, 0, 0), Z(c, o), o.intensity !== void 0 && (c.intensity = o.intensity), c.name = t.createUniqueName(o.name || "light_" + e), n = Promise.resolve(c), t.cache.add(r, n), n;
|
|
638
|
+
}
|
|
639
|
+
getDependency(e, t) {
|
|
640
|
+
if (e === "light")
|
|
641
|
+
return this._loadLight(t);
|
|
642
|
+
}
|
|
643
|
+
createNodeAttachment(e) {
|
|
644
|
+
const t = this, r = this.parser, i = r.json.nodes[e], a = (i.extensions && i.extensions[this.name] || {}).light;
|
|
645
|
+
return a === void 0 ? null : this._loadLight(a).then(function(o) {
|
|
646
|
+
return r._getNodeRef(t.cache, a, o);
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
class cn {
|
|
651
|
+
constructor() {
|
|
652
|
+
this.name = E.KHR_MATERIALS_UNLIT;
|
|
653
|
+
}
|
|
654
|
+
getMaterialType() {
|
|
655
|
+
return le;
|
|
656
|
+
}
|
|
657
|
+
extendParams(e, t, r) {
|
|
658
|
+
const n = [];
|
|
659
|
+
e.color = new V(1, 1, 1), e.opacity = 1;
|
|
660
|
+
const i = t.pbrMetallicRoughness;
|
|
661
|
+
if (i) {
|
|
662
|
+
if (Array.isArray(i.baseColorFactor)) {
|
|
663
|
+
const s = i.baseColorFactor;
|
|
664
|
+
e.color.setRGB(s[0], s[1], s[2], K), e.opacity = s[3];
|
|
665
|
+
}
|
|
666
|
+
i.baseColorTexture !== void 0 && n.push(r.assignTexture(e, "map", i.baseColorTexture, te));
|
|
667
|
+
}
|
|
668
|
+
return Promise.all(n);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
class ln {
|
|
672
|
+
constructor(e) {
|
|
673
|
+
this.parser = e, this.name = E.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
674
|
+
}
|
|
675
|
+
extendMaterialParams(e, t) {
|
|
676
|
+
const n = this.parser.json.materials[e];
|
|
677
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
678
|
+
return Promise.resolve();
|
|
679
|
+
const i = n.extensions[this.name].emissiveStrength;
|
|
680
|
+
return i !== void 0 && (t.emissiveIntensity = i), Promise.resolve();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
class un {
|
|
684
|
+
constructor(e) {
|
|
685
|
+
this.parser = e, this.name = E.KHR_MATERIALS_CLEARCOAT;
|
|
686
|
+
}
|
|
687
|
+
getMaterialType(e) {
|
|
688
|
+
const r = this.parser.json.materials[e];
|
|
689
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
690
|
+
}
|
|
691
|
+
extendMaterialParams(e, t) {
|
|
692
|
+
const r = this.parser, n = r.json.materials[e];
|
|
693
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
694
|
+
return Promise.resolve();
|
|
695
|
+
const i = [], s = n.extensions[this.name];
|
|
696
|
+
if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && i.push(r.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && i.push(r.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (i.push(r.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
|
|
697
|
+
const a = s.clearcoatNormalTexture.scale;
|
|
698
|
+
t.clearcoatNormalScale = new De(a, a);
|
|
699
|
+
}
|
|
700
|
+
return Promise.all(i);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
class dn {
|
|
704
|
+
constructor(e) {
|
|
705
|
+
this.parser = e, this.name = E.KHR_MATERIALS_DISPERSION;
|
|
706
|
+
}
|
|
707
|
+
getMaterialType(e) {
|
|
708
|
+
const r = this.parser.json.materials[e];
|
|
709
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
710
|
+
}
|
|
711
|
+
extendMaterialParams(e, t) {
|
|
712
|
+
const n = this.parser.json.materials[e];
|
|
713
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
714
|
+
return Promise.resolve();
|
|
715
|
+
const i = n.extensions[this.name];
|
|
716
|
+
return t.dispersion = i.dispersion !== void 0 ? i.dispersion : 0, Promise.resolve();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
class hn {
|
|
720
|
+
constructor(e) {
|
|
721
|
+
this.parser = e, this.name = E.KHR_MATERIALS_IRIDESCENCE;
|
|
722
|
+
}
|
|
723
|
+
getMaterialType(e) {
|
|
724
|
+
const r = this.parser.json.materials[e];
|
|
725
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
726
|
+
}
|
|
727
|
+
extendMaterialParams(e, t) {
|
|
728
|
+
const r = this.parser, n = r.json.materials[e];
|
|
729
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
730
|
+
return Promise.resolve();
|
|
731
|
+
const i = [], s = n.extensions[this.name];
|
|
732
|
+
return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && i.push(r.assignTexture(t, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (t.iridescenceIOR = s.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && i.push(r.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(i);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
class fn {
|
|
736
|
+
constructor(e) {
|
|
737
|
+
this.parser = e, this.name = E.KHR_MATERIALS_SHEEN;
|
|
738
|
+
}
|
|
739
|
+
getMaterialType(e) {
|
|
740
|
+
const r = this.parser.json.materials[e];
|
|
741
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
742
|
+
}
|
|
743
|
+
extendMaterialParams(e, t) {
|
|
744
|
+
const r = this.parser, n = r.json.materials[e];
|
|
745
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
746
|
+
return Promise.resolve();
|
|
747
|
+
const i = [];
|
|
748
|
+
t.sheenColor = new V(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
|
|
749
|
+
const s = n.extensions[this.name];
|
|
750
|
+
if (s.sheenColorFactor !== void 0) {
|
|
751
|
+
const a = s.sheenColorFactor;
|
|
752
|
+
t.sheenColor.setRGB(a[0], a[1], a[2], K);
|
|
753
|
+
}
|
|
754
|
+
return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && i.push(r.assignTexture(t, "sheenColorMap", s.sheenColorTexture, te)), s.sheenRoughnessTexture !== void 0 && i.push(r.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(i);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
class pn {
|
|
758
|
+
constructor(e) {
|
|
759
|
+
this.parser = e, this.name = E.KHR_MATERIALS_TRANSMISSION;
|
|
760
|
+
}
|
|
761
|
+
getMaterialType(e) {
|
|
762
|
+
const r = this.parser.json.materials[e];
|
|
763
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
764
|
+
}
|
|
765
|
+
extendMaterialParams(e, t) {
|
|
766
|
+
const r = this.parser, n = r.json.materials[e];
|
|
767
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
768
|
+
return Promise.resolve();
|
|
769
|
+
const i = [], s = n.extensions[this.name];
|
|
770
|
+
return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && i.push(r.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(i);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
class mn {
|
|
774
|
+
constructor(e) {
|
|
775
|
+
this.parser = e, this.name = E.KHR_MATERIALS_VOLUME;
|
|
776
|
+
}
|
|
777
|
+
getMaterialType(e) {
|
|
778
|
+
const r = this.parser.json.materials[e];
|
|
779
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
780
|
+
}
|
|
781
|
+
extendMaterialParams(e, t) {
|
|
782
|
+
const r = this.parser, n = r.json.materials[e];
|
|
783
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
784
|
+
return Promise.resolve();
|
|
785
|
+
const i = [], s = n.extensions[this.name];
|
|
786
|
+
t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && i.push(r.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
|
|
787
|
+
const a = s.attenuationColor || [1, 1, 1];
|
|
788
|
+
return t.attenuationColor = new V().setRGB(a[0], a[1], a[2], K), Promise.all(i);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
class gn {
|
|
792
|
+
constructor(e) {
|
|
793
|
+
this.parser = e, this.name = E.KHR_MATERIALS_IOR;
|
|
794
|
+
}
|
|
795
|
+
getMaterialType(e) {
|
|
796
|
+
const r = this.parser.json.materials[e];
|
|
797
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
798
|
+
}
|
|
799
|
+
extendMaterialParams(e, t) {
|
|
800
|
+
const n = this.parser.json.materials[e];
|
|
801
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
802
|
+
return Promise.resolve();
|
|
803
|
+
const i = n.extensions[this.name];
|
|
804
|
+
return t.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve();
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
class An {
|
|
808
|
+
constructor(e) {
|
|
809
|
+
this.parser = e, this.name = E.KHR_MATERIALS_SPECULAR;
|
|
810
|
+
}
|
|
811
|
+
getMaterialType(e) {
|
|
812
|
+
const r = this.parser.json.materials[e];
|
|
813
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
814
|
+
}
|
|
815
|
+
extendMaterialParams(e, t) {
|
|
816
|
+
const r = this.parser, n = r.json.materials[e];
|
|
817
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
818
|
+
return Promise.resolve();
|
|
819
|
+
const i = [], s = n.extensions[this.name];
|
|
820
|
+
t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && i.push(r.assignTexture(t, "specularIntensityMap", s.specularTexture));
|
|
821
|
+
const a = s.specularColorFactor || [1, 1, 1];
|
|
822
|
+
return t.specularColor = new V().setRGB(a[0], a[1], a[2], K), s.specularColorTexture !== void 0 && i.push(r.assignTexture(t, "specularColorMap", s.specularColorTexture, te)), Promise.all(i);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
class Tn {
|
|
826
|
+
constructor(e) {
|
|
827
|
+
this.parser = e, this.name = E.EXT_MATERIALS_BUMP;
|
|
828
|
+
}
|
|
829
|
+
getMaterialType(e) {
|
|
830
|
+
const r = this.parser.json.materials[e];
|
|
831
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
832
|
+
}
|
|
833
|
+
extendMaterialParams(e, t) {
|
|
834
|
+
const r = this.parser, n = r.json.materials[e];
|
|
835
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
836
|
+
return Promise.resolve();
|
|
837
|
+
const i = [], s = n.extensions[this.name];
|
|
838
|
+
return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && i.push(r.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(i);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
class yn {
|
|
842
|
+
constructor(e) {
|
|
843
|
+
this.parser = e, this.name = E.KHR_MATERIALS_ANISOTROPY;
|
|
844
|
+
}
|
|
845
|
+
getMaterialType(e) {
|
|
846
|
+
const r = this.parser.json.materials[e];
|
|
847
|
+
return !r.extensions || !r.extensions[this.name] ? null : X;
|
|
848
|
+
}
|
|
849
|
+
extendMaterialParams(e, t) {
|
|
850
|
+
const r = this.parser, n = r.json.materials[e];
|
|
851
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
852
|
+
return Promise.resolve();
|
|
853
|
+
const i = [], s = n.extensions[this.name];
|
|
854
|
+
return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && i.push(r.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(i);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
class Rn {
|
|
858
|
+
constructor(e) {
|
|
859
|
+
this.parser = e, this.name = E.KHR_TEXTURE_BASISU;
|
|
860
|
+
}
|
|
861
|
+
loadTexture(e) {
|
|
862
|
+
const t = this.parser, r = t.json, n = r.textures[e];
|
|
863
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
864
|
+
return null;
|
|
865
|
+
const i = n.extensions[this.name], s = t.options.ktx2Loader;
|
|
866
|
+
if (!s) {
|
|
867
|
+
if (r.extensionsRequired && r.extensionsRequired.indexOf(this.name) >= 0)
|
|
868
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
return t.loadTextureImage(e, i.source, s);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
class xn {
|
|
875
|
+
constructor(e) {
|
|
876
|
+
this.parser = e, this.name = E.EXT_TEXTURE_WEBP, this.isSupported = null;
|
|
877
|
+
}
|
|
878
|
+
loadTexture(e) {
|
|
879
|
+
const t = this.name, r = this.parser, n = r.json, i = n.textures[e];
|
|
880
|
+
if (!i.extensions || !i.extensions[t])
|
|
881
|
+
return null;
|
|
882
|
+
const s = i.extensions[t], a = n.images[s.source];
|
|
883
|
+
let o = r.textureLoader;
|
|
884
|
+
if (a.uri) {
|
|
885
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
886
|
+
c !== null && (o = c);
|
|
887
|
+
}
|
|
888
|
+
return this.detectSupport().then(function(c) {
|
|
889
|
+
if (c) return r.loadTextureImage(e, s.source, o);
|
|
890
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
|
|
891
|
+
throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
|
|
892
|
+
return r.loadTexture(e);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
detectSupport() {
|
|
896
|
+
return this.isSupported || (this.isSupported = new Promise(function(e) {
|
|
897
|
+
const t = new Image();
|
|
898
|
+
t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
|
|
899
|
+
e(t.height === 1);
|
|
900
|
+
};
|
|
901
|
+
})), this.isSupported;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
class _n {
|
|
905
|
+
constructor(e) {
|
|
906
|
+
this.parser = e, this.name = E.EXT_TEXTURE_AVIF, this.isSupported = null;
|
|
907
|
+
}
|
|
908
|
+
loadTexture(e) {
|
|
909
|
+
const t = this.name, r = this.parser, n = r.json, i = n.textures[e];
|
|
910
|
+
if (!i.extensions || !i.extensions[t])
|
|
911
|
+
return null;
|
|
912
|
+
const s = i.extensions[t], a = n.images[s.source];
|
|
913
|
+
let o = r.textureLoader;
|
|
914
|
+
if (a.uri) {
|
|
915
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
916
|
+
c !== null && (o = c);
|
|
917
|
+
}
|
|
918
|
+
return this.detectSupport().then(function(c) {
|
|
919
|
+
if (c) return r.loadTextureImage(e, s.source, o);
|
|
920
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
|
|
921
|
+
throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
|
|
922
|
+
return r.loadTexture(e);
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
detectSupport() {
|
|
926
|
+
return this.isSupported || (this.isSupported = new Promise(function(e) {
|
|
927
|
+
const t = new Image();
|
|
928
|
+
t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
|
|
929
|
+
e(t.height === 1);
|
|
930
|
+
};
|
|
931
|
+
})), this.isSupported;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
class En {
|
|
935
|
+
constructor(e) {
|
|
936
|
+
this.name = E.EXT_MESHOPT_COMPRESSION, this.parser = e;
|
|
937
|
+
}
|
|
938
|
+
loadBufferView(e) {
|
|
939
|
+
const t = this.parser.json, r = t.bufferViews[e];
|
|
940
|
+
if (r.extensions && r.extensions[this.name]) {
|
|
941
|
+
const n = r.extensions[this.name], i = this.parser.getDependency("buffer", n.buffer), s = this.parser.options.meshoptDecoder;
|
|
942
|
+
if (!s || !s.supported) {
|
|
943
|
+
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
|
|
944
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
return i.then(function(a) {
|
|
948
|
+
const o = n.byteOffset || 0, c = n.byteLength || 0, l = n.count, u = n.byteStride, d = new Uint8Array(a, o, c);
|
|
949
|
+
return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(l, u, d, n.mode, n.filter).then(function(f) {
|
|
950
|
+
return f.buffer;
|
|
951
|
+
}) : s.ready.then(function() {
|
|
952
|
+
const f = new ArrayBuffer(l * u);
|
|
953
|
+
return s.decodeGltfBuffer(new Uint8Array(f), l, u, d, n.mode, n.filter), f;
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
} else
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
class wn {
|
|
961
|
+
constructor(e) {
|
|
962
|
+
this.name = E.EXT_MESH_GPU_INSTANCING, this.parser = e;
|
|
963
|
+
}
|
|
964
|
+
createNodeMesh(e) {
|
|
965
|
+
const t = this.parser.json, r = t.nodes[e];
|
|
966
|
+
if (!r.extensions || !r.extensions[this.name] || r.mesh === void 0)
|
|
967
|
+
return null;
|
|
968
|
+
const n = t.meshes[r.mesh];
|
|
969
|
+
for (const c of n.primitives)
|
|
970
|
+
if (c.mode !== j.TRIANGLES && c.mode !== j.TRIANGLE_STRIP && c.mode !== j.TRIANGLE_FAN && c.mode !== void 0)
|
|
971
|
+
return null;
|
|
972
|
+
const s = r.extensions[this.name].attributes, a = [], o = {};
|
|
973
|
+
for (const c in s)
|
|
974
|
+
a.push(this.parser.getDependency("accessor", s[c]).then((l) => (o[c] = l, o[c])));
|
|
975
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((c) => {
|
|
976
|
+
const l = c.pop(), u = l.isGroup ? l.children : [l], d = c[0].count, f = [];
|
|
977
|
+
for (const m of u) {
|
|
978
|
+
const T = new ae(), p = new O(), A = new tt(), x = new O(1, 1, 1), N = new mt(m.geometry, m.material, d);
|
|
979
|
+
for (let _ = 0; _ < d; _++)
|
|
980
|
+
o.TRANSLATION && p.fromBufferAttribute(o.TRANSLATION, _), o.ROTATION && A.fromBufferAttribute(o.ROTATION, _), o.SCALE && x.fromBufferAttribute(o.SCALE, _), N.setMatrixAt(_, T.compose(p, A, x));
|
|
981
|
+
for (const _ in o)
|
|
982
|
+
if (_ === "_COLOR_0") {
|
|
983
|
+
const B = o[_];
|
|
984
|
+
N.instanceColor = new gt(B.array, B.itemSize, B.normalized);
|
|
985
|
+
} else _ !== "TRANSLATION" && _ !== "ROTATION" && _ !== "SCALE" && m.geometry.setAttribute(_, o[_]);
|
|
986
|
+
nt.prototype.copy.call(N, m), this.parser.assignFinalMaterial(N), f.push(N);
|
|
987
|
+
}
|
|
988
|
+
return l.isGroup ? (l.clear(), l.add(...f), l) : f[0];
|
|
989
|
+
}));
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const lt = "glTF", ce = 12, je = { JSON: 1313821514, BIN: 5130562 };
|
|
993
|
+
class bn {
|
|
994
|
+
constructor(e) {
|
|
995
|
+
this.name = E.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
996
|
+
const t = new DataView(e, 0, ce), r = new TextDecoder();
|
|
997
|
+
if (this.header = {
|
|
998
|
+
magic: r.decode(new Uint8Array(e.slice(0, 4))),
|
|
999
|
+
version: t.getUint32(4, !0),
|
|
1000
|
+
length: t.getUint32(8, !0)
|
|
1001
|
+
}, this.header.magic !== lt)
|
|
1002
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
1003
|
+
if (this.header.version < 2)
|
|
1004
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
1005
|
+
const n = this.header.length - ce, i = new DataView(e, ce);
|
|
1006
|
+
let s = 0;
|
|
1007
|
+
for (; s < n; ) {
|
|
1008
|
+
const a = i.getUint32(s, !0);
|
|
1009
|
+
s += 4;
|
|
1010
|
+
const o = i.getUint32(s, !0);
|
|
1011
|
+
if (s += 4, o === je.JSON) {
|
|
1012
|
+
const c = new Uint8Array(e, ce + s, a);
|
|
1013
|
+
this.content = r.decode(c);
|
|
1014
|
+
} else if (o === je.BIN) {
|
|
1015
|
+
const c = ce + s;
|
|
1016
|
+
this.body = e.slice(c, c + a);
|
|
1017
|
+
}
|
|
1018
|
+
s += a;
|
|
1019
|
+
}
|
|
1020
|
+
if (this.content === null)
|
|
1021
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
class Sn {
|
|
1025
|
+
constructor(e, t) {
|
|
1026
|
+
if (!t)
|
|
1027
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
1028
|
+
this.name = E.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
|
|
1029
|
+
}
|
|
1030
|
+
decodePrimitive(e, t) {
|
|
1031
|
+
const r = this.json, n = this.dracoLoader, i = e.extensions[this.name].bufferView, s = e.extensions[this.name].attributes, a = {}, o = {}, c = {};
|
|
1032
|
+
for (const l in s) {
|
|
1033
|
+
const u = Oe[l] || l.toLowerCase();
|
|
1034
|
+
a[u] = s[l];
|
|
1035
|
+
}
|
|
1036
|
+
for (const l in e.attributes) {
|
|
1037
|
+
const u = Oe[l] || l.toLowerCase();
|
|
1038
|
+
if (s[l] !== void 0) {
|
|
1039
|
+
const d = r.accessors[e.attributes[l]], f = oe[d.componentType];
|
|
1040
|
+
c[u] = f.name, o[u] = d.normalized === !0;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return t.getDependency("bufferView", i).then(function(l) {
|
|
1044
|
+
return new Promise(function(u, d) {
|
|
1045
|
+
n.decodeDracoFile(l, function(f) {
|
|
1046
|
+
for (const m in f.attributes) {
|
|
1047
|
+
const T = f.attributes[m], p = o[m];
|
|
1048
|
+
p !== void 0 && (T.normalized = p);
|
|
1049
|
+
}
|
|
1050
|
+
u(f);
|
|
1051
|
+
}, a, c, K, d);
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
class Ln {
|
|
1057
|
+
constructor() {
|
|
1058
|
+
this.name = E.KHR_TEXTURE_TRANSFORM;
|
|
1059
|
+
}
|
|
1060
|
+
extendTexture(e, t) {
|
|
1061
|
+
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;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
class Mn {
|
|
1065
|
+
constructor() {
|
|
1066
|
+
this.name = E.KHR_MESH_QUANTIZATION;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
class ut extends jt {
|
|
1070
|
+
constructor(e, t, r, n) {
|
|
1071
|
+
super(e, t, r, n);
|
|
1072
|
+
}
|
|
1073
|
+
copySampleValue_(e) {
|
|
1074
|
+
const t = this.resultBuffer, r = this.sampleValues, n = this.valueSize, i = e * n * 3 + n;
|
|
1075
|
+
for (let s = 0; s !== n; s++)
|
|
1076
|
+
t[s] = r[i + s];
|
|
1077
|
+
return t;
|
|
1078
|
+
}
|
|
1079
|
+
interpolate_(e, t, r, n) {
|
|
1080
|
+
const i = this.resultBuffer, s = this.sampleValues, a = this.valueSize, o = a * 2, c = a * 3, l = n - t, u = (r - t) / l, d = u * u, f = d * u, m = e * c, T = m - c, p = -2 * f + 3 * d, A = f - d, x = 1 - p, N = A - d + u;
|
|
1081
|
+
for (let _ = 0; _ !== a; _++) {
|
|
1082
|
+
const B = s[T + _ + a], U = s[T + _ + o] * l, M = s[m + _ + a], g = s[m + _] * l;
|
|
1083
|
+
i[_] = x * B + N * U + p * M + A * g;
|
|
1084
|
+
}
|
|
1085
|
+
return i;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
const In = new tt();
|
|
1089
|
+
class Nn extends ut {
|
|
1090
|
+
interpolate_(e, t, r, n) {
|
|
1091
|
+
const i = super.interpolate_(e, t, r, n);
|
|
1092
|
+
return In.fromArray(i).normalize().toArray(i), i;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
const j = {
|
|
1096
|
+
POINTS: 0,
|
|
1097
|
+
LINES: 1,
|
|
1098
|
+
LINE_LOOP: 2,
|
|
1099
|
+
LINE_STRIP: 3,
|
|
1100
|
+
TRIANGLES: 4,
|
|
1101
|
+
TRIANGLE_STRIP: 5,
|
|
1102
|
+
TRIANGLE_FAN: 6
|
|
1103
|
+
}, oe = {
|
|
1104
|
+
5120: Int8Array,
|
|
1105
|
+
5121: Uint8Array,
|
|
1106
|
+
5122: Int16Array,
|
|
1107
|
+
5123: Uint16Array,
|
|
1108
|
+
5125: Uint32Array,
|
|
1109
|
+
5126: Float32Array
|
|
1110
|
+
}, ze = {
|
|
1111
|
+
9728: rt,
|
|
1112
|
+
9729: pe,
|
|
1113
|
+
9984: Et,
|
|
1114
|
+
9985: _t,
|
|
1115
|
+
9986: xt,
|
|
1116
|
+
9987: st
|
|
1117
|
+
}, Ke = {
|
|
1118
|
+
33071: bt,
|
|
1119
|
+
33648: wt,
|
|
1120
|
+
10497: Ce
|
|
1121
|
+
}, be = {
|
|
1122
|
+
SCALAR: 1,
|
|
1123
|
+
VEC2: 2,
|
|
1124
|
+
VEC3: 3,
|
|
1125
|
+
VEC4: 4,
|
|
1126
|
+
MAT2: 4,
|
|
1127
|
+
MAT3: 9,
|
|
1128
|
+
MAT4: 16
|
|
1129
|
+
}, Oe = {
|
|
1130
|
+
POSITION: "position",
|
|
1131
|
+
NORMAL: "normal",
|
|
1132
|
+
TANGENT: "tangent",
|
|
1133
|
+
TEXCOORD_0: "uv",
|
|
1134
|
+
TEXCOORD_1: "uv1",
|
|
1135
|
+
TEXCOORD_2: "uv2",
|
|
1136
|
+
TEXCOORD_3: "uv3",
|
|
1137
|
+
COLOR_0: "color",
|
|
1138
|
+
WEIGHTS_0: "skinWeight",
|
|
1139
|
+
JOINTS_0: "skinIndex"
|
|
1140
|
+
}, ee = {
|
|
1141
|
+
scale: "scale",
|
|
1142
|
+
translation: "position",
|
|
1143
|
+
rotation: "quaternion",
|
|
1144
|
+
weights: "morphTargetInfluences"
|
|
1145
|
+
}, Cn = {
|
|
1146
|
+
CUBICSPLINE: void 0,
|
|
1147
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
1148
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
1149
|
+
LINEAR: at,
|
|
1150
|
+
STEP: Gt
|
|
1151
|
+
}, Se = {
|
|
1152
|
+
OPAQUE: "OPAQUE",
|
|
1153
|
+
MASK: "MASK",
|
|
1154
|
+
BLEND: "BLEND"
|
|
1155
|
+
};
|
|
1156
|
+
function On(h) {
|
|
1157
|
+
return h.DefaultMaterial === void 0 && (h.DefaultMaterial = new it({
|
|
1158
|
+
color: 16777215,
|
|
1159
|
+
emissive: 0,
|
|
1160
|
+
metalness: 1,
|
|
1161
|
+
roughness: 1,
|
|
1162
|
+
transparent: !1,
|
|
1163
|
+
depthTest: !0,
|
|
1164
|
+
side: Ut
|
|
1165
|
+
})), h.DefaultMaterial;
|
|
1166
|
+
}
|
|
1167
|
+
function ne(h, e, t) {
|
|
1168
|
+
for (const r in t.extensions)
|
|
1169
|
+
h[r] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[r] = t.extensions[r]);
|
|
1170
|
+
}
|
|
1171
|
+
function Z(h, e) {
|
|
1172
|
+
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(h.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
|
|
1173
|
+
}
|
|
1174
|
+
function Pn(h, e, t) {
|
|
1175
|
+
let r = !1, n = !1, i = !1;
|
|
1176
|
+
for (let c = 0, l = e.length; c < l; c++) {
|
|
1177
|
+
const u = e[c];
|
|
1178
|
+
if (u.POSITION !== void 0 && (r = !0), u.NORMAL !== void 0 && (n = !0), u.COLOR_0 !== void 0 && (i = !0), r && n && i) break;
|
|
1179
|
+
}
|
|
1180
|
+
if (!r && !n && !i) return Promise.resolve(h);
|
|
1181
|
+
const s = [], a = [], o = [];
|
|
1182
|
+
for (let c = 0, l = e.length; c < l; c++) {
|
|
1183
|
+
const u = e[c];
|
|
1184
|
+
if (r) {
|
|
1185
|
+
const d = u.POSITION !== void 0 ? t.getDependency("accessor", u.POSITION) : h.attributes.position;
|
|
1186
|
+
s.push(d);
|
|
1187
|
+
}
|
|
1188
|
+
if (n) {
|
|
1189
|
+
const d = u.NORMAL !== void 0 ? t.getDependency("accessor", u.NORMAL) : h.attributes.normal;
|
|
1190
|
+
a.push(d);
|
|
1191
|
+
}
|
|
1192
|
+
if (i) {
|
|
1193
|
+
const d = u.COLOR_0 !== void 0 ? t.getDependency("accessor", u.COLOR_0) : h.attributes.color;
|
|
1194
|
+
o.push(d);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
return Promise.all([
|
|
1198
|
+
Promise.all(s),
|
|
1199
|
+
Promise.all(a),
|
|
1200
|
+
Promise.all(o)
|
|
1201
|
+
]).then(function(c) {
|
|
1202
|
+
const l = c[0], u = c[1], d = c[2];
|
|
1203
|
+
return r && (h.morphAttributes.position = l), n && (h.morphAttributes.normal = u), i && (h.morphAttributes.color = d), h.morphTargetsRelative = !0, h;
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
function kn(h, e) {
|
|
1207
|
+
if (h.updateMorphTargets(), e.weights !== void 0)
|
|
1208
|
+
for (let t = 0, r = e.weights.length; t < r; t++)
|
|
1209
|
+
h.morphTargetInfluences[t] = e.weights[t];
|
|
1210
|
+
if (e.extras && Array.isArray(e.extras.targetNames)) {
|
|
1211
|
+
const t = e.extras.targetNames;
|
|
1212
|
+
if (h.morphTargetInfluences.length === t.length) {
|
|
1213
|
+
h.morphTargetDictionary = {};
|
|
1214
|
+
for (let r = 0, n = t.length; r < n; r++)
|
|
1215
|
+
h.morphTargetDictionary[t[r]] = r;
|
|
1216
|
+
} else
|
|
1217
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
function Dn(h) {
|
|
1221
|
+
let e;
|
|
1222
|
+
const t = h.extensions && h.extensions[E.KHR_DRACO_MESH_COMPRESSION];
|
|
1223
|
+
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + Le(t.attributes) : e = h.indices + ":" + Le(h.attributes) + ":" + h.mode, h.targets !== void 0)
|
|
1224
|
+
for (let r = 0, n = h.targets.length; r < n; r++)
|
|
1225
|
+
e += ":" + Le(h.targets[r]);
|
|
1226
|
+
return e;
|
|
1227
|
+
}
|
|
1228
|
+
function Le(h) {
|
|
1229
|
+
let e = "";
|
|
1230
|
+
const t = Object.keys(h).sort();
|
|
1231
|
+
for (let r = 0, n = t.length; r < n; r++)
|
|
1232
|
+
e += t[r] + ":" + h[t[r]] + ";";
|
|
1233
|
+
return e;
|
|
1234
|
+
}
|
|
1235
|
+
function Pe(h) {
|
|
1236
|
+
switch (h) {
|
|
1237
|
+
case Int8Array:
|
|
1238
|
+
return 1 / 127;
|
|
1239
|
+
case Uint8Array:
|
|
1240
|
+
return 1 / 255;
|
|
1241
|
+
case Int16Array:
|
|
1242
|
+
return 1 / 32767;
|
|
1243
|
+
case Uint16Array:
|
|
1244
|
+
return 1 / 65535;
|
|
1245
|
+
default:
|
|
1246
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function Fn(h) {
|
|
1250
|
+
return h.search(/\.jpe?g($|\?)/i) > 0 || h.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : h.search(/\.webp($|\?)/i) > 0 || h.search(/^data\:image\/webp/) === 0 ? "image/webp" : h.search(/\.ktx2($|\?)/i) > 0 || h.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
1251
|
+
}
|
|
1252
|
+
const Hn = new ae();
|
|
1253
|
+
class vn {
|
|
1254
|
+
constructor(e = {}, t = {}) {
|
|
1255
|
+
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new on(), 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 = {};
|
|
1256
|
+
let r = !1, n = -1, i = !1, s = -1;
|
|
1257
|
+
if (typeof navigator < "u") {
|
|
1258
|
+
const a = navigator.userAgent;
|
|
1259
|
+
r = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
1260
|
+
const o = a.match(/Version\/(\d+)/);
|
|
1261
|
+
n = r && o ? parseInt(o[1], 10) : -1, i = a.indexOf("Firefox") > -1, s = i ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
1262
|
+
}
|
|
1263
|
+
typeof createImageBitmap > "u" || r && n < 17 || i && s < 98 ? this.textureLoader = new At(this.options.manager) : this.textureLoader = new Tt(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new ye(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
1264
|
+
}
|
|
1265
|
+
setExtensions(e) {
|
|
1266
|
+
this.extensions = e;
|
|
1267
|
+
}
|
|
1268
|
+
setPlugins(e) {
|
|
1269
|
+
this.plugins = e;
|
|
1270
|
+
}
|
|
1271
|
+
parse(e, t) {
|
|
1272
|
+
const r = this, n = this.json, i = this.extensions;
|
|
1273
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
|
|
1274
|
+
return s._markDefs && s._markDefs();
|
|
1275
|
+
}), Promise.all(this._invokeAll(function(s) {
|
|
1276
|
+
return s.beforeRoot && s.beforeRoot();
|
|
1277
|
+
})).then(function() {
|
|
1278
|
+
return Promise.all([
|
|
1279
|
+
r.getDependencies("scene"),
|
|
1280
|
+
r.getDependencies("animation"),
|
|
1281
|
+
r.getDependencies("camera")
|
|
1282
|
+
]);
|
|
1283
|
+
}).then(function(s) {
|
|
1284
|
+
const a = {
|
|
1285
|
+
scene: s[0][n.scene || 0],
|
|
1286
|
+
scenes: s[0],
|
|
1287
|
+
animations: s[1],
|
|
1288
|
+
cameras: s[2],
|
|
1289
|
+
asset: n.asset,
|
|
1290
|
+
parser: r,
|
|
1291
|
+
userData: {}
|
|
1292
|
+
};
|
|
1293
|
+
return ne(i, a, n), Z(a, n), Promise.all(r._invokeAll(function(o) {
|
|
1294
|
+
return o.afterRoot && o.afterRoot(a);
|
|
1295
|
+
})).then(function() {
|
|
1296
|
+
for (const o of a.scenes)
|
|
1297
|
+
o.updateMatrixWorld();
|
|
1298
|
+
e(a);
|
|
1299
|
+
});
|
|
1300
|
+
}).catch(t);
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
1304
|
+
*
|
|
1305
|
+
* @private
|
|
1306
|
+
*/
|
|
1307
|
+
_markDefs() {
|
|
1308
|
+
const e = this.json.nodes || [], t = this.json.skins || [], r = this.json.meshes || [];
|
|
1309
|
+
for (let n = 0, i = t.length; n < i; n++) {
|
|
1310
|
+
const s = t[n].joints;
|
|
1311
|
+
for (let a = 0, o = s.length; a < o; a++)
|
|
1312
|
+
e[s[a]].isBone = !0;
|
|
1313
|
+
}
|
|
1314
|
+
for (let n = 0, i = e.length; n < i; n++) {
|
|
1315
|
+
const s = e[n];
|
|
1316
|
+
s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (r[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
1321
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
1322
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
1323
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
1324
|
+
* Textures) can be reused directly and are not marked here.
|
|
1325
|
+
*
|
|
1326
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
1327
|
+
*
|
|
1328
|
+
* @private
|
|
1329
|
+
* @param {Object} cache
|
|
1330
|
+
* @param {Object3D} index
|
|
1331
|
+
*/
|
|
1332
|
+
_addNodeRef(e, t) {
|
|
1333
|
+
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
1337
|
+
*
|
|
1338
|
+
* @private
|
|
1339
|
+
* @param {Object} cache
|
|
1340
|
+
* @param {number} index
|
|
1341
|
+
* @param {Object} object
|
|
1342
|
+
* @return {Object}
|
|
1343
|
+
*/
|
|
1344
|
+
_getNodeRef(e, t, r) {
|
|
1345
|
+
if (e.refs[t] <= 1) return r;
|
|
1346
|
+
const n = r.clone(), i = (s, a) => {
|
|
1347
|
+
const o = this.associations.get(s);
|
|
1348
|
+
o != null && this.associations.set(a, o);
|
|
1349
|
+
for (const [c, l] of s.children.entries())
|
|
1350
|
+
i(l, a.children[c]);
|
|
1351
|
+
};
|
|
1352
|
+
return i(r, n), n.name += "_instance_" + e.uses[t]++, n;
|
|
1353
|
+
}
|
|
1354
|
+
_invokeOne(e) {
|
|
1355
|
+
const t = Object.values(this.plugins);
|
|
1356
|
+
t.push(this);
|
|
1357
|
+
for (let r = 0; r < t.length; r++) {
|
|
1358
|
+
const n = e(t[r]);
|
|
1359
|
+
if (n) return n;
|
|
1360
|
+
}
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
_invokeAll(e) {
|
|
1364
|
+
const t = Object.values(this.plugins);
|
|
1365
|
+
t.unshift(this);
|
|
1366
|
+
const r = [];
|
|
1367
|
+
for (let n = 0; n < t.length; n++) {
|
|
1368
|
+
const i = e(t[n]);
|
|
1369
|
+
i && r.push(i);
|
|
1370
|
+
}
|
|
1371
|
+
return r;
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1375
|
+
*
|
|
1376
|
+
* @private
|
|
1377
|
+
* @param {string} type
|
|
1378
|
+
* @param {number} index
|
|
1379
|
+
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1380
|
+
*/
|
|
1381
|
+
getDependency(e, t) {
|
|
1382
|
+
const r = e + ":" + t;
|
|
1383
|
+
let n = this.cache.get(r);
|
|
1384
|
+
if (!n) {
|
|
1385
|
+
switch (e) {
|
|
1386
|
+
case "scene":
|
|
1387
|
+
n = this.loadScene(t);
|
|
1388
|
+
break;
|
|
1389
|
+
case "node":
|
|
1390
|
+
n = this._invokeOne(function(i) {
|
|
1391
|
+
return i.loadNode && i.loadNode(t);
|
|
1392
|
+
});
|
|
1393
|
+
break;
|
|
1394
|
+
case "mesh":
|
|
1395
|
+
n = this._invokeOne(function(i) {
|
|
1396
|
+
return i.loadMesh && i.loadMesh(t);
|
|
1397
|
+
});
|
|
1398
|
+
break;
|
|
1399
|
+
case "accessor":
|
|
1400
|
+
n = this.loadAccessor(t);
|
|
1401
|
+
break;
|
|
1402
|
+
case "bufferView":
|
|
1403
|
+
n = this._invokeOne(function(i) {
|
|
1404
|
+
return i.loadBufferView && i.loadBufferView(t);
|
|
1405
|
+
});
|
|
1406
|
+
break;
|
|
1407
|
+
case "buffer":
|
|
1408
|
+
n = this.loadBuffer(t);
|
|
1409
|
+
break;
|
|
1410
|
+
case "material":
|
|
1411
|
+
n = this._invokeOne(function(i) {
|
|
1412
|
+
return i.loadMaterial && i.loadMaterial(t);
|
|
1413
|
+
});
|
|
1414
|
+
break;
|
|
1415
|
+
case "texture":
|
|
1416
|
+
n = this._invokeOne(function(i) {
|
|
1417
|
+
return i.loadTexture && i.loadTexture(t);
|
|
1418
|
+
});
|
|
1419
|
+
break;
|
|
1420
|
+
case "skin":
|
|
1421
|
+
n = this.loadSkin(t);
|
|
1422
|
+
break;
|
|
1423
|
+
case "animation":
|
|
1424
|
+
n = this._invokeOne(function(i) {
|
|
1425
|
+
return i.loadAnimation && i.loadAnimation(t);
|
|
1426
|
+
});
|
|
1427
|
+
break;
|
|
1428
|
+
case "camera":
|
|
1429
|
+
n = this.loadCamera(t);
|
|
1430
|
+
break;
|
|
1431
|
+
default:
|
|
1432
|
+
if (n = this._invokeOne(function(i) {
|
|
1433
|
+
return i != this && i.getDependency && i.getDependency(e, t);
|
|
1434
|
+
}), !n)
|
|
1435
|
+
throw new Error("Unknown type: " + e);
|
|
1436
|
+
break;
|
|
1437
|
+
}
|
|
1438
|
+
this.cache.add(r, n);
|
|
1439
|
+
}
|
|
1440
|
+
return n;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1444
|
+
*
|
|
1445
|
+
* @private
|
|
1446
|
+
* @param {string} type
|
|
1447
|
+
* @return {Promise<Array<Object>>}
|
|
1448
|
+
*/
|
|
1449
|
+
getDependencies(e) {
|
|
1450
|
+
let t = this.cache.get(e);
|
|
1451
|
+
if (!t) {
|
|
1452
|
+
const r = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
|
|
1453
|
+
t = Promise.all(n.map(function(i, s) {
|
|
1454
|
+
return r.getDependency(e, s);
|
|
1455
|
+
})), this.cache.add(e, t);
|
|
1456
|
+
}
|
|
1457
|
+
return t;
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1461
|
+
*
|
|
1462
|
+
* @private
|
|
1463
|
+
* @param {number} bufferIndex
|
|
1464
|
+
* @return {Promise<ArrayBuffer>}
|
|
1465
|
+
*/
|
|
1466
|
+
loadBuffer(e) {
|
|
1467
|
+
const t = this.json.buffers[e], r = this.fileLoader;
|
|
1468
|
+
if (t.type && t.type !== "arraybuffer")
|
|
1469
|
+
throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
|
|
1470
|
+
if (t.uri === void 0 && e === 0)
|
|
1471
|
+
return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);
|
|
1472
|
+
const n = this.options;
|
|
1473
|
+
return new Promise(function(i, s) {
|
|
1474
|
+
r.load(de.resolveURL(t.uri, n.path), i, void 0, function() {
|
|
1475
|
+
s(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1481
|
+
*
|
|
1482
|
+
* @private
|
|
1483
|
+
* @param {number} bufferViewIndex
|
|
1484
|
+
* @return {Promise<ArrayBuffer>}
|
|
1485
|
+
*/
|
|
1486
|
+
loadBufferView(e) {
|
|
1487
|
+
const t = this.json.bufferViews[e];
|
|
1488
|
+
return this.getDependency("buffer", t.buffer).then(function(r) {
|
|
1489
|
+
const n = t.byteLength || 0, i = t.byteOffset || 0;
|
|
1490
|
+
return r.slice(i, i + n);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1495
|
+
*
|
|
1496
|
+
* @private
|
|
1497
|
+
* @param {number} accessorIndex
|
|
1498
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1499
|
+
*/
|
|
1500
|
+
loadAccessor(e) {
|
|
1501
|
+
const t = this, r = this.json, n = this.json.accessors[e];
|
|
1502
|
+
if (n.bufferView === void 0 && n.sparse === void 0) {
|
|
1503
|
+
const s = be[n.type], a = oe[n.componentType], o = n.normalized === !0, c = new a(n.count * s);
|
|
1504
|
+
return Promise.resolve(new ue(c, s, o));
|
|
1505
|
+
}
|
|
1506
|
+
const i = [];
|
|
1507
|
+
return n.bufferView !== void 0 ? i.push(this.getDependency("bufferView", n.bufferView)) : i.push(null), n.sparse !== void 0 && (i.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(i).then(function(s) {
|
|
1508
|
+
const a = s[0], o = be[n.type], c = oe[n.componentType], l = c.BYTES_PER_ELEMENT, u = l * o, d = n.byteOffset || 0, f = n.bufferView !== void 0 ? r.bufferViews[n.bufferView].byteStride : void 0, m = n.normalized === !0;
|
|
1509
|
+
let T, p;
|
|
1510
|
+
if (f && f !== u) {
|
|
1511
|
+
const A = Math.floor(d / f), x = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + A + ":" + n.count;
|
|
1512
|
+
let N = t.cache.get(x);
|
|
1513
|
+
N || (T = new c(a, A * f, n.count * f / l), N = new yt(T, f / l), t.cache.add(x, N)), p = new Rt(N, o, d % f / l, m);
|
|
1514
|
+
} else
|
|
1515
|
+
a === null ? T = new c(n.count * o) : T = new c(a, d, n.count * o), p = new ue(T, o, m);
|
|
1516
|
+
if (n.sparse !== void 0) {
|
|
1517
|
+
const A = be.SCALAR, x = oe[n.sparse.indices.componentType], N = n.sparse.indices.byteOffset || 0, _ = n.sparse.values.byteOffset || 0, B = new x(s[1], N, n.sparse.count * A), U = new c(s[2], _, n.sparse.count * o);
|
|
1518
|
+
a !== null && (p = new ue(p.array.slice(), p.itemSize, p.normalized)), p.normalized = !1;
|
|
1519
|
+
for (let M = 0, g = B.length; M < g; M++) {
|
|
1520
|
+
const y = B[M];
|
|
1521
|
+
if (p.setX(y, U[M * o]), o >= 2 && p.setY(y, U[M * o + 1]), o >= 3 && p.setZ(y, U[M * o + 2]), o >= 4 && p.setW(y, U[M * o + 3]), o >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1522
|
+
}
|
|
1523
|
+
p.normalized = m;
|
|
1524
|
+
}
|
|
1525
|
+
return p;
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1530
|
+
*
|
|
1531
|
+
* @private
|
|
1532
|
+
* @param {number} textureIndex
|
|
1533
|
+
* @return {Promise<THREE.Texture|null>}
|
|
1534
|
+
*/
|
|
1535
|
+
loadTexture(e) {
|
|
1536
|
+
const t = this.json, r = this.options, i = t.textures[e].source, s = t.images[i];
|
|
1537
|
+
let a = this.textureLoader;
|
|
1538
|
+
if (s.uri) {
|
|
1539
|
+
const o = r.manager.getHandler(s.uri);
|
|
1540
|
+
o !== null && (a = o);
|
|
1541
|
+
}
|
|
1542
|
+
return this.loadTextureImage(e, i, a);
|
|
1543
|
+
}
|
|
1544
|
+
loadTextureImage(e, t, r) {
|
|
1545
|
+
const n = this, i = this.json, s = i.textures[e], a = i.images[t], o = (a.uri || a.bufferView) + ":" + s.sampler;
|
|
1546
|
+
if (this.textureCache[o])
|
|
1547
|
+
return this.textureCache[o];
|
|
1548
|
+
const c = this.loadImageSource(t, r).then(function(l) {
|
|
1549
|
+
l.flipY = !1, l.name = s.name || a.name || "", l.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (l.name = a.uri);
|
|
1550
|
+
const d = (i.samplers || {})[s.sampler] || {};
|
|
1551
|
+
return l.magFilter = ze[d.magFilter] || pe, l.minFilter = ze[d.minFilter] || st, l.wrapS = Ke[d.wrapS] || Ce, l.wrapT = Ke[d.wrapT] || Ce, l.generateMipmaps = !l.isCompressedTexture && l.minFilter !== rt && l.minFilter !== pe, n.associations.set(l, { textures: e }), l;
|
|
1552
|
+
}).catch(function() {
|
|
1553
|
+
return null;
|
|
1554
|
+
});
|
|
1555
|
+
return this.textureCache[o] = c, c;
|
|
1556
|
+
}
|
|
1557
|
+
loadImageSource(e, t) {
|
|
1558
|
+
const r = this, n = this.json, i = this.options;
|
|
1559
|
+
if (this.sourceCache[e] !== void 0)
|
|
1560
|
+
return this.sourceCache[e].then((u) => u.clone());
|
|
1561
|
+
const s = n.images[e], a = self.URL || self.webkitURL;
|
|
1562
|
+
let o = s.uri || "", c = !1;
|
|
1563
|
+
if (s.bufferView !== void 0)
|
|
1564
|
+
o = r.getDependency("bufferView", s.bufferView).then(function(u) {
|
|
1565
|
+
c = !0;
|
|
1566
|
+
const d = new Blob([u], { type: s.mimeType });
|
|
1567
|
+
return o = a.createObjectURL(d), o;
|
|
1568
|
+
});
|
|
1569
|
+
else if (s.uri === void 0)
|
|
1570
|
+
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
|
|
1571
|
+
const l = Promise.resolve(o).then(function(u) {
|
|
1572
|
+
return new Promise(function(d, f) {
|
|
1573
|
+
let m = d;
|
|
1574
|
+
t.isImageBitmapLoader === !0 && (m = function(T) {
|
|
1575
|
+
const p = new He(T);
|
|
1576
|
+
p.needsUpdate = !0, d(p);
|
|
1577
|
+
}), t.load(de.resolveURL(u, i.path), m, void 0, f);
|
|
1578
|
+
});
|
|
1579
|
+
}).then(function(u) {
|
|
1580
|
+
return c === !0 && a.revokeObjectURL(o), Z(u, s), u.userData.mimeType = s.mimeType || Fn(s.uri), u;
|
|
1581
|
+
}).catch(function(u) {
|
|
1582
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", o), u;
|
|
1583
|
+
});
|
|
1584
|
+
return this.sourceCache[e] = l, l;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1588
|
+
*
|
|
1589
|
+
* @private
|
|
1590
|
+
* @param {Object} materialParams
|
|
1591
|
+
* @param {string} mapName
|
|
1592
|
+
* @param {Object} mapDef
|
|
1593
|
+
* @param {string} [colorSpace]
|
|
1594
|
+
* @return {Promise<Texture>}
|
|
1595
|
+
*/
|
|
1596
|
+
assignTexture(e, t, r, n) {
|
|
1597
|
+
const i = this;
|
|
1598
|
+
return this.getDependency("texture", r.index).then(function(s) {
|
|
1599
|
+
if (!s) return null;
|
|
1600
|
+
if (r.texCoord !== void 0 && r.texCoord > 0 && (s = s.clone(), s.channel = r.texCoord), i.extensions[E.KHR_TEXTURE_TRANSFORM]) {
|
|
1601
|
+
const a = r.extensions !== void 0 ? r.extensions[E.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1602
|
+
if (a) {
|
|
1603
|
+
const o = i.associations.get(s);
|
|
1604
|
+
s = i.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), i.associations.set(s, o);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
return n !== void 0 && (s.colorSpace = n), e[t] = s, s;
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1612
|
+
* already has a material (generated from the glTF material options alone)
|
|
1613
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1614
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1615
|
+
* be created if necessary, and reused from a cache.
|
|
1616
|
+
*
|
|
1617
|
+
* @private
|
|
1618
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1619
|
+
*/
|
|
1620
|
+
assignFinalMaterial(e) {
|
|
1621
|
+
const t = e.geometry;
|
|
1622
|
+
let r = e.material;
|
|
1623
|
+
const n = t.attributes.tangent === void 0, i = t.attributes.color !== void 0, s = t.attributes.normal === void 0;
|
|
1624
|
+
if (e.isPoints) {
|
|
1625
|
+
const a = "PointsMaterial:" + r.uuid;
|
|
1626
|
+
let o = this.cache.get(a);
|
|
1627
|
+
o || (o = new St(), _e.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, o.sizeAttenuation = !1, this.cache.add(a, o)), r = o;
|
|
1628
|
+
} else if (e.isLine) {
|
|
1629
|
+
const a = "LineBasicMaterial:" + r.uuid;
|
|
1630
|
+
let o = this.cache.get(a);
|
|
1631
|
+
o || (o = new Lt(), _e.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, this.cache.add(a, o)), r = o;
|
|
1632
|
+
}
|
|
1633
|
+
if (n || i || s) {
|
|
1634
|
+
let a = "ClonedMaterial:" + r.uuid + ":";
|
|
1635
|
+
n && (a += "derivative-tangents:"), i && (a += "vertex-colors:"), s && (a += "flat-shading:");
|
|
1636
|
+
let o = this.cache.get(a);
|
|
1637
|
+
o || (o = r.clone(), i && (o.vertexColors = !0), s && (o.flatShading = !0), n && (o.normalScale && (o.normalScale.y *= -1), o.clearcoatNormalScale && (o.clearcoatNormalScale.y *= -1)), this.cache.add(a, o), this.associations.set(o, this.associations.get(r))), r = o;
|
|
1638
|
+
}
|
|
1639
|
+
e.material = r;
|
|
1640
|
+
}
|
|
1641
|
+
getMaterialType() {
|
|
1642
|
+
return it;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1646
|
+
*
|
|
1647
|
+
* @private
|
|
1648
|
+
* @param {number} materialIndex
|
|
1649
|
+
* @return {Promise<Material>}
|
|
1650
|
+
*/
|
|
1651
|
+
loadMaterial(e) {
|
|
1652
|
+
const t = this, r = this.json, n = this.extensions, i = r.materials[e];
|
|
1653
|
+
let s;
|
|
1654
|
+
const a = {}, o = i.extensions || {}, c = [];
|
|
1655
|
+
if (o[E.KHR_MATERIALS_UNLIT]) {
|
|
1656
|
+
const u = n[E.KHR_MATERIALS_UNLIT];
|
|
1657
|
+
s = u.getMaterialType(), c.push(u.extendParams(a, i, t));
|
|
1658
|
+
} else {
|
|
1659
|
+
const u = i.pbrMetallicRoughness || {};
|
|
1660
|
+
if (a.color = new V(1, 1, 1), a.opacity = 1, Array.isArray(u.baseColorFactor)) {
|
|
1661
|
+
const d = u.baseColorFactor;
|
|
1662
|
+
a.color.setRGB(d[0], d[1], d[2], K), a.opacity = d[3];
|
|
1663
|
+
}
|
|
1664
|
+
u.baseColorTexture !== void 0 && c.push(t.assignTexture(a, "map", u.baseColorTexture, te)), a.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, a.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(a, "metalnessMap", u.metallicRoughnessTexture)), c.push(t.assignTexture(a, "roughnessMap", u.metallicRoughnessTexture))), s = this._invokeOne(function(d) {
|
|
1665
|
+
return d.getMaterialType && d.getMaterialType(e);
|
|
1666
|
+
}), c.push(Promise.all(this._invokeAll(function(d) {
|
|
1667
|
+
return d.extendMaterialParams && d.extendMaterialParams(e, a);
|
|
1668
|
+
})));
|
|
1669
|
+
}
|
|
1670
|
+
i.doubleSided === !0 && (a.side = Mt);
|
|
1671
|
+
const l = i.alphaMode || Se.OPAQUE;
|
|
1672
|
+
if (l === Se.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, l === Se.MASK && (a.alphaTest = i.alphaCutoff !== void 0 ? i.alphaCutoff : 0.5)), i.normalTexture !== void 0 && s !== le && (c.push(t.assignTexture(a, "normalMap", i.normalTexture)), a.normalScale = new De(1, 1), i.normalTexture.scale !== void 0)) {
|
|
1673
|
+
const u = i.normalTexture.scale;
|
|
1674
|
+
a.normalScale.set(u, u);
|
|
1675
|
+
}
|
|
1676
|
+
if (i.occlusionTexture !== void 0 && s !== le && (c.push(t.assignTexture(a, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && s !== le) {
|
|
1677
|
+
const u = i.emissiveFactor;
|
|
1678
|
+
a.emissive = new V().setRGB(u[0], u[1], u[2], K);
|
|
1679
|
+
}
|
|
1680
|
+
return i.emissiveTexture !== void 0 && s !== le && c.push(t.assignTexture(a, "emissiveMap", i.emissiveTexture, te)), Promise.all(c).then(function() {
|
|
1681
|
+
const u = new s(a);
|
|
1682
|
+
return i.name && (u.name = i.name), Z(u, i), t.associations.set(u, { materials: e }), i.extensions && ne(n, u, i), u;
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
1687
|
+
*
|
|
1688
|
+
* @private
|
|
1689
|
+
* @param {string} originalName
|
|
1690
|
+
* @return {string}
|
|
1691
|
+
*/
|
|
1692
|
+
createUniqueName(e) {
|
|
1693
|
+
const t = It.sanitizeNodeName(e || "");
|
|
1694
|
+
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1698
|
+
*
|
|
1699
|
+
* Creates BufferGeometries from primitives.
|
|
1700
|
+
*
|
|
1701
|
+
* @private
|
|
1702
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1703
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1704
|
+
*/
|
|
1705
|
+
loadGeometries(e) {
|
|
1706
|
+
const t = this, r = this.extensions, n = this.primitiveCache;
|
|
1707
|
+
function i(a) {
|
|
1708
|
+
return r[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, t).then(function(o) {
|
|
1709
|
+
return Ve(o, a, t);
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
const s = [];
|
|
1713
|
+
for (let a = 0, o = e.length; a < o; a++) {
|
|
1714
|
+
const c = e[a], l = Dn(c), u = n[l];
|
|
1715
|
+
if (u)
|
|
1716
|
+
s.push(u.promise);
|
|
1717
|
+
else {
|
|
1718
|
+
let d;
|
|
1719
|
+
c.extensions && c.extensions[E.KHR_DRACO_MESH_COMPRESSION] ? d = i(c) : d = Ve(new $e(), c, t), n[l] = { primitive: c, promise: d }, s.push(d);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return Promise.all(s);
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1726
|
+
*
|
|
1727
|
+
* @private
|
|
1728
|
+
* @param {number} meshIndex
|
|
1729
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
1730
|
+
*/
|
|
1731
|
+
loadMesh(e) {
|
|
1732
|
+
const t = this, r = this.json, n = this.extensions, i = r.meshes[e], s = i.primitives, a = [];
|
|
1733
|
+
for (let o = 0, c = s.length; o < c; o++) {
|
|
1734
|
+
const l = s[o].material === void 0 ? On(this.cache) : this.getDependency("material", s[o].material);
|
|
1735
|
+
a.push(l);
|
|
1736
|
+
}
|
|
1737
|
+
return a.push(t.loadGeometries(s)), Promise.all(a).then(function(o) {
|
|
1738
|
+
const c = o.slice(0, o.length - 1), l = o[o.length - 1], u = [];
|
|
1739
|
+
for (let f = 0, m = l.length; f < m; f++) {
|
|
1740
|
+
const T = l[f], p = s[f];
|
|
1741
|
+
let A;
|
|
1742
|
+
const x = c[f];
|
|
1743
|
+
if (p.mode === j.TRIANGLES || p.mode === j.TRIANGLE_STRIP || p.mode === j.TRIANGLE_FAN || p.mode === void 0)
|
|
1744
|
+
A = i.isSkinnedMesh === !0 ? new Nt(T, x) : new Ct(T, x), A.isSkinnedMesh === !0 && A.normalizeSkinWeights(), p.mode === j.TRIANGLE_STRIP ? A.geometry = Ue(A.geometry, Je) : p.mode === j.TRIANGLE_FAN && (A.geometry = Ue(A.geometry, Ie));
|
|
1745
|
+
else if (p.mode === j.LINES)
|
|
1746
|
+
A = new Ot(T, x);
|
|
1747
|
+
else if (p.mode === j.LINE_STRIP)
|
|
1748
|
+
A = new Pt(T, x);
|
|
1749
|
+
else if (p.mode === j.LINE_LOOP)
|
|
1750
|
+
A = new kt(T, x);
|
|
1751
|
+
else if (p.mode === j.POINTS)
|
|
1752
|
+
A = new Dt(T, x);
|
|
1753
|
+
else
|
|
1754
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + p.mode);
|
|
1755
|
+
Object.keys(A.geometry.morphAttributes).length > 0 && kn(A, i), A.name = t.createUniqueName(i.name || "mesh_" + e), Z(A, i), p.extensions && ne(n, A, p), t.assignFinalMaterial(A), u.push(A);
|
|
1756
|
+
}
|
|
1757
|
+
for (let f = 0, m = u.length; f < m; f++)
|
|
1758
|
+
t.associations.set(u[f], {
|
|
1759
|
+
meshes: e,
|
|
1760
|
+
primitives: f
|
|
1761
|
+
});
|
|
1762
|
+
if (u.length === 1)
|
|
1763
|
+
return i.extensions && ne(n, u[0], i), u[0];
|
|
1764
|
+
const d = new Te();
|
|
1765
|
+
i.extensions && ne(n, d, i), t.associations.set(d, { meshes: e });
|
|
1766
|
+
for (let f = 0, m = u.length; f < m; f++)
|
|
1767
|
+
d.add(u[f]);
|
|
1768
|
+
return d;
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1773
|
+
*
|
|
1774
|
+
* @private
|
|
1775
|
+
* @param {number} cameraIndex
|
|
1776
|
+
* @return {Promise<THREE.Camera>}
|
|
1777
|
+
*/
|
|
1778
|
+
loadCamera(e) {
|
|
1779
|
+
let t;
|
|
1780
|
+
const r = this.json.cameras[e], n = r[r.type];
|
|
1781
|
+
if (!n) {
|
|
1782
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
return r.type === "perspective" ? t = new ot(he.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : r.type === "orthographic" && (t = new Ft(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), r.name && (t.name = this.createUniqueName(r.name)), Z(t, r), Promise.resolve(t);
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1789
|
+
*
|
|
1790
|
+
* @private
|
|
1791
|
+
* @param {number} skinIndex
|
|
1792
|
+
* @return {Promise<Skeleton>}
|
|
1793
|
+
*/
|
|
1794
|
+
loadSkin(e) {
|
|
1795
|
+
const t = this.json.skins[e], r = [];
|
|
1796
|
+
for (let n = 0, i = t.joints.length; n < i; n++)
|
|
1797
|
+
r.push(this._loadNodeShallow(t.joints[n]));
|
|
1798
|
+
return t.inverseBindMatrices !== void 0 ? r.push(this.getDependency("accessor", t.inverseBindMatrices)) : r.push(null), Promise.all(r).then(function(n) {
|
|
1799
|
+
const i = n.pop(), s = n, a = [], o = [];
|
|
1800
|
+
for (let c = 0, l = s.length; c < l; c++) {
|
|
1801
|
+
const u = s[c];
|
|
1802
|
+
if (u) {
|
|
1803
|
+
a.push(u);
|
|
1804
|
+
const d = new ae();
|
|
1805
|
+
i !== null && d.fromArray(i.array, c * 16), o.push(d);
|
|
1806
|
+
} else
|
|
1807
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
|
|
1808
|
+
}
|
|
1809
|
+
return new Ht(a, o);
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1814
|
+
*
|
|
1815
|
+
* @private
|
|
1816
|
+
* @param {number} animationIndex
|
|
1817
|
+
* @return {Promise<AnimationClip>}
|
|
1818
|
+
*/
|
|
1819
|
+
loadAnimation(e) {
|
|
1820
|
+
const t = this.json, r = this, n = t.animations[e], i = n.name ? n.name : "animation_" + e, s = [], a = [], o = [], c = [], l = [];
|
|
1821
|
+
for (let u = 0, d = n.channels.length; u < d; u++) {
|
|
1822
|
+
const f = n.channels[u], m = n.samplers[f.sampler], T = f.target, p = T.node, A = n.parameters !== void 0 ? n.parameters[m.input] : m.input, x = n.parameters !== void 0 ? n.parameters[m.output] : m.output;
|
|
1823
|
+
T.node !== void 0 && (s.push(this.getDependency("node", p)), a.push(this.getDependency("accessor", A)), o.push(this.getDependency("accessor", x)), c.push(m), l.push(T));
|
|
1824
|
+
}
|
|
1825
|
+
return Promise.all([
|
|
1826
|
+
Promise.all(s),
|
|
1827
|
+
Promise.all(a),
|
|
1828
|
+
Promise.all(o),
|
|
1829
|
+
Promise.all(c),
|
|
1830
|
+
Promise.all(l)
|
|
1831
|
+
]).then(function(u) {
|
|
1832
|
+
const d = u[0], f = u[1], m = u[2], T = u[3], p = u[4], A = [];
|
|
1833
|
+
for (let x = 0, N = d.length; x < N; x++) {
|
|
1834
|
+
const _ = d[x], B = f[x], U = m[x], M = T[x], g = p[x];
|
|
1835
|
+
if (_ === void 0) continue;
|
|
1836
|
+
_.updateMatrix && _.updateMatrix();
|
|
1837
|
+
const y = r._createAnimationTracks(_, B, U, M, g);
|
|
1838
|
+
if (y)
|
|
1839
|
+
for (let S = 0; S < y.length; S++)
|
|
1840
|
+
A.push(y[S]);
|
|
1841
|
+
}
|
|
1842
|
+
return new vt(i, void 0, A);
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
createNodeMesh(e) {
|
|
1846
|
+
const t = this.json, r = this, n = t.nodes[e];
|
|
1847
|
+
return n.mesh === void 0 ? null : r.getDependency("mesh", n.mesh).then(function(i) {
|
|
1848
|
+
const s = r._getNodeRef(r.meshCache, n.mesh, i);
|
|
1849
|
+
return n.weights !== void 0 && s.traverse(function(a) {
|
|
1850
|
+
if (a.isMesh)
|
|
1851
|
+
for (let o = 0, c = n.weights.length; o < c; o++)
|
|
1852
|
+
a.morphTargetInfluences[o] = n.weights[o];
|
|
1853
|
+
}), s;
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1858
|
+
*
|
|
1859
|
+
* @private
|
|
1860
|
+
* @param {number} nodeIndex
|
|
1861
|
+
* @return {Promise<Object3D>}
|
|
1862
|
+
*/
|
|
1863
|
+
loadNode(e) {
|
|
1864
|
+
const t = this.json, r = this, n = t.nodes[e], i = r._loadNodeShallow(e), s = [], a = n.children || [];
|
|
1865
|
+
for (let c = 0, l = a.length; c < l; c++)
|
|
1866
|
+
s.push(r.getDependency("node", a[c]));
|
|
1867
|
+
const o = n.skin === void 0 ? Promise.resolve(null) : r.getDependency("skin", n.skin);
|
|
1868
|
+
return Promise.all([
|
|
1869
|
+
i,
|
|
1870
|
+
Promise.all(s),
|
|
1871
|
+
o
|
|
1872
|
+
]).then(function(c) {
|
|
1873
|
+
const l = c[0], u = c[1], d = c[2];
|
|
1874
|
+
d !== null && l.traverse(function(f) {
|
|
1875
|
+
f.isSkinnedMesh && f.bind(d, Hn);
|
|
1876
|
+
});
|
|
1877
|
+
for (let f = 0, m = u.length; f < m; f++)
|
|
1878
|
+
l.add(u[f]);
|
|
1879
|
+
return l;
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
// ._loadNodeShallow() parses a single node.
|
|
1883
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1884
|
+
_loadNodeShallow(e) {
|
|
1885
|
+
const t = this.json, r = this.extensions, n = this;
|
|
1886
|
+
if (this.nodeCache[e] !== void 0)
|
|
1887
|
+
return this.nodeCache[e];
|
|
1888
|
+
const i = t.nodes[e], s = i.name ? n.createUniqueName(i.name) : "", a = [], o = n._invokeOne(function(c) {
|
|
1889
|
+
return c.createNodeMesh && c.createNodeMesh(e);
|
|
1890
|
+
});
|
|
1891
|
+
return o && a.push(o), i.camera !== void 0 && a.push(n.getDependency("camera", i.camera).then(function(c) {
|
|
1892
|
+
return n._getNodeRef(n.cameraCache, i.camera, c);
|
|
1893
|
+
})), n._invokeAll(function(c) {
|
|
1894
|
+
return c.createNodeAttachment && c.createNodeAttachment(e);
|
|
1895
|
+
}).forEach(function(c) {
|
|
1896
|
+
a.push(c);
|
|
1897
|
+
}), this.nodeCache[e] = Promise.all(a).then(function(c) {
|
|
1898
|
+
let l;
|
|
1899
|
+
if (i.isBone === !0 ? l = new Bt() : c.length > 1 ? l = new Te() : c.length === 1 ? l = c[0] : l = new nt(), l !== c[0])
|
|
1900
|
+
for (let u = 0, d = c.length; u < d; u++)
|
|
1901
|
+
l.add(c[u]);
|
|
1902
|
+
if (i.name && (l.userData.name = i.name, l.name = s), Z(l, i), i.extensions && ne(r, l, i), i.matrix !== void 0) {
|
|
1903
|
+
const u = new ae();
|
|
1904
|
+
u.fromArray(i.matrix), l.applyMatrix4(u);
|
|
1905
|
+
} else
|
|
1906
|
+
i.translation !== void 0 && l.position.fromArray(i.translation), i.rotation !== void 0 && l.quaternion.fromArray(i.rotation), i.scale !== void 0 && l.scale.fromArray(i.scale);
|
|
1907
|
+
return n.associations.has(l) || n.associations.set(l, {}), n.associations.get(l).nodes = e, l;
|
|
1908
|
+
}), this.nodeCache[e];
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1912
|
+
*
|
|
1913
|
+
* @private
|
|
1914
|
+
* @param {number} sceneIndex
|
|
1915
|
+
* @return {Promise<Group>}
|
|
1916
|
+
*/
|
|
1917
|
+
loadScene(e) {
|
|
1918
|
+
const t = this.extensions, r = this.json.scenes[e], n = this, i = new Te();
|
|
1919
|
+
r.name && (i.name = n.createUniqueName(r.name)), Z(i, r), r.extensions && ne(t, i, r);
|
|
1920
|
+
const s = r.nodes || [], a = [];
|
|
1921
|
+
for (let o = 0, c = s.length; o < c; o++)
|
|
1922
|
+
a.push(n.getDependency("node", s[o]));
|
|
1923
|
+
return Promise.all(a).then(function(o) {
|
|
1924
|
+
for (let l = 0, u = o.length; l < u; l++)
|
|
1925
|
+
i.add(o[l]);
|
|
1926
|
+
const c = (l) => {
|
|
1927
|
+
const u = /* @__PURE__ */ new Map();
|
|
1928
|
+
for (const [d, f] of n.associations)
|
|
1929
|
+
(d instanceof _e || d instanceof He) && u.set(d, f);
|
|
1930
|
+
return l.traverse((d) => {
|
|
1931
|
+
const f = n.associations.get(d);
|
|
1932
|
+
f != null && u.set(d, f);
|
|
1933
|
+
}), u;
|
|
1934
|
+
};
|
|
1935
|
+
return n.associations = c(i), i;
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
_createAnimationTracks(e, t, r, n, i) {
|
|
1939
|
+
const s = [], a = e.name ? e.name : e.uuid, o = [];
|
|
1940
|
+
ee[i.path] === ee.weights ? e.traverse(function(d) {
|
|
1941
|
+
d.morphTargetInfluences && o.push(d.name ? d.name : d.uuid);
|
|
1942
|
+
}) : o.push(a);
|
|
1943
|
+
let c;
|
|
1944
|
+
switch (ee[i.path]) {
|
|
1945
|
+
case ee.weights:
|
|
1946
|
+
c = Be;
|
|
1947
|
+
break;
|
|
1948
|
+
case ee.rotation:
|
|
1949
|
+
c = Ge;
|
|
1950
|
+
break;
|
|
1951
|
+
case ee.translation:
|
|
1952
|
+
case ee.scale:
|
|
1953
|
+
c = ve;
|
|
1954
|
+
break;
|
|
1955
|
+
default:
|
|
1956
|
+
switch (r.itemSize) {
|
|
1957
|
+
case 1:
|
|
1958
|
+
c = Be;
|
|
1959
|
+
break;
|
|
1960
|
+
case 2:
|
|
1961
|
+
case 3:
|
|
1962
|
+
default:
|
|
1963
|
+
c = ve;
|
|
1964
|
+
break;
|
|
1965
|
+
}
|
|
1966
|
+
break;
|
|
1967
|
+
}
|
|
1968
|
+
const l = n.interpolation !== void 0 ? Cn[n.interpolation] : at, u = this._getArrayFromAccessor(r);
|
|
1969
|
+
for (let d = 0, f = o.length; d < f; d++) {
|
|
1970
|
+
const m = new c(
|
|
1971
|
+
o[d] + "." + ee[i.path],
|
|
1972
|
+
t.array,
|
|
1973
|
+
u,
|
|
1974
|
+
l
|
|
1975
|
+
);
|
|
1976
|
+
n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(m), s.push(m);
|
|
1977
|
+
}
|
|
1978
|
+
return s;
|
|
1979
|
+
}
|
|
1980
|
+
_getArrayFromAccessor(e) {
|
|
1981
|
+
let t = e.array;
|
|
1982
|
+
if (e.normalized) {
|
|
1983
|
+
const r = Pe(t.constructor), n = new Float32Array(t.length);
|
|
1984
|
+
for (let i = 0, s = t.length; i < s; i++)
|
|
1985
|
+
n[i] = t[i] * r;
|
|
1986
|
+
t = n;
|
|
1987
|
+
}
|
|
1988
|
+
return t;
|
|
1989
|
+
}
|
|
1990
|
+
_createCubicSplineTrackInterpolant(e) {
|
|
1991
|
+
e.createInterpolant = function(r) {
|
|
1992
|
+
const n = this instanceof Ge ? Nn : ut;
|
|
1993
|
+
return new n(this.times, this.values, this.getValueSize() / 3, r);
|
|
1994
|
+
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
function Bn(h, e, t) {
|
|
1998
|
+
const r = e.attributes, n = new Re();
|
|
1999
|
+
if (r.POSITION !== void 0) {
|
|
2000
|
+
const a = t.json.accessors[r.POSITION], o = a.min, c = a.max;
|
|
2001
|
+
if (o !== void 0 && c !== void 0) {
|
|
2002
|
+
if (n.set(
|
|
2003
|
+
new O(o[0], o[1], o[2]),
|
|
2004
|
+
new O(c[0], c[1], c[2])
|
|
2005
|
+
), a.normalized) {
|
|
2006
|
+
const l = Pe(oe[a.componentType]);
|
|
2007
|
+
n.min.multiplyScalar(l), n.max.multiplyScalar(l);
|
|
2008
|
+
}
|
|
2009
|
+
} else {
|
|
2010
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
2011
|
+
return;
|
|
2012
|
+
}
|
|
2013
|
+
} else
|
|
2014
|
+
return;
|
|
2015
|
+
const i = e.targets;
|
|
2016
|
+
if (i !== void 0) {
|
|
2017
|
+
const a = new O(), o = new O();
|
|
2018
|
+
for (let c = 0, l = i.length; c < l; c++) {
|
|
2019
|
+
const u = i[c];
|
|
2020
|
+
if (u.POSITION !== void 0) {
|
|
2021
|
+
const d = t.json.accessors[u.POSITION], f = d.min, m = d.max;
|
|
2022
|
+
if (f !== void 0 && m !== void 0) {
|
|
2023
|
+
if (o.setX(Math.max(Math.abs(f[0]), Math.abs(m[0]))), o.setY(Math.max(Math.abs(f[1]), Math.abs(m[1]))), o.setZ(Math.max(Math.abs(f[2]), Math.abs(m[2]))), d.normalized) {
|
|
2024
|
+
const T = Pe(oe[d.componentType]);
|
|
2025
|
+
o.multiplyScalar(T);
|
|
2026
|
+
}
|
|
2027
|
+
a.max(o);
|
|
2028
|
+
} else
|
|
2029
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
n.expandByVector(a);
|
|
2033
|
+
}
|
|
2034
|
+
h.boundingBox = n;
|
|
2035
|
+
const s = new zt();
|
|
2036
|
+
n.getCenter(s.center), s.radius = n.min.distanceTo(n.max) / 2, h.boundingSphere = s;
|
|
2037
|
+
}
|
|
2038
|
+
function Ve(h, e, t) {
|
|
2039
|
+
const r = e.attributes, n = [];
|
|
2040
|
+
function i(s, a) {
|
|
2041
|
+
return t.getDependency("accessor", s).then(function(o) {
|
|
2042
|
+
h.setAttribute(a, o);
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
for (const s in r) {
|
|
2046
|
+
const a = Oe[s] || s.toLowerCase();
|
|
2047
|
+
a in h.attributes || n.push(i(r[s], a));
|
|
2048
|
+
}
|
|
2049
|
+
if (e.indices !== void 0 && !h.index) {
|
|
2050
|
+
const s = t.getDependency("accessor", e.indices).then(function(a) {
|
|
2051
|
+
h.setIndex(a);
|
|
2052
|
+
});
|
|
2053
|
+
n.push(s);
|
|
2054
|
+
}
|
|
2055
|
+
return Ne.workingColorSpace !== K && "COLOR_0" in r && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ne.workingColorSpace}" not supported.`), Z(h, e), Bn(h, e, t), Promise.all(n).then(function() {
|
|
2056
|
+
return e.targets !== void 0 ? Pn(h, e.targets, t) : h;
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
class Gn extends Kt {
|
|
2060
|
+
/**
|
|
2061
|
+
* Constructs a new RGBE loader.
|
|
2062
|
+
*
|
|
2063
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
2064
|
+
*/
|
|
2065
|
+
constructor(e) {
|
|
2066
|
+
super(e), this.type = me;
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Parses the given RGBE texture data.
|
|
2070
|
+
*
|
|
2071
|
+
* @param {ArrayBuffer} buffer - The raw texture data.
|
|
2072
|
+
* @return {DataTextureLoader~TexData} An object representing the parsed texture data.
|
|
2073
|
+
*/
|
|
2074
|
+
parse(e) {
|
|
2075
|
+
const s = function(g, y) {
|
|
2076
|
+
switch (g) {
|
|
2077
|
+
case 1:
|
|
2078
|
+
throw new Error("THREE.RGBELoader: Read Error: " + (y || ""));
|
|
2079
|
+
case 2:
|
|
2080
|
+
throw new Error("THREE.RGBELoader: Write Error: " + (y || ""));
|
|
2081
|
+
case 3:
|
|
2082
|
+
throw new Error("THREE.RGBELoader: Bad File Format: " + (y || ""));
|
|
2083
|
+
default:
|
|
2084
|
+
case 4:
|
|
2085
|
+
throw new Error("THREE.RGBELoader: Memory Error: " + (y || ""));
|
|
2086
|
+
}
|
|
2087
|
+
}, l = `
|
|
2088
|
+
`, u = function(g, y, S) {
|
|
2089
|
+
y = y || 1024;
|
|
2090
|
+
let F = g.pos, C = -1, w = 0, H = "", I = String.fromCharCode.apply(null, new Uint16Array(g.subarray(F, F + 128)));
|
|
2091
|
+
for (; 0 > (C = I.indexOf(l)) && w < y && F < g.byteLength; )
|
|
2092
|
+
H += I, w += I.length, F += 128, I += String.fromCharCode.apply(null, new Uint16Array(g.subarray(F, F + 128)));
|
|
2093
|
+
return -1 < C ? (g.pos += w + C + 1, H + I.slice(0, C)) : !1;
|
|
2094
|
+
}, d = function(g) {
|
|
2095
|
+
const y = /^#\?(\S+)/, S = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, P = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, F = /^\s*FORMAT=(\S+)\s*$/, C = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, w = {
|
|
2096
|
+
valid: 0,
|
|
2097
|
+
/* indicate which fields are valid */
|
|
2098
|
+
string: "",
|
|
2099
|
+
/* the actual header string */
|
|
2100
|
+
comments: "",
|
|
2101
|
+
/* comments found in header */
|
|
2102
|
+
programtype: "RGBE",
|
|
2103
|
+
/* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
|
|
2104
|
+
format: "",
|
|
2105
|
+
/* RGBE format, default 32-bit_rle_rgbe */
|
|
2106
|
+
gamma: 1,
|
|
2107
|
+
/* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
|
|
2108
|
+
exposure: 1,
|
|
2109
|
+
/* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
|
|
2110
|
+
width: 0,
|
|
2111
|
+
height: 0
|
|
2112
|
+
/* image dimensions, width/height */
|
|
2113
|
+
};
|
|
2114
|
+
let H, I;
|
|
2115
|
+
for ((g.pos >= g.byteLength || !(H = u(g))) && s(1, "no header found"), (I = H.match(y)) || s(3, "bad initial token"), w.valid |= 1, w.programtype = I[1], w.string += H + `
|
|
2116
|
+
`; H = u(g), H !== !1; ) {
|
|
2117
|
+
if (w.string += H + `
|
|
2118
|
+
`, H.charAt(0) === "#") {
|
|
2119
|
+
w.comments += H + `
|
|
2120
|
+
`;
|
|
2121
|
+
continue;
|
|
2122
|
+
}
|
|
2123
|
+
if ((I = H.match(S)) && (w.gamma = parseFloat(I[1])), (I = H.match(P)) && (w.exposure = parseFloat(I[1])), (I = H.match(F)) && (w.valid |= 2, w.format = I[1]), (I = H.match(C)) && (w.valid |= 4, w.height = parseInt(I[1], 10), w.width = parseInt(I[2], 10)), w.valid & 2 && w.valid & 4) break;
|
|
2124
|
+
}
|
|
2125
|
+
return w.valid & 2 || s(3, "missing format specifier"), w.valid & 4 || s(3, "missing image size specifier"), w;
|
|
2126
|
+
}, f = function(g, y, S) {
|
|
2127
|
+
const P = y;
|
|
2128
|
+
if (
|
|
2129
|
+
// run length encoding is not allowed so read flat
|
|
2130
|
+
P < 8 || P > 32767 || // this file is not run length encoded
|
|
2131
|
+
g[0] !== 2 || g[1] !== 2 || g[2] & 128
|
|
2132
|
+
)
|
|
2133
|
+
return new Uint8Array(g);
|
|
2134
|
+
P !== (g[2] << 8 | g[3]) && s(3, "wrong scanline width");
|
|
2135
|
+
const F = new Uint8Array(4 * y * S);
|
|
2136
|
+
F.length || s(4, "unable to allocate buffer space");
|
|
2137
|
+
let C = 0, w = 0;
|
|
2138
|
+
const H = 4 * P, I = new Uint8Array(4), $ = new Uint8Array(H);
|
|
2139
|
+
let xe = S;
|
|
2140
|
+
for (; xe > 0 && w < g.byteLength; ) {
|
|
2141
|
+
w + 4 > g.byteLength && s(1), I[0] = g[w++], I[1] = g[w++], I[2] = g[w++], I[3] = g[w++], (I[0] != 2 || I[1] != 2 || (I[2] << 8 | I[3]) != P) && s(3, "bad rgbe scanline format");
|
|
2142
|
+
let W = 0, G;
|
|
2143
|
+
for (; W < H && w < g.byteLength; ) {
|
|
2144
|
+
G = g[w++];
|
|
2145
|
+
const q = G > 128;
|
|
2146
|
+
if (q && (G -= 128), (G === 0 || W + G > H) && s(3, "bad scanline data"), q) {
|
|
2147
|
+
const Y = g[w++];
|
|
2148
|
+
for (let Fe = 0; Fe < G; Fe++)
|
|
2149
|
+
$[W++] = Y;
|
|
2150
|
+
} else
|
|
2151
|
+
$.set(g.subarray(w, w + G), W), W += G, w += G;
|
|
2152
|
+
}
|
|
2153
|
+
const dt = P;
|
|
2154
|
+
for (let q = 0; q < dt; q++) {
|
|
2155
|
+
let Y = 0;
|
|
2156
|
+
F[C] = $[q + Y], Y += P, F[C + 1] = $[q + Y], Y += P, F[C + 2] = $[q + Y], Y += P, F[C + 3] = $[q + Y], C += 4;
|
|
2157
|
+
}
|
|
2158
|
+
xe--;
|
|
2159
|
+
}
|
|
2160
|
+
return F;
|
|
2161
|
+
}, m = function(g, y, S, P) {
|
|
2162
|
+
const F = g[y + 3], C = Math.pow(2, F - 128) / 255;
|
|
2163
|
+
S[P + 0] = g[y + 0] * C, S[P + 1] = g[y + 1] * C, S[P + 2] = g[y + 2] * C, S[P + 3] = 1;
|
|
2164
|
+
}, T = function(g, y, S, P) {
|
|
2165
|
+
const F = g[y + 3], C = Math.pow(2, F - 128) / 255;
|
|
2166
|
+
S[P + 0] = ge.toHalfFloat(Math.min(g[y + 0] * C, 65504)), S[P + 1] = ge.toHalfFloat(Math.min(g[y + 1] * C, 65504)), S[P + 2] = ge.toHalfFloat(Math.min(g[y + 2] * C, 65504)), S[P + 3] = ge.toHalfFloat(1);
|
|
2167
|
+
}, p = new Uint8Array(e);
|
|
2168
|
+
p.pos = 0;
|
|
2169
|
+
const A = d(p), x = A.width, N = A.height, _ = f(p.subarray(p.pos), x, N);
|
|
2170
|
+
let B, U, M;
|
|
2171
|
+
switch (this.type) {
|
|
2172
|
+
case Ee:
|
|
2173
|
+
M = _.length / 4;
|
|
2174
|
+
const g = new Float32Array(M * 4);
|
|
2175
|
+
for (let S = 0; S < M; S++)
|
|
2176
|
+
m(_, S * 4, g, S * 4);
|
|
2177
|
+
B = g, U = Ee;
|
|
2178
|
+
break;
|
|
2179
|
+
case me:
|
|
2180
|
+
M = _.length / 4;
|
|
2181
|
+
const y = new Uint16Array(M * 4);
|
|
2182
|
+
for (let S = 0; S < M; S++)
|
|
2183
|
+
T(_, S * 4, y, S * 4);
|
|
2184
|
+
B = y, U = me;
|
|
2185
|
+
break;
|
|
2186
|
+
default:
|
|
2187
|
+
throw new Error("THREE.RGBELoader: Unsupported type: " + this.type);
|
|
2188
|
+
}
|
|
2189
|
+
return {
|
|
2190
|
+
width: x,
|
|
2191
|
+
height: N,
|
|
2192
|
+
data: B,
|
|
2193
|
+
header: A.string,
|
|
2194
|
+
gamma: A.gamma,
|
|
2195
|
+
exposure: A.exposure,
|
|
2196
|
+
type: U
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Sets the texture type.
|
|
2201
|
+
*
|
|
2202
|
+
* @param {(HalfFloatType|FloatType)} value - The texture type to set.
|
|
2203
|
+
* @return {RGBELoader} A reference to this loader.
|
|
2204
|
+
*/
|
|
2205
|
+
setDataType(e) {
|
|
2206
|
+
return this.type = e, this;
|
|
2207
|
+
}
|
|
2208
|
+
load(e, t, r, n) {
|
|
2209
|
+
function i(s, a) {
|
|
2210
|
+
switch (s.type) {
|
|
2211
|
+
case Ee:
|
|
2212
|
+
case me:
|
|
2213
|
+
s.colorSpace = K, s.minFilter = pe, s.magFilter = pe, s.generateMipmaps = !1, s.flipY = !0;
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
t && t(s, a);
|
|
2217
|
+
}
|
|
2218
|
+
return super.load(e, i, r, n);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
const b = {
|
|
2222
|
+
c: null,
|
|
2223
|
+
// center
|
|
2224
|
+
u: [new O(), new O(), new O()],
|
|
2225
|
+
// basis vectors
|
|
2226
|
+
e: []
|
|
2227
|
+
// half width
|
|
2228
|
+
}, L = {
|
|
2229
|
+
c: null,
|
|
2230
|
+
// center
|
|
2231
|
+
u: [new O(), new O(), new O()],
|
|
2232
|
+
// basis vectors
|
|
2233
|
+
e: []
|
|
2234
|
+
// half width
|
|
2235
|
+
}, D = [[], [], []], R = [[], [], []], k = [], se = new O(), re = new O(), ie = new O(), v = new O(), Xe = new O(), We = new O(), z = new ct(), qe = new Re(), Ae = new ae(), Ye = new ae(), Qe = new Vt();
|
|
2236
|
+
class ke {
|
|
2237
|
+
/**
|
|
2238
|
+
* Constructs a new OBB.
|
|
2239
|
+
*
|
|
2240
|
+
* @param {Vector3} [center] - The center of the OBB.
|
|
2241
|
+
* @param {Vector3} [halfSize] - Positive halfwidth extents of the OBB along each axis.
|
|
2242
|
+
* @param {Matrix3} [rotation] - The rotation of the OBB.
|
|
2243
|
+
*/
|
|
2244
|
+
constructor(e = new O(), t = new O(), r = new ct()) {
|
|
2245
|
+
this.center = e, this.halfSize = t, this.rotation = r;
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Sets the OBBs components to the given values.
|
|
2249
|
+
*
|
|
2250
|
+
* @param {Vector3} [center] - The center of the OBB.
|
|
2251
|
+
* @param {Vector3} [halfSize] - Positive halfwidth extents of the OBB along each axis.
|
|
2252
|
+
* @param {Matrix3} [rotation] - The rotation of the OBB.
|
|
2253
|
+
* @return {OBB} A reference to this OBB.
|
|
2254
|
+
*/
|
|
2255
|
+
set(e, t, r) {
|
|
2256
|
+
return this.center = e, this.halfSize = t, this.rotation = r, this;
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Copies the values of the given OBB to this instance.
|
|
2260
|
+
*
|
|
2261
|
+
* @param {OBB} obb - The OBB to copy.
|
|
2262
|
+
* @return {OBB} A reference to this OBB.
|
|
2263
|
+
*/
|
|
2264
|
+
copy(e) {
|
|
2265
|
+
return this.center.copy(e.center), this.halfSize.copy(e.halfSize), this.rotation.copy(e.rotation), this;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Returns a new OBB with copied values from this instance.
|
|
2269
|
+
*
|
|
2270
|
+
* @return {OBB} A clone of this instance.
|
|
2271
|
+
*/
|
|
2272
|
+
clone() {
|
|
2273
|
+
return new this.constructor().copy(this);
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Returns the size of this OBB.
|
|
2277
|
+
*
|
|
2278
|
+
* @param {Vector3} target - The target vector that is used to store the method's result.
|
|
2279
|
+
* @return {Vector3} The size.
|
|
2280
|
+
*/
|
|
2281
|
+
getSize(e) {
|
|
2282
|
+
return e.copy(this.halfSize).multiplyScalar(2);
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* Clamps the given point within the bounds of this OBB.
|
|
2286
|
+
*
|
|
2287
|
+
* @param {Vector3} point - The point that should be clamped within the bounds of this OBB.
|
|
2288
|
+
* @param {Vector3} target - The target vector that is used to store the method's result.
|
|
2289
|
+
* @returns {Vector3} - The clamped point.
|
|
2290
|
+
*/
|
|
2291
|
+
clampPoint(e, t) {
|
|
2292
|
+
const r = this.halfSize;
|
|
2293
|
+
v.subVectors(e, this.center), this.rotation.extractBasis(se, re, ie), t.copy(this.center);
|
|
2294
|
+
const n = he.clamp(v.dot(se), -r.x, r.x);
|
|
2295
|
+
t.add(se.multiplyScalar(n));
|
|
2296
|
+
const i = he.clamp(v.dot(re), -r.y, r.y);
|
|
2297
|
+
t.add(re.multiplyScalar(i));
|
|
2298
|
+
const s = he.clamp(v.dot(ie), -r.z, r.z);
|
|
2299
|
+
return t.add(ie.multiplyScalar(s)), t;
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Returns `true` if the given point lies within this OBB.
|
|
2303
|
+
*
|
|
2304
|
+
* @param {Vector3} point - The point to test.
|
|
2305
|
+
* @returns {boolean} - Whether the given point lies within this OBB or not.
|
|
2306
|
+
*/
|
|
2307
|
+
containsPoint(e) {
|
|
2308
|
+
return v.subVectors(e, this.center), this.rotation.extractBasis(se, re, ie), Math.abs(v.dot(se)) <= this.halfSize.x && Math.abs(v.dot(re)) <= this.halfSize.y && Math.abs(v.dot(ie)) <= this.halfSize.z;
|
|
2309
|
+
}
|
|
2310
|
+
/**
|
|
2311
|
+
* Returns `true` if the given AABB intersects this OBB.
|
|
2312
|
+
*
|
|
2313
|
+
* @param {Box3} box3 - The AABB to test.
|
|
2314
|
+
* @returns {boolean} - Whether the given AABB intersects this OBB or not.
|
|
2315
|
+
*/
|
|
2316
|
+
intersectsBox3(e) {
|
|
2317
|
+
return this.intersectsOBB(Un.fromBox3(e));
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Returns `true` if the given bounding sphere intersects this OBB.
|
|
2321
|
+
*
|
|
2322
|
+
* @param {Sphere} sphere - The bounding sphere to test.
|
|
2323
|
+
* @returns {boolean} - Whether the given bounding sphere intersects this OBB or not.
|
|
2324
|
+
*/
|
|
2325
|
+
intersectsSphere(e) {
|
|
2326
|
+
return this.clampPoint(e.center, We), We.distanceToSquared(e.center) <= e.radius * e.radius;
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Returns `true` if the given OBB intersects this OBB.
|
|
2330
|
+
*
|
|
2331
|
+
* @param {OBB} obb - The OBB to test.
|
|
2332
|
+
* @param {number} [epsilon=Number.EPSILON] - A small value to prevent arithmetic errors.
|
|
2333
|
+
* @returns {boolean} - Whether the given OBB intersects this OBB or not.
|
|
2334
|
+
*/
|
|
2335
|
+
intersectsOBB(e, t = Number.EPSILON) {
|
|
2336
|
+
b.c = this.center, b.e[0] = this.halfSize.x, b.e[1] = this.halfSize.y, b.e[2] = this.halfSize.z, this.rotation.extractBasis(b.u[0], b.u[1], b.u[2]), L.c = e.center, L.e[0] = e.halfSize.x, L.e[1] = e.halfSize.y, L.e[2] = e.halfSize.z, e.rotation.extractBasis(L.u[0], L.u[1], L.u[2]);
|
|
2337
|
+
for (let i = 0; i < 3; i++)
|
|
2338
|
+
for (let s = 0; s < 3; s++)
|
|
2339
|
+
D[i][s] = b.u[i].dot(L.u[s]);
|
|
2340
|
+
v.subVectors(L.c, b.c), k[0] = v.dot(b.u[0]), k[1] = v.dot(b.u[1]), k[2] = v.dot(b.u[2]);
|
|
2341
|
+
for (let i = 0; i < 3; i++)
|
|
2342
|
+
for (let s = 0; s < 3; s++)
|
|
2343
|
+
R[i][s] = Math.abs(D[i][s]) + t;
|
|
2344
|
+
let r, n;
|
|
2345
|
+
for (let i = 0; i < 3; i++)
|
|
2346
|
+
if (r = b.e[i], n = L.e[0] * R[i][0] + L.e[1] * R[i][1] + L.e[2] * R[i][2], Math.abs(k[i]) > r + n) return !1;
|
|
2347
|
+
for (let i = 0; i < 3; i++)
|
|
2348
|
+
if (r = b.e[0] * R[0][i] + b.e[1] * R[1][i] + b.e[2] * R[2][i], n = L.e[i], Math.abs(k[0] * D[0][i] + k[1] * D[1][i] + k[2] * D[2][i]) > r + n) return !1;
|
|
2349
|
+
return r = b.e[1] * R[2][0] + b.e[2] * R[1][0], n = L.e[1] * R[0][2] + L.e[2] * R[0][1], !(Math.abs(k[2] * D[1][0] - k[1] * D[2][0]) > r + n || (r = b.e[1] * R[2][1] + b.e[2] * R[1][1], n = L.e[0] * R[0][2] + L.e[2] * R[0][0], Math.abs(k[2] * D[1][1] - k[1] * D[2][1]) > r + n) || (r = b.e[1] * R[2][2] + b.e[2] * R[1][2], n = L.e[0] * R[0][1] + L.e[1] * R[0][0], Math.abs(k[2] * D[1][2] - k[1] * D[2][2]) > r + n) || (r = b.e[0] * R[2][0] + b.e[2] * R[0][0], n = L.e[1] * R[1][2] + L.e[2] * R[1][1], Math.abs(k[0] * D[2][0] - k[2] * D[0][0]) > r + n) || (r = b.e[0] * R[2][1] + b.e[2] * R[0][1], n = L.e[0] * R[1][2] + L.e[2] * R[1][0], Math.abs(k[0] * D[2][1] - k[2] * D[0][1]) > r + n) || (r = b.e[0] * R[2][2] + b.e[2] * R[0][2], n = L.e[0] * R[1][1] + L.e[1] * R[1][0], Math.abs(k[0] * D[2][2] - k[2] * D[0][2]) > r + n) || (r = b.e[0] * R[1][0] + b.e[1] * R[0][0], n = L.e[1] * R[2][2] + L.e[2] * R[2][1], Math.abs(k[1] * D[0][0] - k[0] * D[1][0]) > r + n) || (r = b.e[0] * R[1][1] + b.e[1] * R[0][1], n = L.e[0] * R[2][2] + L.e[2] * R[2][0], Math.abs(k[1] * D[0][1] - k[0] * D[1][1]) > r + n) || (r = b.e[0] * R[1][2] + b.e[1] * R[0][2], n = L.e[0] * R[2][1] + L.e[1] * R[2][0], Math.abs(k[1] * D[0][2] - k[0] * D[1][2]) > r + n));
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Returns `true` if the given plane intersects this OBB.
|
|
2353
|
+
*
|
|
2354
|
+
* @param {Plane} plane - The plane to test.
|
|
2355
|
+
* @returns {boolean} Whether the given plane intersects this OBB or not.
|
|
2356
|
+
*/
|
|
2357
|
+
intersectsPlane(e) {
|
|
2358
|
+
this.rotation.extractBasis(se, re, ie);
|
|
2359
|
+
const t = this.halfSize.x * Math.abs(e.normal.dot(se)) + this.halfSize.y * Math.abs(e.normal.dot(re)) + this.halfSize.z * Math.abs(e.normal.dot(ie)), r = e.normal.dot(this.center) - e.constant;
|
|
2360
|
+
return Math.abs(r) <= t;
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Performs a ray/OBB intersection test and stores the intersection point
|
|
2364
|
+
* in the given 3D vector.
|
|
2365
|
+
*
|
|
2366
|
+
* @param {Ray} ray - The ray to test.
|
|
2367
|
+
* @param {Vector3} target - The target vector that is used to store the method's result.
|
|
2368
|
+
* @return {?Vector3} The intersection point. If no intersection is detected, `null` is returned.
|
|
2369
|
+
*/
|
|
2370
|
+
intersectRay(e, t) {
|
|
2371
|
+
return this.getSize(Xe), qe.setFromCenterAndSize(v.set(0, 0, 0), Xe), Ae.setFromMatrix3(this.rotation), Ae.setPosition(this.center), Ye.copy(Ae).invert(), Qe.copy(e).applyMatrix4(Ye), Qe.intersectBox(qe, t) ? t.applyMatrix4(Ae) : null;
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Returns `true` if the given ray intersects this OBB.
|
|
2375
|
+
*
|
|
2376
|
+
* @param {Ray} ray - The ray to test.
|
|
2377
|
+
* @returns {boolean} Whether the given ray intersects this OBB or not.
|
|
2378
|
+
*/
|
|
2379
|
+
intersectsRay(e) {
|
|
2380
|
+
return this.intersectRay(e, v) !== null;
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Defines an OBB based on the given AABB.
|
|
2384
|
+
*
|
|
2385
|
+
* @param {Box3} box3 - The AABB to setup the OBB from.
|
|
2386
|
+
* @return {OBB} A reference of this OBB.
|
|
2387
|
+
*/
|
|
2388
|
+
fromBox3(e) {
|
|
2389
|
+
return e.getCenter(this.center), e.getSize(this.halfSize).multiplyScalar(0.5), this.rotation.identity(), this;
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Returns `true` if the given OBB is equal to this OBB.
|
|
2393
|
+
*
|
|
2394
|
+
* @param {OBB} obb - The OBB to test.
|
|
2395
|
+
* @returns {boolean} Whether the given OBB is equal to this OBB or not.
|
|
2396
|
+
*/
|
|
2397
|
+
equals(e) {
|
|
2398
|
+
return e.center.equals(this.center) && e.halfSize.equals(this.halfSize) && e.rotation.equals(this.rotation);
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Applies the given transformation matrix to this OBB. This method can be
|
|
2402
|
+
* used to transform the bounding volume with the world matrix of a 3D object
|
|
2403
|
+
* in order to keep both entities in sync.
|
|
2404
|
+
*
|
|
2405
|
+
* @param {Matrix4} matrix - The matrix to apply.
|
|
2406
|
+
* @return {OBB} A reference of this OBB.
|
|
2407
|
+
*/
|
|
2408
|
+
applyMatrix4(e) {
|
|
2409
|
+
const t = e.elements;
|
|
2410
|
+
let r = v.set(t[0], t[1], t[2]).length();
|
|
2411
|
+
const n = v.set(t[4], t[5], t[6]).length(), i = v.set(t[8], t[9], t[10]).length();
|
|
2412
|
+
e.determinant() < 0 && (r = -r), z.setFromMatrix4(e);
|
|
2413
|
+
const a = 1 / r, o = 1 / n, c = 1 / i;
|
|
2414
|
+
return z.elements[0] *= a, z.elements[1] *= a, z.elements[2] *= a, z.elements[3] *= o, z.elements[4] *= o, z.elements[5] *= o, z.elements[6] *= c, z.elements[7] *= c, z.elements[8] *= c, this.rotation.multiply(z), this.halfSize.x *= r, this.halfSize.y *= n, this.halfSize.z *= i, v.setFromMatrixPosition(e), this.center.add(v), this;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
const Un = new ke(), jn = new URL("/hdr/slightly_overcast_sky_dome_1k.hdr", import.meta.url).href, zn = new Gn(), Me = {}, Kn = {
|
|
2418
|
+
enableDamping: !0,
|
|
2419
|
+
dampingFactor: 0.25,
|
|
2420
|
+
screenSpacePanning: !1,
|
|
2421
|
+
minDistance: 0.1,
|
|
2422
|
+
maxDistance: 1e3,
|
|
2423
|
+
maxPolarAngle: Math.PI / 2
|
|
2424
|
+
}, Q = new Xt({
|
|
2425
|
+
antialias: !0,
|
|
2426
|
+
alpha: !0,
|
|
2427
|
+
precision: "mediump"
|
|
2428
|
+
});
|
|
2429
|
+
function qn(h, e) {
|
|
2430
|
+
const t = Object.assign(
|
|
2431
|
+
{
|
|
2432
|
+
css3d: !1,
|
|
2433
|
+
stats: !1,
|
|
2434
|
+
axesHelper: {
|
|
2435
|
+
init: !1,
|
|
2436
|
+
size: 10
|
|
2437
|
+
},
|
|
2438
|
+
gridHelper: {
|
|
2439
|
+
init: !1
|
|
2440
|
+
},
|
|
2441
|
+
control: {
|
|
2442
|
+
init: !0,
|
|
2443
|
+
options: {}
|
|
2444
|
+
},
|
|
2445
|
+
envImage: !0
|
|
2446
|
+
},
|
|
2447
|
+
e || {}
|
|
2448
|
+
);
|
|
2449
|
+
let r, n, i, s, a = [];
|
|
2450
|
+
const o = ref(0), c = ref(0), l = new Wt({});
|
|
2451
|
+
l.background = new V("#222b38");
|
|
2452
|
+
const u = new Te();
|
|
2453
|
+
l.add(u), Q.setPixelRatio(window.devicePixelRatio);
|
|
2454
|
+
const d = new ot(50, 1, 0.1, 2e3), f = Math.tan(Math.PI / 180 * d.fov / 2);
|
|
2455
|
+
function m() {
|
|
2456
|
+
const M = x();
|
|
2457
|
+
if (o.value = M[0], c.value = M[1], d.aspect = o.value / c.value, d.position.set(47, 39, 100), d.fov = 360 / Math.PI * Math.atan(f * (c.value / o.value)), d.updateProjectionMatrix(), Q.setSize(o.value, c.value), r.appendChild(Q.domElement), t.envImage && Vn(l), t.stats && N(), t.css3d && B(), t.axesHelper && t.axesHelper.init) {
|
|
2458
|
+
const g = Zt(t.axesHelper.size || 10);
|
|
2459
|
+
l.add(g);
|
|
2460
|
+
}
|
|
2461
|
+
if (t.gridHelper && t.gridHelper.init) {
|
|
2462
|
+
const g = $t(
|
|
2463
|
+
t.gridHelper.size || 150,
|
|
2464
|
+
t.gridHelper.options || {}
|
|
2465
|
+
);
|
|
2466
|
+
l.add(g);
|
|
2467
|
+
}
|
|
2468
|
+
if (t.control && t.control.init) {
|
|
2469
|
+
s = en(d, Q.domElement);
|
|
2470
|
+
const g = t.control.options || Kn;
|
|
2471
|
+
Object.keys(g).forEach((y) => {
|
|
2472
|
+
s[y] = g[y];
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
return { control: s, scene: l, camera: d, renderer: Q };
|
|
2476
|
+
}
|
|
2477
|
+
function T(M) {
|
|
2478
|
+
a.push(M);
|
|
2479
|
+
}
|
|
2480
|
+
function p(M) {
|
|
2481
|
+
a && a.length && a.forEach((g) => {
|
|
2482
|
+
typeof g == "function" && g();
|
|
2483
|
+
}), s && s.update(), Q.render(l, d), n && n.update(), i && i.render(l, d), requestAnimationFrame(p);
|
|
2484
|
+
}
|
|
2485
|
+
function A() {
|
|
2486
|
+
nextTick(() => {
|
|
2487
|
+
const M = x();
|
|
2488
|
+
o.value = M[0], c.value = M[1], d.aspect = o.value / c.value, d.fov = 360 / Math.PI * Math.atan(f * (c.value / o.value)), d.updateProjectionMatrix(), d.lookAt(l.position), Q.render(l, d), Q.setSize(o.value, c.value), i && i.setSize(o.value, c.value);
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
function x() {
|
|
2492
|
+
return r = document.querySelector(h), [r.clientWidth, r.clientHeight];
|
|
2493
|
+
}
|
|
2494
|
+
function N() {
|
|
2495
|
+
n = new fe(), n.dom.style.cssText = "position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", r.appendChild(n.dom);
|
|
2496
|
+
}
|
|
2497
|
+
function _(M, g, y, S) {
|
|
2498
|
+
const P = new Re().setFromObject(M), F = P.getSize(new O()).length(), C = P.getCenter(new O()), H = F * g * 0.5, I = he.degToRad(y.fov * 0.5), $ = H / Math.tan(I), W = new O().subVectors(y.position, C).multiply(new O(1, 1, 1)).normalize().multiplyScalar($).add(C), G = {
|
|
2499
|
+
x: W.x,
|
|
2500
|
+
y: W.y,
|
|
2501
|
+
z: W.z,
|
|
2502
|
+
lookAt_x: C.x,
|
|
2503
|
+
lookAt_y: C.y,
|
|
2504
|
+
lookAt_z: C.z
|
|
2505
|
+
};
|
|
2506
|
+
return y.position.set(G.x, G.y, G.z), y.lookAt(
|
|
2507
|
+
G.lookAt_x,
|
|
2508
|
+
G.lookAt_y,
|
|
2509
|
+
G.lookAt_z
|
|
2510
|
+
), y.updateProjectionMatrix(), S.target.copy(C), S.update(), F;
|
|
2511
|
+
}
|
|
2512
|
+
function B() {
|
|
2513
|
+
i = new tn(), i.setSize(o.value, c.value), i.domElement.style.position = "absolute", i.domElement.style.top = 0, i.domElement.style.left = 0, i.domElement.style.pointerEvents = "none", r.appendChild(i.domElement);
|
|
2514
|
+
}
|
|
2515
|
+
function U() {
|
|
2516
|
+
Jt(l);
|
|
2517
|
+
}
|
|
2518
|
+
return {
|
|
2519
|
+
init: m,
|
|
2520
|
+
dispose: U,
|
|
2521
|
+
animate: p,
|
|
2522
|
+
onResize: A,
|
|
2523
|
+
addAnimate: T,
|
|
2524
|
+
frameArea: _,
|
|
2525
|
+
objectGroup: u,
|
|
2526
|
+
scene: l,
|
|
2527
|
+
camera: d,
|
|
2528
|
+
control: s,
|
|
2529
|
+
renderer: Q,
|
|
2530
|
+
domWidth: o,
|
|
2531
|
+
domHeight: c
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
async function Vn(h, e = jn) {
|
|
2535
|
+
if (console.log(" =====> hdrImg:", e), Me[e]) {
|
|
2536
|
+
const t = Me[e];
|
|
2537
|
+
h.environment = t;
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
return new Promise((t, r) => {
|
|
2541
|
+
zn.load(e, t, void 0, r);
|
|
2542
|
+
}).then((t) => {
|
|
2543
|
+
t.mapping = qt, h.environment = t, Me[e] = t;
|
|
2544
|
+
}).catch((t) => {
|
|
2545
|
+
console.log(" =====> e:", t);
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
const Yn = (h = "app") => {
|
|
2549
|
+
const e = new Yt();
|
|
2550
|
+
e.params.Line.threshold = 8;
|
|
2551
|
+
const t = new De(), r = document.getElementById(h);
|
|
2552
|
+
function n(a, o) {
|
|
2553
|
+
const { scaleX: c, scaleY: l } = s(r), { clientWidth: u, clientHeight: d } = o, f = o.getBoundingClientRect(), m = u * c, T = d * l, p = a.clientX - f.left, A = a.clientY - f.top;
|
|
2554
|
+
return t.x = (a.clientX - f.left) / m * 2 - 1, t.y = -((a.clientY - f.top) / T) * 2 + 1, { pointer: t, x: p, y: A };
|
|
2555
|
+
}
|
|
2556
|
+
function i(a, o, c, l) {
|
|
2557
|
+
const { pointer: u, x: d, y: f } = n(a, o);
|
|
2558
|
+
return e.setFromCamera(u, c), { intersects: e.intersectObjects(l), pointer: u, x: d, y: f };
|
|
2559
|
+
}
|
|
2560
|
+
function s(a) {
|
|
2561
|
+
const o = window.getComputedStyle(a), c = o.transform || o.webkitTransform || o.mozTransform;
|
|
2562
|
+
if (c && c !== "none") {
|
|
2563
|
+
const l = c.match(/^matrix\((.+)\)$/);
|
|
2564
|
+
if (l) {
|
|
2565
|
+
const u = l[1].split(", "), d = parseFloat(u[0]), f = parseFloat(u[3]);
|
|
2566
|
+
return { scaleX: d, scaleY: f };
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
return { scaleX: 1, scaleY: 1 };
|
|
2570
|
+
}
|
|
2571
|
+
return {
|
|
2572
|
+
raycaster: e,
|
|
2573
|
+
pointer: t,
|
|
2574
|
+
getPointer: n,
|
|
2575
|
+
getScale: s,
|
|
2576
|
+
getIntersects: i
|
|
2577
|
+
};
|
|
2578
|
+
}, J = [], Qn = new V(16711680), Jn = () => {
|
|
2579
|
+
const h = () => {
|
|
2580
|
+
J.splice(0);
|
|
2581
|
+
}, e = (a, o) => {
|
|
2582
|
+
o.traverse((c) => {
|
|
2583
|
+
c && t(a, c);
|
|
2584
|
+
});
|
|
2585
|
+
}, t = (a, o) => {
|
|
2586
|
+
if (o.userData.needCheck && (o.autoUpdateMatrix = !1, o.updateMatrix(), o.updateMatrixWorld(), o.isMesh)) {
|
|
2587
|
+
const c = new Re(new O()).setFromObject(o);
|
|
2588
|
+
o.geometry.userData.obb = new ke(), o.geometry.userData.obb.halfSize.copy(c.getSize(new O())).multiplyScalar(0.5).multiplyScalar(0.88), o.userData.obb = new ke(), o.userData.originColor = o.material.color.clone(), o.userData.parentUid = a, J.push({
|
|
2589
|
+
object: o,
|
|
2590
|
+
parentUid: a
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
return {
|
|
2595
|
+
resetObbs: h,
|
|
2596
|
+
initObb: e,
|
|
2597
|
+
getObbObjectByParentUid: (a) => J.filter((o) => o.parentUid === a),
|
|
2598
|
+
addObbFromArray: (a, o) => {
|
|
2599
|
+
for (let c = 0, l = o.length; c < l; c++)
|
|
2600
|
+
t(a, o[c]);
|
|
2601
|
+
},
|
|
2602
|
+
removeObbFromArray: (a) => {
|
|
2603
|
+
const o = J.filter((c) => !a.includes(c.object));
|
|
2604
|
+
J.splice(0, J.length, ...o);
|
|
2605
|
+
},
|
|
2606
|
+
removeUidObb: (a) => {
|
|
2607
|
+
for (let o = J.length - 1; o >= 0; o--)
|
|
2608
|
+
J[o].parentUid === a && J.splice(o, 1);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
}, Zn = () => {
|
|
2612
|
+
const h = new Qt(16777215, 1), e = new et(16777215, 1, 0);
|
|
2613
|
+
e.position.set(0, 50, 100), e.angle = Math.PI / 8, e.penumbra = 1, e.decay = 0, e.distance = 0;
|
|
2614
|
+
const t = e.clone();
|
|
2615
|
+
return t.position.set(-100, 50, -100), t.angle = Math.PI / 8, t.penumbra = 1, t.decay = 0, t.distance = 0, [h, e, t];
|
|
2616
|
+
}, $n = () => {
|
|
2617
|
+
const h = new rn(), e = new nn();
|
|
2618
|
+
e.setDecoderPath("/draco/"), h.setDRACOLoader(e);
|
|
2619
|
+
function t(n, i, s, a) {
|
|
2620
|
+
return h.load(n, i, s, a);
|
|
2621
|
+
}
|
|
2622
|
+
function r(n, i) {
|
|
2623
|
+
return new Promise((s, a) => {
|
|
2624
|
+
h.load(n, s, i, a);
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
return {
|
|
2628
|
+
load: t,
|
|
2629
|
+
asyncLoad: r
|
|
2630
|
+
};
|
|
2631
|
+
};
|
|
2632
|
+
export {
|
|
2633
|
+
Yn as a,
|
|
2634
|
+
Qn as b,
|
|
2635
|
+
Jn as c,
|
|
2636
|
+
Zn as d,
|
|
2637
|
+
$n as e,
|
|
2638
|
+
Vn as i,
|
|
2639
|
+
J as o,
|
|
2640
|
+
qn as u
|
|
2641
|
+
};
|