@j-kyoda/vue-three-vrm 0.12.1 → 0.13.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/README.md +18 -0
- package/dist/vue-three-vrm.es.js +18 -17
- package/dist/vue-three-vrm.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,24 @@ const cb_animate = (context) => {
|
|
|
167
167
|
| loading | Occurs while the VRoid model is loading. | VRoid model name |
|
|
168
168
|
| loaded | Occurs when the VRoid model has finished loading. | VRoid model name, VRMModel instance |
|
|
169
169
|
|
|
170
|
+
## GltfControl
|
|
171
|
+
|
|
172
|
+
### Props
|
|
173
|
+
|
|
174
|
+
| ID | Type | default | Description |
|
|
175
|
+
| :-------------- | :----- | :----------- | :------------------------------------------------------ |
|
|
176
|
+
| name | String | '' | The name of the GLTF model. |
|
|
177
|
+
| url | String | '' | The URL of the GLTF model. |
|
|
178
|
+
| data | Object | null | The object for the GLTF model. |
|
|
179
|
+
|
|
180
|
+
### Events (Emits)
|
|
181
|
+
|
|
182
|
+
| Event | Description | Payload |
|
|
183
|
+
| :--------- | :------------------------------------------------ | :----------------------------------- |
|
|
184
|
+
| loading | Occurs while the GLTF model is loading. | GLTF model name |
|
|
185
|
+
| loaded | Occurs when the GLTF model has finished loading. | GLTF model name, GltfModel instance |
|
|
186
|
+
|
|
187
|
+
|
|
170
188
|
|
|
171
189
|
## License
|
|
172
190
|
|
package/dist/vue-three-vrm.es.js
CHANGED
|
@@ -661,7 +661,7 @@ class yn {
|
|
|
661
661
|
}
|
|
662
662
|
extendMaterialParams(e, t) {
|
|
663
663
|
const n = b(this.parser, e, this.name);
|
|
664
|
-
return n === null || (t.ior = n.ior !== void 0 ? n.ior : 1.5), Promise.resolve();
|
|
664
|
+
return n === null || (t.ior = n.ior !== void 0 ? n.ior : 1.5, t.ior === 0 && (t.ior = 1e3)), Promise.resolve();
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
class xn {
|
|
@@ -1778,34 +1778,35 @@ class Vn {
|
|
|
1778
1778
|
}
|
|
1779
1779
|
_createAnimationTracks(e, t, n, s, i) {
|
|
1780
1780
|
const o = [], a = e.name ? e.name : e.uuid, r = [];
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1781
|
+
function c(p) {
|
|
1782
|
+
p.morphTargetInfluences && r.push(p.name ? p.name : p.uuid);
|
|
1783
|
+
}
|
|
1784
|
+
H[i.path] === H.weights ? (c(e), e.isGroup && e.children.forEach(c)) : r.push(a);
|
|
1785
|
+
let h;
|
|
1785
1786
|
switch (H[i.path]) {
|
|
1786
1787
|
case H.weights:
|
|
1787
|
-
|
|
1788
|
+
h = Pe;
|
|
1788
1789
|
break;
|
|
1789
1790
|
case H.rotation:
|
|
1790
|
-
|
|
1791
|
+
h = ve;
|
|
1791
1792
|
break;
|
|
1792
1793
|
case H.translation:
|
|
1793
1794
|
case H.scale:
|
|
1794
|
-
|
|
1795
|
+
h = Se;
|
|
1795
1796
|
break;
|
|
1796
1797
|
default:
|
|
1797
|
-
n.itemSize === 1 ?
|
|
1798
|
+
n.itemSize === 1 ? h = Pe : h = Se;
|
|
1798
1799
|
break;
|
|
1799
1800
|
}
|
|
1800
|
-
const
|
|
1801
|
-
for (let
|
|
1802
|
-
const
|
|
1803
|
-
r[
|
|
1801
|
+
const u = s.interpolation !== void 0 ? On[s.interpolation] : at, d = this._getArrayFromAccessor(n);
|
|
1802
|
+
for (let p = 0, f = r.length; p < f; p++) {
|
|
1803
|
+
const T = new h(
|
|
1804
|
+
r[p] + "." + H[i.path],
|
|
1804
1805
|
t.array,
|
|
1805
|
-
|
|
1806
|
-
|
|
1806
|
+
d,
|
|
1807
|
+
u
|
|
1807
1808
|
);
|
|
1808
|
-
s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(
|
|
1809
|
+
s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(T), o.push(T);
|
|
1809
1810
|
}
|
|
1810
1811
|
return o;
|
|
1811
1812
|
}
|
|
@@ -1924,7 +1925,7 @@ class Gn extends nn {
|
|
|
1924
1925
|
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
|
|
1925
1926
|
}
|
|
1926
1927
|
disconnect() {
|
|
1927
|
-
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "
|
|
1928
|
+
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "";
|
|
1928
1929
|
}
|
|
1929
1930
|
dispose() {
|
|
1930
1931
|
this.disconnect();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(ae);function Ve(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const _=Ve(u);class K{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}normalizePose(e){return e==null?null:"pose"in e?e.pose:e}async fetchPose(e){const t=await this.fetchJSON(e);return this.normalizePose(t)}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class le{constructor(){this.vrm=null,this.vrma=null,this.mixer=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setVrma(e){this.vrma=e}setMixer(e){this.mixer=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,n,s){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=n,i.rotation.z=s)}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,n,s){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=n,i.position.z=s)}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}resetExpression(){return this.vrm?this.vrm.expressionManager.resetValues():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 n in t)e[n]=this.getExpression(n);return e}return null}updateAnimation(e){this.mixer&&this.mixer.update(e),this.vrm&&this.vrm.update(e)}}class ce{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),n=window.WebGL2RenderingContext&&t.getContext("webgl2");return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let s='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",n[e]?s=s.replace("$0","graphics card"):s=s.replace("$0","browser"),s=s.replace("$1",t[e]),i.innerHTML=s,i}}function he(l,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],a=l.getAttribute("position");if(a!==void 0){for(let r=0;r<a.count;r++)o.push(r);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=t.count-2,s=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}function Ue(l){const e=new Map,t=new Map,n=l.clone();return ue(l,n,function(s,i){e.set(i,s),t.set(s,i)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),a=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=a.map(function(r){return t.get(r)}),i.bind(i.skeleton,i.bindMatrix)}),n}function ue(l,e,t){t(l,e);for(let n=0;n<l.children.length;n++)ue(l.children[n],e.children[n],t)}class z extends u.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ke(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new et(t)}),this.register(function(t){return new tt(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new $e(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new de(t,b.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new de(t,b.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new nt(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=u.LoaderUtils.extractUrlBase(e);o=u.LoaderUtils.resolveURL(c,this.path)}else o=u.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},r=new u.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(c){try{i.parse(c,o,function(h){t(h),i.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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,n,s){let i;const o={},a={},r=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(r.decode(new Uint8Array(e,0,4))===pe){try{o[b.KHR_BINARY_GLTF]=new st(e)}catch(d){s&&s(d);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(r.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new gt(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 h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const d=i.extensionsUsed[h],p=i.extensionsRequired||[];switch(d){case b.KHR_MATERIALS_UNLIT:o[d]=new Be;break;case b.KHR_DRACO_MESH_COMPRESSION:o[d]=new it(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[d]=new ot;break;case b.KHR_MESH_QUANTIZATION:o[d]=new rt;break;default:p.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Ee(){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={}}}}function L(l,e,t){const n=l.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}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_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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class je{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 n=0,s=t.length;n<s;n++){const i=t[n];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,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,r=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const h=new u.Color(16777215);r.color!==void 0&&h.setRGB(r.color[0],r.color[1],r.color[2],u.LinearSRGBColorSpace);const d=r.range!==void 0?r.range:0;switch(r.type){case"directional":c=new u.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new u.PointLight(h),c.distance=d;break;case"spot":c=new u.SpotLight(h),c.distance=d,r.spot=r.spot||{},r.spot.innerConeAngle=r.spot.innerConeAngle!==void 0?r.spot.innerConeAngle:0,r.spot.outerConeAngle=r.spot.outerConeAngle!==void 0?r.spot.outerConeAngle:Math.PI/4,c.angle=r.spot.outerConeAngle,c.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return c.position.set(0,0,0),I(c,r),r.intensity!==void 0&&(c.intensity=r.intensity),c.name=t.createUniqueName(r.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(r){return n._getNodeRef(t.cache,a,r)})}}class Be{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new u.Color(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],u.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(s)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const i=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new u.Vector2(i,i)}return Promise.all(s)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class We{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(t.sheenColor=new u.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const i=n.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,u.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class Ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class Qe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const i=n.attenuationColor||[1,1,1];return t.attenuationColor=new u.Color().setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace),Promise.all(s)}}class qe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class Ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const i=n.specularColorFactor||[1,1,1];return t.specularColor=new u.Color().setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,u.SRGBColorSpace)),Promise.all(s)}}class He{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}}class $e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class Je{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.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 et{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=s.images[o.source];let r=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(r=c)}return n.loadTextureImage(e,o.source,r)}}class tt{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=s.images[o.source];let r=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(r=c)}return n.loadTextureImage(e,o.source,r)}}class de{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.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(a){const r=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,p=new Uint8Array(a,r,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,p,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(f),h,d,p,s.mode,s.filter),f})})}else return null}}class nt{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==C.TRIANGLES&&c.mode!==C.TRIANGLE_STRIP&&c.mode!==C.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],r={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(r[c]=h,r[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],p=c[0].count,f=[];for(const m of d){const x=new u.Matrix4,y=new u.Vector3,g=new u.Quaternion,M=new u.Vector3(1,1,1),T=new u.InstancedMesh(m.geometry,m.material,p);for(let A=0;A<p;A++)r.TRANSLATION&&y.fromBufferAttribute(r.TRANSLATION,A),r.ROTATION&&g.fromBufferAttribute(r.ROTATION,A),r.SCALE&&M.fromBufferAttribute(r.SCALE,A),T.setMatrixAt(A,x.compose(y,g,M));for(const A in r)if(A==="_COLOR_0"){const P=r[A];T.instanceColor=new u.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,r[A]);u.Object3D.prototype.copy.call(T,m),this.parser.assignFinalMaterial(T),f.push(T)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const pe="glTF",j=12,fe={JSON:1313821514,BIN:5130562};class st{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,j),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==pe)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-j,i=new DataView(e,j);let o=0;for(;o<s;){const a=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===fe.JSON){const c=new Uint8Array(e,j+o,a);this.content=n.decode(c)}else if(r===fe.BIN){const c=j+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class it{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 n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},r={},c={};for(const h in o){const d=Y[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=Y[h]||h.toLowerCase();if(o[h]!==void 0){const p=n.accessors[e.attributes[h]],f=U[p.componentType];c[d]=f.name,r[d]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(h){return new Promise(function(d,p){s.decodeDracoFile(h,function(f){for(const m in f.attributes){const x=f.attributes[m],y=r[m];y!==void 0&&(x.normalized=y)}d(f)},a,c,u.LinearSRGBColorSpace,p)})})}}class ot{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 rt{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class me extends u.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,r=a*2,c=a*3,h=s-t,d=(n-t)/h,p=d*d,f=p*d,m=e*c,x=m-c,y=-2*f+3*p,g=f-p,M=1-y,T=g-p+d;for(let A=0;A!==a;A++){const P=o[x+A+a],v=o[x+A+r]*h,O=o[m+A+a],G=o[m+A]*h;i[A]=M*P+T*v+y*O+g*G}return i}}const at=new u.Quaternion;class lt extends me{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return at.fromArray(i).normalize().toArray(i),i}}const C={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ge={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},_e={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},X={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Y={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"},F={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ct={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},Q={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ht(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),l.DefaultMaterial}function V(l,e,t){for(const n in t.extensions)l[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function I(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 ut(l,e,t){let n=!1,s=!1,i=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(l);const o=[],a=[],r=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(p)}if(s){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;a.push(p)}if(i){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;r.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r)]).then(function(c){const h=c[0],d=c[1],p=c[2];return n&&(l.morphAttributes.position=h),s&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function dt(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,s=t.length;n<s;n++)l.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function pt(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+q(t.attributes):e=l.indices+":"+q(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,s=l.targets.length;n<s;n++)e+=":"+q(l.targets[n]);return e}function q(l){let e="";const t=Object.keys(l).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+l[t[n]]+";";return e}function Z(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 ft(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 mt=new u.Matrix4;class gt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ee,this.associations=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 n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const r=a.match(/Version\/(\d+)/);s=n&&r?parseInt(r[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(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 n=this,s=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return V(i,a,s),I(a,s),Promise.all(n._invokeAll(function(r){return r.afterRoot&&r.afterRoot(a)})).then(function(){for(const r of a.scenes)r.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let a=0,r=o.length;a<r;a++)e[o[a]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,a)=>{const r=this.associations.get(o);r!=null&&this.associations.set(a,r);for(const[c,h]of o.children.entries())i(h,a.children[c])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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 s=this.options;return new Promise(function(i,o){n.load(u.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=X[s.type],a=U[s.componentType],r=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new u.BufferAttribute(c,o,r))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const a=o[0],r=X[s.type],c=U[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*r,p=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let x,y;if(f&&f!==d){const g=Math.floor(p/f),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count;let T=t.cache.get(M);T||(x=new c(a,g*f,s.count*f/h),T=new u.InterleavedBuffer(x,f/h),t.cache.add(M,T)),y=new u.InterleavedBufferAttribute(T,r,p%f/h,m)}else a===null?x=new c(s.count*r):x=new c(a,p,s.count*r),y=new u.BufferAttribute(x,r,m);if(s.sparse!==void 0){const g=X.SCALAR,M=U[s.sparse.indices.componentType],T=s.sparse.indices.byteOffset||0,A=s.sparse.values.byteOffset||0,P=new M(o[1],T,s.sparse.count*g),v=new c(o[2],A,s.sparse.count*r);a!==null&&(y=new u.BufferAttribute(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let O=0,G=P.length;O<G;O++){const E=P[O];if(y.setX(E,v[O*r]),r>=2&&y.setY(E,v[O*r+1]),r>=3&&y.setZ(E,v[O*r+2]),r>=4&&y.setW(E,v[O*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=m}return y})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let a=this.textureLoader;if(o.uri){const r=n.manager.getHandler(o.uri);r!==null&&(a=r)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],a=i.images[t],r=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[r])return this.textureCache[r];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const p=(i.samplers||{})[o.sampler]||{};return h.magFilter=ge[p.magFilter]||u.LinearFilter,h.minFilter=ge[p.minFilter]||u.LinearMipmapLinearFilter,h.wrapS=_e[p.wrapS]||u.RepeatWrapping,h.wrapT=_e[p.wrapT]||u.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==u.NearestFilter&&h.minFilter!==u.LinearFilter,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[r]=c,c}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],a=self.URL||self.webkitURL;let r=o.uri||"",c=!1;if(o.bufferView!==void 0)r=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return r=a.createObjectURL(p),r});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(r).then(function(d){return new Promise(function(p,f){let m=p;t.isImageBitmapLoader===!0&&(m=function(x){const y=new u.Texture(x);y.needsUpdate=!0,p(y)}),t.load(u.LoaderUtils.resolveURL(d,i.path),m,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(r),I(d,o),d.userData.mimeType=o.mimeType||ft(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const r=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,r)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let r=this.cache.get(a);r||(r=new u.PointsMaterial,u.Material.prototype.copy.call(r,n),r.color.copy(n.color),r.map=n.map,r.sizeAttenuation=!1,this.cache.add(a,r)),n=r}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let r=this.cache.get(a);r||(r=new u.LineBasicMaterial,u.Material.prototype.copy.call(r,n),r.color.copy(n.color),r.map=n.map,this.cache.add(a,r)),n=r}if(s||i||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let r=this.cache.get(a);r||(r=n.clone(),i&&(r.vertexColors=!0),o&&(r.flatShading=!0),s&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(a,r),this.associations.set(r,this.associations.get(n))),n=r}e.material=n}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const a={},r=i.extensions||{},c=[];if(r[b.KHR_MATERIALS_UNLIT]){const d=s[b.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,i,t))}else{const d=i.pbrMetallicRoughness||{};if(a.color=new u.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],u.LinearSRGBColorSpace),a.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,u.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=u.DoubleSide);const h=i.alphaMode||Q.OPAQUE;if(h===Q.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Q.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;a.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&o!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==u.MeshBasicMaterial){const d=i.emissiveFactor;a.emissive=new u.Color().setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==u.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return i.name&&(d.name=i.name),I(d,i),t.associations.set(d,{materials:e}),i.extensions&&V(s,d,i),d})}createUniqueName(e){const t=u.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(a){return n[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(r){return ye(r,a,t)})}const o=[];for(let a=0,r=e.length;a<r;a++){const c=e[a],h=pt(c),d=s[h];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ye(new u.BufferGeometry,c,t),s[h]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,a=[];for(let r=0,c=o.length;r<c;r++){const h=o[r].material===void 0?ht(this.cache):this.getDependency("material",o[r].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(r){const c=r.slice(0,r.length-1),h=r[r.length-1],d=[];for(let f=0,m=h.length;f<m;f++){const x=h[f],y=o[f];let g;const M=c[f];if(y.mode===C.TRIANGLES||y.mode===C.TRIANGLE_STRIP||y.mode===C.TRIANGLE_FAN||y.mode===void 0)g=i.isSkinnedMesh===!0?new u.SkinnedMesh(x,M):new u.Mesh(x,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),y.mode===C.TRIANGLE_STRIP?g.geometry=he(g.geometry,u.TriangleStripDrawMode):y.mode===C.TRIANGLE_FAN&&(g.geometry=he(g.geometry,u.TriangleFanDrawMode));else if(y.mode===C.LINES)g=new u.LineSegments(x,M);else if(y.mode===C.LINE_STRIP)g=new u.Line(x,M);else if(y.mode===C.LINE_LOOP)g=new u.LineLoop(x,M);else if(y.mode===C.POINTS)g=new u.Points(x,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(g.geometry.morphAttributes).length>0&&dt(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),I(g,i),y.extensions&&V(s,g,y),t.assignFinalMaterial(g),d.push(g)}for(let f=0,m=d.length;f<m;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&V(s,d[0],i),d[0];const p=new u.Group;i.extensions&&V(s,p,i),t.associations.set(p,{meshes:e});for(let f=0,m=d.length;f<m;f++)p.add(d[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new u.PerspectiveCamera(u.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new u.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),I(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,a=[],r=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const p=new u.Matrix4;i!==null&&p.fromArray(i.array,c*16),r.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new u.Skeleton(a,r)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],a=[],r=[],c=[],h=[];for(let d=0,p=s.channels.length;d<p;d++){const f=s.channels[d],m=s.samplers[f.sampler],x=f.target,y=x.node,g=s.parameters!==void 0?s.parameters[m.input]:m.input,M=s.parameters!==void 0?s.parameters[m.output]:m.output;x.node!==void 0&&(o.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",g)),r.push(this.getDependency("accessor",M)),c.push(m),h.push(x))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],f=d[1],m=d[2],x=d[3],y=d[4],g=[];for(let T=0,A=p.length;T<A;T++){const P=p[T],v=f[T],O=m[T],G=x[T],E=y[T];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const oe=n._createAnimationTracks(P,v,O,G,E);if(oe)for(let re=0;re<oe.length;re++)g.push(oe[re])}const M=new u.AnimationClip(i,void 0,g);return I(M,s),M})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let r=0,c=s.weights.length;r<c;r++)a.morphTargetInfluences[r]=s.weights[r]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const r=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),r]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(p,mt)});for(let f=0,m=d.length;f<m;f++)h.add(d[f]);if(h.userData.pivot!==void 0&&d.length>0){const f=h.userData.pivot,m=d[0];h.pivot=new u.Vector3().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",a=[],r=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return r&&a.push(r),i.camera!==void 0&&a.push(s.getDependency("camera",i.camera).then(function(c){return s._getNodeRef(s.cameraCache,i.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(i.isBone===!0?h=new u.Bone:c.length>1?h=new u.Group:c.length===1?h=c[0]:h=new u.Object3D,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(i.name&&(h.userData.name=i.name,h.name=o),I(h,i),i.extensions&&V(n,h,i),i.matrix!==void 0){const d=new u.Matrix4;d.fromArray(i.matrix),h.applyMatrix4(d)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new u.Group;n.name&&(i.name=s.createUniqueName(n.name)),I(i,n),n.extensions&&V(t,i,n);const o=n.nodes||[],a=[];for(let r=0,c=o.length;r<c;r++)a.push(s.getDependency("node",o[r]));return Promise.all(a).then(function(r){for(let h=0,d=r.length;h<d;h++){const p=r[h];p.parent!==null?i.add(Ue(p)):i.add(p)}const c=h=>{const d=new Map;for(const[p,f]of s.associations)(p instanceof u.Material||p instanceof u.Texture)&&d.set(p,f);return h.traverse(p=>{const f=s.associations.get(p);f!=null&&d.set(p,f)}),d};return s.associations=c(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],a=e.name?e.name:e.uuid,r=[];F[i.path]===F.weights?e.traverse(function(p){p.morphTargetInfluences&&r.push(p.name?p.name:p.uuid)}):r.push(a);let c;switch(F[i.path]){case F.weights:c=u.NumberKeyframeTrack;break;case F.rotation:c=u.QuaternionKeyframeTrack;break;case F.translation:case F.scale:c=u.VectorKeyframeTrack;break;default:n.itemSize===1?c=u.NumberKeyframeTrack:c=u.VectorKeyframeTrack;break}const h=s.interpolation!==void 0?ct[s.interpolation]:u.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let p=0,f=r.length;p<f;p++){const m=new c(r[p]+"."+F[i.path],t.array,d,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Z(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof u.QuaternionKeyframeTrack?lt:me;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _t(l,e,t){const n=e.attributes,s=new u.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],r=a.min,c=a.max;if(r!==void 0&&c!==void 0){if(s.set(new u.Vector3(r[0],r[1],r[2]),new u.Vector3(c[0],c[1],c[2])),a.normalized){const h=Z(U[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new u.Vector3,r=new u.Vector3;for(let c=0,h=i.length;c<h;c++){const d=i[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(r.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),r.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),r.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const x=Z(U[p.componentType]);r.multiplyScalar(x)}a.max(r)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}l.boundingBox=s;const o=new u.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=o}function ye(l,e,t){const n=e.attributes,s=[];function i(o,a){return t.getDependency("accessor",o).then(function(r){l.setAttribute(a,r)})}for(const o in n){const a=Y[o]||o.toLowerCase();a in l.attributes||s.push(i(n[o],a))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(a){l.setIndex(a)});s.push(o)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),I(l,e),_t(l,e,t),Promise.all(s).then(function(){return e.targets!==void 0?ut(l,e.targets,t):l})}const xe={type:"change"},H={type:"start"},Me={type:"end"},W=new u.Ray,we=new u.Plane,yt=Math.cos(70*u.MathUtils.DEG2RAD),k=new u.Vector3,N=2*Math.PI,S={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$=1e-6;class xt extends u.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wt.bind(this),this._onPointerDown=Mt.bind(this),this._onPointerUp=bt.bind(this),this._onContextMenu=vt.bind(this),this._onMouseWheel=St.bind(this),this._onKeyDown=Lt.bind(this),this._onTouchStart=Pt.bind(this),this._onTouchMove=kt.bind(this),this._onMouseDown=Tt.bind(this),this._onMouseMove=At.bind(this),this._interceptControlDown=Rt.bind(this),this._interceptControlUp=Nt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(xe),this.update(),this.state=S.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;k.copy(t).sub(this.target),k.applyQuaternion(this._quat),this._spherical.setFromVector3(k),this.autoRotate&&this.state===S.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=N:n>Math.PI&&(n-=N),s<-Math.PI?s+=N:s>Math.PI&&(s-=N),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(k.setFromSpherical(this._spherical),k.applyQuaternion(this._quatInverse),t.copy(this.target).add(k),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=k.length();o=this._clampDistance(a*this._scale);const r=a-o;this.object.position.addScaledVector(this._dollyDirection,r),this.object.updateMatrixWorld(),i=!!r}else if(this.object.isOrthographicCamera){const a=new u.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=r!==this.object.zoom;const c=new u.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=k.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(W.origin.copy(this.object.position),W.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(W.direction))<yt?this.object.lookAt(this.target):(we.setFromNormalAndCoplanarPoint(this.object.up,this.target),W.intersectPlane(we,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>$||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$||this._lastTargetPosition.distanceToSquared(this.target)>$?(this.dispatchEvent(xe),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?N/60*this.autoRotateSpeed*e:N/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){k.setFromMatrixColumn(t,0),k.multiplyScalar(-e),this._panOffset.add(k)}_panUp(e,t){this.screenSpacePanning===!0?k.setFromMatrixColumn(t,1):(k.setFromMatrixColumn(t,0),k.crossVectors(this.object.up,k)),k.multiplyScalar(e),this._panOffset.add(k)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;k.copy(s).sub(this.target);let i=k.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,i=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(i/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(N*this._rotateDelta.x/t.clientHeight),this._rotateUp(N*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateEnd.set(s,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(N*this._rotateDelta.x/t.clientHeight),this._rotateUp(N*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Mt(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function wt(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function bt(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Me),this.state=S.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Tt(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case u.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}break;case u.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(H)}function At(l){switch(this.state){case S.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case S.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case S.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function St(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(H),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(Me))}function Lt(l){this.enabled!==!1&&this._handleKeyDown(l)}function Pt(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=S.TOUCH_PAN;break;default:this.state=S.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=S.TOUCH_DOLLY_ROTATE;break;default:this.state=S.NONE}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(H)}function kt(l){switch(this._trackPointer(l),this.state){case S.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case S.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case S.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case S.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=S.NONE}}function vt(l){this.enabled!==!1&&l.preventDefault()}function Rt(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Nt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ot=((l,e)=>{const t=l.__vccOpts||l;for(const[n,s]of e)t[n]=s;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},clearAlpha:{type:[String,Number],default:1},clearColor:{type:String,default:"#7fbfff"},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["initialized","animate"],setup(l,{emit:e}){const t=e,n=l,s="dom"+w.getCurrentInstance().uid,i=w.useTemplateRef(s);let o=null,a=null,r=null,c=null,h=null,d=null,p=null;const f=g=>{o==null&&(o=new _.Timer),o?.update(g);const M=o.getDelta(),T={GLTFLoader:z,THREE:_,VRMExpressionPresetName:D.VRMExpressionPresetName,VRMHumanBoneName:D.VRMHumanBoneName,VRMUtils:D.VRMUtils,camera:c,controls:d,deltaTime:M,renderer:h,scene:r};t("animate",T),a!=null&&(cancelAnimationFrame(a),a=null),n.animation&&(a=requestAnimationFrame(f)),h.render(r,c)},m=()=>{a!=null&&(cancelAnimationFrame(a),a=null),a=requestAnimationFrame(f)},x=()=>{a!=null&&(cancelAnimationFrame(a),a=null)};w.watch(()=>n.animation,g=>{g==!0?m():x()}),w.watch(()=>n.clearAlpha,g=>{h&&h.setClearAlpha(parseFloat(g))}),w.watch(()=>n.clearColor,g=>{if(h){const M=new _.Color(g),T=h.getClearAlpha();h.setClearColor(M,T)}});const y=()=>{const g=i.value,M=g.clientWidth,T=g.clientHeight,A={antialias:!0,alpha:!1};if(_.ColorManagement.enabled=!1,h=new _.WebGLRenderer(A),h.setPixelRatio(window.devicePixelRatio),h.setSize(M,T),h.setClearColor(n.clearColor,n.clearAlpha),h.outputColorSpace=_.SRGBColorSpace,g.appendChild(h.domElement),r=new _.Scene,c=new _.PerspectiveCamera(45,M/T,.1,1e3),c.position.set(0,1.25,1),n.useOrbitControls&&(d=new xt(c,g),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),n.useGridHelper){const v=new _.GridHelper(10,10);r.add(v),v.visible=!0}if(n.useAxesHelper){const v=new _.AxesHelper(5);r.add(v)}if(n.useDefaultLight){const v=new _.DirectionalLight(16777215);v.intensity=3,v.position.set(1,1,1).normalize(),r.add(v);const O=new _.AmbientLight(4210752);r.add(O)}const P={GLTFLoader:z,THREE:_,VRMExpressionPresetName:D.VRMExpressionPresetName,VRMHumanBoneName:D.VRMHumanBoneName,VRMUtils:D.VRMUtils,camera:c,controls:d,renderer:h,scene:r};t("initialized",P)};return w.onMounted(async()=>{if(!ce.isWebGL2Available()){const g=ce.getWebGLErrorMessage();console.error(g);return}p=new ResizeObserver(g=>{const M=g[0],T=M.contentRect.width,A=M.contentRect.height;h.setPixelRatio(window.devicePixelRatio),h.setSize(T,A),c.aspect=T/A,c.updateProjectionMatrix()}),p.observe(i.value),y()}),w.onUnmounted(()=>{p&&p.disconnect()}),(g,M)=>(w.openBlock(),w.createElementBlock("div",{ref:s,class:"box"}))}},[["__scopeId","data-v-0b88fd37"]]);var be=(l,e,t)=>new Promise((n,s)=>{var i=r=>{try{a(t.next(r))}catch(c){s(c)}},o=r=>{try{a(t.throw(r))}catch(c){s(c)}},a=r=>r.done?n(r.value):Promise.resolve(r.value).then(i,o);a((t=t.apply(l,e)).next())}),Ct={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};new _.Color,new _.Vector2,new _.Vector3,new _.Vector3,new _.Quaternion;var Te={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function It(l){return l.invert?l.invert():l.inverse(),l}new _.Vector3,new _.Quaternion,new _.Vector3,new _.Quaternion,new _.Vector3,new _.Quaternion,new _.Quaternion,new _.Vector3,new _.Vector3;var Ae=Math.sqrt(2)/2;new _.Quaternion(0,0,-Ae,Ae),new _.Vector3(0,1,0);var Dt=new _.Vector3,Ft=new _.Vector3;function Vt(l,e){return l.matrixWorld.decompose(Dt,e,Ft),e}function J(l){return[Math.atan2(-l.z,l.x),Math.atan2(l.y,Math.sqrt(l.x*l.x+l.z*l.z))]}function Se(l){const e=Math.round(l/2/Math.PI);return l-2*Math.PI*e}var Le=new _.Vector3(0,0,1),Ut=new _.Vector3,Et=new _.Vector3,jt=new _.Vector3,Bt=new _.Quaternion,ee=new _.Quaternion,Pe=new _.Quaternion,Gt=new _.Quaternion,te=new _.Euler,ke=class Fe{constructor(e,t){this.offsetFromHeadBone=new _.Vector3,this.autoUpdate=!0,this.faceFront=new _.Vector3(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new _.Quaternion)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new _.Euler)}getEuler(e){return e.set(_.MathUtils.DEG2RAD*this._pitch,_.MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new Fe(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){const t=this.humanoid.getRawBoneNode("head");return Vt(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(Le)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,n]=J(this.faceFront);return te.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(te).premultiply(Gt.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(ee),this.getFaceFrontQuaternion(Pe),e.copy(Le).applyQuaternion(ee).applyQuaternion(Pe).applyEuler(this.getEuler(te))}lookAt(e){const t=Bt.copy(this._restHeadWorldQuaternion).multiply(It(this.getLookAtWorldQuaternion(ee))),n=this.getLookAtWorldPosition(Et),s=jt.copy(e).sub(n).applyQuaternion(t).normalize(),[i,o]=J(this.faceFront),[a,r]=J(s),c=Se(a-i),h=Se(o-r);this._yaw=_.MathUtils.RAD2DEG*c,this._pitch=_.MathUtils.RAD2DEG*h,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(Ut)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};ke.EULER_ORDER="YXZ";var Kt=ke;new _.Vector3(0,0,1),new _.Quaternion,new _.Quaternion,new _.Euler(0,0,0,"YXZ");var ve=180/Math.PI,ne=new _.Euler,se=class extends _.Object3D{constructor(l){super(),this.vrmLookAt=l,this.type="VRMLookAtQuaternionProxy";const e=this.rotation._onChangeCallback;this.rotation._onChange(()=>{e(),this._applyToLookAt()});const t=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{t(),this._applyToLookAt()})}_applyToLookAt(){ne.setFromQuaternion(this.quaternion,Kt.EULER_ORDER),this.vrmLookAt.yaw=ve*ne.y,this.vrmLookAt.pitch=ve*ne.x}};function zt(l,e,t){var n,s;const i=new Map,o=new Map;for(const[a,r]of l.humanoidTracks.rotation.entries()){const c=(n=e.getNormalizedBoneNode(a))==null?void 0:n.name;if(c!=null){const h=new _.QuaternionKeyframeTrack(`${c}.quaternion`,r.times,r.values.map((d,p)=>t==="0"&&p%2===0?-d:d));o.set(a,h)}}for(const[a,r]of l.humanoidTracks.translation.entries()){const c=(s=e.getNormalizedBoneNode(a))==null?void 0:s.name;if(c!=null){const h=l.restHipsPosition.y,p=e.normalizedRestPose.hips.position[1]/h,f=r.clone();f.values=f.values.map((m,x)=>(t==="0"&&x%3!==1?-m:m)*p),f.name=`${c}.position`,i.set(a,f)}}return{translation:i,rotation:o}}function Wt(l,e){const t=new Map,n=new Map;for(const[s,i]of l.expressionTracks.preset.entries()){const o=e.getExpressionTrackName(s);if(o!=null){const a=i.clone();a.name=o,t.set(s,a)}}for(const[s,i]of l.expressionTracks.custom.entries()){const o=e.getExpressionTrackName(s);if(o!=null){const a=i.clone();a.name=o,n.set(s,a)}}return{preset:t,custom:n}}function Xt(l,e){if(l.lookAtTrack==null)return null;const t=l.lookAtTrack.clone();return t.name=e,t}function Yt(l,e){const t=[],n=zt(l,e.humanoid,e.meta.metaVersion);if(t.push(...n.translation.values()),t.push(...n.rotation.values()),e.expressionManager!=null){const s=Wt(l,e.expressionManager);t.push(...s.preset.values()),t.push(...s.custom.values())}if(e.lookAt!=null){let s=e.scene.children.find(o=>o instanceof se);s==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),s=new se(e.lookAt),s.name="VRMLookAtQuaternionProxy",e.scene.add(s)):s.name===""&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),s.name="VRMLookAtQuaternionProxy");const i=Xt(l,`${s.name}.quaternion`);i!=null&&t.push(i)}return new _.AnimationClip("Clip",l.duration,t)}var Qt=class{constructor(){this.duration=0,this.restHipsPosition=new _.Vector3,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function Re(l,e){const t=l.length,n=[];let s=[],i=0;for(let o=0;o<t;o++){const a=l[o];i<=0&&(i=e,s=[],n.push(s)),s.push(a),i--}return n}var qt=new _.Matrix4,B=new _.Vector3,ie=new _.Quaternion,Ne=new _.Quaternion,Zt=new _.Quaternion,Ht=new Set(["1.0","1.0-draft"]),$t=new Set(Object.values(Ct)),Jt=class{constructor(l){this.parser=l}get name(){return"VRMC_vrm_animation"}afterRoot(l){return be(this,null,function*(){var e,t,n;const s=l.parser.json,i=s.extensionsUsed;if(i==null||i.indexOf(this.name)==-1)return;const o=(e=s.extensions)==null?void 0:e[this.name];if(o==null)return;const a=o.specVersion;if(a==null)console.warn("VRMAnimationLoaderPlugin: specVersion of the VRMA is not defined. Consider updating the animation file. Assuming the spec version is 1.0.");else{if(!Ht.has(a)){console.warn(`VRMAnimationLoaderPlugin: Unknown VRMC_vrm_animation spec version: ${a}`);return}a==="1.0-draft"&&console.warn("VRMAnimationLoaderPlugin: Using a draft spec version: 1.0-draft. Some behaviors may be different. Consider updating the animation file.")}const r=this._createNodeMap(o),c=yield this._createBoneWorldMatrixMap(l,o),h=(n=(t=o.humanoid)==null?void 0:t.humanBones.hips)==null?void 0:n.node,d=h!=null?yield l.parser.getDependency("node",h):null,p=new _.Vector3;d?.getWorldPosition(p),p.y<.001&&console.warn("VRMAnimationLoaderPlugin: The loaded VRM Animation might violate the VRM T-pose (The y component of the rest hips position is approximately zero or below.)");const m=l.animations.map((x,y)=>{const g=s.animations[y],M=this._parseAnimation(x,g,r,c);return M.restHipsPosition=p,M});l.userData.vrmAnimations=m})}_createNodeMap(l){var e,t,n,s,i;const o=new Map,a=new Map,r=(e=l.humanoid)==null?void 0:e.humanBones;r&&Object.entries(r).forEach(([p,f])=>{const m=f?.node;m!=null&&o.set(m,p)});const c=(t=l.expressions)==null?void 0:t.preset;c&&Object.entries(c).forEach(([p,f])=>{const m=f?.node;m!=null&&a.set(m,p)});const h=(n=l.expressions)==null?void 0:n.custom;h&&Object.entries(h).forEach(([p,f])=>{const{node:m}=f;a.set(m,p)});const d=(i=(s=l.lookAt)==null?void 0:s.node)!=null?i:null;return{humanoidIndexToName:o,expressionsIndexToName:a,lookAtIndex:d}}_createBoneWorldMatrixMap(l,e){return be(this,null,function*(){var t,n;l.scene.updateWorldMatrix(!1,!0);const s=yield l.parser.getDependencies("node"),i=new Map;if(e.humanoid==null)return i;for(const[o,a]of Object.entries(e.humanoid.humanBones)){const r=a?.node;if(r!=null){const c=s[r];i.set(o,c.matrixWorld),o==="hips"&&i.set("hipsParent",(n=(t=c.parent)==null?void 0:t.matrixWorld)!=null?n:qt)}}return i})}_parseAnimation(l,e,t,n){const s=l.tracks,i=e.channels,o=new Qt;return o.duration=l.duration,i.forEach((a,r)=>{const{node:c,path:h}=a.target,d=s[r];if(c==null)return;const p=t.humanoidIndexToName.get(c);if(p!=null){let m=Te[p];for(;m!=null&&n.get(m)==null;)m=Te[m];if(m==null&&(m="hipsParent"),h==="translation")if(p!=="hips")console.warn(`The loading animation contains a translation track for ${p}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const x=n.get("hipsParent"),y=Re(d.values,3).flatMap(M=>B.fromArray(M).applyMatrix4(x).toArray()),g=d.clone();g.values=new Float32Array(y),o.humanoidTracks.translation.set(p,g)}else if(h==="rotation"){const x=n.get(p),y=n.get(m);x.decompose(B,ie,B),ie.invert(),y.decompose(B,Ne,B);const g=Re(d.values,4).flatMap(T=>Zt.fromArray(T).premultiply(Ne).multiply(ie).toArray()),M=d.clone();M.values=new Float32Array(g),o.humanoidTracks.rotation.set(p,M)}else throw new Error(`Invalid path "${h}"`);return}const f=t.expressionsIndexToName.get(c);if(f!=null){if(h==="translation"){const m=d.times,x=new Float32Array(d.values.length/3);for(let g=0;g<x.length;g++)x[g]=d.values[3*g];const y=new _.NumberKeyframeTrack(`${f}.weight`,m,x);$t.has(f)?o.expressionTracks.preset.set(f,y):o.expressionTracks.custom.set(f,y)}else throw new Error(`Invalid path "${h}"`);return}if(c===t.lookAtIndex)if(h==="rotation")o.lookAtTrack=d;else throw new Error(`Invalid path "${h}"`)}),o}};const Oe={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const r=await new K().fetchExpression(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},i=o=>{t("loading",n.name,n.command);let a=!1;o&&(a=!0),t("loaded",n.name,n.command,a,o)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},Ce={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const r=await new K().fetchPose(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},i=o=>{t("loading",n.name,n.command);const r=new K().normalizePose(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},Ie={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async a=>{const r=new z;return r.register(c=>new D.VRMLoaderPlugin(c)),await r.loadAsync(a).then(c=>{const h=c.userData.vrm;return D.VRMUtils.rotateVRM0(h),h})},i=async a=>{if(!a)return;t("loading",n.name,n.command);const r=await s(a);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},o=a=>{t("loading",n.name,n.command);let r=!1;a&&(r=!0),t("loaded",n.name,n.command,r,a)};return w.onMounted(async()=>{n.data!=null?o(n.data):i(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&o(n.data)}),w.watch(()=>n.url,()=>{n.url&&i(n.url)}),(a,r)=>null}},en={__name:"VroidVrma",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const a=new z;a.crossOrigin="anonymous",a.register(d=>new Jt(d));const c=(await a.loadAsync(o)).userData.vrmAnimations[0];let h=!1;c&&(h=!0),t("loaded",n.name,n.command,h,c)},i=o=>{t("loading",n.name,n.command);let a=!1;o&&(a=!0),t("loaded",n.name,n.command,a,o)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},De={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null},vrma_name:{type:String},vrma_url:{type:String},vrma_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s={},i={},o=w.ref(null),a=w.ref(null),r=w.ref(null),c=w.ref(null),h=(p,f)=>{const m=Object.keys(s).length;s[p]=f;const x=Object.keys(s).length;m==0&&x&&t("loading",n.name)},d=(p,f,m,x)=>{const y=Object.keys(s).length;m&&(f=="load_expression"&&(o.value=x),f=="load_pose"&&(a.value=x),f=="load_vrm"&&(r.value=x),f=="load_vrma"&&(c.value=x),i[p]=f),delete s[p];const g=Object.keys(s).length;if(y&&g==0){const M={};for(const A in i){const P=i[A];P=="load_expression"&&(M.expression=o.value),P=="load_pose"&&(M.pose=a.value),P=="load_vrm"&&(M.vrm=r.value),P=="load_vrma"&&(M.vrma=c.value)}t("loaded",n.name,M);const T=Object.keys(i);for(const A of T)delete i[A]}};return(p,f)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[w.createVNode(Oe,{command:"load_expression",name:n.expression_name,url:n.expression_url,data:n.expression_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(Ce,{command:"load_pose",name:n.pose_name,url:n.pose_url,data:n.pose_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(Ie,{command:"load_vrm",name:n.vrm_name,url:n.vrm_url,data:n.vrm_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(en,{command:"load_vrma",name:n.vrma_name,url:n.vrma_url,data:n.vrma_data,onLoading:h,onLoaded:d},null,8,["name","url","data"])],64))}},tn={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null},vrma_name:{type:String,default:"vrma"},vrma_url:{type:String,default:""},vrma_data:{type:[Object,null],default:null},vrma_autoplay:{type:[Boolean,null],default:!0}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=w.ref(null);s.value=new le;const i=a=>{t("loading",a)},o=(a,r)=>{if("vrm"in r){s.value.setModel(r.vrm);const c=new se(s.value.vrm.lookAt);c.name="lookAtQuaternionProxy",s.value.vrm.scene.add(c);const h=new _.AnimationMixer(s.value.vrm.scene);s.value.setMixer(h)}if("pose"in r&&(s.value.resetPose(),s.value.setPose(r.pose),s.value.updatePose()),"expression"in r&&(s.value.resetExpression(),s.value.importExpression(r.expression),s.value.updateExpression()),"vrma"in r&&(s.value.setVrma(r.vrma),n.vrma_autoplay)){const c=Yt(s.value.vrma,s.value.vrm);s.value.mixer.stopAllAction(),s.value.mixer.clipAction(c).play()}t("loaded",a,s.value)};return(a,r)=>(w.openBlock(),w.createBlock(De,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,vrma_name:l.vrma_name,vrma_url:l.vrma_url,vrma_data:l.vrma_data,onLoading:i,onLoaded:o},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data","vrma_name","vrma_url","vrma_data"]))}};R.ResourceLoader=K,R.ThreeFrame=Ot,R.VrmModel=le,R.VroidControl=tn,R.VroidExpression=Oe,R.VroidModel=De,R.VroidPose=Ce,R.VroidVrm=Ie,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(v,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("vue"),require("three"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","vue","three","@pixiv/three-vrm"],w):(v=typeof globalThis<"u"?globalThis:v||self,w(v.VueThreeVrm={},v.Vue,v.THREE,v.THREE_VRM))})(this,(function(v,w,u,D){"use strict";var ae=document.createElement("style");ae.textContent=`.box[data-v-0b88fd37]{display:block;width:100%;height:100%}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(ae);function Ve(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const _=Ve(u);class K{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}normalizePose(e){return e==null?null:"pose"in e?e.pose:e}async fetchPose(e){const t=await this.fetchJSON(e);return this.normalizePose(t)}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class le{constructor(){this.vrm=null,this.vrma=null,this.mixer=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setVrma(e){this.vrma=e}setMixer(e){this.mixer=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,n,s){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=n,i.rotation.z=s)}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,n,s){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=n,i.position.z=s)}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}resetExpression(){return this.vrm?this.vrm.expressionManager.resetValues():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 n in t)e[n]=this.getExpression(n);return e}return null}updateAnimation(e){this.mixer&&this.mixer.update(e),this.vrm&&this.vrm.update(e)}}class ce{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),n=window.WebGL2RenderingContext&&t.getContext("webgl2");return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let s='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",n[e]?s=s.replace("$0","graphics card"):s=s.replace("$0","browser"),s=s.replace("$1",t[e]),i.innerHTML=s,i}}function he(l,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],a=l.getAttribute("position");if(a!==void 0){for(let r=0;r<a.count;r++)o.push(r);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=t.count-2,s=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}function Ue(l){const e=new Map,t=new Map,n=l.clone();return ue(l,n,function(s,i){e.set(i,s),t.set(s,i)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),a=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=a.map(function(r){return t.get(r)}),i.bind(i.skeleton,i.bindMatrix)}),n}function ue(l,e,t){t(l,e);for(let n=0;n<l.children.length;n++)ue(l.children[n],e.children[n],t)}class z extends u.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ke(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new et(t)}),this.register(function(t){return new tt(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new $e(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new de(t,b.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new de(t,b.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new nt(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=u.LoaderUtils.extractUrlBase(e);o=u.LoaderUtils.resolveURL(c,this.path)}else o=u.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},r=new u.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(c){try{i.parse(c,o,function(h){t(h),i.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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,n,s){let i;const o={},a={},r=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(r.decode(new Uint8Array(e,0,4))===pe){try{o[b.KHR_BINARY_GLTF]=new st(e)}catch(d){s&&s(d);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(r.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new gt(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 h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const d=i.extensionsUsed[h],p=i.extensionsRequired||[];switch(d){case b.KHR_MATERIALS_UNLIT:o[d]=new Be;break;case b.KHR_DRACO_MESH_COMPRESSION:o[d]=new it(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[d]=new ot;break;case b.KHR_MESH_QUANTIZATION:o[d]=new rt;break;default:p.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Ee(){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={}}}}function L(l,e,t){const n=l.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}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_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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class je{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 n=0,s=t.length;n<s;n++){const i=t[n];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,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,r=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const h=new u.Color(16777215);r.color!==void 0&&h.setRGB(r.color[0],r.color[1],r.color[2],u.LinearSRGBColorSpace);const d=r.range!==void 0?r.range:0;switch(r.type){case"directional":c=new u.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new u.PointLight(h),c.distance=d;break;case"spot":c=new u.SpotLight(h),c.distance=d,r.spot=r.spot||{},r.spot.innerConeAngle=r.spot.innerConeAngle!==void 0?r.spot.innerConeAngle:0,r.spot.outerConeAngle=r.spot.outerConeAngle!==void 0?r.spot.outerConeAngle:Math.PI/4,c.angle=r.spot.outerConeAngle,c.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return c.position.set(0,0,0),I(c,r),r.intensity!==void 0&&(c.intensity=r.intensity),c.name=t.createUniqueName(r.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(r){return n._getNodeRef(t.cache,a,r)})}}class Be{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new u.Color(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],u.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(s)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const i=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new u.Vector2(i,i)}return Promise.all(s)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class We{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(t.sheenColor=new u.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const i=n.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,u.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class Ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class Qe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const i=n.attenuationColor||[1,1,1];return t.attenuationColor=new u.Color().setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace),Promise.all(s)}}class qe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class Ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const i=n.specularColorFactor||[1,1,1];return t.specularColor=new u.Color().setRGB(i[0],i[1],i[2],u.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,u.SRGBColorSpace)),Promise.all(s)}}class He{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}}class $e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return L(this.parser,e,this.name)!==null?u.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class Je{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.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 et{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=s.images[o.source];let r=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(r=c)}return n.loadTextureImage(e,o.source,r)}}class tt{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=s.images[o.source];let r=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(r=c)}return n.loadTextureImage(e,o.source,r)}}class de{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.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(a){const r=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,p=new Uint8Array(a,r,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,p,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(f),h,d,p,s.mode,s.filter),f})})}else return null}}class nt{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==C.TRIANGLES&&c.mode!==C.TRIANGLE_STRIP&&c.mode!==C.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],r={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(r[c]=h,r[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],p=c[0].count,f=[];for(const m of d){const x=new u.Matrix4,y=new u.Vector3,g=new u.Quaternion,M=new u.Vector3(1,1,1),T=new u.InstancedMesh(m.geometry,m.material,p);for(let A=0;A<p;A++)r.TRANSLATION&&y.fromBufferAttribute(r.TRANSLATION,A),r.ROTATION&&g.fromBufferAttribute(r.ROTATION,A),r.SCALE&&M.fromBufferAttribute(r.SCALE,A),T.setMatrixAt(A,x.compose(y,g,M));for(const A in r)if(A==="_COLOR_0"){const P=r[A];T.instanceColor=new u.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,r[A]);u.Object3D.prototype.copy.call(T,m),this.parser.assignFinalMaterial(T),f.push(T)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const pe="glTF",j=12,fe={JSON:1313821514,BIN:5130562};class st{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,j),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==pe)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-j,i=new DataView(e,j);let o=0;for(;o<s;){const a=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===fe.JSON){const c=new Uint8Array(e,j+o,a);this.content=n.decode(c)}else if(r===fe.BIN){const c=j+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class it{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 n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},r={},c={};for(const h in o){const d=Y[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=Y[h]||h.toLowerCase();if(o[h]!==void 0){const p=n.accessors[e.attributes[h]],f=U[p.componentType];c[d]=f.name,r[d]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(h){return new Promise(function(d,p){s.decodeDracoFile(h,function(f){for(const m in f.attributes){const x=f.attributes[m],y=r[m];y!==void 0&&(x.normalized=y)}d(f)},a,c,u.LinearSRGBColorSpace,p)})})}}class ot{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 rt{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class me extends u.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,r=a*2,c=a*3,h=s-t,d=(n-t)/h,p=d*d,f=p*d,m=e*c,x=m-c,y=-2*f+3*p,g=f-p,M=1-y,T=g-p+d;for(let A=0;A!==a;A++){const P=o[x+A+a],R=o[x+A+r]*h,O=o[m+A+a],G=o[m+A]*h;i[A]=M*P+T*R+y*O+g*G}return i}}const at=new u.Quaternion;class lt extends me{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return at.fromArray(i).normalize().toArray(i),i}}const C={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ge={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},_e={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},X={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Y={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"},F={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ct={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},Q={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ht(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),l.DefaultMaterial}function V(l,e,t){for(const n in t.extensions)l[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function I(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 ut(l,e,t){let n=!1,s=!1,i=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(l);const o=[],a=[],r=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(p)}if(s){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;a.push(p)}if(i){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;r.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r)]).then(function(c){const h=c[0],d=c[1],p=c[2];return n&&(l.morphAttributes.position=h),s&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function dt(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,s=t.length;n<s;n++)l.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function pt(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+q(t.attributes):e=l.indices+":"+q(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,s=l.targets.length;n<s;n++)e+=":"+q(l.targets[n]);return e}function q(l){let e="";const t=Object.keys(l).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+l[t[n]]+";";return e}function Z(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 ft(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 mt=new u.Matrix4;class gt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ee,this.associations=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 n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const r=a.match(/Version\/(\d+)/);s=n&&r?parseInt(r[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(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 n=this,s=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return V(i,a,s),I(a,s),Promise.all(n._invokeAll(function(r){return r.afterRoot&&r.afterRoot(a)})).then(function(){for(const r of a.scenes)r.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let a=0,r=o.length;a<r;a++)e[o[a]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,a)=>{const r=this.associations.get(o);r!=null&&this.associations.set(a,r);for(const[c,h]of o.children.entries())i(h,a.children[c])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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 s=this.options;return new Promise(function(i,o){n.load(u.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=X[s.type],a=U[s.componentType],r=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new u.BufferAttribute(c,o,r))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const a=o[0],r=X[s.type],c=U[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*r,p=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let x,y;if(f&&f!==d){const g=Math.floor(p/f),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count;let T=t.cache.get(M);T||(x=new c(a,g*f,s.count*f/h),T=new u.InterleavedBuffer(x,f/h),t.cache.add(M,T)),y=new u.InterleavedBufferAttribute(T,r,p%f/h,m)}else a===null?x=new c(s.count*r):x=new c(a,p,s.count*r),y=new u.BufferAttribute(x,r,m);if(s.sparse!==void 0){const g=X.SCALAR,M=U[s.sparse.indices.componentType],T=s.sparse.indices.byteOffset||0,A=s.sparse.values.byteOffset||0,P=new M(o[1],T,s.sparse.count*g),R=new c(o[2],A,s.sparse.count*r);a!==null&&(y=new u.BufferAttribute(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let O=0,G=P.length;O<G;O++){const E=P[O];if(y.setX(E,R[O*r]),r>=2&&y.setY(E,R[O*r+1]),r>=3&&y.setZ(E,R[O*r+2]),r>=4&&y.setW(E,R[O*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=m}return y})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let a=this.textureLoader;if(o.uri){const r=n.manager.getHandler(o.uri);r!==null&&(a=r)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],a=i.images[t],r=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[r])return this.textureCache[r];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const p=(i.samplers||{})[o.sampler]||{};return h.magFilter=ge[p.magFilter]||u.LinearFilter,h.minFilter=ge[p.minFilter]||u.LinearMipmapLinearFilter,h.wrapS=_e[p.wrapS]||u.RepeatWrapping,h.wrapT=_e[p.wrapT]||u.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==u.NearestFilter&&h.minFilter!==u.LinearFilter,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[r]=c,c}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],a=self.URL||self.webkitURL;let r=o.uri||"",c=!1;if(o.bufferView!==void 0)r=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return r=a.createObjectURL(p),r});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(r).then(function(d){return new Promise(function(p,f){let m=p;t.isImageBitmapLoader===!0&&(m=function(x){const y=new u.Texture(x);y.needsUpdate=!0,p(y)}),t.load(u.LoaderUtils.resolveURL(d,i.path),m,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(r),I(d,o),d.userData.mimeType=o.mimeType||ft(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const r=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,r)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let r=this.cache.get(a);r||(r=new u.PointsMaterial,u.Material.prototype.copy.call(r,n),r.color.copy(n.color),r.map=n.map,r.sizeAttenuation=!1,this.cache.add(a,r)),n=r}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let r=this.cache.get(a);r||(r=new u.LineBasicMaterial,u.Material.prototype.copy.call(r,n),r.color.copy(n.color),r.map=n.map,this.cache.add(a,r)),n=r}if(s||i||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let r=this.cache.get(a);r||(r=n.clone(),i&&(r.vertexColors=!0),o&&(r.flatShading=!0),s&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(a,r),this.associations.set(r,this.associations.get(n))),n=r}e.material=n}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const a={},r=i.extensions||{},c=[];if(r[b.KHR_MATERIALS_UNLIT]){const d=s[b.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,i,t))}else{const d=i.pbrMetallicRoughness||{};if(a.color=new u.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],u.LinearSRGBColorSpace),a.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,u.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=u.DoubleSide);const h=i.alphaMode||Q.OPAQUE;if(h===Q.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Q.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;a.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&o!==u.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==u.MeshBasicMaterial){const d=i.emissiveFactor;a.emissive=new u.Color().setRGB(d[0],d[1],d[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==u.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return i.name&&(d.name=i.name),I(d,i),t.associations.set(d,{materials:e}),i.extensions&&V(s,d,i),d})}createUniqueName(e){const t=u.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(a){return n[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(r){return ye(r,a,t)})}const o=[];for(let a=0,r=e.length;a<r;a++){const c=e[a],h=pt(c),d=s[h];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ye(new u.BufferGeometry,c,t),s[h]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,a=[];for(let r=0,c=o.length;r<c;r++){const h=o[r].material===void 0?ht(this.cache):this.getDependency("material",o[r].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(r){const c=r.slice(0,r.length-1),h=r[r.length-1],d=[];for(let f=0,m=h.length;f<m;f++){const x=h[f],y=o[f];let g;const M=c[f];if(y.mode===C.TRIANGLES||y.mode===C.TRIANGLE_STRIP||y.mode===C.TRIANGLE_FAN||y.mode===void 0)g=i.isSkinnedMesh===!0?new u.SkinnedMesh(x,M):new u.Mesh(x,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),y.mode===C.TRIANGLE_STRIP?g.geometry=he(g.geometry,u.TriangleStripDrawMode):y.mode===C.TRIANGLE_FAN&&(g.geometry=he(g.geometry,u.TriangleFanDrawMode));else if(y.mode===C.LINES)g=new u.LineSegments(x,M);else if(y.mode===C.LINE_STRIP)g=new u.Line(x,M);else if(y.mode===C.LINE_LOOP)g=new u.LineLoop(x,M);else if(y.mode===C.POINTS)g=new u.Points(x,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(g.geometry.morphAttributes).length>0&&dt(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),I(g,i),y.extensions&&V(s,g,y),t.assignFinalMaterial(g),d.push(g)}for(let f=0,m=d.length;f<m;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&V(s,d[0],i),d[0];const p=new u.Group;i.extensions&&V(s,p,i),t.associations.set(p,{meshes:e});for(let f=0,m=d.length;f<m;f++)p.add(d[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new u.PerspectiveCamera(u.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new u.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),I(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,a=[],r=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const p=new u.Matrix4;i!==null&&p.fromArray(i.array,c*16),r.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new u.Skeleton(a,r)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],a=[],r=[],c=[],h=[];for(let d=0,p=s.channels.length;d<p;d++){const f=s.channels[d],m=s.samplers[f.sampler],x=f.target,y=x.node,g=s.parameters!==void 0?s.parameters[m.input]:m.input,M=s.parameters!==void 0?s.parameters[m.output]:m.output;x.node!==void 0&&(o.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",g)),r.push(this.getDependency("accessor",M)),c.push(m),h.push(x))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],f=d[1],m=d[2],x=d[3],y=d[4],g=[];for(let T=0,A=p.length;T<A;T++){const P=p[T],R=f[T],O=m[T],G=x[T],E=y[T];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const oe=n._createAnimationTracks(P,R,O,G,E);if(oe)for(let re=0;re<oe.length;re++)g.push(oe[re])}const M=new u.AnimationClip(i,void 0,g);return I(M,s),M})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let r=0,c=s.weights.length;r<c;r++)a.morphTargetInfluences[r]=s.weights[r]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const r=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),r]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(p,mt)});for(let f=0,m=d.length;f<m;f++)h.add(d[f]);if(h.userData.pivot!==void 0&&d.length>0){const f=h.userData.pivot,m=d[0];h.pivot=new u.Vector3().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",a=[],r=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return r&&a.push(r),i.camera!==void 0&&a.push(s.getDependency("camera",i.camera).then(function(c){return s._getNodeRef(s.cameraCache,i.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(i.isBone===!0?h=new u.Bone:c.length>1?h=new u.Group:c.length===1?h=c[0]:h=new u.Object3D,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(i.name&&(h.userData.name=i.name,h.name=o),I(h,i),i.extensions&&V(n,h,i),i.matrix!==void 0){const d=new u.Matrix4;d.fromArray(i.matrix),h.applyMatrix4(d)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new u.Group;n.name&&(i.name=s.createUniqueName(n.name)),I(i,n),n.extensions&&V(t,i,n);const o=n.nodes||[],a=[];for(let r=0,c=o.length;r<c;r++)a.push(s.getDependency("node",o[r]));return Promise.all(a).then(function(r){for(let h=0,d=r.length;h<d;h++){const p=r[h];p.parent!==null?i.add(Ue(p)):i.add(p)}const c=h=>{const d=new Map;for(const[p,f]of s.associations)(p instanceof u.Material||p instanceof u.Texture)&&d.set(p,f);return h.traverse(p=>{const f=s.associations.get(p);f!=null&&d.set(p,f)}),d};return s.associations=c(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],a=e.name?e.name:e.uuid,r=[];function c(f){f.morphTargetInfluences&&r.push(f.name?f.name:f.uuid)}F[i.path]===F.weights?(c(e),e.isGroup&&e.children.forEach(c)):r.push(a);let h;switch(F[i.path]){case F.weights:h=u.NumberKeyframeTrack;break;case F.rotation:h=u.QuaternionKeyframeTrack;break;case F.translation:case F.scale:h=u.VectorKeyframeTrack;break;default:n.itemSize===1?h=u.NumberKeyframeTrack:h=u.VectorKeyframeTrack;break}const d=s.interpolation!==void 0?ct[s.interpolation]:u.InterpolateLinear,p=this._getArrayFromAccessor(n);for(let f=0,m=r.length;f<m;f++){const x=new h(r[f]+"."+F[i.path],t.array,p,d);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),o.push(x)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Z(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof u.QuaternionKeyframeTrack?lt:me;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function _t(l,e,t){const n=e.attributes,s=new u.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],r=a.min,c=a.max;if(r!==void 0&&c!==void 0){if(s.set(new u.Vector3(r[0],r[1],r[2]),new u.Vector3(c[0],c[1],c[2])),a.normalized){const h=Z(U[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new u.Vector3,r=new u.Vector3;for(let c=0,h=i.length;c<h;c++){const d=i[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(r.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),r.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),r.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const x=Z(U[p.componentType]);r.multiplyScalar(x)}a.max(r)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}l.boundingBox=s;const o=new u.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=o}function ye(l,e,t){const n=e.attributes,s=[];function i(o,a){return t.getDependency("accessor",o).then(function(r){l.setAttribute(a,r)})}for(const o in n){const a=Y[o]||o.toLowerCase();a in l.attributes||s.push(i(n[o],a))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(a){l.setIndex(a)});s.push(o)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),I(l,e),_t(l,e,t),Promise.all(s).then(function(){return e.targets!==void 0?ut(l,e.targets,t):l})}const xe={type:"change"},H={type:"start"},Me={type:"end"},W=new u.Ray,we=new u.Plane,yt=Math.cos(70*u.MathUtils.DEG2RAD),k=new u.Vector3,N=2*Math.PI,S={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$=1e-6;class xt extends u.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wt.bind(this),this._onPointerDown=Mt.bind(this),this._onPointerUp=bt.bind(this),this._onContextMenu=Rt.bind(this),this._onMouseWheel=St.bind(this),this._onKeyDown=Lt.bind(this),this._onTouchStart=Pt.bind(this),this._onTouchMove=kt.bind(this),this._onMouseDown=Tt.bind(this),this._onMouseMove=At.bind(this),this._interceptControlDown=vt.bind(this),this._interceptControlUp=Nt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(xe),this.update(),this.state=S.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;k.copy(t).sub(this.target),k.applyQuaternion(this._quat),this._spherical.setFromVector3(k),this.autoRotate&&this.state===S.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=N:n>Math.PI&&(n-=N),s<-Math.PI?s+=N:s>Math.PI&&(s-=N),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(k.setFromSpherical(this._spherical),k.applyQuaternion(this._quatInverse),t.copy(this.target).add(k),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=k.length();o=this._clampDistance(a*this._scale);const r=a-o;this.object.position.addScaledVector(this._dollyDirection,r),this.object.updateMatrixWorld(),i=!!r}else if(this.object.isOrthographicCamera){const a=new u.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=r!==this.object.zoom;const c=new u.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=k.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(W.origin.copy(this.object.position),W.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(W.direction))<yt?this.object.lookAt(this.target):(we.setFromNormalAndCoplanarPoint(this.object.up,this.target),W.intersectPlane(we,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>$||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$||this._lastTargetPosition.distanceToSquared(this.target)>$?(this.dispatchEvent(xe),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?N/60*this.autoRotateSpeed*e:N/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){k.setFromMatrixColumn(t,0),k.multiplyScalar(-e),this._panOffset.add(k)}_panUp(e,t){this.screenSpacePanning===!0?k.setFromMatrixColumn(t,1):(k.setFromMatrixColumn(t,0),k.crossVectors(this.object.up,k)),k.multiplyScalar(e),this._panOffset.add(k)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;k.copy(s).sub(this.target);let i=k.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,i=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(i/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(N*this._rotateDelta.x/t.clientHeight),this._rotateUp(N*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-N*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateEnd.set(s,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(N*this._rotateDelta.x/t.clientHeight),this._rotateUp(N*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Mt(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function wt(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function bt(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Me),this.state=S.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Tt(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case u.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}break;case u.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(H)}function At(l){switch(this.state){case S.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case S.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case S.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function St(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(H),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(Me))}function Lt(l){this.enabled!==!1&&this._handleKeyDown(l)}function Pt(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=S.TOUCH_PAN;break;default:this.state=S.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=S.TOUCH_DOLLY_ROTATE;break;default:this.state=S.NONE}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(H)}function kt(l){switch(this._trackPointer(l),this.state){case S.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case S.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case S.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case S.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=S.NONE}}function Rt(l){this.enabled!==!1&&l.preventDefault()}function vt(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Nt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ot=((l,e)=>{const t=l.__vccOpts||l;for(const[n,s]of e)t[n]=s;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},clearAlpha:{type:[String,Number],default:1},clearColor:{type:String,default:"#7fbfff"},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["initialized","animate"],setup(l,{emit:e}){const t=e,n=l,s="dom"+w.getCurrentInstance().uid,i=w.useTemplateRef(s);let o=null,a=null,r=null,c=null,h=null,d=null,p=null;const f=g=>{o==null&&(o=new _.Timer),o?.update(g);const M=o.getDelta(),T={GLTFLoader:z,THREE:_,VRMExpressionPresetName:D.VRMExpressionPresetName,VRMHumanBoneName:D.VRMHumanBoneName,VRMUtils:D.VRMUtils,camera:c,controls:d,deltaTime:M,renderer:h,scene:r};t("animate",T),a!=null&&(cancelAnimationFrame(a),a=null),n.animation&&(a=requestAnimationFrame(f)),h.render(r,c)},m=()=>{a!=null&&(cancelAnimationFrame(a),a=null),a=requestAnimationFrame(f)},x=()=>{a!=null&&(cancelAnimationFrame(a),a=null)};w.watch(()=>n.animation,g=>{g==!0?m():x()}),w.watch(()=>n.clearAlpha,g=>{h&&h.setClearAlpha(parseFloat(g))}),w.watch(()=>n.clearColor,g=>{if(h){const M=new _.Color(g),T=h.getClearAlpha();h.setClearColor(M,T)}});const y=()=>{const g=i.value,M=g.clientWidth,T=g.clientHeight,A={antialias:!0,alpha:!1};if(_.ColorManagement.enabled=!1,h=new _.WebGLRenderer(A),h.setPixelRatio(window.devicePixelRatio),h.setSize(M,T),h.setClearColor(n.clearColor,n.clearAlpha),h.outputColorSpace=_.SRGBColorSpace,g.appendChild(h.domElement),r=new _.Scene,c=new _.PerspectiveCamera(45,M/T,.1,1e3),c.position.set(0,1.25,1),n.useOrbitControls&&(d=new xt(c,g),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),n.useGridHelper){const R=new _.GridHelper(10,10);r.add(R),R.visible=!0}if(n.useAxesHelper){const R=new _.AxesHelper(5);r.add(R)}if(n.useDefaultLight){const R=new _.DirectionalLight(16777215);R.intensity=3,R.position.set(1,1,1).normalize(),r.add(R);const O=new _.AmbientLight(4210752);r.add(O)}const P={GLTFLoader:z,THREE:_,VRMExpressionPresetName:D.VRMExpressionPresetName,VRMHumanBoneName:D.VRMHumanBoneName,VRMUtils:D.VRMUtils,camera:c,controls:d,renderer:h,scene:r};t("initialized",P)};return w.onMounted(async()=>{if(!ce.isWebGL2Available()){const g=ce.getWebGLErrorMessage();console.error(g);return}p=new ResizeObserver(g=>{const M=g[0],T=M.contentRect.width,A=M.contentRect.height;h.setPixelRatio(window.devicePixelRatio),h.setSize(T,A),c.aspect=T/A,c.updateProjectionMatrix()}),p.observe(i.value),y()}),w.onUnmounted(()=>{p&&p.disconnect()}),(g,M)=>(w.openBlock(),w.createElementBlock("div",{ref:s,class:"box"}))}},[["__scopeId","data-v-0b88fd37"]]);var be=(l,e,t)=>new Promise((n,s)=>{var i=r=>{try{a(t.next(r))}catch(c){s(c)}},o=r=>{try{a(t.throw(r))}catch(c){s(c)}},a=r=>r.done?n(r.value):Promise.resolve(r.value).then(i,o);a((t=t.apply(l,e)).next())}),Ct={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};new _.Color,new _.Vector2,new _.Vector3,new _.Vector3,new _.Quaternion;var Te={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function It(l){return l.invert?l.invert():l.inverse(),l}new _.Vector3,new _.Quaternion,new _.Vector3,new _.Quaternion,new _.Vector3,new _.Quaternion,new _.Quaternion,new _.Vector3,new _.Vector3;var Ae=Math.sqrt(2)/2;new _.Quaternion(0,0,-Ae,Ae),new _.Vector3(0,1,0);var Dt=new _.Vector3,Ft=new _.Vector3;function Vt(l,e){return l.matrixWorld.decompose(Dt,e,Ft),e}function J(l){return[Math.atan2(-l.z,l.x),Math.atan2(l.y,Math.sqrt(l.x*l.x+l.z*l.z))]}function Se(l){const e=Math.round(l/2/Math.PI);return l-2*Math.PI*e}var Le=new _.Vector3(0,0,1),Ut=new _.Vector3,Et=new _.Vector3,jt=new _.Vector3,Bt=new _.Quaternion,ee=new _.Quaternion,Pe=new _.Quaternion,Gt=new _.Quaternion,te=new _.Euler,ke=class Fe{constructor(e,t){this.offsetFromHeadBone=new _.Vector3,this.autoUpdate=!0,this.faceFront=new _.Vector3(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new _.Quaternion)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new _.Euler)}getEuler(e){return e.set(_.MathUtils.DEG2RAD*this._pitch,_.MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new Fe(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){const t=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(t.matrixWorld)}getLookAtWorldQuaternion(e){const t=this.humanoid.getRawBoneNode("head");return Vt(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(Le)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,n]=J(this.faceFront);return te.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(te).premultiply(Gt.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(ee),this.getFaceFrontQuaternion(Pe),e.copy(Le).applyQuaternion(ee).applyQuaternion(Pe).applyEuler(this.getEuler(te))}lookAt(e){const t=Bt.copy(this._restHeadWorldQuaternion).multiply(It(this.getLookAtWorldQuaternion(ee))),n=this.getLookAtWorldPosition(Et),s=jt.copy(e).sub(n).applyQuaternion(t).normalize(),[i,o]=J(this.faceFront),[a,r]=J(s),c=Se(a-i),h=Se(o-r);this._yaw=_.MathUtils.RAD2DEG*c,this._pitch=_.MathUtils.RAD2DEG*h,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(Ut)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};ke.EULER_ORDER="YXZ";var Kt=ke;new _.Vector3(0,0,1),new _.Quaternion,new _.Quaternion,new _.Euler(0,0,0,"YXZ");var Re=180/Math.PI,ne=new _.Euler,se=class extends _.Object3D{constructor(l){super(),this.vrmLookAt=l,this.type="VRMLookAtQuaternionProxy";const e=this.rotation._onChangeCallback;this.rotation._onChange(()=>{e(),this._applyToLookAt()});const t=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{t(),this._applyToLookAt()})}_applyToLookAt(){ne.setFromQuaternion(this.quaternion,Kt.EULER_ORDER),this.vrmLookAt.yaw=Re*ne.y,this.vrmLookAt.pitch=Re*ne.x}};function zt(l,e,t){var n,s;const i=new Map,o=new Map;for(const[a,r]of l.humanoidTracks.rotation.entries()){const c=(n=e.getNormalizedBoneNode(a))==null?void 0:n.name;if(c!=null){const h=new _.QuaternionKeyframeTrack(`${c}.quaternion`,r.times,r.values.map((d,p)=>t==="0"&&p%2===0?-d:d));o.set(a,h)}}for(const[a,r]of l.humanoidTracks.translation.entries()){const c=(s=e.getNormalizedBoneNode(a))==null?void 0:s.name;if(c!=null){const h=l.restHipsPosition.y,p=e.normalizedRestPose.hips.position[1]/h,f=r.clone();f.values=f.values.map((m,x)=>(t==="0"&&x%3!==1?-m:m)*p),f.name=`${c}.position`,i.set(a,f)}}return{translation:i,rotation:o}}function Wt(l,e){const t=new Map,n=new Map;for(const[s,i]of l.expressionTracks.preset.entries()){const o=e.getExpressionTrackName(s);if(o!=null){const a=i.clone();a.name=o,t.set(s,a)}}for(const[s,i]of l.expressionTracks.custom.entries()){const o=e.getExpressionTrackName(s);if(o!=null){const a=i.clone();a.name=o,n.set(s,a)}}return{preset:t,custom:n}}function Xt(l,e){if(l.lookAtTrack==null)return null;const t=l.lookAtTrack.clone();return t.name=e,t}function Yt(l,e){const t=[],n=zt(l,e.humanoid,e.meta.metaVersion);if(t.push(...n.translation.values()),t.push(...n.rotation.values()),e.expressionManager!=null){const s=Wt(l,e.expressionManager);t.push(...s.preset.values()),t.push(...s.custom.values())}if(e.lookAt!=null){let s=e.scene.children.find(o=>o instanceof se);s==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),s=new se(e.lookAt),s.name="VRMLookAtQuaternionProxy",e.scene.add(s)):s.name===""&&(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually"),s.name="VRMLookAtQuaternionProxy");const i=Xt(l,`${s.name}.quaternion`);i!=null&&t.push(i)}return new _.AnimationClip("Clip",l.duration,t)}var Qt=class{constructor(){this.duration=0,this.restHipsPosition=new _.Vector3,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function ve(l,e){const t=l.length,n=[];let s=[],i=0;for(let o=0;o<t;o++){const a=l[o];i<=0&&(i=e,s=[],n.push(s)),s.push(a),i--}return n}var qt=new _.Matrix4,B=new _.Vector3,ie=new _.Quaternion,Ne=new _.Quaternion,Zt=new _.Quaternion,Ht=new Set(["1.0","1.0-draft"]),$t=new Set(Object.values(Ct)),Jt=class{constructor(l){this.parser=l}get name(){return"VRMC_vrm_animation"}afterRoot(l){return be(this,null,function*(){var e,t,n;const s=l.parser.json,i=s.extensionsUsed;if(i==null||i.indexOf(this.name)==-1)return;const o=(e=s.extensions)==null?void 0:e[this.name];if(o==null)return;const a=o.specVersion;if(a==null)console.warn("VRMAnimationLoaderPlugin: specVersion of the VRMA is not defined. Consider updating the animation file. Assuming the spec version is 1.0.");else{if(!Ht.has(a)){console.warn(`VRMAnimationLoaderPlugin: Unknown VRMC_vrm_animation spec version: ${a}`);return}a==="1.0-draft"&&console.warn("VRMAnimationLoaderPlugin: Using a draft spec version: 1.0-draft. Some behaviors may be different. Consider updating the animation file.")}const r=this._createNodeMap(o),c=yield this._createBoneWorldMatrixMap(l,o),h=(n=(t=o.humanoid)==null?void 0:t.humanBones.hips)==null?void 0:n.node,d=h!=null?yield l.parser.getDependency("node",h):null,p=new _.Vector3;d?.getWorldPosition(p),p.y<.001&&console.warn("VRMAnimationLoaderPlugin: The loaded VRM Animation might violate the VRM T-pose (The y component of the rest hips position is approximately zero or below.)");const m=l.animations.map((x,y)=>{const g=s.animations[y],M=this._parseAnimation(x,g,r,c);return M.restHipsPosition=p,M});l.userData.vrmAnimations=m})}_createNodeMap(l){var e,t,n,s,i;const o=new Map,a=new Map,r=(e=l.humanoid)==null?void 0:e.humanBones;r&&Object.entries(r).forEach(([p,f])=>{const m=f?.node;m!=null&&o.set(m,p)});const c=(t=l.expressions)==null?void 0:t.preset;c&&Object.entries(c).forEach(([p,f])=>{const m=f?.node;m!=null&&a.set(m,p)});const h=(n=l.expressions)==null?void 0:n.custom;h&&Object.entries(h).forEach(([p,f])=>{const{node:m}=f;a.set(m,p)});const d=(i=(s=l.lookAt)==null?void 0:s.node)!=null?i:null;return{humanoidIndexToName:o,expressionsIndexToName:a,lookAtIndex:d}}_createBoneWorldMatrixMap(l,e){return be(this,null,function*(){var t,n;l.scene.updateWorldMatrix(!1,!0);const s=yield l.parser.getDependencies("node"),i=new Map;if(e.humanoid==null)return i;for(const[o,a]of Object.entries(e.humanoid.humanBones)){const r=a?.node;if(r!=null){const c=s[r];i.set(o,c.matrixWorld),o==="hips"&&i.set("hipsParent",(n=(t=c.parent)==null?void 0:t.matrixWorld)!=null?n:qt)}}return i})}_parseAnimation(l,e,t,n){const s=l.tracks,i=e.channels,o=new Qt;return o.duration=l.duration,i.forEach((a,r)=>{const{node:c,path:h}=a.target,d=s[r];if(c==null)return;const p=t.humanoidIndexToName.get(c);if(p!=null){let m=Te[p];for(;m!=null&&n.get(m)==null;)m=Te[m];if(m==null&&(m="hipsParent"),h==="translation")if(p!=="hips")console.warn(`The loading animation contains a translation track for ${p}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const x=n.get("hipsParent"),y=ve(d.values,3).flatMap(M=>B.fromArray(M).applyMatrix4(x).toArray()),g=d.clone();g.values=new Float32Array(y),o.humanoidTracks.translation.set(p,g)}else if(h==="rotation"){const x=n.get(p),y=n.get(m);x.decompose(B,ie,B),ie.invert(),y.decompose(B,Ne,B);const g=ve(d.values,4).flatMap(T=>Zt.fromArray(T).premultiply(Ne).multiply(ie).toArray()),M=d.clone();M.values=new Float32Array(g),o.humanoidTracks.rotation.set(p,M)}else throw new Error(`Invalid path "${h}"`);return}const f=t.expressionsIndexToName.get(c);if(f!=null){if(h==="translation"){const m=d.times,x=new Float32Array(d.values.length/3);for(let g=0;g<x.length;g++)x[g]=d.values[3*g];const y=new _.NumberKeyframeTrack(`${f}.weight`,m,x);$t.has(f)?o.expressionTracks.preset.set(f,y):o.expressionTracks.custom.set(f,y)}else throw new Error(`Invalid path "${h}"`);return}if(c===t.lookAtIndex)if(h==="rotation")o.lookAtTrack=d;else throw new Error(`Invalid path "${h}"`)}),o}};const Oe={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const r=await new K().fetchExpression(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},i=o=>{t("loading",n.name,n.command);let a=!1;o&&(a=!0),t("loaded",n.name,n.command,a,o)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},Ce={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const r=await new K().fetchPose(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},i=o=>{t("loading",n.name,n.command);const r=new K().normalizePose(o);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},Ie={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async a=>{const r=new z;return r.register(c=>new D.VRMLoaderPlugin(c)),await r.loadAsync(a).then(c=>{const h=c.userData.vrm;return D.VRMUtils.rotateVRM0(h),h})},i=async a=>{if(!a)return;t("loading",n.name,n.command);const r=await s(a);let c=!1;r&&(c=!0),t("loaded",n.name,n.command,c,r)},o=a=>{t("loading",n.name,n.command);let r=!1;a&&(r=!0),t("loaded",n.name,n.command,r,a)};return w.onMounted(async()=>{n.data!=null?o(n.data):i(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&o(n.data)}),w.watch(()=>n.url,()=>{n.url&&i(n.url)}),(a,r)=>null}},en={__name:"VroidVrma",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async o=>{if(!o)return;t("loading",n.name,n.command);const a=new z;a.crossOrigin="anonymous",a.register(d=>new Jt(d));const c=(await a.loadAsync(o)).userData.vrmAnimations[0];let h=!1;c&&(h=!0),t("loaded",n.name,n.command,h,c)},i=o=>{t("loading",n.name,n.command);let a=!1;o&&(a=!0),t("loaded",n.name,n.command,a,o)};return w.onMounted(async()=>{n.data!=null?i(n.data):s(n.url)}),w.watch(()=>n.data,()=>{n.data!=null&&i(n.data)}),w.watch(()=>n.url,()=>{n.url&&s(n.url)}),(o,a)=>null}},De={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null},vrma_name:{type:String},vrma_url:{type:String},vrma_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s={},i={},o=w.ref(null),a=w.ref(null),r=w.ref(null),c=w.ref(null),h=(p,f)=>{const m=Object.keys(s).length;s[p]=f;const x=Object.keys(s).length;m==0&&x&&t("loading",n.name)},d=(p,f,m,x)=>{const y=Object.keys(s).length;m&&(f=="load_expression"&&(o.value=x),f=="load_pose"&&(a.value=x),f=="load_vrm"&&(r.value=x),f=="load_vrma"&&(c.value=x),i[p]=f),delete s[p];const g=Object.keys(s).length;if(y&&g==0){const M={};for(const A in i){const P=i[A];P=="load_expression"&&(M.expression=o.value),P=="load_pose"&&(M.pose=a.value),P=="load_vrm"&&(M.vrm=r.value),P=="load_vrma"&&(M.vrma=c.value)}t("loaded",n.name,M);const T=Object.keys(i);for(const A of T)delete i[A]}};return(p,f)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[w.createVNode(Oe,{command:"load_expression",name:n.expression_name,url:n.expression_url,data:n.expression_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(Ce,{command:"load_pose",name:n.pose_name,url:n.pose_url,data:n.pose_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(Ie,{command:"load_vrm",name:n.vrm_name,url:n.vrm_url,data:n.vrm_data,onLoading:h,onLoaded:d},null,8,["name","url","data"]),w.createVNode(en,{command:"load_vrma",name:n.vrma_name,url:n.vrma_url,data:n.vrma_data,onLoading:h,onLoaded:d},null,8,["name","url","data"])],64))}},tn={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null},vrma_name:{type:String,default:"vrma"},vrma_url:{type:String,default:""},vrma_data:{type:[Object,null],default:null},vrma_autoplay:{type:[Boolean,null],default:!0}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=w.ref(null);s.value=new le;const i=a=>{t("loading",a)},o=(a,r)=>{if("vrm"in r){s.value.setModel(r.vrm);const c=new se(s.value.vrm.lookAt);c.name="lookAtQuaternionProxy",s.value.vrm.scene.add(c);const h=new _.AnimationMixer(s.value.vrm.scene);s.value.setMixer(h)}if("pose"in r&&(s.value.resetPose(),s.value.setPose(r.pose),s.value.updatePose()),"expression"in r&&(s.value.resetExpression(),s.value.importExpression(r.expression),s.value.updateExpression()),"vrma"in r&&(s.value.setVrma(r.vrma),n.vrma_autoplay)){const c=Yt(s.value.vrma,s.value.vrm);s.value.mixer.stopAllAction(),s.value.mixer.clipAction(c).play()}t("loaded",a,s.value)};return(a,r)=>(w.openBlock(),w.createBlock(De,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,vrma_name:l.vrma_name,vrma_url:l.vrma_url,vrma_data:l.vrma_data,onLoading:i,onLoaded:o},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data","vrma_name","vrma_url","vrma_data"]))}};v.ResourceLoader=K,v.ThreeFrame=Ot,v.VrmModel=le,v.VroidControl=tn,v.VroidExpression=Oe,v.VroidModel=De,v.VroidPose=Ce,v.VroidVrm=Ie,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|