@j-kyoda/vue-three-vrm 0.7.0 → 0.8.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 CHANGED
@@ -7,33 +7,143 @@ A Vue 3 component designed to render and display VRM models on your web pages.
7
7
  Package is available on NPM: https://www.npmjs.com/package/@j-kyoda/vue-three-vrm
8
8
 
9
9
  ```sh
10
- npm i @j-kyoda/vue-three-vrm
10
+ npm install @j-kyoda/vue-three-vrm three @pixiv/three-vrm
11
11
  ```
12
12
 
13
- ## Customize configuration
13
+ ---
14
14
 
15
- See [Vite Configuration Reference](https://vite.dev/config/).
15
+ ## Usage
16
16
 
17
- ## Project Setup
17
+ ```vue
18
+ <script setup>
19
+ import { ref } from 'vue'
18
20
 
19
- ```sh
20
- npm install
21
- ```
21
+ import { VroidControl, ThreeFrame } from '@j-kyoda/vue-three-vrm'
22
22
 
23
- ### Compile and Hot-Reload for Development
24
23
 
25
- ```sh
26
- npm run dev
27
- ```
24
+ const context_ready = ref(false)
25
+ const render_context = ref(null)
26
+ const animation = ref(false)
28
27
 
29
- ### Compile and Minify for Production
28
+ // toDo: Please enter your model name here.
29
+ const model_name = 'chico_hoodie'
30
+ // toDo: Please enter your pose URL here.
31
+ const pose_url = 'poses/chico_pose_goodjob_202506.json'
32
+ // toDo: Please enter your VRM model URL here.
33
+ const vrm_url = 'models/chico_hoodie.vrm'
30
34
 
31
- ```sh
32
- npm run build
35
+
36
+ const context_initialized = async (context) => {
37
+ render_context.value = context // save context
38
+ context_ready.value = true // Begin model loading.
39
+ }
40
+
41
+ const model_loaded = (name, vrm_model) => {
42
+ const context = render_context.value
43
+
44
+ // add model to scene
45
+ const model = vrm_model.scene
46
+ model.name = name
47
+ vrm_model.setPosition({ x: 0, y: 0, z: 0 })
48
+ context.scene.add(model)
49
+
50
+ animation.value = true // Starting animation.
51
+ }
52
+ </script>
53
+
54
+ <template>
55
+ <div class="frame">
56
+ <ThreeFrame
57
+ :animation="animation"
58
+ :useOrbitControls="true"
59
+ :useGridHelper="true"
60
+ :useAxesHelper="false"
61
+ :useDefaultLight="true"
62
+ v-on:initialized="context_initialized"
63
+ />
64
+ </div>
65
+ <div v-if="context_ready">
66
+ <VroidControl
67
+ :model_name="model_name"
68
+ :pose_url="pose_url"
69
+ :vrm_url="vrm_url"
70
+ v-on:loaded="model_loaded"
71
+ />
72
+ </div>
73
+ </template>
74
+
75
+ <style scoped>
76
+ .frame {
77
+ display: block;
78
+ width: 400px;
79
+ height: 400px;
80
+ margin: 0 auto;
81
+ padding: 0;
82
+ }
83
+ </style>
33
84
  ```
34
85
 
35
- ### Lint with [ESLint](https://eslint.org/)
86
+ ---
87
+
88
+ ## ThreeFrame
89
+
90
+ ### Props
91
+
92
+ | ID | Type | Default | Description |
93
+ | :--------------- | :------- | :------ | :---------------------------------- |
94
+ | animation | Boolean | false | Controls animation loop execution. |
95
+ | useOrbitControls | Boolean | false | Enables/disables `OrbitControls`. |
96
+ | useGridHelper | Boolean | false | Shows/hides the grid. |
97
+ | useAxesHelper | Boolean | false | Shows/hides the 3D axis arrows. |
98
+ | useDefaultLight | Boolean | false | Sets up default lighting. |
99
+
100
+ ### Events (Emits)
101
+
102
+ | Event | Description | Payload |
103
+ | :----------- | :----------------------------------------------------- | :------------- |
104
+ | initialized | Occurs when the renderer setup is complete. | ContextObject |
105
+ | animate | Occurs before the rendering process in animation loop. | ContextObject |
106
+
107
+ ## ContextObject
36
108
 
37
- ```sh
38
- npm run lint
39
109
  ```
110
+ {
111
+ GLTFLoader,
112
+ THREE,
113
+ VRMExpressionPresetName,
114
+ VRMHumanBoneName,
115
+ camera, // Instance of THREE.PerspectiveCamera
116
+ controls, // Instance of OrbitControls
117
+ renderer, // Instance of THREE.WebGLRenderer
118
+ scene // Instance of THREE.Scene
119
+ }
120
+ ```
121
+
122
+ ## VroidControl
123
+
124
+ ### Props
125
+
126
+ | ID | Type | default | Description |
127
+ | :-------------- | :----- | :----------- | :------------------------------------------------------ |
128
+ | model_name | String | '' | The name of the VRoid model to display. ** Required **. |
129
+ | expression_name | String | 'expression' | The name of the expression model. |
130
+ | expression_url | String | '' | The URL of the expression model. |
131
+ | expression_data | Object | null | The object for the expression model. |
132
+ | pose_name | String | 'pose' | The name of the pose model. |
133
+ | pose_url | String | '' | The URL of the pose model. |
134
+ | pose_data | Object | null | The object for the pose model. |
135
+ | vrm_name | String | 'vrm' | The name of the VRM model. |
136
+ | vrm_url | String | '' | The URL of the VRM model. |
137
+ | vrm_data | Object | null | The object for the VRM model. |
138
+
139
+ ### Events (Emits)
140
+
141
+ | Event | Description | Payload |
142
+ | :--------- | :------------------------------------------------ | :----------------------------------- |
143
+ | loading | Occurs while the VRoid model is loading. | VRoid model name |
144
+ | loaded | Occurs when the VRoid model has finished loading. | VRoid model name, VRMModel instance |
145
+
146
+
147
+ ## License
148
+
149
+ This project is licensed under the MIT License. For more details, please refer to the LICENSE file located at the root of the project.
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- .box[data-v-e91ca0ac]{display:block;width:100%;height:100%}
1
+ .box[data-v-8fb60132]{display:block;width:100%;height:100%}
@@ -2376,7 +2376,7 @@ const Ds = (l, e) => {
2376
2376
  default: !1
2377
2377
  }
2378
2378
  },
2379
- emits: ["init", "animate"],
2379
+ emits: ["initialized", "animate"],
2380
2380
  setup(l, { emit: e }) {
2381
2381
  const t = e, s = l, n = "dom" + ze().uid, i = Xe(n);
2382
2382
  let o = null, r = null, a = null, c = null, u = null;
@@ -2423,7 +2423,7 @@ const Ds = (l, e) => {
2423
2423
  const A = new N.AmbientLight(4210752);
2424
2424
  r.add(A);
2425
2425
  }
2426
- t("init", {
2426
+ t("initialized", {
2427
2427
  GLTFLoader: ue,
2428
2428
  THREE: N,
2429
2429
  VRMExpressionPresetName: Re,
@@ -2450,7 +2450,7 @@ const Ds = (l, e) => {
2450
2450
  class: "box"
2451
2451
  }));
2452
2452
  }
2453
- }, Us = /* @__PURE__ */ Ds(Cs, [["__scopeId", "data-v-e91ca0ac"]]), Is = {
2453
+ }, Us = /* @__PURE__ */ Ds(Cs, [["__scopeId", "data-v-8fb60132"]]), Is = {
2454
2454
  __name: "VroidExpression",
2455
2455
  props: {
2456
2456
  command: {
@@ -1,2 +1,2 @@
1
- (function(A,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("vue"),require("three"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","vue","three","@pixiv/three-vrm"],T):(A=typeof globalThis<"u"?globalThis:A||self,T(A.VueThreeVrm={},A.Vue,A.THREE,A.THREE_VRM))})(this,function(A,T,h,F){"use strict";var J=document.createElement("style");J.textContent=`.box[data-v-e91ca0ac]{display:block;width:100%;height:100%}
2
- /*$vite$:1*/`,document.head.appendChild(J);function me(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const C=me(h);class E{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}async fetchPose(e){const t=await this.fetchJSON(e);return t==null?null:"pose"in t?t.pose:t}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class H{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,s,n){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=s,i.rotation.z=n)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,s,n){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=s,i.position.z=n)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const s in t)e[s]=this.getExpression(s);return e}return null}}class ee{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"),s=window.WebGL2RenderingContext&&t.getContext("webgl2");return s.drawingBufferColorSpace=e,s.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},s={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let n='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",s[e]?n=n.replace("$0","graphics card"):n=n.replace("$0","browser"),n=n.replace("$1",t[e]),i.innerHTML=n,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}function te(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class K extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new De(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Pe(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Oe(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new ke(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const r=function(c){n?n(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},a=new h.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{i.parse(c,o,function(d){t(d),i.manager.itemEnd(e)},r)}catch(d){r(d)}},s,r)}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,s,n){let i;const o={},r={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===se){try{o[b.KHR_BINARY_GLTF]=new ve(e)}catch(u){n&&n(u);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qe(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 d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[u.name]=u,o[u.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const u=i.extensionsUsed[d],p=i.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:o[u]=new ye;break;case b.KHR_DRACO_MESH_COMPRESSION:o[u]=new je(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[u]=new Fe;break;case b.KHR_MESH_QUANTIZATION:o[u]=new Ue;break;default:p.indexOf(u)>=0&&r[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(r),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function _e(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const 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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ge{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 s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const d=new h.Color(16777215);a.color!==void 0&&d.setRGB(a.color[0],a.color[1],a.color[2],h.LinearSRGBColorSpace);const u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new h.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(d),c.distance=u;break;case"spot":c=new h.SpotLight(d),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),R(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return s._getNodeRef(t.cache,r,a)})}}class ye{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new h.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],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(n)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(i)}}class Me{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const r=o.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Pe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Oe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Ne{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class De{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const c=s.options.manager.getHandler(r.uri);c!==null&&(a=c)}return s.loadTextureImage(e,o.source,a)}}class Re{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const c=s.options.manager.getHandler(r.uri);c!==null&&(a=c)}return s.loadTextureImage(e,o.source,a)}}class Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,p=new Uint8Array(r,a,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,p,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,p,n.mode,n.filter),f})})}else return null}}class ke{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,r=[],a={};for(const c in o)r.push(this.parser.getDependency("accessor",o[c]).then(d=>(a[c]=d,a[c])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],p=c[0].count,f=[];for(const _ of u){const y=new h.Matrix4,m=new h.Vector3,g=new h.Quaternion,M=new h.Vector3(1,1,1),w=new h.InstancedMesh(_.geometry,_.material,p);for(let x=0;x<p;x++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,x),a.ROTATION&&g.fromBufferAttribute(a.ROTATION,x),a.SCALE&&M.fromBufferAttribute(a.SCALE,x),w.setMatrixAt(x,y.compose(m,g,M));for(const x in a)if(x==="_COLOR_0"){const N=a[x];w.instanceColor=new h.InstancedBufferAttribute(N.array,N.itemSize,N.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&_.geometry.setAttribute(x,a[x]);h.Object3D.prototype.copy.call(w,_),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const se="glTF",G=12,ne={JSON:1313821514,BIN:5130562};class ve{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,i=new DataView(e,G);let o=0;for(;o<n;){const r=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===ne.JSON){const c=new Uint8Array(e,G+o,r);this.content=s.decode(c)}else if(a===ne.BIN){const c=G+o;this.body=e.slice(c,c+r)}o+=r}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class je{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 s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},c={};for(const d in o){const u=X[d]||d.toLowerCase();r[u]=o[d]}for(const d in e.attributes){const u=X[d]||d.toLowerCase();if(o[d]!==void 0){const p=s.accessors[e.attributes[d]],f=U[p.componentType];c[u]=f.name,a[u]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(u,p){n.decodeDracoFile(d,function(f){for(const _ in f.attributes){const y=f.attributes[_],m=a[_];m!==void 0&&(y.normalized=m)}u(f)},r,c,h.LinearSRGBColorSpace,p)})})}}class Fe{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 Ue{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ie extends h.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,c=r*3,d=n-t,u=(s-t)/d,p=u*u,f=p*u,_=e*c,y=_-c,m=-2*f+3*p,g=f-p,M=1-m,w=g-p+u;for(let x=0;x!==r;x++){const N=o[y+x+r],k=o[y+x+a]*d,D=o[_+x+r],B=o[_+x]*d;i[x]=M*N+w*k+m*D+g*B}return i}}const Ge=new h.Quaternion;class Be extends ie{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ge.fromArray(i).normalize().toArray(i),i}}const O={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},oe={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},re={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={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"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ve={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ee(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function j(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function R(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 Ke(l,e,t){let s=!1,n=!1,i=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(s){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):l.attributes.position;o.push(p)}if(n){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):l.attributes.normal;r.push(p)}if(i){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):l.attributes.color;a.push(p)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(c){const d=c[0],u=c[1],p=c[2];return s&&(l.morphAttributes.position=d),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ze(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xe(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Y(l.targets[s]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function q(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 We(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 Ye=new h.Matrix4;class qe{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _e,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 s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const r=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(r)===!0;const a=r.match(/Version\/(\d+)/);n=s&&a?parseInt(a[1],10):-1,i=r.indexOf("Firefox")>-1,o=i?r.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.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 s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const r={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return j(i,r,n),R(r,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){for(const a of r.scenes)a.updateMatrixWorld();e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[c,d]of o.children.entries())i(d,r.children[c])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(h.LoaderUtils.resolveURL(t.uri,n.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(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=z[n.type],r=U[n.componentType],a=n.normalized===!0,c=new r(n.count*o);return Promise.resolve(new h.BufferAttribute(c,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=z[n.type],c=U[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*a,p=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,_=n.normalized===!0;let y,m;if(f&&f!==u){const g=Math.floor(p/f),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+g+":"+n.count;let w=t.cache.get(M);w||(y=new c(r,g*f,n.count*f/d),w=new h.InterleavedBuffer(y,f/d),t.cache.add(M,w)),m=new h.InterleavedBufferAttribute(w,a,p%f/d,_)}else r===null?y=new c(n.count*a):y=new c(r,p,n.count*a),m=new h.BufferAttribute(y,a,_);if(n.sparse!==void 0){const g=z.SCALAR,M=U[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,N=new M(o[1],w,n.sparse.count*g),k=new c(o[2],x,n.sparse.count*a);r!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let D=0,B=N.length;D<B;D++){const v=N[D];if(m.setX(v,k[D*a]),a>=2&&m.setY(v,k[D*a+1]),a>=3&&m.setZ(v,k[D*a+2]),a>=4&&m.setW(v,k[D*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const p=(i.samplers||{})[o.sampler]||{};return d.magFilter=oe[p.magFilter]||h.LinearFilter,d.minFilter=oe[p.minFilter]||h.LinearMipmapLinearFilter,d.wrapS=re[p.wrapS]||h.RepeatWrapping,d.wrapT=re[p.wrapT]||h.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==h.NearestFilter&&d.minFilter!==h.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",c=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const p=new Blob([u],{type:o.mimeType});return a=r.createObjectURL(p),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(u){return new Promise(function(p,f){let _=p;t.isImageBitmapLoader===!0&&(_=function(y){const m=new h.Texture(y);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(u,i.path),_,void 0,f)})}).then(function(u){return c===!0&&r.revokeObjectURL(a),R(u,o),u.userData.mimeType=o.mimeType||We(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new h.PointsMaterial,h.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(r,a)),s=a}else if(e.isLine){const r="LineBasicMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new h.LineBasicMaterial,h.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(r,a)),s=a}if(n||i||o){let r="ClonedMaterial:"+s.uuid+":";n&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const r={},a=i.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(r,i,t))}else{const u=i.pbrMetallicRoughness||{};if(r.color=new h.Color(1,1,1),r.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;r.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),r.opacity=p[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(r,"map",u.baseColorTexture,h.SRGBColorSpace)),r.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,r.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(r,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(r,"roughnessMap",u.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,r)})))}i.doubleSided===!0&&(r.side=h.DoubleSide);const d=i.alphaMode||W.OPAQUE;if(d===W.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===W.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;r.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const u=i.emissiveFactor;r.emissive=new h.Color().setRGB(u[0],u[1],u[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(r);return i.name&&(u.name=i.name),R(u,i),t.associations.set(u,{materials:e}),i.extensions&&j(n,u,i),u})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(r){return s[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return ae(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const c=e[r],d=Xe(c),u=n[d];if(u)o.push(u.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ae(new h.BufferGeometry,c,t),n[d]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,r=[];for(let a=0,c=o.length;a<c;a++){const d=o[a].material===void 0?Ee(this.cache):this.getDependency("material",o[a].material);r.push(d)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const c=a.slice(0,a.length-1),d=a[a.length-1],u=[];for(let f=0,_=d.length;f<_;f++){const y=d[f],m=o[f];let g;const M=c[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)g=i.isSkinnedMesh===!0?new h.SkinnedMesh(y,M):new h.Mesh(y,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?g.geometry=te(g.geometry,h.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(g.geometry=te(g.geometry,h.TriangleFanDrawMode));else if(m.mode===O.LINES)g=new h.LineSegments(y,M);else if(m.mode===O.LINE_STRIP)g=new h.Line(y,M);else if(m.mode===O.LINE_LOOP)g=new h.LineLoop(y,M);else if(m.mode===O.POINTS)g=new h.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(g.geometry.morphAttributes).length>0&&ze(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),R(g,i),m.extensions&&j(n,g,m),t.assignFinalMaterial(g),u.push(g)}for(let f=0,_=u.length;f<_;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&j(n,u[0],i),u[0];const p=new h.Group;i.extensions&&j(n,p,i),t.associations.set(p,{meshes:e});for(let f=0,_=u.length;f<_;f++)p.add(u[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new h.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),R(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,r=[],a=[];for(let c=0,d=o.length;c<d;c++){const u=o[c];if(u){r.push(u);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),a.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(r,a)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],r=[],a=[],c=[],d=[];for(let u=0,p=n.channels.length;u<p;u++){const f=n.channels[u],_=n.samplers[f.sampler],y=f.target,m=y.node,g=n.parameters!==void 0?n.parameters[_.input]:_.input,M=n.parameters!==void 0?n.parameters[_.output]:_.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),r.push(this.getDependency("accessor",g)),a.push(this.getDependency("accessor",M)),c.push(_),d.push(y))}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(d)]).then(function(u){const p=u[0],f=u[1],_=u[2],y=u[3],m=u[4],g=[];for(let M=0,w=p.length;M<w;M++){const x=p[M],N=f[M],k=_[M],D=y[M],B=m[M];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=s._createAnimationTracks(x,N,k,D,B);if(v)for(let $=0;$<v.length;$++)g.push(v[$])}return new h.AnimationClip(i,void 0,g)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,c=n.weights.length;a<c;a++)r.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],r=n.children||[];for(let c=0,d=r.length;c<d;c++)o.push(s.getDependency("node",r[c]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(c){const d=c[0],u=c[1],p=c[2];p!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ye)});for(let f=0,_=u.length;f<_;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",r=[],a=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){r.push(c)}),this.nodeCache[e]=Promise.all(r).then(function(c){let d;if(i.isBone===!0?d=new h.Bone:c.length>1?d=new h.Group:c.length===1?d=c[0]:d=new h.Object3D,d!==c[0])for(let u=0,p=c.length;u<p;u++)d.add(c[u]);if(i.name&&(d.userData.name=i.name,d.name=o),R(d,i),i.extensions&&j(s,d,i),i.matrix!==void 0){const u=new h.Matrix4;u.fromArray(i.matrix),d.applyMatrix4(u)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new h.Group;s.name&&(i.name=n.createUniqueName(s.name)),R(i,s),s.extensions&&j(t,i,s);const o=s.nodes||[],r=[];for(let a=0,c=o.length;a<c;a++)r.push(n.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let d=0,u=a.length;d<u;d++)i.add(a[d]);const c=d=>{const u=new Map;for(const[p,f]of n.associations)(p instanceof h.Material||p instanceof h.Texture)&&u.set(p,f);return d.traverse(p=>{const f=n.associations.get(p);f!=null&&u.set(p,f)}),u};return n.associations=c(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],r=e.name?e.name:e.uuid,a=[];I[i.path]===I.weights?e.traverse(function(p){p.morphTargetInfluences&&a.push(p.name?p.name:p.uuid)}):a.push(r);let c;switch(I[i.path]){case I.weights:c=h.NumberKeyframeTrack;break;case I.rotation:c=h.QuaternionKeyframeTrack;break;case I.translation:case I.scale:c=h.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?Ve[n.interpolation]:h.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let p=0,f=a.length;p<f;p++){const _=new c(a[p]+"."+I[i.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),o.push(_)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=q(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof h.QuaternionKeyframeTrack?Be:ie;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ze(l,e,t){const s=e.attributes,n=new h.Box3;if(s.POSITION!==void 0){const r=t.json.accessors[s.POSITION],a=r.min,c=r.max;if(a!==void 0&&c!==void 0){if(n.set(new h.Vector3(a[0],a[1],a[2]),new h.Vector3(c[0],c[1],c[2])),r.normalized){const d=q(U[r.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new h.Vector3,a=new h.Vector3;for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,_=p.max;if(f!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),p.normalized){const y=q(U[p.componentType]);a.multiplyScalar(y)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(r)}l.boundingBox=n;const o=new h.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function ae(l,e,t){const s=e.attributes,n=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in s){const r=X[o]||o.toLowerCase();r in l.attributes||n.push(i(s[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});n.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),R(l,e),Ze(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ke(l,e.targets,t):l})}const ce={type:"change"},Z={type:"start"},le={type:"end"},V=new h.Ray,he=new h.Plane,Qe=Math.cos(70*h.MathUtils.DEG2RAD),L=new h.Vector3,P=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},Q=1e-6;class $e extends h.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new h.Vector3,this.cursor=new h.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:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=He.bind(this),this._onPointerDown=Je.bind(this),this._onPointerUp=et.bind(this),this._onContextMenu=at.bind(this),this._onMouseWheel=nt.bind(this),this._onKeyDown=it.bind(this),this._onTouchStart=ot.bind(this),this._onTouchMove=rt.bind(this),this._onMouseDown=tt.bind(this),this._onMouseMove=st.bind(this),this._interceptControlDown=ct.bind(this),this._interceptControlUp=lt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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(ce),this.update(),this.state=S.NONE}update(e=null){const t=this.object.position;L.copy(t).sub(this.target),L.applyQuaternion(this._quat),this._spherical.setFromVector3(L),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 s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,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(L.setFromSpherical(this._spherical),L.applyQuaternion(this._quatInverse),t.copy(this.target).add(L),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 r=L.length();o=this._clampDistance(r*this._scale);const a=r-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const r=new h.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(r),this.object.updateMatrixWorld(),o=L.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):(V.origin.copy(this.object.position),V.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(V.direction))<Qe?this.object.lookAt(this.target):(he.setFromNormalAndCoplanarPoint(this.object.up,this.target),V.intersectPlane(he,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)>Q||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q||this._lastTargetPosition.distanceToSquared(this.target)>Q?(this.dispatchEvent(ce),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/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){L.setFromMatrixColumn(t,0),L.multiplyScalar(-e),this._panOffset.add(L)}_panUp(e,t){this.screenSpacePanning===!0?L.setFromMatrixColumn(t,1):(L.setFromMatrixColumn(t,0),L.crossVectors(this.object.up,L)),L.multiplyScalar(e),this._panOffset.add(L)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;L.copy(n).sub(this.target);let i=L.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.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 s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,r=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/r)*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(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*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(P*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(-P*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(P*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(-P*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);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 s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}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),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);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,r=(e.pageY+t.y)*.5;this._updateZoomParameters(o,r)}_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 h.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,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Je(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function He(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function et(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(le),this.state=S.NONE;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 h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case h.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 h.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(Z)}function st(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 nt(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(Z),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(le))}function it(l){this.enabled!==!1&&this._handleKeyDown(l)}function ot(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case h.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 h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case h.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(Z)}function rt(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 at(l){this.enabled!==!1&&l.preventDefault()}function ct(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ht=((l,e)=>{const t=l.__vccOpts||l;for(const[s,n]of e)t[s]=n;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["init","animate"],setup(l,{emit:e}){const t=e,s=l,n="dom"+T.getCurrentInstance().uid,i=T.useTemplateRef(n);let o=null,r=null,a=null,c=null,d=null;const u=()=>{const y={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:a,controls:d,renderer:c,scene:r};t("animate",y),o!=null&&(cancelAnimationFrame(o),o=null),s.animation&&(o=requestAnimationFrame(u)),c.render(r,a)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(u)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};T.watch(()=>s.animation,y=>{y==!0?p():f()});const _=()=>{const y=i.value,m=y.clientWidth,g=y.clientHeight,M={antialias:!0,alpha:!1};if(C.ColorManagement.enabled=!1,c=new C.WebGLRenderer(M),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,g),c.setClearColor(8372223,1),c.outputColorSpace=C.SRGBColorSpace,y.appendChild(c.domElement),r=new C.Scene,a=new C.PerspectiveCamera(45,m/g,.1,1e3),a.position.set(0,1.25,1),s.useOrbitControls&&(d=new $e(a,y),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),s.useGridHelper){const x=new C.GridHelper(10,10);r.add(x),x.visible=!0}if(s.useAxesHelper){const x=new C.AxesHelper(5);r.add(x)}if(s.useDefaultLight){const x=new C.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),r.add(x);const N=new C.AmbientLight(4210752);r.add(N)}const w={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:a,controls:d,renderer:c,scene:r};t("init",w)};return T.onMounted(async()=>{if(!ee.isWebGL2Available()){const m=ee.getWebGLErrorMessage();console.error(m);return}const y=()=>{const m=i.value,g=m.clientWidth,M=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(g,M),a.aspect=g/M,a.updateProjectionMatrix()};window.addEventListener("resize",y),_()}),(y,m)=>(T.openBlock(),T.createElementBlock("div",{ref:n,class:"box"}))}},[["__scopeId","data-v-e91ca0ac"]]),ue={__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,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const a=await new E().fetchExpression(o);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},i=o=>{t("loading",s.name,s.command);let r=!1;o&&(r=!0),t("loaded",s.name,s.command,r,o)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,r)=>null}},de={__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,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const a=await new E().fetchPose(o);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},i=o=>{t("loading",s.name,s.command);let r=!1;o&&(r=!0),t("loaded",s.name,s.command,r,o)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,r)=>null}},pe={__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,s=l,n=async r=>{const a=new K;return a.register(c=>new F.VRMLoaderPlugin(c)),await a.loadAsync(r).then(c=>{const d=c.userData.vrm;return F.VRMUtils.rotateVRM0(d),d})},i=async r=>{if(!r)return;t("loading",s.name,s.command);const a=await n(r);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},o=r=>{t("loading",s.name,s.command);let a=!1;r&&(a=!0),t("loaded",s.name,s.command,a,r)};return T.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),T.watch(()=>s.url,()=>{s.url&&i(s.url)}),(r,a)=>null}},fe={__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}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n={},i={},o=T.ref(null),r=T.ref(null),a=T.ref(null),c=(u,p)=>{const f=Object.keys(n).length;n[u]=p;const _=Object.keys(n).length;f==0&&_&&t("loading",s.name)},d=(u,p,f,_)=>{const y=Object.keys(n).length;f&&(p=="load_expression"&&(o.value=_),p=="load_pose"&&(r.value=_),p=="load_vrm"&&(a.value=_),i[u]=p),delete n[u];const m=Object.keys(n).length;if(y&&m==0){const g={};for(const w in i){const x=i[w];x=="load_expression"&&(g.expression=o.value),x=="load_pose"&&(g.pose=r.value),x=="load_vrm"&&(g.vrm=a.value)}t("loaded",s.name,g);const M=Object.keys(i);for(const w of M)delete i[w]}};return(u,p)=>(T.openBlock(),T.createElementBlock(T.Fragment,null,[T.createVNode(ue,{command:"load_expression",name:s.expression_name,url:s.expression_url,data:s.expression_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(de,{command:"load_pose",name:s.pose_name,url:s.pose_url,data:s.pose_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(pe,{command:"load_vrm",name:s.vrm_name,url:s.vrm_url,data:s.vrm_data,onLoading:c,onLoaded:d},null,8,["name","url","data"])],64))}},ut={__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}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=T.ref(null);s.value=new H;const n=o=>{t("loading",o)},i=(o,r)=>{"vrm"in r&&s.value.setModel(r.vrm),"pose"in r&&(s.value.setPose(r.pose),s.value.updatePose()),"expression"in r&&(s.value.importExpression(r.expression),s.value.updateExpression()),t("loaded",o,s.value)};return(o,r)=>(T.openBlock(),T.createBlock(fe,{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,onLoading:n,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=E,A.ThreeFrame=ht,A.VrmModel=H,A.VroidControl=ut,A.VroidExpression=ue,A.VroidModel=fe,A.VroidPose=de,A.VroidVrm=pe,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
1
+ (function(A,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("vue"),require("three"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","vue","three","@pixiv/three-vrm"],T):(A=typeof globalThis<"u"?globalThis:A||self,T(A.VueThreeVrm={},A.Vue,A.THREE,A.THREE_VRM))})(this,function(A,T,h,F){"use strict";var J=document.createElement("style");J.textContent=`.box[data-v-8fb60132]{display:block;width:100%;height:100%}
2
+ /*$vite$:1*/`,document.head.appendChild(J);function me(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const C=me(h);class E{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}async fetchPose(e){const t=await this.fetchJSON(e);return t==null?null:"pose"in t?t.pose:t}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class H{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,s,n){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=s,i.rotation.z=n)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,s,n){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=s,i.position.z=n)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const s in t)e[s]=this.getExpression(s);return e}return null}}class ee{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"),s=window.WebGL2RenderingContext&&t.getContext("webgl2");return s.drawingBufferColorSpace=e,s.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},s={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let n='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",s[e]?n=n.replace("$0","graphics card"):n=n.replace("$0","browser"),n=n.replace("$1",t[e]),i.innerHTML=n,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}function te(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class K extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new De(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Pe(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Oe(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new ke(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const r=function(c){n?n(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},a=new h.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{i.parse(c,o,function(d){t(d),i.manager.itemEnd(e)},r)}catch(d){r(d)}},s,r)}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,s,n){let i;const o={},r={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===se){try{o[b.KHR_BINARY_GLTF]=new ve(e)}catch(u){n&&n(u);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qe(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 d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[u.name]=u,o[u.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const u=i.extensionsUsed[d],p=i.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:o[u]=new ye;break;case b.KHR_DRACO_MESH_COMPRESSION:o[u]=new je(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[u]=new Fe;break;case b.KHR_MESH_QUANTIZATION:o[u]=new Ue;break;default:p.indexOf(u)>=0&&r[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(r),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function _e(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const 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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ge{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 s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const d=new h.Color(16777215);a.color!==void 0&&d.setRGB(a.color[0],a.color[1],a.color[2],h.LinearSRGBColorSpace);const u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new h.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(d),c.distance=u;break;case"spot":c=new h.SpotLight(d),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),R(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return s._getNodeRef(t.cache,r,a)})}}class ye{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new h.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],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(n)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(i)}}class Me{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const r=o.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Pe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Oe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Ne{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class De{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const c=s.options.manager.getHandler(r.uri);c!==null&&(a=c)}return s.loadTextureImage(e,o.source,a)}}class Re{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const c=s.options.manager.getHandler(r.uri);c!==null&&(a=c)}return s.loadTextureImage(e,o.source,a)}}class Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,p=new Uint8Array(r,a,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,p,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,p,n.mode,n.filter),f})})}else return null}}class ke{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,r=[],a={};for(const c in o)r.push(this.parser.getDependency("accessor",o[c]).then(d=>(a[c]=d,a[c])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],p=c[0].count,f=[];for(const _ of u){const y=new h.Matrix4,m=new h.Vector3,g=new h.Quaternion,M=new h.Vector3(1,1,1),w=new h.InstancedMesh(_.geometry,_.material,p);for(let x=0;x<p;x++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,x),a.ROTATION&&g.fromBufferAttribute(a.ROTATION,x),a.SCALE&&M.fromBufferAttribute(a.SCALE,x),w.setMatrixAt(x,y.compose(m,g,M));for(const x in a)if(x==="_COLOR_0"){const N=a[x];w.instanceColor=new h.InstancedBufferAttribute(N.array,N.itemSize,N.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&_.geometry.setAttribute(x,a[x]);h.Object3D.prototype.copy.call(w,_),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const se="glTF",G=12,ne={JSON:1313821514,BIN:5130562};class ve{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,i=new DataView(e,G);let o=0;for(;o<n;){const r=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===ne.JSON){const c=new Uint8Array(e,G+o,r);this.content=s.decode(c)}else if(a===ne.BIN){const c=G+o;this.body=e.slice(c,c+r)}o+=r}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class je{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 s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},c={};for(const d in o){const u=X[d]||d.toLowerCase();r[u]=o[d]}for(const d in e.attributes){const u=X[d]||d.toLowerCase();if(o[d]!==void 0){const p=s.accessors[e.attributes[d]],f=U[p.componentType];c[u]=f.name,a[u]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(u,p){n.decodeDracoFile(d,function(f){for(const _ in f.attributes){const y=f.attributes[_],m=a[_];m!==void 0&&(y.normalized=m)}u(f)},r,c,h.LinearSRGBColorSpace,p)})})}}class Fe{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 Ue{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ie extends h.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,c=r*3,d=n-t,u=(s-t)/d,p=u*u,f=p*u,_=e*c,y=_-c,m=-2*f+3*p,g=f-p,M=1-m,w=g-p+u;for(let x=0;x!==r;x++){const N=o[y+x+r],k=o[y+x+a]*d,D=o[_+x+r],B=o[_+x]*d;i[x]=M*N+w*k+m*D+g*B}return i}}const Ge=new h.Quaternion;class Be extends ie{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ge.fromArray(i).normalize().toArray(i),i}}const O={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},oe={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},re={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={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"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ve={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ee(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function j(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function R(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 Ke(l,e,t){let s=!1,n=!1,i=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(s){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):l.attributes.position;o.push(p)}if(n){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):l.attributes.normal;r.push(p)}if(i){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):l.attributes.color;a.push(p)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(c){const d=c[0],u=c[1],p=c[2];return s&&(l.morphAttributes.position=d),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ze(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xe(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Y(l.targets[s]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function q(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 We(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 Ye=new h.Matrix4;class qe{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _e,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 s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const r=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(r)===!0;const a=r.match(/Version\/(\d+)/);n=s&&a?parseInt(a[1],10):-1,i=r.indexOf("Firefox")>-1,o=i?r.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.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 s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const r={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return j(i,r,n),R(r,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){for(const a of r.scenes)a.updateMatrixWorld();e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[c,d]of o.children.entries())i(d,r.children[c])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(h.LoaderUtils.resolveURL(t.uri,n.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(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=z[n.type],r=U[n.componentType],a=n.normalized===!0,c=new r(n.count*o);return Promise.resolve(new h.BufferAttribute(c,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=z[n.type],c=U[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*a,p=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,_=n.normalized===!0;let y,m;if(f&&f!==u){const g=Math.floor(p/f),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+g+":"+n.count;let w=t.cache.get(M);w||(y=new c(r,g*f,n.count*f/d),w=new h.InterleavedBuffer(y,f/d),t.cache.add(M,w)),m=new h.InterleavedBufferAttribute(w,a,p%f/d,_)}else r===null?y=new c(n.count*a):y=new c(r,p,n.count*a),m=new h.BufferAttribute(y,a,_);if(n.sparse!==void 0){const g=z.SCALAR,M=U[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,N=new M(o[1],w,n.sparse.count*g),k=new c(o[2],x,n.sparse.count*a);r!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let D=0,B=N.length;D<B;D++){const v=N[D];if(m.setX(v,k[D*a]),a>=2&&m.setY(v,k[D*a+1]),a>=3&&m.setZ(v,k[D*a+2]),a>=4&&m.setW(v,k[D*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const p=(i.samplers||{})[o.sampler]||{};return d.magFilter=oe[p.magFilter]||h.LinearFilter,d.minFilter=oe[p.minFilter]||h.LinearMipmapLinearFilter,d.wrapS=re[p.wrapS]||h.RepeatWrapping,d.wrapT=re[p.wrapT]||h.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==h.NearestFilter&&d.minFilter!==h.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",c=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const p=new Blob([u],{type:o.mimeType});return a=r.createObjectURL(p),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(u){return new Promise(function(p,f){let _=p;t.isImageBitmapLoader===!0&&(_=function(y){const m=new h.Texture(y);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(u,i.path),_,void 0,f)})}).then(function(u){return c===!0&&r.revokeObjectURL(a),R(u,o),u.userData.mimeType=o.mimeType||We(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new h.PointsMaterial,h.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(r,a)),s=a}else if(e.isLine){const r="LineBasicMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new h.LineBasicMaterial,h.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(r,a)),s=a}if(n||i||o){let r="ClonedMaterial:"+s.uuid+":";n&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const r={},a=i.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(r,i,t))}else{const u=i.pbrMetallicRoughness||{};if(r.color=new h.Color(1,1,1),r.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;r.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),r.opacity=p[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(r,"map",u.baseColorTexture,h.SRGBColorSpace)),r.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,r.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(r,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(r,"roughnessMap",u.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,r)})))}i.doubleSided===!0&&(r.side=h.DoubleSide);const d=i.alphaMode||W.OPAQUE;if(d===W.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===W.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;r.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const u=i.emissiveFactor;r.emissive=new h.Color().setRGB(u[0],u[1],u[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(r);return i.name&&(u.name=i.name),R(u,i),t.associations.set(u,{materials:e}),i.extensions&&j(n,u,i),u})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(r){return s[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return ae(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const c=e[r],d=Xe(c),u=n[d];if(u)o.push(u.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ae(new h.BufferGeometry,c,t),n[d]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,r=[];for(let a=0,c=o.length;a<c;a++){const d=o[a].material===void 0?Ee(this.cache):this.getDependency("material",o[a].material);r.push(d)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const c=a.slice(0,a.length-1),d=a[a.length-1],u=[];for(let f=0,_=d.length;f<_;f++){const y=d[f],m=o[f];let g;const M=c[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)g=i.isSkinnedMesh===!0?new h.SkinnedMesh(y,M):new h.Mesh(y,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?g.geometry=te(g.geometry,h.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(g.geometry=te(g.geometry,h.TriangleFanDrawMode));else if(m.mode===O.LINES)g=new h.LineSegments(y,M);else if(m.mode===O.LINE_STRIP)g=new h.Line(y,M);else if(m.mode===O.LINE_LOOP)g=new h.LineLoop(y,M);else if(m.mode===O.POINTS)g=new h.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(g.geometry.morphAttributes).length>0&&ze(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),R(g,i),m.extensions&&j(n,g,m),t.assignFinalMaterial(g),u.push(g)}for(let f=0,_=u.length;f<_;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&j(n,u[0],i),u[0];const p=new h.Group;i.extensions&&j(n,p,i),t.associations.set(p,{meshes:e});for(let f=0,_=u.length;f<_;f++)p.add(u[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new h.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),R(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,r=[],a=[];for(let c=0,d=o.length;c<d;c++){const u=o[c];if(u){r.push(u);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),a.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(r,a)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],r=[],a=[],c=[],d=[];for(let u=0,p=n.channels.length;u<p;u++){const f=n.channels[u],_=n.samplers[f.sampler],y=f.target,m=y.node,g=n.parameters!==void 0?n.parameters[_.input]:_.input,M=n.parameters!==void 0?n.parameters[_.output]:_.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),r.push(this.getDependency("accessor",g)),a.push(this.getDependency("accessor",M)),c.push(_),d.push(y))}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(d)]).then(function(u){const p=u[0],f=u[1],_=u[2],y=u[3],m=u[4],g=[];for(let M=0,w=p.length;M<w;M++){const x=p[M],N=f[M],k=_[M],D=y[M],B=m[M];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=s._createAnimationTracks(x,N,k,D,B);if(v)for(let $=0;$<v.length;$++)g.push(v[$])}return new h.AnimationClip(i,void 0,g)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,c=n.weights.length;a<c;a++)r.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],r=n.children||[];for(let c=0,d=r.length;c<d;c++)o.push(s.getDependency("node",r[c]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(c){const d=c[0],u=c[1],p=c[2];p!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ye)});for(let f=0,_=u.length;f<_;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",r=[],a=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){r.push(c)}),this.nodeCache[e]=Promise.all(r).then(function(c){let d;if(i.isBone===!0?d=new h.Bone:c.length>1?d=new h.Group:c.length===1?d=c[0]:d=new h.Object3D,d!==c[0])for(let u=0,p=c.length;u<p;u++)d.add(c[u]);if(i.name&&(d.userData.name=i.name,d.name=o),R(d,i),i.extensions&&j(s,d,i),i.matrix!==void 0){const u=new h.Matrix4;u.fromArray(i.matrix),d.applyMatrix4(u)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new h.Group;s.name&&(i.name=n.createUniqueName(s.name)),R(i,s),s.extensions&&j(t,i,s);const o=s.nodes||[],r=[];for(let a=0,c=o.length;a<c;a++)r.push(n.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let d=0,u=a.length;d<u;d++)i.add(a[d]);const c=d=>{const u=new Map;for(const[p,f]of n.associations)(p instanceof h.Material||p instanceof h.Texture)&&u.set(p,f);return d.traverse(p=>{const f=n.associations.get(p);f!=null&&u.set(p,f)}),u};return n.associations=c(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],r=e.name?e.name:e.uuid,a=[];I[i.path]===I.weights?e.traverse(function(p){p.morphTargetInfluences&&a.push(p.name?p.name:p.uuid)}):a.push(r);let c;switch(I[i.path]){case I.weights:c=h.NumberKeyframeTrack;break;case I.rotation:c=h.QuaternionKeyframeTrack;break;case I.translation:case I.scale:c=h.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?Ve[n.interpolation]:h.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let p=0,f=a.length;p<f;p++){const _=new c(a[p]+"."+I[i.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),o.push(_)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=q(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof h.QuaternionKeyframeTrack?Be:ie;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ze(l,e,t){const s=e.attributes,n=new h.Box3;if(s.POSITION!==void 0){const r=t.json.accessors[s.POSITION],a=r.min,c=r.max;if(a!==void 0&&c!==void 0){if(n.set(new h.Vector3(a[0],a[1],a[2]),new h.Vector3(c[0],c[1],c[2])),r.normalized){const d=q(U[r.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new h.Vector3,a=new h.Vector3;for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,_=p.max;if(f!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),p.normalized){const y=q(U[p.componentType]);a.multiplyScalar(y)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(r)}l.boundingBox=n;const o=new h.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function ae(l,e,t){const s=e.attributes,n=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in s){const r=X[o]||o.toLowerCase();r in l.attributes||n.push(i(s[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});n.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),R(l,e),Ze(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ke(l,e.targets,t):l})}const ce={type:"change"},Z={type:"start"},le={type:"end"},V=new h.Ray,he=new h.Plane,Qe=Math.cos(70*h.MathUtils.DEG2RAD),L=new h.Vector3,P=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},Q=1e-6;class $e extends h.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new h.Vector3,this.cursor=new h.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:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=He.bind(this),this._onPointerDown=Je.bind(this),this._onPointerUp=et.bind(this),this._onContextMenu=at.bind(this),this._onMouseWheel=nt.bind(this),this._onKeyDown=it.bind(this),this._onTouchStart=ot.bind(this),this._onTouchMove=rt.bind(this),this._onMouseDown=tt.bind(this),this._onMouseMove=st.bind(this),this._interceptControlDown=ct.bind(this),this._interceptControlUp=lt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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(ce),this.update(),this.state=S.NONE}update(e=null){const t=this.object.position;L.copy(t).sub(this.target),L.applyQuaternion(this._quat),this._spherical.setFromVector3(L),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 s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,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(L.setFromSpherical(this._spherical),L.applyQuaternion(this._quatInverse),t.copy(this.target).add(L),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 r=L.length();o=this._clampDistance(r*this._scale);const a=r-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const r=new h.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(r),this.object.updateMatrixWorld(),o=L.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):(V.origin.copy(this.object.position),V.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(V.direction))<Qe?this.object.lookAt(this.target):(he.setFromNormalAndCoplanarPoint(this.object.up,this.target),V.intersectPlane(he,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)>Q||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q||this._lastTargetPosition.distanceToSquared(this.target)>Q?(this.dispatchEvent(ce),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/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){L.setFromMatrixColumn(t,0),L.multiplyScalar(-e),this._panOffset.add(L)}_panUp(e,t){this.screenSpacePanning===!0?L.setFromMatrixColumn(t,1):(L.setFromMatrixColumn(t,0),L.crossVectors(this.object.up,L)),L.multiplyScalar(e),this._panOffset.add(L)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;L.copy(n).sub(this.target);let i=L.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.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 s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,r=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/r)*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(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*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(P*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(-P*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(P*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(-P*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);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 s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*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),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}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),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);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,r=(e.pageY+t.y)*.5;this._updateZoomParameters(o,r)}_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 h.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,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Je(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function He(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function et(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(le),this.state=S.NONE;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 h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case h.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 h.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(Z)}function st(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 nt(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(Z),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(le))}function it(l){this.enabled!==!1&&this._handleKeyDown(l)}function ot(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case h.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 h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case h.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(Z)}function rt(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 at(l){this.enabled!==!1&&l.preventDefault()}function ct(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ht=((l,e)=>{const t=l.__vccOpts||l;for(const[s,n]of e)t[s]=n;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},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,s=l,n="dom"+T.getCurrentInstance().uid,i=T.useTemplateRef(n);let o=null,r=null,a=null,c=null,d=null;const u=()=>{const y={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:a,controls:d,renderer:c,scene:r};t("animate",y),o!=null&&(cancelAnimationFrame(o),o=null),s.animation&&(o=requestAnimationFrame(u)),c.render(r,a)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(u)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};T.watch(()=>s.animation,y=>{y==!0?p():f()});const _=()=>{const y=i.value,m=y.clientWidth,g=y.clientHeight,M={antialias:!0,alpha:!1};if(C.ColorManagement.enabled=!1,c=new C.WebGLRenderer(M),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,g),c.setClearColor(8372223,1),c.outputColorSpace=C.SRGBColorSpace,y.appendChild(c.domElement),r=new C.Scene,a=new C.PerspectiveCamera(45,m/g,.1,1e3),a.position.set(0,1.25,1),s.useOrbitControls&&(d=new $e(a,y),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),s.useGridHelper){const x=new C.GridHelper(10,10);r.add(x),x.visible=!0}if(s.useAxesHelper){const x=new C.AxesHelper(5);r.add(x)}if(s.useDefaultLight){const x=new C.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),r.add(x);const N=new C.AmbientLight(4210752);r.add(N)}const w={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:a,controls:d,renderer:c,scene:r};t("initialized",w)};return T.onMounted(async()=>{if(!ee.isWebGL2Available()){const m=ee.getWebGLErrorMessage();console.error(m);return}const y=()=>{const m=i.value,g=m.clientWidth,M=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(g,M),a.aspect=g/M,a.updateProjectionMatrix()};window.addEventListener("resize",y),_()}),(y,m)=>(T.openBlock(),T.createElementBlock("div",{ref:n,class:"box"}))}},[["__scopeId","data-v-8fb60132"]]),ue={__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,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const a=await new E().fetchExpression(o);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},i=o=>{t("loading",s.name,s.command);let r=!1;o&&(r=!0),t("loaded",s.name,s.command,r,o)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,r)=>null}},de={__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,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const a=await new E().fetchPose(o);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},i=o=>{t("loading",s.name,s.command);let r=!1;o&&(r=!0),t("loaded",s.name,s.command,r,o)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,r)=>null}},pe={__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,s=l,n=async r=>{const a=new K;return a.register(c=>new F.VRMLoaderPlugin(c)),await a.loadAsync(r).then(c=>{const d=c.userData.vrm;return F.VRMUtils.rotateVRM0(d),d})},i=async r=>{if(!r)return;t("loading",s.name,s.command);const a=await n(r);let c=!1;a&&(c=!0),t("loaded",s.name,s.command,c,a)},o=r=>{t("loading",s.name,s.command);let a=!1;r&&(a=!0),t("loaded",s.name,s.command,a,r)};return T.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),T.watch(()=>s.url,()=>{s.url&&i(s.url)}),(r,a)=>null}},fe={__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}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n={},i={},o=T.ref(null),r=T.ref(null),a=T.ref(null),c=(u,p)=>{const f=Object.keys(n).length;n[u]=p;const _=Object.keys(n).length;f==0&&_&&t("loading",s.name)},d=(u,p,f,_)=>{const y=Object.keys(n).length;f&&(p=="load_expression"&&(o.value=_),p=="load_pose"&&(r.value=_),p=="load_vrm"&&(a.value=_),i[u]=p),delete n[u];const m=Object.keys(n).length;if(y&&m==0){const g={};for(const w in i){const x=i[w];x=="load_expression"&&(g.expression=o.value),x=="load_pose"&&(g.pose=r.value),x=="load_vrm"&&(g.vrm=a.value)}t("loaded",s.name,g);const M=Object.keys(i);for(const w of M)delete i[w]}};return(u,p)=>(T.openBlock(),T.createElementBlock(T.Fragment,null,[T.createVNode(ue,{command:"load_expression",name:s.expression_name,url:s.expression_url,data:s.expression_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(de,{command:"load_pose",name:s.pose_name,url:s.pose_url,data:s.pose_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(pe,{command:"load_vrm",name:s.vrm_name,url:s.vrm_url,data:s.vrm_data,onLoading:c,onLoaded:d},null,8,["name","url","data"])],64))}},ut={__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}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=T.ref(null);s.value=new H;const n=o=>{t("loading",o)},i=(o,r)=>{"vrm"in r&&s.value.setModel(r.vrm),"pose"in r&&(s.value.setPose(r.pose),s.value.updatePose()),"expression"in r&&(s.value.importExpression(r.expression),s.value.updateExpression()),t("loaded",o,s.value)};return(o,r)=>(T.openBlock(),T.createBlock(fe,{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,onLoading:n,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=E,A.ThreeFrame=ht,A.VrmModel=H,A.VroidControl=ut,A.VroidExpression=ue,A.VroidModel=fe,A.VroidPose=de,A.VroidVrm=pe,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j-kyoda/vue-three-vrm",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A Vue 3 component designed to render and display VRM models on your web pages.",
5
5
  "type": "module",
6
6
  "private": false,