UNPKG

@j-kyoda/vue-three-vrm

Version:

A Vue 3 component designed to render and display VRM models on your web pages.

1,342 lines 107 kB
import { getCurrentInstance as ze, useTemplateRef as Xe, watch as F, onMounted as $, createElementBlock as De, openBlock as fe, ref as Z, Fragment as Ye, createVNode as ee, createBlock as We } from "vue"; import * as N from "three"; import { TrianglesDrawMode as Ze, TriangleFanDrawMode as ce, TriangleStripDrawMode as Ce, Loader as qe, LoaderUtils as X, FileLoader as Ie, MeshPhysicalMaterial as O, Vector2 as S, Color as H, LinearSRGBColorSpace as C, SRGBColorSpace as Y, SpotLight as Qe, PointLight as $e, DirectionalLight as Je, Matrix4 as q, Vector3 as M, Quaternion as Q, InstancedMesh as et, InstancedBufferAttribute as tt, Object3D as ve, TextureLoader as st, ImageBitmapLoader as nt, BufferAttribute as te, InterleavedBuffer as it, InterleavedBufferAttribute as ot, LinearMipmapLinearFilter as ke, NearestMipmapLinearFilter as rt, LinearMipmapNearestFilter as at, NearestMipmapNearestFilter as ct, LinearFilter as le, NearestFilter as je, RepeatWrapping as he, MirroredRepeatWrapping as lt, ClampToEdgeWrapping as ht, PointsMaterial as ut, Material as se, LineBasicMaterial as dt, MeshStandardMaterial as Fe, DoubleSide as pt, MeshBasicMaterial as z, PropertyBinding as ft, BufferGeometry as mt, SkinnedMesh as _t, Mesh as gt, LineSegments as Tt, Line as yt, LineLoop as xt, Points as Et, Group as ne, PerspectiveCamera as bt, MathUtils as He, OrthographicCamera as Rt, Skeleton as Mt, AnimationClip as wt, Bone as St, InterpolateDiscrete as At, InterpolateLinear as Ge, Texture as _e, VectorKeyframeTrack as ge, NumberKeyframeTrack as Te, QuaternionKeyframeTrack as ye, ColorManagement as xe, FrontSide as Lt, Interpolant as Pt, Box3 as Nt, Sphere as Ot, Controls as Dt, MOUSE as U, TOUCH as G, Spherical as Ee, Ray as Ct, Plane as It } from "three"; import { VRMHumanBoneName as be, VRMExpressionPresetName as Re, VRMLoaderPlugin as vt, VRMUtils as kt } from "@pixiv/three-vrm"; class Ue { constructor() { } async fetchJSON(e) { const t = await fetch(e); return t.ok ? await t.json() : null; } async fetchPose(e) { const t = await this.fetchJSON(e); return t == null ? null : "pose" in t ? t.pose : t; } async fetchExpression(e) { const t = await this.fetchJSON(e); return t == null ? null : "expressions" in t ? t.expressions : t; } } class jt { constructor() { this.vrm = null; } // getter get scene() { return this.vrm ? this.vrm.scene : null; } // methods setModel(e) { this.vrm = e; } setPosition(e) { this.vrm.scene.position.x = e.x, this.vrm.scene.position.y = e.y, this.vrm.scene.position.z = e.z; } getPosition() { return { x: this.vrm.scene.position.x, y: this.vrm.scene.position.y, z: this.vrm.scene.position.z }; } setPose(e) { this.vrm && this.vrm.humanoid.setNormalizedPose(e); } getPose() { return this.vrm ? this.vrm.humanoid.getNormalizedPose() : null; } updatePose() { this.vrm && this.vrm.humanoid.update(); } resetPose() { this.vrm && this.vrm.humanoid.resetNormalizedPose(); } getBoneNode(e) { return this.vrm ? this.vrm.humanoid.getNormalizedBoneNode(e) : null; } isValid() { return !!this.vrm; } getBoneRotate(e) { const t = this.getBoneNode(e); return t ? { x: t.rotation.x, y: t.rotation.y, z: t.rotation.z } : null; } setBoneRotate(e, t, s, n) { const i = this.getBoneNode(e); i && (i.rotation.x = t, i.rotation.y = s, i.rotation.z = n); } getBonePosition(e) { const t = this.getBoneNode(e); return t ? { x: t.position.x, y: t.position.y, z: t.position.z } : null; } setBonePosition(e, t, s, n) { const i = this.getBoneNode(e); i && (i.position.x = t, i.position.y = s, i.position.z = n); } getMetaVersion() { return this.vrm ? this.vrm.meta.metaVersion : null; } setExpression(e, t) { this.vrm && this.vrm.expressionManager.setValue(e, t); } getExpression(e) { return this.vrm ? this.vrm.expressionManager.getValue(e) : null; } updateExpression() { return this.vrm ? this.vrm.expressionManager.update() : null; } getExpressionNames() { if (this.vrm) { let e = []; for (const t in this.vrm.expressionManager.expressionMap) e.push(t); return e; } return null; } importExpression(e) { if (this.vrm) for (const t in e) this.vrm.expressionManager.setValue(t, e[t]); } exportExpression() { if (this.vrm) { let e = {}; const t = this.getExpressionNames(); for (const s in t) e[s] = this.getExpression(s); return e; } return null; } } class Me { /** * Returns `true` if WebGL 2 is available. * * @return {boolean} Whether WebGL 2 is available or not. */ static isWebGL2Available() { try { const e = document.createElement("canvas"); return !!(window.WebGL2RenderingContext && e.getContext("webgl2")); } catch { return !1; } } /** * Returns `true` if the given color space is available. This method can only be used * if WebGL 2 is supported. * * @param {string} colorSpace - The color space to test. * @return {boolean} Whether the given color space is available or not. */ static isColorSpaceAvailable(e) { try { const t = document.createElement("canvas"), s = window.WebGL2RenderingContext && t.getContext("webgl2"); return s.drawingBufferColorSpace = e, s.drawingBufferColorSpace === e; } catch { return !1; } } /** * Returns a `div` element representing a formatted error message that can be appended in * web sites if WebGL 2 isn't supported. * * @return {HTMLDivElement} A `div` element representing a formatted error message that WebGL 2 isn't supported. */ static getWebGL2ErrorMessage() { return this._getErrorMessage(2); } // private static _getErrorMessage(e) { const t = { 1: "WebGL", 2: "WebGL 2" }, s = { 1: window.WebGLRenderingContext, 2: window.WebGL2RenderingContext }; let n = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>'; const i = document.createElement("div"); return i.id = "webglmessage", i.style.fontFamily = "monospace", i.style.fontSize = "13px", i.style.fontWeight = "normal", i.style.textAlign = "center", i.style.background = "#fff", i.style.color = "#000", i.style.padding = "1.5em", i.style.width = "400px", i.style.margin = "5em auto 0", s[e] ? n = n.replace("$0", "graphics card") : n = n.replace("$0", "browser"), n = n.replace("$1", t[e]), i.innerHTML = n, i; } // @deprecated, r168 static isWebGLAvailable() { console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead."); try { const e = document.createElement("canvas"); return !!(window.WebGLRenderingContext && (e.getContext("webgl") || e.getContext("experimental-webgl"))); } catch { return !1; } } static getWebGLErrorMessage() { return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."), this._getErrorMessage(1); } } function we(l, e) { if (e === Ze) return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), l; if (e === ce || e === Ce) { let t = l.getIndex(); if (t === null) { const o = [], r = l.getAttribute("position"); if (r !== void 0) { for (let a = 0; a < r.count; a++) o.push(a); l.setIndex(o), t = l.getIndex(); } else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), l; } const s = t.count - 2, n = []; if (e === ce) for (let o = 1; o <= s; o++) n.push(t.getX(0)), n.push(t.getX(o)), n.push(t.getX(o + 1)); else for (let o = 0; o < s; o++) o % 2 === 0 ? (n.push(t.getX(o)), n.push(t.getX(o + 1)), n.push(t.getX(o + 2))) : (n.push(t.getX(o + 2)), n.push(t.getX(o + 1)), n.push(t.getX(o))); n.length / 3 !== s && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."); const i = l.clone(); return i.setIndex(n), i.clearGroups(), i; } else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), l; } class ue extends qe { /** * Constructs a new glTF loader. * * @param {LoadingManager} [manager] - The loading manager. */ constructor(e) { super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) { return new Kt(t); }), this.register(function(t) { return new Bt(t); }), this.register(function(t) { return new $t(t); }), this.register(function(t) { return new Jt(t); }), this.register(function(t) { return new es(t); }), this.register(function(t) { return new zt(t); }), this.register(function(t) { return new Xt(t); }), this.register(function(t) { return new Yt(t); }), this.register(function(t) { return new Wt(t); }), this.register(function(t) { return new Ut(t); }), this.register(function(t) { return new Zt(t); }), this.register(function(t) { return new Vt(t); }), this.register(function(t) { return new Qt(t); }), this.register(function(t) { return new qt(t); }), this.register(function(t) { return new Ht(t); }), this.register(function(t) { return new ts(t); }), this.register(function(t) { return new ss(t); }); } /** * Starts loading from the given URL and passes the loaded glTF asset * to the `onLoad()` callback. * * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI. * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished. * @param {onProgressCallback} onProgress - Executed while the loading is in progress. * @param {onErrorCallback} onError - Executed when errors occur. */ load(e, t, s, n) { const i = this; let o; if (this.resourcePath !== "") o = this.resourcePath; else if (this.path !== "") { const c = X.extractUrlBase(e); o = X.resolveURL(c, this.path); } else o = X.extractUrlBase(e); this.manager.itemStart(e); const r = function(c) { n ? n(c) : console.error(c), i.manager.itemError(e), i.manager.itemEnd(e); }, a = new Ie(this.manager); a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(c) { try { i.parse(c, o, function(u) { t(u), i.manager.itemEnd(e); }, r); } catch (u) { r(u); } }, s, r); } /** * Sets the given Draco loader to this loader. Required for decoding assets * compressed with the `KHR_draco_mesh_compression` extension. * * @param {DRACOLoader} dracoLoader - The Draco loader to set. * @return {GLTFLoader} A reference to this loader. */ setDRACOLoader(e) { return this.dracoLoader = e, this; } /** * Sets the given KTX2 loader to this loader. Required for loading KTX2 * compressed textures. * * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set. * @return {GLTFLoader} A reference to this loader. */ setKTX2Loader(e) { return this.ktx2Loader = e, this; } /** * Sets the given meshopt decoder. Required for decoding assets * compressed with the `EXT_meshopt_compression` extension. * * @param {Object} meshoptDecoder - The meshopt decoder to set. * @return {GLTFLoader} A reference to this loader. */ setMeshoptDecoder(e) { return this.meshoptDecoder = e, this; } /** * Registers a plugin callback. This API is internally used to implement the various * glTF extensions but can also used by third-party code to add additional logic * to the loader. * * @param {function(parser:GLTFParser)} callback - The callback function to register. * @return {GLTFLoader} A reference to this loader. */ register(e) { return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this; } /** * Unregisters a plugin callback. * * @param {Function} callback - The callback function to unregister. * @return {GLTFLoader} A reference to this loader. */ unregister(e) { return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this; } /** * Parses the given FBX data and returns the resulting group. * * @param {string|ArrayBuffer} data - The raw glTF data. * @param {string} path - The URL base path. * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished. * @param {onErrorCallback} onError - Executed when errors occur. */ parse(e, t, s, n) { let i; const o = {}, r = {}, a = new TextDecoder(); if (typeof e == "string") i = JSON.parse(e); else if (e instanceof ArrayBuffer) if (a.decode(new Uint8Array(e, 0, 4)) === Ke) { try { o[y.KHR_BINARY_GLTF] = new ns(e); } catch (h) { n && n(h); return; } i = JSON.parse(o[y.KHR_BINARY_GLTF].content); } else i = JSON.parse(a.decode(e)); else i = e; if (i.asset === void 0 || i.asset.version[0] < 2) { n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")); return; } const c = new _s(i, { 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 h = this.pluginCallbacks[u](c); h.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), r[h.name] = h, o[h.name] = !0; } if (i.extensionsUsed) for (let u = 0; u < i.extensionsUsed.length; ++u) { const h = i.extensionsUsed[u], d = i.extensionsRequired || []; switch (h) { case y.KHR_MATERIALS_UNLIT: o[h] = new Gt(); break; case y.KHR_DRACO_MESH_COMPRESSION: o[h] = new is(i, this.dracoLoader); break; case y.KHR_TEXTURE_TRANSFORM: o[h] = new os(); break; case y.KHR_MESH_QUANTIZATION: o[h] = new rs(); break; default: d.indexOf(h) >= 0 && r[h] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + h + '".'); } } c.setExtensions(o), c.setPlugins(r), c.parse(s, n); } /** * Async version of {@link GLTFLoader#parse}. * * @async * @param {string|ArrayBuffer} data - The raw glTF data. * @param {string} path - The URL base path. * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished. */ parseAsync(e, t) { const s = this; return new Promise(function(n, i) { s.parse(e, t, n, i); }); } } function Ft() { let l = {}; return { get: function(e) { return l[e]; }, add: function(e, t) { l[e] = t; }, remove: function(e) { delete l[e]; }, removeAll: function() { l = {}; } }; } const y = { 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_DISPERSION: "KHR_materials_dispersion", 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 Ht { constructor(e) { this.parser = e, this.name = y.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} }; } _markDefs() { const e = this.parser, t = this.parser.json.nodes || []; for (let s = 0, n = t.length; s < n; s++) { const i = t[s]; i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, i.extensions[this.name].light); } } _loadLight(e) { const t = this.parser, s = "light:" + e; let n = t.cache.get(s); if (n) return n; const i = t.json, a = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e]; let c; const u = new H(16777215); a.color !== void 0 && u.setRGB(a.color[0], a.color[1], a.color[2], C); const h = a.range !== void 0 ? a.range : 0; switch (a.type) { case "directional": c = new Je(u), c.target.position.set(0, 0, -1), c.add(c.target); break; case "point": c = new $e(u), c.distance = h; break; case "spot": c = new Qe(u), c.distance = h, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, c.angle = a.spot.outerConeAngle, c.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target); break; default: throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type); } return c.position.set(0, 0, 0), D(c, a), a.intensity !== void 0 && (c.intensity = a.intensity), c.name = t.createUniqueName(a.name || "light_" + e), n = Promise.resolve(c), t.cache.add(s, n), n; } getDependency(e, t) { if (e === "light") return this._loadLight(t); } createNodeAttachment(e) { const t = this, s = this.parser, i = s.json.nodes[e], r = (i.extensions && i.extensions[this.name] || {}).light; return r === void 0 ? null : this._loadLight(r).then(function(a) { return s._getNodeRef(t.cache, r, a); }); } } class Gt { constructor() { this.name = y.KHR_MATERIALS_UNLIT; } getMaterialType() { return z; } extendParams(e, t, s) { const n = []; e.color = new H(1, 1, 1), e.opacity = 1; const i = t.pbrMetallicRoughness; if (i) { if (Array.isArray(i.baseColorFactor)) { const o = i.baseColorFactor; e.color.setRGB(o[0], o[1], o[2], C), e.opacity = o[3]; } i.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", i.baseColorTexture, Y)); } return Promise.all(n); } } class Ut { constructor(e) { this.parser = e, this.name = y.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 i = n.extensions[this.name].emissiveStrength; return i !== void 0 && (t.emissiveIntensity = i), Promise.resolve(); } } class Kt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_CLEARCOAT; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; if (o.clearcoatFactor !== void 0 && (t.clearcoat = o.clearcoatFactor), o.clearcoatTexture !== void 0 && i.push(s.assignTexture(t, "clearcoatMap", o.clearcoatTexture)), o.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = o.clearcoatRoughnessFactor), o.clearcoatRoughnessTexture !== void 0 && i.push(s.assignTexture(t, "clearcoatRoughnessMap", o.clearcoatRoughnessTexture)), o.clearcoatNormalTexture !== void 0 && (i.push(s.assignTexture(t, "clearcoatNormalMap", o.clearcoatNormalTexture)), o.clearcoatNormalTexture.scale !== void 0)) { const r = o.clearcoatNormalTexture.scale; t.clearcoatNormalScale = new S(r, r); } return Promise.all(i); } } class Bt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_DISPERSION; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.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 i = n.extensions[this.name]; return t.dispersion = i.dispersion !== void 0 ? i.dispersion : 0, Promise.resolve(); } } class Vt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_IRIDESCENCE; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.iridescenceFactor !== void 0 && (t.iridescence = o.iridescenceFactor), o.iridescenceTexture !== void 0 && i.push(s.assignTexture(t, "iridescenceMap", o.iridescenceTexture)), o.iridescenceIor !== void 0 && (t.iridescenceIOR = o.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), o.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = o.iridescenceThicknessMinimum), o.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = o.iridescenceThicknessMaximum), o.iridescenceThicknessTexture !== void 0 && i.push(s.assignTexture(t, "iridescenceThicknessMap", o.iridescenceThicknessTexture)), Promise.all(i); } } class zt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_SHEEN; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = []; t.sheenColor = new H(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1; const o = n.extensions[this.name]; if (o.sheenColorFactor !== void 0) { const r = o.sheenColorFactor; t.sheenColor.setRGB(r[0], r[1], r[2], C); } return o.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = o.sheenRoughnessFactor), o.sheenColorTexture !== void 0 && i.push(s.assignTexture(t, "sheenColorMap", o.sheenColorTexture, Y)), o.sheenRoughnessTexture !== void 0 && i.push(s.assignTexture(t, "sheenRoughnessMap", o.sheenRoughnessTexture)), Promise.all(i); } } class Xt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_TRANSMISSION; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.transmissionFactor !== void 0 && (t.transmission = o.transmissionFactor), o.transmissionTexture !== void 0 && i.push(s.assignTexture(t, "transmissionMap", o.transmissionTexture)), Promise.all(i); } } class Yt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_VOLUME; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; t.thickness = o.thicknessFactor !== void 0 ? o.thicknessFactor : 0, o.thicknessTexture !== void 0 && i.push(s.assignTexture(t, "thicknessMap", o.thicknessTexture)), t.attenuationDistance = o.attenuationDistance || 1 / 0; const r = o.attenuationColor || [1, 1, 1]; return t.attenuationColor = new H().setRGB(r[0], r[1], r[2], C), Promise.all(i); } } class Wt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_IOR; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.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 i = n.extensions[this.name]; return t.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve(); } } class Zt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_SPECULAR; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; t.specularIntensity = o.specularFactor !== void 0 ? o.specularFactor : 1, o.specularTexture !== void 0 && i.push(s.assignTexture(t, "specularIntensityMap", o.specularTexture)); const r = o.specularColorFactor || [1, 1, 1]; return t.specularColor = new H().setRGB(r[0], r[1], r[2], C), o.specularColorTexture !== void 0 && i.push(s.assignTexture(t, "specularColorMap", o.specularColorTexture, Y)), Promise.all(i); } } class qt { constructor(e) { this.parser = e, this.name = y.EXT_MATERIALS_BUMP; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return t.bumpScale = o.bumpFactor !== void 0 ? o.bumpFactor : 1, o.bumpTexture !== void 0 && i.push(s.assignTexture(t, "bumpMap", o.bumpTexture)), Promise.all(i); } } class Qt { constructor(e) { this.parser = e, this.name = y.KHR_MATERIALS_ANISOTROPY; } getMaterialType(e) { const s = this.parser.json.materials[e]; return !s.extensions || !s.extensions[this.name] ? null : O; } extendMaterialParams(e, t) { const s = this.parser, n = s.json.materials[e]; if (!n.extensions || !n.extensions[this.name]) return Promise.resolve(); const i = [], o = n.extensions[this.name]; return o.anisotropyStrength !== void 0 && (t.anisotropy = o.anisotropyStrength), o.anisotropyRotation !== void 0 && (t.anisotropyRotation = o.anisotropyRotation), o.anisotropyTexture !== void 0 && i.push(s.assignTexture(t, "anisotropyMap", o.anisotropyTexture)), Promise.all(i); } } class $t { constructor(e) { this.parser = e, this.name = y.KHR_TEXTURE_BASISU; } loadTexture(e) { const t = this.parser, s = t.json, n = s.textures[e]; if (!n.extensions || !n.extensions[this.name]) return null; const i = n.extensions[this.name], o = t.options.ktx2Loader; if (!o) { if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0) throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures"); return null; } return t.loadTextureImage(e, i.source, o); } } class Jt { constructor(e) { this.parser = e, this.name = y.EXT_TEXTURE_WEBP; } loadTexture(e) { const t = this.name, s = this.parser, n = s.json, i = n.textures[e]; if (!i.extensions || !i.extensions[t]) return null; const o = i.extensions[t], r = n.images[o.source]; let a = s.textureLoader; if (r.uri) { const c = s.options.manager.getHandler(r.uri); c !== null && (a = c); } return s.loadTextureImage(e, o.source, a); } } class es { constructor(e) { this.parser = e, this.name = y.EXT_TEXTURE_AVIF; } loadTexture(e) { const t = this.name, s = this.parser, n = s.json, i = n.textures[e]; if (!i.extensions || !i.extensions[t]) return null; const o = i.extensions[t], r = n.images[o.source]; let a = s.textureLoader; if (r.uri) { const c = s.options.manager.getHandler(r.uri); c !== null && (a = c); } return s.loadTextureImage(e, o.source, a); } } class ts { constructor(e) { this.name = y.EXT_MESHOPT_COMPRESSION, this.parser = e; } loadBufferView(e) { const t = this.parser.json, s = t.bufferViews[e]; if (s.extensions && s.extensions[this.name]) { const n = s.extensions[this.name], i = this.parser.getDependency("buffer", n.buffer), o = this.parser.options.meshoptDecoder; if (!o || !o.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 i.then(function(r) { const a = n.byteOffset || 0, c = n.byteLength || 0, u = n.count, h = n.byteStride, d = new Uint8Array(r, a, c); return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(u, h, d, n.mode, n.filter).then(function(p) { return p.buffer; }) : o.ready.then(function() { const p = new ArrayBuffer(u * h); return o.decodeGltfBuffer(new Uint8Array(p), u, h, d, n.mode, n.filter), p; }); }); } else return null; } } class ss { constructor(e) { this.name = y.EXT_MESH_GPU_INSTANCING, this.parser = e; } createNodeMesh(e) { const t = this.parser.json, s = t.nodes[e]; if (!s.extensions || !s.extensions[this.name] || s.mesh === void 0) return null; const n = t.meshes[s.mesh]; for (const c of n.primitives) if (c.mode !== L.TRIANGLES && c.mode !== L.TRIANGLE_STRIP && c.mode !== L.TRIANGLE_FAN && c.mode !== void 0) return null; const o = s.extensions[this.name].attributes, r = [], a = {}; for (const c in o) r.push(this.parser.getDependency("accessor", o[c]).then((u) => (a[c] = u, a[c]))); return r.length < 1 ? null : (r.push(this.parser.createNodeMesh(e)), Promise.all(r).then((c) => { const u = c.pop(), h = u.isGroup ? u.children : [u], d = c[0].count, p = []; for (const m of h) { const g = new q(), f = new M(), _ = new Q(), x = new M(1, 1, 1), b = new et(m.geometry, m.material, d); for (let T = 0; T < d; T++) a.TRANSLATION && f.fromBufferAttribute(a.TRANSLATION, T), a.ROTATION && _.fromBufferAttribute(a.ROTATION, T), a.SCALE && x.fromBufferAttribute(a.SCALE, T), b.setMatrixAt(T, g.compose(f, _, x)); for (const T in a) if (T === "_COLOR_0") { const A = a[T]; b.instanceColor = new tt(A.array, A.itemSize, A.normalized); } else T !== "TRANSLATION" && T !== "ROTATION" && T !== "SCALE" && m.geometry.setAttribute(T, a[T]); ve.prototype.copy.call(b, m), this.parser.assignFinalMaterial(b), p.push(b); } return u.isGroup ? (u.clear(), u.add(...p), u) : p[0]; })); } } const Ke = "glTF", V = 12, Se = { JSON: 1313821514, BIN: 5130562 }; class ns { constructor(e) { this.name = y.KHR_BINARY_GLTF, this.content = null, this.body = null; const t = new DataView(e, 0, V), s = new TextDecoder(); if (this.header = { magic: s.decode(new Uint8Array(e.slice(0, 4))), version: t.getUint32(4, !0), length: t.getUint32(8, !0) }, this.header.magic !== Ke) 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, i = new DataView(e, V); let o = 0; for (; o < n; ) { const r = i.getUint32(o, !0); o += 4; const a = i.getUint32(o, !0); if (o += 4, a === Se.JSON) { const c = new Uint8Array(e, V + o, r); this.content = s.decode(c); } else if (a === Se.BIN) { const c = V + o; this.body = e.slice(c, c + r); } o += r; } if (this.content === null) throw new Error("THREE.GLTFLoader: JSON content not found."); } } class is { constructor(e, t) { if (!t) throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided."); this.name = y.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload(); } decodePrimitive(e, t) { const s = this.json, n = this.dracoLoader, i = e.extensions[this.name].bufferView, o = e.extensions[this.name].attributes, r = {}, a = {}, c = {}; for (const u in o) { const h = de[u] || u.toLowerCase(); r[h] = o[u]; } for (const u in e.attributes) { const h = de[u] || u.toLowerCase(); if (o[u] !== void 0) { const d = s.accessors[e.attributes[u]], p = K[d.componentType]; c[h] = p.name, a[h] = d.normalized === !0; } } return t.getDependency("bufferView", i).then(function(u) { return new Promise(function(h, d) { n.decodeDracoFile(u, function(p) { for (const m in p.attributes) { const g = p.attributes[m], f = a[m]; f !== void 0 && (g.normalized = f); } h(p); }, r, c, C, d); }); }); } } class os { constructor() { this.name = y.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 rs { constructor() { this.name = y.KHR_MESH_QUANTIZATION; } } class Be extends Pt { constructor(e, t, s, n) { super(e, t, s, n); } copySampleValue_(e) { const t = this.resultBuffer, s = this.sampleValues, n = this.valueSize, i = e * n * 3 + n; for (let o = 0; o !== n; o++) t[o] = s[i + o]; return t; } interpolate_(e, t, s, n) { const i = this.resultBuffer, o = this.sampleValues, r = this.valueSize, a = r * 2, c = r * 3, u = n - t, h = (s - t) / u, d = h * h, p = d * h, m = e * c, g = m - c, f = -2 * p + 3 * d, _ = p - d, x = 1 - f, b = _ - d + h; for (let T = 0; T !== r; T++) { const A = o[g + T + r], I = o[g + T + a] * u, P = o[m + T + r], B = o[m + T] * u; i[T] = x * A + b * I + f * P + _ * B; } return i; } } const as = new Q(); class cs extends Be { interpolate_(e, t, s, n) { const i = super.interpolate_(e, t, s, n); return as.fromArray(i).normalize().toArray(i), i; } } const L = { POINTS: 0, LINES: 1, LINE_LOOP: 2, LINE_STRIP: 3, TRIANGLES: 4, TRIANGLE_STRIP: 5, TRIANGLE_FAN: 6 }, K = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array }, Ae = { 9728: je, 9729: le, 9984: ct, 9985: at, 9986: rt, 9987: ke }, Le = { 33071: ht, 33648: lt, 10497: he }, ie = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }, de = { 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" }, ls = { 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: Ge, STEP: At }, oe = { OPAQUE: "OPAQUE", MASK: "MASK", BLEND: "BLEND" }; function hs(l) { return l.DefaultMaterial === void 0 && (l.DefaultMaterial = new Fe({ color: 16777215, emissive: 0, metalness: 1, roughness: 1, transparent: !1, depthTest: !0, side: Lt })), l.DefaultMaterial; } function j(l, e, t) { for (const s in t.extensions) l[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]); } function D(l, e) { e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(l.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras)); } function us(l, e, t) { let s = !1, n = !1, i = !1; for (let c = 0, u = e.length; c < u; c++) { const h = e[c]; if (h.POSITION !== void 0 && (s = !0), h.NORMAL !== void 0 && (n = !0), h.COLOR_0 !== void 0 && (i = !0), s && n && i) break; } if (!s && !n && !i) return Promise.resolve(l); const o = [], r = [], a = []; for (let c = 0, u = e.length; c < u; c++) { const h = e[c]; if (s) { const d = h.POSITION !== void 0 ? t.getDependency("accessor", h.POSITION) : l.attributes.position; o.push(d); } if (n) { const d = h.NORMAL !== void 0 ? t.getDependency("accessor", h.NORMAL) : l.attributes.normal; r.push(d); } if (i) { const d = h.COLOR_0 !== void 0 ? t.getDependency("accessor", h.COLOR_0) : l.attributes.color; a.push(d); } } return Promise.all([ Promise.all(o), Promise.all(r), Promise.all(a) ]).then(function(c) { const u = c[0], h = c[1], d = c[2]; return s && (l.morphAttributes.position = u), n && (l.morphAttributes.normal = h), i && (l.morphAttributes.color = d), l.morphTargetsRelative = !0, l; }); } function ds(l, e) { if (l.updateMorphTargets(), e.weights !== void 0) for (let t = 0, s = e.weights.length; t < s; t++) l.morphTargetInfluences[t] = e.weights[t]; if (e.extras && Array.isArray(e.extras.targetNames)) { const t = e.extras.targetNames; if (l.morphTargetInfluences.length === t.length) { l.morphTargetDictionary = {}; for (let s = 0, n = t.length; s < n; s++) l.morphTargetDictionary[t[s]] = s; } else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names."); } } function ps(l) { let e; const t = l.extensions && l.extensions[y.KHR_DRACO_MESH_COMPRESSION]; if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + re(t.attributes) : e = l.indices + ":" + re(l.attributes) + ":" + l.mode, l.targets !== void 0) for (let s = 0, n = l.targets.length; s < n; s++) e += ":" + re(l.targets[s]); return e; } function re(l) { let e = ""; const t = Object.keys(l).sort(); for (let s = 0, n = t.length; s < n; s++) e += t[s] + ":" + l[t[s]] + ";"; return e; } function pe(l) { switch (l) { 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 fs(l) { return l.search(/\.jpe?g($|\?)/i) > 0 || l.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : l.search(/\.webp($|\?)/i) > 0 || l.search(/^data\:image\/webp/) === 0 ? "image/webp" : l.search(/\.ktx2($|\?)/i) > 0 || l.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png"; } const ms = new q(); class _s { constructor(e = {}, t = {}) { this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Ft(), 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 s = !1, n = -1, i = !1, o = -1; if (typeof navigator < "u") { const r = navigator.userAgent; s = /^((?!chrome|android).)*safari/i.test(r) === !0; const a = r.match(/Version\/(\d+)/); n = s && a ? parseInt(a[1], 10) : -1, i = r.indexOf("Firefox") > -1, o = i ? r.match(/Firefox\/([0-9]+)\./)[1] : -1; } typeof createImageBitmap > "u" || s && n < 17 || i && o < 98 ? this.textureLoader = new st(this.options.manager) : this.textureLoader = new nt(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Ie(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 s = this, n = this.json, i = this.extensions; this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) { return o._markDefs && o._markDefs(); }), Promise.all(this._invokeAll(function(o) { return o.beforeRoot && o.beforeRoot(); })).then(function() { return Promise.all([ s.getDependencies("scene"), s.getDependencies("animation"), s.getDependencies("camera") ]); }).then(function(o) { const r = { scene: o[0][n.scene || 0], scenes: o[0], animations: o[1], cameras: o[2], asset: n.asset, parser: s, userData: {} }; return j(i, r, n), D(r, n), Promise.all(s._invokeAll(function(a) { return a.afterRoot && a.afterRoot(r); })).then(function() { for (const a of r.scenes) a.updateMatrixWorld(); e(r); }); }).catch(t); } /** * Marks the special nodes/meshes in json for efficient parse. * * @private */ _markDefs() { const e = this.json.nodes || [], t = this.json.skins || [], s = this.json.meshes || []; for (let n = 0, i = t.length; n < i; n++) { const o = t[n].joints; for (let r = 0, a = o.length; r < a; r++) e[o[r]].isBone = !0; } for (let n = 0, i = e.length; n < i; n++) { const o = e[n]; o.mesh !== void 0 && (this._addNodeRef(this.meshCache, o.mesh), o.skin !== void 0 && (s[o.mesh].isSkinnedMesh = !0)), o.camera !== void 0 && this._addNodeRef(this.cameraCache, o.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. * * @private * @param {Object} cache * @param {Object3D} index */ _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. * * @private * @param {Object} cache * @param {number} index * @param {Object} object * @return {Object} */ _getNodeRef(e, t, s) { if (e.refs[t] <= 1) return s; const n = s.clone(), i = (o, r) => { const a = this.associations.get(o); a != null && this.associations.set(r, a); for (const [c, u] of o.children.entries()) i(u, r.children[c]); }; return i(s, n), n.name += "_instance_" + e.uses[t]++, n; } _invokeOne(e) { const t = Object.values(this.plugins); t.push(this); for (let s = 0; s < t.length; s++) { const n = e(t[s]); if (n) return n; } return null; } _invokeAll(e) { const t = Object.values(this.plugins); t.unshift(this); const s = []; for (let n = 0; n < t.length; n++) { const i = e(t[n]); i && s.push(i); } return s; } /** * Requests the specified dependency asynchronously, with caching. * * @private * @param {string} type * @param {number} index * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>} */ getDependency(e, t) { const s = e + ":" + t; let n = this.cache.get(s); if (!n) { switch (e) { case "scene": n = this.loadScene(t); break; case "node": n = this._invokeOne(function(i) { return i.loadNode && i.loadNode(t); }); break; case "mesh": n = this._invokeOne(function(i) { return i.loadMesh && i.loadMesh(t); }); break; case "accessor": n = this.loadAccessor(t); break; case "bufferView": n = this._invokeOne(function(i) { return i.loadBufferView && i.loadBufferView(t); }); break; case "buffer": n = this.loadBuffer(t); break; case "material": n = this._invokeOne(function(i) { return i.loadMaterial && i.loadMaterial(t); }); break; case "texture": n = this._invokeOne(function(i) { return i.loadTexture && i.loadTexture(t); }); break; case "skin": n = this.loadSkin(t); break; case "animation": n = this._invokeOne(function(i) { return i.loadAnimation && i.loadAnimation(t); }); break; case "camera": n = this.loadCamera(t); break; default: if (n = this._invokeOne(function(i) { return i != this && i.getDependency && i.getDependency(e, t); }), !n) throw new Error("Unknown type: " + e); break; } this.cache.add(s, n); } return n; } /** * Requests all dependencies of the specified type asynchronously, with caching. * * @private * @param {string} type * @return {Promise<Array<Object>>} */ getDependencies(e) { let t = this.cache.get(e); if (!t) { const s = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || []; t = Promise.all(n.map(function(i, o) { return s.getDependency(e, o); })), this.cache.add(e, t); } return t; } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views * * @private * @param {number} bufferIndex * @return {Promise<ArrayBuffer>} */ loadBuffer(e) { const t = this.json.buffers[e], s = 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[y.KHR_BINARY_GLTF].body); const n = this.options; return new Promise(function(i, o) { s.load(X.resolveURL(t.uri, n.path), i, void 0, function() { o(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 * * @private * @param {number} bufferViewIndex * @return {Promise<ArrayBuffer>} */ loadBufferView(e) { const t = this.json.bufferViews[e]; return this.getDependency("buffer", t.buffer).then(function(s) { const n = t.byteLength || 0, i = t.byteOffset || 0; return s.slice(i, i + n); }); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors * * @private * @param {number} accessorIndex * @return {Promise<BufferAttribute|InterleavedBufferAttribute>} */ loadAccessor(e) { const t = this, s = this.json, n = this.json.accessors[e]; if (n.bufferView === void 0 && n.sparse === void 0) { const o = ie[n.type], r = K[n.componentType], a = n.normalized === !0, c = new r(n.count * o); return Promise.resolve(new te(c, o, a)); } const i = []; return n.bufferView !== void 0 ? i.push(this.getDependency("bufferView", n.bufferView)) : i.push(null), n.sparse !== void 0 && (i.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(i).then(function(o) { const r = o[0], a = ie[n.type], c = K[n.componentType], u = c.BYTES_PER_ELEMENT, h = u * a, d = n.byteOffset || 0, p = n.bufferView !== void 0 ? s.bufferViews[n.bufferView].byteStride : void 0, m = n.normalized === !0; let g, f; if (p && p !== h) { const _ = Math.floor(d / p), x = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + _ + ":" +