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