@pixiv/three-vrm 3.4.1 → 3.4.2

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
@@ -32,8 +32,8 @@ You can import all the dependencies via CDN like [jsDelivr](https://www.jsdelivr
32
32
  <script type="importmap">
33
33
  {
34
34
  "imports": {
35
- "three": "https://cdn.jsdelivr.net/npm/three@0.176.0/build/three.module.js",
36
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.176.0/examples/jsm/",
35
+ "three": "https://cdn.jsdelivr.net/npm/three@0.177.0/build/three.module.js",
36
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.177.0/examples/jsm/",
37
37
  "@pixiv/three-vrm": "https://cdn.jsdelivr.net/npm/@pixiv/three-vrm@3/lib/three-vrm.module.min.js"
38
38
  }
39
39
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm v3.4.1
2
+ * @pixiv/three-vrm v3.4.2
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 THREE5.NodeMaterial {
522
522
  }
523
523
  };
524
524
  /*!
525
- * @pixiv/three-vrm-materials-mtoon v3.4.1
525
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
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 Z=Object.create;var x=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var it=(t,i)=>{for(var o in i)x(t,o,{get:i[o],enumerable:!0})},O=(t,i,o,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of J(i))!tt.call(t,n)&&n!==o&&x(t,n,{get:()=>i[n],enumerable:!(r=$(i,n))||r.enumerable});return t};var c=(t,i,o)=>(o=t!=null?Z(Q(t)):{},O(i||!t||!t.__esModule?x(o,"default",{value:t,enumerable:!0}):o,t)),et=t=>O(x({},"__esModule",{value:!0}),t);var At={};it(At,{MToonAnimatedUVNode:()=>X,MToonLightingModel:()=>j,MToonNodeMaterial:()=>Pt});module.exports=et(At);var D=c(require("three"),1),Y=c(require("three/webgpu"),1),h=require("three/tsl"),a=require("three/tsl"),z=c(require("three/webgpu"),1),l=require("three/tsl"),m=c(require("three/webgpu"),1),d=require("three/tsl"),K=c(require("three/tsl"),1),R=c(require("three/webgpu"),1),s=c(require("three/webgpu"),1),e=require("three/tsl"),N=require("three/tsl");var I=parseInt(D.REVISION,10);I<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${I}). This would not work correctly.`);var ot=(0,a.materialReference)("color","color"),rt=(0,a.materialReference)("map","texture"),at=(0,a.materialReference)("normalMap","texture"),nt=(0,a.materialReference)("normalScale","vec2"),lt=(0,a.materialReference)("emissive","color"),st=(0,a.materialReference)("emissiveIntensity","float"),ht=(0,a.materialReference)("emissiveMap","texture"),ut=(0,a.materialReference)("shadeColorFactor","color"),mt=(0,a.materialReference)("shadingShiftFactor","float"),k=(0,a.materialReference)("shadeMultiplyTexture","texture"),dt=(0,a.materialReference)("shadeMultiplyTextureScale","float"),ct=(0,a.materialReference)("shadingToonyFactor","float"),pt=(0,a.materialReference)("rimLightingMixFactor","float"),ft=(0,a.materialReference)("rimMultiplyTexture","texture"),Nt=(0,a.materialReference)("matcapFactor","color"),gt=(0,a.materialReference)("matcapTexture","texture"),vt=(0,a.materialReference)("parametricRimColorFactor","color"),Tt=(0,a.materialReference)("parametricRimLiftFactor","float"),Mt=(0,a.materialReference)("parametricRimFresnelPowerFactor","float"),xt=(0,a.materialReference)("outlineWidthMultiplyTexture","texture"),Rt=(0,a.materialReference)("outlineWidthFactor","float"),b=(0,a.materialReference)("outlineColorFactor","color"),St=(0,a.materialReference)("outlineLightingMixFactor","float"),Ft=(0,a.materialReference)("uvAnimationMaskTexture","texture"),Et=(0,a.materialReference)("uvAnimationScrollXOffset","float"),yt=(0,a.materialReference)("uvAnimationScrollYOffset","float"),Ct=(0,a.materialReference)("uvAnimationRotationPhase","float"),X=class extends Y.TempNode{constructor(t){super("vec2"),this.hasMaskTexture=t}setup(){let t=1;this.hasMaskTexture&&(t=(0,h.vec4)(Ft).context({getUV:()=>(0,h.uv)()}).r);let i=(0,h.uv)(),o=Ct.mul(t),r=(0,h.cos)(o),n=(0,h.sin)(o);i=i.sub((0,h.vec2)(.5,.5)),i=i.mul((0,h.mat2)(r,n,n.negate(),r)),i=i.add((0,h.vec2)(.5,.5));let u=(0,h.vec2)(Et,yt).mul(t);return i=i.add(u),i.toVar("AnimatedUV")}},B=(0,d.nodeImmutable)(m.PropertyNode,"vec3").toVar("ShadeColor"),q=(0,d.nodeImmutable)(m.PropertyNode,"float").toVar("ShadingShift"),G=(0,d.nodeImmutable)(m.PropertyNode,"float").toVar("ShadingToony"),F=(0,d.nodeImmutable)(m.PropertyNode,"float").toVar("RimLightingMix"),E=(0,d.nodeImmutable)(m.PropertyNode,"vec3").toVar("RimMultiply"),y=(0,d.nodeImmutable)(m.PropertyNode,"vec3").toVar("matcap"),C=(0,d.nodeImmutable)(m.PropertyNode,"vec3").toVar("ParametricRim"),S=t=>parseInt(R.REVISION,10)>=168?K.Fn(t):R.tslFn(t),_t=S(({a:t,b:i,t:o})=>{let r=o.sub(t),n=i.sub(t);return r.div(n).clamp()}),Vt=S(({dotNL:t})=>{let o=(0,l.float)(1).sub(G),r=t.add(q);return r=_t({a:o.negate(),b:o,t:r}),r=r.mul(1),r}),Lt=S(({shading:t,lightColor:i})=>{let o=(0,l.mix)(B,l.diffuseColor,t);return i.mul((0,l.BRDF_Lambert)({diffuseColor:o}))}),j=class extends z.LightingModel{constructor(){super()}direct({lightDirection:t,lightColor:i,reflectedLight:o}){let r=l.transformedNormalView.dot(t).clamp(-1,1),n=Vt({dotNL:r});o.directDiffuse.addAssign(Lt({shading:n,lightColor:i})),o.directSpecular.addAssign(C.add(y).mul(E).mul((0,l.mix)((0,l.vec3)(0),(0,l.BRDF_Lambert)({diffuseColor:i}),F)))}indirect(t){let i="context"in t?t.context:t;this.indirectDiffuse(i),this.indirectSpecular(i)}indirectDiffuse(t){let{irradiance:i,reflectedLight:o}=t;o.indirectDiffuse.addAssign(i.mul((0,l.BRDF_Lambert)({diffuseColor:l.diffuseColor})))}indirectSpecular(t){let{reflectedLight:i}=t;i.indirectSpecular.addAssign(C.add(y).mul(E).mul((0,l.mix)((0,l.vec3)(1),(0,l.vec3)(0),F)))}},v={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},wt=S(({parametricRimLift:t,parametricRimFresnelPower:i,parametricRimColor:o})=>{let r=N.modelViewPosition.normalize(),n=N.transformedNormalView.dot(r.negate());return(0,N.float)(1).sub(n).add(t).clamp().pow(i).mul(o)}),Pt=class extends s.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 s.Color(1,1,1),this.map=null,this.emissive=new s.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new s.Vector2(1,1),this.shadeColorFactor=new s.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 s.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new s.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=v.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new s.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 j}setup(t){var i;this._animatedUVNode=new X((i=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?i:!1),super.setup(t)}setupDiffuseColor(t){let i=null;if(this.colorNode==null){if(i=ot,this.map&&this.map.isTexture===!0){let o=rt.context({getUV:()=>this._animatedUVNode});i=i.mul(o)}this.colorNode=i}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(s.REVISION,10)<166&&this.transparent===!1&&this.blending===s.NormalBlending&&this.alphaToCoverage===!1&&e.diffuseColor.a.assign(1),this.colorNode===i&&(this.colorNode=null)}setupVariants(){B.assign(this._setupShadeColorNode()),q.assign(this._setupShadingShiftNode()),G.assign(this._setupShadingToonyNode()),F.assign(this._setupRimLightingMixNode()),E.assign(this._setupRimMultiplyNode()),y.assign(this._setupMatcapNode()),C.assign(this._setupParametricRimNode())}setupNormal(t){let i=this.normalNode;if(this.normalNode==null){if(this.normalNode=e.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let r=at.context({getUV:()=>this._animatedUVNode});this.normalNode=(0,e.normalMap)(r,nt)}this.isOutline&&(this.normalNode=this.normalNode.negate())}if(parseInt(s.REVISION,10)>=168){let r=this.normalNode;return this.normalNode=i,r}else{super.setupNormal(t),this.normalNode=i;return}}setupLighting(t){let i=null;if(this.emissiveNode==null){if(i=lt.mul(st),this.emissiveMap&&this.emissiveMap.isTexture===!0){let r=ht.context({getUV:()=>this._animatedUVNode});i=i.mul(r)}this.emissiveNode=i}let o=super.setupLighting(t);return this.emissiveNode===i&&(this.emissiveNode=null),o}setupOutput(t,i){return this.isOutline&&this.outlineWidthMode!==v.None&&(i=(0,e.vec4)((0,e.mix)(b,i.xyz.mul(b),St),i.w)),super.setupOutput(t,i)}setupPosition(t){var i,o;let r=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==v.None){(i=this.positionNode)!=null||(this.positionNode=e.positionLocal);let u=e.normalLocal.normalize(),p=Rt;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let f=xt.context({getUV:()=>this._animatedUVNode});p=p.mul(f)}let T=(0,e.length)(e.modelNormalMatrix.mul(u)),g=p.mul(T).mul(u);if(this.outlineWidthMode===v.WorldCoordinates)this.positionNode=this.positionNode.add(g);else if(this.outlineWidthMode===v.ScreenCoordinates){let f=e.cameraProjectionMatrix.element(1).element(1),M=e.modelViewMatrix.mul(e.positionLocal);this.positionNode=this.positionNode.add(g.div(f).mul(M.z.negate()))}(o=this.positionNode)!=null||(this.positionNode=e.positionLocal)}let n=super.setupPosition(t);return n.z.add(n.w.mul(1e-6)),this.positionNode=r,n}copy(t){var i,o,r,n,u,p,T,g,f,M,_,V,L,w,P,A,H,W,U;return this.color.copy(t.color),this.map=(i=t.map)!=null?i: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=(n=t.shadeMultiplyTexture)!=null?n:null,this.shadingShiftFactor=t.shadingShiftFactor,this.shadingShiftTexture=(u=t.shadingShiftTexture)!=null?u:null,this.shadingShiftTextureScale=t.shadingShiftTextureScale,this.shadingToonyFactor=t.shadingToonyFactor,this.rimLightingMixFactor=t.rimLightingMixFactor,this.rimMultiplyTexture=(p=t.rimMultiplyTexture)!=null?p: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=(g=t.outlineWidthMultiplyTexture)!=null?g: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=(f=t.uvAnimationMaskTexture)!=null?f:null,this.shadeColorNode=(M=t.shadeColorNode)!=null?M:null,this.shadingShiftNode=(_=t.shadingShiftNode)!=null?_:null,this.shadingToonyNode=(V=t.shadingToonyNode)!=null?V:null,this.rimLightingMixNode=(L=t.rimLightingMixNode)!=null?L:null,this.rimMultiplyNode=(w=t.rimMultiplyNode)!=null?w:null,this.matcapNode=(P=t.matcapNode)!=null?P:null,this.parametricRimColorNode=(A=t.parametricRimColorNode)!=null?A:null,this.parametricRimLiftNode=(H=t.parametricRimLiftNode)!=null?H:null,this.parametricRimFresnelPowerNode=(W=t.parametricRimFresnelPowerNode)!=null?W:null,this.isOutline=(U=t.isOutline)!=null?U: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(0,e.vec3)(this.shadeColorNode);let t=ut;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let i=k.context({getUV:()=>this._animatedUVNode});t=t.mul(i)}return t}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return(0,e.float)(this.shadingShiftNode);let t=mt;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let i=k.context({getUV:()=>this._animatedUVNode});t=t.add(i.mul(dt))}return t}_setupShadingToonyNode(){return this.shadingToonyNode!=null?(0,e.float)(this.shadingToonyNode):ct}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?(0,e.float)(this.rimLightingMixNode):pt}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?(0,e.vec3)(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?ft.context({getUV:()=>this._animatedUVNode}):(0,e.vec3)(1)}_setupMatcapNode(){return this.matcapNode!=null?(0,e.vec3)(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?gt.context({getUV:()=>e.matcapUV.mul(1,-1).add(0,1)}).mul(Nt):(0,e.vec3)(0)}_setupParametricRimNode(){let t=this.parametricRimColorNode!=null?(0,e.vec3)(this.parametricRimColorNode):vt,i=this.parametricRimLiftNode!=null?(0,e.float)(this.parametricRimLiftNode):Tt,o=this.parametricRimFresnelPowerNode!=null?(0,e.float)(this.parametricRimFresnelPowerNode):Mt;return wt({parametricRimLift:i,parametricRimFresnelPower:o,parametricRimColor:t})}};
3
3
  /*!
4
- * @pixiv/three-vrm-materials-mtoon v3.4.1
4
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
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.4.1
2
+ * @pixiv/three-vrm v3.4.2
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -505,7 +505,7 @@ export {
505
505
  MToonNodeMaterial
506
506
  };
507
507
  /*!
508
- * @pixiv/three-vrm-materials-mtoon v3.4.1
508
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
509
509
  * MToon (toon material) module for @pixiv/three-vrm
510
510
  *
511
511
  * 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 Y from"three";import*as X from"three/webgpu";import{cos as Z,mat2 as $,sin as J,uv as k,vec2 as M,vec4 as Q}from"three/tsl";import{materialReference as o}from"three/tsl";import*as z from"three/webgpu";import{BRDF_Lambert as S,diffuseColor as B,float as yt,mix as F,transformedNormalView as Ct,vec3 as x}from"three/tsl";import*as s from"three/webgpu";import{nodeImmutable as h}from"three/tsl";import*as j from"three/tsl";import*as v from"three/webgpu";import*as a from"three/webgpu";import{cameraProjectionMatrix as Pt,diffuseColor as At,float as p,length as Ht,matcapUV as Wt,materialNormal as Ut,mix as Ot,modelNormalMatrix as It,modelViewMatrix as kt,normalLocal as bt,normalMap as Dt,positionLocal as R,vec3 as d,vec4 as Yt}from"three/tsl";import{float as Xt,modelViewPosition as zt,transformedNormalView as Bt}from"three/tsl";var I=parseInt(Y.REVISION,10);I<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${I}). This would not work correctly.`);var tt=o("color","color"),it=o("map","texture"),et=o("normalMap","texture"),ot=o("normalScale","vec2"),rt=o("emissive","color"),at=o("emissiveIntensity","float"),nt=o("emissiveMap","texture"),lt=o("shadeColorFactor","color"),st=o("shadingShiftFactor","float"),b=o("shadeMultiplyTexture","texture"),ht=o("shadeMultiplyTextureScale","float"),ut=o("shadingToonyFactor","float"),mt=o("rimLightingMixFactor","float"),dt=o("rimMultiplyTexture","texture"),ct=o("matcapFactor","color"),pt=o("matcapTexture","texture"),ft=o("parametricRimColorFactor","color"),Nt=o("parametricRimLiftFactor","float"),gt=o("parametricRimFresnelPowerFactor","float"),vt=o("outlineWidthMultiplyTexture","texture"),Tt=o("outlineWidthFactor","float"),D=o("outlineColorFactor","color"),Mt=o("outlineLightingMixFactor","float"),xt=o("uvAnimationMaskTexture","texture"),Rt=o("uvAnimationScrollXOffset","float"),St=o("uvAnimationScrollYOffset","float"),Ft=o("uvAnimationRotationPhase","float"),Et=class extends X.TempNode{constructor(t){super("vec2"),this.hasMaskTexture=t}setup(){let t=1;this.hasMaskTexture&&(t=Q(xt).context({getUV:()=>k()}).r);let i=k(),e=Ft.mul(t),r=Z(e),n=J(e);i=i.sub(M(.5,.5)),i=i.mul($(r,n,n.negate(),r)),i=i.add(M(.5,.5));let l=M(Rt,St).mul(t);return i=i.add(l),i.toVar("AnimatedUV")}},q=h(s.PropertyNode,"vec3").toVar("ShadeColor"),G=h(s.PropertyNode,"float").toVar("ShadingShift"),K=h(s.PropertyNode,"float").toVar("ShadingToony"),E=h(s.PropertyNode,"float").toVar("RimLightingMix"),y=h(s.PropertyNode,"vec3").toVar("RimMultiply"),C=h(s.PropertyNode,"vec3").toVar("matcap"),_=h(s.PropertyNode,"vec3").toVar("ParametricRim"),T=t=>parseInt(v.REVISION,10)>=168?j.Fn(t):v.tslFn(t),_t=T(({a:t,b:i,t:e})=>{let r=e.sub(t),n=i.sub(t);return r.div(n).clamp()}),Vt=T(({dotNL:t})=>{let e=yt(1).sub(K),r=t.add(G);return r=_t({a:e.negate(),b:e,t:r}),r=r.mul(1),r}),Lt=T(({shading:t,lightColor:i})=>{let e=F(q,B,t);return i.mul(S({diffuseColor:e}))}),wt=class extends z.LightingModel{constructor(){super()}direct({lightDirection:t,lightColor:i,reflectedLight:e}){let r=Ct.dot(t).clamp(-1,1),n=Vt({dotNL:r});e.directDiffuse.addAssign(Lt({shading:n,lightColor:i})),e.directSpecular.addAssign(_.add(C).mul(y).mul(F(x(0),S({diffuseColor:i}),E)))}indirect(t){let i="context"in t?t.context:t;this.indirectDiffuse(i),this.indirectSpecular(i)}indirectDiffuse(t){let{irradiance:i,reflectedLight:e}=t;e.indirectDiffuse.addAssign(i.mul(S({diffuseColor:B})))}indirectSpecular(t){let{reflectedLight:i}=t;i.indirectSpecular.addAssign(_.add(C).mul(y).mul(F(x(1),x(0),E)))}},f={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},qt=T(({parametricRimLift:t,parametricRimFresnelPower:i,parametricRimColor:e})=>{let r=zt.normalize(),n=Bt.dot(r.negate());return Xt(1).sub(n).add(t).clamp().pow(i).mul(e)}),Qt=class extends a.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 a.Color(1,1,1),this.map=null,this.emissive=new a.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new a.Vector2(1,1),this.shadeColorFactor=new a.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 a.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new a.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=f.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new a.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 wt}setup(t){var i;this._animatedUVNode=new Et((i=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?i:!1),super.setup(t)}setupDiffuseColor(t){let i=null;if(this.colorNode==null){if(i=tt,this.map&&this.map.isTexture===!0){let e=it.context({getUV:()=>this._animatedUVNode});i=i.mul(e)}this.colorNode=i}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(a.REVISION,10)<166&&this.transparent===!1&&this.blending===a.NormalBlending&&this.alphaToCoverage===!1&&At.a.assign(1),this.colorNode===i&&(this.colorNode=null)}setupVariants(){q.assign(this._setupShadeColorNode()),G.assign(this._setupShadingShiftNode()),K.assign(this._setupShadingToonyNode()),E.assign(this._setupRimLightingMixNode()),y.assign(this._setupRimMultiplyNode()),C.assign(this._setupMatcapNode()),_.assign(this._setupParametricRimNode())}setupNormal(t){let i=this.normalNode;if(this.normalNode==null){if(this.normalNode=Ut,this.normalMap&&this.normalMap.isTexture===!0){let r=et.context({getUV:()=>this._animatedUVNode});this.normalNode=Dt(r,ot)}this.isOutline&&(this.normalNode=this.normalNode.negate())}if(parseInt(a.REVISION,10)>=168){let r=this.normalNode;return this.normalNode=i,r}else{super.setupNormal(t),this.normalNode=i;return}}setupLighting(t){let i=null;if(this.emissiveNode==null){if(i=rt.mul(at),this.emissiveMap&&this.emissiveMap.isTexture===!0){let r=nt.context({getUV:()=>this._animatedUVNode});i=i.mul(r)}this.emissiveNode=i}let e=super.setupLighting(t);return this.emissiveNode===i&&(this.emissiveNode=null),e}setupOutput(t,i){return this.isOutline&&this.outlineWidthMode!==f.None&&(i=Yt(Ot(D,i.xyz.mul(D),Mt),i.w)),super.setupOutput(t,i)}setupPosition(t){var i,e;let r=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==f.None){(i=this.positionNode)!=null||(this.positionNode=R);let l=bt.normalize(),u=Tt;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let m=vt.context({getUV:()=>this._animatedUVNode});u=u.mul(m)}let N=Ht(It.mul(l)),c=u.mul(N).mul(l);if(this.outlineWidthMode===f.WorldCoordinates)this.positionNode=this.positionNode.add(c);else if(this.outlineWidthMode===f.ScreenCoordinates){let m=Pt.element(1).element(1),g=kt.mul(R);this.positionNode=this.positionNode.add(c.div(m).mul(g.z.negate()))}(e=this.positionNode)!=null||(this.positionNode=R)}let n=super.setupPosition(t);return n.z.add(n.w.mul(1e-6)),this.positionNode=r,n}copy(t){var i,e,r,n,l,u,N,c,m,g,V,L,w,P,A,H,W,U,O;return this.color.copy(t.color),this.map=(i=t.map)!=null?i:null,this.emissive.copy(t.emissive),this.emissiveIntensity=t.emissiveIntensity,this.emissiveMap=(e=t.emissiveMap)!=null?e:null,this.normalMap=(r=t.normalMap)!=null?r:null,this.normalScale.copy(t.normalScale),this.shadeColorFactor.copy(t.shadeColorFactor),this.shadeMultiplyTexture=(n=t.shadeMultiplyTexture)!=null?n:null,this.shadingShiftFactor=t.shadingShiftFactor,this.shadingShiftTexture=(l=t.shadingShiftTexture)!=null?l:null,this.shadingShiftTextureScale=t.shadingShiftTextureScale,this.shadingToonyFactor=t.shadingToonyFactor,this.rimLightingMixFactor=t.rimLightingMixFactor,this.rimMultiplyTexture=(u=t.rimMultiplyTexture)!=null?u:null,this.matcapFactor.copy(t.matcapFactor),this.matcapTexture=(N=t.matcapTexture)!=null?N:null,this.parametricRimColorFactor.copy(t.parametricRimColorFactor),this.parametricRimLiftFactor=t.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=t.parametricRimFresnelPowerFactor,this.outlineWidthMode=t.outlineWidthMode,this.outlineWidthMultiplyTexture=(c=t.outlineWidthMultiplyTexture)!=null?c: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=(m=t.uvAnimationMaskTexture)!=null?m:null,this.shadeColorNode=(g=t.shadeColorNode)!=null?g:null,this.shadingShiftNode=(V=t.shadingShiftNode)!=null?V:null,this.shadingToonyNode=(L=t.shadingToonyNode)!=null?L:null,this.rimLightingMixNode=(w=t.rimLightingMixNode)!=null?w:null,this.rimMultiplyNode=(P=t.rimMultiplyNode)!=null?P:null,this.matcapNode=(A=t.matcapNode)!=null?A:null,this.parametricRimColorNode=(H=t.parametricRimColorNode)!=null?H:null,this.parametricRimLiftNode=(W=t.parametricRimLiftNode)!=null?W:null,this.parametricRimFresnelPowerNode=(U=t.parametricRimFresnelPowerNode)!=null?U:null,this.isOutline=(O=t.isOutline)!=null?O: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 d(this.shadeColorNode);let t=lt;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let i=b.context({getUV:()=>this._animatedUVNode});t=t.mul(i)}return t}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return p(this.shadingShiftNode);let t=st;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let i=b.context({getUV:()=>this._animatedUVNode});t=t.add(i.mul(ht))}return t}_setupShadingToonyNode(){return this.shadingToonyNode!=null?p(this.shadingToonyNode):ut}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?p(this.rimLightingMixNode):mt}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?d(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?dt.context({getUV:()=>this._animatedUVNode}):d(1)}_setupMatcapNode(){return this.matcapNode!=null?d(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?pt.context({getUV:()=>Wt.mul(1,-1).add(0,1)}).mul(ct):d(0)}_setupParametricRimNode(){let t=this.parametricRimColorNode!=null?d(this.parametricRimColorNode):ft,i=this.parametricRimLiftNode!=null?p(this.parametricRimLiftNode):Nt,e=this.parametricRimFresnelPowerNode!=null?p(this.parametricRimFresnelPowerNode):gt;return qt({parametricRimLift:i,parametricRimFresnelPower:e,parametricRimColor:t})}};export{Et as MToonAnimatedUVNode,wt as MToonLightingModel,Qt as MToonNodeMaterial};
3
3
  /*!
4
- * @pixiv/three-vrm-materials-mtoon v3.4.1
4
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
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.4.1
2
+ * @pixiv/three-vrm v3.4.2
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6710,7 +6710,7 @@ VRMUtils.removeUnnecessaryJoints = removeUnnecessaryJoints;
6710
6710
  VRMUtils.removeUnnecessaryVertices = removeUnnecessaryVertices;
6711
6711
  VRMUtils.rotateVRM0 = rotateVRM0;
6712
6712
  /*!
6713
- * @pixiv/three-vrm-core v3.4.1
6713
+ * @pixiv/three-vrm-core v3.4.2
6714
6714
  * The implementation of core features of VRM, for @pixiv/three-vrm
6715
6715
  *
6716
6716
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6718,7 +6718,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6718
6718
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6719
6719
  */
6720
6720
  /*!
6721
- * @pixiv/three-vrm-materials-mtoon v3.4.1
6721
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
6722
6722
  * MToon (toon material) module for @pixiv/three-vrm
6723
6723
  *
6724
6724
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6726,7 +6726,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6726
6726
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6727
6727
  */
6728
6728
  /*!
6729
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.1
6729
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.2
6730
6730
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
6731
6731
  *
6732
6732
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6734,7 +6734,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6734
6734
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6735
6735
  */
6736
6736
  /*!
6737
- * @pixiv/three-vrm-materials-v0compat v3.4.1
6737
+ * @pixiv/three-vrm-materials-v0compat v3.4.2
6738
6738
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
6739
6739
  *
6740
6740
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6742,7 +6742,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6742
6742
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6743
6743
  */
6744
6744
  /*!
6745
- * @pixiv/three-vrm-node-constraint v3.4.1
6745
+ * @pixiv/three-vrm-node-constraint v3.4.2
6746
6746
  * Node constraint module for @pixiv/three-vrm
6747
6747
  *
6748
6748
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6750,7 +6750,7 @@ VRMUtils.rotateVRM0 = rotateVRM0;
6750
6750
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6751
6751
  */
6752
6752
  /*!
6753
- * @pixiv/three-vrm-springbone v3.4.1
6753
+ * @pixiv/three-vrm-springbone v3.4.2
6754
6754
  * Spring bone module for @pixiv/three-vrm
6755
6755
  *
6756
6756
  * 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(P.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===Ut.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},vo=new Set(["1.0","1.0-beta"]),vi=class tt{get name(){return tt.EXTENSION_NAME}constructor(e,n={}){var i,r,o,a;this.parser=e,this.materialType=(i=n.materialType)!=null?i:_i,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 de(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return de(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 de(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[tt.EXTENSION_NAME];if(l==null)return;let s=l.specVersion;if(!vo.has(s)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${tt.EXTENSION_NAME} specVersion "${s}"`);return}return l}_extendMaterialParams(e,n){return de(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new mo(this.parser,n);r.assignPrimitive("transparentWithZWrite",e.transparentWithZWrite),r.assignColor("shadeColorFactor",e.shadeColorFactor),r.assignTexture("shadeMultiplyTexture",e.shadeMultiplyTexture,!0),r.assignPrimitive("shadingShiftFactor",e.shadingShiftFactor),r.assignTexture("shadingShiftTexture",e.shadingShiftTexture,!0),r.assignPrimitive("shadingShiftTextureScale",(i=e.shadingShiftTexture)==null?void 0:i.scale),r.assignPrimitive("shadingToonyFactor",e.shadingToonyFactor),r.assignPrimitive("giEqualizationFactor",e.giEqualizationFactor),r.assignColor("matcapFactor",e.matcapFactor),r.assignTexture("matcapTexture",e.matcapTexture,!0),r.assignColor("parametricRimColorFactor",e.parametricRimColorFactor),r.assignTexture("rimMultiplyTexture",e.rimMultiplyTexture,!0),r.assignPrimitive("rimLightingMixFactor",e.rimLightingMixFactor),r.assignPrimitive("parametricRimFresnelPowerFactor",e.parametricRimFresnelPowerFactor),r.assignPrimitive("parametricRimLiftFactor",e.parametricRimLiftFactor),r.assignPrimitive("outlineWidthMode",e.outlineWidthMode),r.assignPrimitive("outlineWidthFactor",e.outlineWidthFactor),r.assignTexture("outlineWidthMultiplyTexture",e.outlineWidthMultiplyTexture,!1),r.assignColor("outlineColorFactor",e.outlineColorFactor),r.assignPrimitive("outlineLightingMixFactor",e.outlineLightingMixFactor),r.assignTexture("uvAnimationMaskTexture",e.uvAnimationMaskTexture,!1),r.assignPrimitive("uvAnimationScrollXSpeedFactor",e.uvAnimationScrollXSpeedFactor),r.assignPrimitive("uvAnimationScrollYSpeedFactor",e.uvAnimationScrollYSpeedFactor),r.assignPrimitive("uvAnimationRotationSpeedFactor",e.uvAnimationRotationSpeedFactor),r.assignPrimitive("v0CompatShade",this.v0CompatShade),r.assignPrimitive("debugMode",this.debugMode),yield r.pending})}_setupPrimitive(e,n){let i=this._getMToonExtension(n);if(i){let r=this._parseRenderOrder(i);e.renderOrder=r+this.renderOrderOffset,this._generateOutline(e),this._addToMaterialSet(e);return}}_shouldGenerateOutline(e){return typeof e.outlineWidthMode=="string"&&e.outlineWidthMode!=="none"&&typeof e.outlineWidthFactor=="number"&&e.outlineWidthFactor>0}_generateOutline(e){let n=e.material;if(!(n instanceof nt.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=nt.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)}};vi.EXTENSION_NAME="VRMC_materials_mtoon";var Ot=vi;var Eo=(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())}),Ei=class Nt{get name(){return Nt.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return Eo(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[Nt.EXTENSION_NAME];if(l!=null)return l}};Ei.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var Mi=Ei;var yi=R(require("three"),1);var Mo=Object.defineProperty,Ro=Object.defineProperties,To=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,yo=Object.prototype.propertyIsEnumerable,Ti=(t,e,n)=>e in t?Mo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))xo.call(e,n)&&Ti(t,n,e[n]);if(Ri)for(var n of Ri(e))yo.call(e,n)&&Ti(t,n,e[n]);return t},xi=(t,e)=>Ro(t,To(e)),wo=(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 Me(t){return Math.pow(t,2.2)}var wi=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 wo(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,p,m,c,f,g,v,A,y,_,E,M,T,x,b,w,L,H,B,se,z,q,G,me,Se,O,$t,Zt,Jt,Kt,en,tn,nn,rn,on,sn,an,ln,un,dn,hn,cn,pn,mn,fn,gn;let _n=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,Ji=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&_n,Ki=this._v0ParseRenderQueue(t),vn=(a=(o=t.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?a:!1,er=_n?"BLEND":vn?"MASK":"OPAQUE",tr=vn?(s=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?s:.5:void 0,nr=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,ae=this._portTextureTransform(t),ir=((p=(h=t.vectorProperties)==null?void 0:h._Color)!=null?p:[1,1,1,1]).map((Pn,Pr)=>Pr===3?Pn:Me(Pn)),En=(m=t.textureProperties)==null?void 0:m._MainTex,rr=En!=null?{index:En,extensions:X({},ae)}:void 0,or=(f=(c=t.floatProperties)==null?void 0:c._BumpScale)!=null?f:1,Mn=(g=t.textureProperties)==null?void 0:g._BumpMap,sr=Mn!=null?{index:Mn,scale:or,extensions:X({},ae)}:void 0,ar=((A=(v=t.vectorProperties)==null?void 0:v._EmissionColor)!=null?A:[0,0,0,1]).map(Me),Rn=(y=t.textureProperties)==null?void 0:y._EmissionMap,lr=Rn!=null?{index:Rn,extensions:X({},ae)}:void 0,ur=((E=(_=t.vectorProperties)==null?void 0:_._ShadeColor)!=null?E:[.97,.81,.86,1]).map(Me),Tn=(M=t.textureProperties)==null?void 0:M._ShadeTexture,dr=Tn!=null?{index:Tn,extensions:X({},ae)}:void 0,Be=(x=(T=t.floatProperties)==null?void 0:T._ShadeShift)!=null?x:0,De=(w=(b=t.floatProperties)==null?void 0:b._ShadeToony)!=null?w:.9;De=yi.MathUtils.lerp(De,1,.5+.5*Be),Be=-Be-(1-De);let xn=(H=(L=t.floatProperties)==null?void 0:L._IndirectLightIntensity)!=null?H:.1,hr=xn?1-xn:void 0,ft=(B=t.textureProperties)==null?void 0:B._SphereAdd,cr=ft!=null?[1,1,1]:void 0,pr=ft!=null?{index:ft}:void 0,mr=(z=(se=t.floatProperties)==null?void 0:se._RimLightingMix)!=null?z:0,yn=(q=t.textureProperties)==null?void 0:q._RimTexture,fr=yn!=null?{index:yn,extensions:X({},ae)}:void 0,gr=((me=(G=t.vectorProperties)==null?void 0:G._RimColor)!=null?me:[0,0,0,1]).map(Me),_r=(O=(Se=t.floatProperties)==null?void 0:Se._RimFresnelPower)!=null?O:1,vr=(Zt=($t=t.floatProperties)==null?void 0:$t._RimLift)!=null?Zt:0,Er=["none","worldCoordinates","screenCoordinates"][(Kt=(Jt=t.floatProperties)==null?void 0:Jt._OutlineWidthMode)!=null?Kt:0],gt=(tn=(en=t.floatProperties)==null?void 0:en._OutlineWidth)!=null?tn:0;gt=.01*gt;let wn=(nn=t.textureProperties)==null?void 0:nn._OutlineWidthTexture,Mr=wn!=null?{index:wn,extensions:X({},ae)}:void 0,Rr=((on=(rn=t.vectorProperties)==null?void 0:rn._OutlineColor)!=null?on:[0,0,0]).map(Me),Tr=((an=(sn=t.floatProperties)==null?void 0:sn._OutlineColorMode)!=null?an:0)===1?(un=(ln=t.floatProperties)==null?void 0:ln._OutlineLightingMix)!=null?un:1:0,Sn=(dn=t.textureProperties)==null?void 0:dn._UvAnimMaskTexture,xr=Sn!=null?{index:Sn,extensions:X({},ae)}:void 0,yr=(cn=(hn=t.floatProperties)==null?void 0:hn._UvAnimScrollX)!=null?cn:0,Fe=(mn=(pn=t.floatProperties)==null?void 0:pn._UvAnimScrollY)!=null?mn:0;Fe!=null&&(Fe=-Fe);let wr=(gn=(fn=t.floatProperties)==null?void 0:fn._UvAnimRotation)!=null?gn:0,Sr={specVersion:"1.0",transparentWithZWrite:Ji,renderQueueOffsetNumber:Ki,shadeColorFactor:ur,shadeMultiplyTexture:dr,shadingShiftFactor:Be,shadingToonyFactor:De,giEqualizationFactor:hr,matcapFactor:cr,matcapTexture:pr,rimLightingMixFactor:mr,rimMultiplyTexture:fr,parametricRimColorFactor:gr,parametricRimFresnelPowerFactor:_r,parametricRimLiftFactor:vr,outlineWidthMode:Er,outlineWidthFactor:gt,outlineWidthMultiplyTexture:Mr,outlineColorFactor:Rr,outlineLightingMixFactor:Tr,uvAnimationMaskTexture:xr,uvAnimationScrollXSpeedFactor:yr,uvAnimationScrollYSpeedFactor:Fe,uvAnimationRotationSpeedFactor:wr};return xi(X({},e),{pbrMetallicRoughness:{baseColorFactor:ir,baseColorTexture:rr},normalTexture:sr,emissiveTexture:lr,emissiveFactor:ar,alphaMode:er,alphaCutoff:tr,doubleSided:nr,extensions:{VRMC_materials_mtoon:Sr}})}_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",p=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,m=this._portTextureTransform(t),c=((o=(r=t.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(Me),f=(a=t.textureProperties)==null?void 0:a._MainTex,g=f!=null?{index:f,extensions:X({},m)}:void 0,v={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:c,shadeMultiplyTexture:g};return xi(X({},e),{pbrMetallicRoughness:{baseColorFactor:c,baseColorTexture:g},alphaMode:h,alphaCutoff:p,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=R(require("three"),1),Q=R(require("three"),1),Bt=R(require("three"),1),Ie=R(require("three"),1),Z=R(require("three"),1);var Si=(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,it=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 Pi(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var So=new Bt.Vector3,Po=new Bt.Vector3;function Ao(t,e){return t.decompose(So,e,Po),e}function rt(t){return t.invert?t.invert():t.inverse(),t}var ot=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},Lo=new Q.Vector3,bo=new Q.Vector3,Ho=new Q.Vector3,Io=new Q.Quaternion,Vo=new Q.Quaternion,Co=new Q.Quaternion,Ai=class extends ot{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=Io.identity(),e=Vo.identity();this.destination.parent&&(Ao(this.destination.parent.matrixWorld,t),rt(e.copy(t)));let n=Lo.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=Pi(this.source.matrixWorld,bo).sub(Pi(this.destination.matrixWorld,Ho)).normalize(),r=Co.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function Uo(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var Li=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(t){this._constraints.add(t);let e=this._objectConstraintsMap.get(t.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(t.destination,e)),e.add(t)}deleteConstraint(t){this._constraints.delete(t),this._objectConstraintsMap.get(t.destination).delete(t)}setInitState(){let t=new Set,e=new Set;for(let n of this._constraints)this._processConstraint(n,t,e,i=>i.setInitState())}update(){let t=new Set,e=new Set;for(let n of this._constraints)this._processConstraint(n,t,e,i=>i.update())}_processConstraint(t,e,n,i){if(n.has(t))return;if(e.has(t))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(t);let r=t.dependencies;for(let o of r)Uo(o,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)}},Oo=new Ie.Quaternion,No=new Ie.Quaternion,bi=class extends ot{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new Ie.Quaternion,this._invSrcRestQuat=new Ie.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),rt(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=Oo.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=No.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},Bo=new Z.Vector3,Do=new Z.Quaternion,Fo=new Z.Quaternion,Hi=class extends ot{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),rt(this._invDstRestQuat.copy(this._dstRestQuat)),rt(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=Do.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=Bo.copy(this._v3RollAxis).applyQuaternion(t),i=Fo.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},ko=new Set(["1.0","1.0-beta"]),Ii=class He{get name(){return He.EXTENSION_NAME}constructor(e,n){this.parser=e,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(e){return Si(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return Si(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(He.EXTENSION_NAME))!==-1))return null;let o=new Li,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[He.EXTENSION_NAME];if(h==null)return;let p=h.specVersion;if(!ko.has(p)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${He.EXTENSION_NAME} specVersion "${p}"`);return}let m=h.constraint;if(m.roll!=null){let c=this._importRollConstraint(l,a,m.roll);o.addConstraint(c)}else if(m.aim!=null){let c=this._importAimConstraint(l,a,m.aim);o.addConstraint(c)}else if(m.rotation!=null){let c=this._importRotationConstraint(l,a,m.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 Hi(e,l);if(o!=null&&(s.rollAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new it(s);this.helperRoot.add(u)}return s}_importAimConstraint(e,n,i){let{source:r,aimAxis:o,weight:a}=i,l=n[r],s=new Ai(e,l);if(o!=null&&(s.aimAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new it(s);this.helperRoot.add(u)}return s}_importRotationConstraint(e,n,i){let{source:r,weight:o}=i,a=n[r],l=new bi(e,a);if(o!=null&&(l.weight=o),this.helperRoot){let s=new it(l);this.helperRoot.add(s)}return l}};Ii.EXTENSION_NAME="VRMC_node_constraint";var Dt=Ii;var re=R(require("three"),1),Oe=R(require("three"),1),xe=R(require("three"),1),Qt=R(require("three"),1),J=R(require("three"),1),ie=R(require("three"),1),ce=R(require("three"),1),oe=R(require("three"),1),pe=R(require("three"),1),dt=R(require("three"),1),U=R(require("three"),1),Oi=R(require("three"),1),Ni=R(require("three"),1),F=R(require("three"),1);var st=(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())}),ut=class{},Ft=new Oe.Vector3,he=new Oe.Vector3,jt=class extends ut{get type(){return"capsule"}constructor(t){var e,n,i,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Oe.Vector3(0,0,0),this.tail=(n=t==null?void 0:t.tail)!=null?n:new Oe.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){Ft.setFromMatrixPosition(t),he.subVectors(this.tail,this.offset).applyMatrix4(t),he.sub(Ft);let r=he.lengthSq();i.copy(e).sub(Ft);let o=he.dot(i);o<=0||(r<=o||he.multiplyScalar(o/r),i.sub(he));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}},kt=new xe.Vector3,Vi=new xe.Matrix3,Xt=class extends ut{get type(){return"plane"}constructor(t){var e,n;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new xe.Vector3(0,0,0),this.normal=(n=t==null?void 0:t.normal)!=null?n:new xe.Vector3(0,0,1)}calculateCollision(t,e,n,i){i.setFromMatrixPosition(t),i.negate().add(e),Vi.getNormalMatrix(t),kt.copy(this.normal).applyNormalMatrix(Vi).normalize();let r=i.dot(kt)-n;return i.copy(kt),r}},Wo=new Qt.Vector3,Yt=class extends ut{get type(){return"sphere"}constructor(t){var e,n,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Qt.Vector3(0,0,0),this.radius=(n=t==null?void 0:t.radius)!=null?n:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,n,i){i.subVectors(e,Wo.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,zo=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}},Go=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}},jo=class extends ce.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new ce.Vector3,this._shape=t,this._attrPos=new ce.BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ce.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}},Xo=new re.Vector3,at=class extends re.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof Yt)this._geometry=new jo(this.collider.shape);else if(this.collider.shape instanceof jt)this._geometry=new zo(this.collider.shape);else if(this.collider.shape instanceof Xt)this._geometry=new Go(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=Xo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},Qo=class extends pe.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new pe.Vector3,this._springBone=t,this._attrPos=new pe.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new pe.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}},Yo=new oe.Vector3,Ui=class extends oe.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new Qo(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=Yo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},lt=class extends dt.Object3D{constructor(t){super(),this.colliderMatrix=new dt.Matrix4,this.shape=t}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),qo(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function qo(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 $o=new Ni.Matrix4;function Zo(t){return t.invert?t.invert():t.getInverse($o.copy(t)),t}var Jo=class{constructor(t){this._inverseCache=new Oi.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&&(Zo(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},Wt=new U.Matrix4,Re=new U.Vector3,Ve=new U.Vector3,Ce=new U.Vector3,Ue=new U.Vector3,Ko=new U.Matrix4,Bi=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 Jo(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Wt}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=Ve.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);Ue.copy(this._currentTail).add(Re.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),Ce.setFromMatrixPosition(this.bone.matrixWorld),Ue.sub(Ce).normalize().multiplyScalar(this._worldSpaceBoneLength).add(Ce),this._collision(Ue),this._prevTail.copy(this._currentTail),this._currentTail.copy(Ue).applyMatrix4(this._getMatrixWorldToCenter());let n=Ko.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Re.copy(Ue).applyMatrix4(n).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let n=0;n<this.colliderGroups[e].colliders.length;n++){let i=this.colliderGroups[e].colliders[n],r=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,Re);if(r<0){t.addScaledVector(Re,-r),t.sub(Ce);let o=t.length();t.multiplyScalar(this._worldSpaceBoneLength/o).add(Ce)}}}_calcWorldSpaceBoneLength(){Re.setFromMatrixPosition(this.bone.matrixWorld),this.child?Ve.setFromMatrixPosition(this.child.matrixWorld):(Ve.copy(this._initialLocalChildPosition),Ve.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Re.sub(Ve).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:Wt}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:Wt}};function es(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function zt(t,e){t.children.forEach(n=>{e(n)||zt(n,e)})}function ts(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 Gt=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),zt(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=ts(i);this._ancestors=[],r&&(this._ancestors.push(r),zt(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;es(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)}},Ci="VRMC_springBone_extended_collider",ns=new Set(["1.0","1.0-beta"]),is=new Set(["1.0"]),Di=class Te{get name(){return Te.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 st(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return st(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 st(this,null,function*(){var n,i,r,o,a;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(Te.EXTENSION_NAME))!==-1))return null;let u=new Gt,d=yield e.parser.getDependencies("node"),h=(i=l.extensions)==null?void 0:i[Te.EXTENSION_NAME];if(!h)return null;let p=h.specVersion;if(!ns.has(p))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Te.EXTENSION_NAME} specVersion "${p}"`),null;let m=(r=h.colliders)==null?void 0:r.map((f,g)=>{var v,A,y,_,E,M,T,x,b,w,L,H,B,se,z;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,me=(v=f.extensions)==null?void 0:v[Ci];if(this.useExtendedColliders&&me!=null){let Se=me.specVersion;if(!is.has(Se))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ci} specVersion "${Se}". Fallbacking to the ${Te.EXTENSION_NAME} definition`);else{let O=me.shape;if(O.sphere)return this._importSphereCollider(q,{offset:new F.Vector3().fromArray((A=O.sphere.offset)!=null?A:[0,0,0]),radius:(y=O.sphere.radius)!=null?y:0,inside:(_=O.sphere.inside)!=null?_:!1});if(O.capsule)return this._importCapsuleCollider(q,{offset:new F.Vector3().fromArray((E=O.capsule.offset)!=null?E:[0,0,0]),radius:(M=O.capsule.radius)!=null?M:0,tail:new F.Vector3().fromArray((T=O.capsule.tail)!=null?T:[0,0,0]),inside:(x=O.capsule.inside)!=null?x:!1});if(O.plane)return this._importPlaneCollider(q,{offset:new F.Vector3().fromArray((b=O.plane.offset)!=null?b:[0,0,0]),normal:new F.Vector3().fromArray((w=O.plane.normal)!=null?w:[0,0,1])})}}if(G.sphere)return this._importSphereCollider(q,{offset:new F.Vector3().fromArray((L=G.sphere.offset)!=null?L:[0,0,0]),radius:(H=G.sphere.radius)!=null?H:0,inside:!1});if(G.capsule)return this._importCapsuleCollider(q,{offset:new F.Vector3().fromArray((B=G.capsule.offset)!=null?B:[0,0,0]),radius:(se=G.capsule.radius)!=null?se:0,tail:new F.Vector3().fromArray((z=G.capsule.tail)!=null?z:[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(y=>{let _=m==null?void 0:m[y];return _==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${g} attempted to use a collider #${y} but not found`),[]):_}),name:f.name}});return(a=h.springs)==null||a.forEach((f,g)=>{var v;let A=f.joints,y=(v=f.colliderGroups)==null?void 0:v.map(M=>{let T=c==null?void 0:c[M];if(T==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to use a colliderGroup ${M} but not found`);return T}),_=f.center!=null?d[f.center]:void 0,E;A.forEach(M=>{if(E){let T=E.node,x=d[T],b=M.node,w=d[b],L={hitRadius:E.hitRadius,dragForce:E.dragForce,gravityPower:E.gravityPower,stiffness:E.stiffness,gravityDir:E.gravityDir!=null?new F.Vector3().fromArray(E.gravityDir):void 0},H=this._importJoint(x,w,L,y);_&&(H.center=_),u.addJoint(H)}E=M})}),u.setInitState(),u})}_v0Import(e){return st(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 Gt,h=yield e.parser.getDependencies("node"),p=(r=s.colliderGroups)==null?void 0:r.map(m=>{var c;let f=h[m.node];return{colliders:((c=m.colliders)!=null?c:[]).map((v,A)=>{var y,_,E;let M=new F.Vector3(0,0,0);return v.offset&&M.set((y=v.offset.x)!=null?y: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((m,c)=>{let f=m.bones;f&&f.forEach(g=>{var v,A,y,_;let E=h[g],M=new F.Vector3;m.gravityDir?M.set((v=m.gravityDir.x)!=null?v:0,(A=m.gravityDir.y)!=null?A:0,(y=m.gravityDir.z)!=null?y:0):M.set(0,-1,0);let T=m.center!=null?h[m.center]:void 0,x={hitRadius:m.hitRadius,dragForce:m.dragForce,gravityPower:m.gravityPower,stiffness:m.stiffiness,gravityDir:M},b=(_=m.colliderGroups)==null?void 0:_.map(w=>{let L=p==null?void 0:p[w];if(L==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${c} attempted to use a colliderGroup ${w} but not found`);return L});E.traverse(w=>{var L;let H=(L=w.children[0])!=null?L:null,B=this._importJoint(w,H,x,b);T&&(B.center=T),d.addJoint(B)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let o=new Bi(e,n,i,r);if(this.jointHelperRoot){let a=new Ui(o);this.jointHelperRoot.add(a),a.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(e,n){let i=new Yt(n),r=new lt(i);if(e.add(r),this.colliderHelperRoot){let o=new at(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,n){let i=new jt(n),r=new lt(i);if(e.add(r),this.colliderHelperRoot){let o=new at(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,n){let i=new Xt(n),r=new lt(i);if(e.add(r),this.colliderHelperRoot){let o=new at(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}};Di.EXTENSION_NAME="VRMC_springBone";var qt=Di;var ht=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var o,a,l,s,u,d,h,p,m,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 Ye(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 Ze(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(s=n==null?void 0:n.lookAtPlugin)!=null?s:new Je(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new Ke(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new Ot(e),this.materialsHDREmissiveMultiplierPlugin=(h=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?h:new Mi(e),this.materialsV0CompatPlugin=(p=n==null?void 0:n.materialsV0CompatPlugin)!=null?p:new wi(e),this.springBonePlugin=(m=n==null?void 0:n.springBonePlugin)!=null?m:new qt(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(c=n==null?void 0:n.nodeConstraintPlugin)!=null?c:new Dt(e,{helperRoot:i})}beforeRoot(){return Pe(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return Pe(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(e)})}getMaterialType(e){let n=this.mtoonMaterialPlugin.getMaterialType(e);return n!=null?n:null}extendMaterialParams(e,n){return Pe(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,n),yield this.mtoonMaterialPlugin.extendMaterialParams(e,n)})}afterRoot(e){return Pe(this,null,function*(){yield this.metaPlugin.afterRoot(e),yield this.humanoidPlugin.afterRoot(e),yield this.expressionPlugin.afterRoot(e),yield this.lookAtPlugin.afterRoot(e),yield this.firstPersonPlugin.afterRoot(e),yield this.springBonePlugin.afterRoot(e),yield this.nodeConstraintPlugin.afterRoot(e),yield this.mtoonMaterialPlugin.afterRoot(e);let n=e.userData.vrmMeta,i=e.userData.vrmHumanoid;if(n&&i){let r=new Ee({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 ki=R(require("three"),1);function rs(t){let e=new Set;return t.traverse(n=>{if(!n.isMesh)return;let i=n;e.add(i)}),e}function Fi(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 ki.BufferAttribute(i,3)}function Wi(t){var r;let e=rs(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 ve){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,p={},m={},c=[];if(d||h){d&&(p.position=[]),h&&(p.normal=[]);let f=0;for(let[g,v]of a)d&&(p.position[f]=Fi(l.position,v,u)),h&&(p.normal[f]=Fi(l.normal,v,u)),i==null||i[g].addBind(new ve({index:f,weight:1,primitives:[o]})),m[g]=f,c.push(0),f++}s.morphAttributes=p,o.morphTargetDictionary=m,o.morphTargetInfluences=c}}var we=R(require("three"),1);var zi=R(require("three"),1);function ye(t,e,n){if(t.getComponent)return t.getComponent(e,n);{let i=t.array[e*t.itemSize+n];return t.normalized&&(i=zi.MathUtils.denormalize(i,t.array)),i}}var Gi=R(require("three"),1);function ct(t,e,n,i){t.setComponent?t.setComponent(e,n,i):(t.normalized&&(i=Gi.MathUtils.normalize(i,t.array)),t.array[e*t.itemSize+n]=i)}function ji(t){var d;let e=os(t),n=new Set;for(let h of e)n.has(h.geometry)&&(h.geometry=hs(h.geometry)),n.add(h.geometry);let i=new Map;for(let h of n){let p=h.getAttribute("skinIndex"),m=(d=i.get(p))!=null?d:new Map;i.set(p,m);let c=h.getAttribute("skinWeight"),f=ss(p,c);m.set(c,f)}let r=new Map;for(let h of e){let p=as(h,i);r.set(h,p)}let o=[];for(let[h,p]of r){let m=!1;for(let c of o)if(ls(p,c.boneInverseMap)){m=!0,c.meshes.add(h);for(let[g,v]of p)c.boneInverseMap.set(g,v);break}m||o.push({boneInverseMap:p,meshes:new Set([h])})}let a=new Map,l=new Ne,s=new Ne,u=new Ne;for(let h of o){let{boneInverseMap:p,meshes:m}=h,c=Array.from(p.keys()),f=Array.from(p.values()),g=new we.Skeleton(c,f),v=s.getOrCreate(g);for(let A of m){let y=A.geometry.getAttribute("skinIndex"),_=l.getOrCreate(y),E=A.skeleton.bones,M=E.map(b=>u.getOrCreate(b)).join(","),T=`${_};${v};${M}`,x=a.get(T);x==null&&(x=y.clone(),us(x,E,c),a.set(T,x)),A.geometry.setAttribute("skinIndex",x)}for(let A of m)A.bind(g,new we.Matrix4)}}function os(t){let e=new Set;return t.traverse(n=>{if(!n.isSkinnedMesh)return;let i=n;e.add(i)}),e}function ss(t,e){let n=new Set;for(let i=0;i<t.count;i++)for(let r=0;r<t.itemSize;r++){let o=ye(t,i,r);ye(e,i,r)!==0&&n.add(o)}return n}function as(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 ls(t,e){for(let[n,i]of t.entries()){let r=e.get(n);if(r!=null&&!ds(i,r))return!1}return!0}function us(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=ye(t,o,a),s=r.get(l);ct(t,o,a,s)}t.needsUpdate=!0}function ds(t,e,n){if(n=n||1e-4,t.elements.length!=e.elements.length)return!1;for(let i=0,r=t.elements.length;i<r;i++)if(Math.abs(t.elements[i]-e.elements[i])>n)return!1;return!0}var Ne=class{constructor(){this._objectIndexMap=new Map;this._index=0}get(e){return this._objectIndexMap.get(e)}getOrCreate(e){let n=this._objectIndexMap.get(e);return n==null&&(n=this._index,this._objectIndexMap.set(e,n),this._index++),n}};function hs(t){var n,i,r,o;let e=new we.BufferGeometry;e.name=t.name,e.setIndex(t.index);for(let[a,l]of Object.entries(t.attributes))e.setAttribute(a,l);for(let[a,l]of Object.entries(t.morphAttributes)){let s=a;e.morphAttributes[s]=l.concat()}e.morphTargetsRelative=t.morphTargetsRelative,e.groups=[];for(let a of t.groups)e.addGroup(a.start,a.count,a.materialIndex);return e.boundingSphere=(i=(n=t.boundingSphere)==null?void 0:n.clone())!=null?i:null,e.boundingBox=(o=(r=t.boundingBox)==null?void 0:r.clone())!=null?o:null,e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e}function Xi(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 cs(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=>Xi(r)):i&&Xi(i))}function Qi(t){t.traverse(cs)}var pt=R(require("three"),1);function Yi(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,p=new Map;for(let m=0;m<d.count;m++)for(let c=0;c<d.itemSize;c++){let f=ye(d,m,c),g=h.get(f);g==null&&(g=h.size,h.set(f,g),p.set(g,f)),ct(d,m,c,g)}d.needsUpdate=!0,r.set(d,p),o=Math.max(o,h.size)}for(let s of i){let d=s.geometry.getAttribute("skinIndex"),h=r.get(d),p=[],m=[],c=n?o:h.size;for(let g=0;g<c;g++){let v=(l=h.get(g))!=null?l:0;p.push(s.skeleton.bones[v]),m.push(s.skeleton.boneInverses[v])}let f=new pt.Skeleton(p,m);s.bind(f,new pt.Matrix4)}}var qi=R(require("three"),1),mt=require("three");function $i(t){let e=new Map;t.traverse(n=>{var g,v,A,y;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=[],p=[],m=0;for(let _=0;_<s.length;_++)if(s[_]){let E=m++;h[_]=E,p[E]=_}let c=new qi.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=(y=(A=r.boundingSphere)==null?void 0:A.clone())!=null?y: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 T=_[M],x=h[T];E[M]=x}c.setIndex(new mt.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:T,normalized:x}=E,b=new M.constructor(p.length*T);p.forEach((w,L)=>{for(let H=0;H<T;H++)b[L*T+H]=M[w*T+H]}),c.setAttribute(_,new mt.BufferAttribute(b,T,x))});let f=!0;for(let[_,E]of Object.entries(r.morphAttributes)){let M=_;c.morphAttributes[M]=[];for(let T=0;T<E.length;T++){let x=E[T];if(x.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let b=x.array,{itemSize:w,normalized:L}=x,H=new b.constructor(p.length*w);p.forEach((B,se)=>{for(let z=0;z<w;z++)H[se*w+z]=b[B*w+z]}),f=f&&H.every(B=>B===0),c.morphAttributes[M][T]=new mt.BufferAttribute(H,w,L)}}f&&(c.morphAttributes={}),i.geometry=c}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function Zi(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var K=class{constructor(){}};K.combineMorphs=Wi,K.combineSkeletons=ji,K.deepDispose=Qi,K.removeUnnecessaryJoints=Yi,K.removeUnnecessaryVertices=$i,K.rotateVRM0=Zi;
925
925
  /*!
926
- * @pixiv/three-vrm-core v3.4.1
926
+ * @pixiv/three-vrm-core v3.4.2
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.4.1
934
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
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.4.1
942
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.2
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.4.1
950
+ * @pixiv/three-vrm-materials-v0compat v3.4.2
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.4.1
958
+ * @pixiv/three-vrm-node-constraint v3.4.2
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.4.1
966
+ * @pixiv/three-vrm-springbone v3.4.2
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.4.1
2
+ * @pixiv/three-vrm v3.4.2
3
3
  * VRM file loader for three.js.
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6678,7 +6678,7 @@ export {
6678
6678
  VRMUtils
6679
6679
  };
6680
6680
  /*!
6681
- * @pixiv/three-vrm-core v3.4.1
6681
+ * @pixiv/three-vrm-core v3.4.2
6682
6682
  * The implementation of core features of VRM, for @pixiv/three-vrm
6683
6683
  *
6684
6684
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6686,7 +6686,7 @@ export {
6686
6686
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6687
6687
  */
6688
6688
  /*!
6689
- * @pixiv/three-vrm-materials-mtoon v3.4.1
6689
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
6690
6690
  * MToon (toon material) module for @pixiv/three-vrm
6691
6691
  *
6692
6692
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6694,7 +6694,7 @@ export {
6694
6694
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6695
6695
  */
6696
6696
  /*!
6697
- * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.1
6697
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.2
6698
6698
  * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
6699
6699
  *
6700
6700
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6702,7 +6702,7 @@ export {
6702
6702
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6703
6703
  */
6704
6704
  /*!
6705
- * @pixiv/three-vrm-materials-v0compat v3.4.1
6705
+ * @pixiv/three-vrm-materials-v0compat v3.4.2
6706
6706
  * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
6707
6707
  *
6708
6708
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6710,7 +6710,7 @@ export {
6710
6710
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6711
6711
  */
6712
6712
  /*!
6713
- * @pixiv/three-vrm-node-constraint v3.4.1
6713
+ * @pixiv/three-vrm-node-constraint v3.4.2
6714
6714
  * Node constraint module for @pixiv/three-vrm
6715
6715
  *
6716
6716
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -6718,7 +6718,7 @@ export {
6718
6718
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
6719
6719
  */
6720
6720
  /*!
6721
- * @pixiv/three-vrm-springbone v3.4.1
6721
+ * @pixiv/three-vrm-springbone v3.4.2
6722
6722
  * Spring bone module for @pixiv/three-vrm
6723
6723
  *
6724
6724
  * 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===Jn.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},$r=new Set(["1.0","1.0-beta"]),ni=class Ge{get name(){return Ge.EXTENSION_NAME}constructor(e,n={}){var i,r,o,a;this.parser=e,this.materialType=(i=n.materialType)!=null?i:qr,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[Ge.EXTENSION_NAME];if(l==null)return;let s=l.specVersion;if(!$r.has(s)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${Ge.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 Gr(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 je.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=je.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)}};ni.EXTENSION_NAME="VRMC_materials_mtoon";var ii=ni;var Zr=(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())}),ri=class vt{get name(){return vt.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return Zr(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[vt.EXTENSION_NAME];if(l!=null)return l}};ri.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var oi=ri;import*as ui from"three";var Jr=Object.defineProperty,Kr=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,si=Object.getOwnPropertySymbols,to=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable,ai=(t,e,n)=>e in t?Jr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,j=(t,e)=>{for(var n in e||(e={}))to.call(e,n)&&ai(t,n,e[n]);if(si)for(var n of si(e))no.call(e,n)&&ai(t,n,e[n]);return t},li=(t,e)=>Kr(t,eo(e)),io=(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 ge(t){return Math.pow(t,2.2)}var di=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 io(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,p,m,c,f,g,v,P,x,_,E,M,R,T,L,y,A,b,N,oe,W,Y,z,pe,Te,U,It,Vt,Ct,Ut,Ot,Nt,Bt,Dt,Ft,kt,Wt,zt,Gt,jt,Xt,Qt,Yt,qt,$t,Zt;let Jt=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,Ni=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&Jt,Bi=this._v0ParseRenderQueue(t),Kt=(a=(o=t.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?a:!1,Di=Jt?"BLEND":Kt?"MASK":"OPAQUE",Fi=Kt?(s=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?s:.5:void 0,ki=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,se=this._portTextureTransform(t),Wi=((p=(h=t.vectorProperties)==null?void 0:h._Color)!=null?p:[1,1,1,1]).map((un,cr)=>cr===3?un:ge(un)),en=(m=t.textureProperties)==null?void 0:m._MainTex,zi=en!=null?{index:en,extensions:j({},se)}:void 0,Gi=(f=(c=t.floatProperties)==null?void 0:c._BumpScale)!=null?f:1,tn=(g=t.textureProperties)==null?void 0:g._BumpMap,ji=tn!=null?{index:tn,scale:Gi,extensions:j({},se)}:void 0,Xi=((P=(v=t.vectorProperties)==null?void 0:v._EmissionColor)!=null?P:[0,0,0,1]).map(ge),nn=(x=t.textureProperties)==null?void 0:x._EmissionMap,Qi=nn!=null?{index:nn,extensions:j({},se)}:void 0,Yi=((E=(_=t.vectorProperties)==null?void 0:_._ShadeColor)!=null?E:[.97,.81,.86,1]).map(ge),rn=(M=t.textureProperties)==null?void 0:M._ShadeTexture,qi=rn!=null?{index:rn,extensions:j({},se)}:void 0,Oe=(T=(R=t.floatProperties)==null?void 0:R._ShadeShift)!=null?T:0,Ne=(y=(L=t.floatProperties)==null?void 0:L._ShadeToony)!=null?y:.9;Ne=ui.MathUtils.lerp(Ne,1,.5+.5*Oe),Oe=-Oe-(1-Ne);let on=(b=(A=t.floatProperties)==null?void 0:A._IndirectLightIntensity)!=null?b:.1,$i=on?1-on:void 0,Ze=(N=t.textureProperties)==null?void 0:N._SphereAdd,Zi=Ze!=null?[1,1,1]:void 0,Ji=Ze!=null?{index:Ze}:void 0,Ki=(W=(oe=t.floatProperties)==null?void 0:oe._RimLightingMix)!=null?W:0,sn=(Y=t.textureProperties)==null?void 0:Y._RimTexture,er=sn!=null?{index:sn,extensions:j({},se)}:void 0,tr=((pe=(z=t.vectorProperties)==null?void 0:z._RimColor)!=null?pe:[0,0,0,1]).map(ge),nr=(U=(Te=t.floatProperties)==null?void 0:Te._RimFresnelPower)!=null?U:1,ir=(Vt=(It=t.floatProperties)==null?void 0:It._RimLift)!=null?Vt:0,rr=["none","worldCoordinates","screenCoordinates"][(Ut=(Ct=t.floatProperties)==null?void 0:Ct._OutlineWidthMode)!=null?Ut:0],Je=(Nt=(Ot=t.floatProperties)==null?void 0:Ot._OutlineWidth)!=null?Nt:0;Je=.01*Je;let an=(Bt=t.textureProperties)==null?void 0:Bt._OutlineWidthTexture,or=an!=null?{index:an,extensions:j({},se)}:void 0,sr=((Ft=(Dt=t.vectorProperties)==null?void 0:Dt._OutlineColor)!=null?Ft:[0,0,0]).map(ge),ar=((Wt=(kt=t.floatProperties)==null?void 0:kt._OutlineColorMode)!=null?Wt:0)===1?(Gt=(zt=t.floatProperties)==null?void 0:zt._OutlineLightingMix)!=null?Gt:1:0,ln=(jt=t.textureProperties)==null?void 0:jt._UvAnimMaskTexture,lr=ln!=null?{index:ln,extensions:j({},se)}:void 0,ur=(Qt=(Xt=t.floatProperties)==null?void 0:Xt._UvAnimScrollX)!=null?Qt:0,Be=(qt=(Yt=t.floatProperties)==null?void 0:Yt._UvAnimScrollY)!=null?qt:0;Be!=null&&(Be=-Be);let dr=(Zt=($t=t.floatProperties)==null?void 0:$t._UvAnimRotation)!=null?Zt:0,hr={specVersion:"1.0",transparentWithZWrite:Ni,renderQueueOffsetNumber:Bi,shadeColorFactor:Yi,shadeMultiplyTexture:qi,shadingShiftFactor:Oe,shadingToonyFactor:Ne,giEqualizationFactor:$i,matcapFactor:Zi,matcapTexture:Ji,rimLightingMixFactor:Ki,rimMultiplyTexture:er,parametricRimColorFactor:tr,parametricRimFresnelPowerFactor:nr,parametricRimLiftFactor:ir,outlineWidthMode:rr,outlineWidthFactor:Je,outlineWidthMultiplyTexture:or,outlineColorFactor:sr,outlineLightingMixFactor:ar,uvAnimationMaskTexture:lr,uvAnimationScrollXSpeedFactor:ur,uvAnimationScrollYSpeedFactor:Be,uvAnimationRotationSpeedFactor:dr};return li(j({},e),{pbrMetallicRoughness:{baseColorFactor:Wi,baseColorTexture:zi},normalTexture:ji,emissiveTexture:Qi,emissiveFactor:Xi,alphaMode:Di,alphaCutoff:Fi,doubleSided:ki,extensions:{VRMC_materials_mtoon:hr}})}_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",p=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,m=this._portTextureTransform(t),c=((o=(r=t.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(ge),f=(a=t.textureProperties)==null?void 0:a._MainTex,g=f!=null?{index:f,extensions:j({},m)}:void 0,v={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:c,shadeMultiplyTexture:g};return li(j({},e),{pbrMetallicRoughness:{baseColorFactor:c,baseColorTexture:g},alphaMode:h,alphaCutoff:p,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 Mt from"three";import*as be from"three";import*as $ from"three";var hi=(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,Et=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 ci(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var ro=new Mt.Vector3,oo=new Mt.Vector3;function so(t,e){return t.decompose(ro,e,oo),e}function Xe(t){return t.invert?t.invert():t.inverse(),t}var Rt=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},ao=new X.Vector3,lo=new X.Vector3,uo=new X.Vector3,ho=new X.Quaternion,co=new X.Quaternion,po=new X.Quaternion,mo=class extends Rt{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=ho.identity(),e=co.identity();this.destination.parent&&(so(this.destination.parent.matrixWorld,t),Xe(e.copy(t)));let n=ao.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=ci(this.source.matrixWorld,lo).sub(ci(this.destination.matrixWorld,uo)).normalize(),r=po.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function fo(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var go=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)fo(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)}},_o=new be.Quaternion,vo=new be.Quaternion,Eo=class extends Rt{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),Xe(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=_o.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=vo.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},Mo=new $.Vector3,Ro=new $.Quaternion,To=new $.Quaternion,xo=class extends Rt{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),Xe(this._invDstRestQuat.copy(this._dstRestQuat)),Xe(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=Ro.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=Mo.copy(this._v3RollAxis).applyQuaternion(t),i=To.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},yo=new Set(["1.0","1.0-beta"]),pi=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 hi(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return hi(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 go,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 p=h.specVersion;if(!yo.has(p)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Le.EXTENSION_NAME} specVersion "${p}"`);return}let m=h.constraint;if(m.roll!=null){let c=this._importRollConstraint(l,a,m.roll);o.addConstraint(c)}else if(m.aim!=null){let c=this._importAimConstraint(l,a,m.aim);o.addConstraint(c)}else if(m.rotation!=null){let c=this._importRotationConstraint(l,a,m.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 xo(e,l);if(o!=null&&(s.rollAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new Et(s);this.helperRoot.add(u)}return s}_importAimConstraint(e,n,i){let{source:r,aimAxis:o,weight:a}=i,l=n[r],s=new mo(e,l);if(o!=null&&(s.aimAxis=o),a!=null&&(s.weight=a),this.helperRoot){let u=new Et(s);this.helperRoot.add(u)}return s}_importRotationConstraint(e,n,i){let{source:r,weight:o}=i,a=n[r],l=new Eo(e,a);if(o!=null&&(l.weight=o),this.helperRoot){let s=new Et(l);this.helperRoot.add(s)}return l}};pi.EXTENSION_NAME="VRMC_node_constraint";var mi=pi;import*as ne from"three";import*as Ce from"three";import*as Ee from"three";import*as Lt from"three";import*as Z from"three";import*as te from"three";import*as he from"three";import*as ie from"three";import*as ce from"three";import*as Ye from"three";import*as C from"three";import*as Ri from"three";import*as Ti from"three";import*as D from"three";var Qe=(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{},Tt=new Ce.Vector3,de=new Ce.Vector3,vi=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){Tt.setFromMatrixPosition(t),de.subVectors(this.tail,this.offset).applyMatrix4(t),de.sub(Tt);let r=de.lengthSq();i.copy(e).sub(Tt);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}},xt=new Ee.Vector3,fi=new Ee.Matrix3,Ei=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 Ee.Vector3(0,0,0),this.normal=(n=t==null?void 0:t.normal)!=null?n:new Ee.Vector3(0,0,1)}calculateCollision(t,e,n,i){i.setFromMatrixPosition(t),i.negate().add(e),fi.getNormalMatrix(t),xt.copy(this.normal).applyNormalMatrix(fi).normalize();let r=i.dot(xt)-n;return i.copy(xt),r}},wo=new Lt.Vector3,Mi=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 Lt.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,wo.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,So=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}},Po=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}},Ao=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}},Lo=new ne.Vector3,yt=class extends ne.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof Mi)this._geometry=new Ao(this.collider.shape);else if(this.collider.shape instanceof vi)this._geometry=new So(this.collider.shape);else if(this.collider.shape instanceof Ei)this._geometry=new Po(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=Lo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},bo=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}},Ho=new ie.Vector3,Io=class extends ie.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new bo(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=Ho.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},wt=class extends Ye.Object3D{constructor(t){super(),this.colliderMatrix=new Ye.Matrix4,this.shape=t}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),Vo(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Vo(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 Co=new Ti.Matrix4;function Uo(t){return t.invert?t.invert():t.getInverse(Co.copy(t)),t}var Oo=class{constructor(t){this._inverseCache=new Ri.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&&(Uo(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},St=new C.Matrix4,_e=new C.Vector3,He=new C.Vector3,Ie=new C.Vector3,Ve=new C.Vector3,No=new C.Matrix4,Bo=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 Oo(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:St}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(_e.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=No.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,_e.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,_e);if(r<0){t.addScaledVector(_e,-r),t.sub(Ie);let o=t.length();t.multiplyScalar(this._worldSpaceBoneLength/o).add(Ie)}}}_calcWorldSpaceBoneLength(){_e.setFromMatrixPosition(this.bone.matrixWorld),this.child?He.setFromMatrixPosition(this.child.matrixWorld):(He.copy(this._initialLocalChildPosition),He.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=_e.sub(He).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:St}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:St}};function Do(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function Pt(t,e){t.children.forEach(n=>{e(n)||Pt(n,e)})}function Fo(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 gi=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),Pt(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=Fo(i);this._ancestors=[],r&&(this._ancestors.push(r),Pt(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;Do(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)}},_i="VRMC_springBone_extended_collider",ko=new Set(["1.0","1.0-beta"]),Wo=new Set(["1.0"]),xi=class ve{get name(){return ve.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 Qe(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return Qe(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 Qe(this,null,function*(){var n,i,r,o,a;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(ve.EXTENSION_NAME))!==-1))return null;let u=new gi,d=yield e.parser.getDependencies("node"),h=(i=l.extensions)==null?void 0:i[ve.EXTENSION_NAME];if(!h)return null;let p=h.specVersion;if(!ko.has(p))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${ve.EXTENSION_NAME} specVersion "${p}"`),null;let m=(r=h.colliders)==null?void 0:r.map((f,g)=>{var v,P,x,_,E,M,R,T,L,y,A,b,N,oe,W;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,pe=(v=f.extensions)==null?void 0:v[_i];if(this.useExtendedColliders&&pe!=null){let Te=pe.specVersion;if(!Wo.has(Te))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${_i} specVersion "${Te}". Fallbacking to the ${ve.EXTENSION_NAME} definition`);else{let U=pe.shape;if(U.sphere)return this._importSphereCollider(Y,{offset:new D.Vector3().fromArray((P=U.sphere.offset)!=null?P:[0,0,0]),radius:(x=U.sphere.radius)!=null?x:0,inside:(_=U.sphere.inside)!=null?_:!1});if(U.capsule)return this._importCapsuleCollider(Y,{offset:new D.Vector3().fromArray((E=U.capsule.offset)!=null?E:[0,0,0]),radius:(M=U.capsule.radius)!=null?M:0,tail:new D.Vector3().fromArray((R=U.capsule.tail)!=null?R:[0,0,0]),inside:(T=U.capsule.inside)!=null?T:!1});if(U.plane)return this._importPlaneCollider(Y,{offset:new D.Vector3().fromArray((L=U.plane.offset)!=null?L:[0,0,0]),normal:new D.Vector3().fromArray((y=U.plane.normal)!=null?y:[0,0,1])})}}if(z.sphere)return this._importSphereCollider(Y,{offset:new D.Vector3().fromArray((A=z.sphere.offset)!=null?A:[0,0,0]),radius:(b=z.sphere.radius)!=null?b:0,inside:!1});if(z.capsule)return this._importCapsuleCollider(Y,{offset:new D.Vector3().fromArray((N=z.capsule.offset)!=null?N:[0,0,0]),radius:(oe=z.capsule.radius)!=null?oe:0,tail:new D.Vector3().fromArray((W=z.capsule.tail)!=null?W:[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 _=m==null?void 0:m[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 P=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;P.forEach(M=>{if(E){let R=E.node,T=d[R],L=M.node,y=d[L],A={hitRadius:E.hitRadius,dragForce:E.dragForce,gravityPower:E.gravityPower,stiffness:E.stiffness,gravityDir:E.gravityDir!=null?new D.Vector3().fromArray(E.gravityDir):void 0},b=this._importJoint(T,y,A,x);_&&(b.center=_),u.addJoint(b)}E=M})}),u.setInitState(),u})}_v0Import(e){return Qe(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 gi,h=yield e.parser.getDependencies("node"),p=(r=s.colliderGroups)==null?void 0:r.map(m=>{var c;let f=h[m.node];return{colliders:((c=m.colliders)!=null?c:[]).map((v,P)=>{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((m,c)=>{let f=m.bones;f&&f.forEach(g=>{var v,P,x,_;let E=h[g],M=new D.Vector3;m.gravityDir?M.set((v=m.gravityDir.x)!=null?v:0,(P=m.gravityDir.y)!=null?P:0,(x=m.gravityDir.z)!=null?x:0):M.set(0,-1,0);let R=m.center!=null?h[m.center]:void 0,T={hitRadius:m.hitRadius,dragForce:m.dragForce,gravityPower:m.gravityPower,stiffness:m.stiffiness,gravityDir:M},L=(_=m.colliderGroups)==null?void 0:_.map(y=>{let A=p==null?void 0:p[y];if(A==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${c} attempted to use a colliderGroup ${y} but not found`);return A});E.traverse(y=>{var A;let b=(A=y.children[0])!=null?A:null,N=this._importJoint(y,b,T,L);R&&(N.center=R),d.addJoint(N)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let o=new Bo(e,n,i,r);if(this.jointHelperRoot){let a=new Io(o);this.jointHelperRoot.add(a),a.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(e,n){let i=new Mi(n),r=new wt(i);if(e.add(r),this.colliderHelperRoot){let o=new yt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,n){let i=new vi(n),r=new wt(i);if(e.add(r),this.colliderHelperRoot){let o=new yt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,n){let i=new Ei(n),r=new wt(i);if(e.add(r),this.colliderHelperRoot){let o=new yt(r);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return r}};xi.EXTENSION_NAME="VRMC_springBone";var yi=xi;var bt=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var o,a,l,s,u,d,h,p,m,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 ut(e),this.firstPersonPlugin=(a=n==null?void 0:n.firstPersonPlugin)!=null?a:new ht(e),this.humanoidPlugin=(l=n==null?void 0:n.humanoidPlugin)!=null?l:new ct(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(s=n==null?void 0:n.lookAtPlugin)!=null?s:new mt(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new ft(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new ii(e),this.materialsHDREmissiveMultiplierPlugin=(h=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?h:new oi(e),this.materialsV0CompatPlugin=(p=n==null?void 0:n.materialsV0CompatPlugin)!=null?p:new di(e),this.springBonePlugin=(m=n==null?void 0:n.springBonePlugin)!=null?m:new yi(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(c=n==null?void 0:n.nodeConstraintPlugin)!=null?c:new mi(e,{helperRoot:i})}beforeRoot(){return xe(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(e){return xe(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 xe(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(e,n),yield this.mtoonMaterialPlugin.extendMaterialParams(e,n)})}afterRoot(e){return xe(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 Ae({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 Si from"three";function zo(t){let e=new Set;return t.traverse(n=>{if(!n.isMesh)return;let i=n;e.add(i)}),e}function wi(t,e,n){if(e.size===1){let 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 Si.BufferAttribute(i,3)}function Pi(t){var r;let e=zo(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 Se){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,p={},m={},c=[];if(d||h){d&&(p.position=[]),h&&(p.normal=[]);let f=0;for(let[g,v]of a)d&&(p.position[f]=wi(l.position,v,u)),h&&(p.normal[f]=wi(l.normal,v,u)),i==null||i[g].addBind(new Se({index:f,weight:1,primitives:[o]})),m[g]=f,c.push(0),f++}s.morphAttributes=p,o.morphTargetDictionary=m,o.morphTargetInfluences=c}}import*as Re from"three";import*as Ai from"three";function Me(t,e,n){if(t.getComponent)return t.getComponent(e,n);{let i=t.array[e*t.itemSize+n];return t.normalized&&(i=Ai.MathUtils.denormalize(i,t.array)),i}}import*as Li from"three";function qe(t,e,n,i){t.setComponent?t.setComponent(e,n,i):(t.normalized&&(i=Li.MathUtils.normalize(i,t.array)),t.array[e*t.itemSize+n]=i)}function bi(t){var d;let e=Go(t),n=new Set;for(let h of e)n.has(h.geometry)&&(h.geometry=$o(h.geometry)),n.add(h.geometry);let i=new Map;for(let h of n){let p=h.getAttribute("skinIndex"),m=(d=i.get(p))!=null?d:new Map;i.set(p,m);let c=h.getAttribute("skinWeight"),f=jo(p,c);m.set(c,f)}let r=new Map;for(let h of e){let p=Xo(h,i);r.set(h,p)}let o=[];for(let[h,p]of r){let m=!1;for(let c of o)if(Qo(p,c.boneInverseMap)){m=!0,c.meshes.add(h);for(let[g,v]of p)c.boneInverseMap.set(g,v);break}m||o.push({boneInverseMap:p,meshes:new Set([h])})}let a=new Map,l=new Ue,s=new Ue,u=new Ue;for(let h of o){let{boneInverseMap:p,meshes:m}=h,c=Array.from(p.keys()),f=Array.from(p.values()),g=new Re.Skeleton(c,f),v=s.getOrCreate(g);for(let P of m){let x=P.geometry.getAttribute("skinIndex"),_=l.getOrCreate(x),E=P.skeleton.bones,M=E.map(L=>u.getOrCreate(L)).join(","),R=`${_};${v};${M}`,T=a.get(R);T==null&&(T=x.clone(),Yo(T,E,c),a.set(R,T)),P.geometry.setAttribute("skinIndex",T)}for(let P of m)P.bind(g,new Re.Matrix4)}}function Go(t){let e=new Set;return t.traverse(n=>{if(!n.isSkinnedMesh)return;let i=n;e.add(i)}),e}function jo(t,e){let n=new Set;for(let i=0;i<t.count;i++)for(let r=0;r<t.itemSize;r++){let o=Me(t,i,r);Me(e,i,r)!==0&&n.add(o)}return n}function Xo(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 Qo(t,e){for(let[n,i]of t.entries()){let r=e.get(n);if(r!=null&&!qo(i,r))return!1}return!0}function Yo(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=Me(t,o,a),s=r.get(l);qe(t,o,a,s)}t.needsUpdate=!0}function qo(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 $o(t){var n,i,r,o;let e=new Re.BufferGeometry;e.name=t.name,e.setIndex(t.index);for(let[a,l]of Object.entries(t.attributes))e.setAttribute(a,l);for(let[a,l]of Object.entries(t.morphAttributes)){let s=a;e.morphAttributes[s]=l.concat()}e.morphTargetsRelative=t.morphTargetsRelative,e.groups=[];for(let a of t.groups)e.addGroup(a.start,a.count,a.materialIndex);return e.boundingSphere=(i=(n=t.boundingSphere)==null?void 0:n.clone())!=null?i:null,e.boundingBox=(o=(r=t.boundingBox)==null?void 0:r.clone())!=null?o:null,e.drawRange.start=t.drawRange.start,e.drawRange.count=t.drawRange.count,e.userData=t.userData,e}function Hi(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 Zo(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=>Hi(r)):i&&Hi(i))}function Ii(t){t.traverse(Zo)}import*as $e from"three";function Vi(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,p=new Map;for(let m=0;m<d.count;m++)for(let c=0;c<d.itemSize;c++){let f=Me(d,m,c),g=h.get(f);g==null&&(g=h.size,h.set(f,g),p.set(g,f)),qe(d,m,c,g)}d.needsUpdate=!0,r.set(d,p),o=Math.max(o,h.size)}for(let s of i){let d=s.geometry.getAttribute("skinIndex"),h=r.get(d),p=[],m=[],c=n?o:h.size;for(let g=0;g<c;g++){let v=(l=h.get(g))!=null?l:0;p.push(s.skeleton.bones[v]),m.push(s.skeleton.boneInverses[v])}let f=new $e.Skeleton(p,m);s.bind(f,new $e.Matrix4)}}import*as Ci from"three";import{BufferAttribute as Ht}from"three";function Ui(t){let e=new Map;t.traverse(n=>{var g,v,P,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=[],p=[],m=0;for(let _=0;_<s.length;_++)if(s[_]){let E=m++;h[_]=E,p[E]=_}let c=new Ci.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=(P=r.boundingSphere)==null?void 0:P.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],T=h[R];E[M]=T}c.setIndex(new Ht(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:T}=E,L=new M.constructor(p.length*R);p.forEach((y,A)=>{for(let b=0;b<R;b++)L[A*R+b]=M[y*R+b]}),c.setAttribute(_,new Ht(L,R,T))});let f=!0;for(let[_,E]of Object.entries(r.morphAttributes)){let M=_;c.morphAttributes[M]=[];for(let R=0;R<E.length;R++){let T=E[R];if(T.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let L=T.array,{itemSize:y,normalized:A}=T,b=new L.constructor(p.length*y);p.forEach((N,oe)=>{for(let W=0;W<y;W++)b[oe*y+W]=L[N*y+W]}),f=f&&b.every(N=>N===0),c.morphAttributes[M][R]=new Ht(b,y,A)}}f&&(c.morphAttributes={}),i.geometry=c}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function Oi(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var re=class{constructor(){}};re.combineMorphs=Pi,re.combineSkeletons=bi,re.deepDispose=Ii,re.removeUnnecessaryJoints=Vi,re.removeUnnecessaryVertices=Ui,re.rotateVRM0=Oi;export{qr as MToonMaterial,Qr as MToonMaterialDebugMode,ii as MToonMaterialLoaderPlugin,Jn as MToonMaterialOutlineWidthMode,Ae as VRM,mo as VRMAimConstraint,gt as VRMCore,ss as VRMCoreLoaderPlugin,dn as VRMExpression,ut as VRMExpressionLoaderPlugin,pn as VRMExpressionManager,mn as VRMExpressionMaterialColorBind,ye as VRMExpressionMaterialColorType,Se as VRMExpressionMorphTargetBind,ns as VRMExpressionOverrideType,it as VRMExpressionPresetName,gn as VRMExpressionTextureTransformBind,_n as VRMFirstPerson,ht as VRMFirstPersonLoaderPlugin,is as VRMFirstPersonMeshAnnotationType,Ke as VRMHumanBoneList,rs as VRMHumanBoneName,vr as VRMHumanBoneParentMap,Tn as VRMHumanoid,Mn as VRMHumanoidHelper,ct as VRMHumanoidLoaderPlugin,bt as VRMLoaderPlugin,Cr as VRMLookAt,We as VRMLookAtBoneApplier,at as VRMLookAtExpressionApplier,Sr as VRMLookAtHelper,mt as VRMLookAtLoaderPlugin,Hn as VRMLookAtRangeMap,os as VRMLookAtTypeName,ft as VRMMetaLoaderPlugin,Rt as VRMNodeConstraint,Et as VRMNodeConstraintHelper,mi as VRMNodeConstraintLoaderPlugin,go as VRMNodeConstraintManager,Rr as VRMRequiredHumanBoneName,xo as VRMRollConstraint,Eo as VRMRotationConstraint,wt as VRMSpringBoneCollider,yt as VRMSpringBoneColliderHelper,At as VRMSpringBoneColliderShape,vi as VRMSpringBoneColliderShapeCapsule,Ei as VRMSpringBoneColliderShapePlane,Mi as VRMSpringBoneColliderShapeSphere,Bo as VRMSpringBoneJoint,Io as VRMSpringBoneJointHelper,yi as VRMSpringBoneLoaderPlugin,gi as VRMSpringBoneManager,re as VRMUtils};
925
925
  /*!
926
- * @pixiv/three-vrm-core v3.4.1
926
+ * @pixiv/three-vrm-core v3.4.2
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.4.1
934
+ * @pixiv/three-vrm-materials-mtoon v3.4.2
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.4.1
942
+ * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.2
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.4.1
950
+ * @pixiv/three-vrm-materials-v0compat v3.4.2
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.4.1
958
+ * @pixiv/three-vrm-node-constraint v3.4.2
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.4.1
966
+ * @pixiv/three-vrm-springbone v3.4.2
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.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "VRM file loader for three.js.",
5
5
  "license": "MIT",
6
6
  "author": "pixiv",
@@ -55,19 +55,19 @@
55
55
  ]
56
56
  },
57
57
  "dependencies": {
58
- "@pixiv/three-vrm-core": "3.4.1",
59
- "@pixiv/three-vrm-materials-hdr-emissive-multiplier": "3.4.1",
60
- "@pixiv/three-vrm-materials-mtoon": "3.4.1",
61
- "@pixiv/three-vrm-materials-v0compat": "3.4.1",
62
- "@pixiv/three-vrm-node-constraint": "3.4.1",
63
- "@pixiv/three-vrm-springbone": "3.4.1"
58
+ "@pixiv/three-vrm-core": "3.4.2",
59
+ "@pixiv/three-vrm-materials-hdr-emissive-multiplier": "3.4.2",
60
+ "@pixiv/three-vrm-materials-mtoon": "3.4.2",
61
+ "@pixiv/three-vrm-materials-v0compat": "3.4.2",
62
+ "@pixiv/three-vrm-node-constraint": "3.4.2",
63
+ "@pixiv/three-vrm-springbone": "3.4.2"
64
64
  },
65
65
  "devDependencies": {
66
- "@types/three": "^0.176.0",
67
- "three": "^0.176.0"
66
+ "@types/three": "^0.177.0",
67
+ "three": "^0.177.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "three": ">=0.137"
71
71
  },
72
- "gitHead": "52b29f643f3091ca3ae767a8464411f35e4fdfbd"
72
+ "gitHead": "d20d8cd0ec2c18e8226a9fc45a524bb16646d86e"
73
73
  }