@pixiv/three-vrm 3.5.4 → 3.5.5

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.
@@ -934,7 +934,7 @@ void main() {
934
934
  `)+`
935
935
  `;n.vertexShader=r+n.vertexShader,n.fragmentShader=r+n.fragmentShader,i<154&&(n.fragmentShader=n.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>"))}}get color(){return this.uniforms.litFactor.value}set color(t){this.uniforms.litFactor.value=t}get map(){return this.uniforms.map.value}set map(t){this.uniforms.map.value=t}get normalMap(){return this.uniforms.normalMap.value}set normalMap(t){this.uniforms.normalMap.value=t}get normalScale(){return this.uniforms.normalScale.value}set normalScale(t){this.uniforms.normalScale.value=t}get emissive(){return this.uniforms.emissive.value}set emissive(t){this.uniforms.emissive.value=t}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(t){this.uniforms.emissiveIntensity.value=t}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(t){this.uniforms.emissiveMap.value=t}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(t){this.uniforms.shadeColorFactor.value=t}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(t){this.uniforms.shadeMultiplyTexture.value=t}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(t){this.uniforms.shadingShiftFactor.value=t}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(t){this.uniforms.shadingShiftTexture.value=t}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(t){this.uniforms.shadingShiftTextureScale.value=t}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(t){this.uniforms.shadingToonyFactor.value=t}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(t){this.uniforms.giEqualizationFactor.value=t}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(t){this.uniforms.matcapFactor.value=t}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(t){this.uniforms.matcapTexture.value=t}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(t){this.uniforms.parametricRimColorFactor.value=t}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(t){this.uniforms.rimMultiplyTexture.value=t}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(t){this.uniforms.rimLightingMixFactor.value=t}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(t){this.uniforms.parametricRimFresnelPowerFactor.value=t}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(t){this.uniforms.parametricRimLiftFactor.value=t}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(t){this.uniforms.outlineWidthMultiplyTexture.value=t}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(t){this.uniforms.outlineWidthFactor.value=t}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(t){this.uniforms.outlineColorFactor.value=t}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(t){this.uniforms.outlineLightingMixFactor.value=t}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(t){this.uniforms.uvAnimationMaskTexture.value=t}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(t){this.uniforms.uvAnimationScrollXOffset.value=t}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(t){this.uniforms.uvAnimationScrollYOffset.value=t}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(t){this.uniforms.uvAnimationRotationPhase.value=t}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(t){this._ignoreVertexColor=t,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(t){this._v0CompatShade=t,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(t){this._debugMode=t,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(t){this._outlineWidthMode=t,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(t){this._isOutline=t,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(t){this._uploadUniformsWorkaround(),this._updateUVAnimation(t)}copy(t){return super.copy(t),this.map=t.map,this.normalMap=t.normalMap,this.emissiveMap=t.emissiveMap,this.shadeMultiplyTexture=t.shadeMultiplyTexture,this.shadingShiftTexture=t.shadingShiftTexture,this.matcapTexture=t.matcapTexture,this.rimMultiplyTexture=t.rimMultiplyTexture,this.outlineWidthMultiplyTexture=t.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=t.uvAnimationMaskTexture,this.normalMapType=t.normalMapType,this.uvAnimationScrollXSpeedFactor=t.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=t.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=t.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=t.ignoreVertexColor,this.v0CompatShade=t.v0CompatShade,this.debugMode=t.debugMode,this.outlineWidthMode=t.outlineWidthMode,this.isOutline=t.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(t){this.uniforms.uvAnimationScrollXOffset.value+=t*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=t*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=t*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){let t=parseInt(S.REVISION,10),e=this.outlineWidthMultiplyTexture!==null,n=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:t,OUTLINE:this._isOutline,MTOON_USE_UV:e||n,MTOON_UVS_VERTEX_ONLY:e&&!n,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===Bt.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},Eo=new Set(["1.0","1.0-beta"]),Mi=class nt{get name(){return nt.EXTENSION_NAME}constructor(e,n={}){var i,r,o,s;this.parser=e,this.materialType=(i=n.materialType)!=null?i:Ei,this.renderOrderOffset=(r=n.renderOrderOffset)!=null?r:0,this.v0CompatShade=(o=n.v0CompatShade)!=null?o:!1,this.debugMode=(s=n.debugMode)!=null?s:"none",this._mToonMaterialSet=new Set}beforeRoot(){return ue(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return ue(this,null,function*(){e.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(e){return this._getMToonExtension(e)?this.materialType:null}extendMaterialParams(e,n){let i=this._getMToonExtension(e);return i?this._extendMaterialParams(i,n):null}loadMesh(e){return ue(this,null,function*(){var n;let i=this.parser,o=(n=i.json.meshes)==null?void 0:n[e];if(o==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);let s=o.primitives,l=yield i.loadMesh(e);if(s.length===1){let a=l,u=s[0].material;u!=null&&this._setupPrimitive(a,u)}else{let a=l;for(let u=0;u<s.length;u++){let d=a.children[u],h=s[u].material;h!=null&&this._setupPrimitive(d,h)}}return l})}_removeUnlitExtensionIfMToonExists(){let i=this.parser.json.materials;i==null||i.map((r,o)=>{var s;this._getMToonExtension(o)&&((s=r.extensions)!=null&&s.KHR_materials_unlit)&&delete r.extensions.KHR_materials_unlit})}_getMToonExtension(e){var n,i;let s=(n=this.parser.json.materials)==null?void 0:n[e];if(s==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=s.extensions)==null?void 0:i[nt.EXTENSION_NAME];if(l==null)return;let a=l.specVersion;if(!Eo.has(a)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${nt.EXTENSION_NAME} specVersion "${a}"`);return}return l}_extendMaterialParams(e,n){return ue(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new mo(this.parser,n);r.assignPrimitive("transparentWithZWrite",e.transparentWithZWrite),r.assignColor("shadeColorFactor",e.shadeColorFactor),r.assignTexture("shadeMultiplyTexture",e.shadeMultiplyTexture,!0),r.assignPrimitive("shadingShiftFactor",e.shadingShiftFactor),r.assignTexture("shadingShiftTexture",e.shadingShiftTexture,!0),r.assignPrimitive("shadingShiftTextureScale",(i=e.shadingShiftTexture)==null?void 0:i.scale),r.assignPrimitive("shadingToonyFactor",e.shadingToonyFactor),r.assignPrimitive("giEqualizationFactor",e.giEqualizationFactor),r.assignColor("matcapFactor",e.matcapFactor),r.assignTexture("matcapTexture",e.matcapTexture,!0),r.assignColor("parametricRimColorFactor",e.parametricRimColorFactor),r.assignTexture("rimMultiplyTexture",e.rimMultiplyTexture,!0),r.assignPrimitive("rimLightingMixFactor",e.rimLightingMixFactor),r.assignPrimitive("parametricRimFresnelPowerFactor",e.parametricRimFresnelPowerFactor),r.assignPrimitive("parametricRimLiftFactor",e.parametricRimLiftFactor),r.assignPrimitive("outlineWidthMode",e.outlineWidthMode),r.assignPrimitive("outlineWidthFactor",e.outlineWidthFactor),r.assignTexture("outlineWidthMultiplyTexture",e.outlineWidthMultiplyTexture,!1),r.assignColor("outlineColorFactor",e.outlineColorFactor),r.assignPrimitive("outlineLightingMixFactor",e.outlineLightingMixFactor),r.assignTexture("uvAnimationMaskTexture",e.uvAnimationMaskTexture,!1),r.assignPrimitive("uvAnimationScrollXSpeedFactor",e.uvAnimationScrollXSpeedFactor),r.assignPrimitive("uvAnimationScrollYSpeedFactor",e.uvAnimationScrollYSpeedFactor),r.assignPrimitive("uvAnimationRotationSpeedFactor",e.uvAnimationRotationSpeedFactor),r.assignPrimitive("v0CompatShade",this.v0CompatShade),r.assignPrimitive("debugMode",this.debugMode),yield r.pending})}_setupPrimitive(e,n){let i=this._getMToonExtension(n);if(i){let r=this._parseRenderOrder(i);e.renderOrder=r+this.renderOrderOffset,this._generateOutline(e),this._addToMaterialSet(e);return}}_shouldGenerateOutline(e){return typeof e.outlineWidthMode=="string"&&e.outlineWidthMode!=="none"&&typeof e.outlineWidthFactor=="number"&&e.outlineWidthFactor>0}_generateOutline(e){let n=e.material;if(!(n instanceof it.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=it.BackSide,e.material.push(i);let r=e.geometry,o=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,o,0),r.addGroup(0,o,1)}_addToMaterialSet(e){let n=e.material,i=new Set;Array.isArray(n)?n.forEach(r=>i.add(r)):i.add(n);for(let r of i)this._mToonMaterialSet.add(r)}_parseRenderOrder(e){var n;return(e.transparentWithZWrite?0:19)+((n=e.renderQueueOffsetNumber)!=null?n:0)}};Mi.EXTENSION_NAME="VRMC_materials_mtoon";var Nt=Mi;var Mo=(t,e,n)=>new Promise((i,r)=>{var o=a=>{try{l(n.next(a))}catch(u){r(u)}},s=a=>{try{l(n.throw(a))}catch(u){r(u)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,s);l((n=n.apply(t,e)).next())}),Ri=class Dt{get name(){return Dt.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return Mo(this,null,function*(){let i=this._getHDREmissiveMultiplierExtension(e);if(i==null)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");let r=i.emissiveMultiplier;n.emissiveIntensity=r})}_getHDREmissiveMultiplierExtension(e){var n,i;let s=(n=this.parser.json.materials)==null?void 0:n[e];if(s==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=s.extensions)==null?void 0:i[Dt.EXTENSION_NAME];if(l!=null)return l}};Ri.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var Ti=Ri;var Si=v(require("three"),1);var Ro=Object.defineProperty,To=Object.defineProperties,xo=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertySymbols,yo=Object.prototype.hasOwnProperty,wo=Object.prototype.propertyIsEnumerable,yi=(t,e,n)=>e in t?Ro(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,z=(t,e)=>{for(var n in e||(e={}))yo.call(e,n)&&yi(t,n,e[n]);if(xi)for(var n of xi(e))wo.call(e,n)&&yi(t,n,e[n]);return t},wi=(t,e)=>To(t,xo(e)),So=(t,e,n)=>new Promise((i,r)=>{var o=a=>{try{l(n.next(a))}catch(u){r(u)}},s=a=>{try{l(n.throw(a))}catch(u){r(u)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,s);l((n=n.apply(t,e)).next())});function Ee(t){return Math.pow(t,2.2)}var Ai=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(t){var e;this.parser=t,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;let n=this.parser.json;n.extensionsUsed=(e=n.extensionsUsed)!=null?e:[],n.extensionsUsed.indexOf("KHR_texture_transform")===-1&&n.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return So(this,null,function*(){var t;let e=this.parser.json,n=(t=e.extensions)==null?void 0:t.VRM,i=n==null?void 0:n.materialProperties;i&&(this._populateRenderQueueMap(i),i.forEach((r,o)=>{var s,l;let a=(s=e.materials)==null?void 0:s[o];if(a==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${o}] of glTF but the material doesn't exist`);return}if(r.shader==="VRM/MToon"){let u=this._parseV0MToonProperties(r,a);e.materials[o]=u}else if((l=r.shader)!=null&&l.startsWith("VRM/Unlit")){let u=this._parseV0UnlitProperties(r,a);e.materials[o]=u}else r.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${r.shader}`)}))})}_parseV0MToonProperties(t,e){var n,i,r,o,s,l,a,u,d,h,c,p,f,m,g,_,R,x,T,E,M,y,A,I,P,H,C,J,we,Se,Q,W,pe,Ae,U,Jt,Kt,en,tn,nn,rn,on,sn,an,ln,un,dn,hn,cn,pn,fn,mn,gn,_n,vn;let En=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,Ki=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&En,er=this._v0ParseRenderQueue(t),Mn=(s=(o=t.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?s:!1,tr=En?"BLEND":Mn?"MASK":"OPAQUE",nr=Mn?(a=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?a:.5:void 0,ir=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,se=this._portTextureTransform(t),rr=((c=(h=t.vectorProperties)==null?void 0:h._Color)!=null?c:[1,1,1,1]).map((bn,Pr)=>Pr===3?bn:Ee(bn)),Rn=(p=t.textureProperties)==null?void 0:p._MainTex,or=Rn!=null?{index:Rn,extensions:z({},se)}:void 0,sr=(m=(f=t.floatProperties)==null?void 0:f._BumpScale)!=null?m:1,Tn=(g=t.textureProperties)==null?void 0:g._BumpMap,ar=Tn!=null?{index:Tn,scale:sr,extensions:z({},se)}:void 0,lr=((R=(_=t.vectorProperties)==null?void 0:_._EmissionColor)!=null?R:[0,0,0,1]).map(Ee),xn=(x=t.textureProperties)==null?void 0:x._EmissionMap,ur=xn!=null?{index:xn,extensions:z({},se)}:void 0,dr=((E=(T=t.vectorProperties)==null?void 0:T._ShadeColor)!=null?E:[.97,.81,.86,1]).map(Ee),yn=(M=t.textureProperties)==null?void 0:M._ShadeTexture,hr=yn!=null?{index:yn,extensions:z({},se)}:void 0,De=(A=(y=t.floatProperties)==null?void 0:y._ShadeShift)!=null?A:0,Fe=(P=(I=t.floatProperties)==null?void 0:I._ShadeToony)!=null?P:.9;Fe=Si.MathUtils.lerp(Fe,1,.5+.5*De),De=-De-(1-Fe);let wn=(C=(H=t.floatProperties)==null?void 0:H._IndirectLightIntensity)!=null?C:.1,cr=wn?1-wn:void 0,_t=(J=t.textureProperties)==null?void 0:J._SphereAdd,pr=_t!=null?[1,1,1]:void 0,fr=_t!=null?{index:_t}:void 0,mr=(Se=(we=t.floatProperties)==null?void 0:we._RimLightingMix)!=null?Se:0,Sn=(Q=t.textureProperties)==null?void 0:Q._RimTexture,gr=Sn!=null?{index:Sn,extensions:z({},se)}:void 0,_r=((pe=(W=t.vectorProperties)==null?void 0:W._RimColor)!=null?pe:[0,0,0,1]).map(Ee),vr=(U=(Ae=t.floatProperties)==null?void 0:Ae._RimFresnelPower)!=null?U:1,Er=(Kt=(Jt=t.floatProperties)==null?void 0:Jt._RimLift)!=null?Kt:0,Mr=["none","worldCoordinates","screenCoordinates"][(tn=(en=t.floatProperties)==null?void 0:en._OutlineWidthMode)!=null?tn:0],vt=(rn=(nn=t.floatProperties)==null?void 0:nn._OutlineWidth)!=null?rn:0;vt=.01*vt;let An=(on=t.textureProperties)==null?void 0:on._OutlineWidthTexture,Rr=An!=null?{index:An,extensions:z({},se)}:void 0,Tr=((an=(sn=t.vectorProperties)==null?void 0:sn._OutlineColor)!=null?an:[0,0,0]).map(Ee),xr=((un=(ln=t.floatProperties)==null?void 0:ln._OutlineColorMode)!=null?un:0)===1?(hn=(dn=t.floatProperties)==null?void 0:dn._OutlineLightingMix)!=null?hn:1:0,Pn=(cn=t.textureProperties)==null?void 0:cn._UvAnimMaskTexture,yr=Pn!=null?{index:Pn,extensions:z({},se)}:void 0,wr=(fn=(pn=t.floatProperties)==null?void 0:pn._UvAnimScrollX)!=null?fn:0,ke=(gn=(mn=t.floatProperties)==null?void 0:mn._UvAnimScrollY)!=null?gn:0;ke!=null&&(ke=-ke);let Sr=(vn=(_n=t.floatProperties)==null?void 0:_n._UvAnimRotation)!=null?vn:0,Ar={specVersion:"1.0",transparentWithZWrite:Ki,renderQueueOffsetNumber:er,shadeColorFactor:dr,shadeMultiplyTexture:hr,shadingShiftFactor:De,shadingToonyFactor:Fe,giEqualizationFactor:cr,matcapFactor:pr,matcapTexture:fr,rimLightingMixFactor:mr,rimMultiplyTexture:gr,parametricRimColorFactor:_r,parametricRimFresnelPowerFactor:vr,parametricRimLiftFactor:Er,outlineWidthMode:Mr,outlineWidthFactor:vt,outlineWidthMultiplyTexture:Rr,outlineColorFactor:Tr,outlineLightingMixFactor:xr,uvAnimationMaskTexture:yr,uvAnimationScrollXSpeedFactor:wr,uvAnimationScrollYSpeedFactor:ke,uvAnimationRotationSpeedFactor:Sr};return wi(z({},e),{pbrMetallicRoughness:{baseColorFactor:rr,baseColorTexture:or},normalTexture:ar,emissiveTexture:ur,emissiveFactor:lr,alphaMode:tr,alphaCutoff:nr,doubleSided:ir,extensions:{VRMC_materials_mtoon:Ar}})}_parseV0UnlitProperties(t,e){var n,i,r,o,s;let l=t.shader==="VRM/UnlitTransparentZWrite",a=t.shader==="VRM/UnlitTransparent"||l,u=this._v0ParseRenderQueue(t),d=t.shader==="VRM/UnlitCutout",h=a?"BLEND":d?"MASK":"OPAQUE",c=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,p=this._portTextureTransform(t),f=((o=(r=t.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(Ee),m=(s=t.textureProperties)==null?void 0:s._MainTex,g=m!=null?{index:m,extensions:z({},p)}:void 0,_={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:f,shadeMultiplyTexture:g};return wi(z({},e),{pbrMetallicRoughness:{baseColorFactor:f,baseColorTexture:g},alphaMode:h,alphaCutoff:c,extensions:{VRMC_materials_mtoon:_}})}_portTextureTransform(t){var e,n,i,r,o;let s=(e=t.vectorProperties)==null?void 0:e._MainTex;if(s==null)return{};let l=[(n=s==null?void 0:s[0])!=null?n:0,(i=s==null?void 0:s[1])!=null?i:0],a=[(r=s==null?void 0:s[2])!=null?r:1,(o=s==null?void 0:s[3])!=null?o:1];return l[1]=1-a[1]-l[1],{KHR_texture_transform:{offset:l,scale:a}}}_v0ParseRenderQueue(t){var e,n;let i=t.shader==="VRM/UnlitTransparentZWrite",r=((e=t.keywordMap)==null?void 0:e._ALPHABLEND_ON)!=null||t.shader==="VRM/UnlitTransparent"||i,o=((n=t.floatProperties)==null?void 0:n._ZWrite)===1||i,s=0;if(r){let l=t.renderQueue;l!=null&&(o?s=this._renderQueueMapTransparentZWrite.get(l):s=this._renderQueueMapTransparent.get(l))}return s}_populateRenderQueueMap(t){let e=new Set,n=new Set;t.forEach(i=>{var r,o;let s=i.shader==="VRM/UnlitTransparentZWrite",l=((r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null||i.shader==="VRM/UnlitTransparent"||s,a=((o=i.floatProperties)==null?void 0:o._ZWrite)===1||s;if(l){let u=i.renderQueue;u!=null&&(a?n.add(u):e.add(u))}}),e.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${e.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),n.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${n.size} render queues for TransparentZWrite materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),Array.from(e).sort().forEach((i,r)=>{let o=Math.min(Math.max(r-e.size+1,-9),0);this._renderQueueMapTransparent.set(i,o)}),Array.from(n).sort().forEach((i,r)=>{let o=Math.min(Math.max(r,0),9);this._renderQueueMapTransparentZWrite.set(i,o)})}};var B=v(require("three"),1),j=v(require("three"),1),Ft=v(require("three"),1),Ve=v(require("three"),1),q=v(require("three"),1);var Pi=(t,e,n)=>new Promise((i,r)=>{var o=a=>{try{l(n.next(a))}catch(u){r(u)}},s=a=>{try{l(n.throw(a))}catch(u){r(u)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,s);l((n=n.apply(t,e)).next())}),te=new B.Vector3,rt=class extends B.Group{constructor(t){super(),this._attrPosition=new B.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(B.DynamicDrawUsage);let e=new B.BufferGeometry;e.setAttribute("position",this._attrPosition);let n=new B.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new B.Line(e,n),this.add(this._line),this.constraint=t}updateMatrixWorld(t){te.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,te.x,te.y,te.z),this.constraint.source&&te.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,te.x,te.y,te.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};function bi(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var Ao=new Ft.Vector3,Po=new Ft.Vector3;function bo(t,e){return t.decompose(Ao,e,Po),e}function ot(t){return t.invert?t.invert():t.inverse(),t}var st=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},Ho=new j.Vector3,Lo=new j.Vector3,Io=new j.Vector3,Vo=new j.Quaternion,Co=new j.Quaternion,Oo=new j.Quaternion,Hi=class extends st{get aimAxis(){return this._aimAxis}set aimAxis(t){this._aimAxis=t,this._v3AimAxis.set(t==="PositiveX"?1:t==="NegativeX"?-1:0,t==="PositiveY"?1:t==="NegativeY"?-1:0,t==="PositiveZ"?1:t==="NegativeZ"?-1:0)}get dependencies(){let t=new Set([this.source]);return this.destination.parent&&t.add(this.destination.parent),t}constructor(t,e){super(t,e),this._aimAxis="PositiveX",this._v3AimAxis=new j.Vector3(1,0,0),this._dstRestQuat=new j.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=Vo.identity(),e=Co.identity();this.destination.parent&&(bo(this.destination.parent.matrixWorld,t),ot(e.copy(t)));let n=Ho.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=bi(this.source.matrixWorld,Lo).sub(bi(this.destination.matrixWorld,Io)).normalize(),r=Oo.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function Uo(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var Li=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(t){this._constraints.add(t);let e=this._objectConstraintsMap.get(t.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(t.destination,e)),e.add(t)}deleteConstraint(t){this._constraints.delete(t),this._objectConstraintsMap.get(t.destination).delete(t)}setInitState(){let t=new Set,e=new Set;for(let n of this._constraints)this._processConstraint(n,t,e,i=>i.setInitState())}update(){let t=new Set,e=new Set;for(let n of this._constraints)this._processConstraint(n,t,e,i=>i.update())}_processConstraint(t,e,n,i){if(n.has(t))return;if(e.has(t))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(t);let r=t.dependencies;for(let o of r)Uo(o,s=>{let l=this._objectConstraintsMap.get(s);if(l)for(let a of l)this._processConstraint(a,e,n,i)});i(t),n.add(t)}},Bo=new Ve.Quaternion,No=new Ve.Quaternion,Ii=class extends st{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new Ve.Quaternion,this._invSrcRestQuat=new Ve.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),ot(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=Bo.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=No.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},Do=new q.Vector3,Fo=new q.Quaternion,ko=new q.Quaternion,Vi=class extends st{get rollAxis(){return this._rollAxis}set rollAxis(t){this._rollAxis=t,this._v3RollAxis.set(t==="X"?1:0,t==="Y"?1:0,t==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._rollAxis="X",this._v3RollAxis=new q.Vector3(1,0,0),this._dstRestQuat=new q.Quaternion,this._invDstRestQuat=new q.Quaternion,this._invSrcRestQuatMulDstRestQuat=new q.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),ot(this._invDstRestQuat.copy(this._dstRestQuat)),ot(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=Fo.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=Do.copy(this._v3RollAxis).applyQuaternion(t),i=ko.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},Wo=new Set(["1.0","1.0-beta"]),Ci=class Ie{get name(){return Ie.EXTENSION_NAME}constructor(e,n){this.parser=e,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(e){return Pi(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return Pi(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(Ie.EXTENSION_NAME))!==-1))return null;let o=new Li,s=yield this.parser.getDependencies("node");return s.forEach((l,a)=>{var u;let d=i.nodes[a],h=(u=d==null?void 0:d.extensions)==null?void 0:u[Ie.EXTENSION_NAME];if(h==null)return;let c=h.specVersion;if(!Wo.has(c)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Ie.EXTENSION_NAME} specVersion "${c}"`);return}let p=h.constraint;if(p.roll!=null){let f=this._importRollConstraint(l,s,p.roll);o.addConstraint(f)}else if(p.aim!=null){let f=this._importAimConstraint(l,s,p.aim);o.addConstraint(f)}else if(p.rotation!=null){let f=this._importRotationConstraint(l,s,p.rotation);o.addConstraint(f)}}),e.scene.updateMatrixWorld(),o.setInitState(),o})}_importRollConstraint(e,n,i){let{source:r,rollAxis:o,weight:s}=i,l=n[r],a=new Vi(e,l);if(o!=null&&(a.rollAxis=o),s!=null&&(a.weight=s),this.helperRoot){let u=new rt(a);this.helperRoot.add(u)}return a}_importAimConstraint(e,n,i){let{source:r,aimAxis:o,weight:s}=i,l=n[r],a=new Hi(e,l);if(o!=null&&(a.aimAxis=o),s!=null&&(a.weight=s),this.helperRoot){let u=new rt(a);this.helperRoot.add(u)}return a}_importRotationConstraint(e,n,i){let{source:r,weight:o}=i,s=n[r],l=new Ii(e,s);if(o!=null&&(l.weight=o),this.helperRoot){let a=new rt(l);this.helperRoot.add(a)}return l}};Ci.EXTENSION_NAME="VRMC_node_constraint";var kt=Ci;var ie=v(require("three"),1),Be=v(require("three"),1),Te=v(require("three"),1),qt=v(require("three"),1),$=v(require("three"),1),ne=v(require("three"),1),he=v(require("three"),1),re=v(require("three"),1),ce=v(require("three"),1),ht=v(require("three"),1),O=v(require("three"),1),Ni=v(require("three"),1),Di=v(require("three"),1),D=v(require("three"),1);var at=(t,e,n)=>new Promise((i,r)=>{var o=a=>{try{l(n.next(a))}catch(u){r(u)}},s=a=>{try{l(n.throw(a))}catch(u){r(u)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,s);l((n=n.apply(t,e)).next())}),dt=class{},Wt=new Be.Vector3,de=new Be.Vector3,Qt=class extends dt{get type(){return"capsule"}constructor(t){var e,n,i,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Be.Vector3(0,0,0),this.tail=(n=t==null?void 0:t.tail)!=null?n:new Be.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0,this.inside=(r=t==null?void 0:t.inside)!=null?r:!1}calculateCollision(t,e,n,i){Wt.setFromMatrixPosition(t),de.subVectors(this.tail,this.offset).applyMatrix4(t),de.sub(Wt);let r=de.lengthSq();i.copy(e).sub(Wt);let o=de.dot(i);o<=0||(r<=o||de.multiplyScalar(o/r),i.sub(de));let s=i.length(),l=this.inside?this.radius-n-s:s-n-this.radius;return l<0&&(i.multiplyScalar(1/s),this.inside&&i.negate()),l}},Gt=new Te.Vector3,Oi=new Te.Matrix3,Yt=class extends dt{get type(){return"plane"}constructor(t){var e,n;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Te.Vector3(0,0,0),this.normal=(n=t==null?void 0:t.normal)!=null?n:new Te.Vector3(0,0,1)}calculateCollision(t,e,n,i){i.setFromMatrixPosition(t),i.negate().add(e),Oi.getNormalMatrix(t),Gt.copy(this.normal).applyNormalMatrix(Oi).normalize();let r=i.dot(Gt)-n;return i.copy(Gt),r}},Go=new qt.Vector3,$t=class extends dt{get type(){return"sphere"}constructor(t){var e,n,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new qt.Vector3(0,0,0),this.radius=(n=t==null?void 0:t.radius)!=null?n:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,n,i){i.subVectors(e,Go.setFromMatrixPosition(t));let r=i.length(),o=this.inside?this.radius-n-r:r-n-this.radius;return o<0&&(i.multiplyScalar(1/r),this.inside&&i.negate()),o}},X=new $.Vector3,zo=class extends $.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new $.Vector3,this._currentTail=new $.Vector3,this._shape=t,this._attrPos=new $.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new $.BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1,e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,t=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),t=!0);let n=X.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),t=!0),t&&this._buildPosition()}_buildPosition(){X.copy(this._currentTail).sub(this._currentOffset);let t=X.length()/this._currentRadius;for(let i=0;i<=16;i++){let r=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(r),-Math.cos(r),0),this._attrPos.setXYZ(17+i,t+Math.sin(r),Math.cos(r),0),this._attrPos.setXYZ(34+i,-Math.sin(r),0,-Math.cos(r)),this._attrPos.setXYZ(51+i,t+Math.sin(r),0,Math.cos(r))}for(let i=0;i<32;i++){let r=i/16*Math.PI;this._attrPos.setXYZ(68+i,0,Math.sin(r),Math.cos(r)),this._attrPos.setXYZ(100+i,t,Math.sin(r),Math.cos(r))}let e=Math.atan2(X.y,Math.sqrt(X.x*X.x+X.z*X.z)),n=-Math.atan2(X.z,X.x);this.rotateZ(e),this.rotateY(n),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let t=0;t<34;t++){let e=(t+1)%34;this._attrIndex.setXY(t*2,t,e),this._attrIndex.setXY(68+t*2,34+t,34+e)}for(let t=0;t<32;t++){let e=(t+1)%32;this._attrIndex.setXY(136+t*2,68+t,68+e),this._attrIndex.setXY(200+t*2,100+t,100+e)}this._attrIndex.needsUpdate=!0}},jo=class extends ne.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentOffset=new ne.Vector3,this._currentNormal=new ne.Vector3,this._shape=t,this._attrPos=new ne.BufferAttribute(new Float32Array(18),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ne.BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),t=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),t=!0),t&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}},Xo=class extends he.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new he.Vector3,this._shape=t,this._attrPos=new he.BufferAttribute(new Float32Array(288),3),this.setAttribute("position",this._attrPos),this._attrIndex=new he.BufferAttribute(new Uint16Array(192),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1,e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,t=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),t=!0),t&&this._buildPosition()}_buildPosition(){for(let t=0;t<32;t++){let e=t/16*Math.PI;this._attrPos.setXYZ(t,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+t,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+t,Math.sin(e),0,Math.cos(e))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let t=0;t<32;t++){let e=(t+1)%32;this._attrIndex.setXY(t*2,t,e),this._attrIndex.setXY(64+t*2,32+t,32+e),this._attrIndex.setXY(128+t*2,64+t,64+e)}this._attrIndex.needsUpdate=!0}},Qo=new ie.Vector3,lt=class extends ie.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof $t)this._geometry=new Xo(this.collider.shape);else if(this.collider.shape instanceof Qt)this._geometry=new zo(this.collider.shape);else if(this.collider.shape instanceof Yt)this._geometry=new jo(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new ie.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new ie.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=Qo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},Yo=class extends ce.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new ce.Vector3,this._springBone=t,this._attrPos=new ce.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ce.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1,e=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,t=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),t=!0),t&&this._buildPosition()}_buildPosition(){for(let t=0;t<32;t++){let e=t/16*Math.PI;this._attrPos.setXYZ(t,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+t,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+t,Math.sin(e),0,Math.cos(e))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let t=0;t<32;t++){let e=(t+1)%32;this._attrIndex.setXY(t*2,t,e),this._attrIndex.setXY(64+t*2,32+t,32+e),this._attrIndex.setXY(128+t*2,64+t,64+e)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},qo=new re.Vector3,Bi=class extends re.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new Yo(this.springBone);let e=new re.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new re.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=qo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},ut=class extends ht.Object3D{constructor(t){super(),this.colliderMatrix=new ht.Matrix4,this.shape=t}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),$o(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function $o(t,e,n){let i=e.elements;t.copy(e),n&&(t.elements[12]=i[0]*n.x+i[4]*n.y+i[8]*n.z+i[12],t.elements[13]=i[1]*n.x+i[5]*n.y+i[9]*n.z+i[13],t.elements[14]=i[2]*n.x+i[6]*n.y+i[10]*n.z+i[14])}var Zo=new Di.Matrix4;function Jo(t){return t.invert?t.invert():t.getInverse(Zo.copy(t)),t}var Ko=class{constructor(t){this._inverseCache=new Ni.Matrix4,this._shouldUpdateInverse=!0,this.matrix=t;let e={set:(n,i,r)=>(this._shouldUpdateInverse=!0,n[i]=r,!0)};this._originalElements=t.elements,t.elements=new Proxy(t.elements,e)}get inverse(){return this._shouldUpdateInverse&&(Jo(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},zt=new O.Matrix4,Me=new O.Vector3,Ce=new O.Vector3,Oe=new O.Vector3,Ue=new O.Vector3,es=new O.Matrix4,Fi=class{constructor(t,e,n={},i=[]){this._currentTail=new O.Vector3,this._prevTail=new O.Vector3,this._boneAxis=new O.Vector3,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new O.Matrix4,this._initialLocalRotation=new O.Quaternion,this._initialLocalChildPosition=new O.Vector3;var r,o,s,l,a,u;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(r=n.hitRadius)!=null?r:0,stiffness:(o=n.stiffness)!=null?o:1,gravityPower:(s=n.gravityPower)!=null?s:0,gravityDir:(a=(l=n.gravityDir)==null?void 0:l.clone())!=null?a:new O.Vector3(0,-1,0),dragForce:(u=n.dragForce)!=null?u:.4},this.colliderGroups=i}get dependencies(){let t=new Set,e=this.bone.parent;e&&t.add(e);for(let n=0;n<this.colliderGroups.length;n++)for(let i=0;i<this.colliderGroups[n].colliders.length;i++)t.add(this.colliderGroups[n].colliders[i]);return t}get center(){return this._center}set center(t){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=t,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new Ko(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:zt}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength();let e=Ce.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);Ue.copy(this._currentTail).add(Me.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*t).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*t),Oe.setFromMatrixPosition(this.bone.matrixWorld),Ue.sub(Oe).normalize().multiplyScalar(this._worldSpaceBoneLength).add(Oe),this._collision(Ue),this._prevTail.copy(this._currentTail),this._currentTail.copy(Ue).applyMatrix4(this._getMatrixWorldToCenter());let n=es.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Me.copy(Ue).applyMatrix4(n).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let n=0;n<this.colliderGroups[e].colliders.length;n++){let i=this.colliderGroups[e].colliders[n],r=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,Me);if(r<0){t.addScaledVector(Me,-r),t.sub(Oe);let o=t.length();t.multiplyScalar(this._worldSpaceBoneLength/o).add(Oe)}}}_calcWorldSpaceBoneLength(){Me.setFromMatrixPosition(this.bone.matrixWorld),this.child?Ce.setFromMatrixPosition(this.child.matrixWorld):(Ce.copy(this._initialLocalChildPosition),Ce.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Me.sub(Ce).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:zt}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:zt}};function ts(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function jt(t,e){t.children.forEach(n=>{e(n)||jt(n,e)})}function ns(t){var e;let n=new Map;for(let i of t){let r=i;do{let o=((e=n.get(r))!=null?e:0)+1;if(o===t.size)return r;n.set(r,o),r=r.parent}while(r!==null)}return null}var Xt=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let t=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(n=>{t.add(n)})}),Array.from(t)}get colliders(){let t=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(n=>{t.add(n)})}),Array.from(t)}addJoint(t){this._joints.add(t);let e=this._objectSpringBonesMap.get(t.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(t.bone,e)),e.add(t),this._isSortedJointsDirty=!0}addSpringBone(t){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(t)}deleteJoint(t){this._joints.delete(t),this._objectSpringBonesMap.get(t.bone).delete(t),this._isSortedJointsDirty=!0}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(t){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){let n=this._sortedJoints[e];n.bone.updateMatrix(),n.bone.updateWorldMatrix(!1,!1),n.update(t),jt(n.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;let t=[],e=new Set,n=new Set,i=new Set;for(let o of this._joints)this._insertJointSort(o,e,n,t,i);this._sortedJoints=t;let r=ns(i);this._ancestors=[],r&&(this._ancestors.push(r),jt(r,o=>{var s,l;return((l=(s=this._objectSpringBonesMap.get(o))==null?void 0:s.size)!=null?l:0)>0?!0:(this._ancestors.push(o),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(t,e,n,i,r){if(n.has(t))return;if(e.has(t)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(t);let o=t.dependencies;for(let s of o){let l=!1,a=null;ts(s,u=>{let d=this._objectSpringBonesMap.get(u);if(d)for(let h of d)l=!0,this._insertJointSort(h,e,n,i,r);else l||(a=u)}),a&&r.add(a)}i.push(t),n.add(t)}_relevantChildrenUpdated(t){var e,n;return((n=(e=this._objectSpringBonesMap.get(t))==null?void 0:e.size)!=null?n:0)>0?!0:(t.updateWorldMatrix(!1,!1),!1)}},Ui="VRMC_springBone_extended_collider",is=new Set(["1.0","1.0-beta"]),rs=new Set(["1.0"]),ki=class Re{get name(){return Re.EXTENSION_NAME}constructor(e,n){var i;this.parser=e,this.jointHelperRoot=n==null?void 0:n.jointHelperRoot,this.colliderHelperRoot=n==null?void 0:n.colliderHelperRoot,this.useExtendedColliders=(i=n==null?void 0:n.useExtendedColliders)!=null?i:!0}afterRoot(e){return at(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return at(this,null,function*(){let n=yield this._v1Import(e);if(n!=null)return n;let i=yield this._v0Import(e);return i!=null?i:null})}_v1Import(e){return at(this,null,function*(){var n,i,r,o,s;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(Re.EXTENSION_NAME))!==-1))return null;let u=new Xt,d=yield e.parser.getDependencies("node"),h=(i=l.extensions)==null?void 0:i[Re.EXTENSION_NAME];if(!h)return null;let c=h.specVersion;if(!is.has(c))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Re.EXTENSION_NAME} specVersion "${c}"`),null;let p=(r=h.colliders)==null?void 0:r.map((m,g)=>{var _,R,x,T,E,M,y,A,I,P,H,C,J,we,Se;let Q=d[m.node];if(Q==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${g} attempted to reference a node #${m.node} but not found. Skipping the collider`),null;let W=m.shape,pe=(_=m.extensions)==null?void 0:_[Ui];if(this.useExtendedColliders&&pe!=null){let Ae=pe.specVersion;if(!rs.has(Ae))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ui} specVersion "${Ae}". Fallbacking to the ${Re.EXTENSION_NAME} definition`);else{let U=pe.shape;if(U.sphere)return this._importSphereCollider(Q,{offset:new D.Vector3().fromArray((R=U.sphere.offset)!=null?R:[0,0,0]),radius:(x=U.sphere.radius)!=null?x:0,inside:(T=U.sphere.inside)!=null?T:!1});if(U.capsule)return this._importCapsuleCollider(Q,{offset:new D.Vector3().fromArray((E=U.capsule.offset)!=null?E:[0,0,0]),radius:(M=U.capsule.radius)!=null?M:0,tail:new D.Vector3().fromArray((y=U.capsule.tail)!=null?y:[0,0,0]),inside:(A=U.capsule.inside)!=null?A:!1});if(U.plane)return this._importPlaneCollider(Q,{offset:new D.Vector3().fromArray((I=U.plane.offset)!=null?I:[0,0,0]),normal:new D.Vector3().fromArray((P=U.plane.normal)!=null?P:[0,0,1])})}}if(W.sphere)return this._importSphereCollider(Q,{offset:new D.Vector3().fromArray((H=W.sphere.offset)!=null?H:[0,0,0]),radius:(C=W.sphere.radius)!=null?C:0,inside:!1});if(W.capsule)return this._importCapsuleCollider(Q,{offset:new D.Vector3().fromArray((J=W.capsule.offset)!=null?J:[0,0,0]),radius:(we=W.capsule.radius)!=null?we:0,tail:new D.Vector3().fromArray((Se=W.capsule.tail)!=null?Se:[0,0,0]),inside:!1});console.warn(`VRMSpringBoneLoaderPlugin: The collider #${g} has no valid shape. Skipping the collider`)}),f=(o=h.colliderGroups)==null?void 0:o.map((m,g)=>{var _;return{colliders:((_=m.colliders)!=null?_:[]).map(x=>{let T=p==null?void 0:p[x];return T==null?(console.warn(`VRMSpringBoneLoaderPlugin: The collider group #${g} attempted to reference a collider #${x} but not found. Skipping the collider`),null):T}).filter(x=>x!=null),name:m.name}});return(s=h.springs)==null||s.forEach((m,g)=>{var _;let R=m.joints,x=(_=m.colliderGroups)==null?void 0:_.map(M=>{let y=f==null?void 0:f[M];return y==null?(console.warn(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to reference a collider group #${M} but not found. Skipping the collider group`),null):y}).filter(M=>M!=null),T=m.center!=null?d[m.center]:void 0,E;R.forEach(M=>{if(E){let y=E.node,A=d[y],I=M.node,P=d[I],H={hitRadius:E.hitRadius,dragForce:E.dragForce,gravityPower:E.gravityPower,stiffness:E.stiffness,gravityDir:E.gravityDir!=null?new D.Vector3().fromArray(E.gravityDir):void 0},C=this._importJoint(A,P,H,x);T&&(C.center=T),u.addJoint(C)}E=M})}),u.setInitState(),u})}_v0Import(e){return at(this,null,function*(){var n,i,r;let o=e.parser.json;if(!(((n=o.extensionsUsed)==null?void 0:n.indexOf("VRM"))!==-1))return null;let l=(i=o.extensions)==null?void 0:i.VRM,a=l==null?void 0:l.secondaryAnimation;if(!a)return null;let u=a==null?void 0:a.boneGroups;if(!u)return null;let d=new Xt,h=yield e.parser.getDependencies("node"),c=(r=a.colliderGroups)==null?void 0:r.map((p,f)=>{var m;let g=h[p.node];return g==null?(console.warn(`VRMSpringBoneLoaderPlugin: The collider group #${f} attempted to reference a node #${p.node} but not found. Skipping the collider group`),null):{colliders:((m=p.colliders)!=null?m:[]).map((R,x)=>{var T,E,M;let y=new D.Vector3(0,0,0);return R.offset&&y.set((T=R.offset.x)!=null?T:0,(E=R.offset.y)!=null?E:0,R.offset.z?-R.offset.z:0),this._importSphereCollider(g,{offset:y,radius:(M=R.radius)!=null?M:0,inside:!1})})}});return u==null||u.forEach((p,f)=>{let m=p.bones;m&&m.forEach(g=>{var _,R,x,T;let E=h[g];if(E==null){console.warn(`VRMSpringBoneLoaderPlugin: The spring bone group #${f} attempted to reference a node #${g} but not found. Skipping the node`);return}let M=new D.Vector3;p.gravityDir?M.set((_=p.gravityDir.x)!=null?_:0,(R=p.gravityDir.y)!=null?R:0,(x=p.gravityDir.z)!=null?x:0):M.set(0,-1,0);let y=p.center!=null?h[p.center]:void 0,A={hitRadius:p.hitRadius,dragForce:p.dragForce,gravityPower:p.gravityPower,stiffness:p.stiffiness,gravityDir:M},I=(T=p.colliderGroups)==null?void 0:T.map(P=>{let H=c==null?void 0:c[P];return H==null?(console.warn(`VRMSpringBoneLoaderPlugin: The spring #${f} attempted to reference a collider group #${P} but not found. Skipping the collider group`),null):H}).filter(P=>P!=null);E.traverse(P=>{var H;let C=(H=P.children[0])!=null?H:null,J=this._importJoint(P,C,A,I);y&&(J.center=y),d.addJoint(J)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let o=new Fi(e,n,i,r);if(this.jointHelperRoot){let s=new Bi(o);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(e,n){let i=new $t(n),r=new ut(i);if(e.add(r),this.colliderHelperRoot){let o=new lt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,n){let i=new Qt(n),r=new ut(i);if(e.add(r),this.colliderHelperRoot){let o=new lt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,n){let i=new Yt(n),r=new ut(i);if(e.add(r),this.colliderHelperRoot){let o=new lt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}};ki.EXTENSION_NAME="VRMC_springBone";var Zt=ki;var ct=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var o,s,l,a,u,d,h,c,p,f;this.parser=e;let i=n==null?void 0:n.helperRoot,r=n==null?void 0:n.autoUpdateHumanBones;this.expressionPlugin=(o=n==null?void 0:n.expressionPlugin)!=null?o:new qe(e),this.firstPersonPlugin=(s=n==null?void 0:n.firstPersonPlugin)!=null?s:new $e(e),this.humanoidPlugin=(l=n==null?void 0:n.humanoidPlugin)!=null?l:new Je(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(a=n==null?void 0:n.lookAtPlugin)!=null?a:new Ke(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new et(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new Nt(e),this.materialsHDREmissiveMultiplierPlugin=(h=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?h:new Ti(e),this.materialsV0CompatPlugin=(c=n==null?void 0:n.materialsV0CompatPlugin)!=null?c:new Ai(e),this.springBonePlugin=(p=n==null?void 0:n.springBonePlugin)!=null?p:new Zt(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(f=n==null?void 0:n.nodeConstraintPlugin)!=null?f:new kt(e,{helperRoot:i})}beforeRoot(){return Pe(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return Pe(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)})}getMaterialType(e){let n=this.mtoonMaterialPlugin.getMaterialType(e);return n!=null?n:null}extendMaterialParams(e,n){return Pe(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,n),yield this.mtoonMaterialPlugin.extendMaterialParams(e,n)})}afterRoot(e){return Pe(this,null,function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);let n=e.userData.vrmMeta,i=e.userData.vrmHumanoid;if(n&&i){let r=new ve({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:i,lookAt:e.userData.vrmLookAt,meta:n,materials:e.userData.vrmMToonMaterials,springBoneManager:e.userData.vrmSpringBoneManager,nodeConstraintManager:e.userData.vrmNodeConstraintManager});e.userData.vrm=r}})}};var Gi=v(require("three"),1);function os(t){let e=new Set;return t.traverse(n=>{if(!n.isMesh)return;let i=n;e.add(i)}),e}function Wi(t,e,n){if(e.size===1){let s=e.values().next().value;if(s.weight===1)return t[s.index]}let i=new Float32Array(t[0].count*3),r=0;if(n)r=1;else for(let s of e)r+=s.weight;for(let s of e){let l=t[s.index],a=s.weight/r;for(let u=0;u<l.count;u++)i[u*3+0]+=l.getX(u)*a,i[u*3+1]+=l.getY(u)*a,i[u*3+2]+=l.getZ(u)*a}return new Gi.BufferAttribute(i,3)}function zi(t){var r;let e=os(t.scene),n=new Map,i=(r=t.expressionManager)==null?void 0:r.expressionMap;if(i!=null)for(let[o,s]of Object.entries(i)){let l=new Set;for(let a of s.binds)if(a instanceof _e){if(a.weight!==0)for(let u of a.primitives){let d=n.get(u);d==null&&(d=new Map,n.set(u,d));let h=d.get(o);h==null&&(h=new Set,d.set(o,h)),h.add(a)}l.add(a)}for(let a of l)s.deleteBind(a)}for(let o of e){let s=n.get(o);if(s==null)continue;let l=o.geometry.morphAttributes;o.geometry.morphAttributes={};let a=o.geometry.clone();o.geometry=a;let u=a.morphTargetsRelative,d=l.position!=null,h=l.normal!=null,c={},p={},f=[];if(d||h){d&&(c.position=[]),h&&(c.normal=[]);let m=0;for(let[g,_]of s)d&&(c.position[m]=Wi(l.position,_,u)),h&&(c.normal[m]=Wi(l.normal,_,u)),i==null||i[g].addBind(new _e({index:m,weight:1,primitives:[o]})),p[g]=m,f.push(0),m++}a.morphAttributes=c,o.morphTargetDictionary=p,o.morphTargetInfluences=f}}var ye=v(require("three"),1);var ji=v(require("three"),1);function xe(t,e,n){if(t.getComponent)return t.getComponent(e,n);{let i=t.array[e*t.itemSize+n];return t.normalized&&(i=ji.MathUtils.denormalize(i,t.array)),i}}var Xi=v(require("three"),1);function pt(t,e,n,i){t.setComponent?t.setComponent(e,n,i):(t.normalized&&(i=Xi.MathUtils.normalize(i,t.array)),t.array[e*t.itemSize+n]=i)}function Qi(t){var d;let e=ss(t),n=new Set;for(let h of e)n.has(h.geometry)&&(h.geometry=cs(h.geometry)),n.add(h.geometry);let i=new Map;for(let h of n){let c=h.getAttribute("skinIndex"),p=(d=i.get(c))!=null?d:new Map;i.set(c,p);let f=h.getAttribute("skinWeight"),m=as(c,f);p.set(f,m)}let r=new Map;for(let h of e){let c=ls(h,i);r.set(h,c)}let o=[];for(let[h,c]of r){let p=!1;for(let f of o)if(us(c,f.boneInverseMap)){p=!0,f.meshes.add(h);for(let[g,_]of c)f.boneInverseMap.set(g,_);break}p||o.push({boneInverseMap:c,meshes:new Set([h])})}let s=new Map,l=new Ne,a=new Ne,u=new Ne;for(let h of o){let{boneInverseMap:c,meshes:p}=h,f=Array.from(c.keys()),m=Array.from(c.values()),g=new ye.Skeleton(f,m),_=a.getOrCreate(g);for(let R of p){let x=R.geometry.getAttribute("skinIndex"),T=l.getOrCreate(x),E=R.skeleton.bones,M=E.map(I=>u.getOrCreate(I)).join(","),y=`${T};${_};${M}`,A=s.get(y);A==null&&(A=x.clone(),ds(A,E,f),s.set(y,A)),R.geometry.setAttribute("skinIndex",A)}for(let R of p)R.bind(g,new ye.Matrix4)}}function ss(t){let e=new Set;return t.traverse(n=>{if(!n.isSkinnedMesh)return;let i=n;e.add(i)}),e}function as(t,e){let n=new Set;for(let i=0;i<t.count;i++)for(let r=0;r<t.itemSize;r++){let o=xe(t,i,r);xe(e,i,r)!==0&&n.add(o)}return n}function ls(t,e){let n=new Map,i=t.skeleton,r=t.geometry,o=r.getAttribute("skinIndex"),s=r.getAttribute("skinWeight"),l=e.get(o),a=l==null?void 0:l.get(s);if(!a)throw new Error("Unreachable. attributeUsedIndexSetMap does not know the skin index attribute or the skin weight attribute.");for(let u of a)n.set(i.bones[u],i.boneInverses[u]);return n}function us(t,e){for(let[n,i]of t.entries()){let r=e.get(n);if(r!=null&&!hs(i,r))return!1}return!0}function ds(t,e,n){let i=new Map;for(let o of e)i.set(o,i.size);let r=new Map;for(let[o,s]of n.entries()){let l=i.get(s);r.set(l,o)}for(let o=0;o<t.count;o++)for(let s=0;s<t.itemSize;s++){let l=xe(t,o,s),a=r.get(l);pt(t,o,s,a)}t.needsUpdate=!0}function hs(t,e,n){if(n=n||1e-4,t.elements.length!=e.elements.length)return!1;for(let i=0,r=t.elements.length;i<r;i++)if(Math.abs(t.elements[i]-e.elements[i])>n)return!1;return!0}var Ne=class{constructor(){this._objectIndexMap=new Map;this._index=0}get(e){return this._objectIndexMap.get(e)}getOrCreate(e){let n=this._objectIndexMap.get(e);return n==null&&(n=this._index,this._objectIndexMap.set(e,n),this._index++),n}};function cs(t){var n,i,r,o;let e=new ye.BufferGeometry;e.name=t.name,e.setIndex(t.index);for(let[s,l]of Object.entries(t.attributes))e.setAttribute(s,l);for(let[s,l]of Object.entries(t.morphAttributes)){let a=s;e.morphAttributes[a]=l.concat()}e.morphTargetsRelative=t.morphTargetsRelative,e.groups=[];for(let s of t.groups)e.addGroup(s.start,s.count,s.materialIndex);return e.boundingSphere=(i=(n=t.boundingSphere)==null?void 0:n.clone())!=null?i:null,e.boundingBox=(o=(r=t.boundingBox)==null?void 0:r.clone())!=null?o:null,e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e}function Yi(t){if(Object.values(t).forEach(e=>{e!=null&&e.isTexture&&e.dispose()}),t.isShaderMaterial){let e=t.uniforms;e&&Object.values(e).forEach(n=>{let i=n.value;i!=null&&i.isTexture&&i.dispose()})}t.dispose()}function ps(t){let e=t.geometry;e&&e.dispose();let n=t.skeleton;n&&n.dispose();let i=t.material;i&&(Array.isArray(i)?i.forEach(r=>Yi(r)):i&&Yi(i))}function qi(t){t.traverse(ps)}var ft=v(require("three"),1);function $i(t,e){var s,l;console.warn("VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.");let n=(s=e==null?void 0:e.experimentalSameBoneCounts)!=null?s:!1,i=[];t.traverse(a=>{a.type==="SkinnedMesh"&&i.push(a)});let r=new Map,o=0;for(let a of i){let d=a.geometry.getAttribute("skinIndex");if(r.has(d))continue;let h=new Map,c=new Map;for(let p=0;p<d.count;p++)for(let f=0;f<d.itemSize;f++){let m=xe(d,p,f),g=h.get(m);g==null&&(g=h.size,h.set(m,g),c.set(g,m)),pt(d,p,f,g)}d.needsUpdate=!0,r.set(d,c),o=Math.max(o,h.size)}for(let a of i){let d=a.geometry.getAttribute("skinIndex"),h=r.get(d),c=[],p=[],f=n?o:h.size;for(let g=0;g<f;g++){let _=(l=h.get(g))!=null?l:0;c.push(a.skeleton.bones[_]),p.push(a.skeleton.boneInverses[_])}let m=new ft.Skeleton(c,p);a.bind(m,new ft.Matrix4)}}var oe=v(require("three"),1),gt=require("three");function fs(t,e){let n=t.position.count,i=new Array(n),r=0,o=e.array;for(let s=0;s<o.length;s++){let l=o[s];i[l]||(i[l]=!0,r++)}return{isVertexUsed:i,vertexCount:n,verticesUsed:r}}function ms(t){let e=[],n=[],i=0;for(let r=0;r<t.length;r++)if(t[r]){let o=i++;e[r]=o,n[o]=r}return{originalIndexNewIndexMap:e,newIndexOriginalIndexMap:n}}function gs(t,e){var n,i,r,o;e.name=t.name,e.morphTargetsRelative=t.morphTargetsRelative,t.groups.forEach(s=>{e.addGroup(s.start,s.count,s.materialIndex)}),e.boundingBox=(i=(n=t.boundingBox)==null?void 0:n.clone())!=null?i:null,e.boundingSphere=(o=(r=t.boundingSphere)==null?void 0:r.clone())!=null?o:null,e.setDrawRange(t.drawRange.start,t.drawRange.count),e.userData=t.userData}function _s(t,e,n){let i=e.array,r=new i.constructor(i.length);for(let o=0;o<i.length;o++){let s=i[o];r[o]=n[s]}t.setIndex(new gt.BufferAttribute(r,e.itemSize,e.normalized))}function mt(t,e,n){let i=t.constructor,r=new i(e.length*n),o=!0;for(let s=0;s<e.length;s++){let a=e[s]*n,u=s*n;for(let d=0;d<n;d++){let h=t[a+d];r[u+d]=h,o=o&&h===0}}return[r,o]}function vs(t){var i;let e=new Map,n=[];for(let[r,o]of Object.entries(t))if(o.isInterleavedBufferAttribute){let s=o,l=s.data,a=(i=e.get(l))!=null?i:[];e.set(l,a),a.push([r,s])}else{let s=o;n.push([r,s])}return[e,n]}function Es(t,e,n){let[i,r]=vs(e);for(let[o,s]of i){let l=o.array,{stride:a}=o,[u,d]=mt(l,n,a),h=new oe.InterleavedBuffer(u,a);h.setUsage(o.usage);for(let[c,p]of s){let{itemSize:f,offset:m,normalized:g}=p,_=new oe.InterleavedBufferAttribute(h,f,m,g);t.setAttribute(c,_)}}for(let[o,s]of r){let l=s.array,{itemSize:a,normalized:u}=s,[d,h]=mt(l,n,a);t.setAttribute(o,new gt.BufferAttribute(d,a,u))}}function Ms(t){var i;let e=new Map,n=[];for(let[r,o]of Object.entries(t)){let s=r;for(let l=0;l<o.length;l++){let a=o[l];if(a.isInterleavedBufferAttribute){let u=a,d=u.data,h=(i=e.get(d))!=null?i:[];e.set(d,h),h.push([s,l,u])}else{let u=a;n.push([s,l,u])}}}return[e,n]}function Rs(t,e,n){var l,a;let i=!0,[r,o]=Ms(e),s={};for(let[u,d]of r){let h=u.array,{stride:c}=u,[p,f]=mt(h,n,c);i=i&&f;let m=new oe.InterleavedBuffer(p,c);m.setUsage(u.usage);for(let[g,_,R]of d){let{itemSize:x,offset:T,normalized:E}=R,M=new oe.InterleavedBufferAttribute(m,x,T,E);(l=s[g])!=null||(s[g]=[]),s[g][_]=M}}for(let[u,d,h]of o){let c=h,p=c.array,{itemSize:f,normalized:m}=c,[g,_]=mt(p,n,f);i=i&&_,(a=s[u])!=null||(s[u]=[]),s[u][d]=new gt.BufferAttribute(g,f,m)}t.morphAttributes=i?{}:s}function Zi(t){let e=new Map;t.traverse(n=>{if(!n.isMesh)return;let i=n,r=i.geometry,o=r.index;if(o==null)return;let s=e.get(r);if(s!=null){i.geometry=s;return}let{isVertexUsed:l,vertexCount:a,verticesUsed:u}=fs(r.attributes,o);if(u===a)return;let{originalIndexNewIndexMap:d,newIndexOriginalIndexMap:h}=ms(l),c=new oe.BufferGeometry;gs(r,c),e.set(r,c),_s(c,o,d),Es(c,r.attributes,h),Rs(c,r.morphAttributes,h),i.geometry=c}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function Ji(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var Z=class{constructor(){}};Z.combineMorphs=zi,Z.combineSkeletons=Qi,Z.deepDispose=qi,Z.removeUnnecessaryJoints=$i,Z.removeUnnecessaryVertices=Zi,Z.rotateVRM0=Ji;
936
936
  /*!
937
- * @pixiv/three-vrm-core v3.5.4
937
+ * @pixiv/three-vrm-core v3.5.5
938
938
  * The implementation of core features of VRM, for @pixiv/three-vrm
939
939
  *
940
940
  * Copyright (c) 2019-2026 pixiv Inc.
@@ -942,7 +942,7 @@ void main() {
942
942
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
943
943
  */
944
944
  /*!
945
- * @pixiv/three-vrm-materials-mtoon v3.5.4
945
+ * @pixiv/three-vrm-materials-mtoon v3.5.5
946
946
  * MToon (toon material) module for @pixiv/three-vrm
947
947
  *
948
948
  * Copyright (c) 2019-2026 pixiv Inc.
@@ -950,7 +950,7 @@ void main() {
950
950
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
951
951
  */
952
952
  /*!
953
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.5.4
953
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.5.5
954
954
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
955
955
  *
956
956
  * Copyright (c) 2019-2026 pixiv Inc.
@@ -958,7 +958,7 @@ void main() {
958
958
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
959
959
  */
960
960
  /*!
961
- * @pixiv/three-vrm-materials-v0compat v3.5.4
961
+ * @pixiv/three-vrm-materials-v0compat v3.5.5
962
962
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
963
963
  *
964
964
  * Copyright (c) 2019-2026 pixiv Inc.
@@ -966,7 +966,7 @@ void main() {
966
966
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
967
967
  */
968
968
  /*!
969
- * @pixiv/three-vrm-node-constraint v3.5.4
969
+ * @pixiv/three-vrm-node-constraint v3.5.5
970
970
  * Node constraint module for @pixiv/three-vrm
971
971
  *
972
972
  * Copyright (c) 2019-2026 pixiv Inc.
@@ -974,7 +974,7 @@ void main() {
974
974
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
975
975
  */
976
976
  /*!
977
- * @pixiv/three-vrm-springbone v3.5.4
977
+ * @pixiv/three-vrm-springbone v3.5.5
978
978
  * Spring bone module for @pixiv/three-vrm
979
979
  *
980
980
  * Copyright (c) 2019-2026 pixiv Inc.