@allincart-ag/dive
Version:
Allincart Spatial Framework
1,230 lines • 90.9 kB
JavaScript
var ve = Object.defineProperty;
var Be = (d, e, t) => e in d ? ve(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
var v = (d, e, t) => Be(d, typeof e != "symbol" ? e + "" : e, t);
import { TrianglesDrawMode as je, TriangleFanDrawMode as re, TriangleStripDrawMode as be, Loader as ae, LoaderUtils as X, FileLoader as K, MeshPhysicalMaterial as O, Vector2 as q, Color as U, LinearSRGBColorSpace as D, SRGBColorSpace as N, SpotLight as Ke, PointLight as Ve, DirectionalLight as We, Matrix4 as Y, Vector3 as B, Quaternion as Le, InstancedMesh as Xe, InstancedBufferAttribute as ze, Object3D as ce, TextureLoader as Me, ImageBitmapLoader as qe, BufferAttribute as P, InterleavedBuffer as Ye, InterleavedBufferAttribute as Je, LinearMipmapLinearFilter as Ie, NearestMipmapLinearFilter as Qe, LinearMipmapNearestFilter as Ze, NearestMipmapNearestFilter as $e, LinearFilter as Ce, NearestFilter as et, RepeatWrapping as J, MirroredRepeatWrapping as Ne, ClampToEdgeWrapping as De, PointsMaterial as tt, Material as Z, LineBasicMaterial as nt, MeshStandardMaterial as Oe, DoubleSide as st, MeshBasicMaterial as W, PropertyBinding as rt, BufferGeometry as ue, SkinnedMesh as ot, Mesh as Pe, LineSegments as it, Line as at, LineLoop as ct, Points as ut, Group as z, PerspectiveCamera as lt, MathUtils as ft, OrthographicCamera as dt, Skeleton as ht, AnimationClip as pt, Bone as mt, InterpolateDiscrete as gt, InterpolateLinear as ke, Texture as de, VectorKeyframeTrack as he, NumberKeyframeTrack as pe, QuaternionKeyframeTrack as me, ColorManagement as ge, FrontSide as At, Interpolant as Tt, Box3 as yt, Sphere as Rt, NoColorSpace as H } from "three";
import { u as xt, a as Ae } from "./fflate.module-xyO_T3Zm.mjs";
import { S as _t } from "./FileTypes-CXnW0NAe.mjs";
import { N as Te, g as wt, i as Et } from "./network-error-CHvryg-4.mjs";
import { F as ye, P as Re } from "./parse-error-BFRJyIxM.mjs";
function xe(d, e) {
if (e === je)
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
if (e === re || e === be) {
let t = d.getIndex();
if (t === null) {
const s = [], a = d.getAttribute("position");
if (a !== void 0) {
for (let i = 0; i < a.count; i++)
s.push(i);
d.setIndex(s), t = d.getIndex();
} else
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), d;
}
const o = t.count - 2, n = [];
if (e === re)
for (let s = 1; s <= o; s++)
n.push(t.getX(0)), n.push(t.getX(s)), n.push(t.getX(s + 1));
else
for (let s = 0; s < o; s++)
s % 2 === 0 ? (n.push(t.getX(s)), n.push(t.getX(s + 1)), n.push(t.getX(s + 2))) : (n.push(t.getX(s + 2)), n.push(t.getX(s + 1)), n.push(t.getX(s)));
n.length / 3 !== o && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
const r = d.clone();
return r.setIndex(n), r.clearGroups(), r;
} else
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), d;
}
class St extends ae {
constructor(e) {
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
return new Ct(t);
}), this.register(function(t) {
return new Gt(t);
}), this.register(function(t) {
return new vt(t);
}), this.register(function(t) {
return new Bt(t);
}), this.register(function(t) {
return new Dt(t);
}), this.register(function(t) {
return new Ot(t);
}), this.register(function(t) {
return new Pt(t);
}), this.register(function(t) {
return new kt(t);
}), this.register(function(t) {
return new It(t);
}), this.register(function(t) {
return new Ft(t);
}), this.register(function(t) {
return new Nt(t);
}), this.register(function(t) {
return new Ht(t);
}), this.register(function(t) {
return new Ut(t);
}), this.register(function(t) {
return new Lt(t);
}), this.register(function(t) {
return new jt(t);
}), this.register(function(t) {
return new Kt(t);
});
}
load(e, t, o, n) {
const r = this;
let s;
if (this.resourcePath !== "")
s = this.resourcePath;
else if (this.path !== "") {
const c = X.extractUrlBase(e);
s = X.resolveURL(c, this.path);
} else
s = X.extractUrlBase(e);
this.manager.itemStart(e);
const a = function(c) {
n ? n(c) : console.error(c), r.manager.itemError(e), r.manager.itemEnd(e);
}, i = new K(this.manager);
i.setPath(this.path), i.setResponseType("arraybuffer"), i.setRequestHeader(this.requestHeader), i.setWithCredentials(this.withCredentials), i.load(e, function(c) {
try {
r.parse(c, s, function(u) {
t(u), r.manager.itemEnd(e);
}, a);
} catch (u) {
a(u);
}
}, o, a);
}
setDRACOLoader(e) {
return this.dracoLoader = e, this;
}
setDDSLoader() {
throw new Error(
'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".'
);
}
setKTX2Loader(e) {
return this.ktx2Loader = e, this;
}
setMeshoptDecoder(e) {
return this.meshoptDecoder = e, this;
}
register(e) {
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
}
unregister(e) {
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
}
parse(e, t, o, n) {
let r;
const s = {}, a = {}, i = new TextDecoder();
if (typeof e == "string")
r = JSON.parse(e);
else if (e instanceof ArrayBuffer)
if (i.decode(new Uint8Array(e, 0, 4)) === Fe) {
try {
s[b.KHR_BINARY_GLTF] = new Vt(e);
} catch (l) {
n && n(l);
return;
}
r = JSON.parse(s[b.KHR_BINARY_GLTF].content);
} else
r = JSON.parse(i.decode(e));
else
r = e;
if (r.asset === void 0 || r.asset.version[0] < 2) {
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
return;
}
const c = new sn(r, {
path: t || this.resourcePath || "",
crossOrigin: this.crossOrigin,
requestHeader: this.requestHeader,
manager: this.manager,
ktx2Loader: this.ktx2Loader,
meshoptDecoder: this.meshoptDecoder
});
c.fileLoader.setRequestHeader(this.requestHeader);
for (let u = 0; u < this.pluginCallbacks.length; u++) {
const l = this.pluginCallbacks[u](c);
l.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[l.name] = l, s[l.name] = !0;
}
if (r.extensionsUsed)
for (let u = 0; u < r.extensionsUsed.length; ++u) {
const l = r.extensionsUsed[u], f = r.extensionsRequired || [];
switch (l) {
case b.KHR_MATERIALS_UNLIT:
s[l] = new Mt();
break;
case b.KHR_DRACO_MESH_COMPRESSION:
s[l] = new Wt(r, this.dracoLoader);
break;
case b.KHR_TEXTURE_TRANSFORM:
s[l] = new Xt();
break;
case b.KHR_MESH_QUANTIZATION:
s[l] = new zt();
break;
default:
f.indexOf(l) >= 0 && a[l] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + l + '".');
}
}
c.setExtensions(s), c.setPlugins(a), c.parse(o, n);
}
parseAsync(e, t) {
const o = this;
return new Promise(function(n, r) {
o.parse(e, t, n, r);
});
}
}
function bt() {
let d = {};
return {
get: function(e) {
return d[e];
},
add: function(e, t) {
d[e] = t;
},
remove: function(e) {
delete d[e];
},
removeAll: function() {
d = {};
}
};
}
const b = {
KHR_BINARY_GLTF: "KHR_binary_glTF",
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
KHR_MATERIALS_IOR: "KHR_materials_ior",
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
EXT_MATERIALS_BUMP: "EXT_materials_bump",
EXT_TEXTURE_WEBP: "EXT_texture_webp",
EXT_TEXTURE_AVIF: "EXT_texture_avif",
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
};
class Lt {
constructor(e) {
this.parser = e, this.name = b.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
}
_markDefs() {
const e = this.parser, t = this.parser.json.nodes || [];
for (let o = 0, n = t.length; o < n; o++) {
const r = t[o];
r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
}
}
_loadLight(e) {
const t = this.parser, o = "light:" + e;
let n = t.cache.get(o);
if (n) return n;
const r = t.json, i = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];
let c;
const u = new U(16777215);
i.color !== void 0 && u.setRGB(i.color[0], i.color[1], i.color[2], D);
const l = i.range !== void 0 ? i.range : 0;
switch (i.type) {
case "directional":
c = new We(u), c.target.position.set(0, 0, -1), c.add(c.target);
break;
case "point":
c = new Ve(u), c.distance = l;
break;
case "spot":
c = new Ke(u), c.distance = l, i.spot = i.spot || {}, i.spot.innerConeAngle = i.spot.innerConeAngle !== void 0 ? i.spot.innerConeAngle : 0, i.spot.outerConeAngle = i.spot.outerConeAngle !== void 0 ? i.spot.outerConeAngle : Math.PI / 4, c.angle = i.spot.outerConeAngle, c.penumbra = 1 - i.spot.innerConeAngle / i.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
break;
default:
throw new Error("THREE.GLTFLoader: Unexpected light type: " + i.type);
}
return c.position.set(0, 0, 0), c.decay = 2, F(c, i), i.intensity !== void 0 && (c.intensity = i.intensity), c.name = t.createUniqueName(i.name || "light_" + e), n = Promise.resolve(c), t.cache.add(o, n), n;
}
getDependency(e, t) {
if (e === "light")
return this._loadLight(t);
}
createNodeAttachment(e) {
const t = this, o = this.parser, r = o.json.nodes[e], a = (r.extensions && r.extensions[this.name] || {}).light;
return a === void 0 ? null : this._loadLight(a).then(function(i) {
return o._getNodeRef(t.cache, a, i);
});
}
}
class Mt {
constructor() {
this.name = b.KHR_MATERIALS_UNLIT;
}
getMaterialType() {
return W;
}
extendParams(e, t, o) {
const n = [];
e.color = new U(1, 1, 1), e.opacity = 1;
const r = t.pbrMetallicRoughness;
if (r) {
if (Array.isArray(r.baseColorFactor)) {
const s = r.baseColorFactor;
e.color.setRGB(s[0], s[1], s[2], D), e.opacity = s[3];
}
r.baseColorTexture !== void 0 && n.push(o.assignTexture(e, "map", r.baseColorTexture, N));
}
return Promise.all(n);
}
}
class It {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_EMISSIVE_STRENGTH;
}
extendMaterialParams(e, t) {
const n = this.parser.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = n.extensions[this.name].emissiveStrength;
return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();
}
}
class Ct {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_CLEARCOAT;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (r.push(o.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
const a = s.clearcoatNormalTexture.scale;
t.clearcoatNormalScale = new q(a, a);
}
return Promise.all(r);
}
}
class Nt {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_IRIDESCENCE;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && r.push(o.assignTexture(t, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (t.iridescenceIOR = s.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && r.push(o.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(r);
}
}
class Dt {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_SHEEN;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [];
t.sheenColor = new U(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
const s = n.extensions[this.name];
if (s.sheenColorFactor !== void 0) {
const a = s.sheenColorFactor;
t.sheenColor.setRGB(a[0], a[1], a[2], D);
}
return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && r.push(o.assignTexture(t, "sheenColorMap", s.sheenColorTexture, N)), s.sheenRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(r);
}
}
class Ot {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_TRANSMISSION;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && r.push(o.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(r);
}
}
class Pt {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_VOLUME;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && r.push(o.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
const a = s.attenuationColor || [1, 1, 1];
return t.attenuationColor = new U().setRGB(a[0], a[1], a[2], D), Promise.all(r);
}
}
class kt {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_IOR;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const n = this.parser.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = n.extensions[this.name];
return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();
}
}
class Ft {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_SPECULAR;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && r.push(o.assignTexture(t, "specularIntensityMap", s.specularTexture));
const a = s.specularColorFactor || [1, 1, 1];
return t.specularColor = new U().setRGB(a[0], a[1], a[2], D), s.specularColorTexture !== void 0 && r.push(o.assignTexture(t, "specularColorMap", s.specularColorTexture, N)), Promise.all(r);
}
}
class Ut {
constructor(e) {
this.parser = e, this.name = b.EXT_MATERIALS_BUMP;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && r.push(o.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(r);
}
}
class Ht {
constructor(e) {
this.parser = e, this.name = b.KHR_MATERIALS_ANISOTROPY;
}
getMaterialType(e) {
const o = this.parser.json.materials[e];
return !o.extensions || !o.extensions[this.name] ? null : O;
}
extendMaterialParams(e, t) {
const o = this.parser, n = o.json.materials[e];
if (!n.extensions || !n.extensions[this.name])
return Promise.resolve();
const r = [], s = n.extensions[this.name];
return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && r.push(o.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(r);
}
}
class Gt {
constructor(e) {
this.parser = e, this.name = b.KHR_TEXTURE_BASISU;
}
loadTexture(e) {
const t = this.parser, o = t.json, n = o.textures[e];
if (!n.extensions || !n.extensions[this.name])
return null;
const r = n.extensions[this.name], s = t.options.ktx2Loader;
if (!s) {
if (o.extensionsRequired && o.extensionsRequired.indexOf(this.name) >= 0)
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
return null;
}
return t.loadTextureImage(e, r.source, s);
}
}
class vt {
constructor(e) {
this.parser = e, this.name = b.EXT_TEXTURE_WEBP, this.isSupported = null;
}
loadTexture(e) {
const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
if (!r.extensions || !r.extensions[t])
return null;
const s = r.extensions[t], a = n.images[s.source];
let i = o.textureLoader;
if (a.uri) {
const c = o.options.manager.getHandler(a.uri);
c !== null && (i = c);
}
return this.detectSupport().then(function(c) {
if (c) return o.loadTextureImage(e, s.source, i);
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
return o.loadTexture(e);
});
}
detectSupport() {
return this.isSupported || (this.isSupported = new Promise(function(e) {
const t = new Image();
t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
e(t.height === 1);
};
})), this.isSupported;
}
}
class Bt {
constructor(e) {
this.parser = e, this.name = b.EXT_TEXTURE_AVIF, this.isSupported = null;
}
loadTexture(e) {
const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
if (!r.extensions || !r.extensions[t])
return null;
const s = r.extensions[t], a = n.images[s.source];
let i = o.textureLoader;
if (a.uri) {
const c = o.options.manager.getHandler(a.uri);
c !== null && (i = c);
}
return this.detectSupport().then(function(c) {
if (c) return o.loadTextureImage(e, s.source, i);
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
return o.loadTexture(e);
});
}
detectSupport() {
return this.isSupported || (this.isSupported = new Promise(function(e) {
const t = new Image();
t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
e(t.height === 1);
};
})), this.isSupported;
}
}
class jt {
constructor(e) {
this.name = b.EXT_MESHOPT_COMPRESSION, this.parser = e;
}
loadBufferView(e) {
const t = this.parser.json, o = t.bufferViews[e];
if (o.extensions && o.extensions[this.name]) {
const n = o.extensions[this.name], r = this.parser.getDependency("buffer", n.buffer), s = this.parser.options.meshoptDecoder;
if (!s || !s.supported) {
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
return null;
}
return r.then(function(a) {
const i = n.byteOffset || 0, c = n.byteLength || 0, u = n.count, l = n.byteStride, f = new Uint8Array(a, i, c);
return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(u, l, f, n.mode, n.filter).then(function(m) {
return m.buffer;
}) : s.ready.then(function() {
const m = new ArrayBuffer(u * l);
return s.decodeGltfBuffer(new Uint8Array(m), u, l, f, n.mode, n.filter), m;
});
});
} else
return null;
}
}
class Kt {
constructor(e) {
this.name = b.EXT_MESH_GPU_INSTANCING, this.parser = e;
}
createNodeMesh(e) {
const t = this.parser.json, o = t.nodes[e];
if (!o.extensions || !o.extensions[this.name] || o.mesh === void 0)
return null;
const n = t.meshes[o.mesh];
for (const c of n.primitives)
if (c.mode !== C.TRIANGLES && c.mode !== C.TRIANGLE_STRIP && c.mode !== C.TRIANGLE_FAN && c.mode !== void 0)
return null;
const s = o.extensions[this.name].attributes, a = [], i = {};
for (const c in s)
a.push(this.parser.getDependency("accessor", s[c]).then((u) => (i[c] = u, i[c])));
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((c) => {
const u = c.pop(), l = u.isGroup ? u.children : [u], f = c[0].count, m = [];
for (const T of l) {
const x = new Y(), y = new B(), R = new Le(), E = new B(1, 1, 1), S = new Xe(T.geometry, T.material, f);
for (let _ = 0; _ < f; _++)
i.TRANSLATION && y.fromBufferAttribute(i.TRANSLATION, _), i.ROTATION && R.fromBufferAttribute(i.ROTATION, _), i.SCALE && E.fromBufferAttribute(i.SCALE, _), S.setMatrixAt(_, x.compose(y, R, E));
for (const _ in i)
if (_ === "_COLOR_0") {
const M = i[_];
S.instanceColor = new ze(M.array, M.itemSize, M.normalized);
} else _ !== "TRANSLATION" && _ !== "ROTATION" && _ !== "SCALE" && T.geometry.setAttribute(_, i[_]);
ce.prototype.copy.call(S, T), this.parser.assignFinalMaterial(S), m.push(S);
}
return u.isGroup ? (u.clear(), u.add(...m), u) : m[0];
}));
}
}
const Fe = "glTF", V = 12, _e = { JSON: 1313821514, BIN: 5130562 };
class Vt {
constructor(e) {
this.name = b.KHR_BINARY_GLTF, this.content = null, this.body = null;
const t = new DataView(e, 0, V), o = new TextDecoder();
if (this.header = {
magic: o.decode(new Uint8Array(e.slice(0, 4))),
version: t.getUint32(4, !0),
length: t.getUint32(8, !0)
}, this.header.magic !== Fe)
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
if (this.header.version < 2)
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
const n = this.header.length - V, r = new DataView(e, V);
let s = 0;
for (; s < n; ) {
const a = r.getUint32(s, !0);
s += 4;
const i = r.getUint32(s, !0);
if (s += 4, i === _e.JSON) {
const c = new Uint8Array(e, V + s, a);
this.content = o.decode(c);
} else if (i === _e.BIN) {
const c = V + s;
this.body = e.slice(c, c + a);
}
s += a;
}
if (this.content === null)
throw new Error("THREE.GLTFLoader: JSON content not found.");
}
}
class Wt {
constructor(e, t) {
if (!t)
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
this.name = b.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
}
decodePrimitive(e, t) {
const o = this.json, n = this.dracoLoader, r = e.extensions[this.name].bufferView, s = e.extensions[this.name].attributes, a = {}, i = {}, c = {};
for (const u in s) {
const l = oe[u] || u.toLowerCase();
a[l] = s[u];
}
for (const u in e.attributes) {
const l = oe[u] || u.toLowerCase();
if (s[u] !== void 0) {
const f = o.accessors[e.attributes[u]], m = j[f.componentType];
c[l] = m.name, i[l] = f.normalized === !0;
}
}
return t.getDependency("bufferView", r).then(function(u) {
return new Promise(function(l, f) {
n.decodeDracoFile(u, function(m) {
for (const T in m.attributes) {
const x = m.attributes[T], y = i[T];
y !== void 0 && (x.normalized = y);
}
l(m);
}, a, c, D, f);
});
});
}
}
class Xt {
constructor() {
this.name = b.KHR_TEXTURE_TRANSFORM;
}
extendTexture(e, t) {
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
}
}
class zt {
constructor() {
this.name = b.KHR_MESH_QUANTIZATION;
}
}
class Ue extends Tt {
constructor(e, t, o, n) {
super(e, t, o, n);
}
copySampleValue_(e) {
const t = this.resultBuffer, o = this.sampleValues, n = this.valueSize, r = e * n * 3 + n;
for (let s = 0; s !== n; s++)
t[s] = o[r + s];
return t;
}
interpolate_(e, t, o, n) {
const r = this.resultBuffer, s = this.sampleValues, a = this.valueSize, i = a * 2, c = a * 3, u = n - t, l = (o - t) / u, f = l * l, m = f * l, T = e * c, x = T - c, y = -2 * m + 3 * f, R = m - f, E = 1 - y, S = R - f + l;
for (let _ = 0; _ !== a; _++) {
const M = s[x + _ + a], I = s[x + _ + i] * u, L = s[T + _ + a], h = s[T + _] * u;
r[_] = E * M + S * I + y * L + R * h;
}
return r;
}
}
const qt = new Le();
class Yt extends Ue {
interpolate_(e, t, o, n) {
const r = super.interpolate_(e, t, o, n);
return qt.fromArray(r).normalize().toArray(r), r;
}
}
const C = {
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6
}, j = {
5120: Int8Array,
5121: Uint8Array,
5122: Int16Array,
5123: Uint16Array,
5125: Uint32Array,
5126: Float32Array
}, we = {
9728: et,
9729: Ce,
9984: $e,
9985: Ze,
9986: Qe,
9987: Ie
}, Ee = {
33071: De,
33648: Ne,
10497: J
}, $ = {
SCALAR: 1,
VEC2: 2,
VEC3: 3,
VEC4: 4,
MAT2: 4,
MAT3: 9,
MAT4: 16
}, oe = {
POSITION: "position",
NORMAL: "normal",
TANGENT: "tangent",
TEXCOORD_0: "uv",
TEXCOORD_1: "uv1",
TEXCOORD_2: "uv2",
TEXCOORD_3: "uv3",
COLOR_0: "color",
WEIGHTS_0: "skinWeight",
JOINTS_0: "skinIndex"
}, k = {
scale: "scale",
translation: "position",
rotation: "quaternion",
weights: "morphTargetInfluences"
}, Jt = {
CUBICSPLINE: void 0,
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
// keyframe track will be initialized with a default interpolation type, then modified.
LINEAR: ke,
STEP: gt
}, ee = {
OPAQUE: "OPAQUE",
MASK: "MASK",
BLEND: "BLEND"
};
function Qt(d) {
return d.DefaultMaterial === void 0 && (d.DefaultMaterial = new Oe({
color: 16777215,
emissive: 0,
metalness: 1,
roughness: 1,
transparent: !1,
depthTest: !0,
side: At
})), d.DefaultMaterial;
}
function G(d, e, t) {
for (const o in t.extensions)
d[o] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[o] = t.extensions[o]);
}
function F(d, e) {
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(d.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
}
function Zt(d, e, t) {
let o = !1, n = !1, r = !1;
for (let c = 0, u = e.length; c < u; c++) {
const l = e[c];
if (l.POSITION !== void 0 && (o = !0), l.NORMAL !== void 0 && (n = !0), l.COLOR_0 !== void 0 && (r = !0), o && n && r) break;
}
if (!o && !n && !r) return Promise.resolve(d);
const s = [], a = [], i = [];
for (let c = 0, u = e.length; c < u; c++) {
const l = e[c];
if (o) {
const f = l.POSITION !== void 0 ? t.getDependency("accessor", l.POSITION) : d.attributes.position;
s.push(f);
}
if (n) {
const f = l.NORMAL !== void 0 ? t.getDependency("accessor", l.NORMAL) : d.attributes.normal;
a.push(f);
}
if (r) {
const f = l.COLOR_0 !== void 0 ? t.getDependency("accessor", l.COLOR_0) : d.attributes.color;
i.push(f);
}
}
return Promise.all([
Promise.all(s),
Promise.all(a),
Promise.all(i)
]).then(function(c) {
const u = c[0], l = c[1], f = c[2];
return o && (d.morphAttributes.position = u), n && (d.morphAttributes.normal = l), r && (d.morphAttributes.color = f), d.morphTargetsRelative = !0, d;
});
}
function $t(d, e) {
if (d.updateMorphTargets(), e.weights !== void 0)
for (let t = 0, o = e.weights.length; t < o; t++)
d.morphTargetInfluences[t] = e.weights[t];
if (e.extras && Array.isArray(e.extras.targetNames)) {
const t = e.extras.targetNames;
if (d.morphTargetInfluences.length === t.length) {
d.morphTargetDictionary = {};
for (let o = 0, n = t.length; o < n; o++)
d.morphTargetDictionary[t[o]] = o;
} else
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
}
}
function en(d) {
let e;
const t = d.extensions && d.extensions[b.KHR_DRACO_MESH_COMPRESSION];
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + te(t.attributes) : e = d.indices + ":" + te(d.attributes) + ":" + d.mode, d.targets !== void 0)
for (let o = 0, n = d.targets.length; o < n; o++)
e += ":" + te(d.targets[o]);
return e;
}
function te(d) {
let e = "";
const t = Object.keys(d).sort();
for (let o = 0, n = t.length; o < n; o++)
e += t[o] + ":" + d[t[o]] + ";";
return e;
}
function ie(d) {
switch (d) {
case Int8Array:
return 1 / 127;
case Uint8Array:
return 1 / 255;
case Int16Array:
return 1 / 32767;
case Uint16Array:
return 1 / 65535;
default:
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
}
}
function tn(d) {
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";
}
const nn = new Y();
class sn {
constructor(e = {}, t = {}) {
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new bt(), 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 = {};
let o = !1, n = !1, r = -1;
typeof navigator < "u" && (o = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === !0, n = navigator.userAgent.indexOf("Firefox") > -1, r = n ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1), typeof createImageBitmap > "u" || o || n && r < 98 ? this.textureLoader = new Me(this.options.manager) : this.textureLoader = new qe(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new K(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
}
setExtensions(e) {
this.extensions = e;
}
setPlugins(e) {
this.plugins = e;
}
parse(e, t) {
const o = this, n = this.json, r = this.extensions;
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
return s._markDefs && s._markDefs();
}), Promise.all(this._invokeAll(function(s) {
return s.beforeRoot && s.beforeRoot();
})).then(function() {
return Promise.all([
o.getDependencies("scene"),
o.getDependencies("animation"),
o.getDependencies("camera")
]);
}).then(function(s) {
const a = {
scene: s[0][n.scene || 0],
scenes: s[0],
animations: s[1],
cameras: s[2],
asset: n.asset,
parser: o,
userData: {}
};
return G(r, a, n), F(a, n), Promise.all(o._invokeAll(function(i) {
return i.afterRoot && i.afterRoot(a);
})).then(function() {
for (const i of a.scenes)
i.updateMatrixWorld();
e(a);
});
}).catch(t);
}
/**
* Marks the special nodes/meshes in json for efficient parse.
*/
_markDefs() {
const e = this.json.nodes || [], t = this.json.skins || [], o = this.json.meshes || [];
for (let n = 0, r = t.length; n < r; n++) {
const s = t[n].joints;
for (let a = 0, i = s.length; a < i; a++)
e[s[a]].isBone = !0;
}
for (let n = 0, r = e.length; n < r; n++) {
const s = e[n];
s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (o[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
}
}
/**
* Counts references to shared node / Object3D resources. These resources
* can be reused, or "instantiated", at multiple nodes in the scene
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
* be marked. Non-scenegraph resources (like Materials, Geometries, and
* Textures) can be reused directly and are not marked here.
*
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
*/
_addNodeRef(e, t) {
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
}
/** Returns a reference to a shared resource, cloning it if necessary. */
_getNodeRef(e, t, o) {
if (e.refs[t] <= 1) return o;
const n = o.clone(), r = (s, a) => {
const i = this.associations.get(s);
i != null && this.associations.set(a, i);
for (const [c, u] of s.children.entries())
r(u, a.children[c]);
};
return r(o, n), n.name += "_instance_" + e.uses[t]++, n;
}
_invokeOne(e) {
const t = Object.values(this.plugins);
t.push(this);
for (let o = 0; o < t.length; o++) {
const n = e(t[o]);
if (n) return n;
}
return null;
}
_invokeAll(e) {
const t = Object.values(this.plugins);
t.unshift(this);
const o = [];
for (let n = 0; n < t.length; n++) {
const r = e(t[n]);
r && o.push(r);
}
return o;
}
/**
* Requests the specified dependency asynchronously, with caching.
* @param {string} type
* @param {number} index
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
*/
getDependency(e, t) {
const o = e + ":" + t;
let n = this.cache.get(o);
if (!n) {
switch (e) {
case "scene":
n = this.loadScene(t);
break;
case "node":
n = this._invokeOne(function(r) {
return r.loadNode && r.loadNode(t);
});
break;
case "mesh":
n = this._invokeOne(function(r) {
return r.loadMesh && r.loadMesh(t);
});
break;
case "accessor":
n = this.loadAccessor(t);
break;
case "bufferView":
n = this._invokeOne(function(r) {
return r.loadBufferView && r.loadBufferView(t);
});
break;
case "buffer":
n = this.loadBuffer(t);
break;
case "material":
n = this._invokeOne(function(r) {
return r.loadMaterial && r.loadMaterial(t);
});
break;
case "texture":
n = this._invokeOne(function(r) {
return r.loadTexture && r.loadTexture(t);
});
break;
case "skin":
n = this.loadSkin(t);
break;
case "animation":
n = this._invokeOne(function(r) {
return r.loadAnimation && r.loadAnimation(t);
});
break;
case "camera":
n = this.loadCamera(t);
break;
default:
if (n = this._invokeOne(function(r) {
return r != this && r.getDependency && r.getDependency(e, t);
}), !n)
throw new Error("Unknown type: " + e);
break;
}
this.cache.add(o, n);
}
return n;
}
/**
* Requests all dependencies of the specified type asynchronously, with caching.
* @param {string} type
* @return {Promise<Array<Object>>}
*/
getDependencies(e) {
let t = this.cache.get(e);
if (!t) {
const o = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
t = Promise.all(n.map(function(r, s) {
return o.getDependency(e, s);
})), this.cache.add(e, t);
}
return t;
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferIndex
* @return {Promise<ArrayBuffer>}
*/
loadBuffer(e) {
const t = this.json.buffers[e], o = this.fileLoader;
if (t.type && t.type !== "arraybuffer")
throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
if (t.uri === void 0 && e === 0)
return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);
const n = this.options;
return new Promise(function(r, s) {
o.load(X.resolveURL(t.uri, n.path), r, void 0, function() {
s(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
});
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferViewIndex
* @return {Promise<ArrayBuffer>}
*/
loadBufferView(e) {
const t = this.json.bufferViews[e];
return this.getDependency("buffer", t.buffer).then(function(o) {
const n = t.byteLength || 0, r = t.byteOffset || 0;
return o.slice(r, r + n);
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
* @param {number} accessorIndex
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
*/
loadAccessor(e) {
const t = this, o = this.json, n = this.json.accessors[e];
if (n.bufferView === void 0 && n.sparse === void 0) {
const s = $[n.type], a = j[n.componentType], i = n.normalized === !0, c = new a(n.count * s);
return Promise.resolve(new P(c, s, i));
}
const r = [];
return n.bufferView !== void 0 ? r.push(this.getDependency("bufferView", n.bufferView)) : r.push(null), n.sparse !== void 0 && (r.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(r).then(function(s) {
const a = s[0], i = $[n.type], c = j[n.componentType], u = c.BYTES_PER_ELEMENT, l = u * i, f = n.byteOffset || 0, m = n.bufferView !== void 0 ? o.bufferViews[n.bufferView].byteStride : void 0, T = n.normalized === !0;
let x, y;
if (m && m !== l) {
const R = Math.floor(f / m), E = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + R + ":" + n.count;
let S = t.cache.get(E);
S || (x = new c(a, R * m, n.count * m / u), S = new Ye(x, m / u), t.cache.add(E, S)), y = new Je(S, i, f % m / u, T);
} else
a === null ? x = new c(n.count * i) : x = new c(a, f, n.count * i), y = new P(x, i, T);
if (n.sparse !== void 0) {
const R = $.SCALAR, E = j[n.sparse.indices.componentType], S = n.sparse.indices.byteOffset || 0, _ = n.sparse.values.byteOffset || 0, M = new E(s[1], S, n.sparse.count * R), I = new c(s[2], _, n.sparse.count * i);
a !== null && (y = new P(y.array.slice(), y.itemSize, y.normalized));
for (let L = 0, h = M.length; L < h; L++) {
const p = M[L];
if (y.setX(p, I[L * i]), i >= 2 && y.setY(p, I[L * i + 1]), i >= 3 && y.setZ(p, I[L * i + 2]), i >= 4 && y.setW(p, I[L * i + 3]), i >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
}
}
return y;
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
* @param {number} textureIndex
* @return {Promise<THREE.Texture|null>}
*/
loadTexture(e) {
const t = this.json, o = this.options, r = t.textures[e].source, s = t.images[r];
let a = this.textureLoader;
if (s.uri) {
const i = o.manager.getHandler(s.uri);
i !== null && (a = i);
}
return this.loadTextureImage(e, r, a);
}
loadTextureImage(e, t, o) {
const n = this, r = this.json, s = r.textures[e], a = r.images[t], i = (a.uri || a.bufferView) + ":" + s.sampler;
if (this.textureCache[i])
return this.textureCache[i];
const c = this.loadImageSource(t, o).then(function(u) {
u.flipY = !1, u.name = s.name || a.name || "", u.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (u.name = a.uri);
const f = (r.samplers || {})[s.sampler] || {};
return u.magFilter = we[f.magFilter] || Ce, u.minFilter = we[f.minFilter] || Ie, u.wrapS = Ee[f.wrapS] || J, u.wrapT = Ee[f.wrapT] || J, n.associations.set(u, { textures: e }), u;
}).catch(function() {
return null;
});
return this.textureCache[i] = c, c;
}
loadImageSource(e, t) {
const o = this, n = this.json, r = this.options;
if (this.sourceCache[e] !== void 0)
return this.sourceCache[e].then((l) => l.clone());
const s = n.images[e], a = self.URL || self.webkitURL;
let i = s.uri || "", c = !1;
if (s.bufferView !== void 0)
i = o.getDependency("bufferView", s.bufferView).then(function(l) {
c = !0;
const f = new Blob([l], { type: s.mimeType });
return i = a.createObjectURL(f), i;
});
else if (s.uri === void 0)
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
const u = Promise.resolve(i).then(function(l) {
return new Promise(function(f, m) {
let T = f;
t.isImageBitmapLoader === !0 && (T = function(x) {
const y = new de(x);
y.needsUpdate = !0, f(y);
}), t.load(X.resolveURL(l, r.path), T, void 0, m);
});
}).then(function(l) {
return c === !0 && a.revokeObjectURL(i), l.userData.mimeType = s.mimeType || tn(s.uri), l;
}).catch(function(l) {
throw console.error("THREE.GLTFLoader: Couldn't load texture", i), l;
});
return this.sourceCache[e] = u, u;
}
/**
* Asynchronously assigns a texture to the given material parameters.
* @param {Object} materialParams
* @param {string} mapName
* @param {Object} mapDef
* @return {Promise<Texture>}
*/
assignTexture(e, t, o, n) {
const r = this;
return this.getDependency("texture", o.index).then(function(s) {
if (!s) return null;
if (o.texCoord !== void 0 && o.texCoord > 0 && (s = s.clone(), s.channel = o.texCoord), r.extensions[b.KHR_TEXTURE_TRANSFORM]) {
const a = o.extensions !== void 0 ? o.extensions[b.KHR_TEXTURE_TRANSFORM] : void 0;
if (a) {
const i = r.associations.get(s);
s = r.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), r.associations.set(s, i);
}
}
return n !== void 0 && (s.colorSpace = n), e[t] = s, s;
});
}
/**
* Assigns final material to a Mesh, Line, or Points instance. The instance
* already has a material (generated from the glTF material options alone)
* but reuse of the same glTF material may require multiple threejs materials
* to accommodate different primitive types, defines, etc. New materials will
* be created if necessary, and reused from a cache.
* @param {Object3D} mesh Mesh, Line, or Points instance.
*/
assignFinalMaterial(e) {
const t = e.geometry;
let o = e.material;
const n = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, s = t.attributes.normal === void 0;
if (e.isPoints) {
const a = "PointsMaterial:" + o.uuid;
let i = this.cache.get(a);
i || (i = new tt(), Z.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, i.sizeAttenuation = !1, this.cache.add(a, i)), o = i;
} else if (e.isLine) {
const a = "LineBasicMaterial:" + o.uuid;
let i = this.cache.get(a);
i || (i = new nt(), Z.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, this.cache.add(a, i)), o = i;
}
if (n || r || s) {
let a = "ClonedMaterial:" + o.uuid + ":";
n && (a += "derivative-tangents:"), r && (a += "vertex-colors:"), s && (a += "flat-shading:");
let i = this.cache.get(a);
i || (i = o.clone(), r && (i.vertexColors = !0), s && (i.flatShading = !0), n && (i.normalScale && (i.normalScale.y *= -1), i.clearcoatNormalScale && (i.clearcoatNormalScale.y *= -1)), this.cache.add(a, i), this.associations.set(i, this.associations.get(o))), o = i;
}
e.material = o;
}
getMaterialType() {
return Oe;
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
* @param {number} materialIndex
* @return {Promise<Material>}
*/
loadMaterial(e) {
const t = this, o = this.json, n = this.extensions, r = o.materials[e];
let s;
const a = {}, i = r.extensions || {}, c = [];
if (i[b.KHR_MATERIALS_UNLIT]) {
const l = n[b.KHR_MATERIALS_UNLIT];
s = l.getMaterialType(), c.push(l.extendParams(a, r, t));
} else {
const l = r.pbrMetallicRoughness || {};
if (a.color = new U(1, 1, 1), a.opacity = 1, Array.isArray(l.baseColorFactor)) {
const f = l.baseColorFactor;
a.color.setRGB(f[0], f[1], f[2], D), a.opacity = f[3];
}
l.baseColorTexture !== void 0 && c.push(t.assignTexture(a, "map", l.baseColorTexture, N)), a.metalness = l.metallicFactor !== void 0 ? l.metallicFactor : 1, a.roughness = l.roughnessFactor !== void 0 ? l.roughnessFactor : 1, l.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(a, "metalnessMap", l.metallicRoughnessTexture)), c.push(t.assignTexture(a, "roughnessMap", l.metallicRoughnessTexture))), s = this._invokeOne(function(f) {
return f.getMaterialType && f.getMaterialType(e);
}), c.push(Promise.all(this._invokeAll(function(f) {
return f.extendMaterialParams && f.extendMaterialParams(e, a);
})));
}
r.doubleSided === !0 && (a.side =