@pixiv/three-vrm 3.3.5 → 3.3.6

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
@@ -10,9 +10,9 @@ Use [VRM](https://vrm.dev/) on [three.js](https://threejs.org/)
10
10
 
11
11
  [Examples](https://pixiv.github.io/three-vrm/packages/three-vrm/examples)
12
12
 
13
- [Documentations](https://github.com/pixiv/three-vrm/tree/dev/docs/README.md)
13
+ [Guides](https://github.com/pixiv/three-vrm/tree/dev/guides)
14
14
 
15
- [API Reference](https://pixiv.github.io/three-vrm/packages/three-vrm/docs)
15
+ [API Reference](https://pixiv.github.io/three-vrm/docs/modules/three-vrm)
16
16
 
17
17
  ## How to Use
18
18
 
@@ -138,8 +138,8 @@ See the example for the complete code: https://github.com/pixiv/three-vrm/blob/r
138
138
 
139
139
  ## Contributing
140
140
 
141
- See: [CONTRIBUTING.md](CONTRIBUTING.md)
141
+ See: [CONTRIBUTING.md](../../CONTRIBUTING.md)
142
142
 
143
143
  ## LICENSE
144
144
 
145
- [MIT](LICENSE)
145
+ [MIT](../../LICENSE)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm v3.3.5
2
+ * @pixiv/three-vrm v3.3.6
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -522,7 +522,7 @@ var MToonNodeMaterial = class extends THREE8.NodeMaterial {
522
522
  }
523
523
  };
524
524
  /*!
525
- * @pixiv/three-vrm-materials-mtoon v3.3.5
525
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
526
526
  * MToon (toon material) module for @pixiv/three-vrm
527
527
  *
528
528
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,7 +1,7 @@
1
1
  /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
2
  "use strict";var B=Object.create;var v=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var o in e)v(t,o,{get:e[o],enumerable:!0})},O=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of K(e))!Z.call(t,l)&&l!==o&&v(t,l,{get:()=>e[l],enumerable:!(r=q(e,l))||r.enumerable});return t};var h=(t,e,o)=>(o=t!=null?B(j(t)):{},O(e||!t||!t.__esModule?v(o,"default",{value:t,enumerable:!0}):o,t)),G=t=>O(v({},"__esModule",{value:!0}),t);var Ct={};$(Ct,{MToonAnimatedUVNode:()=>D,MToonLightingModel:()=>z,MToonNodeMaterial:()=>yt});module.exports=G(Ct);var b=h(require("three"),1),s=h(require("three/webgpu"),1),a=h(require("three/webgpu"),1),n=h(require("three/webgpu"),1),u=h(require("three/webgpu"),1),E=h(require("three/webgpu"),1),i=h(require("three/webgpu"),1),p=h(require("three/webgpu"),1);var W=parseInt(b.REVISION,10);W<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${W}). This would not work correctly.`);var J=a.materialReference("color","color"),Q=a.materialReference("map","texture"),tt=a.materialReference("normalMap","texture"),et=a.materialReference("normalScale","vec2"),it=a.materialReference("emissive","color"),ot=a.materialReference("emissiveIntensity","float"),rt=a.materialReference("emissiveMap","texture"),at=a.materialReference("shadeColorFactor","color"),lt=a.materialReference("shadingShiftFactor","float"),U=a.materialReference("shadeMultiplyTexture","texture"),nt=a.materialReference("shadeMultiplyTextureScale","float"),st=a.materialReference("shadingToonyFactor","float"),ut=a.materialReference("rimLightingMixFactor","float"),mt=a.materialReference("rimMultiplyTexture","texture"),ht=a.materialReference("matcapFactor","color"),dt=a.materialReference("matcapTexture","texture"),ct=a.materialReference("parametricRimColorFactor","color"),Et=a.materialReference("parametricRimLiftFactor","float"),pt=a.materialReference("parametricRimFresnelPowerFactor","float"),Rt=a.materialReference("outlineWidthMultiplyTexture","texture"),ft=a.materialReference("outlineWidthFactor","float"),I=a.materialReference("outlineColorFactor","color"),Tt=a.materialReference("outlineLightingMixFactor","float"),vt=a.materialReference("uvAnimationMaskTexture","texture"),Nt=a.materialReference("uvAnimationScrollXOffset","float"),gt=a.materialReference("uvAnimationScrollYOffset","float"),Ht=a.materialReference("uvAnimationRotationPhase","float"),D=class extends s.TempNode{constructor(t){super("vec2"),this.hasMaskTexture=t}setup(){let t=1;this.hasMaskTexture&&(t=s.vec4(vt).context({getUV:()=>s.uv()}).r);let e=s.uv(),o=Ht.mul(t),r=s.cos(o),l=s.sin(o);e=e.sub(s.vec2(.5,.5)),e=e.mul(s.mat2(r,l,l.negate(),r)),e=e.add(s.vec2(.5,.5));let m=s.vec2(Nt,gt).mul(t);return e=e.add(m),e.toVar("AnimatedUV")}},k=u.nodeImmutable(u.PropertyNode,"vec3").toVar("ShadeColor"),Y=u.nodeImmutable(u.PropertyNode,"float").toVar("ShadingShift"),X=u.nodeImmutable(u.PropertyNode,"float").toVar("ShadingToony"),g=u.nodeImmutable(u.PropertyNode,"float").toVar("RimLightingMix"),H=u.nodeImmutable(u.PropertyNode,"vec3").toVar("RimMultiply"),M=u.nodeImmutable(u.PropertyNode,"vec3").toVar("matcap"),x=u.nodeImmutable(u.PropertyNode,"vec3").toVar("ParametricRim"),N=t=>parseInt(E.REVISION,10)>=168?E.Fn(t):E.tslFn(t),Mt=N(({a:t,b:e,t:o})=>{let r=o.sub(t),l=e.sub(t);return r.div(l).clamp()}),xt=N(({dotNL:t})=>{let o=n.float(1).sub(X),r=t.add(Y);return r=Mt({a:o.negate(),b:o,t:r}),r=r.mul(1),r}),St=N(({shading:t,lightColor:e})=>{let o=n.mix(k,n.diffuseColor,t);return e.mul(n.BRDF_Lambert({diffuseColor:o}))}),z=class extends n.LightingModel{constructor(){super()}direct({lightDirection:t,lightColor:e,reflectedLight:o}){let r=n.transformedNormalView.dot(t).clamp(-1,1),l=xt({dotNL:r});o.directDiffuse.assign(o.directDiffuse.add(St({shading:l,lightColor:e}))),o.directSpecular.assign(o.directSpecular.add(x.add(M).mul(H).mul(n.mix(n.vec3(0),n.BRDF_Lambert({diffuseColor:e}),g))))}indirect(t){this.indirectDiffuse(t),this.indirectSpecular(t)}indirectDiffuse({irradiance:t,reflectedLight:e}){e.indirectDiffuse.assign(e.indirectDiffuse.add(t.mul(n.BRDF_Lambert({diffuseColor:n.diffuseColor}))))}indirectSpecular({reflectedLight:t}){t.indirectSpecular.assign(t.indirectSpecular.add(x.add(M).mul(H).mul(n.mix(n.vec3(1),n.vec3(0),g))))}},f={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},Ft=N(({parametricRimLift:t,parametricRimFresnelPower:e,parametricRimColor:o})=>{let r=p.modelViewPosition.normalize(),l=p.transformedNormalView.dot(r.negate());return p.float(1).sub(l).add(t).clamp().pow(e).mul(o)}),yt=class extends i.NodeMaterial{customProgramCacheKey(){let t=super.customProgramCacheKey();return t+=`isOutline:${this.isOutline},`,t}get isMToonNodeMaterial(){return!0}constructor(t={}){super(),t.transparentWithZWrite&&(t.depthWrite=!0),delete t.transparentWithZWrite,delete t.giEqualizationFactor,delete t.v0CompatShade,delete t.debugMode,this.emissiveNode=null,this.lights=!0,this.color=new i.Color(1,1,1),this.map=null,this.emissive=new i.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new i.Vector2(1,1),this.shadeColorFactor=new i.Color(0,0,0),this.shadeMultiplyTexture=null,this.shadingShiftFactor=0,this.shadingShiftTexture=null,this.shadingShiftTextureScale=1,this.shadingToonyFactor=.9,this.rimLightingMixFactor=1,this.rimMultiplyTexture=null,this.matcapFactor=new i.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new i.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=f.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new i.Color(0,0,0),this.outlineLightingMixFactor=1,this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.uvAnimationMaskTexture=null,this.shadeColorNode=null,this.shadingShiftNode=null,this.shadingToonyNode=null,this.rimLightingMixNode=null,this.rimMultiplyNode=null,this.matcapNode=null,this.parametricRimColorNode=null,this.parametricRimLiftNode=null,this.parametricRimFresnelPowerNode=null,this.uvAnimationScrollXOffset=0,this.uvAnimationScrollYOffset=0,this.uvAnimationRotationPhase=0,this.isOutline=!1,this._animatedUVNode=null,this.setValues(t)}setupLightingModel(){return new z}setup(t){var e;this._animatedUVNode=new D((e=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?e:!1),super.setup(t)}setupDiffuseColor(t){let e=null;if(this.colorNode==null){if(e=J,this.map&&this.map.isTexture===!0){let o=Q.context({getUV:()=>this._animatedUVNode});e=e.mul(o)}this.colorNode=e}this.vertexColors===!0&&t.geometry.hasAttribute("color")&&(console.warn("MToonNodeMaterial: MToon ignores vertex colors. Consider using a model without vertex colors instead."),this.vertexColors=!1),super.setupDiffuseColor(t),parseInt(i.REVISION,10)<166&&this.transparent===!1&&this.blending===i.NormalBlending&&this.alphaToCoverage===!1&&i.diffuseColor.a.assign(1),this.colorNode===e&&(this.colorNode=null)}setupVariants(){k.assign(this._setupShadeColorNode()),Y.assign(this._setupShadingShiftNode()),X.assign(this._setupShadingToonyNode()),g.assign(this._setupRimLightingMixNode()),H.assign(this._setupRimMultiplyNode()),M.assign(this._setupMatcapNode()),x.assign(this._setupParametricRimNode())}setupNormal(t){let e=this.normalNode;if(this.normalNode==null){if(this.normalNode=i.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let r=tt.context({getUV:()=>this._animatedUVNode});this.normalNode=i.normalMap(r,et)}this.isOutline&&(this.normalNode=this.normalNode.negate())}if(parseInt(i.REVISION,10)>=168){let r=this.normalNode;return this.normalNode=e,r}else{super.setupNormal(t),this.normalNode=e;return}}setupLighting(t){let e=null;if(this.emissiveNode==null){if(e=it.mul(ot),this.emissiveMap&&this.emissiveMap.isTexture===!0){let r=rt.context({getUV:()=>this._animatedUVNode});e=e.mul(r)}this.emissiveNode=e}let o=super.setupLighting(t);return this.emissiveNode===e&&(this.emissiveNode=null),o}setupOutput(t,e){return this.isOutline&&this.outlineWidthMode!==f.None&&(e=i.vec4(i.mix(I,e.xyz.mul(I),Tt),e.w)),super.setupOutput(t,e)}setupPosition(t){var e,o;let r=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==f.None){(e=this.positionNode)!=null||(this.positionNode=i.positionLocal);let m=i.normalLocal.normalize(),d=ft;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let c=Rt.context({getUV:()=>this._animatedUVNode});d=d.mul(c)}let T=i.length(i.modelNormalMatrix.mul(m)),R=d.mul(T).mul(m);if(this.outlineWidthMode===f.WorldCoordinates)this.positionNode=this.positionNode.add(R);else if(this.outlineWidthMode===f.ScreenCoordinates){let c=i.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(R.div(c).mul(i.positionView.z.negate()))}(o=this.positionNode)!=null||(this.positionNode=i.positionLocal)}let l=super.setupPosition(t);return l.z.add(l.w.mul(1e-6)),this.positionNode=r,l}copy(t){var e,o,r,l,m,d,T,R,c,S,F,y,C,_,V,L,w,P,A;return this.color.copy(t.color),this.map=(e=t.map)!=null?e:null,this.emissive.copy(t.emissive),this.emissiveIntensity=t.emissiveIntensity,this.emissiveMap=(o=t.emissiveMap)!=null?o:null,this.normalMap=(r=t.normalMap)!=null?r:null,this.normalScale.copy(t.normalScale),this.shadeColorFactor.copy(t.shadeColorFactor),this.shadeMultiplyTexture=(l=t.shadeMultiplyTexture)!=null?l:null,this.shadingShiftFactor=t.shadingShiftFactor,this.shadingShiftTexture=(m=t.shadingShiftTexture)!=null?m:null,this.shadingShiftTextureScale=t.shadingShiftTextureScale,this.shadingToonyFactor=t.shadingToonyFactor,this.rimLightingMixFactor=t.rimLightingMixFactor,this.rimMultiplyTexture=(d=t.rimMultiplyTexture)!=null?d:null,this.matcapFactor.copy(t.matcapFactor),this.matcapTexture=(T=t.matcapTexture)!=null?T:null,this.parametricRimColorFactor.copy(t.parametricRimColorFactor),this.parametricRimLiftFactor=t.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=t.parametricRimFresnelPowerFactor,this.outlineWidthMode=t.outlineWidthMode,this.outlineWidthMultiplyTexture=(R=t.outlineWidthMultiplyTexture)!=null?R:null,this.outlineWidthFactor=t.outlineWidthFactor,this.outlineColorFactor.copy(t.outlineColorFactor),this.outlineLightingMixFactor=t.outlineLightingMixFactor,this.uvAnimationScrollXSpeedFactor=t.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=t.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=t.uvAnimationRotationSpeedFactor,this.uvAnimationMaskTexture=(c=t.uvAnimationMaskTexture)!=null?c:null,this.shadeColorNode=(S=t.shadeColorNode)!=null?S:null,this.shadingShiftNode=(F=t.shadingShiftNode)!=null?F:null,this.shadingToonyNode=(y=t.shadingToonyNode)!=null?y:null,this.rimLightingMixNode=(C=t.rimLightingMixNode)!=null?C:null,this.rimMultiplyNode=(_=t.rimMultiplyNode)!=null?_:null,this.matcapNode=(V=t.matcapNode)!=null?V:null,this.parametricRimColorNode=(L=t.parametricRimColorNode)!=null?L:null,this.parametricRimLiftNode=(w=t.parametricRimLiftNode)!=null?w:null,this.parametricRimFresnelPowerNode=(P=t.parametricRimFresnelPowerNode)!=null?P:null,this.isOutline=(A=t.isOutline)!=null?A:null,super.copy(t)}update(t){this.uvAnimationScrollXOffset+=t*this.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYOffset+=t*this.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationPhase+=t*this.uvAnimationRotationSpeedFactor}_setupShadeColorNode(){if(this.shadeColorNode!=null)return i.vec3(this.shadeColorNode);let t=at;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let e=U.context({getUV:()=>this._animatedUVNode});t=t.mul(e)}return t}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return i.float(this.shadingShiftNode);let t=lt;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let e=U.context({getUV:()=>this._animatedUVNode});t=t.add(e.mul(nt))}return t}_setupShadingToonyNode(){return this.shadingToonyNode!=null?i.float(this.shadingToonyNode):st}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?i.float(this.rimLightingMixNode):ut}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?i.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?mt.context({getUV:()=>this._animatedUVNode}):i.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?i.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?dt.context({getUV:()=>i.matcapUV.mul(1,-1).add(0,1)}).mul(ht):i.vec3(0)}_setupParametricRimNode(){let t=this.parametricRimColorNode!=null?i.vec3(this.parametricRimColorNode):ct,e=this.parametricRimLiftNode!=null?i.float(this.parametricRimLiftNode):Et,o=this.parametricRimFresnelPowerNode!=null?i.float(this.parametricRimFresnelPowerNode):pt;return Ft({parametricRimLift:e,parametricRimFresnelPower:o,parametricRimColor:t})}};
3
3
  /*!
4
- * @pixiv/three-vrm-materials-mtoon v3.3.5
4
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
5
5
  * MToon (toon material) module for @pixiv/three-vrm
6
6
  *
7
7
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm v3.3.5
2
+ * @pixiv/three-vrm v3.3.6
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -490,7 +490,7 @@ export {
490
490
  MToonNodeMaterial
491
491
  };
492
492
  /*!
493
- * @pixiv/three-vrm-materials-mtoon v3.3.5
493
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
494
494
  * MToon (toon material) module for @pixiv/three-vrm
495
495
  *
496
496
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,7 +1,7 @@
1
1
  /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
2
  import*as W from"three";import*as n from"three/webgpu";import*as r from"three/webgpu";import*as l from"three/webgpu";import*as s from"three/webgpu";import*as c from"three/webgpu";import*as i from"three/webgpu";import*as E from"three/webgpu";var P=parseInt(W.REVISION,10);P<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${P}). This would not work correctly.`);var D=r.materialReference("color","color"),k=r.materialReference("map","texture"),Y=r.materialReference("normalMap","texture"),X=r.materialReference("normalScale","vec2"),z=r.materialReference("emissive","color"),B=r.materialReference("emissiveIntensity","float"),q=r.materialReference("emissiveMap","texture"),K=r.materialReference("shadeColorFactor","color"),j=r.materialReference("shadingShiftFactor","float"),A=r.materialReference("shadeMultiplyTexture","texture"),Z=r.materialReference("shadeMultiplyTextureScale","float"),$=r.materialReference("shadingToonyFactor","float"),G=r.materialReference("rimLightingMixFactor","float"),J=r.materialReference("rimMultiplyTexture","texture"),Q=r.materialReference("matcapFactor","color"),tt=r.materialReference("matcapTexture","texture"),et=r.materialReference("parametricRimColorFactor","color"),it=r.materialReference("parametricRimLiftFactor","float"),ot=r.materialReference("parametricRimFresnelPowerFactor","float"),rt=r.materialReference("outlineWidthMultiplyTexture","texture"),at=r.materialReference("outlineWidthFactor","float"),O=r.materialReference("outlineColorFactor","color"),lt=r.materialReference("outlineLightingMixFactor","float"),nt=r.materialReference("uvAnimationMaskTexture","texture"),st=r.materialReference("uvAnimationScrollXOffset","float"),ut=r.materialReference("uvAnimationScrollYOffset","float"),mt=r.materialReference("uvAnimationRotationPhase","float"),ht=class extends n.TempNode{constructor(t){super("vec2"),this.hasMaskTexture=t}setup(){let t=1;this.hasMaskTexture&&(t=n.vec4(nt).context({getUV:()=>n.uv()}).r);let e=n.uv(),o=mt.mul(t),a=n.cos(o),u=n.sin(o);e=e.sub(n.vec2(.5,.5)),e=e.mul(n.mat2(a,u,u.negate(),a)),e=e.add(n.vec2(.5,.5));let m=n.vec2(st,ut).mul(t);return e=e.add(m),e.toVar("AnimatedUV")}},U=s.nodeImmutable(s.PropertyNode,"vec3").toVar("ShadeColor"),I=s.nodeImmutable(s.PropertyNode,"float").toVar("ShadingShift"),b=s.nodeImmutable(s.PropertyNode,"float").toVar("ShadingToony"),v=s.nodeImmutable(s.PropertyNode,"float").toVar("RimLightingMix"),N=s.nodeImmutable(s.PropertyNode,"vec3").toVar("RimMultiply"),g=s.nodeImmutable(s.PropertyNode,"vec3").toVar("matcap"),H=s.nodeImmutable(s.PropertyNode,"vec3").toVar("ParametricRim"),T=t=>parseInt(c.REVISION,10)>=168?c.Fn(t):c.tslFn(t),dt=T(({a:t,b:e,t:o})=>{let a=o.sub(t),u=e.sub(t);return a.div(u).clamp()}),ct=T(({dotNL:t})=>{let o=l.float(1).sub(b),a=t.add(I);return a=dt({a:o.negate(),b:o,t:a}),a=a.mul(1),a}),Et=T(({shading:t,lightColor:e})=>{let o=l.mix(U,l.diffuseColor,t);return e.mul(l.BRDF_Lambert({diffuseColor:o}))}),pt=class extends l.LightingModel{constructor(){super()}direct({lightDirection:t,lightColor:e,reflectedLight:o}){let a=l.transformedNormalView.dot(t).clamp(-1,1),u=ct({dotNL:a});o.directDiffuse.assign(o.directDiffuse.add(Et({shading:u,lightColor:e}))),o.directSpecular.assign(o.directSpecular.add(H.add(g).mul(N).mul(l.mix(l.vec3(0),l.BRDF_Lambert({diffuseColor:e}),v))))}indirect(t){this.indirectDiffuse(t),this.indirectSpecular(t)}indirectDiffuse({irradiance:t,reflectedLight:e}){e.indirectDiffuse.assign(e.indirectDiffuse.add(t.mul(l.BRDF_Lambert({diffuseColor:l.diffuseColor}))))}indirectSpecular({reflectedLight:t}){t.indirectSpecular.assign(t.indirectSpecular.add(H.add(g).mul(N).mul(l.mix(l.vec3(1),l.vec3(0),v))))}},R={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},Rt=T(({parametricRimLift:t,parametricRimFresnelPower:e,parametricRimColor:o})=>{let a=E.modelViewPosition.normalize(),u=E.transformedNormalView.dot(a.negate());return E.float(1).sub(u).add(t).clamp().pow(e).mul(o)}),ft=class extends i.NodeMaterial{customProgramCacheKey(){let t=super.customProgramCacheKey();return t+=`isOutline:${this.isOutline},`,t}get isMToonNodeMaterial(){return!0}constructor(t={}){super(),t.transparentWithZWrite&&(t.depthWrite=!0),delete t.transparentWithZWrite,delete t.giEqualizationFactor,delete t.v0CompatShade,delete t.debugMode,this.emissiveNode=null,this.lights=!0,this.color=new i.Color(1,1,1),this.map=null,this.emissive=new i.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new i.Vector2(1,1),this.shadeColorFactor=new i.Color(0,0,0),this.shadeMultiplyTexture=null,this.shadingShiftFactor=0,this.shadingShiftTexture=null,this.shadingShiftTextureScale=1,this.shadingToonyFactor=.9,this.rimLightingMixFactor=1,this.rimMultiplyTexture=null,this.matcapFactor=new i.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new i.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=R.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new i.Color(0,0,0),this.outlineLightingMixFactor=1,this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.uvAnimationMaskTexture=null,this.shadeColorNode=null,this.shadingShiftNode=null,this.shadingToonyNode=null,this.rimLightingMixNode=null,this.rimMultiplyNode=null,this.matcapNode=null,this.parametricRimColorNode=null,this.parametricRimLiftNode=null,this.parametricRimFresnelPowerNode=null,this.uvAnimationScrollXOffset=0,this.uvAnimationScrollYOffset=0,this.uvAnimationRotationPhase=0,this.isOutline=!1,this._animatedUVNode=null,this.setValues(t)}setupLightingModel(){return new pt}setup(t){var e;this._animatedUVNode=new ht((e=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?e:!1),super.setup(t)}setupDiffuseColor(t){let e=null;if(this.colorNode==null){if(e=D,this.map&&this.map.isTexture===!0){let o=k.context({getUV:()=>this._animatedUVNode});e=e.mul(o)}this.colorNode=e}this.vertexColors===!0&&t.geometry.hasAttribute("color")&&(console.warn("MToonNodeMaterial: MToon ignores vertex colors. Consider using a model without vertex colors instead."),this.vertexColors=!1),super.setupDiffuseColor(t),parseInt(i.REVISION,10)<166&&this.transparent===!1&&this.blending===i.NormalBlending&&this.alphaToCoverage===!1&&i.diffuseColor.a.assign(1),this.colorNode===e&&(this.colorNode=null)}setupVariants(){U.assign(this._setupShadeColorNode()),I.assign(this._setupShadingShiftNode()),b.assign(this._setupShadingToonyNode()),v.assign(this._setupRimLightingMixNode()),N.assign(this._setupRimMultiplyNode()),g.assign(this._setupMatcapNode()),H.assign(this._setupParametricRimNode())}setupNormal(t){let e=this.normalNode;if(this.normalNode==null){if(this.normalNode=i.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let a=Y.context({getUV:()=>this._animatedUVNode});this.normalNode=i.normalMap(a,X)}this.isOutline&&(this.normalNode=this.normalNode.negate())}if(parseInt(i.REVISION,10)>=168){let a=this.normalNode;return this.normalNode=e,a}else{super.setupNormal(t),this.normalNode=e;return}}setupLighting(t){let e=null;if(this.emissiveNode==null){if(e=z.mul(B),this.emissiveMap&&this.emissiveMap.isTexture===!0){let a=q.context({getUV:()=>this._animatedUVNode});e=e.mul(a)}this.emissiveNode=e}let o=super.setupLighting(t);return this.emissiveNode===e&&(this.emissiveNode=null),o}setupOutput(t,e){return this.isOutline&&this.outlineWidthMode!==R.None&&(e=i.vec4(i.mix(O,e.xyz.mul(O),lt),e.w)),super.setupOutput(t,e)}setupPosition(t){var e,o;let a=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==R.None){(e=this.positionNode)!=null||(this.positionNode=i.positionLocal);let m=i.normalLocal.normalize(),h=at;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let d=rt.context({getUV:()=>this._animatedUVNode});h=h.mul(d)}let f=i.length(i.modelNormalMatrix.mul(m)),p=h.mul(f).mul(m);if(this.outlineWidthMode===R.WorldCoordinates)this.positionNode=this.positionNode.add(p);else if(this.outlineWidthMode===R.ScreenCoordinates){let d=i.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(p.div(d).mul(i.positionView.z.negate()))}(o=this.positionNode)!=null||(this.positionNode=i.positionLocal)}let u=super.setupPosition(t);return u.z.add(u.w.mul(1e-6)),this.positionNode=a,u}copy(t){var e,o,a,u,m,h,f,p,d,M,x,S,F,y,C,_,V,L,w;return this.color.copy(t.color),this.map=(e=t.map)!=null?e:null,this.emissive.copy(t.emissive),this.emissiveIntensity=t.emissiveIntensity,this.emissiveMap=(o=t.emissiveMap)!=null?o:null,this.normalMap=(a=t.normalMap)!=null?a:null,this.normalScale.copy(t.normalScale),this.shadeColorFactor.copy(t.shadeColorFactor),this.shadeMultiplyTexture=(u=t.shadeMultiplyTexture)!=null?u:null,this.shadingShiftFactor=t.shadingShiftFactor,this.shadingShiftTexture=(m=t.shadingShiftTexture)!=null?m:null,this.shadingShiftTextureScale=t.shadingShiftTextureScale,this.shadingToonyFactor=t.shadingToonyFactor,this.rimLightingMixFactor=t.rimLightingMixFactor,this.rimMultiplyTexture=(h=t.rimMultiplyTexture)!=null?h:null,this.matcapFactor.copy(t.matcapFactor),this.matcapTexture=(f=t.matcapTexture)!=null?f:null,this.parametricRimColorFactor.copy(t.parametricRimColorFactor),this.parametricRimLiftFactor=t.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=t.parametricRimFresnelPowerFactor,this.outlineWidthMode=t.outlineWidthMode,this.outlineWidthMultiplyTexture=(p=t.outlineWidthMultiplyTexture)!=null?p:null,this.outlineWidthFactor=t.outlineWidthFactor,this.outlineColorFactor.copy(t.outlineColorFactor),this.outlineLightingMixFactor=t.outlineLightingMixFactor,this.uvAnimationScrollXSpeedFactor=t.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=t.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=t.uvAnimationRotationSpeedFactor,this.uvAnimationMaskTexture=(d=t.uvAnimationMaskTexture)!=null?d:null,this.shadeColorNode=(M=t.shadeColorNode)!=null?M:null,this.shadingShiftNode=(x=t.shadingShiftNode)!=null?x:null,this.shadingToonyNode=(S=t.shadingToonyNode)!=null?S:null,this.rimLightingMixNode=(F=t.rimLightingMixNode)!=null?F:null,this.rimMultiplyNode=(y=t.rimMultiplyNode)!=null?y:null,this.matcapNode=(C=t.matcapNode)!=null?C:null,this.parametricRimColorNode=(_=t.parametricRimColorNode)!=null?_:null,this.parametricRimLiftNode=(V=t.parametricRimLiftNode)!=null?V:null,this.parametricRimFresnelPowerNode=(L=t.parametricRimFresnelPowerNode)!=null?L:null,this.isOutline=(w=t.isOutline)!=null?w:null,super.copy(t)}update(t){this.uvAnimationScrollXOffset+=t*this.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYOffset+=t*this.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationPhase+=t*this.uvAnimationRotationSpeedFactor}_setupShadeColorNode(){if(this.shadeColorNode!=null)return i.vec3(this.shadeColorNode);let t=K;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let e=A.context({getUV:()=>this._animatedUVNode});t=t.mul(e)}return t}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return i.float(this.shadingShiftNode);let t=j;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let e=A.context({getUV:()=>this._animatedUVNode});t=t.add(e.mul(Z))}return t}_setupShadingToonyNode(){return this.shadingToonyNode!=null?i.float(this.shadingToonyNode):$}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?i.float(this.rimLightingMixNode):G}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?i.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?J.context({getUV:()=>this._animatedUVNode}):i.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?i.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?tt.context({getUV:()=>i.matcapUV.mul(1,-1).add(0,1)}).mul(Q):i.vec3(0)}_setupParametricRimNode(){let t=this.parametricRimColorNode!=null?i.vec3(this.parametricRimColorNode):et,e=this.parametricRimLiftNode!=null?i.float(this.parametricRimLiftNode):it,o=this.parametricRimFresnelPowerNode!=null?i.float(this.parametricRimFresnelPowerNode):ot;return Rt({parametricRimLift:e,parametricRimFresnelPower:o,parametricRimColor:t})}};export{ht as MToonAnimatedUVNode,pt as MToonLightingModel,ft as MToonNodeMaterial};
3
3
  /*!
4
- * @pixiv/three-vrm-materials-mtoon v3.3.5
4
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
5
5
  * MToon (toon material) module for @pixiv/three-vrm
6
6
  *
7
7
  * Copyright (c) 2019-2025 pixiv Inc.
package/lib/three-vrm.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm v3.3.5
2
+ * @pixiv/three-vrm v3.3.6
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6651,7 +6651,7 @@ VRMUtils.removeUnnecessaryJoints = removeUnnecessaryJoints;
6651
6651
  VRMUtils.removeUnnecessaryVertices = removeUnnecessaryVertices;
6652
6652
  VRMUtils.rotateVRM0 = rotateVRM0;
6653
6653
  /*!
6654
- * @pixiv/three-vrm-core v3.3.5
6654
+ * @pixiv/three-vrm-core v3.3.6
6655
6655
  * The implementation of core features of VRM, for @pixiv/three-vrm
6656
6656
  *
6657
6657
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6659,7 +6659,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6659
6659
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6660
6660
  */
6661
6661
  /*!
6662
- * @pixiv/three-vrm-materials-mtoon v3.3.5
6662
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
6663
6663
  * MToon (toon material) module for @pixiv/three-vrm
6664
6664
  *
6665
6665
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6667,7 +6667,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6667
6667
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6668
6668
  */
6669
6669
  /*!
6670
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.5
6670
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.6
6671
6671
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
6672
6672
  *
6673
6673
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6675,7 +6675,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6675
6675
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6676
6676
  */
6677
6677
  /*!
6678
- * @pixiv/three-vrm-materials-v0compat v3.3.5
6678
+ * @pixiv/three-vrm-materials-v0compat v3.3.6
6679
6679
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
6680
6680
  *
6681
6681
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6683,7 +6683,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6683
6683
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6684
6684
  */
6685
6685
  /*!
6686
- * @pixiv/three-vrm-node-constraint v3.3.5
6686
+ * @pixiv/three-vrm-node-constraint v3.3.6
6687
6687
  * Node constraint module for @pixiv/three-vrm
6688
6688
  *
6689
6689
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6691,7 +6691,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6691
6691
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6692
6692
  */
6693
6693
  /*!
6694
- * @pixiv/three-vrm-springbone v3.3.5
6694
+ * @pixiv/three-vrm-springbone v3.3.6
6695
6695
  * Spring bone module for @pixiv/three-vrm
6696
6696
  *
6697
6697
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -923,7 +923,7 @@ void main() {
923
923
  `)+`
924
924
  `;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===Vt.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},mo=new Set(["1.0","1.0-beta"]),gi=class Ke{get name(){return Ke.EXTENSION_NAME}constructor(e,n={}){var i,r,o,a;this.parser=e,this.materialType=(i=n.materialType)!=null?i:fi,this.renderOrderOffset=(r=n.renderOrderOffset)!=null?r:0,this.v0CompatShade=(o=n.v0CompatShade)!=null?o:!1,this.debugMode=(a=n.debugMode)!=null?a:"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 a=o.primitives,l=yield i.loadMesh(e);if(a.length===1){let s=l,u=a[0].material;u!=null&&this._setupPrimitive(s,u)}else{let s=l;for(let u=0;u<a.length;u++){let d=s.children[u],h=a[u].material;h!=null&&this._setupPrimitive(d,h)}}return l})}_removeUnlitExtensionIfMToonExists(){let i=this.parser.json.materials;i==null||i.map((r,o)=>{var a;this._getMToonExtension(o)&&((a=r.extensions)!=null&&a.KHR_materials_unlit)&&delete r.extensions.KHR_materials_unlit})}_getMToonExtension(e){var n,i;let a=(n=this.parser.json.materials)==null?void 0:n[e];if(a==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=a.extensions)==null?void 0:i[Ke.EXTENSION_NAME];if(l==null)return;let s=l.specVersion;if(!mo.has(s)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${Ke.EXTENSION_NAME} specVersion "${s}"`);return}return l}_extendMaterialParams(e,n){return ue(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new uo(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 et.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=et.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)}};gi.EXTENSION_NAME="VRMC_materials_mtoon";var Ct=gi;var fo=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),_i=class Ut{get name(){return Ut.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return fo(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 a=(n=this.parser.json.materials)==null?void 0:n[e];if(a==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=a.extensions)==null?void 0:i[Ut.EXTENSION_NAME];if(l!=null)return l}};_i.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var vi=_i;var Ti=T(require("three"),1);var go=Object.defineProperty,_o=Object.defineProperties,vo=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Eo=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable,Mi=(t,e,n)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))Eo.call(e,n)&&Mi(t,n,e[n]);if(Ei)for(var n of Ei(e))Mo.call(e,n)&&Mi(t,n,e[n]);return t},Ri=(t,e)=>_o(t,vo(e)),Ro=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())});function Ee(t){return Math.pow(t,2.2)}var xi=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 Ro(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 a,l;let s=(a=e.materials)==null?void 0:a[o];if(s==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,s);e.materials[o]=u}else if((l=r.shader)!=null&&l.startsWith("VRM/Unlit")){let u=this._parseV0UnlitProperties(r,s);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,a,l,s,u,d,h,m,p,c,f,g,v,L,x,_,E,M,R,w,b,A,P,H,W,z,xe,q,G,pe,ye,O,Yt,qt,$t,Zt,Jt,Kt,en,tn,nn,rn,on,sn,an,ln,un,dn,hn,cn,pn,mn;let fn=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,Yi=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&fn,qi=this._v0ParseRenderQueue(t),gn=(a=(o=t.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?a:!1,$i=fn?"BLEND":gn?"MASK":"OPAQUE",Zi=gn?(s=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?s:.5:void 0,Ji=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,se=this._portTextureTransform(t),Ki=((m=(h=t.vectorProperties)==null?void 0:h._Color)!=null?m:[1,1,1,1]).map((wn,xr)=>xr===3?wn:Ee(wn)),_n=(p=t.textureProperties)==null?void 0:p._MainTex,er=_n!=null?{index:_n,extensions:X({},se)}:void 0,tr=(f=(c=t.floatProperties)==null?void 0:c._BumpScale)!=null?f:1,vn=(g=t.textureProperties)==null?void 0:g._BumpMap,nr=vn!=null?{index:vn,scale:tr,extensions:X({},se)}:void 0,ir=((L=(v=t.vectorProperties)==null?void 0:v._EmissionColor)!=null?L:[0,0,0,1]).map(Ee),En=(x=t.textureProperties)==null?void 0:x._EmissionMap,rr=En!=null?{index:En,extensions:X({},se)}:void 0,or=((E=(_=t.vectorProperties)==null?void 0:_._ShadeColor)!=null?E:[.97,.81,.86,1]).map(Ee),Mn=(M=t.textureProperties)==null?void 0:M._ShadeTexture,sr=Mn!=null?{index:Mn,extensions:X({},se)}:void 0,Oe=(w=(R=t.floatProperties)==null?void 0:R._ShadeShift)!=null?w:0,Ne=(A=(b=t.floatProperties)==null?void 0:b._ShadeToony)!=null?A:.9;Ne=Ti.MathUtils.lerp(Ne,1,.5+.5*Oe),Oe=-Oe-(1-Ne);let Rn=(H=(P=t.floatProperties)==null?void 0:P._IndirectLightIntensity)!=null?H:.1,ar=Rn?1-Rn:void 0,pt=(W=t.textureProperties)==null?void 0:W._SphereAdd,lr=pt!=null?[1,1,1]:void 0,ur=pt!=null?{index:pt}:void 0,dr=(xe=(z=t.floatProperties)==null?void 0:z._RimLightingMix)!=null?xe:0,Tn=(q=t.textureProperties)==null?void 0:q._RimTexture,hr=Tn!=null?{index:Tn,extensions:X({},se)}:void 0,cr=((pe=(G=t.vectorProperties)==null?void 0:G._RimColor)!=null?pe:[0,0,0,1]).map(Ee),pr=(O=(ye=t.floatProperties)==null?void 0:ye._RimFresnelPower)!=null?O:1,mr=(qt=(Yt=t.floatProperties)==null?void 0:Yt._RimLift)!=null?qt:0,fr=["none","worldCoordinates","screenCoordinates"][(Zt=($t=t.floatProperties)==null?void 0:$t._OutlineWidthMode)!=null?Zt:0],mt=(Kt=(Jt=t.floatProperties)==null?void 0:Jt._OutlineWidth)!=null?Kt:0;mt=.01*mt;let xn=(en=t.textureProperties)==null?void 0:en._OutlineWidthTexture,gr=xn!=null?{index:xn,extensions:X({},se)}:void 0,_r=((nn=(tn=t.vectorProperties)==null?void 0:tn._OutlineColor)!=null?nn:[0,0,0]).map(Ee),vr=((on=(rn=t.floatProperties)==null?void 0:rn._OutlineColorMode)!=null?on:0)===1?(an=(sn=t.floatProperties)==null?void 0:sn._OutlineLightingMix)!=null?an:1:0,yn=(ln=t.textureProperties)==null?void 0:ln._UvAnimMaskTexture,Er=yn!=null?{index:yn,extensions:X({},se)}:void 0,Mr=(dn=(un=t.floatProperties)==null?void 0:un._UvAnimScrollX)!=null?dn:0,Be=(cn=(hn=t.floatProperties)==null?void 0:hn._UvAnimScrollY)!=null?cn:0;Be!=null&&(Be=-Be);let Rr=(mn=(pn=t.floatProperties)==null?void 0:pn._UvAnimRotation)!=null?mn:0,Tr={specVersion:"1.0",transparentWithZWrite:Yi,renderQueueOffsetNumber:qi,shadeColorFactor:or,shadeMultiplyTexture:sr,shadingShiftFactor:Oe,shadingToonyFactor:Ne,giEqualizationFactor:ar,matcapFactor:lr,matcapTexture:ur,rimLightingMixFactor:dr,rimMultiplyTexture:hr,parametricRimColorFactor:cr,parametricRimFresnelPowerFactor:pr,parametricRimLiftFactor:mr,outlineWidthMode:fr,outlineWidthFactor:mt,outlineWidthMultiplyTexture:gr,outlineColorFactor:_r,outlineLightingMixFactor:vr,uvAnimationMaskTexture:Er,uvAnimationScrollXSpeedFactor:Mr,uvAnimationScrollYSpeedFactor:Be,uvAnimationRotationSpeedFactor:Rr};return Ri(X({},e),{pbrMetallicRoughness:{baseColorFactor:Ki,baseColorTexture:er},normalTexture:nr,emissiveTexture:rr,emissiveFactor:ir,alphaMode:$i,alphaCutoff:Zi,doubleSided:Ji,extensions:{VRMC_materials_mtoon:Tr}})}_parseV0UnlitProperties(t,e){var n,i,r,o,a;let l=t.shader==="VRM/UnlitTransparentZWrite",s=t.shader==="VRM/UnlitTransparent"||l,u=this._v0ParseRenderQueue(t),d=t.shader==="VRM/UnlitCutout",h=s?"BLEND":d?"MASK":"OPAQUE",m=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,p=this._portTextureTransform(t),c=((o=(r=t.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(Ee),f=(a=t.textureProperties)==null?void 0:a._MainTex,g=f!=null?{index:f,extensions:X({},p)}:void 0,v={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:c,shadeMultiplyTexture:g};return Ri(X({},e),{pbrMetallicRoughness:{baseColorFactor:c,baseColorTexture:g},alphaMode:h,alphaCutoff:m,extensions:{VRMC_materials_mtoon:v}})}_portTextureTransform(t){var e,n,i,r,o;let a=(e=t.vectorProperties)==null?void 0:e._MainTex;if(a==null)return{};let l=[(n=a==null?void 0:a[0])!=null?n:0,(i=a==null?void 0:a[1])!=null?i:0],s=[(r=a==null?void 0:a[2])!=null?r:1,(o=a==null?void 0:a[3])!=null?o:1];return l[1]=1-s[1]-l[1],{KHR_texture_transform:{offset:l,scale:s}}}_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,a=0;if(r){let l=t.renderQueue;l!=null&&(o?a=this._renderQueueMapTransparentZWrite.get(l):a=this._renderQueueMapTransparent.get(l))}return a}_populateRenderQueueMap(t){let e=new Set,n=new Set;t.forEach(i=>{var r,o;let a=i.shader==="VRM/UnlitTransparentZWrite",l=((r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null||i.shader==="VRM/UnlitTransparent"||a,s=((o=i.floatProperties)==null?void 0:o._ZWrite)===1||a;if(l){let u=i.renderQueue;u!=null&&(s?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 N=T(require("three"),1),Q=T(require("three"),1),Ot=T(require("three"),1),be=T(require("three"),1),Z=T(require("three"),1);var yi=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),ne=new N.Vector3,tt=class extends N.Group{constructor(t){super(),this._attrPosition=new N.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(N.DynamicDrawUsage);let e=new N.BufferGeometry;e.setAttribute("position",this._attrPosition);let n=new N.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new N.Line(e,n),this.add(this._line),this.constraint=t}updateMatrixWorld(t){ne.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,ne.x,ne.y,ne.z),this.constraint.source&&ne.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,ne.x,ne.y,ne.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};function wi(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var To=new Ot.Vector3,xo=new Ot.Vector3;function yo(t,e){return t.decompose(To,e,xo),e}function nt(t){return t.invert?t.invert():t.inverse(),t}var it=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},wo=new Q.Vector3,So=new Q.Vector3,Po=new Q.Vector3,Ao=new Q.Quaternion,Lo=new Q.Quaternion,bo=new Q.Quaternion,Si=class extends it{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 Q.Vector3(1,0,0),this._dstRestQuat=new Q.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=Ao.identity(),e=Lo.identity();this.destination.parent&&(yo(this.destination.parent.matrixWorld,t),nt(e.copy(t)));let n=wo.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=wi(this.source.matrixWorld,So).sub(wi(this.destination.matrixWorld,Po)).normalize(),r=bo.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function Ho(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var Pi=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)Ho(o,a=>{let l=this._objectConstraintsMap.get(a);if(l)for(let s of l)this._processConstraint(s,e,n,i)});i(t),n.add(t)}},Io=new be.Quaternion,Vo=new be.Quaternion,Ai=class extends it{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new be.Quaternion,this._invSrcRestQuat=new be.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),nt(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=Io.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=Vo.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},Co=new Z.Vector3,Uo=new Z.Quaternion,Oo=new Z.Quaternion,Li=class extends it{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 Z.Vector3(1,0,0),this._dstRestQuat=new Z.Quaternion,this._invDstRestQuat=new Z.Quaternion,this._invSrcRestQuatMulDstRestQuat=new Z.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),nt(this._invDstRestQuat.copy(this._dstRestQuat)),nt(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=Uo.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=Co.copy(this._v3RollAxis).applyQuaternion(t),i=Oo.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},No=new Set(["1.0","1.0-beta"]),bi=class Le{get name(){return Le.EXTENSION_NAME}constructor(e,n){this.parser=e,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(e){return yi(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return yi(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(Le.EXTENSION_NAME))!==-1))return null;let o=new Pi,a=yield this.parser.getDependencies("node");return a.forEach((l,s)=>{var u;let d=i.nodes[s],h=(u=d==null?void 0:d.extensions)==null?void 0:u[Le.EXTENSION_NAME];if(h==null)return;let m=h.specVersion;if(!No.has(m)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Le.EXTENSION_NAME} specVersion "${m}"`);return}let p=h.constraint;if(p.roll!=null){let c=this._importRollConstraint(l,a,p.roll);o.addConstraint(c)}else if(p.aim!=null){let c=this._importAimConstraint(l,a,p.aim);o.addConstraint(c)}else if(p.rotation!=null){let c=this._importRotationConstraint(l,a,p.rotation);o.addConstraint(c)}}),e.scene.updateMatrixWorld(),o.setInitState(),o})}_importRollConstraint(e,n,i){let{source:r,rollAxis:o,weight:a}=i,l=n[r],s=new Li(e,l);if(o!=null&&(s.rollAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new tt(s);this.helperRoot.add(u)}return s}_importAimConstraint(e,n,i){let{source:r,aimAxis:o,weight:a}=i,l=n[r],s=new Si(e,l);if(o!=null&&(s.aimAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new tt(s);this.helperRoot.add(u)}return s}_importRotationConstraint(e,n,i){let{source:r,weight:o}=i,a=n[r],l=new Ai(e,a);if(o!=null&&(l.weight=o),this.helperRoot){let s=new tt(l);this.helperRoot.add(s)}return l}};bi.EXTENSION_NAME="VRMC_node_constraint";var Nt=bi;var re=T(require("three"),1),Ce=T(require("three"),1),Te=T(require("three"),1),jt=T(require("three"),1),J=T(require("three"),1),ie=T(require("three"),1),he=T(require("three"),1),oe=T(require("three"),1),ce=T(require("three"),1),lt=T(require("three"),1),U=T(require("three"),1),Ci=T(require("three"),1),Ui=T(require("three"),1),D=T(require("three"),1);var rt=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),at=class{},Bt=new Ce.Vector3,de=new Ce.Vector3,zt=class extends at{get type(){return"capsule"}constructor(t){var e,n,i,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Ce.Vector3(0,0,0),this.tail=(n=t==null?void 0:t.tail)!=null?n:new Ce.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){Bt.setFromMatrixPosition(t),de.subVectors(this.tail,this.offset).applyMatrix4(t),de.sub(Bt);let r=de.lengthSq();i.copy(e).sub(Bt);let o=de.dot(i);o<=0||(r<=o||de.multiplyScalar(o/r),i.sub(de));let a=i.length(),l=this.inside?this.radius-n-a:a-n-this.radius;return l<0&&(i.multiplyScalar(1/a),this.inside&&i.negate()),l}},Dt=new Te.Vector3,Hi=new Te.Matrix3,Gt=class extends at{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),Hi.getNormalMatrix(t),Dt.copy(this.normal).applyNormalMatrix(Hi).normalize();let r=i.dot(Dt)-n;return i.copy(Dt),r}},Bo=new jt.Vector3,Xt=class extends at{get type(){return"sphere"}constructor(t){var e,n,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new jt.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,Bo.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}},Y=new J.Vector3,Do=class extends J.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new J.Vector3,this._currentTail=new J.Vector3,this._shape=t,this._attrPos=new J.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new J.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=Y.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),t=!0),t&&this._buildPosition()}_buildPosition(){Y.copy(this._currentTail).sub(this._currentOffset);let t=Y.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(Y.y,Math.sqrt(Y.x*Y.x+Y.z*Y.z)),n=-Math.atan2(Y.z,Y.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}},Fo=class extends ie.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentOffset=new ie.Vector3,this._currentNormal=new ie.Vector3,this._shape=t,this._attrPos=new ie.BufferAttribute(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ie.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}},ko=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(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new he.BufferAttribute(new Uint16Array(64*3),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}},Wo=new re.Vector3,ot=class extends re.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof Xt)this._geometry=new ko(this.collider.shape);else if(this.collider.shape instanceof zt)this._geometry=new Do(this.collider.shape);else if(this.collider.shape instanceof Gt)this._geometry=new Fo(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new re.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new re.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=Wo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},zo=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}},Go=new oe.Vector3,Vi=class extends oe.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new zo(this.springBone);let e=new oe.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new oe.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=Go.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},st=class extends lt.Object3D{constructor(t){super(),this.colliderMatrix=new lt.Matrix4,this.shape=t}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),jo(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function jo(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 Xo=new Ui.Matrix4;function Qo(t){return t.invert?t.invert():t.getInverse(Xo.copy(t)),t}var Yo=class{constructor(t){this._inverseCache=new Ci.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&&(Qo(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},Ft=new U.Matrix4,Me=new U.Vector3,He=new U.Vector3,Ie=new U.Vector3,Ve=new U.Vector3,qo=new U.Matrix4,Oi=class{constructor(t,e,n={},i=[]){this._currentTail=new U.Vector3,this._prevTail=new U.Vector3,this._boneAxis=new U.Vector3,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new U.Matrix4,this._initialLocalRotation=new U.Quaternion,this._initialLocalChildPosition=new U.Vector3;var r,o,a,l,s,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:(a=n.gravityPower)!=null?a:0,gravityDir:(s=(l=n.gravityDir)==null?void 0:l.clone())!=null?s:new U.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 Yo(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Ft}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=He.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);Ve.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),Ie.setFromMatrixPosition(this.bone.matrixWorld),Ve.sub(Ie).normalize().multiplyScalar(this._worldSpaceBoneLength).add(Ie),this._collision(Ve),this._prevTail.copy(this._currentTail),this._currentTail.copy(Ve).applyMatrix4(this._getMatrixWorldToCenter());let n=qo.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Me.copy(Ve).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(Ie);let o=t.length();t.multiplyScalar(this._worldSpaceBoneLength/o).add(Ie)}}}_calcWorldSpaceBoneLength(){Me.setFromMatrixPosition(this.bone.matrixWorld),this.child?He.setFromMatrixPosition(this.child.matrixWorld):(He.copy(this._initialLocalChildPosition),He.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Me.sub(He).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:Ft}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:Ft}};function $o(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function kt(t,e){t.children.forEach(n=>{e(n)||kt(n,e)})}function Zo(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 Wt=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),kt(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=Zo(i);this._ancestors=[],r&&(this._ancestors.push(r),kt(r,o=>{var a,l;return((l=(a=this._objectSpringBonesMap.get(o))==null?void 0:a.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 a of o){let l=!1,s=null;$o(a,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||(s=u)}),s&&r.add(s)}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)}},Ii="VRMC_springBone_extended_collider",Jo=new Set(["1.0","1.0-beta"]),Ko=new Set(["1.0"]),Ni=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 rt(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return rt(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 rt(this,null,function*(){var n,i,r,o,a;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(Re.EXTENSION_NAME))!==-1))return null;let u=new Wt,d=yield e.parser.getDependencies("node"),h=(i=l.extensions)==null?void 0:i[Re.EXTENSION_NAME];if(!h)return null;let m=h.specVersion;if(!Jo.has(m))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Re.EXTENSION_NAME} specVersion "${m}"`),null;let p=(r=h.colliders)==null?void 0:r.map((f,g)=>{var v,L,x,_,E,M,R,w,b,A,P,H,W,z,xe;let q=d[f.node];if(q==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${g} attempted to use the node #${f.node} but not found`),null;let G=f.shape,pe=(v=f.extensions)==null?void 0:v[Ii];if(this.useExtendedColliders&&pe!=null){let ye=pe.specVersion;if(!Ko.has(ye))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ii} specVersion "${ye}". Fallbacking to the ${Re.EXTENSION_NAME} definition`);else{let O=pe.shape;if(O.sphere)return this._importSphereCollider(q,{offset:new D.Vector3().fromArray((L=O.sphere.offset)!=null?L:[0,0,0]),radius:(x=O.sphere.radius)!=null?x:0,inside:(_=O.sphere.inside)!=null?_:!1});if(O.capsule)return this._importCapsuleCollider(q,{offset:new D.Vector3().fromArray((E=O.capsule.offset)!=null?E:[0,0,0]),radius:(M=O.capsule.radius)!=null?M:0,tail:new D.Vector3().fromArray((R=O.capsule.tail)!=null?R:[0,0,0]),inside:(w=O.capsule.inside)!=null?w:!1});if(O.plane)return this._importPlaneCollider(q,{offset:new D.Vector3().fromArray((b=O.plane.offset)!=null?b:[0,0,0]),normal:new D.Vector3().fromArray((A=O.plane.normal)!=null?A:[0,0,1])})}}if(G.sphere)return this._importSphereCollider(q,{offset:new D.Vector3().fromArray((P=G.sphere.offset)!=null?P:[0,0,0]),radius:(H=G.sphere.radius)!=null?H:0,inside:!1});if(G.capsule)return this._importCapsuleCollider(q,{offset:new D.Vector3().fromArray((W=G.capsule.offset)!=null?W:[0,0,0]),radius:(z=G.capsule.radius)!=null?z:0,tail:new D.Vector3().fromArray((xe=G.capsule.tail)!=null?xe:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${g} has no valid shape`)}),c=(o=h.colliderGroups)==null?void 0:o.map((f,g)=>{var v;return{colliders:((v=f.colliders)!=null?v:[]).flatMap(x=>{let _=p==null?void 0:p[x];return _==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${g} attempted to use a collider #${x} but not found`),[]):_}),name:f.name}});return(a=h.springs)==null||a.forEach((f,g)=>{var v;let L=f.joints,x=(v=f.colliderGroups)==null?void 0:v.map(M=>{let R=c==null?void 0:c[M];if(R==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to use a colliderGroup ${M} but not found`);return R}),_=f.center!=null?d[f.center]:void 0,E;L.forEach(M=>{if(E){let R=E.node,w=d[R],b=M.node,A=d[b],P={hitRadius:E.hitRadius,dragForce:E.dragForce,gravityPower:E.gravityPower,stiffness:E.stiffness,gravityDir:E.gravityDir!=null?new D.Vector3().fromArray(E.gravityDir):void 0},H=this._importJoint(w,A,P,x);_&&(H.center=_),u.addJoint(H)}E=M})}),u.setInitState(),u})}_v0Import(e){return rt(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,s=l==null?void 0:l.secondaryAnimation;if(!s)return null;let u=s==null?void 0:s.boneGroups;if(!u)return null;let d=new Wt,h=yield e.parser.getDependencies("node"),m=(r=s.colliderGroups)==null?void 0:r.map(p=>{var c;let f=h[p.node];return{colliders:((c=p.colliders)!=null?c:[]).map((v,L)=>{var x,_,E;let M=new D.Vector3(0,0,0);return v.offset&&M.set((x=v.offset.x)!=null?x:0,(_=v.offset.y)!=null?_:0,v.offset.z?-v.offset.z:0),this._importSphereCollider(f,{offset:M,radius:(E=v.radius)!=null?E:0,inside:!1})})}});return u==null||u.forEach((p,c)=>{let f=p.bones;f&&f.forEach(g=>{var v,L,x,_;let E=h[g],M=new D.Vector3;p.gravityDir?M.set((v=p.gravityDir.x)!=null?v:0,(L=p.gravityDir.y)!=null?L:0,(x=p.gravityDir.z)!=null?x:0):M.set(0,-1,0);let R=p.center!=null?h[p.center]:void 0,w={hitRadius:p.hitRadius,dragForce:p.dragForce,gravityPower:p.gravityPower,stiffness:p.stiffiness,gravityDir:M},b=(_=p.colliderGroups)==null?void 0:_.map(A=>{let P=m==null?void 0:m[A];if(P==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${c} attempted to use a colliderGroup ${A} but not found`);return P});E.traverse(A=>{var P;let H=(P=A.children[0])!=null?P:null,W=this._importJoint(A,H,w,b);R&&(W.center=R),d.addJoint(W)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let o=new Oi(e,n,i,r);if(this.jointHelperRoot){let a=new Vi(o);this.jointHelperRoot.add(a),a.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(e,n){let i=new Xt(n),r=new st(i);if(e.add(r),this.colliderHelperRoot){let o=new ot(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,n){let i=new zt(n),r=new st(i);if(e.add(r),this.colliderHelperRoot){let o=new ot(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,n){let i=new Gt(n),r=new st(i);if(e.add(r),this.colliderHelperRoot){let o=new ot(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}};Ni.EXTENSION_NAME="VRMC_springBone";var Qt=Ni;var ut=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var o,a,l,s,u,d,h,m,p,c;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 Xe(e),this.firstPersonPlugin=(a=n==null?void 0:n.firstPersonPlugin)!=null?a:new Qe(e),this.humanoidPlugin=(l=n==null?void 0:n.humanoidPlugin)!=null?l:new qe(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(s=n==null?void 0:n.lookAtPlugin)!=null?s:new $e(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new Ze(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new Ct(e),this.materialsHDREmissiveMultiplierPlugin=(h=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?h:new vi(e),this.materialsV0CompatPlugin=(m=n==null?void 0:n.materialsV0CompatPlugin)!=null?m:new xi(e),this.springBonePlugin=(p=n==null?void 0:n.springBonePlugin)!=null?p:new Qt(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(c=n==null?void 0:n.nodeConstraintPlugin)!=null?c:new Nt(e,{helperRoot:i})}beforeRoot(){return we(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return we(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 we(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,n),yield this.mtoonMaterialPlugin.extendMaterialParams(e,n)})}afterRoot(e){return we(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 Di=T(require("three"),1);function es(t){let e=new Set;return t.traverse(n=>{if(!n.isMesh)return;let i=n;e.add(i)}),e}function Bi(t,e,n){if(e.size===1){let a=e.values().next().value;if(a.weight===1)return t[a.index]}let i=new Float32Array(t[0].count*3),r=0;if(n)r=1;else for(let a of e)r+=a.weight;for(let a of e){let l=t[a.index],s=a.weight/r;for(let u=0;u<l.count;u++)i[u*3+0]+=l.getX(u)*s,i[u*3+1]+=l.getY(u)*s,i[u*3+2]+=l.getZ(u)*s}return new Di.BufferAttribute(i,3)}function Fi(t){var r;let e=es(t.scene),n=new Map,i=(r=t.expressionManager)==null?void 0:r.expressionMap;if(i!=null)for(let[o,a]of Object.entries(i)){let l=new Set;for(let s of a.binds)if(s instanceof _e){if(s.weight!==0)for(let u of s.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(s)}l.add(s)}for(let s of l)a.deleteBind(s)}for(let o of e){let a=n.get(o);if(a==null)continue;let l=o.geometry.morphAttributes;o.geometry.morphAttributes={};let s=o.geometry.clone();o.geometry=s;let u=s.morphTargetsRelative,d=l.position!=null,h=l.normal!=null,m={},p={},c=[];if(d||h){d&&(m.position=[]),h&&(m.normal=[]);let f=0;for(let[g,v]of a)d&&(m.position[f]=Bi(l.position,v,u)),h&&(m.normal[f]=Bi(l.normal,v,u)),i==null||i[g].addBind(new _e({index:f,weight:1,primitives:[o]})),p[g]=f,c.push(0),f++}s.morphAttributes=m,o.morphTargetDictionary=p,o.morphTargetInfluences=c}}var dt=T(require("three"),1);function ki(t){var u;let e=ts(t),n=new Map;for(let d of e){let h=d.geometry,m=h.getAttribute("skinIndex"),p=(u=n.get(m))!=null?u:new Map;n.set(m,p);let c=h.getAttribute("skinWeight"),f=ns(m,c);p.set(c,f)}let i=new Map;for(let d of e){let h=is(d,n);i.set(d,h)}let r=[];for(let[d,h]of i){let m=!1;for(let p of r)if(rs(h,p.boneInverseMap)){m=!0,p.meshes.add(d);for(let[f,g]of h)p.boneInverseMap.set(f,g);break}m||r.push({boneInverseMap:h,meshes:new Set([d])})}let o=new Map,a=new Ue,l=new Ue,s=new Ue;for(let d of r){let{boneInverseMap:h,meshes:m}=d,p=Array.from(h.keys()),c=Array.from(h.values()),f=new dt.Skeleton(p,c),g=l.getOrCreate(f);for(let v of m){let L=v.geometry.getAttribute("skinIndex"),x=a.getOrCreate(L),_=v.skeleton.bones,E=_.map(w=>s.getOrCreate(w)).join(","),M=`${x};${g};${E}`,R=o.get(M);R==null&&(R=L.clone(),os(R,_,p),o.set(M,R)),v.geometry.setAttribute("skinIndex",R)}for(let v of m)v.bind(f,new dt.Matrix4)}}function ts(t){let e=new Set;return t.traverse(n=>{if(!n.isSkinnedMesh)return;let i=n;e.add(i)}),e}function ns(t,e){let n=new Set;for(let i=0;i<t.count;i++)for(let r=0;r<t.itemSize;r++){let o=t.getComponent(i,r);e.getComponent(i,r)!==0&&n.add(o)}return n}function is(t,e){let n=new Map,i=t.skeleton,r=t.geometry,o=r.getAttribute("skinIndex"),a=r.getAttribute("skinWeight"),l=e.get(o),s=l==null?void 0:l.get(a);if(!s)throw new Error("Unreachable. attributeUsedIndexSetMap does not know the skin index attribute or the skin weight attribute.");for(let u of s)n.set(i.bones[u],i.boneInverses[u]);return n}function rs(t,e){for(let[n,i]of t.entries()){let r=e.get(n);if(r!=null&&!ss(i,r))return!1}return!0}function os(t,e,n){let i=new Map;for(let o of e)i.set(o,i.size);let r=new Map;for(let[o,a]of n.entries()){let l=i.get(a);r.set(l,o)}for(let o=0;o<t.count;o++)for(let a=0;a<t.itemSize;a++){let l=t.getComponent(o,a),s=r.get(l);t.setComponent(o,a,s)}t.needsUpdate=!0}function ss(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 Ue=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 Wi(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 as(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=>Wi(r)):i&&Wi(i))}function zi(t){t.traverse(as)}var ht=T(require("three"),1);function Gi(t,e){var a,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=(a=e==null?void 0:e.experimentalSameBoneCounts)!=null?a:!1,i=[];t.traverse(s=>{s.type==="SkinnedMesh"&&i.push(s)});let r=new Map,o=0;for(let s of i){let d=s.geometry.getAttribute("skinIndex");if(r.has(d))continue;let h=new Map,m=new Map;for(let p=0;p<d.count;p++)for(let c=0;c<d.itemSize;c++){let f=d.getComponent(p,c),g=h.get(f);g==null&&(g=h.size,h.set(f,g),m.set(g,f)),d.setComponent(p,c,g)}d.needsUpdate=!0,r.set(d,m),o=Math.max(o,h.size)}for(let s of i){let d=s.geometry.getAttribute("skinIndex"),h=r.get(d),m=[],p=[],c=n?o:h.size;for(let g=0;g<c;g++){let v=(l=h.get(g))!=null?l:0;m.push(s.skeleton.bones[v]),p.push(s.skeleton.boneInverses[v])}let f=new ht.Skeleton(m,p);s.bind(f,new ht.Matrix4)}}var ji=T(require("three"),1),ct=require("three");function Xi(t){let e=new Map;t.traverse(n=>{var g,v,L,x;if(!n.isMesh)return;let i=n,r=i.geometry,o=r.index;if(o==null)return;let a=e.get(r);if(a!=null){i.geometry=a;return}let l=Object.values(r.attributes)[0].count,s=new Array(l),u=0,d=o.array;for(let _=0;_<d.length;_++){let E=d[_];s[E]||(s[E]=!0,u++)}if(u===l)return;let h=[],m=[],p=0;for(let _=0;_<s.length;_++)if(s[_]){let E=p++;h[_]=E,m[E]=_}let c=new ji.BufferGeometry;c.name=r.name,c.morphTargetsRelative=r.morphTargetsRelative,r.groups.forEach(_=>{c.addGroup(_.start,_.count,_.materialIndex)}),c.boundingBox=(v=(g=r.boundingBox)==null?void 0:g.clone())!=null?v:null,c.boundingSphere=(x=(L=r.boundingSphere)==null?void 0:L.clone())!=null?x:null,c.setDrawRange(r.drawRange.start,r.drawRange.count),c.userData=r.userData,e.set(r,c);{let _=o.array,E=new _.constructor(_.length);for(let M=0;M<_.length;M++){let R=_[M],w=h[R];E[M]=w}c.setIndex(new ct.BufferAttribute(E,1,!1))}Object.keys(r.attributes).forEach(_=>{let E=r.attributes[_];if(E.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let M=E.array,{itemSize:R,normalized:w}=E,b=new M.constructor(m.length*R);m.forEach((A,P)=>{for(let H=0;H<R;H++)b[P*R+H]=M[A*R+H]}),c.setAttribute(_,new ct.BufferAttribute(b,R,w))});let f=!0;Object.keys(r.morphAttributes).forEach(_=>{c.morphAttributes[_]=[];let E=r.morphAttributes[_];for(let M=0;M<E.length;M++){let R=E[M];if(R.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let w=R.array,{itemSize:b,normalized:A}=R,P=new w.constructor(m.length*b);m.forEach((H,W)=>{for(let z=0;z<b;z++)P[W*b+z]=w[H*b+z]}),f=f&&P.every(H=>H===0),c.morphAttributes[_][M]=new ct.BufferAttribute(P,b,A)}}),f&&(c.morphAttributes={}),i.geometry=c}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function Qi(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var K=class{constructor(){}};K.combineMorphs=Fi,K.combineSkeletons=ki,K.deepDispose=zi,K.removeUnnecessaryJoints=Gi,K.removeUnnecessaryVertices=Xi,K.rotateVRM0=Qi;
925
925
  /*!
926
- * @pixiv/three-vrm-core v3.3.5
926
+ * @pixiv/three-vrm-core v3.3.6
927
927
  * The implementation of core features of VRM, for @pixiv/three-vrm
928
928
  *
929
929
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -931,7 +931,7 @@ void main() {
931
931
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
932
932
  */
933
933
  /*!
934
- * @pixiv/three-vrm-materials-mtoon v3.3.5
934
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
935
935
  * MToon (toon material) module for @pixiv/three-vrm
936
936
  *
937
937
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -939,7 +939,7 @@ void main() {
939
939
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
940
940
  */
941
941
  /*!
942
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.5
942
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.6
943
943
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
944
944
  *
945
945
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -947,7 +947,7 @@ void main() {
947
947
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
948
948
  */
949
949
  /*!
950
- * @pixiv/three-vrm-materials-v0compat v3.3.5
950
+ * @pixiv/three-vrm-materials-v0compat v3.3.6
951
951
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
952
952
  *
953
953
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -955,7 +955,7 @@ void main() {
955
955
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
956
956
  */
957
957
  /*!
958
- * @pixiv/three-vrm-node-constraint v3.3.5
958
+ * @pixiv/three-vrm-node-constraint v3.3.6
959
959
  * Node constraint module for @pixiv/three-vrm
960
960
  *
961
961
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -963,7 +963,7 @@ void main() {
963
963
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
964
964
  */
965
965
  /*!
966
- * @pixiv/three-vrm-springbone v3.3.5
966
+ * @pixiv/three-vrm-springbone v3.3.6
967
967
  * Spring bone module for @pixiv/three-vrm
968
968
  *
969
969
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm v3.3.5
2
+ * @pixiv/three-vrm v3.3.6
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6619,7 +6619,7 @@ export {
6619
6619
  VRMUtils
6620
6620
  };
6621
6621
  /*!
6622
- * @pixiv/three-vrm-core v3.3.5
6622
+ * @pixiv/three-vrm-core v3.3.6
6623
6623
  * The implementation of core features of VRM, for @pixiv/three-vrm
6624
6624
  *
6625
6625
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6627,7 +6627,7 @@ export {
6627
6627
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6628
6628
  */
6629
6629
  /*!
6630
- * @pixiv/three-vrm-materials-mtoon v3.3.5
6630
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
6631
6631
  * MToon (toon material) module for @pixiv/three-vrm
6632
6632
  *
6633
6633
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6635,7 +6635,7 @@ export {
6635
6635
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6636
6636
  */
6637
6637
  /*!
6638
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.5
6638
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.6
6639
6639
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
6640
6640
  *
6641
6641
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6643,7 +6643,7 @@ export {
6643
6643
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6644
6644
  */
6645
6645
  /*!
6646
- * @pixiv/three-vrm-materials-v0compat v3.3.5
6646
+ * @pixiv/three-vrm-materials-v0compat v3.3.6
6647
6647
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
6648
6648
  *
6649
6649
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6651,7 +6651,7 @@ export {
6651
6651
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6652
6652
  */
6653
6653
  /*!
6654
- * @pixiv/three-vrm-node-constraint v3.3.5
6654
+ * @pixiv/three-vrm-node-constraint v3.3.6
6655
6655
  * Node constraint module for @pixiv/three-vrm
6656
6656
  *
6657
6657
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6659,7 +6659,7 @@ export {
6659
6659
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6660
6660
  */
6661
6661
  /*!
6662
- * @pixiv/three-vrm-springbone v3.3.5
6662
+ * @pixiv/three-vrm-springbone v3.3.6
6663
6663
  * Spring bone module for @pixiv/three-vrm
6664
6664
  *
6665
6665
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -923,7 +923,7 @@ void main() {
923
923
  `)+`
924
924
  `;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(w.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===$n.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},Xr=new Set(["1.0","1.0-beta"]),ei=class We{get name(){return We.EXTENSION_NAME}constructor(e,n={}){var i,r,o,a;this.parser=e,this.materialType=(i=n.materialType)!=null?i:jr,this.renderOrderOffset=(r=n.renderOrderOffset)!=null?r:0,this.v0CompatShade=(o=n.v0CompatShade)!=null?o:!1,this.debugMode=(a=n.debugMode)!=null?a:"none",this._mToonMaterialSet=new Set}beforeRoot(){return le(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return le(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 le(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 a=o.primitives,l=yield i.loadMesh(e);if(a.length===1){let s=l,u=a[0].material;u!=null&&this._setupPrimitive(s,u)}else{let s=l;for(let u=0;u<a.length;u++){let d=s.children[u],h=a[u].material;h!=null&&this._setupPrimitive(d,h)}}return l})}_removeUnlitExtensionIfMToonExists(){let i=this.parser.json.materials;i==null||i.map((r,o)=>{var a;this._getMToonExtension(o)&&((a=r.extensions)!=null&&a.KHR_materials_unlit)&&delete r.extensions.KHR_materials_unlit})}_getMToonExtension(e){var n,i;let a=(n=this.parser.json.materials)==null?void 0:n[e];if(a==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=a.extensions)==null?void 0:i[We.EXTENSION_NAME];if(l==null)return;let s=l.specVersion;if(!Xr.has(s)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${We.EXTENSION_NAME} specVersion "${s}"`);return}return l}_extendMaterialParams(e,n){return le(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new Fr(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 ze.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=ze.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)}};ei.EXTENSION_NAME="VRMC_materials_mtoon";var ti=ei;var Qr=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),ni=class gt{get name(){return gt.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return Qr(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 a=(n=this.parser.json.materials)==null?void 0:n[e];if(a==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}let l=(i=a.extensions)==null?void 0:i[gt.EXTENSION_NAME];if(l!=null)return l}};ni.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var ii=ni;import*as ai from"three";var Yr=Object.defineProperty,qr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,ri=Object.getOwnPropertySymbols,Zr=Object.prototype.hasOwnProperty,Jr=Object.prototype.propertyIsEnumerable,oi=(t,e,n)=>e in t?Yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,j=(t,e)=>{for(var n in e||(e={}))Zr.call(e,n)&&oi(t,n,e[n]);if(ri)for(var n of ri(e))Jr.call(e,n)&&oi(t,n,e[n]);return t},si=(t,e)=>qr(t,$r(e)),Kr=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())});function fe(t){return Math.pow(t,2.2)}var li=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 Kr(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 a,l;let s=(a=e.materials)==null?void 0:a[o];if(s==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,s);e.materials[o]=u}else if((l=r.shader)!=null&&l.startsWith("VRM/Unlit")){let u=this._parseV0UnlitProperties(r,s);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,a,l,s,u,d,h,m,p,c,f,g,v,A,T,_,E,M,R,y,L,P,S,b,k,W,Ee,Y,z,ce,Me,U,bt,Ht,It,Vt,Ct,Ut,Ot,Nt,Bt,Dt,Ft,kt,Wt,zt,Gt,jt,Xt,Qt,Yt,qt;let $t=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,Vi=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&$t,Ci=this._v0ParseRenderQueue(t),Zt=(a=(o=t.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?a:!1,Ui=$t?"BLEND":Zt?"MASK":"OPAQUE",Oi=Zt?(s=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?s:.5:void 0,Ni=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,oe=this._portTextureTransform(t),Bi=((m=(h=t.vectorProperties)==null?void 0:h._Color)!=null?m:[1,1,1,1]).map((an,lr)=>lr===3?an:fe(an)),Jt=(p=t.textureProperties)==null?void 0:p._MainTex,Di=Jt!=null?{index:Jt,extensions:j({},oe)}:void 0,Fi=(f=(c=t.floatProperties)==null?void 0:c._BumpScale)!=null?f:1,Kt=(g=t.textureProperties)==null?void 0:g._BumpMap,ki=Kt!=null?{index:Kt,scale:Fi,extensions:j({},oe)}:void 0,Wi=((A=(v=t.vectorProperties)==null?void 0:v._EmissionColor)!=null?A:[0,0,0,1]).map(fe),en=(T=t.textureProperties)==null?void 0:T._EmissionMap,zi=en!=null?{index:en,extensions:j({},oe)}:void 0,Gi=((E=(_=t.vectorProperties)==null?void 0:_._ShadeColor)!=null?E:[.97,.81,.86,1]).map(fe),tn=(M=t.textureProperties)==null?void 0:M._ShadeTexture,ji=tn!=null?{index:tn,extensions:j({},oe)}:void 0,Ce=(y=(R=t.floatProperties)==null?void 0:R._ShadeShift)!=null?y:0,Ue=(P=(L=t.floatProperties)==null?void 0:L._ShadeToony)!=null?P:.9;Ue=ai.MathUtils.lerp(Ue,1,.5+.5*Ce),Ce=-Ce-(1-Ue);let nn=(b=(S=t.floatProperties)==null?void 0:S._IndirectLightIntensity)!=null?b:.1,Xi=nn?1-nn:void 0,qe=(k=t.textureProperties)==null?void 0:k._SphereAdd,Qi=qe!=null?[1,1,1]:void 0,Yi=qe!=null?{index:qe}:void 0,qi=(Ee=(W=t.floatProperties)==null?void 0:W._RimLightingMix)!=null?Ee:0,rn=(Y=t.textureProperties)==null?void 0:Y._RimTexture,$i=rn!=null?{index:rn,extensions:j({},oe)}:void 0,Zi=((ce=(z=t.vectorProperties)==null?void 0:z._RimColor)!=null?ce:[0,0,0,1]).map(fe),Ji=(U=(Me=t.floatProperties)==null?void 0:Me._RimFresnelPower)!=null?U:1,Ki=(Ht=(bt=t.floatProperties)==null?void 0:bt._RimLift)!=null?Ht:0,er=["none","worldCoordinates","screenCoordinates"][(Vt=(It=t.floatProperties)==null?void 0:It._OutlineWidthMode)!=null?Vt:0],$e=(Ut=(Ct=t.floatProperties)==null?void 0:Ct._OutlineWidth)!=null?Ut:0;$e=.01*$e;let on=(Ot=t.textureProperties)==null?void 0:Ot._OutlineWidthTexture,tr=on!=null?{index:on,extensions:j({},oe)}:void 0,nr=((Bt=(Nt=t.vectorProperties)==null?void 0:Nt._OutlineColor)!=null?Bt:[0,0,0]).map(fe),ir=((Ft=(Dt=t.floatProperties)==null?void 0:Dt._OutlineColorMode)!=null?Ft:0)===1?(Wt=(kt=t.floatProperties)==null?void 0:kt._OutlineLightingMix)!=null?Wt:1:0,sn=(zt=t.textureProperties)==null?void 0:zt._UvAnimMaskTexture,rr=sn!=null?{index:sn,extensions:j({},oe)}:void 0,or=(jt=(Gt=t.floatProperties)==null?void 0:Gt._UvAnimScrollX)!=null?jt:0,Oe=(Qt=(Xt=t.floatProperties)==null?void 0:Xt._UvAnimScrollY)!=null?Qt:0;Oe!=null&&(Oe=-Oe);let sr=(qt=(Yt=t.floatProperties)==null?void 0:Yt._UvAnimRotation)!=null?qt:0,ar={specVersion:"1.0",transparentWithZWrite:Vi,renderQueueOffsetNumber:Ci,shadeColorFactor:Gi,shadeMultiplyTexture:ji,shadingShiftFactor:Ce,shadingToonyFactor:Ue,giEqualizationFactor:Xi,matcapFactor:Qi,matcapTexture:Yi,rimLightingMixFactor:qi,rimMultiplyTexture:$i,parametricRimColorFactor:Zi,parametricRimFresnelPowerFactor:Ji,parametricRimLiftFactor:Ki,outlineWidthMode:er,outlineWidthFactor:$e,outlineWidthMultiplyTexture:tr,outlineColorFactor:nr,outlineLightingMixFactor:ir,uvAnimationMaskTexture:rr,uvAnimationScrollXSpeedFactor:or,uvAnimationScrollYSpeedFactor:Oe,uvAnimationRotationSpeedFactor:sr};return si(j({},e),{pbrMetallicRoughness:{baseColorFactor:Bi,baseColorTexture:Di},normalTexture:ki,emissiveTexture:zi,emissiveFactor:Wi,alphaMode:Ui,alphaCutoff:Oi,doubleSided:Ni,extensions:{VRMC_materials_mtoon:ar}})}_parseV0UnlitProperties(t,e){var n,i,r,o,a;let l=t.shader==="VRM/UnlitTransparentZWrite",s=t.shader==="VRM/UnlitTransparent"||l,u=this._v0ParseRenderQueue(t),d=t.shader==="VRM/UnlitCutout",h=s?"BLEND":d?"MASK":"OPAQUE",m=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,p=this._portTextureTransform(t),c=((o=(r=t.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(fe),f=(a=t.textureProperties)==null?void 0:a._MainTex,g=f!=null?{index:f,extensions:j({},p)}:void 0,v={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:c,shadeMultiplyTexture:g};return si(j({},e),{pbrMetallicRoughness:{baseColorFactor:c,baseColorTexture:g},alphaMode:h,alphaCutoff:m,extensions:{VRMC_materials_mtoon:v}})}_portTextureTransform(t){var e,n,i,r,o;let a=(e=t.vectorProperties)==null?void 0:e._MainTex;if(a==null)return{};let l=[(n=a==null?void 0:a[0])!=null?n:0,(i=a==null?void 0:a[1])!=null?i:0],s=[(r=a==null?void 0:a[2])!=null?r:1,(o=a==null?void 0:a[3])!=null?o:1];return l[1]=1-s[1]-l[1],{KHR_texture_transform:{offset:l,scale:s}}}_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,a=0;if(r){let l=t.renderQueue;l!=null&&(o?a=this._renderQueueMapTransparentZWrite.get(l):a=this._renderQueueMapTransparent.get(l))}return a}_populateRenderQueueMap(t){let e=new Set,n=new Set;t.forEach(i=>{var r,o;let a=i.shader==="VRM/UnlitTransparentZWrite",l=((r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null||i.shader==="VRM/UnlitTransparent"||a,s=((o=i.floatProperties)==null?void 0:o._ZWrite)===1||a;if(l){let u=i.renderQueue;u!=null&&(s?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)})}};import*as O from"three";import*as X from"three";import*as vt from"three";import*as Ae from"three";import*as $ from"three";var ui=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),ee=new O.Vector3,_t=class extends O.Group{constructor(t){super(),this._attrPosition=new O.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(O.DynamicDrawUsage);let e=new O.BufferGeometry;e.setAttribute("position",this._attrPosition);let n=new O.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new O.Line(e,n),this.add(this._line),this.constraint=t}updateMatrixWorld(t){ee.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,ee.x,ee.y,ee.z),this.constraint.source&&ee.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,ee.x,ee.y,ee.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};function di(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var eo=new vt.Vector3,to=new vt.Vector3;function no(t,e){return t.decompose(eo,e,to),e}function Ge(t){return t.invert?t.invert():t.inverse(),t}var Et=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},io=new X.Vector3,ro=new X.Vector3,oo=new X.Vector3,so=new X.Quaternion,ao=new X.Quaternion,lo=new X.Quaternion,uo=class extends Et{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 X.Vector3(1,0,0),this._dstRestQuat=new X.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=so.identity(),e=ao.identity();this.destination.parent&&(no(this.destination.parent.matrixWorld,t),Ge(e.copy(t)));let n=io.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=di(this.source.matrixWorld,ro).sub(di(this.destination.matrixWorld,oo)).normalize(),r=lo.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function ho(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var co=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)ho(o,a=>{let l=this._objectConstraintsMap.get(a);if(l)for(let s of l)this._processConstraint(s,e,n,i)});i(t),n.add(t)}},po=new Ae.Quaternion,mo=new Ae.Quaternion,fo=class extends Et{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new Ae.Quaternion,this._invSrcRestQuat=new Ae.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Ge(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=po.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=mo.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},go=new $.Vector3,_o=new $.Quaternion,vo=new $.Quaternion,Eo=class extends Et{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 $.Vector3(1,0,0),this._dstRestQuat=new $.Quaternion,this._invDstRestQuat=new $.Quaternion,this._invSrcRestQuatMulDstRestQuat=new $.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Ge(this._invDstRestQuat.copy(this._dstRestQuat)),Ge(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=_o.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=go.copy(this._v3RollAxis).applyQuaternion(t),i=vo.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},Mo=new Set(["1.0","1.0-beta"]),hi=class Pe{get name(){return Pe.EXTENSION_NAME}constructor(e,n){this.parser=e,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(e){return ui(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return ui(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(Pe.EXTENSION_NAME))!==-1))return null;let o=new co,a=yield this.parser.getDependencies("node");return a.forEach((l,s)=>{var u;let d=i.nodes[s],h=(u=d==null?void 0:d.extensions)==null?void 0:u[Pe.EXTENSION_NAME];if(h==null)return;let m=h.specVersion;if(!Mo.has(m)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Pe.EXTENSION_NAME} specVersion "${m}"`);return}let p=h.constraint;if(p.roll!=null){let c=this._importRollConstraint(l,a,p.roll);o.addConstraint(c)}else if(p.aim!=null){let c=this._importAimConstraint(l,a,p.aim);o.addConstraint(c)}else if(p.rotation!=null){let c=this._importRotationConstraint(l,a,p.rotation);o.addConstraint(c)}}),e.scene.updateMatrixWorld(),o.setInitState(),o})}_importRollConstraint(e,n,i){let{source:r,rollAxis:o,weight:a}=i,l=n[r],s=new Eo(e,l);if(o!=null&&(s.rollAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new _t(s);this.helperRoot.add(u)}return s}_importAimConstraint(e,n,i){let{source:r,aimAxis:o,weight:a}=i,l=n[r],s=new uo(e,l);if(o!=null&&(s.aimAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new _t(s);this.helperRoot.add(u)}return s}_importRotationConstraint(e,n,i){let{source:r,weight:o}=i,a=n[r],l=new fo(e,a);if(o!=null&&(l.weight=o),this.helperRoot){let s=new _t(l);this.helperRoot.add(s)}return l}};hi.EXTENSION_NAME="VRMC_node_constraint";var ci=hi;import*as ne from"three";import*as Ie from"three";import*as ve from"three";import*as Pt from"three";import*as Z from"three";import*as te from"three";import*as de from"three";import*as ie from"three";import*as he from"three";import*as Xe from"three";import*as C from"three";import*as Ei from"three";import*as Mi from"three";import*as B from"three";var je=(t,e,n)=>new Promise((i,r)=>{var o=s=>{try{l(n.next(s))}catch(u){r(u)}},a=s=>{try{l(n.throw(s))}catch(u){r(u)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((n=n.apply(t,e)).next())}),St=class{},Mt=new Ie.Vector3,ue=new Ie.Vector3,gi=class extends St{get type(){return"capsule"}constructor(t){var e,n,i,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Ie.Vector3(0,0,0),this.tail=(n=t==null?void 0:t.tail)!=null?n:new Ie.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){Mt.setFromMatrixPosition(t),ue.subVectors(this.tail,this.offset).applyMatrix4(t),ue.sub(Mt);let r=ue.lengthSq();i.copy(e).sub(Mt);let o=ue.dot(i);o<=0||(r<=o||ue.multiplyScalar(o/r),i.sub(ue));let a=i.length(),l=this.inside?this.radius-n-a:a-n-this.radius;return l<0&&(i.multiplyScalar(1/a),this.inside&&i.negate()),l}},Rt=new ve.Vector3,pi=new ve.Matrix3,_i=class extends St{get type(){return"plane"}constructor(t){var e,n;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ve.Vector3(0,0,0),this.normal=(n=t==null?void 0:t.normal)!=null?n:new ve.Vector3(0,0,1)}calculateCollision(t,e,n,i){i.setFromMatrixPosition(t),i.negate().add(e),pi.getNormalMatrix(t),Rt.copy(this.normal).applyNormalMatrix(pi).normalize();let r=i.dot(Rt)-n;return i.copy(Rt),r}},Ro=new Pt.Vector3,vi=class extends St{get type(){return"sphere"}constructor(t){var e,n,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Pt.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,Ro.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}},Q=new Z.Vector3,To=class extends Z.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Z.Vector3,this._currentTail=new Z.Vector3,this._shape=t,this._attrPos=new Z.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Z.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=Q.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),t=!0),t&&this._buildPosition()}_buildPosition(){Q.copy(this._currentTail).sub(this._currentOffset);let t=Q.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(Q.y,Math.sqrt(Q.x*Q.x+Q.z*Q.z)),n=-Math.atan2(Q.z,Q.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}},xo=class extends te.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentOffset=new te.Vector3,this._currentNormal=new te.Vector3,this._shape=t,this._attrPos=new te.BufferAttribute(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new te.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}},yo=class extends de.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new de.Vector3,this._shape=t,this._attrPos=new de.BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new de.BufferAttribute(new Uint16Array(64*3),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}},wo=new ne.Vector3,Tt=class extends ne.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof vi)this._geometry=new yo(this.collider.shape);else if(this.collider.shape instanceof gi)this._geometry=new To(this.collider.shape);else if(this.collider.shape instanceof _i)this._geometry=new xo(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new ne.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new ne.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=wo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},So=class extends he.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new he.Vector3,this._springBone=t,this._attrPos=new he.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new he.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}},Po=new ie.Vector3,Ao=class extends ie.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new So(this.springBone);let e=new ie.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new ie.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=Po.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},xt=class extends Xe.Object3D{constructor(t){super(),this.colliderMatrix=new Xe.Matrix4,this.shape=t}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),Lo(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Lo(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 bo=new Mi.Matrix4;function Ho(t){return t.invert?t.invert():t.getInverse(bo.copy(t)),t}var Io=class{constructor(t){this._inverseCache=new Ei.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&&(Ho(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},yt=new C.Matrix4,ge=new C.Vector3,Le=new C.Vector3,be=new C.Vector3,He=new C.Vector3,Vo=new C.Matrix4,Co=class{constructor(t,e,n={},i=[]){this._currentTail=new C.Vector3,this._prevTail=new C.Vector3,this._boneAxis=new C.Vector3,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new C.Matrix4,this._initialLocalRotation=new C.Quaternion,this._initialLocalChildPosition=new C.Vector3;var r,o,a,l,s,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:(a=n.gravityPower)!=null?a:0,gravityDir:(s=(l=n.gravityDir)==null?void 0:l.clone())!=null?s:new C.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 Io(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:yt}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=Le.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);He.copy(this._currentTail).add(ge.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),be.setFromMatrixPosition(this.bone.matrixWorld),He.sub(be).normalize().multiplyScalar(this._worldSpaceBoneLength).add(be),this._collision(He),this._prevTail.copy(this._currentTail),this._currentTail.copy(He).applyMatrix4(this._getMatrixWorldToCenter());let n=Vo.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,ge.copy(He).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,ge);if(r<0){t.addScaledVector(ge,-r),t.sub(be);let o=t.length();t.multiplyScalar(this._worldSpaceBoneLength/o).add(be)}}}_calcWorldSpaceBoneLength(){ge.setFromMatrixPosition(this.bone.matrixWorld),this.child?Le.setFromMatrixPosition(this.child.matrixWorld):(Le.copy(this._initialLocalChildPosition),Le.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=ge.sub(Le).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:yt}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:yt}};function Uo(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function wt(t,e){t.children.forEach(n=>{e(n)||wt(n,e)})}function Oo(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 mi=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),wt(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=Oo(i);this._ancestors=[],r&&(this._ancestors.push(r),wt(r,o=>{var a,l;return((l=(a=this._objectSpringBonesMap.get(o))==null?void 0:a.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 a of o){let l=!1,s=null;Uo(a,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||(s=u)}),s&&r.add(s)}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)}},fi="VRMC_springBone_extended_collider",No=new Set(["1.0","1.0-beta"]),Bo=new Set(["1.0"]),Ri=class _e{get name(){return _e.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 je(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return je(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 je(this,null,function*(){var n,i,r,o,a;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(_e.EXTENSION_NAME))!==-1))return null;let u=new mi,d=yield e.parser.getDependencies("node"),h=(i=l.extensions)==null?void 0:i[_e.EXTENSION_NAME];if(!h)return null;let m=h.specVersion;if(!No.has(m))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${_e.EXTENSION_NAME} specVersion "${m}"`),null;let p=(r=h.colliders)==null?void 0:r.map((f,g)=>{var v,A,T,_,E,M,R,y,L,P,S,b,k,W,Ee;let Y=d[f.node];if(Y==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${g} attempted to use the node #${f.node} but not found`),null;let z=f.shape,ce=(v=f.extensions)==null?void 0:v[fi];if(this.useExtendedColliders&&ce!=null){let Me=ce.specVersion;if(!Bo.has(Me))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${fi} specVersion "${Me}". Fallbacking to the ${_e.EXTENSION_NAME} definition`);else{let U=ce.shape;if(U.sphere)return this._importSphereCollider(Y,{offset:new B.Vector3().fromArray((A=U.sphere.offset)!=null?A:[0,0,0]),radius:(T=U.sphere.radius)!=null?T:0,inside:(_=U.sphere.inside)!=null?_:!1});if(U.capsule)return this._importCapsuleCollider(Y,{offset:new B.Vector3().fromArray((E=U.capsule.offset)!=null?E:[0,0,0]),radius:(M=U.capsule.radius)!=null?M:0,tail:new B.Vector3().fromArray((R=U.capsule.tail)!=null?R:[0,0,0]),inside:(y=U.capsule.inside)!=null?y:!1});if(U.plane)return this._importPlaneCollider(Y,{offset:new B.Vector3().fromArray((L=U.plane.offset)!=null?L:[0,0,0]),normal:new B.Vector3().fromArray((P=U.plane.normal)!=null?P:[0,0,1])})}}if(z.sphere)return this._importSphereCollider(Y,{offset:new B.Vector3().fromArray((S=z.sphere.offset)!=null?S:[0,0,0]),radius:(b=z.sphere.radius)!=null?b:0,inside:!1});if(z.capsule)return this._importCapsuleCollider(Y,{offset:new B.Vector3().fromArray((k=z.capsule.offset)!=null?k:[0,0,0]),radius:(W=z.capsule.radius)!=null?W:0,tail:new B.Vector3().fromArray((Ee=z.capsule.tail)!=null?Ee:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${g} has no valid shape`)}),c=(o=h.colliderGroups)==null?void 0:o.map((f,g)=>{var v;return{colliders:((v=f.colliders)!=null?v:[]).flatMap(T=>{let _=p==null?void 0:p[T];return _==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${g} attempted to use a collider #${T} but not found`),[]):_}),name:f.name}});return(a=h.springs)==null||a.forEach((f,g)=>{var v;let A=f.joints,T=(v=f.colliderGroups)==null?void 0:v.map(M=>{let R=c==null?void 0:c[M];if(R==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to use a colliderGroup ${M} but not found`);return R}),_=f.center!=null?d[f.center]:void 0,E;A.forEach(M=>{if(E){let R=E.node,y=d[R],L=M.node,P=d[L],S={hitRadius:E.hitRadius,dragForce:E.dragForce,gravityPower:E.gravityPower,stiffness:E.stiffness,gravityDir:E.gravityDir!=null?new B.Vector3().fromArray(E.gravityDir):void 0},b=this._importJoint(y,P,S,T);_&&(b.center=_),u.addJoint(b)}E=M})}),u.setInitState(),u})}_v0Import(e){return je(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,s=l==null?void 0:l.secondaryAnimation;if(!s)return null;let u=s==null?void 0:s.boneGroups;if(!u)return null;let d=new mi,h=yield e.parser.getDependencies("node"),m=(r=s.colliderGroups)==null?void 0:r.map(p=>{var c;let f=h[p.node];return{colliders:((c=p.colliders)!=null?c:[]).map((v,A)=>{var T,_,E;let M=new B.Vector3(0,0,0);return v.offset&&M.set((T=v.offset.x)!=null?T:0,(_=v.offset.y)!=null?_:0,v.offset.z?-v.offset.z:0),this._importSphereCollider(f,{offset:M,radius:(E=v.radius)!=null?E:0,inside:!1})})}});return u==null||u.forEach((p,c)=>{let f=p.bones;f&&f.forEach(g=>{var v,A,T,_;let E=h[g],M=new B.Vector3;p.gravityDir?M.set((v=p.gravityDir.x)!=null?v:0,(A=p.gravityDir.y)!=null?A:0,(T=p.gravityDir.z)!=null?T:0):M.set(0,-1,0);let R=p.center!=null?h[p.center]:void 0,y={hitRadius:p.hitRadius,dragForce:p.dragForce,gravityPower:p.gravityPower,stiffness:p.stiffiness,gravityDir:M},L=(_=p.colliderGroups)==null?void 0:_.map(P=>{let S=m==null?void 0:m[P];if(S==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${c} attempted to use a colliderGroup ${P} but not found`);return S});E.traverse(P=>{var S;let b=(S=P.children[0])!=null?S:null,k=this._importJoint(P,b,y,L);R&&(k.center=R),d.addJoint(k)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let o=new Co(e,n,i,r);if(this.jointHelperRoot){let a=new Ao(o);this.jointHelperRoot.add(a),a.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(e,n){let i=new vi(n),r=new xt(i);if(e.add(r),this.colliderHelperRoot){let o=new Tt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,n){let i=new gi(n),r=new xt(i);if(e.add(r),this.colliderHelperRoot){let o=new Tt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,n){let i=new _i(n),r=new xt(i);if(e.add(r),this.colliderHelperRoot){let o=new Tt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}};Ri.EXTENSION_NAME="VRMC_springBone";var Ti=Ri;var At=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var o,a,l,s,u,d,h,m,p,c;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 at(e),this.firstPersonPlugin=(a=n==null?void 0:n.firstPersonPlugin)!=null?a:new ut(e),this.humanoidPlugin=(l=n==null?void 0:n.humanoidPlugin)!=null?l:new dt(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(s=n==null?void 0:n.lookAtPlugin)!=null?s:new ct(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new pt(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new ti(e),this.materialsHDREmissiveMultiplierPlugin=(h=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?h:new ii(e),this.materialsV0CompatPlugin=(m=n==null?void 0:n.materialsV0CompatPlugin)!=null?m:new li(e),this.springBonePlugin=(p=n==null?void 0:n.springBonePlugin)!=null?p:new Ti(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(c=n==null?void 0:n.nodeConstraintPlugin)!=null?c:new ci(e,{helperRoot:i})}beforeRoot(){return Re(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return Re(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 Re(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,n),yield this.mtoonMaterialPlugin.extendMaterialParams(e,n)})}afterRoot(e){return Re(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 Se({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}})}};import*as yi from"three";function Do(t){let e=new Set;return t.traverse(n=>{if(!n.isMesh)return;let i=n;e.add(i)}),e}function xi(t,e,n){if(e.size===1){let a=e.values().next().value;if(a.weight===1)return t[a.index]}let i=new Float32Array(t[0].count*3),r=0;if(n)r=1;else for(let a of e)r+=a.weight;for(let a of e){let l=t[a.index],s=a.weight/r;for(let u=0;u<l.count;u++)i[u*3+0]+=l.getX(u)*s,i[u*3+1]+=l.getY(u)*s,i[u*3+2]+=l.getZ(u)*s}return new yi.BufferAttribute(i,3)}function wi(t){var r;let e=Do(t.scene),n=new Map,i=(r=t.expressionManager)==null?void 0:r.expressionMap;if(i!=null)for(let[o,a]of Object.entries(i)){let l=new Set;for(let s of a.binds)if(s instanceof ye){if(s.weight!==0)for(let u of s.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(s)}l.add(s)}for(let s of l)a.deleteBind(s)}for(let o of e){let a=n.get(o);if(a==null)continue;let l=o.geometry.morphAttributes;o.geometry.morphAttributes={};let s=o.geometry.clone();o.geometry=s;let u=s.morphTargetsRelative,d=l.position!=null,h=l.normal!=null,m={},p={},c=[];if(d||h){d&&(m.position=[]),h&&(m.normal=[]);let f=0;for(let[g,v]of a)d&&(m.position[f]=xi(l.position,v,u)),h&&(m.normal[f]=xi(l.normal,v,u)),i==null||i[g].addBind(new ye({index:f,weight:1,primitives:[o]})),p[g]=f,c.push(0),f++}s.morphAttributes=m,o.morphTargetDictionary=p,o.morphTargetInfluences=c}}import*as Qe from"three";function Si(t){var u;let e=Fo(t),n=new Map;for(let d of e){let h=d.geometry,m=h.getAttribute("skinIndex"),p=(u=n.get(m))!=null?u:new Map;n.set(m,p);let c=h.getAttribute("skinWeight"),f=ko(m,c);p.set(c,f)}let i=new Map;for(let d of e){let h=Wo(d,n);i.set(d,h)}let r=[];for(let[d,h]of i){let m=!1;for(let p of r)if(zo(h,p.boneInverseMap)){m=!0,p.meshes.add(d);for(let[f,g]of h)p.boneInverseMap.set(f,g);break}m||r.push({boneInverseMap:h,meshes:new Set([d])})}let o=new Map,a=new Ve,l=new Ve,s=new Ve;for(let d of r){let{boneInverseMap:h,meshes:m}=d,p=Array.from(h.keys()),c=Array.from(h.values()),f=new Qe.Skeleton(p,c),g=l.getOrCreate(f);for(let v of m){let A=v.geometry.getAttribute("skinIndex"),T=a.getOrCreate(A),_=v.skeleton.bones,E=_.map(y=>s.getOrCreate(y)).join(","),M=`${T};${g};${E}`,R=o.get(M);R==null&&(R=A.clone(),Go(R,_,p),o.set(M,R)),v.geometry.setAttribute("skinIndex",R)}for(let v of m)v.bind(f,new Qe.Matrix4)}}function Fo(t){let e=new Set;return t.traverse(n=>{if(!n.isSkinnedMesh)return;let i=n;e.add(i)}),e}function ko(t,e){let n=new Set;for(let i=0;i<t.count;i++)for(let r=0;r<t.itemSize;r++){let o=t.getComponent(i,r);e.getComponent(i,r)!==0&&n.add(o)}return n}function Wo(t,e){let n=new Map,i=t.skeleton,r=t.geometry,o=r.getAttribute("skinIndex"),a=r.getAttribute("skinWeight"),l=e.get(o),s=l==null?void 0:l.get(a);if(!s)throw new Error("Unreachable. attributeUsedIndexSetMap does not know the skin index attribute or the skin weight attribute.");for(let u of s)n.set(i.bones[u],i.boneInverses[u]);return n}function zo(t,e){for(let[n,i]of t.entries()){let r=e.get(n);if(r!=null&&!jo(i,r))return!1}return!0}function Go(t,e,n){let i=new Map;for(let o of e)i.set(o,i.size);let r=new Map;for(let[o,a]of n.entries()){let l=i.get(a);r.set(l,o)}for(let o=0;o<t.count;o++)for(let a=0;a<t.itemSize;a++){let l=t.getComponent(o,a),s=r.get(l);t.setComponent(o,a,s)}t.needsUpdate=!0}function jo(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 Ve=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 Pi(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 Xo(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=>Pi(r)):i&&Pi(i))}function Ai(t){t.traverse(Xo)}import*as Ye from"three";function Li(t,e){var a,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=(a=e==null?void 0:e.experimentalSameBoneCounts)!=null?a:!1,i=[];t.traverse(s=>{s.type==="SkinnedMesh"&&i.push(s)});let r=new Map,o=0;for(let s of i){let d=s.geometry.getAttribute("skinIndex");if(r.has(d))continue;let h=new Map,m=new Map;for(let p=0;p<d.count;p++)for(let c=0;c<d.itemSize;c++){let f=d.getComponent(p,c),g=h.get(f);g==null&&(g=h.size,h.set(f,g),m.set(g,f)),d.setComponent(p,c,g)}d.needsUpdate=!0,r.set(d,m),o=Math.max(o,h.size)}for(let s of i){let d=s.geometry.getAttribute("skinIndex"),h=r.get(d),m=[],p=[],c=n?o:h.size;for(let g=0;g<c;g++){let v=(l=h.get(g))!=null?l:0;m.push(s.skeleton.bones[v]),p.push(s.skeleton.boneInverses[v])}let f=new Ye.Skeleton(m,p);s.bind(f,new Ye.Matrix4)}}import*as bi from"three";import{BufferAttribute as Lt}from"three";function Hi(t){let e=new Map;t.traverse(n=>{var g,v,A,T;if(!n.isMesh)return;let i=n,r=i.geometry,o=r.index;if(o==null)return;let a=e.get(r);if(a!=null){i.geometry=a;return}let l=Object.values(r.attributes)[0].count,s=new Array(l),u=0,d=o.array;for(let _=0;_<d.length;_++){let E=d[_];s[E]||(s[E]=!0,u++)}if(u===l)return;let h=[],m=[],p=0;for(let _=0;_<s.length;_++)if(s[_]){let E=p++;h[_]=E,m[E]=_}let c=new bi.BufferGeometry;c.name=r.name,c.morphTargetsRelative=r.morphTargetsRelative,r.groups.forEach(_=>{c.addGroup(_.start,_.count,_.materialIndex)}),c.boundingBox=(v=(g=r.boundingBox)==null?void 0:g.clone())!=null?v:null,c.boundingSphere=(T=(A=r.boundingSphere)==null?void 0:A.clone())!=null?T:null,c.setDrawRange(r.drawRange.start,r.drawRange.count),c.userData=r.userData,e.set(r,c);{let _=o.array,E=new _.constructor(_.length);for(let M=0;M<_.length;M++){let R=_[M],y=h[R];E[M]=y}c.setIndex(new Lt(E,1,!1))}Object.keys(r.attributes).forEach(_=>{let E=r.attributes[_];if(E.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let M=E.array,{itemSize:R,normalized:y}=E,L=new M.constructor(m.length*R);m.forEach((P,S)=>{for(let b=0;b<R;b++)L[S*R+b]=M[P*R+b]}),c.setAttribute(_,new Lt(L,R,y))});let f=!0;Object.keys(r.morphAttributes).forEach(_=>{c.morphAttributes[_]=[];let E=r.morphAttributes[_];for(let M=0;M<E.length;M++){let R=E[M];if(R.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let y=R.array,{itemSize:L,normalized:P}=R,S=new y.constructor(m.length*L);m.forEach((b,k)=>{for(let W=0;W<L;W++)S[k*L+W]=y[b*L+W]}),f=f&&S.every(b=>b===0),c.morphAttributes[_][M]=new Lt(S,L,P)}}),f&&(c.morphAttributes={}),i.geometry=c}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function Ii(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var re=class{constructor(){}};re.combineMorphs=wi,re.combineSkeletons=Si,re.deepDispose=Ai,re.removeUnnecessaryJoints=Li,re.removeUnnecessaryVertices=Hi,re.rotateVRM0=Ii;export{jr as MToonMaterial,zr as MToonMaterialDebugMode,ti as MToonMaterialLoaderPlugin,$n as MToonMaterialOutlineWidthMode,Se as VRM,uo as VRMAimConstraint,mt as VRMCore,ts as VRMCoreLoaderPlugin,ln as VRMExpression,at as VRMExpressionLoaderPlugin,hn as VRMExpressionManager,cn as VRMExpressionMaterialColorBind,Te as VRMExpressionMaterialColorType,ye as VRMExpressionMorphTargetBind,Zo as VRMExpressionOverrideType,tt as VRMExpressionPresetName,mn as VRMExpressionTextureTransformBind,fn as VRMFirstPerson,ut as VRMFirstPersonLoaderPlugin,Jo as VRMFirstPersonMeshAnnotationType,Ze as VRMHumanBoneList,Ko as VRMHumanBoneName,mr as VRMHumanBoneParentMap,Mn as VRMHumanoid,vn as VRMHumanoidHelper,dt as VRMHumanoidLoaderPlugin,At as VRMLoaderPlugin,br as VRMLookAt,Fe as VRMLookAtBoneApplier,ot as VRMLookAtExpressionApplier,Tr as VRMLookAtHelper,ct as VRMLookAtLoaderPlugin,Ln as VRMLookAtRangeMap,es as VRMLookAtTypeName,pt as VRMMetaLoaderPlugin,Et as VRMNodeConstraint,_t as VRMNodeConstraintHelper,ci as VRMNodeConstraintLoaderPlugin,co as VRMNodeConstraintManager,_r as VRMRequiredHumanBoneName,Eo as VRMRollConstraint,fo as VRMRotationConstraint,xt as VRMSpringBoneCollider,Tt as VRMSpringBoneColliderHelper,St as VRMSpringBoneColliderShape,gi as VRMSpringBoneColliderShapeCapsule,_i as VRMSpringBoneColliderShapePlane,vi as VRMSpringBoneColliderShapeSphere,Co as VRMSpringBoneJoint,Ao as VRMSpringBoneJointHelper,Ti as VRMSpringBoneLoaderPlugin,mi as VRMSpringBoneManager,re as VRMUtils};
925
925
  /*!
926
- * @pixiv/three-vrm-core v3.3.5
926
+ * @pixiv/three-vrm-core v3.3.6
927
927
  * The implementation of core features of VRM, for @pixiv/three-vrm
928
928
  *
929
929
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -931,7 +931,7 @@ void main() {
931
931
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
932
932
  */
933
933
  /*!
934
- * @pixiv/three-vrm-materials-mtoon v3.3.5
934
+ * @pixiv/three-vrm-materials-mtoon v3.3.6
935
935
  * MToon (toon material) module for @pixiv/three-vrm
936
936
  *
937
937
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -939,7 +939,7 @@ void main() {
939
939
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
940
940
  */
941
941
  /*!
942
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.5
942
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.3.6
943
943
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
944
944
  *
945
945
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -947,7 +947,7 @@ void main() {
947
947
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
948
948
  */
949
949
  /*!
950
- * @pixiv/three-vrm-materials-v0compat v3.3.5
950
+ * @pixiv/three-vrm-materials-v0compat v3.3.6
951
951
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
952
952
  *
953
953
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -955,7 +955,7 @@ void main() {
955
955
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
956
956
  */
957
957
  /*!
958
- * @pixiv/three-vrm-node-constraint v3.3.5
958
+ * @pixiv/three-vrm-node-constraint v3.3.6
959
959
  * Node constraint module for @pixiv/three-vrm
960
960
  *
961
961
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -963,7 +963,7 @@ void main() {
963
963
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
964
964
  */
965
965
  /*!
966
- * @pixiv/three-vrm-springbone v3.3.5
966
+ * @pixiv/three-vrm-springbone v3.3.6
967
967
  * Spring bone module for @pixiv/three-vrm
968
968
  *
969
969
  * Copyright (c) 2019-2025 pixiv Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixiv/three-vrm",
3
- "version": "3.3.5",
3
+ "version": "3.3.6",
4
4
  "description": "VRM file loader for three.js.",
5
5
  "license": "MIT",
6
6
  "author": "pixiv",
@@ -31,8 +31,7 @@
31
31
  "directory": "packages/three-vrm"
32
32
  },
33
33
  "scripts": {
34
- "version": "yarn all",
35
- "all": "yarn test && yarn lint && yarn clean && yarn build && yarn docs",
34
+ "version": "yarn clean && yarn build",
36
35
  "dev": "cross-env SERVE=1 yarn build-dev",
37
36
  "clean": "rimraf docs/ lib/ types/",
38
37
  "build": "yarn build-dev && yarn build-prod && yarn build-types",
@@ -40,7 +39,7 @@
40
39
  "build-dev": "cross-env NODE_ENV=development yarn build-js",
41
40
  "build-prod": "cross-env NODE_ENV=production yarn build-js",
42
41
  "build-types": "tsc --declaration --declarationDir ./types --emitDeclarationOnly",
43
- "docs": "typedoc --entryPoints ./src/index.ts --out docs",
42
+ "docs-legacy": "typedoc --plugin ../../typedoc-redirect-legacy-docs-plugin.mjs",
44
43
  "test": "echo There is no test for three-vrm",
45
44
  "lint": "eslint \"src/**/*.{ts,tsx}\" && yarn lint-examples && prettier \"src/**/*.{ts,tsx}\" --check",
46
45
  "lint-examples": "eslint \"examples/**/*.{js,html}\" --rule \"padded-blocks: error\"",
@@ -56,12 +55,12 @@
56
55
  ]
57
56
  },
58
57
  "dependencies": {
59
- "@pixiv/three-vrm-core": "3.3.5",
60
- "@pixiv/three-vrm-materials-hdr-emissive-multiplier": "3.3.5",
61
- "@pixiv/three-vrm-materials-mtoon": "3.3.5",
62
- "@pixiv/three-vrm-materials-v0compat": "3.3.5",
63
- "@pixiv/three-vrm-node-constraint": "3.3.5",
64
- "@pixiv/three-vrm-springbone": "3.3.5"
58
+ "@pixiv/three-vrm-core": "3.3.6",
59
+ "@pixiv/three-vrm-materials-hdr-emissive-multiplier": "3.3.6",
60
+ "@pixiv/three-vrm-materials-mtoon": "3.3.6",
61
+ "@pixiv/three-vrm-materials-v0compat": "3.3.6",
62
+ "@pixiv/three-vrm-node-constraint": "3.3.6",
63
+ "@pixiv/three-vrm-springbone": "3.3.6"
65
64
  },
66
65
  "devDependencies": {
67
66
  "@types/three": "^0.169.0",
@@ -70,5 +69,5 @@
70
69
  "peerDependencies": {
71
70
  "three": ">=0.137"
72
71
  },
73
- "gitHead": "3446b275735a9edcd0f6362bc446855ed68dcc02"
72
+ "gitHead": "b83ddc31d4b90d49a0fb9ae16851e7d13075f3a9"
74
73
  }