aptechka 0.5.44 → 0.7.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/lib/Animation-6Na1MCtM.cjs +1 -0
- package/lib/Animation-CELiTw3n.js +132 -0
- package/lib/Composed-DmLYTh1b.js +35 -0
- package/lib/Composed-Dx2hs-va.cjs +1 -0
- package/lib/{Damped-P4MkCGoY.js → Damped-Mx_FNNVz.js} +2 -5
- package/lib/Damped-loFiBsBy.cjs +1 -0
- package/lib/{Derived-kPJs5JC5.js → Derived-DlCvc0xQ.js} +1 -1
- package/lib/{Derived-B-g8dYgh.cjs → Derived-a6MDQEPY.cjs} +1 -1
- package/lib/ElementConstructor-CAZ2ra8m.cjs +1 -0
- package/lib/ElementConstructor-OYlPJf2L.js +366 -0
- package/lib/Resource-D3TQormz.cjs +1 -0
- package/lib/Resource-DIcoALGo.js +64 -0
- package/lib/{SourceManager-Q-PB-Rkh.js → SourceManager-Bz329f90.js} +1 -1
- package/lib/{SourceManager-vSlsMKUE.cjs → SourceManager-kxr5eUyL.cjs} +1 -1
- package/lib/Store-6s0YXK4o.cjs +1 -0
- package/lib/{Store-BQXXikps.js → Store-BI2xxXOA.js} +42 -42
- package/lib/Tweened-B_mclQ61.cjs +1 -0
- package/lib/Tweened-NE8M9onF.js +48 -0
- package/lib/{Viewport-DMB0dO-s.cjs → Viewport-CJeKnL5V.cjs} +1 -1
- package/lib/{Viewport-CFFhFKqX.js → Viewport-D9IL7kUQ.js} +1 -1
- package/lib/_createStore-Cf1MyeHa.cjs +1 -0
- package/lib/_createStore-Ck9bHolX.js +12 -0
- package/lib/accordion/AccordionElement.d.ts +3 -0
- package/lib/accordion/index.cjs +1 -1
- package/lib/accordion/index.js +140 -104
- package/lib/animation/Animation.d.ts +10 -18
- package/lib/animation/Damped.d.ts +3 -5
- package/lib/animation/Tweened.d.ts +0 -2
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +3 -3
- package/lib/attribute/index.cjs +1 -1
- package/lib/attribute/index.js +31 -31
- package/lib/canvas/index.cjs +1 -1
- package/lib/canvas/index.js +3 -3
- package/lib/checkbox/index.cjs +1 -1
- package/lib/checkbox/index.js +3 -3
- package/lib/class-linked-status/index.cjs +1 -1
- package/lib/class-linked-status/index.js +1 -1
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +3 -3
- package/lib/counter/index.d.ts +8 -0
- package/lib/{createStylesheet-DBCEbDjI.js → createStylesheet-CR_yi5tp.js} +1 -1
- package/lib/{createStylesheet-CqHU9_qv.cjs → createStylesheet-p23sZ7Ey.cjs} +1 -1
- package/lib/css-property/index.cjs +1 -1
- package/lib/css-property/index.d.ts +1 -0
- package/lib/css-property/index.js +36 -32
- package/lib/dev/index.cjs +1 -1
- package/lib/dev/index.js +1 -1
- package/lib/device/index.cjs +1 -1
- package/lib/device/index.js +1 -1
- package/lib/element-constructor/index.cjs +1 -1
- package/lib/element-constructor/index.js +114 -113
- package/lib/en3/core/En3Raycaster.d.ts +20 -0
- package/lib/en3/core/En3View.d.ts +1 -1
- package/lib/en3/core/en3.d.ts +5 -1
- package/lib/en3/helpers/En3Controls.d.ts +5 -0
- package/lib/en3/helpers/En3GridHelper.d.ts +8 -0
- package/lib/en3/helpers/En3Object3dManager.d.ts +12 -0
- package/lib/en3/helpers/En3OrbitControls.d.ts +8 -0
- package/lib/en3/helpers/En3TransformControls.d.ts +8 -0
- package/lib/en3/helpers/index.cjs +1 -0
- package/lib/en3/helpers/index.d.ts +2 -0
- package/lib/en3/helpers/index.js +1165 -0
- package/lib/en3/index.cjs +1 -213
- package/lib/en3/index.d.ts +1 -19
- package/lib/en3/index.js +4 -3305
- package/lib/en3/libs/index.d.ts +1 -0
- package/lib/en3/loaders/{en3GLTFLoader.d.ts → _En3GLTFLoader.d.ts} +2 -4
- package/lib/en3/loaders/_En3TextureLoader.d.ts +8 -0
- package/lib/en3/loaders/index.cjs +1 -0
- package/lib/en3/loaders/index.d.ts +3 -0
- package/lib/en3/loaders/index.js +1757 -0
- package/lib/en3/loaders/loaders.d.ts +13 -0
- package/lib/en3/misc/index.cjs +10 -0
- package/lib/en3/misc/index.d.ts +2 -0
- package/lib/en3/misc/index.js +115 -0
- package/lib/en3/objects/En3Clip.d.ts +1 -1
- package/lib/en3/objects/En3GLTF.d.ts +2 -1
- package/lib/en3/objects/En3ImageLike.d.ts +2 -1
- package/lib/en3/objects/En3SourceConsumer.d.ts +1 -1
- package/lib/en3/objects/fluid/index.d.ts +0 -3
- package/lib/en3/objects/index.d.ts +7 -0
- package/lib/en3/utils/index.cjs +1 -0
- package/lib/en3/utils/index.d.ts +5 -0
- package/lib/en3/utils/index.js +43 -0
- package/lib/en3-C4mzaF6q.cjs +8 -0
- package/lib/en3-hbkN1OPu.js +343 -0
- package/lib/globals-DMjysUXI.js +8 -0
- package/lib/globals-bYKki-b9.cjs +1 -0
- package/lib/image/index.cjs +1 -1
- package/lib/image/index.js +1 -1
- package/lib/{index-BN9X-l9M.js → index-BAH_fO2N.js} +3 -3
- package/lib/{index-BbgmbQ-5.cjs → index-D1LQUR-R.cjs} +1 -1
- package/lib/instantiate-D19Uvc31.js +125 -0
- package/lib/instantiate-Db5gGSYG.cjs +1 -0
- package/lib/jsx/ComponentElement.d.ts +18 -0
- package/lib/jsx/globals.d.ts +13 -0
- package/lib/jsx/h.d.ts +7 -0
- package/lib/jsx/hooks/basic/_createStore.d.ts +4 -0
- package/lib/jsx/hooks/basic/attachInternals.d.ts +1 -0
- package/lib/jsx/hooks/basic/attachShadow.d.ts +1 -0
- package/lib/jsx/hooks/basic/attachStylesheet.d.ts +3 -0
- package/lib/jsx/hooks/basic/createContext.d.ts +2 -0
- package/lib/jsx/hooks/basic/onConnect.d.ts +3 -0
- package/lib/jsx/hooks/basic/onDisconnect.d.ts +3 -0
- package/lib/jsx/hooks/onAnimationFrame.cjs +1 -0
- package/lib/jsx/hooks/onAnimationFrame.d.ts +6 -0
- package/lib/jsx/hooks/onAnimationFrame.js +22 -0
- package/lib/jsx/hooks/onElementResize.cjs +1 -0
- package/lib/jsx/hooks/onElementResize.d.ts +5 -0
- package/lib/jsx/hooks/onElementResize.js +11 -0
- package/lib/jsx/hooks/onIntersection.cjs +1 -0
- package/lib/jsx/hooks/onIntersection.d.ts +5 -0
- package/lib/jsx/hooks/onIntersection.js +11 -0
- package/lib/jsx/hooks/onWindowResize.cjs +1 -0
- package/lib/jsx/hooks/onWindowResize.d.ts +3 -0
- package/lib/jsx/hooks/onWindowResize.js +8 -0
- package/lib/jsx/hooks/store/createArrayStore.d.ts +3 -0
- package/lib/jsx/hooks/store/createComposed.d.ts +3 -0
- package/lib/jsx/hooks/store/createDerived.d.ts +3 -0
- package/lib/jsx/hooks/store/createDerivedArray.d.ts +3 -0
- package/lib/jsx/hooks/store/createDerivedComponent.d.ts +3 -0
- package/lib/jsx/hooks/store/createDerivedComponents.d.ts +3 -0
- package/lib/jsx/hooks/store/createResource.d.ts +3 -0
- package/lib/jsx/hooks/store/createStore.d.ts +3 -0
- package/lib/jsx/hooks/store/index.cjs +1 -0
- package/lib/jsx/hooks/store/index.d.ts +7 -0
- package/lib/jsx/hooks/store/index.js +49 -0
- package/lib/jsx/hooks/watchAttribute.cjs +1 -0
- package/lib/jsx/hooks/watchAttribute.d.ts +6 -0
- package/lib/jsx/hooks/watchAttribute.js +17 -0
- package/lib/jsx/hooks/watchCSSProperty.cjs +1 -0
- package/lib/jsx/hooks/watchCSSProperty.d.ts +7 -0
- package/lib/jsx/hooks/watchCSSProperty.js +17 -0
- package/lib/jsx/index.cjs +1 -0
- package/lib/jsx/index.d.ts +13 -0
- package/lib/jsx/index.js +91 -0
- package/lib/jsx/instantiate.d.ts +5 -0
- package/lib/jsx/register.d.ts +1 -0
- package/lib/jsx/render.d.ts +6 -0
- package/lib/jsx/type.d.ts +188 -0
- package/lib/ladder/index.cjs +1 -1
- package/lib/ladder/index.d.ts +2 -0
- package/lib/ladder/index.js +84 -66
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.d.ts +9 -0
- package/lib/layout-box/index.js +190 -164
- package/lib/media/index.cjs +1 -1
- package/lib/media/index.js +1 -1
- package/lib/modal/index.cjs +1 -1
- package/lib/modal/index.js +7 -7
- package/lib/morph/Morph.d.ts +2 -2
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.d.ts +1 -1
- package/lib/morph/index.js +135 -143
- package/lib/notifier/index.d.ts +2 -2
- package/lib/notifier/index.js +3 -1
- package/lib/onConnect-DGP866cj.cjs +1 -0
- package/lib/onConnect-y5DrxJ9P.js +7 -0
- package/lib/pointer/index.cjs +1 -1
- package/lib/pointer/index.js +2 -2
- package/lib/polyfills-CM4SCDTt.cjs +1 -0
- package/lib/polyfills-X6KXuHg-.js +33 -0
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +2 -2
- package/lib/router/Router.d.ts +11 -3
- package/lib/router/index.cjs +1 -1
- package/lib/router/index.d.ts +1 -1
- package/lib/router/index.js +185 -165
- package/lib/scroll/ScrollElement.d.ts +2 -19
- package/lib/scroll/ScrollSection.d.ts +23 -0
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +81 -77
- package/lib/select/index.cjs +1 -1
- package/lib/select/index.js +1 -1
- package/lib/sequence/index.cjs +1 -1
- package/lib/sequence/index.js +1 -1
- package/lib/source/index.cjs +1 -1
- package/lib/source/index.js +2 -2
- package/lib/store/ArrayStore.d.ts +21 -0
- package/lib/store/Store.d.ts +1 -7
- package/lib/store/index.cjs +1 -1
- package/lib/store/index.d.ts +2 -2
- package/lib/store/index.js +65 -139
- package/lib/tags-BqJKcIve.js +485 -0
- package/lib/tags-ld5jemJw.cjs +1 -0
- package/lib/theme/index.cjs +1 -1
- package/lib/theme/index.js +2 -2
- package/lib/tweaker/TweakerBooleanManagerElement.d.ts +1 -1
- package/lib/tweaker/TweakerColorManagerElement.d.ts +1 -1
- package/lib/tweaker/TweakerFolderElement.d.ts +2 -0
- package/lib/tweaker/TweakerLinkManagerElement.d.ts +1 -1
- package/lib/tweaker/TweakerNumberManagerElement.d.ts +4 -8
- package/lib/tweaker/TweakerSelectManagerElement.d.ts +1 -1
- package/lib/tweaker/TweakerStoreManagerElement.d.ts +7 -7
- package/lib/tweaker/TweakerStringManagerElement.d.ts +3 -5
- package/lib/tweaker/index.cjs +3 -3
- package/lib/tweaker/index.js +535 -412
- package/lib/tweaker/tweakerManagerConstructors.d.ts +2 -2
- package/lib/tweaker/tweakerStorage.d.ts +8 -1
- package/lib/url-C3dWnJQg.cjs +1 -0
- package/lib/url-DMNfW7uN.js +22 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +39 -34
- package/lib/utils/number.d.ts +1 -0
- package/lib/utils/url.d.ts +9 -0
- package/lib/video/index.cjs +1 -1
- package/lib/video/index.js +1 -1
- package/package.json +107 -3
- package/lib/Animation-DDHjrbtL.cjs +0 -1
- package/lib/Animation-Dq_05jlR.js +0 -217
- package/lib/DRACOLoader-C2CFpMGS.cjs +0 -2
- package/lib/DRACOLoader-D2KY2dku.js +0 -241
- package/lib/Damped-l0mnlhar.cjs +0 -1
- package/lib/KTX2Loader-DdUl1XiY.cjs +0 -2
- package/lib/KTX2Loader-DqpAffDj.js +0 -536
- package/lib/Store-C-1ruEIm.cjs +0 -1
- package/lib/Tweened-CwDC2zl8.js +0 -51
- package/lib/Tweened-DIt9j9B-.cjs +0 -1
- package/lib/animation/AnimationLink.d.ts +0 -13
- package/lib/en3/loaders/en3TextureLoader.d.ts +0 -3
- package/lib/en3/test/En3HTML.d.ts +0 -10
- package/lib/polyfills-BA-CL_HF.js +0 -27
- package/lib/polyfills-DHs2SNbz.cjs +0 -1
- package/lib/store/CumulativeResource.d.ts +0 -13
- package/lib/tags-CMPg9ETZ.js +0 -848
- package/lib/tags-Djb6mb1o.cjs +0 -1
- package/lib/tweaker/TweakerRangeManagerElement.d.ts +0 -11
- /package/lib/en3/{loaders → core}/en3Cache.d.ts +0 -0
- /package/lib/{MeshoptDecoder-CMeN3oU0.cjs → en3/libs/index.cjs} +0 -0
- /package/lib/{MeshoptDecoder-6XfTpOG2.js → en3/libs/index.js} +0 -0
- /package/lib/en3/{test → misc}/En3ModifiedMaterial.d.ts +0 -0
- /package/lib/en3/{attachments → misc}/En3SourceManager.d.ts +0 -0
|
@@ -0,0 +1,1757 @@
|
|
|
1
|
+
var ce = (d, t, e) => {
|
|
2
|
+
if (!t.has(d))
|
|
3
|
+
throw TypeError("Cannot " + e);
|
|
4
|
+
};
|
|
5
|
+
var S = (d, t, e) => (ce(d, t, "read from private field"), e ? e.call(d) : t.get(d)), j = (d, t, e) => {
|
|
6
|
+
if (t.has(d))
|
|
7
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
+
t instanceof WeakSet ? t.add(d) : t.set(d, e);
|
|
9
|
+
}, Z = (d, t, e, r) => (ce(d, t, "write to private field"), r ? r.call(d, e) : t.set(d, e), e);
|
|
10
|
+
var ue = (d, t, e) => new Promise((r, n) => {
|
|
11
|
+
var s = (o) => {
|
|
12
|
+
try {
|
|
13
|
+
a(e.next(o));
|
|
14
|
+
} catch (c) {
|
|
15
|
+
n(c);
|
|
16
|
+
}
|
|
17
|
+
}, i = (o) => {
|
|
18
|
+
try {
|
|
19
|
+
a(e.throw(o));
|
|
20
|
+
} catch (c) {
|
|
21
|
+
n(c);
|
|
22
|
+
}
|
|
23
|
+
}, a = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(s, i);
|
|
24
|
+
a((e = e.apply(d, t)).next());
|
|
25
|
+
});
|
|
26
|
+
import { TrianglesDrawMode as De, TriangleFanDrawMode as re, TriangleStripDrawMode as Ee, Loader as Fe, LoaderUtils as X, FileLoader as Le, Color as G, LinearSRGBColorSpace as I, SpotLight as Pe, PointLight as ke, DirectionalLight as He, MeshBasicMaterial as V, SRGBColorSpace as z, MeshPhysicalMaterial as y, Vector2 as _e, Matrix4 as Y, Vector3 as B, Quaternion as Se, InstancedMesh as Ge, InstancedBufferAttribute as Be, Object3D as Me, TextureLoader as ye, ImageBitmapLoader as Ue, BufferAttribute as J, InterleavedBuffer as ve, InterleavedBufferAttribute as je, LinearFilter as we, LinearMipmapLinearFilter as be, RepeatWrapping as ie, PointsMaterial as Ke, Material as $, LineBasicMaterial as Ve, MeshStandardMaterial as Ne, DoubleSide as Xe, PropertyBinding as ze, BufferGeometry as qe, SkinnedMesh as We, Mesh as Ye, LineSegments as Qe, Line as Ze, LineLoop as Je, Points as $e, Group as ee, PerspectiveCamera as et, MathUtils as tt, OrthographicCamera as nt, Skeleton as st, AnimationClip as rt, Bone as it, InterpolateLinear as Ie, ColorManagement as le, NearestFilter as ot, NearestMipmapNearestFilter as at, LinearMipmapNearestFilter as ct, NearestMipmapLinearFilter as ut, ClampToEdgeWrapping as lt, MirroredRepeatWrapping as dt, InterpolateDiscrete as ft, FrontSide as ht, Texture as de, VectorKeyframeTrack as fe, NumberKeyframeTrack as he, QuaternionKeyframeTrack as pe, Box3 as pt, Sphere as mt, Interpolant as At } from "three";
|
|
27
|
+
import { e as N, a as b, d as me } from "../../en3-hbkN1OPu.js";
|
|
28
|
+
function Ae(d, t) {
|
|
29
|
+
if (t === De)
|
|
30
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
|
|
31
|
+
if (t === re || t === Ee) {
|
|
32
|
+
let e = d.getIndex();
|
|
33
|
+
if (e === null) {
|
|
34
|
+
const i = [], a = d.getAttribute("position");
|
|
35
|
+
if (a !== void 0) {
|
|
36
|
+
for (let o = 0; o < a.count; o++)
|
|
37
|
+
i.push(o);
|
|
38
|
+
d.setIndex(i), e = d.getIndex();
|
|
39
|
+
} else
|
|
40
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), d;
|
|
41
|
+
}
|
|
42
|
+
const r = e.count - 2, n = [];
|
|
43
|
+
if (t === re)
|
|
44
|
+
for (let i = 1; i <= r; i++)
|
|
45
|
+
n.push(e.getX(0)), n.push(e.getX(i)), n.push(e.getX(i + 1));
|
|
46
|
+
else
|
|
47
|
+
for (let i = 0; i < r; i++)
|
|
48
|
+
i % 2 === 0 ? (n.push(e.getX(i)), n.push(e.getX(i + 1)), n.push(e.getX(i + 2))) : (n.push(e.getX(i + 2)), n.push(e.getX(i + 1)), n.push(e.getX(i)));
|
|
49
|
+
n.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
50
|
+
const s = d.clone();
|
|
51
|
+
return s.setIndex(n), s.clearGroups(), s;
|
|
52
|
+
} else
|
|
53
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", t), d;
|
|
54
|
+
}
|
|
55
|
+
class gt extends Fe {
|
|
56
|
+
constructor(t) {
|
|
57
|
+
super(t), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
58
|
+
return new Lt(e);
|
|
59
|
+
}), this.register(function(e) {
|
|
60
|
+
return new _t(e);
|
|
61
|
+
}), this.register(function(e) {
|
|
62
|
+
return new Ct(e);
|
|
63
|
+
}), this.register(function(e) {
|
|
64
|
+
return new Dt(e);
|
|
65
|
+
}), this.register(function(e) {
|
|
66
|
+
return new Ft(e);
|
|
67
|
+
}), this.register(function(e) {
|
|
68
|
+
return new Mt(e);
|
|
69
|
+
}), this.register(function(e) {
|
|
70
|
+
return new yt(e);
|
|
71
|
+
}), this.register(function(e) {
|
|
72
|
+
return new wt(e);
|
|
73
|
+
}), this.register(function(e) {
|
|
74
|
+
return new bt(e);
|
|
75
|
+
}), this.register(function(e) {
|
|
76
|
+
return new Et(e);
|
|
77
|
+
}), this.register(function(e) {
|
|
78
|
+
return new Nt(e);
|
|
79
|
+
}), this.register(function(e) {
|
|
80
|
+
return new St(e);
|
|
81
|
+
}), this.register(function(e) {
|
|
82
|
+
return new Ot(e);
|
|
83
|
+
}), this.register(function(e) {
|
|
84
|
+
return new It(e);
|
|
85
|
+
}), this.register(function(e) {
|
|
86
|
+
return new xt(e);
|
|
87
|
+
}), this.register(function(e) {
|
|
88
|
+
return new Pt(e);
|
|
89
|
+
}), this.register(function(e) {
|
|
90
|
+
return new kt(e);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
load(t, e, r, n) {
|
|
94
|
+
const s = this;
|
|
95
|
+
let i;
|
|
96
|
+
if (this.resourcePath !== "")
|
|
97
|
+
i = this.resourcePath;
|
|
98
|
+
else if (this.path !== "") {
|
|
99
|
+
const c = X.extractUrlBase(t);
|
|
100
|
+
i = X.resolveURL(c, this.path);
|
|
101
|
+
} else
|
|
102
|
+
i = X.extractUrlBase(t);
|
|
103
|
+
this.manager.itemStart(t);
|
|
104
|
+
const a = function(c) {
|
|
105
|
+
n ? n(c) : console.error(c), s.manager.itemError(t), s.manager.itemEnd(t);
|
|
106
|
+
}, o = new Le(this.manager);
|
|
107
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(t, function(c) {
|
|
108
|
+
try {
|
|
109
|
+
s.parse(c, i, function(l) {
|
|
110
|
+
e(l), s.manager.itemEnd(t);
|
|
111
|
+
}, a);
|
|
112
|
+
} catch (l) {
|
|
113
|
+
a(l);
|
|
114
|
+
}
|
|
115
|
+
}, r, a);
|
|
116
|
+
}
|
|
117
|
+
setDRACOLoader(t) {
|
|
118
|
+
return this.dracoLoader = t, this;
|
|
119
|
+
}
|
|
120
|
+
setDDSLoader() {
|
|
121
|
+
throw new Error(
|
|
122
|
+
'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".'
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
setKTX2Loader(t) {
|
|
126
|
+
return this.ktx2Loader = t, this;
|
|
127
|
+
}
|
|
128
|
+
setMeshoptDecoder(t) {
|
|
129
|
+
return this.meshoptDecoder = t, this;
|
|
130
|
+
}
|
|
131
|
+
register(t) {
|
|
132
|
+
return this.pluginCallbacks.indexOf(t) === -1 && this.pluginCallbacks.push(t), this;
|
|
133
|
+
}
|
|
134
|
+
unregister(t) {
|
|
135
|
+
return this.pluginCallbacks.indexOf(t) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t), 1), this;
|
|
136
|
+
}
|
|
137
|
+
parse(t, e, r, n) {
|
|
138
|
+
let s;
|
|
139
|
+
const i = {}, a = {}, o = new TextDecoder();
|
|
140
|
+
if (typeof t == "string")
|
|
141
|
+
s = JSON.parse(t);
|
|
142
|
+
else if (t instanceof ArrayBuffer)
|
|
143
|
+
if (o.decode(new Uint8Array(t, 0, 4)) === Oe) {
|
|
144
|
+
try {
|
|
145
|
+
i[A.KHR_BINARY_GLTF] = new Ht(t);
|
|
146
|
+
} catch (u) {
|
|
147
|
+
n && n(u);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
s = JSON.parse(i[A.KHR_BINARY_GLTF].content);
|
|
151
|
+
} else
|
|
152
|
+
s = JSON.parse(o.decode(t));
|
|
153
|
+
else
|
|
154
|
+
s = t;
|
|
155
|
+
if (s.asset === void 0 || s.asset.version[0] < 2) {
|
|
156
|
+
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const c = new Qt(s, {
|
|
160
|
+
path: e || this.resourcePath || "",
|
|
161
|
+
crossOrigin: this.crossOrigin,
|
|
162
|
+
requestHeader: this.requestHeader,
|
|
163
|
+
manager: this.manager,
|
|
164
|
+
ktx2Loader: this.ktx2Loader,
|
|
165
|
+
meshoptDecoder: this.meshoptDecoder
|
|
166
|
+
});
|
|
167
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
168
|
+
for (let l = 0; l < this.pluginCallbacks.length; l++) {
|
|
169
|
+
const u = this.pluginCallbacks[l](c);
|
|
170
|
+
u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[u.name] = u, i[u.name] = !0;
|
|
171
|
+
}
|
|
172
|
+
if (s.extensionsUsed)
|
|
173
|
+
for (let l = 0; l < s.extensionsUsed.length; ++l) {
|
|
174
|
+
const u = s.extensionsUsed[l], f = s.extensionsRequired || [];
|
|
175
|
+
switch (u) {
|
|
176
|
+
case A.KHR_MATERIALS_UNLIT:
|
|
177
|
+
i[u] = new Rt();
|
|
178
|
+
break;
|
|
179
|
+
case A.KHR_DRACO_MESH_COMPRESSION:
|
|
180
|
+
i[u] = new Gt(s, this.dracoLoader);
|
|
181
|
+
break;
|
|
182
|
+
case A.KHR_TEXTURE_TRANSFORM:
|
|
183
|
+
i[u] = new Bt();
|
|
184
|
+
break;
|
|
185
|
+
case A.KHR_MESH_QUANTIZATION:
|
|
186
|
+
i[u] = new Ut();
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
f.indexOf(u) >= 0 && a[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
c.setExtensions(i), c.setPlugins(a), c.parse(r, n);
|
|
193
|
+
}
|
|
194
|
+
parseAsync(t, e) {
|
|
195
|
+
const r = this;
|
|
196
|
+
return new Promise(function(n, s) {
|
|
197
|
+
r.parse(t, e, n, s);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function Tt() {
|
|
202
|
+
let d = {};
|
|
203
|
+
return {
|
|
204
|
+
get: function(t) {
|
|
205
|
+
return d[t];
|
|
206
|
+
},
|
|
207
|
+
add: function(t, e) {
|
|
208
|
+
d[t] = e;
|
|
209
|
+
},
|
|
210
|
+
remove: function(t) {
|
|
211
|
+
delete d[t];
|
|
212
|
+
},
|
|
213
|
+
removeAll: function() {
|
|
214
|
+
d = {};
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const A = {
|
|
219
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
220
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
221
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
222
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
223
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
224
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
225
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
226
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
227
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
228
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
229
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
230
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
231
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
232
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
233
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
234
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
235
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
236
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
237
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
238
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
239
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
240
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
241
|
+
};
|
|
242
|
+
class xt {
|
|
243
|
+
constructor(t) {
|
|
244
|
+
this.parser = t, this.name = A.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
245
|
+
}
|
|
246
|
+
_markDefs() {
|
|
247
|
+
const t = this.parser, e = this.parser.json.nodes || [];
|
|
248
|
+
for (let r = 0, n = e.length; r < n; r++) {
|
|
249
|
+
const s = e[r];
|
|
250
|
+
s.extensions && s.extensions[this.name] && s.extensions[this.name].light !== void 0 && t._addNodeRef(this.cache, s.extensions[this.name].light);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
_loadLight(t) {
|
|
254
|
+
const e = this.parser, r = "light:" + t;
|
|
255
|
+
let n = e.cache.get(r);
|
|
256
|
+
if (n)
|
|
257
|
+
return n;
|
|
258
|
+
const s = e.json, o = ((s.extensions && s.extensions[this.name] || {}).lights || [])[t];
|
|
259
|
+
let c;
|
|
260
|
+
const l = new G(16777215);
|
|
261
|
+
o.color !== void 0 && l.setRGB(o.color[0], o.color[1], o.color[2], I);
|
|
262
|
+
const u = o.range !== void 0 ? o.range : 0;
|
|
263
|
+
switch (o.type) {
|
|
264
|
+
case "directional":
|
|
265
|
+
c = new He(l), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
266
|
+
break;
|
|
267
|
+
case "point":
|
|
268
|
+
c = new ke(l), c.distance = u;
|
|
269
|
+
break;
|
|
270
|
+
case "spot":
|
|
271
|
+
c = new Pe(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);
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + o.type);
|
|
275
|
+
}
|
|
276
|
+
return c.position.set(0, 0, 0), c.decay = 2, w(c, o), o.intensity !== void 0 && (c.intensity = o.intensity), c.name = e.createUniqueName(o.name || "light_" + t), n = Promise.resolve(c), e.cache.add(r, n), n;
|
|
277
|
+
}
|
|
278
|
+
getDependency(t, e) {
|
|
279
|
+
if (t === "light")
|
|
280
|
+
return this._loadLight(e);
|
|
281
|
+
}
|
|
282
|
+
createNodeAttachment(t) {
|
|
283
|
+
const e = this, r = this.parser, s = r.json.nodes[t], a = (s.extensions && s.extensions[this.name] || {}).light;
|
|
284
|
+
return a === void 0 ? null : this._loadLight(a).then(function(o) {
|
|
285
|
+
return r._getNodeRef(e.cache, a, o);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
class Rt {
|
|
290
|
+
constructor() {
|
|
291
|
+
this.name = A.KHR_MATERIALS_UNLIT;
|
|
292
|
+
}
|
|
293
|
+
getMaterialType() {
|
|
294
|
+
return V;
|
|
295
|
+
}
|
|
296
|
+
extendParams(t, e, r) {
|
|
297
|
+
const n = [];
|
|
298
|
+
t.color = new G(1, 1, 1), t.opacity = 1;
|
|
299
|
+
const s = e.pbrMetallicRoughness;
|
|
300
|
+
if (s) {
|
|
301
|
+
if (Array.isArray(s.baseColorFactor)) {
|
|
302
|
+
const i = s.baseColorFactor;
|
|
303
|
+
t.color.setRGB(i[0], i[1], i[2], I), t.opacity = i[3];
|
|
304
|
+
}
|
|
305
|
+
s.baseColorTexture !== void 0 && n.push(r.assignTexture(t, "map", s.baseColorTexture, z));
|
|
306
|
+
}
|
|
307
|
+
return Promise.all(n);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
class Et {
|
|
311
|
+
constructor(t) {
|
|
312
|
+
this.parser = t, this.name = A.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
313
|
+
}
|
|
314
|
+
extendMaterialParams(t, e) {
|
|
315
|
+
const n = this.parser.json.materials[t];
|
|
316
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
317
|
+
return Promise.resolve();
|
|
318
|
+
const s = n.extensions[this.name].emissiveStrength;
|
|
319
|
+
return s !== void 0 && (e.emissiveIntensity = s), Promise.resolve();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
class Lt {
|
|
323
|
+
constructor(t) {
|
|
324
|
+
this.parser = t, this.name = A.KHR_MATERIALS_CLEARCOAT;
|
|
325
|
+
}
|
|
326
|
+
getMaterialType(t) {
|
|
327
|
+
const r = this.parser.json.materials[t];
|
|
328
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
329
|
+
}
|
|
330
|
+
extendMaterialParams(t, e) {
|
|
331
|
+
const r = this.parser, n = r.json.materials[t];
|
|
332
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
333
|
+
return Promise.resolve();
|
|
334
|
+
const s = [], i = n.extensions[this.name];
|
|
335
|
+
if (i.clearcoatFactor !== void 0 && (e.clearcoat = i.clearcoatFactor), i.clearcoatTexture !== void 0 && s.push(r.assignTexture(e, "clearcoatMap", i.clearcoatTexture)), i.clearcoatRoughnessFactor !== void 0 && (e.clearcoatRoughness = i.clearcoatRoughnessFactor), i.clearcoatRoughnessTexture !== void 0 && s.push(r.assignTexture(e, "clearcoatRoughnessMap", i.clearcoatRoughnessTexture)), i.clearcoatNormalTexture !== void 0 && (s.push(r.assignTexture(e, "clearcoatNormalMap", i.clearcoatNormalTexture)), i.clearcoatNormalTexture.scale !== void 0)) {
|
|
336
|
+
const a = i.clearcoatNormalTexture.scale;
|
|
337
|
+
e.clearcoatNormalScale = new _e(a, a);
|
|
338
|
+
}
|
|
339
|
+
return Promise.all(s);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
class _t {
|
|
343
|
+
constructor(t) {
|
|
344
|
+
this.parser = t, this.name = A.KHR_MATERIALS_DISPERSION;
|
|
345
|
+
}
|
|
346
|
+
getMaterialType(t) {
|
|
347
|
+
const r = this.parser.json.materials[t];
|
|
348
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
349
|
+
}
|
|
350
|
+
extendMaterialParams(t, e) {
|
|
351
|
+
const n = this.parser.json.materials[t];
|
|
352
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
353
|
+
return Promise.resolve();
|
|
354
|
+
const s = n.extensions[this.name];
|
|
355
|
+
return e.dispersion = s.dispersion !== void 0 ? s.dispersion : 0, Promise.resolve();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
class St {
|
|
359
|
+
constructor(t) {
|
|
360
|
+
this.parser = t, this.name = A.KHR_MATERIALS_IRIDESCENCE;
|
|
361
|
+
}
|
|
362
|
+
getMaterialType(t) {
|
|
363
|
+
const r = this.parser.json.materials[t];
|
|
364
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
365
|
+
}
|
|
366
|
+
extendMaterialParams(t, e) {
|
|
367
|
+
const r = this.parser, n = r.json.materials[t];
|
|
368
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
369
|
+
return Promise.resolve();
|
|
370
|
+
const s = [], i = n.extensions[this.name];
|
|
371
|
+
return i.iridescenceFactor !== void 0 && (e.iridescence = i.iridescenceFactor), i.iridescenceTexture !== void 0 && s.push(r.assignTexture(e, "iridescenceMap", i.iridescenceTexture)), i.iridescenceIor !== void 0 && (e.iridescenceIOR = i.iridescenceIor), e.iridescenceThicknessRange === void 0 && (e.iridescenceThicknessRange = [100, 400]), i.iridescenceThicknessMinimum !== void 0 && (e.iridescenceThicknessRange[0] = i.iridescenceThicknessMinimum), i.iridescenceThicknessMaximum !== void 0 && (e.iridescenceThicknessRange[1] = i.iridescenceThicknessMaximum), i.iridescenceThicknessTexture !== void 0 && s.push(r.assignTexture(e, "iridescenceThicknessMap", i.iridescenceThicknessTexture)), Promise.all(s);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
class Mt {
|
|
375
|
+
constructor(t) {
|
|
376
|
+
this.parser = t, this.name = A.KHR_MATERIALS_SHEEN;
|
|
377
|
+
}
|
|
378
|
+
getMaterialType(t) {
|
|
379
|
+
const r = this.parser.json.materials[t];
|
|
380
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
381
|
+
}
|
|
382
|
+
extendMaterialParams(t, e) {
|
|
383
|
+
const r = this.parser, n = r.json.materials[t];
|
|
384
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
385
|
+
return Promise.resolve();
|
|
386
|
+
const s = [];
|
|
387
|
+
e.sheenColor = new G(0, 0, 0), e.sheenRoughness = 0, e.sheen = 1;
|
|
388
|
+
const i = n.extensions[this.name];
|
|
389
|
+
if (i.sheenColorFactor !== void 0) {
|
|
390
|
+
const a = i.sheenColorFactor;
|
|
391
|
+
e.sheenColor.setRGB(a[0], a[1], a[2], I);
|
|
392
|
+
}
|
|
393
|
+
return i.sheenRoughnessFactor !== void 0 && (e.sheenRoughness = i.sheenRoughnessFactor), i.sheenColorTexture !== void 0 && s.push(r.assignTexture(e, "sheenColorMap", i.sheenColorTexture, z)), i.sheenRoughnessTexture !== void 0 && s.push(r.assignTexture(e, "sheenRoughnessMap", i.sheenRoughnessTexture)), Promise.all(s);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class yt {
|
|
397
|
+
constructor(t) {
|
|
398
|
+
this.parser = t, this.name = A.KHR_MATERIALS_TRANSMISSION;
|
|
399
|
+
}
|
|
400
|
+
getMaterialType(t) {
|
|
401
|
+
const r = this.parser.json.materials[t];
|
|
402
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
403
|
+
}
|
|
404
|
+
extendMaterialParams(t, e) {
|
|
405
|
+
const r = this.parser, n = r.json.materials[t];
|
|
406
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
407
|
+
return Promise.resolve();
|
|
408
|
+
const s = [], i = n.extensions[this.name];
|
|
409
|
+
return i.transmissionFactor !== void 0 && (e.transmission = i.transmissionFactor), i.transmissionTexture !== void 0 && s.push(r.assignTexture(e, "transmissionMap", i.transmissionTexture)), Promise.all(s);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
class wt {
|
|
413
|
+
constructor(t) {
|
|
414
|
+
this.parser = t, this.name = A.KHR_MATERIALS_VOLUME;
|
|
415
|
+
}
|
|
416
|
+
getMaterialType(t) {
|
|
417
|
+
const r = this.parser.json.materials[t];
|
|
418
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
419
|
+
}
|
|
420
|
+
extendMaterialParams(t, e) {
|
|
421
|
+
const r = this.parser, n = r.json.materials[t];
|
|
422
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
423
|
+
return Promise.resolve();
|
|
424
|
+
const s = [], i = n.extensions[this.name];
|
|
425
|
+
e.thickness = i.thicknessFactor !== void 0 ? i.thicknessFactor : 0, i.thicknessTexture !== void 0 && s.push(r.assignTexture(e, "thicknessMap", i.thicknessTexture)), e.attenuationDistance = i.attenuationDistance || 1 / 0;
|
|
426
|
+
const a = i.attenuationColor || [1, 1, 1];
|
|
427
|
+
return e.attenuationColor = new G().setRGB(a[0], a[1], a[2], I), Promise.all(s);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
class bt {
|
|
431
|
+
constructor(t) {
|
|
432
|
+
this.parser = t, this.name = A.KHR_MATERIALS_IOR;
|
|
433
|
+
}
|
|
434
|
+
getMaterialType(t) {
|
|
435
|
+
const r = this.parser.json.materials[t];
|
|
436
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
437
|
+
}
|
|
438
|
+
extendMaterialParams(t, e) {
|
|
439
|
+
const n = this.parser.json.materials[t];
|
|
440
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
441
|
+
return Promise.resolve();
|
|
442
|
+
const s = n.extensions[this.name];
|
|
443
|
+
return e.ior = s.ior !== void 0 ? s.ior : 1.5, Promise.resolve();
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
class Nt {
|
|
447
|
+
constructor(t) {
|
|
448
|
+
this.parser = t, this.name = A.KHR_MATERIALS_SPECULAR;
|
|
449
|
+
}
|
|
450
|
+
getMaterialType(t) {
|
|
451
|
+
const r = this.parser.json.materials[t];
|
|
452
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
453
|
+
}
|
|
454
|
+
extendMaterialParams(t, e) {
|
|
455
|
+
const r = this.parser, n = r.json.materials[t];
|
|
456
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
457
|
+
return Promise.resolve();
|
|
458
|
+
const s = [], i = n.extensions[this.name];
|
|
459
|
+
e.specularIntensity = i.specularFactor !== void 0 ? i.specularFactor : 1, i.specularTexture !== void 0 && s.push(r.assignTexture(e, "specularIntensityMap", i.specularTexture));
|
|
460
|
+
const a = i.specularColorFactor || [1, 1, 1];
|
|
461
|
+
return e.specularColor = new G().setRGB(a[0], a[1], a[2], I), i.specularColorTexture !== void 0 && s.push(r.assignTexture(e, "specularColorMap", i.specularColorTexture, z)), Promise.all(s);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
class It {
|
|
465
|
+
constructor(t) {
|
|
466
|
+
this.parser = t, this.name = A.EXT_MATERIALS_BUMP;
|
|
467
|
+
}
|
|
468
|
+
getMaterialType(t) {
|
|
469
|
+
const r = this.parser.json.materials[t];
|
|
470
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
471
|
+
}
|
|
472
|
+
extendMaterialParams(t, e) {
|
|
473
|
+
const r = this.parser, n = r.json.materials[t];
|
|
474
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
475
|
+
return Promise.resolve();
|
|
476
|
+
const s = [], i = n.extensions[this.name];
|
|
477
|
+
return e.bumpScale = i.bumpFactor !== void 0 ? i.bumpFactor : 1, i.bumpTexture !== void 0 && s.push(r.assignTexture(e, "bumpMap", i.bumpTexture)), Promise.all(s);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
class Ot {
|
|
481
|
+
constructor(t) {
|
|
482
|
+
this.parser = t, this.name = A.KHR_MATERIALS_ANISOTROPY;
|
|
483
|
+
}
|
|
484
|
+
getMaterialType(t) {
|
|
485
|
+
const r = this.parser.json.materials[t];
|
|
486
|
+
return !r.extensions || !r.extensions[this.name] ? null : y;
|
|
487
|
+
}
|
|
488
|
+
extendMaterialParams(t, e) {
|
|
489
|
+
const r = this.parser, n = r.json.materials[t];
|
|
490
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
491
|
+
return Promise.resolve();
|
|
492
|
+
const s = [], i = n.extensions[this.name];
|
|
493
|
+
return i.anisotropyStrength !== void 0 && (e.anisotropy = i.anisotropyStrength), i.anisotropyRotation !== void 0 && (e.anisotropyRotation = i.anisotropyRotation), i.anisotropyTexture !== void 0 && s.push(r.assignTexture(e, "anisotropyMap", i.anisotropyTexture)), Promise.all(s);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
class Ct {
|
|
497
|
+
constructor(t) {
|
|
498
|
+
this.parser = t, this.name = A.KHR_TEXTURE_BASISU;
|
|
499
|
+
}
|
|
500
|
+
loadTexture(t) {
|
|
501
|
+
const e = this.parser, r = e.json, n = r.textures[t];
|
|
502
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
503
|
+
return null;
|
|
504
|
+
const s = n.extensions[this.name], i = e.options.ktx2Loader;
|
|
505
|
+
if (!i) {
|
|
506
|
+
if (r.extensionsRequired && r.extensionsRequired.indexOf(this.name) >= 0)
|
|
507
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
return e.loadTextureImage(t, s.source, i);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
class Dt {
|
|
514
|
+
constructor(t) {
|
|
515
|
+
this.parser = t, this.name = A.EXT_TEXTURE_WEBP, this.isSupported = null;
|
|
516
|
+
}
|
|
517
|
+
loadTexture(t) {
|
|
518
|
+
const e = this.name, r = this.parser, n = r.json, s = n.textures[t];
|
|
519
|
+
if (!s.extensions || !s.extensions[e])
|
|
520
|
+
return null;
|
|
521
|
+
const i = s.extensions[e], a = n.images[i.source];
|
|
522
|
+
let o = r.textureLoader;
|
|
523
|
+
if (a.uri) {
|
|
524
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
525
|
+
c !== null && (o = c);
|
|
526
|
+
}
|
|
527
|
+
return this.detectSupport().then(function(c) {
|
|
528
|
+
if (c)
|
|
529
|
+
return r.loadTextureImage(t, i.source, o);
|
|
530
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(e) >= 0)
|
|
531
|
+
throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
|
|
532
|
+
return r.loadTexture(t);
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
detectSupport() {
|
|
536
|
+
return this.isSupported || (this.isSupported = new Promise(function(t) {
|
|
537
|
+
const e = new Image();
|
|
538
|
+
e.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", e.onload = e.onerror = function() {
|
|
539
|
+
t(e.height === 1);
|
|
540
|
+
};
|
|
541
|
+
})), this.isSupported;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
class Ft {
|
|
545
|
+
constructor(t) {
|
|
546
|
+
this.parser = t, this.name = A.EXT_TEXTURE_AVIF, this.isSupported = null;
|
|
547
|
+
}
|
|
548
|
+
loadTexture(t) {
|
|
549
|
+
const e = this.name, r = this.parser, n = r.json, s = n.textures[t];
|
|
550
|
+
if (!s.extensions || !s.extensions[e])
|
|
551
|
+
return null;
|
|
552
|
+
const i = s.extensions[e], a = n.images[i.source];
|
|
553
|
+
let o = r.textureLoader;
|
|
554
|
+
if (a.uri) {
|
|
555
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
556
|
+
c !== null && (o = c);
|
|
557
|
+
}
|
|
558
|
+
return this.detectSupport().then(function(c) {
|
|
559
|
+
if (c)
|
|
560
|
+
return r.loadTextureImage(t, i.source, o);
|
|
561
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(e) >= 0)
|
|
562
|
+
throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
|
|
563
|
+
return r.loadTexture(t);
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
detectSupport() {
|
|
567
|
+
return this.isSupported || (this.isSupported = new Promise(function(t) {
|
|
568
|
+
const e = new Image();
|
|
569
|
+
e.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", e.onload = e.onerror = function() {
|
|
570
|
+
t(e.height === 1);
|
|
571
|
+
};
|
|
572
|
+
})), this.isSupported;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
class Pt {
|
|
576
|
+
constructor(t) {
|
|
577
|
+
this.name = A.EXT_MESHOPT_COMPRESSION, this.parser = t;
|
|
578
|
+
}
|
|
579
|
+
loadBufferView(t) {
|
|
580
|
+
const e = this.parser.json, r = e.bufferViews[t];
|
|
581
|
+
if (r.extensions && r.extensions[this.name]) {
|
|
582
|
+
const n = r.extensions[this.name], s = this.parser.getDependency("buffer", n.buffer), i = this.parser.options.meshoptDecoder;
|
|
583
|
+
if (!i || !i.supported) {
|
|
584
|
+
if (e.extensionsRequired && e.extensionsRequired.indexOf(this.name) >= 0)
|
|
585
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
return s.then(function(a) {
|
|
589
|
+
const o = n.byteOffset || 0, c = n.byteLength || 0, l = n.count, u = n.byteStride, f = new Uint8Array(a, o, c);
|
|
590
|
+
return i.decodeGltfBufferAsync ? i.decodeGltfBufferAsync(l, u, f, n.mode, n.filter).then(function(h) {
|
|
591
|
+
return h.buffer;
|
|
592
|
+
}) : i.ready.then(function() {
|
|
593
|
+
const h = new ArrayBuffer(l * u);
|
|
594
|
+
return i.decodeGltfBuffer(new Uint8Array(h), l, u, f, n.mode, n.filter), h;
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
} else
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
class kt {
|
|
602
|
+
constructor(t) {
|
|
603
|
+
this.name = A.EXT_MESH_GPU_INSTANCING, this.parser = t;
|
|
604
|
+
}
|
|
605
|
+
createNodeMesh(t) {
|
|
606
|
+
const e = this.parser.json, r = e.nodes[t];
|
|
607
|
+
if (!r.extensions || !r.extensions[this.name] || r.mesh === void 0)
|
|
608
|
+
return null;
|
|
609
|
+
const n = e.meshes[r.mesh];
|
|
610
|
+
for (const c of n.primitives)
|
|
611
|
+
if (c.mode !== L.TRIANGLES && c.mode !== L.TRIANGLE_STRIP && c.mode !== L.TRIANGLE_FAN && c.mode !== void 0)
|
|
612
|
+
return null;
|
|
613
|
+
const i = r.extensions[this.name].attributes, a = [], o = {};
|
|
614
|
+
for (const c in i)
|
|
615
|
+
a.push(this.parser.getDependency("accessor", i[c]).then((l) => (o[c] = l, o[c])));
|
|
616
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(t)), Promise.all(a).then((c) => {
|
|
617
|
+
const l = c.pop(), u = l.isGroup ? l.children : [l], f = c[0].count, h = [];
|
|
618
|
+
for (const p of u) {
|
|
619
|
+
const T = new Y(), m = new B(), g = new Se(), R = new B(1, 1, 1), E = new Ge(p.geometry, p.material, f);
|
|
620
|
+
for (let x = 0; x < f; x++)
|
|
621
|
+
o.TRANSLATION && m.fromBufferAttribute(o.TRANSLATION, x), o.ROTATION && g.fromBufferAttribute(o.ROTATION, x), o.SCALE && R.fromBufferAttribute(o.SCALE, x), E.setMatrixAt(x, T.compose(m, g, R));
|
|
622
|
+
for (const x in o)
|
|
623
|
+
if (x === "_COLOR_0") {
|
|
624
|
+
const M = o[x];
|
|
625
|
+
E.instanceColor = new Be(M.array, M.itemSize, M.normalized);
|
|
626
|
+
} else
|
|
627
|
+
x !== "TRANSLATION" && x !== "ROTATION" && x !== "SCALE" && p.geometry.setAttribute(x, o[x]);
|
|
628
|
+
Me.prototype.copy.call(E, p), this.parser.assignFinalMaterial(E), h.push(E);
|
|
629
|
+
}
|
|
630
|
+
return l.isGroup ? (l.clear(), l.add(...h), l) : h[0];
|
|
631
|
+
}));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
const Oe = "glTF", K = 12, ge = { JSON: 1313821514, BIN: 5130562 };
|
|
635
|
+
class Ht {
|
|
636
|
+
constructor(t) {
|
|
637
|
+
this.name = A.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
638
|
+
const e = new DataView(t, 0, K), r = new TextDecoder();
|
|
639
|
+
if (this.header = {
|
|
640
|
+
magic: r.decode(new Uint8Array(t.slice(0, 4))),
|
|
641
|
+
version: e.getUint32(4, !0),
|
|
642
|
+
length: e.getUint32(8, !0)
|
|
643
|
+
}, this.header.magic !== Oe)
|
|
644
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
645
|
+
if (this.header.version < 2)
|
|
646
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
647
|
+
const n = this.header.length - K, s = new DataView(t, K);
|
|
648
|
+
let i = 0;
|
|
649
|
+
for (; i < n; ) {
|
|
650
|
+
const a = s.getUint32(i, !0);
|
|
651
|
+
i += 4;
|
|
652
|
+
const o = s.getUint32(i, !0);
|
|
653
|
+
if (i += 4, o === ge.JSON) {
|
|
654
|
+
const c = new Uint8Array(t, K + i, a);
|
|
655
|
+
this.content = r.decode(c);
|
|
656
|
+
} else if (o === ge.BIN) {
|
|
657
|
+
const c = K + i;
|
|
658
|
+
this.body = t.slice(c, c + a);
|
|
659
|
+
}
|
|
660
|
+
i += a;
|
|
661
|
+
}
|
|
662
|
+
if (this.content === null)
|
|
663
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
class Gt {
|
|
667
|
+
constructor(t, e) {
|
|
668
|
+
if (!e)
|
|
669
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
670
|
+
this.name = A.KHR_DRACO_MESH_COMPRESSION, this.json = t, this.dracoLoader = e, this.dracoLoader.preload();
|
|
671
|
+
}
|
|
672
|
+
decodePrimitive(t, e) {
|
|
673
|
+
const r = this.json, n = this.dracoLoader, s = t.extensions[this.name].bufferView, i = t.extensions[this.name].attributes, a = {}, o = {}, c = {};
|
|
674
|
+
for (const l in i) {
|
|
675
|
+
const u = oe[l] || l.toLowerCase();
|
|
676
|
+
a[u] = i[l];
|
|
677
|
+
}
|
|
678
|
+
for (const l in t.attributes) {
|
|
679
|
+
const u = oe[l] || l.toLowerCase();
|
|
680
|
+
if (i[l] !== void 0) {
|
|
681
|
+
const f = r.accessors[t.attributes[l]], h = U[f.componentType];
|
|
682
|
+
c[u] = h.name, o[u] = f.normalized === !0;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return e.getDependency("bufferView", s).then(function(l) {
|
|
686
|
+
return new Promise(function(u, f) {
|
|
687
|
+
n.decodeDracoFile(l, function(h) {
|
|
688
|
+
for (const p in h.attributes) {
|
|
689
|
+
const T = h.attributes[p], m = o[p];
|
|
690
|
+
m !== void 0 && (T.normalized = m);
|
|
691
|
+
}
|
|
692
|
+
u(h);
|
|
693
|
+
}, a, c, I, f);
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
class Bt {
|
|
699
|
+
constructor() {
|
|
700
|
+
this.name = A.KHR_TEXTURE_TRANSFORM;
|
|
701
|
+
}
|
|
702
|
+
extendTexture(t, e) {
|
|
703
|
+
return (e.texCoord === void 0 || e.texCoord === t.channel) && e.offset === void 0 && e.rotation === void 0 && e.scale === void 0 || (t = t.clone(), e.texCoord !== void 0 && (t.channel = e.texCoord), e.offset !== void 0 && t.offset.fromArray(e.offset), e.rotation !== void 0 && (t.rotation = e.rotation), e.scale !== void 0 && t.repeat.fromArray(e.scale), t.needsUpdate = !0), t;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
class Ut {
|
|
707
|
+
constructor() {
|
|
708
|
+
this.name = A.KHR_MESH_QUANTIZATION;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
class Ce extends At {
|
|
712
|
+
constructor(t, e, r, n) {
|
|
713
|
+
super(t, e, r, n);
|
|
714
|
+
}
|
|
715
|
+
copySampleValue_(t) {
|
|
716
|
+
const e = this.resultBuffer, r = this.sampleValues, n = this.valueSize, s = t * n * 3 + n;
|
|
717
|
+
for (let i = 0; i !== n; i++)
|
|
718
|
+
e[i] = r[s + i];
|
|
719
|
+
return e;
|
|
720
|
+
}
|
|
721
|
+
interpolate_(t, e, r, n) {
|
|
722
|
+
const s = this.resultBuffer, i = this.sampleValues, a = this.valueSize, o = a * 2, c = a * 3, l = n - e, u = (r - e) / l, f = u * u, h = f * u, p = t * c, T = p - c, m = -2 * h + 3 * f, g = h - f, R = 1 - m, E = g - f + u;
|
|
723
|
+
for (let x = 0; x !== a; x++) {
|
|
724
|
+
const M = i[T + x + a], O = i[T + x + o] * l, _ = i[p + x + a], v = i[p + x] * l;
|
|
725
|
+
s[x] = R * M + E * O + m * _ + g * v;
|
|
726
|
+
}
|
|
727
|
+
return s;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const vt = new Se();
|
|
731
|
+
class jt extends Ce {
|
|
732
|
+
interpolate_(t, e, r, n) {
|
|
733
|
+
const s = super.interpolate_(t, e, r, n);
|
|
734
|
+
return vt.fromArray(s).normalize().toArray(s), s;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
const L = {
|
|
738
|
+
FLOAT: 5126,
|
|
739
|
+
//FLOAT_MAT2: 35674,
|
|
740
|
+
FLOAT_MAT3: 35675,
|
|
741
|
+
FLOAT_MAT4: 35676,
|
|
742
|
+
FLOAT_VEC2: 35664,
|
|
743
|
+
FLOAT_VEC3: 35665,
|
|
744
|
+
FLOAT_VEC4: 35666,
|
|
745
|
+
LINEAR: 9729,
|
|
746
|
+
REPEAT: 10497,
|
|
747
|
+
SAMPLER_2D: 35678,
|
|
748
|
+
POINTS: 0,
|
|
749
|
+
LINES: 1,
|
|
750
|
+
LINE_LOOP: 2,
|
|
751
|
+
LINE_STRIP: 3,
|
|
752
|
+
TRIANGLES: 4,
|
|
753
|
+
TRIANGLE_STRIP: 5,
|
|
754
|
+
TRIANGLE_FAN: 6,
|
|
755
|
+
UNSIGNED_BYTE: 5121,
|
|
756
|
+
UNSIGNED_SHORT: 5123
|
|
757
|
+
}, U = {
|
|
758
|
+
5120: Int8Array,
|
|
759
|
+
5121: Uint8Array,
|
|
760
|
+
5122: Int16Array,
|
|
761
|
+
5123: Uint16Array,
|
|
762
|
+
5125: Uint32Array,
|
|
763
|
+
5126: Float32Array
|
|
764
|
+
}, Te = {
|
|
765
|
+
9728: ot,
|
|
766
|
+
9729: we,
|
|
767
|
+
9984: at,
|
|
768
|
+
9985: ct,
|
|
769
|
+
9986: ut,
|
|
770
|
+
9987: be
|
|
771
|
+
}, xe = {
|
|
772
|
+
33071: lt,
|
|
773
|
+
33648: dt,
|
|
774
|
+
10497: ie
|
|
775
|
+
}, te = {
|
|
776
|
+
SCALAR: 1,
|
|
777
|
+
VEC2: 2,
|
|
778
|
+
VEC3: 3,
|
|
779
|
+
VEC4: 4,
|
|
780
|
+
MAT2: 4,
|
|
781
|
+
MAT3: 9,
|
|
782
|
+
MAT4: 16
|
|
783
|
+
}, oe = {
|
|
784
|
+
POSITION: "position",
|
|
785
|
+
NORMAL: "normal",
|
|
786
|
+
TANGENT: "tangent",
|
|
787
|
+
TEXCOORD_0: "uv",
|
|
788
|
+
TEXCOORD_1: "uv1",
|
|
789
|
+
TEXCOORD_2: "uv2",
|
|
790
|
+
TEXCOORD_3: "uv3",
|
|
791
|
+
COLOR_0: "color",
|
|
792
|
+
WEIGHTS_0: "skinWeight",
|
|
793
|
+
JOINTS_0: "skinIndex"
|
|
794
|
+
}, D = {
|
|
795
|
+
scale: "scale",
|
|
796
|
+
translation: "position",
|
|
797
|
+
rotation: "quaternion",
|
|
798
|
+
weights: "morphTargetInfluences"
|
|
799
|
+
}, Kt = {
|
|
800
|
+
CUBICSPLINE: void 0,
|
|
801
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
802
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
803
|
+
LINEAR: Ie,
|
|
804
|
+
STEP: ft
|
|
805
|
+
}, ne = {
|
|
806
|
+
OPAQUE: "OPAQUE",
|
|
807
|
+
MASK: "MASK",
|
|
808
|
+
BLEND: "BLEND"
|
|
809
|
+
};
|
|
810
|
+
function Vt(d) {
|
|
811
|
+
return d.DefaultMaterial === void 0 && (d.DefaultMaterial = new Ne({
|
|
812
|
+
color: 16777215,
|
|
813
|
+
emissive: 0,
|
|
814
|
+
metalness: 1,
|
|
815
|
+
roughness: 1,
|
|
816
|
+
transparent: !1,
|
|
817
|
+
depthTest: !0,
|
|
818
|
+
side: ht
|
|
819
|
+
})), d.DefaultMaterial;
|
|
820
|
+
}
|
|
821
|
+
function P(d, t, e) {
|
|
822
|
+
for (const r in e.extensions)
|
|
823
|
+
d[r] === void 0 && (t.userData.gltfExtensions = t.userData.gltfExtensions || {}, t.userData.gltfExtensions[r] = e.extensions[r]);
|
|
824
|
+
}
|
|
825
|
+
function w(d, t) {
|
|
826
|
+
t.extras !== void 0 && (typeof t.extras == "object" ? Object.assign(d.userData, t.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + t.extras));
|
|
827
|
+
}
|
|
828
|
+
function Xt(d, t, e) {
|
|
829
|
+
let r = !1, n = !1, s = !1;
|
|
830
|
+
for (let c = 0, l = t.length; c < l; c++) {
|
|
831
|
+
const u = t[c];
|
|
832
|
+
if (u.POSITION !== void 0 && (r = !0), u.NORMAL !== void 0 && (n = !0), u.COLOR_0 !== void 0 && (s = !0), r && n && s)
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
if (!r && !n && !s)
|
|
836
|
+
return Promise.resolve(d);
|
|
837
|
+
const i = [], a = [], o = [];
|
|
838
|
+
for (let c = 0, l = t.length; c < l; c++) {
|
|
839
|
+
const u = t[c];
|
|
840
|
+
if (r) {
|
|
841
|
+
const f = u.POSITION !== void 0 ? e.getDependency("accessor", u.POSITION) : d.attributes.position;
|
|
842
|
+
i.push(f);
|
|
843
|
+
}
|
|
844
|
+
if (n) {
|
|
845
|
+
const f = u.NORMAL !== void 0 ? e.getDependency("accessor", u.NORMAL) : d.attributes.normal;
|
|
846
|
+
a.push(f);
|
|
847
|
+
}
|
|
848
|
+
if (s) {
|
|
849
|
+
const f = u.COLOR_0 !== void 0 ? e.getDependency("accessor", u.COLOR_0) : d.attributes.color;
|
|
850
|
+
o.push(f);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
return Promise.all([
|
|
854
|
+
Promise.all(i),
|
|
855
|
+
Promise.all(a),
|
|
856
|
+
Promise.all(o)
|
|
857
|
+
]).then(function(c) {
|
|
858
|
+
const l = c[0], u = c[1], f = c[2];
|
|
859
|
+
return r && (d.morphAttributes.position = l), n && (d.morphAttributes.normal = u), s && (d.morphAttributes.color = f), d.morphTargetsRelative = !0, d;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
function zt(d, t) {
|
|
863
|
+
if (d.updateMorphTargets(), t.weights !== void 0)
|
|
864
|
+
for (let e = 0, r = t.weights.length; e < r; e++)
|
|
865
|
+
d.morphTargetInfluences[e] = t.weights[e];
|
|
866
|
+
if (t.extras && Array.isArray(t.extras.targetNames)) {
|
|
867
|
+
const e = t.extras.targetNames;
|
|
868
|
+
if (d.morphTargetInfluences.length === e.length) {
|
|
869
|
+
d.morphTargetDictionary = {};
|
|
870
|
+
for (let r = 0, n = e.length; r < n; r++)
|
|
871
|
+
d.morphTargetDictionary[e[r]] = r;
|
|
872
|
+
} else
|
|
873
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function qt(d) {
|
|
877
|
+
let t;
|
|
878
|
+
const e = d.extensions && d.extensions[A.KHR_DRACO_MESH_COMPRESSION];
|
|
879
|
+
if (e ? t = "draco:" + e.bufferView + ":" + e.indices + ":" + se(e.attributes) : t = d.indices + ":" + se(d.attributes) + ":" + d.mode, d.targets !== void 0)
|
|
880
|
+
for (let r = 0, n = d.targets.length; r < n; r++)
|
|
881
|
+
t += ":" + se(d.targets[r]);
|
|
882
|
+
return t;
|
|
883
|
+
}
|
|
884
|
+
function se(d) {
|
|
885
|
+
let t = "";
|
|
886
|
+
const e = Object.keys(d).sort();
|
|
887
|
+
for (let r = 0, n = e.length; r < n; r++)
|
|
888
|
+
t += e[r] + ":" + d[e[r]] + ";";
|
|
889
|
+
return t;
|
|
890
|
+
}
|
|
891
|
+
function ae(d) {
|
|
892
|
+
switch (d) {
|
|
893
|
+
case Int8Array:
|
|
894
|
+
return 1 / 127;
|
|
895
|
+
case Uint8Array:
|
|
896
|
+
return 1 / 255;
|
|
897
|
+
case Int16Array:
|
|
898
|
+
return 1 / 32767;
|
|
899
|
+
case Uint16Array:
|
|
900
|
+
return 1 / 65535;
|
|
901
|
+
default:
|
|
902
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function Wt(d) {
|
|
906
|
+
return d.search(/\.jpe?g($|\?)/i) > 0 || d.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : d.search(/\.webp($|\?)/i) > 0 || d.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png";
|
|
907
|
+
}
|
|
908
|
+
const Yt = new Y();
|
|
909
|
+
class Qt {
|
|
910
|
+
constructor(t = {}, e = {}) {
|
|
911
|
+
this.json = t, this.extensions = {}, this.plugins = {}, this.options = e, this.cache = new Tt(), 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 = {};
|
|
912
|
+
let r = !1, n = -1, s = !1, i = -1;
|
|
913
|
+
if (typeof navigator != "undefined") {
|
|
914
|
+
const a = navigator.userAgent;
|
|
915
|
+
r = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
916
|
+
const o = a.match(/Version\/(\d+)/);
|
|
917
|
+
n = r && o ? parseInt(o[1], 10) : -1, s = a.indexOf("Firefox") > -1, i = s ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
918
|
+
}
|
|
919
|
+
typeof createImageBitmap == "undefined" || r && n < 17 || s && i < 98 ? this.textureLoader = new ye(this.options.manager) : this.textureLoader = new Ue(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Le(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
920
|
+
}
|
|
921
|
+
setExtensions(t) {
|
|
922
|
+
this.extensions = t;
|
|
923
|
+
}
|
|
924
|
+
setPlugins(t) {
|
|
925
|
+
this.plugins = t;
|
|
926
|
+
}
|
|
927
|
+
parse(t, e) {
|
|
928
|
+
const r = this, n = this.json, s = this.extensions;
|
|
929
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(i) {
|
|
930
|
+
return i._markDefs && i._markDefs();
|
|
931
|
+
}), Promise.all(this._invokeAll(function(i) {
|
|
932
|
+
return i.beforeRoot && i.beforeRoot();
|
|
933
|
+
})).then(function() {
|
|
934
|
+
return Promise.all([
|
|
935
|
+
r.getDependencies("scene"),
|
|
936
|
+
r.getDependencies("animation"),
|
|
937
|
+
r.getDependencies("camera")
|
|
938
|
+
]);
|
|
939
|
+
}).then(function(i) {
|
|
940
|
+
const a = {
|
|
941
|
+
scene: i[0][n.scene || 0],
|
|
942
|
+
scenes: i[0],
|
|
943
|
+
animations: i[1],
|
|
944
|
+
cameras: i[2],
|
|
945
|
+
asset: n.asset,
|
|
946
|
+
parser: r,
|
|
947
|
+
userData: {}
|
|
948
|
+
};
|
|
949
|
+
return P(s, a, n), w(a, n), Promise.all(r._invokeAll(function(o) {
|
|
950
|
+
return o.afterRoot && o.afterRoot(a);
|
|
951
|
+
})).then(function() {
|
|
952
|
+
for (const o of a.scenes)
|
|
953
|
+
o.updateMatrixWorld();
|
|
954
|
+
t(a);
|
|
955
|
+
});
|
|
956
|
+
}).catch(e);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
960
|
+
*/
|
|
961
|
+
_markDefs() {
|
|
962
|
+
const t = this.json.nodes || [], e = this.json.skins || [], r = this.json.meshes || [];
|
|
963
|
+
for (let n = 0, s = e.length; n < s; n++) {
|
|
964
|
+
const i = e[n].joints;
|
|
965
|
+
for (let a = 0, o = i.length; a < o; a++)
|
|
966
|
+
t[i[a]].isBone = !0;
|
|
967
|
+
}
|
|
968
|
+
for (let n = 0, s = t.length; n < s; n++) {
|
|
969
|
+
const i = t[n];
|
|
970
|
+
i.mesh !== void 0 && (this._addNodeRef(this.meshCache, i.mesh), i.skin !== void 0 && (r[i.mesh].isSkinnedMesh = !0)), i.camera !== void 0 && this._addNodeRef(this.cameraCache, i.camera);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
975
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
976
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
977
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
978
|
+
* Textures) can be reused directly and are not marked here.
|
|
979
|
+
*
|
|
980
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
981
|
+
*/
|
|
982
|
+
_addNodeRef(t, e) {
|
|
983
|
+
e !== void 0 && (t.refs[e] === void 0 && (t.refs[e] = t.uses[e] = 0), t.refs[e]++);
|
|
984
|
+
}
|
|
985
|
+
/** Returns a reference to a shared resource, cloning it if necessary. */
|
|
986
|
+
_getNodeRef(t, e, r) {
|
|
987
|
+
if (t.refs[e] <= 1)
|
|
988
|
+
return r;
|
|
989
|
+
const n = r.clone(), s = (i, a) => {
|
|
990
|
+
const o = this.associations.get(i);
|
|
991
|
+
o != null && this.associations.set(a, o);
|
|
992
|
+
for (const [c, l] of i.children.entries())
|
|
993
|
+
s(l, a.children[c]);
|
|
994
|
+
};
|
|
995
|
+
return s(r, n), n.name += "_instance_" + t.uses[e]++, n;
|
|
996
|
+
}
|
|
997
|
+
_invokeOne(t) {
|
|
998
|
+
const e = Object.values(this.plugins);
|
|
999
|
+
e.push(this);
|
|
1000
|
+
for (let r = 0; r < e.length; r++) {
|
|
1001
|
+
const n = t(e[r]);
|
|
1002
|
+
if (n)
|
|
1003
|
+
return n;
|
|
1004
|
+
}
|
|
1005
|
+
return null;
|
|
1006
|
+
}
|
|
1007
|
+
_invokeAll(t) {
|
|
1008
|
+
const e = Object.values(this.plugins);
|
|
1009
|
+
e.unshift(this);
|
|
1010
|
+
const r = [];
|
|
1011
|
+
for (let n = 0; n < e.length; n++) {
|
|
1012
|
+
const s = t(e[n]);
|
|
1013
|
+
s && r.push(s);
|
|
1014
|
+
}
|
|
1015
|
+
return r;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1019
|
+
* @param {string} type
|
|
1020
|
+
* @param {number} index
|
|
1021
|
+
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1022
|
+
*/
|
|
1023
|
+
getDependency(t, e) {
|
|
1024
|
+
const r = t + ":" + e;
|
|
1025
|
+
let n = this.cache.get(r);
|
|
1026
|
+
if (!n) {
|
|
1027
|
+
switch (t) {
|
|
1028
|
+
case "scene":
|
|
1029
|
+
n = this.loadScene(e);
|
|
1030
|
+
break;
|
|
1031
|
+
case "node":
|
|
1032
|
+
n = this._invokeOne(function(s) {
|
|
1033
|
+
return s.loadNode && s.loadNode(e);
|
|
1034
|
+
});
|
|
1035
|
+
break;
|
|
1036
|
+
case "mesh":
|
|
1037
|
+
n = this._invokeOne(function(s) {
|
|
1038
|
+
return s.loadMesh && s.loadMesh(e);
|
|
1039
|
+
});
|
|
1040
|
+
break;
|
|
1041
|
+
case "accessor":
|
|
1042
|
+
n = this.loadAccessor(e);
|
|
1043
|
+
break;
|
|
1044
|
+
case "bufferView":
|
|
1045
|
+
n = this._invokeOne(function(s) {
|
|
1046
|
+
return s.loadBufferView && s.loadBufferView(e);
|
|
1047
|
+
});
|
|
1048
|
+
break;
|
|
1049
|
+
case "buffer":
|
|
1050
|
+
n = this.loadBuffer(e);
|
|
1051
|
+
break;
|
|
1052
|
+
case "material":
|
|
1053
|
+
n = this._invokeOne(function(s) {
|
|
1054
|
+
return s.loadMaterial && s.loadMaterial(e);
|
|
1055
|
+
});
|
|
1056
|
+
break;
|
|
1057
|
+
case "texture":
|
|
1058
|
+
n = this._invokeOne(function(s) {
|
|
1059
|
+
return s.loadTexture && s.loadTexture(e);
|
|
1060
|
+
});
|
|
1061
|
+
break;
|
|
1062
|
+
case "skin":
|
|
1063
|
+
n = this.loadSkin(e);
|
|
1064
|
+
break;
|
|
1065
|
+
case "animation":
|
|
1066
|
+
n = this._invokeOne(function(s) {
|
|
1067
|
+
return s.loadAnimation && s.loadAnimation(e);
|
|
1068
|
+
});
|
|
1069
|
+
break;
|
|
1070
|
+
case "camera":
|
|
1071
|
+
n = this.loadCamera(e);
|
|
1072
|
+
break;
|
|
1073
|
+
default:
|
|
1074
|
+
if (n = this._invokeOne(function(s) {
|
|
1075
|
+
return s != this && s.getDependency && s.getDependency(t, e);
|
|
1076
|
+
}), !n)
|
|
1077
|
+
throw new Error("Unknown type: " + t);
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
this.cache.add(r, n);
|
|
1081
|
+
}
|
|
1082
|
+
return n;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1086
|
+
* @param {string} type
|
|
1087
|
+
* @return {Promise<Array<Object>>}
|
|
1088
|
+
*/
|
|
1089
|
+
getDependencies(t) {
|
|
1090
|
+
let e = this.cache.get(t);
|
|
1091
|
+
if (!e) {
|
|
1092
|
+
const r = this, n = this.json[t + (t === "mesh" ? "es" : "s")] || [];
|
|
1093
|
+
e = Promise.all(n.map(function(s, i) {
|
|
1094
|
+
return r.getDependency(t, i);
|
|
1095
|
+
})), this.cache.add(t, e);
|
|
1096
|
+
}
|
|
1097
|
+
return e;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1101
|
+
* @param {number} bufferIndex
|
|
1102
|
+
* @return {Promise<ArrayBuffer>}
|
|
1103
|
+
*/
|
|
1104
|
+
loadBuffer(t) {
|
|
1105
|
+
const e = this.json.buffers[t], r = this.fileLoader;
|
|
1106
|
+
if (e.type && e.type !== "arraybuffer")
|
|
1107
|
+
throw new Error("THREE.GLTFLoader: " + e.type + " buffer type is not supported.");
|
|
1108
|
+
if (e.uri === void 0 && t === 0)
|
|
1109
|
+
return Promise.resolve(this.extensions[A.KHR_BINARY_GLTF].body);
|
|
1110
|
+
const n = this.options;
|
|
1111
|
+
return new Promise(function(s, i) {
|
|
1112
|
+
r.load(X.resolveURL(e.uri, n.path), s, void 0, function() {
|
|
1113
|
+
i(new Error('THREE.GLTFLoader: Failed to load buffer "' + e.uri + '".'));
|
|
1114
|
+
});
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1119
|
+
* @param {number} bufferViewIndex
|
|
1120
|
+
* @return {Promise<ArrayBuffer>}
|
|
1121
|
+
*/
|
|
1122
|
+
loadBufferView(t) {
|
|
1123
|
+
const e = this.json.bufferViews[t];
|
|
1124
|
+
return this.getDependency("buffer", e.buffer).then(function(r) {
|
|
1125
|
+
const n = e.byteLength || 0, s = e.byteOffset || 0;
|
|
1126
|
+
return r.slice(s, s + n);
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1131
|
+
* @param {number} accessorIndex
|
|
1132
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1133
|
+
*/
|
|
1134
|
+
loadAccessor(t) {
|
|
1135
|
+
const e = this, r = this.json, n = this.json.accessors[t];
|
|
1136
|
+
if (n.bufferView === void 0 && n.sparse === void 0) {
|
|
1137
|
+
const i = te[n.type], a = U[n.componentType], o = n.normalized === !0, c = new a(n.count * i);
|
|
1138
|
+
return Promise.resolve(new J(c, i, o));
|
|
1139
|
+
}
|
|
1140
|
+
const s = [];
|
|
1141
|
+
return n.bufferView !== void 0 ? s.push(this.getDependency("bufferView", n.bufferView)) : s.push(null), n.sparse !== void 0 && (s.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), s.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(s).then(function(i) {
|
|
1142
|
+
const a = i[0], o = te[n.type], c = U[n.componentType], l = c.BYTES_PER_ELEMENT, u = l * o, f = n.byteOffset || 0, h = n.bufferView !== void 0 ? r.bufferViews[n.bufferView].byteStride : void 0, p = n.normalized === !0;
|
|
1143
|
+
let T, m;
|
|
1144
|
+
if (h && h !== u) {
|
|
1145
|
+
const g = Math.floor(f / h), R = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + g + ":" + n.count;
|
|
1146
|
+
let E = e.cache.get(R);
|
|
1147
|
+
E || (T = new c(a, g * h, n.count * h / l), E = new ve(T, h / l), e.cache.add(R, E)), m = new je(E, o, f % h / l, p);
|
|
1148
|
+
} else
|
|
1149
|
+
a === null ? T = new c(n.count * o) : T = new c(a, f, n.count * o), m = new J(T, o, p);
|
|
1150
|
+
if (n.sparse !== void 0) {
|
|
1151
|
+
const g = te.SCALAR, R = U[n.sparse.indices.componentType], E = n.sparse.indices.byteOffset || 0, x = n.sparse.values.byteOffset || 0, M = new R(i[1], E, n.sparse.count * g), O = new c(i[2], x, n.sparse.count * o);
|
|
1152
|
+
a !== null && (m = new J(m.array.slice(), m.itemSize, m.normalized));
|
|
1153
|
+
for (let _ = 0, v = M.length; _ < v; _++) {
|
|
1154
|
+
const C = M[_];
|
|
1155
|
+
if (m.setX(C, O[_ * o]), o >= 2 && m.setY(C, O[_ * o + 1]), o >= 3 && m.setZ(C, O[_ * o + 2]), o >= 4 && m.setW(C, O[_ * o + 3]), o >= 5)
|
|
1156
|
+
throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
return m;
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1164
|
+
* @param {number} textureIndex
|
|
1165
|
+
* @return {Promise<THREE.Texture|null>}
|
|
1166
|
+
*/
|
|
1167
|
+
loadTexture(t) {
|
|
1168
|
+
const e = this.json, r = this.options, s = e.textures[t].source, i = e.images[s];
|
|
1169
|
+
let a = this.textureLoader;
|
|
1170
|
+
if (i.uri) {
|
|
1171
|
+
const o = r.manager.getHandler(i.uri);
|
|
1172
|
+
o !== null && (a = o);
|
|
1173
|
+
}
|
|
1174
|
+
return this.loadTextureImage(t, s, a);
|
|
1175
|
+
}
|
|
1176
|
+
loadTextureImage(t, e, r) {
|
|
1177
|
+
const n = this, s = this.json, i = s.textures[t], a = s.images[e], o = (a.uri || a.bufferView) + ":" + i.sampler;
|
|
1178
|
+
if (this.textureCache[o])
|
|
1179
|
+
return this.textureCache[o];
|
|
1180
|
+
const c = this.loadImageSource(e, r).then(function(l) {
|
|
1181
|
+
l.flipY = !1, l.name = i.name || a.name || "", l.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (l.name = a.uri);
|
|
1182
|
+
const f = (s.samplers || {})[i.sampler] || {};
|
|
1183
|
+
return l.magFilter = Te[f.magFilter] || we, l.minFilter = Te[f.minFilter] || be, l.wrapS = xe[f.wrapS] || ie, l.wrapT = xe[f.wrapT] || ie, n.associations.set(l, { textures: t }), l;
|
|
1184
|
+
}).catch(function() {
|
|
1185
|
+
return null;
|
|
1186
|
+
});
|
|
1187
|
+
return this.textureCache[o] = c, c;
|
|
1188
|
+
}
|
|
1189
|
+
loadImageSource(t, e) {
|
|
1190
|
+
const r = this, n = this.json, s = this.options;
|
|
1191
|
+
if (this.sourceCache[t] !== void 0)
|
|
1192
|
+
return this.sourceCache[t].then((u) => u.clone());
|
|
1193
|
+
const i = n.images[t], a = self.URL || self.webkitURL;
|
|
1194
|
+
let o = i.uri || "", c = !1;
|
|
1195
|
+
if (i.bufferView !== void 0)
|
|
1196
|
+
o = r.getDependency("bufferView", i.bufferView).then(function(u) {
|
|
1197
|
+
c = !0;
|
|
1198
|
+
const f = new Blob([u], { type: i.mimeType });
|
|
1199
|
+
return o = a.createObjectURL(f), o;
|
|
1200
|
+
});
|
|
1201
|
+
else if (i.uri === void 0)
|
|
1202
|
+
throw new Error("THREE.GLTFLoader: Image " + t + " is missing URI and bufferView");
|
|
1203
|
+
const l = Promise.resolve(o).then(function(u) {
|
|
1204
|
+
return new Promise(function(f, h) {
|
|
1205
|
+
let p = f;
|
|
1206
|
+
e.isImageBitmapLoader === !0 && (p = function(T) {
|
|
1207
|
+
const m = new de(T);
|
|
1208
|
+
m.needsUpdate = !0, f(m);
|
|
1209
|
+
}), e.load(X.resolveURL(u, s.path), p, void 0, h);
|
|
1210
|
+
});
|
|
1211
|
+
}).then(function(u) {
|
|
1212
|
+
return c === !0 && a.revokeObjectURL(o), w(u, i), u.userData.mimeType = i.mimeType || Wt(i.uri), u;
|
|
1213
|
+
}).catch(function(u) {
|
|
1214
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", o), u;
|
|
1215
|
+
});
|
|
1216
|
+
return this.sourceCache[t] = l, l;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1220
|
+
* @param {Object} materialParams
|
|
1221
|
+
* @param {string} mapName
|
|
1222
|
+
* @param {Object} mapDef
|
|
1223
|
+
* @return {Promise<Texture>}
|
|
1224
|
+
*/
|
|
1225
|
+
assignTexture(t, e, r, n) {
|
|
1226
|
+
const s = this;
|
|
1227
|
+
return this.getDependency("texture", r.index).then(function(i) {
|
|
1228
|
+
if (!i)
|
|
1229
|
+
return null;
|
|
1230
|
+
if (r.texCoord !== void 0 && r.texCoord > 0 && (i = i.clone(), i.channel = r.texCoord), s.extensions[A.KHR_TEXTURE_TRANSFORM]) {
|
|
1231
|
+
const a = r.extensions !== void 0 ? r.extensions[A.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1232
|
+
if (a) {
|
|
1233
|
+
const o = s.associations.get(i);
|
|
1234
|
+
i = s.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(i, a), s.associations.set(i, o);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
return n !== void 0 && (i.colorSpace = n), t[e] = i, i;
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1242
|
+
* already has a material (generated from the glTF material options alone)
|
|
1243
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1244
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1245
|
+
* be created if necessary, and reused from a cache.
|
|
1246
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1247
|
+
*/
|
|
1248
|
+
assignFinalMaterial(t) {
|
|
1249
|
+
const e = t.geometry;
|
|
1250
|
+
let r = t.material;
|
|
1251
|
+
const n = e.attributes.tangent === void 0, s = e.attributes.color !== void 0, i = e.attributes.normal === void 0;
|
|
1252
|
+
if (t.isPoints) {
|
|
1253
|
+
const a = "PointsMaterial:" + r.uuid;
|
|
1254
|
+
let o = this.cache.get(a);
|
|
1255
|
+
o || (o = new Ke(), $.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, o.sizeAttenuation = !1, this.cache.add(a, o)), r = o;
|
|
1256
|
+
} else if (t.isLine) {
|
|
1257
|
+
const a = "LineBasicMaterial:" + r.uuid;
|
|
1258
|
+
let o = this.cache.get(a);
|
|
1259
|
+
o || (o = new Ve(), $.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, this.cache.add(a, o)), r = o;
|
|
1260
|
+
}
|
|
1261
|
+
if (n || s || i) {
|
|
1262
|
+
let a = "ClonedMaterial:" + r.uuid + ":";
|
|
1263
|
+
n && (a += "derivative-tangents:"), s && (a += "vertex-colors:"), i && (a += "flat-shading:");
|
|
1264
|
+
let o = this.cache.get(a);
|
|
1265
|
+
o || (o = r.clone(), s && (o.vertexColors = !0), i && (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;
|
|
1266
|
+
}
|
|
1267
|
+
t.material = r;
|
|
1268
|
+
}
|
|
1269
|
+
getMaterialType() {
|
|
1270
|
+
return Ne;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1274
|
+
* @param {number} materialIndex
|
|
1275
|
+
* @return {Promise<Material>}
|
|
1276
|
+
*/
|
|
1277
|
+
loadMaterial(t) {
|
|
1278
|
+
const e = this, r = this.json, n = this.extensions, s = r.materials[t];
|
|
1279
|
+
let i;
|
|
1280
|
+
const a = {}, o = s.extensions || {}, c = [];
|
|
1281
|
+
if (o[A.KHR_MATERIALS_UNLIT]) {
|
|
1282
|
+
const u = n[A.KHR_MATERIALS_UNLIT];
|
|
1283
|
+
i = u.getMaterialType(), c.push(u.extendParams(a, s, e));
|
|
1284
|
+
} else {
|
|
1285
|
+
const u = s.pbrMetallicRoughness || {};
|
|
1286
|
+
if (a.color = new G(1, 1, 1), a.opacity = 1, Array.isArray(u.baseColorFactor)) {
|
|
1287
|
+
const f = u.baseColorFactor;
|
|
1288
|
+
a.color.setRGB(f[0], f[1], f[2], I), a.opacity = f[3];
|
|
1289
|
+
}
|
|
1290
|
+
u.baseColorTexture !== void 0 && c.push(e.assignTexture(a, "map", u.baseColorTexture, z)), a.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, a.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (c.push(e.assignTexture(a, "metalnessMap", u.metallicRoughnessTexture)), c.push(e.assignTexture(a, "roughnessMap", u.metallicRoughnessTexture))), i = this._invokeOne(function(f) {
|
|
1291
|
+
return f.getMaterialType && f.getMaterialType(t);
|
|
1292
|
+
}), c.push(Promise.all(this._invokeAll(function(f) {
|
|
1293
|
+
return f.extendMaterialParams && f.extendMaterialParams(t, a);
|
|
1294
|
+
})));
|
|
1295
|
+
}
|
|
1296
|
+
s.doubleSided === !0 && (a.side = Xe);
|
|
1297
|
+
const l = s.alphaMode || ne.OPAQUE;
|
|
1298
|
+
if (l === ne.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, l === ne.MASK && (a.alphaTest = s.alphaCutoff !== void 0 ? s.alphaCutoff : 0.5)), s.normalTexture !== void 0 && i !== V && (c.push(e.assignTexture(a, "normalMap", s.normalTexture)), a.normalScale = new _e(1, 1), s.normalTexture.scale !== void 0)) {
|
|
1299
|
+
const u = s.normalTexture.scale;
|
|
1300
|
+
a.normalScale.set(u, u);
|
|
1301
|
+
}
|
|
1302
|
+
if (s.occlusionTexture !== void 0 && i !== V && (c.push(e.assignTexture(a, "aoMap", s.occlusionTexture)), s.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = s.occlusionTexture.strength)), s.emissiveFactor !== void 0 && i !== V) {
|
|
1303
|
+
const u = s.emissiveFactor;
|
|
1304
|
+
a.emissive = new G().setRGB(u[0], u[1], u[2], I);
|
|
1305
|
+
}
|
|
1306
|
+
return s.emissiveTexture !== void 0 && i !== V && c.push(e.assignTexture(a, "emissiveMap", s.emissiveTexture, z)), Promise.all(c).then(function() {
|
|
1307
|
+
const u = new i(a);
|
|
1308
|
+
return s.name && (u.name = s.name), w(u, s), e.associations.set(u, { materials: t }), s.extensions && P(n, u, s), u;
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
/** When Object3D instances are targeted by animation, they need unique names. */
|
|
1312
|
+
createUniqueName(t) {
|
|
1313
|
+
const e = ze.sanitizeNodeName(t || "");
|
|
1314
|
+
return e in this.nodeNamesUsed ? e + "_" + ++this.nodeNamesUsed[e] : (this.nodeNamesUsed[e] = 0, e);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1318
|
+
*
|
|
1319
|
+
* Creates BufferGeometries from primitives.
|
|
1320
|
+
*
|
|
1321
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1322
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1323
|
+
*/
|
|
1324
|
+
loadGeometries(t) {
|
|
1325
|
+
const e = this, r = this.extensions, n = this.primitiveCache;
|
|
1326
|
+
function s(a) {
|
|
1327
|
+
return r[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, e).then(function(o) {
|
|
1328
|
+
return Re(o, a, e);
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
const i = [];
|
|
1332
|
+
for (let a = 0, o = t.length; a < o; a++) {
|
|
1333
|
+
const c = t[a], l = qt(c), u = n[l];
|
|
1334
|
+
if (u)
|
|
1335
|
+
i.push(u.promise);
|
|
1336
|
+
else {
|
|
1337
|
+
let f;
|
|
1338
|
+
c.extensions && c.extensions[A.KHR_DRACO_MESH_COMPRESSION] ? f = s(c) : f = Re(new qe(), c, e), n[l] = { primitive: c, promise: f }, i.push(f);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
return Promise.all(i);
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1345
|
+
* @param {number} meshIndex
|
|
1346
|
+
* @return {Promise<Group|Mesh|SkinnedMesh>}
|
|
1347
|
+
*/
|
|
1348
|
+
loadMesh(t) {
|
|
1349
|
+
const e = this, r = this.json, n = this.extensions, s = r.meshes[t], i = s.primitives, a = [];
|
|
1350
|
+
for (let o = 0, c = i.length; o < c; o++) {
|
|
1351
|
+
const l = i[o].material === void 0 ? Vt(this.cache) : this.getDependency("material", i[o].material);
|
|
1352
|
+
a.push(l);
|
|
1353
|
+
}
|
|
1354
|
+
return a.push(e.loadGeometries(i)), Promise.all(a).then(function(o) {
|
|
1355
|
+
const c = o.slice(0, o.length - 1), l = o[o.length - 1], u = [];
|
|
1356
|
+
for (let h = 0, p = l.length; h < p; h++) {
|
|
1357
|
+
const T = l[h], m = i[h];
|
|
1358
|
+
let g;
|
|
1359
|
+
const R = c[h];
|
|
1360
|
+
if (m.mode === L.TRIANGLES || m.mode === L.TRIANGLE_STRIP || m.mode === L.TRIANGLE_FAN || m.mode === void 0)
|
|
1361
|
+
g = s.isSkinnedMesh === !0 ? new We(T, R) : new Ye(T, R), g.isSkinnedMesh === !0 && g.normalizeSkinWeights(), m.mode === L.TRIANGLE_STRIP ? g.geometry = Ae(g.geometry, Ee) : m.mode === L.TRIANGLE_FAN && (g.geometry = Ae(g.geometry, re));
|
|
1362
|
+
else if (m.mode === L.LINES)
|
|
1363
|
+
g = new Qe(T, R);
|
|
1364
|
+
else if (m.mode === L.LINE_STRIP)
|
|
1365
|
+
g = new Ze(T, R);
|
|
1366
|
+
else if (m.mode === L.LINE_LOOP)
|
|
1367
|
+
g = new Je(T, R);
|
|
1368
|
+
else if (m.mode === L.POINTS)
|
|
1369
|
+
g = new $e(T, R);
|
|
1370
|
+
else
|
|
1371
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode);
|
|
1372
|
+
Object.keys(g.geometry.morphAttributes).length > 0 && zt(g, s), g.name = e.createUniqueName(s.name || "mesh_" + t), w(g, s), m.extensions && P(n, g, m), e.assignFinalMaterial(g), u.push(g);
|
|
1373
|
+
}
|
|
1374
|
+
for (let h = 0, p = u.length; h < p; h++)
|
|
1375
|
+
e.associations.set(u[h], {
|
|
1376
|
+
meshes: t,
|
|
1377
|
+
primitives: h
|
|
1378
|
+
});
|
|
1379
|
+
if (u.length === 1)
|
|
1380
|
+
return s.extensions && P(n, u[0], s), u[0];
|
|
1381
|
+
const f = new ee();
|
|
1382
|
+
s.extensions && P(n, f, s), e.associations.set(f, { meshes: t });
|
|
1383
|
+
for (let h = 0, p = u.length; h < p; h++)
|
|
1384
|
+
f.add(u[h]);
|
|
1385
|
+
return f;
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1390
|
+
* @param {number} cameraIndex
|
|
1391
|
+
* @return {Promise<THREE.Camera>}
|
|
1392
|
+
*/
|
|
1393
|
+
loadCamera(t) {
|
|
1394
|
+
let e;
|
|
1395
|
+
const r = this.json.cameras[t], n = r[r.type];
|
|
1396
|
+
if (!n) {
|
|
1397
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
return r.type === "perspective" ? e = new et(tt.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : r.type === "orthographic" && (e = new nt(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), r.name && (e.name = this.createUniqueName(r.name)), w(e, r), Promise.resolve(e);
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1404
|
+
* @param {number} skinIndex
|
|
1405
|
+
* @return {Promise<Skeleton>}
|
|
1406
|
+
*/
|
|
1407
|
+
loadSkin(t) {
|
|
1408
|
+
const e = this.json.skins[t], r = [];
|
|
1409
|
+
for (let n = 0, s = e.joints.length; n < s; n++)
|
|
1410
|
+
r.push(this._loadNodeShallow(e.joints[n]));
|
|
1411
|
+
return e.inverseBindMatrices !== void 0 ? r.push(this.getDependency("accessor", e.inverseBindMatrices)) : r.push(null), Promise.all(r).then(function(n) {
|
|
1412
|
+
const s = n.pop(), i = n, a = [], o = [];
|
|
1413
|
+
for (let c = 0, l = i.length; c < l; c++) {
|
|
1414
|
+
const u = i[c];
|
|
1415
|
+
if (u) {
|
|
1416
|
+
a.push(u);
|
|
1417
|
+
const f = new Y();
|
|
1418
|
+
s !== null && f.fromArray(s.array, c * 16), o.push(f);
|
|
1419
|
+
} else
|
|
1420
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', e.joints[c]);
|
|
1421
|
+
}
|
|
1422
|
+
return new st(a, o);
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1427
|
+
* @param {number} animationIndex
|
|
1428
|
+
* @return {Promise<AnimationClip>}
|
|
1429
|
+
*/
|
|
1430
|
+
loadAnimation(t) {
|
|
1431
|
+
const e = this.json, r = this, n = e.animations[t], s = n.name ? n.name : "animation_" + t, i = [], a = [], o = [], c = [], l = [];
|
|
1432
|
+
for (let u = 0, f = n.channels.length; u < f; u++) {
|
|
1433
|
+
const h = n.channels[u], p = n.samplers[h.sampler], T = h.target, m = T.node, g = n.parameters !== void 0 ? n.parameters[p.input] : p.input, R = n.parameters !== void 0 ? n.parameters[p.output] : p.output;
|
|
1434
|
+
T.node !== void 0 && (i.push(this.getDependency("node", m)), a.push(this.getDependency("accessor", g)), o.push(this.getDependency("accessor", R)), c.push(p), l.push(T));
|
|
1435
|
+
}
|
|
1436
|
+
return Promise.all([
|
|
1437
|
+
Promise.all(i),
|
|
1438
|
+
Promise.all(a),
|
|
1439
|
+
Promise.all(o),
|
|
1440
|
+
Promise.all(c),
|
|
1441
|
+
Promise.all(l)
|
|
1442
|
+
]).then(function(u) {
|
|
1443
|
+
const f = u[0], h = u[1], p = u[2], T = u[3], m = u[4], g = [];
|
|
1444
|
+
for (let R = 0, E = f.length; R < E; R++) {
|
|
1445
|
+
const x = f[R], M = h[R], O = p[R], _ = T[R], v = m[R];
|
|
1446
|
+
if (x === void 0)
|
|
1447
|
+
continue;
|
|
1448
|
+
x.updateMatrix && x.updateMatrix();
|
|
1449
|
+
const C = r._createAnimationTracks(x, M, O, _, v);
|
|
1450
|
+
if (C)
|
|
1451
|
+
for (let Q = 0; Q < C.length; Q++)
|
|
1452
|
+
g.push(C[Q]);
|
|
1453
|
+
}
|
|
1454
|
+
return new rt(s, void 0, g);
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
createNodeMesh(t) {
|
|
1458
|
+
const e = this.json, r = this, n = e.nodes[t];
|
|
1459
|
+
return n.mesh === void 0 ? null : r.getDependency("mesh", n.mesh).then(function(s) {
|
|
1460
|
+
const i = r._getNodeRef(r.meshCache, n.mesh, s);
|
|
1461
|
+
return n.weights !== void 0 && i.traverse(function(a) {
|
|
1462
|
+
if (a.isMesh)
|
|
1463
|
+
for (let o = 0, c = n.weights.length; o < c; o++)
|
|
1464
|
+
a.morphTargetInfluences[o] = n.weights[o];
|
|
1465
|
+
}), i;
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1470
|
+
* @param {number} nodeIndex
|
|
1471
|
+
* @return {Promise<Object3D>}
|
|
1472
|
+
*/
|
|
1473
|
+
loadNode(t) {
|
|
1474
|
+
const e = this.json, r = this, n = e.nodes[t], s = r._loadNodeShallow(t), i = [], a = n.children || [];
|
|
1475
|
+
for (let c = 0, l = a.length; c < l; c++)
|
|
1476
|
+
i.push(r.getDependency("node", a[c]));
|
|
1477
|
+
const o = n.skin === void 0 ? Promise.resolve(null) : r.getDependency("skin", n.skin);
|
|
1478
|
+
return Promise.all([
|
|
1479
|
+
s,
|
|
1480
|
+
Promise.all(i),
|
|
1481
|
+
o
|
|
1482
|
+
]).then(function(c) {
|
|
1483
|
+
const l = c[0], u = c[1], f = c[2];
|
|
1484
|
+
f !== null && l.traverse(function(h) {
|
|
1485
|
+
h.isSkinnedMesh && h.bind(f, Yt);
|
|
1486
|
+
});
|
|
1487
|
+
for (let h = 0, p = u.length; h < p; h++)
|
|
1488
|
+
l.add(u[h]);
|
|
1489
|
+
return l;
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
// ._loadNodeShallow() parses a single node.
|
|
1493
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1494
|
+
_loadNodeShallow(t) {
|
|
1495
|
+
const e = this.json, r = this.extensions, n = this;
|
|
1496
|
+
if (this.nodeCache[t] !== void 0)
|
|
1497
|
+
return this.nodeCache[t];
|
|
1498
|
+
const s = e.nodes[t], i = s.name ? n.createUniqueName(s.name) : "", a = [], o = n._invokeOne(function(c) {
|
|
1499
|
+
return c.createNodeMesh && c.createNodeMesh(t);
|
|
1500
|
+
});
|
|
1501
|
+
return o && a.push(o), s.camera !== void 0 && a.push(n.getDependency("camera", s.camera).then(function(c) {
|
|
1502
|
+
return n._getNodeRef(n.cameraCache, s.camera, c);
|
|
1503
|
+
})), n._invokeAll(function(c) {
|
|
1504
|
+
return c.createNodeAttachment && c.createNodeAttachment(t);
|
|
1505
|
+
}).forEach(function(c) {
|
|
1506
|
+
a.push(c);
|
|
1507
|
+
}), this.nodeCache[t] = Promise.all(a).then(function(c) {
|
|
1508
|
+
let l;
|
|
1509
|
+
if (s.isBone === !0 ? l = new it() : c.length > 1 ? l = new ee() : c.length === 1 ? l = c[0] : l = new Me(), l !== c[0])
|
|
1510
|
+
for (let u = 0, f = c.length; u < f; u++)
|
|
1511
|
+
l.add(c[u]);
|
|
1512
|
+
if (s.name && (l.userData.name = s.name, l.name = i), w(l, s), s.extensions && P(r, l, s), s.matrix !== void 0) {
|
|
1513
|
+
const u = new Y();
|
|
1514
|
+
u.fromArray(s.matrix), l.applyMatrix4(u);
|
|
1515
|
+
} else
|
|
1516
|
+
s.translation !== void 0 && l.position.fromArray(s.translation), s.rotation !== void 0 && l.quaternion.fromArray(s.rotation), s.scale !== void 0 && l.scale.fromArray(s.scale);
|
|
1517
|
+
return n.associations.has(l) || n.associations.set(l, {}), n.associations.get(l).nodes = t, l;
|
|
1518
|
+
}), this.nodeCache[t];
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1522
|
+
* @param {number} sceneIndex
|
|
1523
|
+
* @return {Promise<Group>}
|
|
1524
|
+
*/
|
|
1525
|
+
loadScene(t) {
|
|
1526
|
+
const e = this.extensions, r = this.json.scenes[t], n = this, s = new ee();
|
|
1527
|
+
r.name && (s.name = n.createUniqueName(r.name)), w(s, r), r.extensions && P(e, s, r);
|
|
1528
|
+
const i = r.nodes || [], a = [];
|
|
1529
|
+
for (let o = 0, c = i.length; o < c; o++)
|
|
1530
|
+
a.push(n.getDependency("node", i[o]));
|
|
1531
|
+
return Promise.all(a).then(function(o) {
|
|
1532
|
+
for (let l = 0, u = o.length; l < u; l++)
|
|
1533
|
+
s.add(o[l]);
|
|
1534
|
+
const c = (l) => {
|
|
1535
|
+
const u = /* @__PURE__ */ new Map();
|
|
1536
|
+
for (const [f, h] of n.associations)
|
|
1537
|
+
(f instanceof $ || f instanceof de) && u.set(f, h);
|
|
1538
|
+
return l.traverse((f) => {
|
|
1539
|
+
const h = n.associations.get(f);
|
|
1540
|
+
h != null && u.set(f, h);
|
|
1541
|
+
}), u;
|
|
1542
|
+
};
|
|
1543
|
+
return n.associations = c(s), s;
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
_createAnimationTracks(t, e, r, n, s) {
|
|
1547
|
+
const i = [], a = t.name ? t.name : t.uuid, o = [];
|
|
1548
|
+
D[s.path] === D.weights ? t.traverse(function(f) {
|
|
1549
|
+
f.morphTargetInfluences && o.push(f.name ? f.name : f.uuid);
|
|
1550
|
+
}) : o.push(a);
|
|
1551
|
+
let c;
|
|
1552
|
+
switch (D[s.path]) {
|
|
1553
|
+
case D.weights:
|
|
1554
|
+
c = he;
|
|
1555
|
+
break;
|
|
1556
|
+
case D.rotation:
|
|
1557
|
+
c = pe;
|
|
1558
|
+
break;
|
|
1559
|
+
case D.position:
|
|
1560
|
+
case D.scale:
|
|
1561
|
+
c = fe;
|
|
1562
|
+
break;
|
|
1563
|
+
default:
|
|
1564
|
+
switch (r.itemSize) {
|
|
1565
|
+
case 1:
|
|
1566
|
+
c = he;
|
|
1567
|
+
break;
|
|
1568
|
+
case 2:
|
|
1569
|
+
case 3:
|
|
1570
|
+
default:
|
|
1571
|
+
c = fe;
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
const l = n.interpolation !== void 0 ? Kt[n.interpolation] : Ie, u = this._getArrayFromAccessor(r);
|
|
1577
|
+
for (let f = 0, h = o.length; f < h; f++) {
|
|
1578
|
+
const p = new c(
|
|
1579
|
+
o[f] + "." + D[s.path],
|
|
1580
|
+
e.array,
|
|
1581
|
+
u,
|
|
1582
|
+
l
|
|
1583
|
+
);
|
|
1584
|
+
n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(p), i.push(p);
|
|
1585
|
+
}
|
|
1586
|
+
return i;
|
|
1587
|
+
}
|
|
1588
|
+
_getArrayFromAccessor(t) {
|
|
1589
|
+
let e = t.array;
|
|
1590
|
+
if (t.normalized) {
|
|
1591
|
+
const r = ae(e.constructor), n = new Float32Array(e.length);
|
|
1592
|
+
for (let s = 0, i = e.length; s < i; s++)
|
|
1593
|
+
n[s] = e[s] * r;
|
|
1594
|
+
e = n;
|
|
1595
|
+
}
|
|
1596
|
+
return e;
|
|
1597
|
+
}
|
|
1598
|
+
_createCubicSplineTrackInterpolant(t) {
|
|
1599
|
+
t.createInterpolant = function(r) {
|
|
1600
|
+
const n = this instanceof pe ? jt : Ce;
|
|
1601
|
+
return new n(this.times, this.values, this.getValueSize() / 3, r);
|
|
1602
|
+
}, t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
function Zt(d, t, e) {
|
|
1606
|
+
const r = t.attributes, n = new pt();
|
|
1607
|
+
if (r.POSITION !== void 0) {
|
|
1608
|
+
const a = e.json.accessors[r.POSITION], o = a.min, c = a.max;
|
|
1609
|
+
if (o !== void 0 && c !== void 0) {
|
|
1610
|
+
if (n.set(
|
|
1611
|
+
new B(o[0], o[1], o[2]),
|
|
1612
|
+
new B(c[0], c[1], c[2])
|
|
1613
|
+
), a.normalized) {
|
|
1614
|
+
const l = ae(U[a.componentType]);
|
|
1615
|
+
n.min.multiplyScalar(l), n.max.multiplyScalar(l);
|
|
1616
|
+
}
|
|
1617
|
+
} else {
|
|
1618
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
} else
|
|
1622
|
+
return;
|
|
1623
|
+
const s = t.targets;
|
|
1624
|
+
if (s !== void 0) {
|
|
1625
|
+
const a = new B(), o = new B();
|
|
1626
|
+
for (let c = 0, l = s.length; c < l; c++) {
|
|
1627
|
+
const u = s[c];
|
|
1628
|
+
if (u.POSITION !== void 0) {
|
|
1629
|
+
const f = e.json.accessors[u.POSITION], h = f.min, p = f.max;
|
|
1630
|
+
if (h !== void 0 && p !== void 0) {
|
|
1631
|
+
if (o.setX(Math.max(Math.abs(h[0]), Math.abs(p[0]))), o.setY(Math.max(Math.abs(h[1]), Math.abs(p[1]))), o.setZ(Math.max(Math.abs(h[2]), Math.abs(p[2]))), f.normalized) {
|
|
1632
|
+
const T = ae(U[f.componentType]);
|
|
1633
|
+
o.multiplyScalar(T);
|
|
1634
|
+
}
|
|
1635
|
+
a.max(o);
|
|
1636
|
+
} else
|
|
1637
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
n.expandByVector(a);
|
|
1641
|
+
}
|
|
1642
|
+
d.boundingBox = n;
|
|
1643
|
+
const i = new mt();
|
|
1644
|
+
n.getCenter(i.center), i.radius = n.min.distanceTo(n.max) / 2, d.boundingSphere = i;
|
|
1645
|
+
}
|
|
1646
|
+
function Re(d, t, e) {
|
|
1647
|
+
const r = t.attributes, n = [];
|
|
1648
|
+
function s(i, a) {
|
|
1649
|
+
return e.getDependency("accessor", i).then(function(o) {
|
|
1650
|
+
d.setAttribute(a, o);
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
for (const i in r) {
|
|
1654
|
+
const a = oe[i] || i.toLowerCase();
|
|
1655
|
+
a in d.attributes || n.push(s(r[i], a));
|
|
1656
|
+
}
|
|
1657
|
+
if (t.indices !== void 0 && !d.index) {
|
|
1658
|
+
const i = e.getDependency("accessor", t.indices).then(function(a) {
|
|
1659
|
+
d.setIndex(a);
|
|
1660
|
+
});
|
|
1661
|
+
n.push(i);
|
|
1662
|
+
}
|
|
1663
|
+
return le.workingColorSpace !== I && "COLOR_0" in r && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${le.workingColorSpace}" not supported.`), w(d, t), Zt(d, t, e), Promise.all(n).then(function() {
|
|
1664
|
+
return t.targets !== void 0 ? Xt(d, t.targets, e) : d;
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
var k;
|
|
1668
|
+
class tn {
|
|
1669
|
+
constructor() {
|
|
1670
|
+
j(this, k, new gt());
|
|
1671
|
+
}
|
|
1672
|
+
get gltfLoader() {
|
|
1673
|
+
return S(this, k);
|
|
1674
|
+
}
|
|
1675
|
+
setLoaders(t) {
|
|
1676
|
+
if (t != null && t.draco && F.dracoLoader) {
|
|
1677
|
+
const e = typeof t.draco == "boolean" ? `${N.CDNVersion}/examples/jsm/libs/draco/gltf/` : t.draco;
|
|
1678
|
+
F.dracoLoader.setDecoderPath(e), S(this, k).setDRACOLoader(F.dracoLoader);
|
|
1679
|
+
}
|
|
1680
|
+
if (t != null && t.ktx2 && F.ktx2Loader) {
|
|
1681
|
+
const e = typeof t.ktx2 == "boolean" ? `${N.CDNVersion}/examples/jsm/libs/basis/` : t.ktx2;
|
|
1682
|
+
F.ktx2Loader.setTranscoderPath(e), S(this, k).setKTX2Loader(
|
|
1683
|
+
F.ktx2Loader.detectSupport(N.webglRenderer)
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
t != null && t.meshopt && F.meshoptDecoder && S(this, k).setMeshoptDecoder(F.meshoptDecoder);
|
|
1687
|
+
}
|
|
1688
|
+
load(...t) {
|
|
1689
|
+
const [e, r, ...n] = t;
|
|
1690
|
+
if (N.cacheAssets && b.has(e)) {
|
|
1691
|
+
const s = b.get(e).data;
|
|
1692
|
+
r(s);
|
|
1693
|
+
} else
|
|
1694
|
+
this.gltfLoader.load(
|
|
1695
|
+
e,
|
|
1696
|
+
(s) => {
|
|
1697
|
+
N.cacheAssets && b.set(e, {
|
|
1698
|
+
data: s,
|
|
1699
|
+
dispose: () => {
|
|
1700
|
+
s.cameras.forEach((i) => me(i)), s.scenes.forEach((i) => {
|
|
1701
|
+
me(i);
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}), r(s);
|
|
1705
|
+
},
|
|
1706
|
+
...n
|
|
1707
|
+
);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
k = new WeakMap();
|
|
1711
|
+
var H, q, W;
|
|
1712
|
+
class nn {
|
|
1713
|
+
constructor() {
|
|
1714
|
+
j(this, H, new ye());
|
|
1715
|
+
j(this, q, void 0);
|
|
1716
|
+
j(this, W, void 0);
|
|
1717
|
+
Z(this, q, S(this, H).load.bind(S(this, H))), Z(this, W, S(this, H).loadAsync.bind(S(this, H)));
|
|
1718
|
+
}
|
|
1719
|
+
load(...t) {
|
|
1720
|
+
const [e, r, ...n] = t;
|
|
1721
|
+
if (N.cacheAssets && b.has(e)) {
|
|
1722
|
+
const s = b.get(e);
|
|
1723
|
+
return r == null || r(s.data), s.data;
|
|
1724
|
+
}
|
|
1725
|
+
return S(this, q).call(this, e, (s) => {
|
|
1726
|
+
N.cacheAssets && b.set(e, {
|
|
1727
|
+
data: s,
|
|
1728
|
+
dispose: () => s.dispose()
|
|
1729
|
+
}), r == null || r(s);
|
|
1730
|
+
}, ...n);
|
|
1731
|
+
}
|
|
1732
|
+
loadSync(...t) {
|
|
1733
|
+
return ue(this, null, function* () {
|
|
1734
|
+
const [e, ...r] = t;
|
|
1735
|
+
if (N.cacheAssets && b.has(e))
|
|
1736
|
+
return b.get(e).data;
|
|
1737
|
+
const n = yield S(this, W).call(this, e, ...r);
|
|
1738
|
+
return N.cacheAssets && b.set(e, {
|
|
1739
|
+
data: n,
|
|
1740
|
+
dispose: () => n.dispose()
|
|
1741
|
+
}), n;
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
H = new WeakMap(), q = new WeakMap(), W = new WeakMap();
|
|
1746
|
+
const F = {
|
|
1747
|
+
gltfLoader: null,
|
|
1748
|
+
textureLoader: null,
|
|
1749
|
+
dracoLoader: null,
|
|
1750
|
+
ktx2Loader: null,
|
|
1751
|
+
meshoptDecoder: null
|
|
1752
|
+
};
|
|
1753
|
+
export {
|
|
1754
|
+
tn as En3GLTFLoader,
|
|
1755
|
+
nn as En3TextureLoader,
|
|
1756
|
+
F as loaders
|
|
1757
|
+
};
|