@pixiv/three-vrm 3.0.0-beta.0 → 3.0.0-beta.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 +15 -9
- package/lib/nodes/index.cjs +515 -0
- package/lib/nodes/index.min.cjs +10 -0
- package/lib/nodes/index.module.js +483 -0
- package/lib/nodes/index.module.min.js +10 -0
- package/lib/three-vrm.cjs +164 -627
- package/lib/three-vrm.min.cjs +49 -124
- package/lib/three-vrm.module.js +164 -627
- package/lib/three-vrm.module.min.js +49 -124
- package/package.json +16 -12
- package/types/VRMUtils/removeUnnecessaryJoints.d.ts +10 -4
- package/types/nodes/index.d.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! (c) 2019-2024 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
|
|
2
|
-
var Re=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())});import*as bn from"three";import*as K from"three";import*as Cn from"three";import*as nt from"three";import*as Bn from"three";import*as k from"three";import*as Y from"three";import*as De from"three";import*as z from"three";import*as L from"three";import*as ye from"three";import*as ee from"three";import*as b from"three";import*as at from"three";import*as N from"three";import*as et from"three";import*as $n from"three";var P=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())}),un=class extends bn.Object3D{constructor(e){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${e}`,this.expressionName=e,this.type="VRMExpression",this.visible=!1}get overrideBlinkAmount(){return this.overrideBlink==="block"?0<this.weight?1:0:this.overrideBlink==="blend"?this.weight:0}get overrideLookAtAmount(){return this.overrideLookAt==="block"?0<this.weight?1:0:this.overrideLookAt==="blend"?this.weight:0}get overrideMouthAmount(){return this.overrideMouth==="block"?0<this.weight?1:0:this.overrideMouth==="blend"?this.weight:0}addBind(e){this._binds.push(e)}applyWeight(e){var t;let n=this.isBinary?this.weight<=.5?0:1:this.weight;n*=(t=e==null?void 0:e.multiplier)!=null?t:1,this._binds.forEach(i=>i.applyWeight(n))}clearAppliedWeight(){this._binds.forEach(e=>e.clearAppliedWeight())}};function In(e,t,n){var i,r;let o=e.parser.json,l=(i=o.nodes)==null?void 0:i[t];if(l==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${t}] of glTF but the node doesn't exist`),null;let a=l.mesh;if(a==null)return null;let s=(r=o.meshes)==null?void 0:r[a];if(s==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${a}] of glTF but the mesh doesn't exist`),null;let u=s.primitives.length,d=[];return n.traverse(c=>{d.length<u&&c.isMesh&&d.push(c)}),d}function dn(e,t){return P(this,null,function*(){let n=yield e.parser.getDependency("node",t);return In(e,t,n)})}function hn(e){return P(this,null,function*(){let t=yield e.parser.getDependencies("node"),n=new Map;return t.forEach((i,r)=>{let o=In(e,r,i);o!=null&&n.set(r,o)}),n})}function cn(e,t){var n,i;let r=parseInt(Cn.REVISION,10),o=null;if(r>=133)o=(i=(n=e.associations.get(t))==null?void 0:n.materials)!=null?i:null;else{let a=e.associations.get(t);(a==null?void 0:a.type)==="materials"&&(o=a.index)}return o}var Ze={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function Un(e){return Math.max(Math.min(e,1),0)}var mn=class On{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){let t={},n=new Set(Object.values(Ze));return Object.entries(this._expressionMap).forEach(([i,r])=>{n.has(i)&&(t[i]=r)}),t}get customExpressionMap(){let t={},n=new Set(Object.values(Ze));return Object.entries(this._expressionMap).forEach(([i,r])=>{n.has(i)||(t[i]=r)}),t}copy(t){return this._expressions.concat().forEach(i=>{this.unregisterExpression(i)}),t._expressions.forEach(i=>{this.registerExpression(i)}),this.blinkExpressionNames=t.blinkExpressionNames.concat(),this.lookAtExpressionNames=t.lookAtExpressionNames.concat(),this.mouthExpressionNames=t.mouthExpressionNames.concat(),this}clone(){return new On().copy(this)}getExpression(t){var n;return(n=this._expressionMap[t])!=null?n:null}registerExpression(t){this._expressions.push(t),this._expressionMap[t.expressionName]=t}unregisterExpression(t){let n=this._expressions.indexOf(t);n===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(n,1),delete this._expressionMap[t.expressionName]}getValue(t){var n;let i=this.getExpression(t);return(n=i==null?void 0:i.weight)!=null?n:null}setValue(t,n){let i=this.getExpression(t);i&&(i.weight=Un(n))}getExpressionTrackName(t){let n=this.getExpression(t);return n?`${n.name}.weight`:null}update(){let t=this._calculateWeightMultipliers();this._expressions.forEach(n=>{n.clearAppliedWeight()}),this._expressions.forEach(n=>{let i=1,r=n.expressionName;this.blinkExpressionNames.indexOf(r)!==-1&&(i*=t.blink),this.lookAtExpressionNames.indexOf(r)!==-1&&(i*=t.lookAt),this.mouthExpressionNames.indexOf(r)!==-1&&(i*=t.mouth),n.applyWeight({multiplier:i})})}_calculateWeightMultipliers(){let t=1,n=1,i=1;return this._expressions.forEach(r=>{t-=r.overrideBlinkAmount,n-=r.overrideLookAtAmount,i-=r.overrideMouthAmount}),t=Math.max(0,t),n=Math.max(0,n),i=Math.max(0,i),{blink:t,lookAt:n,mouth:i}}},Te={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",MatcapColor:"matcapColor",RimColor:"rimColor",OutlineColor:"outlineColor"},vr={_Color:Te.Color,_EmissionColor:Te.EmissionColor,_ShadeColor:Te.ShadeColor,_RimColor:Te.RimColor,_OutlineColor:Te.OutlineColor},Er=new nt.Color,Fn=class Dn{constructor({material:t,type:n,targetValue:i,targetAlpha:r}){this.material=t,this.type=n,this.targetValue=i,this.targetAlpha=r!=null?r:1;let o=this._initColorBindState(),l=this._initAlphaBindState();this._state={color:o,alpha:l}}applyWeight(t){let{color:n,alpha:i}=this._state;if(n!=null){let{propertyName:r,deltaValue:o}=n,l=this.material[r];l!=null&&l.add(Er.copy(o).multiplyScalar(t))}if(i!=null){let{propertyName:r,deltaValue:o}=i;this.material[r]!=null&&(this.material[r]+=o*t)}}clearAppliedWeight(){let{color:t,alpha:n}=this._state;if(t!=null){let{propertyName:i,initialValue:r}=t,o=this.material[i];o!=null&&o.copy(r)}if(n!=null){let{propertyName:i,initialValue:r}=n;this.material[i]!=null&&(this.material[i]=r)}}_initColorBindState(){var t,n,i;let{material:r,type:o,targetValue:l}=this,a=this._getPropertyNameMap(),s=(n=(t=a==null?void 0:a[o])==null?void 0:t[0])!=null?n:null;if(s==null)return console.warn(`Tried to add a material color bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${o} but the material or the type is not supported.`),null;let d=r[s].clone(),c=new nt.Color(l.r-d.r,l.g-d.g,l.b-d.b);return{propertyName:s,initialValue:d,deltaValue:c}}_initAlphaBindState(){var t,n,i;let{material:r,type:o,targetAlpha:l}=this,a=this._getPropertyNameMap(),s=(n=(t=a==null?void 0:a[o])==null?void 0:t[1])!=null?n:null;if(s==null&&l!==1)return console.warn(`Tried to add a material alpha bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${o} but the material or the type does not support alpha.`),null;if(s==null)return null;let u=r[s],d=l-u;return{propertyName:s,initialValue:u,deltaValue:d}}_getPropertyNameMap(){var t,n;return(n=(t=Object.entries(Dn._propertyNameMapMap).find(([i])=>this.material[i]===!0))==null?void 0:t[1])!=null?n:null}};Fn._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var pn=Fn,fn=class{constructor({primitives:e,index:t,weight:n}){this.primitives=e,this.index=t,this.weight=n}applyWeight(e){this.primitives.forEach(t=>{var n;((n=t.morphTargetInfluences)==null?void 0:n[this.index])!=null&&(t.morphTargetInfluences[this.index]+=this.weight*e)})}clearAppliedWeight(){this.primitives.forEach(e=>{var t;((t=e.morphTargetInfluences)==null?void 0:t[this.index])!=null&&(e.morphTargetInfluences[this.index]=0)})}},gn=new Bn.Vector2,Wn=class kn{constructor({material:t,scale:n,offset:i}){var r,o;this.material=t,this.scale=n,this.offset=i;let l=(r=Object.entries(kn._propertyNamesMap).find(([a])=>t[a]===!0))==null?void 0:r[1];l==null?(console.warn(`Tried to add a texture transform bind to the material ${(o=t.name)!=null?o:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],l.forEach(a=>{var s;let u=(s=t[a])==null?void 0:s.clone();if(!u)return null;t[a]=u;let d=u.offset.clone(),c=u.repeat.clone(),f=i.clone().sub(d),m=n.clone().sub(c);this._properties.push({name:a,initialOffset:d,deltaOffset:f,initialScale:c,deltaScale:m})}))}applyWeight(t){this._properties.forEach(n=>{let i=this.material[n.name];i!==void 0&&(i.offset.add(gn.copy(n.deltaOffset).multiplyScalar(t)),i.repeat.add(gn.copy(n.deltaScale).multiplyScalar(t)))})}clearAppliedWeight(){this._properties.forEach(t=>{let n=this.material[t.name];n!==void 0&&(n.offset.copy(t.initialOffset),n.repeat.copy(t.initialScale))})}};Wn._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var _n=Wn,Mr=new Set(["1.0","1.0-beta"]),zn=class jn{get name(){return"VRMExpressionLoaderPlugin"}constructor(t){this.parser=t}afterRoot(t){return P(this,null,function*(){t.userData.vrmExpressionManager=yield this._import(t)})}_import(t){return P(this,null,function*(){let n=yield this._v1Import(t);if(n)return n;let i=yield this._v0Import(t);return i||null})}_v1Import(t){return P(this,null,function*(){var n,i;let r=this.parser.json;if(!(((n=r.extensionsUsed)==null?void 0:n.indexOf("VRMC_vrm"))!==-1))return null;let l=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!l)return null;let a=l.specVersion;if(!Mr.has(a))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;let s=l.expressions;if(!s)return null;let u=new Set(Object.values(Ze)),d=new Map;s.preset!=null&&Object.entries(s.preset).forEach(([f,m])=>{if(m!=null){if(!u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${f}" detected. Ignoring the expression`);return}d.set(f,m)}}),s.custom!=null&&Object.entries(s.custom).forEach(([f,m])=>{if(u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${f}". Ignoring the expression`);return}d.set(f,m)});let c=new mn;return yield Promise.all(Array.from(d.entries()).map(f=>P(this,[f],function*([m,p]){var h,g,_,R,E,v,x;let M=new un(m);if(t.scene.add(M),M.isBinary=(h=p.isBinary)!=null?h:!1,M.overrideBlink=(g=p.overrideBlink)!=null?g:"none",M.overrideLookAt=(_=p.overrideLookAt)!=null?_:"none",M.overrideMouth=(R=p.overrideMouth)!=null?R:"none",(E=p.morphTargetBinds)==null||E.forEach(T=>P(this,null,function*(){var H;if(T.node===void 0||T.index===void 0)return;let U=yield dn(t,T.node),V=T.index;if(!U.every(I=>Array.isArray(I.morphTargetInfluences)&&V<I.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${p.name} attempts to index morph #${V} but not found.`);return}M.addBind(new fn({primitives:U,index:V,weight:(H=T.weight)!=null?H:1}))})),p.materialColorBinds||p.textureTransformBinds){let T=[];t.scene.traverse(H=>{let U=H.material;U&&T.push(U)}),(v=p.materialColorBinds)==null||v.forEach(H=>P(this,null,function*(){T.filter(V=>{let I=cn(this.parser,V);return H.material===I}).forEach(V=>{M.addBind(new pn({material:V,type:H.type,targetValue:new K.Color().fromArray(H.targetValue),targetAlpha:H.targetValue[3]}))})})),(x=p.textureTransformBinds)==null||x.forEach(H=>P(this,null,function*(){T.filter(V=>{let I=cn(this.parser,V);return H.material===I}).forEach(V=>{var I,j;M.addBind(new _n({material:V,offset:new K.Vector2().fromArray((I=H.offset)!=null?I:[0,0]),scale:new K.Vector2().fromArray((j=H.scale)!=null?j:[1,1])}))})}))}c.registerExpression(M)}))),c})}_v0Import(t){return P(this,null,function*(){var n;let i=this.parser.json,r=(n=i.extensions)==null?void 0:n.VRM;if(!r)return null;let o=r.blendShapeMaster;if(!o)return null;let l=new mn,a=o.blendShapeGroups;if(!a)return l;let s=new Set;return yield Promise.all(a.map(u=>P(this,null,function*(){var d;let c=u.presetName,f=c!=null&&jn.v0v1PresetNameMap[c]||null,m=f!=null?f:u.name;if(m==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(s.has(m)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${c} has duplicated entries. Ignoring the expression`);return}s.add(m);let p=new un(m);t.scene.add(p),p.isBinary=(d=u.isBinary)!=null?d:!1,u.binds&&u.binds.forEach(g=>P(this,null,function*(){var _;if(g.mesh===void 0||g.index===void 0)return;let R=[];(_=i.nodes)==null||_.forEach((v,x)=>{v.mesh===g.mesh&&R.push(x)});let E=g.index;yield Promise.all(R.map(v=>P(this,null,function*(){var x;let M=yield dn(t,v);if(!M.every(T=>Array.isArray(T.morphTargetInfluences)&&E<T.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${u.name} attempts to index ${E}th morph but not found.`);return}p.addBind(new fn({primitives:M,index:E,weight:.01*((x=g.weight)!=null?x:100)}))})))}));let h=u.materialValues;h&&h.length!==0&&h.forEach(g=>{if(g.materialName===void 0||g.propertyName===void 0||g.targetValue===void 0)return;let _=[];t.scene.traverse(E=>{if(E.material){let v=E.material;Array.isArray(v)?_.push(...v.filter(x=>(x.name===g.materialName||x.name===g.materialName+" (Outline)")&&_.indexOf(x)===-1)):v.name===g.materialName&&_.indexOf(v)===-1&&_.push(v)}});let R=g.propertyName;_.forEach(E=>{if(R==="_MainTex_ST"){let x=new K.Vector2(g.targetValue[0],g.targetValue[1]),M=new K.Vector2(g.targetValue[2],g.targetValue[3]);M.y=1-M.y-x.y,p.addBind(new _n({material:E,scale:x,offset:M}));return}let v=vr[R];if(v){p.addBind(new pn({material:E,type:v,targetValue:new K.Color().fromArray(g.targetValue),targetAlpha:g.targetValue[3]}));return}console.warn(R+" is not supported")})}),l.registerExpression(p)}))),l})}};zn.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var it=zn,ws={None:"none",Block:"block",Blend:"blend"},rt=class fe{constructor(t,n){this._firstPersonOnlyLayer=fe.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=fe.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=t,this.meshAnnotations=n}copy(t){if(this.humanoid!==t.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=t.meshAnnotations.map(n=>({meshes:n.meshes.concat(),type:n.type})),this}clone(){return new fe(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:t=fe.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=fe.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=t,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach(i=>{i.meshes.forEach(r=>{i.type==="firstPersonOnly"?(r.layers.set(this._firstPersonOnlyLayer),r.traverse(o=>o.layers.set(this._firstPersonOnlyLayer))):i.type==="thirdPersonOnly"?(r.layers.set(this._thirdPersonOnlyLayer),r.traverse(o=>o.layers.set(this._thirdPersonOnlyLayer))):i.type==="auto"&&this._createHeadlessModel(r)})}),this._initializedLayers=!0)}_excludeTriangles(t,n,i,r){let o=0;if(n!=null&&n.length>0)for(let l=0;l<t.length;l+=3){let a=t[l],s=t[l+1],u=t[l+2],d=n[a],c=i[a];if(d[0]>0&&r.includes(c[0])||d[1]>0&&r.includes(c[1])||d[2]>0&&r.includes(c[2])||d[3]>0&&r.includes(c[3]))continue;let f=n[s],m=i[s];if(f[0]>0&&r.includes(m[0])||f[1]>0&&r.includes(m[1])||f[2]>0&&r.includes(m[2])||f[3]>0&&r.includes(m[3]))continue;let p=n[u],h=i[u];p[0]>0&&r.includes(h[0])||p[1]>0&&r.includes(h[1])||p[2]>0&&r.includes(h[2])||p[3]>0&&r.includes(h[3])||(t[o++]=a,t[o++]=s,t[o++]=u)}return o}_createErasedMesh(t,n){let i=new k.SkinnedMesh(t.geometry.clone(),t.material);i.name=`${t.name}(erase)`,i.frustumCulled=t.frustumCulled,i.layers.set(this._firstPersonOnlyLayer);let r=i.geometry,o=r.getAttribute("skinIndex"),l=o instanceof k.GLBufferAttribute?[]:o.array,a=[];for(let h=0;h<l.length;h+=4)a.push([l[h],l[h+1],l[h+2],l[h+3]]);let s=r.getAttribute("skinWeight"),u=s instanceof k.GLBufferAttribute?[]:s.array,d=[];for(let h=0;h<u.length;h+=4)d.push([u[h],u[h+1],u[h+2],u[h+3]]);let c=r.getIndex();if(!c)throw new Error("The geometry doesn't have an index buffer");let f=Array.from(c.array),m=this._excludeTriangles(f,d,a,n),p=[];for(let h=0;h<m;h++)p[h]=f[h];return r.setIndex(p),t.onBeforeRender&&(i.onBeforeRender=t.onBeforeRender),i.bind(new k.Skeleton(t.skeleton.bones,t.skeleton.boneInverses),new k.Matrix4),i}_createHeadlessModelForSkinnedMesh(t,n){let i=[];if(n.skeleton.bones.forEach((o,l)=>{this._isEraseTarget(o)&&i.push(l)}),!i.length){n.layers.enable(this._thirdPersonOnlyLayer),n.layers.enable(this._firstPersonOnlyLayer);return}n.layers.set(this._thirdPersonOnlyLayer);let r=this._createErasedMesh(n,i);t.add(r)}_createHeadlessModel(t){if(t.type==="Group")if(t.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(t))t.traverse(n=>n.layers.set(this._thirdPersonOnlyLayer));else{let n=new k.Group;n.name=`_headless_${t.name}`,n.layers.set(this._firstPersonOnlyLayer),t.parent.add(n),t.children.filter(i=>i.type==="SkinnedMesh").forEach(i=>{let r=i;this._createHeadlessModelForSkinnedMesh(n,r)})}else if(t.type==="SkinnedMesh"){let n=t;this._createHeadlessModelForSkinnedMesh(t.parent,n)}else this._isEraseTarget(t)&&(t.layers.set(this._thirdPersonOnlyLayer),t.traverse(n=>n.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(t){return t===this.humanoid.getRawBoneNode("head")?!0:t.parent?this._isEraseTarget(t.parent):!1}};rt.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;rt.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var vn=rt,Rr=new Set(["1.0","1.0-beta"]),ot=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return P(this,null,function*(){let t=e.userData.vrmHumanoid;if(t!==null){if(t===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");e.userData.vrmFirstPerson=yield this._import(e,t)}})}_import(e,t){return P(this,null,function*(){if(t==null)return null;let n=yield this._v1Import(e,t);if(n)return n;let i=yield this._v0Import(e,t);return i||null})}_v1Import(e,t){return P(this,null,function*(){var n,i;let r=this.parser.json;if(!(((n=r.extensionsUsed)==null?void 0:n.indexOf("VRMC_vrm"))!==-1))return null;let l=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!l)return null;let a=l.specVersion;if(!Rr.has(a))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;let s=l.firstPerson;if(!s)return null;let u=[],d=yield hn(e);return Array.from(d.entries()).forEach(([c,f])=>{var m;let p=s.meshAnnotations?s.meshAnnotations.find(h=>h.node===c):void 0;u.push({meshes:f,type:(m=p==null?void 0:p.type)!=null?m:"both"})}),new vn(t,u)})}_v0Import(e,t){return P(this,null,function*(){var n;let i=this.parser.json,r=(n=i.extensions)==null?void 0:n.VRM;if(!r)return null;let o=r.firstPerson;if(!o)return null;let l=[],a=yield hn(e);return Array.from(a.entries()).forEach(([s,u])=>{let d=i.nodes[s],c=o.meshAnnotations?o.meshAnnotations.find(f=>f.mesh===d.mesh):void 0;l.push({meshes:u,type:this._convertV0FlagToV1Type(c==null?void 0:c.firstPersonFlag)})}),new vn(t,l)})}_convertV0FlagToV1Type(e){return e==="FirstPersonOnly"?"firstPersonOnly":e==="ThirdPersonOnly"?"thirdPersonOnly":e==="Auto"?"auto":"both"}},Ls={Auto:"auto",Both:"both",ThirdPersonOnly:"thirdPersonOnly",FirstPersonOnly:"firstPersonOnly"},En=new Y.Vector3,Mn=new Y.Vector3,Tr=new Y.Quaternion,Rn=class extends Y.Group{constructor(e){super(),this.vrmHumanoid=e,this._boneAxesMap=new Map,Object.values(e.humanBones).forEach(t=>{let n=new Y.AxesHelper(1);n.matrixAutoUpdate=!1,n.material.depthTest=!1,n.material.depthWrite=!1,this.add(n),this._boneAxesMap.set(t,n)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(e=>{e.geometry.dispose(),e.material.dispose()})}updateMatrixWorld(e){Array.from(this._boneAxesMap.entries()).forEach(([t,n])=>{t.node.updateWorldMatrix(!0,!1),t.node.matrixWorld.decompose(En,Tr,Mn);let i=En.set(.1,.1,.1).divide(Mn);n.matrix.copy(t.node.matrixWorld).scale(i)}),super.updateMatrixWorld(e)}},qe=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],As={Hips:"hips",Spine:"spine",Chest:"chest",UpperChest:"upperChest",Neck:"neck",Head:"head",LeftEye:"leftEye",RightEye:"rightEye",Jaw:"jaw",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",LeftToes:"leftToes",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",RightToes:"rightToes",LeftShoulder:"leftShoulder",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightShoulder:"rightShoulder",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand",LeftThumbMetacarpal:"leftThumbMetacarpal",LeftThumbProximal:"leftThumbProximal",LeftThumbDistal:"leftThumbDistal",LeftIndexProximal:"leftIndexProximal",LeftIndexIntermediate:"leftIndexIntermediate",LeftIndexDistal:"leftIndexDistal",LeftMiddleProximal:"leftMiddleProximal",LeftMiddleIntermediate:"leftMiddleIntermediate",LeftMiddleDistal:"leftMiddleDistal",LeftRingProximal:"leftRingProximal",LeftRingIntermediate:"leftRingIntermediate",LeftRingDistal:"leftRingDistal",LeftLittleProximal:"leftLittleProximal",LeftLittleIntermediate:"leftLittleIntermediate",LeftLittleDistal:"leftLittleDistal",RightThumbMetacarpal:"rightThumbMetacarpal",RightThumbProximal:"rightThumbProximal",RightThumbDistal:"rightThumbDistal",RightIndexProximal:"rightIndexProximal",RightIndexIntermediate:"rightIndexIntermediate",RightIndexDistal:"rightIndexDistal",RightMiddleProximal:"rightMiddleProximal",RightMiddleIntermediate:"rightMiddleIntermediate",RightMiddleDistal:"rightMiddleDistal",RightRingProximal:"rightRingProximal",RightRingIntermediate:"rightRingIntermediate",RightRingDistal:"rightRingDistal",RightLittleProximal:"rightLittleProximal",RightLittleIntermediate:"rightLittleIntermediate",RightLittleDistal:"rightLittleDistal"},xr={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function Gn(e){return e.invert?e.invert():e.inverse(),e}var ae=new De.Vector3,le=new De.Quaternion,Je=class{constructor(e){this.humanBones=e,this.restPose=this.getAbsolutePose()}getAbsolutePose(){let e={};return Object.keys(this.humanBones).forEach(t=>{let n=t,i=this.getBoneNode(n);i&&(ae.copy(i.position),le.copy(i.quaternion),e[n]={position:ae.toArray(),rotation:le.toArray()})}),e}getPose(){let e={};return Object.keys(this.humanBones).forEach(t=>{let n=t,i=this.getBoneNode(n);if(!i)return;ae.set(0,0,0),le.identity();let r=this.restPose[n];r!=null&&r.position&&ae.fromArray(r.position).negate(),r!=null&&r.rotation&&Gn(le.fromArray(r.rotation)),ae.add(i.position),le.premultiply(i.quaternion),e[n]={position:ae.toArray(),rotation:le.toArray()}}),e}setPose(e){Object.entries(e).forEach(([t,n])=>{let i=t,r=this.getBoneNode(i);if(!r)return;let o=this.restPose[i];o&&(n!=null&&n.position&&(r.position.fromArray(n.position),o.position&&r.position.add(ae.fromArray(o.position))),n!=null&&n.rotation&&(r.quaternion.fromArray(n.rotation),o.rotation&&r.quaternion.multiply(le.fromArray(o.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([e,t])=>{let n=this.getBoneNode(e);n&&(t!=null&&t.position&&n.position.fromArray(t.position),t!=null&&t.rotation&&n.quaternion.fromArray(t.rotation))})}getBone(e){var t;return(t=this.humanBones[e])!=null?t:void 0}getBoneNode(e){var t,n;return(n=(t=this.humanBones[e])==null?void 0:t.node)!=null?n:null}},Xe=new z.Vector3,yr=new z.Quaternion,Sr=new z.Vector3,Tn=class Qn extends Je{static _setupTransforms(t){let n=new z.Object3D;n.name="VRMHumanoidRig";let i={},r={},o={},l={};qe.forEach(s=>{var u;let d=t.getBoneNode(s);if(d){let c=new z.Vector3,f=new z.Quaternion;d.updateWorldMatrix(!0,!1),d.matrixWorld.decompose(c,f,Xe),i[s]=c,r[s]=f,o[s]=d.quaternion.clone();let m=new z.Quaternion;(u=d.parent)==null||u.matrixWorld.decompose(Xe,m,Xe),l[s]=m}});let a={};return qe.forEach(s=>{var u;let d=t.getBoneNode(s);if(d){let c=i[s],f=s,m;for(;m==null&&(f=xr[f],f!=null);)m=i[f];let p=new z.Object3D;p.name="Normalized_"+d.name,(f?(u=a[f])==null?void 0:u.node:n).add(p),p.position.copy(c),m&&p.position.sub(m),a[s]={node:p}}}),{rigBones:a,root:n,parentWorldRotations:l,boneRotations:o}}constructor(t){let{rigBones:n,root:i,parentWorldRotations:r,boneRotations:o}=Qn._setupTransforms(t);super(n),this.original=t,this.root=i,this._parentWorldRotations=r,this._boneRotations=o}update(){qe.forEach(t=>{let n=this.original.getBoneNode(t);if(n!=null){let i=this.getBoneNode(t),r=this._parentWorldRotations[t],o=yr.copy(r).invert(),l=this._boneRotations[t];if(n.quaternion.copy(i.quaternion).multiply(r).premultiply(o).multiply(l),t==="hips"){let a=i.getWorldPosition(Sr);n.parent.updateWorldMatrix(!0,!1);let s=n.parent.matrixWorld,u=a.applyMatrix4(s.invert());n.position.copy(u)}}})}},xn=class qn{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(t,n){var i;this.autoUpdateHumanBones=(i=n==null?void 0:n.autoUpdateHumanBones)!=null?i:!0,this._rawHumanBones=new Je(t),this._normalizedHumanBones=new Tn(this._rawHumanBones)}copy(t){return this.autoUpdateHumanBones=t.autoUpdateHumanBones,this._rawHumanBones=new Je(t.humanBones),this._normalizedHumanBones=new Tn(this._rawHumanBones),this}clone(){return new qn(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(t){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(t)}setRawPose(t){return this._rawHumanBones.setPose(t)}setNormalizedPose(t){return this._normalizedHumanBones.setPose(t)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(t){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(t)}getRawBone(t){return this._rawHumanBones.getBone(t)}getNormalizedBone(t){return this._normalizedHumanBones.getBone(t)}getBoneNode(t){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(t)}getRawBoneNode(t){return this._rawHumanBones.getBoneNode(t)}getNormalizedBoneNode(t){return this._normalizedHumanBones.getBoneNode(t)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},Pr={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},wr=new Set(["1.0","1.0-beta"]),yn={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},st=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(e,t){this.parser=e,this.helperRoot=t==null?void 0:t.helperRoot,this.autoUpdateHumanBones=t==null?void 0:t.autoUpdateHumanBones}afterRoot(e){return P(this,null,function*(){e.userData.vrmHumanoid=yield this._import(e)})}_import(e){return P(this,null,function*(){let t=yield this._v1Import(e);if(t)return t;let n=yield this._v0Import(e);return n||null})}_v1Import(e){return P(this,null,function*(){var t,n;let i=this.parser.json;if(!(((t=i.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;let o=(n=i.extensions)==null?void 0:n.VRMC_vrm;if(!o)return null;let l=o.specVersion;if(!wr.has(l))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${l}"`),null;let a=o.humanoid;if(!a)return null;let s=a.humanBones.leftThumbIntermediate!=null||a.humanBones.rightThumbIntermediate!=null,u={};a.humanBones!=null&&(yield Promise.all(Object.entries(a.humanBones).map(c=>P(this,[c],function*([f,m]){let p=f,h=m.node;if(s){let _=yn[p];_!=null&&(p=_)}let g=yield this.parser.getDependency("node",h);if(g==null){console.warn(`A glTF node bound to the humanoid bone ${p} (index = ${h}) does not exist`);return}u[p]={node:g}}))));let d=new xn(this._ensureRequiredBonesExist(u),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(d.normalizedHumanBonesRoot),this.helperRoot){let c=new Rn(d);this.helperRoot.add(c),c.renderOrder=this.helperRoot.renderOrder}return d})}_v0Import(e){return P(this,null,function*(){var t;let i=(t=this.parser.json.extensions)==null?void 0:t.VRM;if(!i)return null;let r=i.humanoid;if(!r)return null;let o={};r.humanBones!=null&&(yield Promise.all(r.humanBones.map(a=>P(this,null,function*(){let s=a.bone,u=a.node;if(s==null||u==null)return;let d=yield this.parser.getDependency("node",u);if(d==null){console.warn(`A glTF node bound to the humanoid bone ${s} (index = ${u}) does not exist`);return}let c=yn[s],f=c!=null?c:s;if(o[f]!=null){console.warn(`Multiple bone entries for ${f} detected (index = ${u}), ignoring duplicated entries.`);return}o[f]={node:d}}))));let l=new xn(this._ensureRequiredBonesExist(o),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(e.scene.add(l.normalizedHumanBonesRoot),this.helperRoot){let a=new Rn(l);this.helperRoot.add(a),a.renderOrder=this.helperRoot.renderOrder}return l})}_ensureRequiredBonesExist(e){let t=Object.values(Pr).filter(n=>e[n]==null);if(t.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${t.join(", ")}`);return e}},Sn=class extends ye.BufferGeometry{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new ye.BufferAttribute(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ye.BufferAttribute(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,e=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let e=0;e<64;e++){let t=e/63*this._currentTheta;this._attrPos.setXYZ(e+1,this._currentRadius*Math.sin(t),0,this._currentRadius*Math.cos(t))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<63;e++)this._attrIndex.setXYZ(e*3,0,e+1,e+2);this._attrIndex.needsUpdate=!0}},Lr=class extends ee.BufferGeometry{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new ee.Vector3,this._currentTail=new ee.Vector3,this._attrPos=new ee.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new ee.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,e=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}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 e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},Ce=new L.Quaternion,Pn=new L.Quaternion,xe=new L.Vector3,wn=new L.Vector3,Ln=Math.sqrt(2)/2,Ar=new L.Quaternion(0,0,-Ln,Ln),Nr=new L.Vector3(0,1,0),Hr=class extends L.Group{constructor(e){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=e;{let t=new Sn;t.radius=.5;let n=new L.MeshBasicMaterial({color:65280,transparent:!0,opacity:.5,side:L.DoubleSide,depthTest:!1,depthWrite:!1});this._meshPitch=new L.Mesh(t,n),this.add(this._meshPitch)}{let t=new Sn;t.radius=.5;let n=new L.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5,side:L.DoubleSide,depthTest:!1,depthWrite:!1});this._meshYaw=new L.Mesh(t,n),this.add(this._meshYaw)}{let t=new Lr;t.radius=.1;let n=new L.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new L.LineSegments(t,n),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(e){let t=L.MathUtils.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=t,this._meshYaw.geometry.update();let n=L.MathUtils.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=n,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(xe),this.vrmLookAt.getLookAtWorldQuaternion(Ce),Ce.multiply(this.vrmLookAt.getFaceFrontQuaternion(Pn)),this._meshYaw.position.copy(xe),this._meshYaw.quaternion.copy(Ce),this._meshPitch.position.copy(xe),this._meshPitch.quaternion.copy(Ce),this._meshPitch.quaternion.multiply(Pn.setFromAxisAngle(Nr,t)),this._meshPitch.quaternion.multiply(Ar);let{target:i,autoUpdate:r}=this.vrmLookAt;i!=null&&r&&(i.getWorldPosition(wn).sub(xe),this._lineTarget.geometry.tail.copy(wn),this._lineTarget.geometry.update(),this._lineTarget.position.copy(xe)),super.updateMatrixWorld(e)}},Vr=new at.Vector3,br=new at.Vector3;function Ke(e,t){return e.matrixWorld.decompose(Vr,t,br),t}function Oe(e){return[Math.atan2(-e.z,e.x),Math.atan2(e.y,Math.sqrt(e.x*e.x+e.z*e.z))]}function An(e){let t=Math.round(e/2/Math.PI);return e-2*Math.PI*t}var Nn=new b.Vector3(0,0,1),Ir=new b.Vector3,Cr=new b.Vector3,Ur=new b.Vector3,Or=new b.Quaternion,Ye=new b.Quaternion,Hn=new b.Quaternion,Fr=new b.Quaternion,$e=new b.Euler,Xn=class Yn{constructor(t,n){this.offsetFromHeadBone=new b.Vector3,this.autoUpdate=!0,this.faceFront=new b.Vector3(0,0,1),this.humanoid=t,this.applier=n,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new b.Quaternion)}get yaw(){return this._yaw}set yaw(t){this._yaw=t,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(t){this._pitch=t,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new b.Euler)}getEuler(t){return t.set(b.MathUtils.DEG2RAD*this._pitch,b.MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(t){if(this.humanoid!==t.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(t.offsetFromHeadBone),this.applier=t.applier,this.autoUpdate=t.autoUpdate,this.target=t.target,this.faceFront.copy(t.faceFront),this}clone(){return new Yn(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(t){let n=this.humanoid.getRawBoneNode("head");return t.copy(this.offsetFromHeadBone).applyMatrix4(n.matrixWorld)}getLookAtWorldQuaternion(t){let n=this.humanoid.getRawBoneNode("head");return Ke(n,t)}getFaceFrontQuaternion(t){if(this.faceFront.distanceToSquared(Nn)<.01)return t.copy(this._restHeadWorldQuaternion).invert();let[n,i]=Oe(this.faceFront);return $e.set(0,.5*Math.PI+n,i,"YZX"),t.setFromEuler($e).premultiply(Fr.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(t){return this.getLookAtWorldQuaternion(Ye),this.getFaceFrontQuaternion(Hn),t.copy(Nn).applyQuaternion(Ye).applyQuaternion(Hn).applyEuler(this.getEuler($e))}lookAt(t){let n=Or.copy(this._restHeadWorldQuaternion).multiply(Gn(this.getLookAtWorldQuaternion(Ye))),i=this.getLookAtWorldPosition(Cr),r=Ur.copy(t).sub(i).applyQuaternion(n).normalize(),[o,l]=Oe(this.faceFront),[a,s]=Oe(r),u=An(a-o),d=An(l-s);this._yaw=b.MathUtils.RAD2DEG*u,this._pitch=b.MathUtils.RAD2DEG*d,this._needsUpdate=!0}update(t){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(Ir)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Xn.EULER_ORDER="YXZ";var Dr=Xn,Br=new N.Vector3(0,0,1),G=new N.Quaternion,pe=new N.Quaternion,W=new N.Euler(0,0,0,"YXZ"),Fe=class{constructor(e,t,n,i,r){this.humanoid=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r,this.faceFront=new N.Vector3(0,0,1),this._restQuatLeftEye=new N.Quaternion,this._restQuatRightEye=new N.Quaternion,this._restLeftEyeParentWorldQuat=new N.Quaternion,this._restRightEyeParentWorldQuat=new N.Quaternion;let o=this.humanoid.getRawBoneNode("leftEye"),l=this.humanoid.getRawBoneNode("rightEye");o&&(this._restQuatLeftEye.copy(o.quaternion),Ke(o.parent,this._restLeftEyeParentWorldQuat)),l&&(this._restQuatRightEye.copy(l.quaternion),Ke(l.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(e,t){let n=this.humanoid.getRawBoneNode("leftEye"),i=this.humanoid.getRawBoneNode("rightEye"),r=this.humanoid.getNormalizedBoneNode("leftEye"),o=this.humanoid.getNormalizedBoneNode("rightEye");n&&(t<0?W.x=-N.MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-t):W.x=N.MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?W.y=-N.MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(-e):W.y=N.MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(e),G.setFromEuler(W),this._getWorldFaceFrontQuat(pe),r.quaternion.copy(pe).multiply(G).multiply(pe.invert()),G.copy(this._restLeftEyeParentWorldQuat),n.quaternion.copy(r.quaternion).multiply(G).premultiply(G.invert()).multiply(this._restQuatLeftEye)),i&&(t<0?W.x=-N.MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-t):W.x=N.MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(t),e<0?W.y=-N.MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(-e):W.y=N.MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(e),G.setFromEuler(W),this._getWorldFaceFrontQuat(pe),o.quaternion.copy(pe).multiply(G).multiply(pe.invert()),G.copy(this._restRightEyeParentWorldQuat),i.quaternion.copy(o.quaternion).multiply(G).premultiply(G.invert()).multiply(this._restQuatRightEye))}lookAt(e){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");let t=N.MathUtils.RAD2DEG*e.y,n=N.MathUtils.RAD2DEG*e.x;this.applyYawPitch(t,n)}_getWorldFaceFrontQuat(e){if(this.faceFront.distanceToSquared(Br)<.01)return e.identity();let[t,n]=Oe(this.faceFront);return W.set(0,.5*Math.PI+t,n,"YZX"),e.setFromEuler(W)}};Fe.type="bone";var tt=class{constructor(e,t,n,i,r){this.expressions=e,this.rangeMapHorizontalInner=t,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r}applyYawPitch(e,t){t<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-t))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(t))),e<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-e))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(e)))}lookAt(e){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");let t=et.MathUtils.RAD2DEG*e.y,n=et.MathUtils.RAD2DEG*e.x;this.applyYawPitch(t,n)}};tt.type="expression";var Vn=class{constructor(e,t){this.inputMaxValue=e,this.outputScale=t}map(e){return this.outputScale*Un(e/this.inputMaxValue)}},Wr=new Set(["1.0","1.0-beta"]),Ue=.01,lt=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(e,t){this.parser=e,this.helperRoot=t==null?void 0:t.helperRoot}afterRoot(e){return P(this,null,function*(){let t=e.userData.vrmHumanoid;if(t===null)return;if(t===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");let n=e.userData.vrmExpressionManager;if(n!==null){if(n===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");e.userData.vrmLookAt=yield this._import(e,t,n)}})}_import(e,t,n){return P(this,null,function*(){if(t==null||n==null)return null;let i=yield this._v1Import(e,t,n);if(i)return i;let r=yield this._v0Import(e,t,n);return r||null})}_v1Import(e,t,n){return P(this,null,function*(){var i,r,o;let l=this.parser.json;if(!(((i=l.extensionsUsed)==null?void 0:i.indexOf("VRMC_vrm"))!==-1))return null;let s=(r=l.extensions)==null?void 0:r.VRMC_vrm;if(!s)return null;let u=s.specVersion;if(!Wr.has(u))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${u}"`),null;let d=s.lookAt;if(!d)return null;let c=d.type==="expression"?1:10,f=this._v1ImportRangeMap(d.rangeMapHorizontalInner,c),m=this._v1ImportRangeMap(d.rangeMapHorizontalOuter,c),p=this._v1ImportRangeMap(d.rangeMapVerticalDown,c),h=this._v1ImportRangeMap(d.rangeMapVerticalUp,c),g;d.type==="expression"?g=new tt(n,f,m,p,h):g=new Fe(t,f,m,p,h);let _=this._importLookAt(t,g);return _.offsetFromHeadBone.fromArray((o=d.offsetFromHeadBone)!=null?o:[0,.06,0]),_})}_v1ImportRangeMap(e,t){var n,i;let r=(n=e==null?void 0:e.inputMaxValue)!=null?n:90,o=(i=e==null?void 0:e.outputScale)!=null?i:t;return r<Ue&&(console.warn("VRMLookAtLoaderPlugin: inputMaxValue of a range map is too small. Consider reviewing the range map!"),r=Ue),new Vn(r,o)}_v0Import(e,t,n){return P(this,null,function*(){var i,r,o,l;let s=(i=this.parser.json.extensions)==null?void 0:i.VRM;if(!s)return null;let u=s.firstPerson;if(!u)return null;let d=u.lookAtTypeName==="BlendShape"?1:10,c=this._v0ImportDegreeMap(u.lookAtHorizontalInner,d),f=this._v0ImportDegreeMap(u.lookAtHorizontalOuter,d),m=this._v0ImportDegreeMap(u.lookAtVerticalDown,d),p=this._v0ImportDegreeMap(u.lookAtVerticalUp,d),h;u.lookAtTypeName==="BlendShape"?h=new tt(n,c,f,m,p):h=new Fe(t,c,f,m,p);let g=this._importLookAt(t,h);return u.firstPersonBoneOffset?g.offsetFromHeadBone.set((r=u.firstPersonBoneOffset.x)!=null?r:0,(o=u.firstPersonBoneOffset.y)!=null?o:.06,-((l=u.firstPersonBoneOffset.z)!=null?l:0)):g.offsetFromHeadBone.set(0,.06,0),g.faceFront.set(0,0,-1),h instanceof Fe&&h.faceFront.set(0,0,-1),g})}_v0ImportDegreeMap(e,t){var n,i;let r=e==null?void 0:e.curve;JSON.stringify(r)!=="[0,0,0,1,1,1,1,0]"&&console.warn("Curves of LookAtDegreeMap defined in VRM 0.0 are not supported");let o=(n=e==null?void 0:e.xRange)!=null?n:90,l=(i=e==null?void 0:e.yRange)!=null?i:t;return o<Ue&&(console.warn("VRMLookAtLoaderPlugin: xRange of a degree map is too small. Consider reviewing the degree map!"),o=Ue),new Vn(o,l)}_importLookAt(e,t){let n=new Dr(e,t);if(this.helperRoot){let i=new Hr(n);this.helperRoot.add(i),i.renderOrder=this.helperRoot.renderOrder}return n}},Ns={Bone:"bone",Expression:"expression"};function kr(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}var zr=new Set(["1.0","1.0-beta"]),ut=class{get name(){return"VRMMetaLoaderPlugin"}constructor(e,t){var n,i,r;this.parser=e,this.needThumbnailImage=(n=t==null?void 0:t.needThumbnailImage)!=null?n:!1,this.acceptLicenseUrls=(i=t==null?void 0:t.acceptLicenseUrls)!=null?i:["https://vrm.dev/licenses/1.0/"],this.acceptV0Meta=(r=t==null?void 0:t.acceptV0Meta)!=null?r:!0}afterRoot(e){return P(this,null,function*(){e.userData.vrmMeta=yield this._import(e)})}_import(e){return P(this,null,function*(){let t=yield this._v1Import(e);if(t!=null)return t;let n=yield this._v0Import(e);return n!=null?n:null})}_v1Import(e){return P(this,null,function*(){var t,n,i;let r=this.parser.json;if(!(((t=r.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;let l=(n=r.extensions)==null?void 0:n.VRMC_vrm;if(l==null)return null;let a=l.specVersion;if(!zr.has(a))return console.warn(`VRMMetaLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;let s=l.meta;if(!s)return null;let u=s.licenseUrl;if(!new Set(this.acceptLicenseUrls).has(u))throw new Error(`VRMMetaLoaderPlugin: The license url "${u}" is not accepted`);let c;return this.needThumbnailImage&&s.thumbnailImage!=null&&(c=(i=yield this._extractGLTFImage(s.thumbnailImage))!=null?i:void 0),{metaVersion:"1",name:s.name,version:s.version,authors:s.authors,copyrightInformation:s.copyrightInformation,contactInformation:s.contactInformation,references:s.references,thirdPartyLicenses:s.thirdPartyLicenses,thumbnailImage:c,licenseUrl:s.licenseUrl,avatarPermission:s.avatarPermission,allowExcessivelyViolentUsage:s.allowExcessivelyViolentUsage,allowExcessivelySexualUsage:s.allowExcessivelySexualUsage,commercialUsage:s.commercialUsage,allowPoliticalOrReligiousUsage:s.allowPoliticalOrReligiousUsage,allowAntisocialOrHateUsage:s.allowAntisocialOrHateUsage,creditNotation:s.creditNotation,allowRedistribution:s.allowRedistribution,modification:s.modification,otherLicenseUrl:s.otherLicenseUrl}})}_v0Import(e){return P(this,null,function*(){var t;let i=(t=this.parser.json.extensions)==null?void 0:t.VRM;if(!i)return null;let r=i.meta;if(!r)return null;if(!this.acceptV0Meta)throw new Error("VRMMetaLoaderPlugin: Attempted to load VRM0.0 meta but acceptV0Meta is false");let o;return this.needThumbnailImage&&r.texture!=null&&r.texture!==-1&&(o=yield this.parser.getDependency("texture",r.texture)),{metaVersion:"0",allowedUserName:r.allowedUserName,author:r.author,commercialUssageName:r.commercialUssageName,contactInformation:r.contactInformation,licenseName:r.licenseName,otherLicenseUrl:r.otherLicenseUrl,otherPermissionUrl:r.otherPermissionUrl,reference:r.reference,sexualUssageName:r.sexualUssageName,texture:o!=null?o:void 0,title:r.title,version:r.version,violentUssageName:r.violentUssageName}})}_extractGLTFImage(e){return P(this,null,function*(){var t;let i=(t=this.parser.json.images)==null?void 0:t[e];if(i==null)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${e}] of glTF as a thumbnail but the image doesn't exist`),null;let r=i.uri;if(i.bufferView!=null){let l=yield this.parser.getDependency("bufferView",i.bufferView),a=new Blob([l],{type:i.mimeType});r=URL.createObjectURL(a)}return r==null?(console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${e}] of glTF as a thumbnail but the image couldn't load properly`),null):yield new $n.ImageLoader().loadAsync(kr(r,this.parser.options.path)).catch(l=>(console.error(l),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},dt=class{constructor(e){this.scene=e.scene,this.meta=e.meta,this.humanoid=e.humanoid,this.expressionManager=e.expressionManager,this.firstPerson=e.firstPerson,this.lookAt=e.lookAt}update(e){this.humanoid.update(),this.lookAt&&this.lookAt.update(e),this.expressionManager&&this.expressionManager.update()}},Hs=class{get name(){return"VRMC_vrm"}constructor(e,t){var n,i,r,o,l;this.parser=e;let a=t==null?void 0:t.helperRoot,s=t==null?void 0:t.autoUpdateHumanBones;this.expressionPlugin=(n=t==null?void 0:t.expressionPlugin)!=null?n:new it(e),this.firstPersonPlugin=(i=t==null?void 0:t.firstPersonPlugin)!=null?i:new ot(e),this.humanoidPlugin=(r=t==null?void 0:t.humanoidPlugin)!=null?r:new st(e,{helperRoot:a,autoUpdateHumanBones:s}),this.lookAtPlugin=(o=t==null?void 0:t.lookAtPlugin)!=null?o:new lt(e,{helperRoot:a}),this.metaPlugin=(l=t==null?void 0:t.metaPlugin)!=null?l:new ut(e)}afterRoot(e){return P(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);let t=e.userData.vrmMeta,n=e.userData.vrmHumanoid;if(t&&n){let i=new dt({scene:e.scene,expressionManager:e.userData.vrmExpressionManager,firstPerson:e.userData.vrmFirstPerson,humanoid:n,lookAt:e.userData.vrmLookAt,meta:t});e.userData.vrmCore=i}})}};var Se=class extends dt{constructor(t){super(t),this.materials=t.materials,this.springBoneManager=t.springBoneManager,this.nodeConstraintManager=t.nodeConstraintManager}update(t){super.update(t),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(t),this.materials&&this.materials.forEach(n=>{n.update&&n.update(t)})}};import*as We from"three";import*as ni from"three";import*as ii from"three";import*as S from"three";import*as ri from"three";import*as O from"three/addons/nodes/Nodes.js";import*as w from"three/addons/nodes/Nodes.js";import*as A from"three/addons/nodes/Nodes.js";import*as F from"three/addons/nodes/Nodes.js";import*as B from"three";import*as y from"three/addons/nodes/Nodes.js";import*as ne from"three/addons/nodes/Nodes.js";var jr=Object.defineProperty,Zn=Object.getOwnPropertySymbols,Gr=Object.prototype.hasOwnProperty,Qr=Object.prototype.propertyIsEnumerable,Jn=(e,t,n)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kn=(e,t)=>{for(var n in t||(t={}))Gr.call(t,n)&&Jn(e,n,t[n]);if(Zn)for(var n of Zn(t))Qr.call(t,n)&&Jn(e,n,t[n]);return e},ue=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())}),qr={"":3e3,srgb:3001};function Xr(e,t){parseInt(ii.REVISION,10)>=152?e.colorSpace=t:e.encoding=qr[t]}var Yr=class{get pending(){return Promise.all(this._pendings)}constructor(e,t){this._parser=e,this._materialParams=t,this._pendings=[]}assignPrimitive(e,t){t!=null&&(this._materialParams[e]=t)}assignColor(e,t,n){t!=null&&(this._materialParams[e]=new ni.Color().fromArray(t),n&&this._materialParams[e].convertSRGBToLinear())}assignTexture(e,t,n){return ue(this,null,function*(){let i=ue(this,null,function*(){t!=null&&(yield this._parser.assignTexture(this._materialParams,e,t),n&&Xr(this._materialParams[e],"srgb"))});return this._pendings.push(i),i})}assignTextureByIndex(e,t,n){return ue(this,null,function*(){return this.assignTexture(e,t!=null?{index:t}:void 0,n)})}},$r=`// #define PHONG
|
|
2
|
+
var pe=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())});import*as Mn from"three";import*as q from"three";import*as Xe from"three";import*as Pn from"three";import*as N from"three";import*as z from"three";import*as be from"three";import*as D from"three";import*as P from"three";import*as _e from"three";import*as X from"three";import*as b from"three";import*as Ke from"three";import*as S from"three";import*as Qe from"three";import*as On from"three";var y=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())}),$t=class extends Mn.Object3D{constructor(t){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${t}`,this.expressionName=t,this.type="VRMExpression",this.visible=!1}get overrideBlinkAmount(){return this.overrideBlink==="block"?0<this.weight?1:0:this.overrideBlink==="blend"?this.weight:0}get overrideLookAtAmount(){return this.overrideLookAt==="block"?0<this.weight?1:0:this.overrideLookAt==="blend"?this.weight:0}get overrideMouthAmount(){return this.overrideMouth==="block"?0<this.weight?1:0:this.overrideMouth==="blend"?this.weight:0}addBind(t){this._binds.push(t)}applyWeight(t){var e;let n=this.isBinary?this.weight<=.5?0:1:this.weight;n*=(e=t==null?void 0:t.multiplier)!=null?e:1,this._binds.forEach(i=>i.applyWeight(n))}clearAppliedWeight(){this._binds.forEach(t=>t.clearAppliedWeight())}};function Rn(t,e,n){var i,r;let s=t.parser.json,a=(i=s.nodes)==null?void 0:i[e];if(a==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${e}] of glTF but the node doesn't exist`),null;let l=a.mesh;if(l==null)return null;let o=(r=s.meshes)==null?void 0:r[l];if(o==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${l}] of glTF but the mesh doesn't exist`),null;let u=o.primitives.length,d=[];return n.traverse(c=>{d.length<u&&c.isMesh&&d.push(c)}),d}function Zt(t,e){return y(this,null,function*(){let n=yield t.parser.getDependency("node",e);return Rn(t,e,n)})}function Jt(t){return y(this,null,function*(){let e=yield t.parser.getDependencies("node"),n=new Map;return e.forEach((i,r)=>{let s=Rn(t,r,i);s!=null&&n.set(r,s)}),n})}var ze={Aa:"aa",Ih:"ih",Ou:"ou",Ee:"ee",Oh:"oh",Blink:"blink",Happy:"happy",Angry:"angry",Sad:"sad",Relaxed:"relaxed",LookUp:"lookUp",Surprised:"surprised",LookDown:"lookDown",LookLeft:"lookLeft",LookRight:"lookRight",BlinkLeft:"blinkLeft",BlinkRight:"blinkRight",Neutral:"neutral"};function Tn(t){return Math.max(Math.min(t,1),0)}var Kt=class xn{constructor(){this.blinkExpressionNames=["blink","blinkLeft","blinkRight"],this.lookAtExpressionNames=["lookLeft","lookRight","lookUp","lookDown"],this.mouthExpressionNames=["aa","ee","ih","oh","ou"],this._expressions=[],this._expressionMap={}}get expressions(){return this._expressions.concat()}get expressionMap(){return Object.assign({},this._expressionMap)}get presetExpressionMap(){let e={},n=new Set(Object.values(ze));return Object.entries(this._expressionMap).forEach(([i,r])=>{n.has(i)&&(e[i]=r)}),e}get customExpressionMap(){let e={},n=new Set(Object.values(ze));return Object.entries(this._expressionMap).forEach(([i,r])=>{n.has(i)||(e[i]=r)}),e}copy(e){return this._expressions.concat().forEach(i=>{this.unregisterExpression(i)}),e._expressions.forEach(i=>{this.registerExpression(i)}),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return new xn().copy(this)}getExpression(e){var n;return(n=this._expressionMap[e])!=null?n:null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){let n=this._expressions.indexOf(e);n===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(n,1),delete this._expressionMap[e.expressionName]}getValue(e){var n;let i=this.getExpression(e);return(n=i==null?void 0:i.weight)!=null?n:null}setValue(e,n){let i=this.getExpression(e);i&&(i.weight=Tn(n))}resetValues(){this._expressions.forEach(e=>{e.weight=0})}getExpressionTrackName(e){let n=this.getExpression(e);return n?`${n.name}.weight`:null}update(){let e=this._calculateWeightMultipliers();this._expressions.forEach(n=>{n.clearAppliedWeight()}),this._expressions.forEach(n=>{let i=1,r=n.expressionName;this.blinkExpressionNames.indexOf(r)!==-1&&(i*=e.blink),this.lookAtExpressionNames.indexOf(r)!==-1&&(i*=e.lookAt),this.mouthExpressionNames.indexOf(r)!==-1&&(i*=e.mouth),n.applyWeight({multiplier:i})})}_calculateWeightMultipliers(){let e=1,n=1,i=1;return this._expressions.forEach(r=>{e-=r.overrideBlinkAmount,n-=r.overrideLookAtAmount,i-=r.overrideMouthAmount}),e=Math.max(0,e),n=Math.max(0,n),i=Math.max(0,i),{blink:e,lookAt:n,mouth:i}}},me={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",MatcapColor:"matcapColor",RimColor:"rimColor",OutlineColor:"outlineColor"},er={_Color:me.Color,_EmissionColor:me.EmissionColor,_ShadeColor:me.ShadeColor,_RimColor:me.RimColor,_OutlineColor:me.OutlineColor},tr=new Xe.Color,yn=class wn{constructor({material:e,type:n,targetValue:i,targetAlpha:r}){this.material=e,this.type=n,this.targetValue=i,this.targetAlpha=r!=null?r:1;let s=this._initColorBindState(),a=this._initAlphaBindState();this._state={color:s,alpha:a}}applyWeight(e){let{color:n,alpha:i}=this._state;if(n!=null){let{propertyName:r,deltaValue:s}=n,a=this.material[r];a!=null&&a.add(tr.copy(s).multiplyScalar(e))}if(i!=null){let{propertyName:r,deltaValue:s}=i;this.material[r]!=null&&(this.material[r]+=s*e)}}clearAppliedWeight(){let{color:e,alpha:n}=this._state;if(e!=null){let{propertyName:i,initialValue:r}=e,s=this.material[i];s!=null&&s.copy(r)}if(n!=null){let{propertyName:i,initialValue:r}=n;this.material[i]!=null&&(this.material[i]=r)}}_initColorBindState(){var e,n,i;let{material:r,type:s,targetValue:a}=this,l=this._getPropertyNameMap(),o=(n=(e=l==null?void 0:l[s])==null?void 0:e[0])!=null?n:null;if(o==null)return console.warn(`Tried to add a material color bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${s} but the material or the type is not supported.`),null;let d=r[o].clone(),c=new Xe.Color(a.r-d.r,a.g-d.g,a.b-d.b);return{propertyName:o,initialValue:d,deltaValue:c}}_initAlphaBindState(){var e,n,i;let{material:r,type:s,targetAlpha:a}=this,l=this._getPropertyNameMap(),o=(n=(e=l==null?void 0:l[s])==null?void 0:e[1])!=null?n:null;if(o==null&&a!==1)return console.warn(`Tried to add a material alpha bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${s} but the material or the type does not support alpha.`),null;if(o==null)return null;let u=r[o],d=a-u;return{propertyName:o,initialValue:u,deltaValue:d}}_getPropertyNameMap(){var e,n;return(n=(e=Object.entries(wn._propertyNameMapMap).find(([i])=>this.material[i]===!0))==null?void 0:e[1])!=null?n:null}};yn._propertyNameMapMap={isMeshStandardMaterial:{color:["color","opacity"],emissionColor:["emissive",null]},isMeshBasicMaterial:{color:["color","opacity"]},isMToonMaterial:{color:["color","opacity"],emissionColor:["emissive",null],outlineColor:["outlineColorFactor",null],matcapColor:["matcapFactor",null],rimColor:["parametricRimColorFactor",null],shadeColor:["shadeColorFactor",null]}};var en=yn,tn=class{constructor({primitives:t,index:e,weight:n}){this.primitives=t,this.index=e,this.weight=n}applyWeight(t){this.primitives.forEach(e=>{var n;((n=e.morphTargetInfluences)==null?void 0:n[this.index])!=null&&(e.morphTargetInfluences[this.index]+=this.weight*t)})}clearAppliedWeight(){this.primitives.forEach(t=>{var e;((e=t.morphTargetInfluences)==null?void 0:e[this.index])!=null&&(t.morphTargetInfluences[this.index]=0)})}},nn=new Pn.Vector2,Sn=class An{constructor({material:e,scale:n,offset:i}){var r,s;this.material=e,this.scale=n,this.offset=i;let a=(r=Object.entries(An._propertyNamesMap).find(([l])=>e[l]===!0))==null?void 0:r[1];a==null?(console.warn(`Tried to add a texture transform bind to the material ${(s=e.name)!=null?s:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],a.forEach(l=>{var o;let u=(o=e[l])==null?void 0:o.clone();if(!u)return null;e[l]=u;let d=u.offset.clone(),c=u.repeat.clone(),f=i.clone().sub(d),p=n.clone().sub(c);this._properties.push({name:l,initialOffset:d,deltaOffset:f,initialScale:c,deltaScale:p})}))}applyWeight(e){this._properties.forEach(n=>{let i=this.material[n.name];i!==void 0&&(i.offset.add(nn.copy(n.deltaOffset).multiplyScalar(e)),i.repeat.add(nn.copy(n.deltaScale).multiplyScalar(e)))})}clearAppliedWeight(){this._properties.forEach(e=>{let n=this.material[e.name];n!==void 0&&(n.offset.copy(e.initialOffset),n.repeat.copy(e.initialScale))})}};Sn._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var rn=Sn,nr=new Set(["1.0","1.0-beta"]),Ln=class Hn{get name(){return"VRMExpressionLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return y(this,null,function*(){e.userData.vrmExpressionManager=yield this._import(e)})}_import(e){return y(this,null,function*(){let n=yield this._v1Import(e);if(n)return n;let i=yield this._v0Import(e);return i||null})}_v1Import(e){return y(this,null,function*(){var n,i;let r=this.parser.json;if(!(((n=r.extensionsUsed)==null?void 0:n.indexOf("VRMC_vrm"))!==-1))return null;let a=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!a)return null;let l=a.specVersion;if(!nr.has(l))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${l}"`),null;let o=a.expressions;if(!o)return null;let u=new Set(Object.values(ze)),d=new Map;o.preset!=null&&Object.entries(o.preset).forEach(([f,p])=>{if(p!=null){if(!u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${f}" detected. Ignoring the expression`);return}d.set(f,p)}}),o.custom!=null&&Object.entries(o.custom).forEach(([f,p])=>{if(u.has(f)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${f}". Ignoring the expression`);return}d.set(f,p)});let c=new Kt;return yield Promise.all(Array.from(d.entries()).map(f=>y(this,[f],function*([p,m]){var h,_,g,x,T,v,R;let E=new $t(p);if(e.scene.add(E),E.isBinary=(h=m.isBinary)!=null?h:!1,E.overrideBlink=(_=m.overrideBlink)!=null?_:"none",E.overrideLookAt=(g=m.overrideLookAt)!=null?g:"none",E.overrideMouth=(x=m.overrideMouth)!=null?x:"none",(T=m.morphTargetBinds)==null||T.forEach(M=>y(this,null,function*(){var A;if(M.node===void 0||M.index===void 0)return;let I=yield Zt(e,M.node),L=M.index;if(!I.every(H=>Array.isArray(H.morphTargetInfluences)&&L<H.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${m.name} attempts to index morph #${L} but not found.`);return}E.addBind(new tn({primitives:I,index:L,weight:(A=M.weight)!=null?A:1}))})),m.materialColorBinds||m.textureTransformBinds){let M=[];e.scene.traverse(A=>{let I=A.material;I&&M.push(I)}),(v=m.materialColorBinds)==null||v.forEach(A=>y(this,null,function*(){M.filter(L=>{var H;let U=(H=this.parser.associations.get(L))==null?void 0:H.materials;return A.material===U}).forEach(L=>{E.addBind(new en({material:L,type:A.type,targetValue:new q.Color().fromArray(A.targetValue),targetAlpha:A.targetValue[3]}))})})),(R=m.textureTransformBinds)==null||R.forEach(A=>y(this,null,function*(){M.filter(L=>{var H;let U=(H=this.parser.associations.get(L))==null?void 0:H.materials;return A.material===U}).forEach(L=>{var H,U;E.addBind(new rn({material:L,offset:new q.Vector2().fromArray((H=A.offset)!=null?H:[0,0]),scale:new q.Vector2().fromArray((U=A.scale)!=null?U:[1,1])}))})}))}c.registerExpression(E)}))),c})}_v0Import(e){return y(this,null,function*(){var n;let i=this.parser.json,r=(n=i.extensions)==null?void 0:n.VRM;if(!r)return null;let s=r.blendShapeMaster;if(!s)return null;let a=new Kt,l=s.blendShapeGroups;if(!l)return a;let o=new Set;return yield Promise.all(l.map(u=>y(this,null,function*(){var d;let c=u.presetName,f=c!=null&&Hn.v0v1PresetNameMap[c]||null,p=f!=null?f:u.name;if(p==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(o.has(p)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${c} has duplicated entries. Ignoring the expression`);return}o.add(p);let m=new $t(p);e.scene.add(m),m.isBinary=(d=u.isBinary)!=null?d:!1,u.binds&&u.binds.forEach(_=>y(this,null,function*(){var g;if(_.mesh===void 0||_.index===void 0)return;let x=[];(g=i.nodes)==null||g.forEach((v,R)=>{v.mesh===_.mesh&&x.push(R)});let T=_.index;yield Promise.all(x.map(v=>y(this,null,function*(){var R;let E=yield Zt(e,v);if(!E.every(M=>Array.isArray(M.morphTargetInfluences)&&T<M.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${u.name} attempts to index ${T}th morph but not found.`);return}m.addBind(new tn({primitives:E,index:T,weight:.01*((R=_.weight)!=null?R:100)}))})))}));let h=u.materialValues;h&&h.length!==0&&h.forEach(_=>{if(_.materialName===void 0||_.propertyName===void 0||_.targetValue===void 0)return;let g=[];e.scene.traverse(T=>{if(T.material){let v=T.material;Array.isArray(v)?g.push(...v.filter(R=>(R.name===_.materialName||R.name===_.materialName+" (Outline)")&&g.indexOf(R)===-1)):v.name===_.materialName&&g.indexOf(v)===-1&&g.push(v)}});let x=_.propertyName;g.forEach(T=>{if(x==="_MainTex_ST"){let R=new q.Vector2(_.targetValue[0],_.targetValue[1]),E=new q.Vector2(_.targetValue[2],_.targetValue[3]);E.y=1-E.y-R.y,m.addBind(new rn({material:T,scale:R,offset:E}));return}let v=er[x];if(v){m.addBind(new en({material:T,type:v,targetValue:new q.Color().fromArray(_.targetValue),targetAlpha:_.targetValue[3]}));return}console.warn(x+" is not supported")})}),a.registerExpression(m)}))),a})}};Ln.v0v1PresetNameMap={a:"aa",e:"ee",i:"ih",o:"oh",u:"ou",blink:"blink",joy:"happy",angry:"angry",sorrow:"sad",fun:"relaxed",lookup:"lookUp",lookdown:"lookDown",lookleft:"lookLeft",lookright:"lookRight",blink_l:"blinkLeft",blink_r:"blinkRight",neutral:"neutral"};var Ye=Ln,bo={None:"none",Block:"block",Blend:"blend"},$e=class ae{constructor(e,n){this._firstPersonOnlyLayer=ae.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=ae.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=e,this.meshAnnotations=n}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMFirstPerson: humanoid must be same in order to copy");return this.meshAnnotations=e.meshAnnotations.map(n=>({meshes:n.meshes.concat(),type:n.type})),this}clone(){return new ae(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:e=ae.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:n=ae.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=e,this._thirdPersonOnlyLayer=n,this.meshAnnotations.forEach(i=>{i.meshes.forEach(r=>{i.type==="firstPersonOnly"?(r.layers.set(this._firstPersonOnlyLayer),r.traverse(s=>s.layers.set(this._firstPersonOnlyLayer))):i.type==="thirdPersonOnly"?(r.layers.set(this._thirdPersonOnlyLayer),r.traverse(s=>s.layers.set(this._thirdPersonOnlyLayer))):i.type==="auto"&&this._createHeadlessModel(r)})}),this._initializedLayers=!0)}_excludeTriangles(e,n,i,r){let s=0;if(n!=null&&n.length>0)for(let a=0;a<e.length;a+=3){let l=e[a],o=e[a+1],u=e[a+2],d=n[l],c=i[l];if(d[0]>0&&r.includes(c[0])||d[1]>0&&r.includes(c[1])||d[2]>0&&r.includes(c[2])||d[3]>0&&r.includes(c[3]))continue;let f=n[o],p=i[o];if(f[0]>0&&r.includes(p[0])||f[1]>0&&r.includes(p[1])||f[2]>0&&r.includes(p[2])||f[3]>0&&r.includes(p[3]))continue;let m=n[u],h=i[u];m[0]>0&&r.includes(h[0])||m[1]>0&&r.includes(h[1])||m[2]>0&&r.includes(h[2])||m[3]>0&&r.includes(h[3])||(e[s++]=l,e[s++]=o,e[s++]=u)}return s}_createErasedMesh(e,n){let i=new N.SkinnedMesh(e.geometry.clone(),e.material);i.name=`${e.name}(erase)`,i.frustumCulled=e.frustumCulled,i.layers.set(this._firstPersonOnlyLayer);let r=i.geometry,s=r.getAttribute("skinIndex"),a=s instanceof N.GLBufferAttribute?[]:s.array,l=[];for(let h=0;h<a.length;h+=4)l.push([a[h],a[h+1],a[h+2],a[h+3]]);let o=r.getAttribute("skinWeight"),u=o instanceof N.GLBufferAttribute?[]:o.array,d=[];for(let h=0;h<u.length;h+=4)d.push([u[h],u[h+1],u[h+2],u[h+3]]);let c=r.getIndex();if(!c)throw new Error("The geometry doesn't have an index buffer");let f=Array.from(c.array),p=this._excludeTriangles(f,d,l,n),m=[];for(let h=0;h<p;h++)m[h]=f[h];return r.setIndex(m),e.onBeforeRender&&(i.onBeforeRender=e.onBeforeRender),i.bind(new N.Skeleton(e.skeleton.bones,e.skeleton.boneInverses),new N.Matrix4),i}_createHeadlessModelForSkinnedMesh(e,n){let i=[];if(n.skeleton.bones.forEach((s,a)=>{this._isEraseTarget(s)&&i.push(a)}),!i.length){n.layers.enable(this._thirdPersonOnlyLayer),n.layers.enable(this._firstPersonOnlyLayer);return}n.layers.set(this._thirdPersonOnlyLayer);let r=this._createErasedMesh(n,i);e.add(r)}_createHeadlessModel(e){if(e.type==="Group")if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse(n=>n.layers.set(this._thirdPersonOnlyLayer));else{let n=new N.Group;n.name=`_headless_${e.name}`,n.layers.set(this._firstPersonOnlyLayer),e.parent.add(n),e.children.filter(i=>i.type==="SkinnedMesh").forEach(i=>{let r=i;this._createHeadlessModelForSkinnedMesh(n,r)})}else if(e.type==="SkinnedMesh"){let n=e;this._createHeadlessModelForSkinnedMesh(e.parent,n)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse(n=>n.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode("head")?!0:e.parent?this._isEraseTarget(e.parent):!1}};$e.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;$e.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var on=$e,ir=new Set(["1.0","1.0-beta"]),Ze=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(t){this.parser=t}afterRoot(t){return y(this,null,function*(){let e=t.userData.vrmHumanoid;if(e!==null){if(e===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");t.userData.vrmFirstPerson=yield this._import(t,e)}})}_import(t,e){return y(this,null,function*(){if(e==null)return null;let n=yield this._v1Import(t,e);if(n)return n;let i=yield this._v0Import(t,e);return i||null})}_v1Import(t,e){return y(this,null,function*(){var n,i;let r=this.parser.json;if(!(((n=r.extensionsUsed)==null?void 0:n.indexOf("VRMC_vrm"))!==-1))return null;let a=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!a)return null;let l=a.specVersion;if(!ir.has(l))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${l}"`),null;let o=a.firstPerson;if(!o)return null;let u=[],d=yield Jt(t);return Array.from(d.entries()).forEach(([c,f])=>{var p;let m=o.meshAnnotations?o.meshAnnotations.find(h=>h.node===c):void 0;u.push({meshes:f,type:(p=m==null?void 0:m.type)!=null?p:"both"})}),new on(e,u)})}_v0Import(t,e){return y(this,null,function*(){var n;let i=this.parser.json,r=(n=i.extensions)==null?void 0:n.VRM;if(!r)return null;let s=r.firstPerson;if(!s)return null;let a=[],l=yield Jt(t);return Array.from(l.entries()).forEach(([o,u])=>{let d=i.nodes[o],c=s.meshAnnotations?s.meshAnnotations.find(f=>f.mesh===d.mesh):void 0;a.push({meshes:u,type:this._convertV0FlagToV1Type(c==null?void 0:c.firstPersonFlag)})}),new on(e,a)})}_convertV0FlagToV1Type(t){return t==="FirstPersonOnly"?"firstPersonOnly":t==="ThirdPersonOnly"?"thirdPersonOnly":t==="Auto"?"auto":"both"}},Vo={Auto:"auto",Both:"both",ThirdPersonOnly:"thirdPersonOnly",FirstPersonOnly:"firstPersonOnly"},sn=new z.Vector3,an=new z.Vector3,rr=new z.Quaternion,ln=class extends z.Group{constructor(t){super(),this.vrmHumanoid=t,this._boneAxesMap=new Map,Object.values(t.humanBones).forEach(e=>{let n=new z.AxesHelper(1);n.matrixAutoUpdate=!1,n.material.depthTest=!1,n.material.depthWrite=!1,this.add(n),this._boneAxesMap.set(e,n)})}dispose(){Array.from(this._boneAxesMap.values()).forEach(t=>{t.geometry.dispose(),t.material.dispose()})}updateMatrixWorld(t){Array.from(this._boneAxesMap.entries()).forEach(([e,n])=>{e.node.updateWorldMatrix(!0,!1),e.node.matrixWorld.decompose(sn,rr,an);let i=sn.set(.1,.1,.1).divide(an);n.matrix.copy(e.node.matrixWorld).scale(i)}),super.updateMatrixWorld(t)}},Be=["hips","spine","chest","upperChest","neck","head","leftEye","rightEye","jaw","leftUpperLeg","leftLowerLeg","leftFoot","leftToes","rightUpperLeg","rightLowerLeg","rightFoot","rightToes","leftShoulder","leftUpperArm","leftLowerArm","leftHand","rightShoulder","rightUpperArm","rightLowerArm","rightHand","leftThumbMetacarpal","leftThumbProximal","leftThumbDistal","leftIndexProximal","leftIndexIntermediate","leftIndexDistal","leftMiddleProximal","leftMiddleIntermediate","leftMiddleDistal","leftRingProximal","leftRingIntermediate","leftRingDistal","leftLittleProximal","leftLittleIntermediate","leftLittleDistal","rightThumbMetacarpal","rightThumbProximal","rightThumbDistal","rightIndexProximal","rightIndexIntermediate","rightIndexDistal","rightMiddleProximal","rightMiddleIntermediate","rightMiddleDistal","rightRingProximal","rightRingIntermediate","rightRingDistal","rightLittleProximal","rightLittleIntermediate","rightLittleDistal"],Io={Hips:"hips",Spine:"spine",Chest:"chest",UpperChest:"upperChest",Neck:"neck",Head:"head",LeftEye:"leftEye",RightEye:"rightEye",Jaw:"jaw",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",LeftToes:"leftToes",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",RightToes:"rightToes",LeftShoulder:"leftShoulder",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightShoulder:"rightShoulder",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand",LeftThumbMetacarpal:"leftThumbMetacarpal",LeftThumbProximal:"leftThumbProximal",LeftThumbDistal:"leftThumbDistal",LeftIndexProximal:"leftIndexProximal",LeftIndexIntermediate:"leftIndexIntermediate",LeftIndexDistal:"leftIndexDistal",LeftMiddleProximal:"leftMiddleProximal",LeftMiddleIntermediate:"leftMiddleIntermediate",LeftMiddleDistal:"leftMiddleDistal",LeftRingProximal:"leftRingProximal",LeftRingIntermediate:"leftRingIntermediate",LeftRingDistal:"leftRingDistal",LeftLittleProximal:"leftLittleProximal",LeftLittleIntermediate:"leftLittleIntermediate",LeftLittleDistal:"leftLittleDistal",RightThumbMetacarpal:"rightThumbMetacarpal",RightThumbProximal:"rightThumbProximal",RightThumbDistal:"rightThumbDistal",RightIndexProximal:"rightIndexProximal",RightIndexIntermediate:"rightIndexIntermediate",RightIndexDistal:"rightIndexDistal",RightMiddleProximal:"rightMiddleProximal",RightMiddleIntermediate:"rightMiddleIntermediate",RightMiddleDistal:"rightMiddleDistal",RightRingProximal:"rightRingProximal",RightRingIntermediate:"rightRingIntermediate",RightRingDistal:"rightRingDistal",RightLittleProximal:"rightLittleProximal",RightLittleIntermediate:"rightLittleIntermediate",RightLittleDistal:"rightLittleDistal"},or={hips:null,spine:"hips",chest:"spine",upperChest:"chest",neck:"upperChest",head:"neck",leftEye:"head",rightEye:"head",jaw:"head",leftUpperLeg:"hips",leftLowerLeg:"leftUpperLeg",leftFoot:"leftLowerLeg",leftToes:"leftFoot",rightUpperLeg:"hips",rightLowerLeg:"rightUpperLeg",rightFoot:"rightLowerLeg",rightToes:"rightFoot",leftShoulder:"upperChest",leftUpperArm:"leftShoulder",leftLowerArm:"leftUpperArm",leftHand:"leftLowerArm",rightShoulder:"upperChest",rightUpperArm:"rightShoulder",rightLowerArm:"rightUpperArm",rightHand:"rightLowerArm",leftThumbMetacarpal:"leftHand",leftThumbProximal:"leftThumbMetacarpal",leftThumbDistal:"leftThumbProximal",leftIndexProximal:"leftHand",leftIndexIntermediate:"leftIndexProximal",leftIndexDistal:"leftIndexIntermediate",leftMiddleProximal:"leftHand",leftMiddleIntermediate:"leftMiddleProximal",leftMiddleDistal:"leftMiddleIntermediate",leftRingProximal:"leftHand",leftRingIntermediate:"leftRingProximal",leftRingDistal:"leftRingIntermediate",leftLittleProximal:"leftHand",leftLittleIntermediate:"leftLittleProximal",leftLittleDistal:"leftLittleIntermediate",rightThumbMetacarpal:"rightHand",rightThumbProximal:"rightThumbMetacarpal",rightThumbDistal:"rightThumbProximal",rightIndexProximal:"rightHand",rightIndexIntermediate:"rightIndexProximal",rightIndexDistal:"rightIndexIntermediate",rightMiddleProximal:"rightHand",rightMiddleIntermediate:"rightMiddleProximal",rightMiddleDistal:"rightMiddleIntermediate",rightRingProximal:"rightHand",rightRingIntermediate:"rightRingProximal",rightRingDistal:"rightRingIntermediate",rightLittleProximal:"rightHand",rightLittleIntermediate:"rightLittleProximal",rightLittleDistal:"rightLittleIntermediate"};function bn(t){return t.invert?t.invert():t.inverse(),t}var K=new be.Vector3,ee=new be.Quaternion,je=class{constructor(t){this.humanBones=t,this.restPose=this.getAbsolutePose()}getAbsolutePose(){let t={};return Object.keys(this.humanBones).forEach(e=>{let n=e,i=this.getBoneNode(n);i&&(K.copy(i.position),ee.copy(i.quaternion),t[n]={position:K.toArray(),rotation:ee.toArray()})}),t}getPose(){let t={};return Object.keys(this.humanBones).forEach(e=>{let n=e,i=this.getBoneNode(n);if(!i)return;K.set(0,0,0),ee.identity();let r=this.restPose[n];r!=null&&r.position&&K.fromArray(r.position).negate(),r!=null&&r.rotation&&bn(ee.fromArray(r.rotation)),K.add(i.position),ee.premultiply(i.quaternion),t[n]={position:K.toArray(),rotation:ee.toArray()}}),t}setPose(t){Object.entries(t).forEach(([e,n])=>{let i=e,r=this.getBoneNode(i);if(!r)return;let s=this.restPose[i];s&&(n!=null&&n.position&&(r.position.fromArray(n.position),s.position&&r.position.add(K.fromArray(s.position))),n!=null&&n.rotation&&(r.quaternion.fromArray(n.rotation),s.rotation&&r.quaternion.multiply(ee.fromArray(s.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([t,e])=>{let n=this.getBoneNode(t);n&&(e!=null&&e.position&&n.position.fromArray(e.position),e!=null&&e.rotation&&n.quaternion.fromArray(e.rotation))})}getBone(t){var e;return(e=this.humanBones[t])!=null?e:void 0}getBoneNode(t){var e,n;return(n=(e=this.humanBones[t])==null?void 0:e.node)!=null?n:null}},Fe=new D.Vector3,sr=new D.Quaternion,ar=new D.Vector3,un=class Vn extends je{static _setupTransforms(e){let n=new D.Object3D;n.name="VRMHumanoidRig";let i={},r={},s={},a={};Be.forEach(o=>{var u;let d=e.getBoneNode(o);if(d){let c=new D.Vector3,f=new D.Quaternion;d.updateWorldMatrix(!0,!1),d.matrixWorld.decompose(c,f,Fe),i[o]=c,r[o]=f,s[o]=d.quaternion.clone();let p=new D.Quaternion;(u=d.parent)==null||u.matrixWorld.decompose(Fe,p,Fe),a[o]=p}});let l={};return Be.forEach(o=>{var u;let d=e.getBoneNode(o);if(d){let c=i[o],f=o,p;for(;p==null&&(f=or[f],f!=null);)p=i[f];let m=new D.Object3D;m.name="Normalized_"+d.name,(f?(u=l[f])==null?void 0:u.node:n).add(m),m.position.copy(c),p&&m.position.sub(p),l[o]={node:m}}}),{rigBones:l,root:n,parentWorldRotations:a,boneRotations:s}}constructor(e){let{rigBones:n,root:i,parentWorldRotations:r,boneRotations:s}=Vn._setupTransforms(e);super(n),this.original=e,this.root=i,this._parentWorldRotations=r,this._boneRotations=s}update(){Be.forEach(e=>{let n=this.original.getBoneNode(e);if(n!=null){let i=this.getBoneNode(e),r=this._parentWorldRotations[e],s=sr.copy(r).invert(),a=this._boneRotations[e];if(n.quaternion.copy(i.quaternion).multiply(r).premultiply(s).multiply(a),e==="hips"){let l=i.getWorldPosition(ar);n.parent.updateWorldMatrix(!0,!1);let o=n.parent.matrixWorld,u=l.applyMatrix4(o.invert());n.position.copy(u)}}})}},dn=class In{get restPose(){return console.warn("VRMHumanoid: restPose is deprecated. Use either rawRestPose or normalizedRestPose instead."),this.rawRestPose}get rawRestPose(){return this._rawHumanBones.restPose}get normalizedRestPose(){return this._normalizedHumanBones.restPose}get humanBones(){return this._rawHumanBones.humanBones}get rawHumanBones(){return this._rawHumanBones.humanBones}get normalizedHumanBones(){return this._normalizedHumanBones.humanBones}get normalizedHumanBonesRoot(){return this._normalizedHumanBones.root}constructor(e,n){var i;this.autoUpdateHumanBones=(i=n==null?void 0:n.autoUpdateHumanBones)!=null?i:!0,this._rawHumanBones=new je(e),this._normalizedHumanBones=new un(this._rawHumanBones)}copy(e){return this.autoUpdateHumanBones=e.autoUpdateHumanBones,this._rawHumanBones=new je(e.humanBones),this._normalizedHumanBones=new un(this._rawHumanBones),this}clone(){return new In(this.humanBones,{autoUpdateHumanBones:this.autoUpdateHumanBones}).copy(this)}getAbsolutePose(){return console.warn("VRMHumanoid: getAbsolutePose() is deprecated. Use either getRawAbsolutePose() or getNormalizedAbsolutePose() instead."),this.getRawAbsolutePose()}getRawAbsolutePose(){return this._rawHumanBones.getAbsolutePose()}getNormalizedAbsolutePose(){return this._normalizedHumanBones.getAbsolutePose()}getPose(){return console.warn("VRMHumanoid: getPose() is deprecated. Use either getRawPose() or getNormalizedPose() instead."),this.getRawPose()}getRawPose(){return this._rawHumanBones.getPose()}getNormalizedPose(){return this._normalizedHumanBones.getPose()}setPose(e){return console.warn("VRMHumanoid: setPose() is deprecated. Use either setRawPose() or setNormalizedPose() instead."),this.setRawPose(e)}setRawPose(e){return this._rawHumanBones.setPose(e)}setNormalizedPose(e){return this._normalizedHumanBones.setPose(e)}resetPose(){return console.warn("VRMHumanoid: resetPose() is deprecated. Use either resetRawPose() or resetNormalizedPose() instead."),this.resetRawPose()}resetRawPose(){return this._rawHumanBones.resetPose()}resetNormalizedPose(){return this._normalizedHumanBones.resetPose()}getBone(e){return console.warn("VRMHumanoid: getBone() is deprecated. Use either getRawBone() or getNormalizedBone() instead."),this.getRawBone(e)}getRawBone(e){return this._rawHumanBones.getBone(e)}getNormalizedBone(e){return this._normalizedHumanBones.getBone(e)}getBoneNode(e){return console.warn("VRMHumanoid: getBoneNode() is deprecated. Use either getRawBoneNode() or getNormalizedBoneNode() instead."),this.getRawBoneNode(e)}getRawBoneNode(e){return this._rawHumanBones.getBoneNode(e)}getNormalizedBoneNode(e){return this._normalizedHumanBones.getBoneNode(e)}update(){this.autoUpdateHumanBones&&this._normalizedHumanBones.update()}},lr={Hips:"hips",Spine:"spine",Head:"head",LeftUpperLeg:"leftUpperLeg",LeftLowerLeg:"leftLowerLeg",LeftFoot:"leftFoot",RightUpperLeg:"rightUpperLeg",RightLowerLeg:"rightLowerLeg",RightFoot:"rightFoot",LeftUpperArm:"leftUpperArm",LeftLowerArm:"leftLowerArm",LeftHand:"leftHand",RightUpperArm:"rightUpperArm",RightLowerArm:"rightLowerArm",RightHand:"rightHand"},ur=new Set(["1.0","1.0-beta"]),hn={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},Je=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(t,e){this.parser=t,this.helperRoot=e==null?void 0:e.helperRoot,this.autoUpdateHumanBones=e==null?void 0:e.autoUpdateHumanBones}afterRoot(t){return y(this,null,function*(){t.userData.vrmHumanoid=yield this._import(t)})}_import(t){return y(this,null,function*(){let e=yield this._v1Import(t);if(e)return e;let n=yield this._v0Import(t);return n||null})}_v1Import(t){return y(this,null,function*(){var e,n;let i=this.parser.json;if(!(((e=i.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;let s=(n=i.extensions)==null?void 0:n.VRMC_vrm;if(!s)return null;let a=s.specVersion;if(!ur.has(a))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${a}"`),null;let l=s.humanoid;if(!l)return null;let o=l.humanBones.leftThumbIntermediate!=null||l.humanBones.rightThumbIntermediate!=null,u={};l.humanBones!=null&&(yield Promise.all(Object.entries(l.humanBones).map(c=>y(this,[c],function*([f,p]){let m=f,h=p.node;if(o){let g=hn[m];g!=null&&(m=g)}let _=yield this.parser.getDependency("node",h);if(_==null){console.warn(`A glTF node bound to the humanoid bone ${m} (index = ${h}) does not exist`);return}u[m]={node:_}}))));let d=new dn(this._ensureRequiredBonesExist(u),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(t.scene.add(d.normalizedHumanBonesRoot),this.helperRoot){let c=new ln(d);this.helperRoot.add(c),c.renderOrder=this.helperRoot.renderOrder}return d})}_v0Import(t){return y(this,null,function*(){var e;let i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;let r=i.humanoid;if(!r)return null;let s={};r.humanBones!=null&&(yield Promise.all(r.humanBones.map(l=>y(this,null,function*(){let o=l.bone,u=l.node;if(o==null||u==null)return;let d=yield this.parser.getDependency("node",u);if(d==null){console.warn(`A glTF node bound to the humanoid bone ${o} (index = ${u}) does not exist`);return}let c=hn[o],f=c!=null?c:o;if(s[f]!=null){console.warn(`Multiple bone entries for ${f} detected (index = ${u}), ignoring duplicated entries.`);return}s[f]={node:d}}))));let a=new dn(this._ensureRequiredBonesExist(s),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(t.scene.add(a.normalizedHumanBonesRoot),this.helperRoot){let l=new ln(a);this.helperRoot.add(l),l.renderOrder=this.helperRoot.renderOrder}return a})}_ensureRequiredBonesExist(t){let e=Object.values(lr).filter(n=>t[n]==null);if(e.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${e.join(", ")}`);return t}},cn=class extends _e.BufferGeometry{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new _e.BufferAttribute(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new _e.BufferAttribute(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,t=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,t=!0),t&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let t=0;t<64;t++){let e=t/63*this._currentTheta;this._attrPos.setXYZ(t+1,this._currentRadius*Math.sin(e),0,this._currentRadius*Math.cos(e))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let t=0;t<63;t++)this._attrIndex.setXYZ(t*3,0,t+1,t+2);this._attrIndex.needsUpdate=!0}},dr=class extends X.BufferGeometry{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new X.Vector3,this._currentTail=new X.Vector3,this._attrPos=new X.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new X.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let t=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,t=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),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}},Se=new P.Quaternion,pn=new P.Quaternion,fe=new P.Vector3,mn=new P.Vector3,fn=Math.sqrt(2)/2,hr=new P.Quaternion(0,0,-fn,fn),cr=new P.Vector3(0,1,0),pr=class extends P.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=t;{let e=new cn;e.radius=.5;let n=new P.MeshBasicMaterial({color:65280,transparent:!0,opacity:.5,side:P.DoubleSide,depthTest:!1,depthWrite:!1});this._meshPitch=new P.Mesh(e,n),this.add(this._meshPitch)}{let e=new cn;e.radius=.5;let n=new P.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5,side:P.DoubleSide,depthTest:!1,depthWrite:!1});this._meshYaw=new P.Mesh(e,n),this.add(this._meshYaw)}{let e=new dr;e.radius=.1;let n=new P.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new P.LineSegments(e,n),this._lineTarget.frustumCulled=!1,this.add(this._lineTarget)}}dispose(){this._meshYaw.geometry.dispose(),this._meshYaw.material.dispose(),this._meshPitch.geometry.dispose(),this._meshPitch.material.dispose(),this._lineTarget.geometry.dispose(),this._lineTarget.material.dispose()}updateMatrixWorld(t){let e=P.MathUtils.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=e,this._meshYaw.geometry.update();let n=P.MathUtils.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=n,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(fe),this.vrmLookAt.getLookAtWorldQuaternion(Se),Se.multiply(this.vrmLookAt.getFaceFrontQuaternion(pn)),this._meshYaw.position.copy(fe),this._meshYaw.quaternion.copy(Se),this._meshPitch.position.copy(fe),this._meshPitch.quaternion.copy(Se),this._meshPitch.quaternion.multiply(pn.setFromAxisAngle(cr,e)),this._meshPitch.quaternion.multiply(hr);let{target:i,autoUpdate:r}=this.vrmLookAt;i!=null&&r&&(i.getWorldPosition(mn).sub(fe),this._lineTarget.geometry.tail.copy(mn),this._lineTarget.geometry.update(),this._lineTarget.position.copy(fe)),super.updateMatrixWorld(t)}},mr=new Ke.Vector3,fr=new Ke.Vector3;function Ge(t,e){return t.matrixWorld.decompose(mr,e,fr),e}function Le(t){return[Math.atan2(-t.z,t.x),Math.atan2(t.y,Math.sqrt(t.x*t.x+t.z*t.z))]}function _n(t){let e=Math.round(t/2/Math.PI);return t-2*Math.PI*e}var gn=new b.Vector3(0,0,1),_r=new b.Vector3,gr=new b.Vector3,vr=new b.Vector3,Er=new b.Quaternion,We=new b.Quaternion,vn=new b.Quaternion,Mr=new b.Quaternion,ke=new b.Euler,Un=class Cn{constructor(e,n){this.offsetFromHeadBone=new b.Vector3,this.autoUpdate=!0,this.faceFront=new b.Vector3(0,0,1),this.humanoid=e,this.applier=n,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new b.Quaternion)}get yaw(){return this._yaw}set yaw(e){this._yaw=e,this._needsUpdate=!0}get pitch(){return this._pitch}set pitch(e){this._pitch=e,this._needsUpdate=!0}get euler(){return console.warn("VRMLookAt: euler is deprecated. use getEuler() instead."),this.getEuler(new b.Euler)}getEuler(e){return e.set(b.MathUtils.DEG2RAD*this._pitch,b.MathUtils.DEG2RAD*this._yaw,0,"YXZ")}copy(e){if(this.humanoid!==e.humanoid)throw new Error("VRMLookAt: humanoid must be same in order to copy");return this.offsetFromHeadBone.copy(e.offsetFromHeadBone),this.applier=e.applier,this.autoUpdate=e.autoUpdate,this.target=e.target,this.faceFront.copy(e.faceFront),this}clone(){return new Cn(this.humanoid,this.applier).copy(this)}reset(){this._yaw=0,this._pitch=0,this._needsUpdate=!0}getLookAtWorldPosition(e){let n=this.humanoid.getRawBoneNode("head");return e.copy(this.offsetFromHeadBone).applyMatrix4(n.matrixWorld)}getLookAtWorldQuaternion(e){let n=this.humanoid.getRawBoneNode("head");return Ge(n,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(gn)<.01)return e.copy(this._restHeadWorldQuaternion).invert();let[n,i]=Le(this.faceFront);return ke.set(0,.5*Math.PI+n,i,"YZX"),e.setFromEuler(ke).premultiply(Mr.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(We),this.getFaceFrontQuaternion(vn),e.copy(gn).applyQuaternion(We).applyQuaternion(vn).applyEuler(this.getEuler(ke))}lookAt(e){let n=Er.copy(this._restHeadWorldQuaternion).multiply(bn(this.getLookAtWorldQuaternion(We))),i=this.getLookAtWorldPosition(gr),r=vr.copy(e).sub(i).applyQuaternion(n).normalize(),[s,a]=Le(this.faceFront),[l,o]=Le(r),u=_n(l-s),d=_n(a-o);this._yaw=b.MathUtils.RAD2DEG*u,this._pitch=b.MathUtils.RAD2DEG*d,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(_r)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};Un.EULER_ORDER="YXZ";var Rr=Un,Tr=new S.Vector3(0,0,1),B=new S.Quaternion,se=new S.Quaternion,O=new S.Euler(0,0,0,"YXZ"),He=class{constructor(t,e,n,i,r){this.humanoid=t,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r,this.faceFront=new S.Vector3(0,0,1),this._restQuatLeftEye=new S.Quaternion,this._restQuatRightEye=new S.Quaternion,this._restLeftEyeParentWorldQuat=new S.Quaternion,this._restRightEyeParentWorldQuat=new S.Quaternion;let s=this.humanoid.getRawBoneNode("leftEye"),a=this.humanoid.getRawBoneNode("rightEye");s&&(this._restQuatLeftEye.copy(s.quaternion),Ge(s.parent,this._restLeftEyeParentWorldQuat)),a&&(this._restQuatRightEye.copy(a.quaternion),Ge(a.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(t,e){let n=this.humanoid.getRawBoneNode("leftEye"),i=this.humanoid.getRawBoneNode("rightEye"),r=this.humanoid.getNormalizedBoneNode("leftEye"),s=this.humanoid.getNormalizedBoneNode("rightEye");n&&(e<0?O.x=-S.MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-e):O.x=S.MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(e),t<0?O.y=-S.MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(-t):O.y=S.MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(t),B.setFromEuler(O),this._getWorldFaceFrontQuat(se),r.quaternion.copy(se).multiply(B).multiply(se.invert()),B.copy(this._restLeftEyeParentWorldQuat),n.quaternion.copy(r.quaternion).multiply(B).premultiply(B.invert()).multiply(this._restQuatLeftEye)),i&&(e<0?O.x=-S.MathUtils.DEG2RAD*this.rangeMapVerticalDown.map(-e):O.x=S.MathUtils.DEG2RAD*this.rangeMapVerticalUp.map(e),t<0?O.y=-S.MathUtils.DEG2RAD*this.rangeMapHorizontalOuter.map(-t):O.y=S.MathUtils.DEG2RAD*this.rangeMapHorizontalInner.map(t),B.setFromEuler(O),this._getWorldFaceFrontQuat(se),s.quaternion.copy(se).multiply(B).multiply(se.invert()),B.copy(this._restRightEyeParentWorldQuat),i.quaternion.copy(s.quaternion).multiply(B).premultiply(B.invert()).multiply(this._restQuatRightEye))}lookAt(t){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");let e=S.MathUtils.RAD2DEG*t.y,n=S.MathUtils.RAD2DEG*t.x;this.applyYawPitch(e,n)}_getWorldFaceFrontQuat(t){if(this.faceFront.distanceToSquared(Tr)<.01)return t.identity();let[e,n]=Le(this.faceFront);return O.set(0,.5*Math.PI+e,n,"YZX"),t.setFromEuler(O)}};He.type="bone";var qe=class{constructor(t,e,n,i,r){this.expressions=t,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=n,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r}applyYawPitch(t,e){e<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-e))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(e))),t<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-t))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(t)))}lookAt(t){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");let e=Qe.MathUtils.RAD2DEG*t.y,n=Qe.MathUtils.RAD2DEG*t.x;this.applyYawPitch(e,n)}};qe.type="expression";var En=class{constructor(t,e){this.inputMaxValue=t,this.outputScale=e}map(t){return this.outputScale*Tn(t/this.inputMaxValue)}},xr=new Set(["1.0","1.0-beta"]),Ae=.01,et=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(t,e){this.parser=t,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(t){return y(this,null,function*(){let e=t.userData.vrmHumanoid;if(e===null)return;if(e===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");let n=t.userData.vrmExpressionManager;if(n!==null){if(n===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");t.userData.vrmLookAt=yield this._import(t,e,n)}})}_import(t,e,n){return y(this,null,function*(){if(e==null||n==null)return null;let i=yield this._v1Import(t,e,n);if(i)return i;let r=yield this._v0Import(t,e,n);return r||null})}_v1Import(t,e,n){return y(this,null,function*(){var i,r,s;let a=this.parser.json;if(!(((i=a.extensionsUsed)==null?void 0:i.indexOf("VRMC_vrm"))!==-1))return null;let o=(r=a.extensions)==null?void 0:r.VRMC_vrm;if(!o)return null;let u=o.specVersion;if(!xr.has(u))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${u}"`),null;let d=o.lookAt;if(!d)return null;let c=d.type==="expression"?1:10,f=this._v1ImportRangeMap(d.rangeMapHorizontalInner,c),p=this._v1ImportRangeMap(d.rangeMapHorizontalOuter,c),m=this._v1ImportRangeMap(d.rangeMapVerticalDown,c),h=this._v1ImportRangeMap(d.rangeMapVerticalUp,c),_;d.type==="expression"?_=new qe(n,f,p,m,h):_=new He(e,f,p,m,h);let g=this._importLookAt(e,_);return g.offsetFromHeadBone.fromArray((s=d.offsetFromHeadBone)!=null?s:[0,.06,0]),g})}_v1ImportRangeMap(t,e){var n,i;let r=(n=t==null?void 0:t.inputMaxValue)!=null?n:90,s=(i=t==null?void 0:t.outputScale)!=null?i:e;return r<Ae&&(console.warn("VRMLookAtLoaderPlugin: inputMaxValue of a range map is too small. Consider reviewing the range map!"),r=Ae),new En(r,s)}_v0Import(t,e,n){return y(this,null,function*(){var i,r,s,a;let o=(i=this.parser.json.extensions)==null?void 0:i.VRM;if(!o)return null;let u=o.firstPerson;if(!u)return null;let d=u.lookAtTypeName==="BlendShape"?1:10,c=this._v0ImportDegreeMap(u.lookAtHorizontalInner,d),f=this._v0ImportDegreeMap(u.lookAtHorizontalOuter,d),p=this._v0ImportDegreeMap(u.lookAtVerticalDown,d),m=this._v0ImportDegreeMap(u.lookAtVerticalUp,d),h;u.lookAtTypeName==="BlendShape"?h=new qe(n,c,f,p,m):h=new He(e,c,f,p,m);let _=this._importLookAt(e,h);return u.firstPersonBoneOffset?_.offsetFromHeadBone.set((r=u.firstPersonBoneOffset.x)!=null?r:0,(s=u.firstPersonBoneOffset.y)!=null?s:.06,-((a=u.firstPersonBoneOffset.z)!=null?a:0)):_.offsetFromHeadBone.set(0,.06,0),_.faceFront.set(0,0,-1),h instanceof He&&h.faceFront.set(0,0,-1),_})}_v0ImportDegreeMap(t,e){var n,i;let r=t==null?void 0:t.curve;JSON.stringify(r)!=="[0,0,0,1,1,1,1,0]"&&console.warn("Curves of LookAtDegreeMap defined in VRM 0.0 are not supported");let s=(n=t==null?void 0:t.xRange)!=null?n:90,a=(i=t==null?void 0:t.yRange)!=null?i:e;return s<Ae&&(console.warn("VRMLookAtLoaderPlugin: xRange of a degree map is too small. Consider reviewing the degree map!"),s=Ae),new En(s,a)}_importLookAt(t,e){let n=new Rr(t,e);if(this.helperRoot){let i=new pr(n);this.helperRoot.add(i),i.renderOrder=this.helperRoot.renderOrder}return n}},Uo={Bone:"bone",Expression:"expression"};function yr(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}var wr=new Set(["1.0","1.0-beta"]),tt=class{get name(){return"VRMMetaLoaderPlugin"}constructor(t,e){var n,i,r;this.parser=t,this.needThumbnailImage=(n=e==null?void 0:e.needThumbnailImage)!=null?n:!1,this.acceptLicenseUrls=(i=e==null?void 0:e.acceptLicenseUrls)!=null?i:["https://vrm.dev/licenses/1.0/"],this.acceptV0Meta=(r=e==null?void 0:e.acceptV0Meta)!=null?r:!0}afterRoot(t){return y(this,null,function*(){t.userData.vrmMeta=yield this._import(t)})}_import(t){return y(this,null,function*(){let e=yield this._v1Import(t);if(e!=null)return e;let n=yield this._v0Import(t);return n!=null?n:null})}_v1Import(t){return y(this,null,function*(){var e,n,i;let r=this.parser.json;if(!(((e=r.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;let a=(n=r.extensions)==null?void 0:n.VRMC_vrm;if(a==null)return null;let l=a.specVersion;if(!wr.has(l))return console.warn(`VRMMetaLoaderPlugin: Unknown VRMC_vrm specVersion "${l}"`),null;let o=a.meta;if(!o)return null;let u=o.licenseUrl;if(!new Set(this.acceptLicenseUrls).has(u))throw new Error(`VRMMetaLoaderPlugin: The license url "${u}" is not accepted`);let c;return this.needThumbnailImage&&o.thumbnailImage!=null&&(c=(i=yield this._extractGLTFImage(o.thumbnailImage))!=null?i:void 0),{metaVersion:"1",name:o.name,version:o.version,authors:o.authors,copyrightInformation:o.copyrightInformation,contactInformation:o.contactInformation,references:o.references,thirdPartyLicenses:o.thirdPartyLicenses,thumbnailImage:c,licenseUrl:o.licenseUrl,avatarPermission:o.avatarPermission,allowExcessivelyViolentUsage:o.allowExcessivelyViolentUsage,allowExcessivelySexualUsage:o.allowExcessivelySexualUsage,commercialUsage:o.commercialUsage,allowPoliticalOrReligiousUsage:o.allowPoliticalOrReligiousUsage,allowAntisocialOrHateUsage:o.allowAntisocialOrHateUsage,creditNotation:o.creditNotation,allowRedistribution:o.allowRedistribution,modification:o.modification,otherLicenseUrl:o.otherLicenseUrl}})}_v0Import(t){return y(this,null,function*(){var e;let i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;let r=i.meta;if(!r)return null;if(!this.acceptV0Meta)throw new Error("VRMMetaLoaderPlugin: Attempted to load VRM0.0 meta but acceptV0Meta is false");let s;return this.needThumbnailImage&&r.texture!=null&&r.texture!==-1&&(s=yield this.parser.getDependency("texture",r.texture)),{metaVersion:"0",allowedUserName:r.allowedUserName,author:r.author,commercialUssageName:r.commercialUssageName,contactInformation:r.contactInformation,licenseName:r.licenseName,otherLicenseUrl:r.otherLicenseUrl,otherPermissionUrl:r.otherPermissionUrl,reference:r.reference,sexualUssageName:r.sexualUssageName,texture:s!=null?s:void 0,title:r.title,version:r.version,violentUssageName:r.violentUssageName}})}_extractGLTFImage(t){return y(this,null,function*(){var e;let i=(e=this.parser.json.images)==null?void 0:e[t];if(i==null)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${t}] of glTF as a thumbnail but the image doesn't exist`),null;let r=i.uri;if(i.bufferView!=null){let a=yield this.parser.getDependency("bufferView",i.bufferView),l=new Blob([a],{type:i.mimeType});r=URL.createObjectURL(l)}return r==null?(console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${t}] of glTF as a thumbnail but the image couldn't load properly`),null):yield new On.ImageLoader().loadAsync(yr(r,this.parser.options.path)).catch(a=>(console.error(a),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},nt=class{constructor(t){this.scene=t.scene,this.meta=t.meta,this.humanoid=t.humanoid,this.expressionManager=t.expressionManager,this.firstPerson=t.firstPerson,this.lookAt=t.lookAt}update(t){this.humanoid.update(),this.lookAt&&this.lookAt.update(t),this.expressionManager&&this.expressionManager.update()}},Co=class{get name(){return"VRMC_vrm"}constructor(t,e){var n,i,r,s,a;this.parser=t;let l=e==null?void 0:e.helperRoot,o=e==null?void 0:e.autoUpdateHumanBones;this.expressionPlugin=(n=e==null?void 0:e.expressionPlugin)!=null?n:new Ye(t),this.firstPersonPlugin=(i=e==null?void 0:e.firstPersonPlugin)!=null?i:new Ze(t),this.humanoidPlugin=(r=e==null?void 0:e.humanoidPlugin)!=null?r:new Je(t,{helperRoot:l,autoUpdateHumanBones:o}),this.lookAtPlugin=(s=e==null?void 0:e.lookAtPlugin)!=null?s:new et(t,{helperRoot:l}),this.metaPlugin=(a=e==null?void 0:e.metaPlugin)!=null?a:new tt(t)}afterRoot(t){return y(this,null,function*(){yield this.metaPlugin.afterRoot(t),yield this.humanoidPlugin.afterRoot(t),yield this.expressionPlugin.afterRoot(t),yield this.lookAtPlugin.afterRoot(t),yield this.firstPersonPlugin.afterRoot(t);let e=t.userData.vrmMeta,n=t.userData.vrmHumanoid;if(e&&n){let i=new nt({scene:t.scene,expressionManager:t.userData.vrmExpressionManager,firstPerson:t.userData.vrmFirstPerson,humanoid:n,lookAt:t.userData.vrmLookAt,meta:e});t.userData.vrmCore=i}})}};var ge=class extends nt{constructor(e){super(e),this.materials=e.materials,this.springBoneManager=e.springBoneManager,this.nodeConstraintManager=e.nodeConstraintManager}update(e){super.update(e),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(e),this.materials&&this.materials.forEach(n=>{n.update&&n.update(e)})}};import*as Ie from"three";import*as Fn from"three";import*as Wn from"three";import*as w from"three";import*as kn from"three";var Pr=Object.defineProperty,Nn=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable,Dn=(t,e,n)=>e in t?Pr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Bn=(t,e)=>{for(var n in e||(e={}))Sr.call(e,n)&&Dn(t,n,e[n]);if(Nn)for(var n of Nn(e))Ar.call(e,n)&&Dn(t,n,e[n]);return t},te=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())}),Lr={"":3e3,srgb:3001};function Hr(t,e){parseInt(Wn.REVISION,10)>=152?t.colorSpace=e:t.encoding=Lr[e]}var br=class{get pending(){return Promise.all(this._pendings)}constructor(t,e){this._parser=t,this._materialParams=e,this._pendings=[]}assignPrimitive(t,e){e!=null&&(this._materialParams[t]=e)}assignColor(t,e,n){e!=null&&(this._materialParams[t]=new Fn.Color().fromArray(e),n&&this._materialParams[t].convertSRGBToLinear())}assignTexture(t,e,n){return te(this,null,function*(){let i=te(this,null,function*(){e!=null&&(yield this._parser.assignTexture(this._materialParams,t,e),n&&Hr(this._materialParams[t],"srgb"))});return this._pendings.push(i),i})}assignTextureByIndex(t,e,n){return te(this,null,function*(){return this.assignTexture(t,e!=null?{index:e}:void 0,n)})}},Vr=`// #define PHONG
|
|
3
3
|
|
|
4
4
|
varying vec3 vViewPosition;
|
|
5
5
|
|
|
@@ -122,7 +122,7 @@ void main() {
|
|
|
122
122
|
#include <shadowmap_vertex>
|
|
123
123
|
#include <fog_vertex>
|
|
124
124
|
|
|
125
|
-
}`,
|
|
125
|
+
}`,Ir=`// #define PHONG
|
|
126
126
|
|
|
127
127
|
uniform vec3 litFactor;
|
|
128
128
|
|
|
@@ -201,9 +201,7 @@ uniform float uvAnimationRotationPhase;
|
|
|
201
201
|
|
|
202
202
|
// #include <alphamap_pars_fragment>
|
|
203
203
|
|
|
204
|
-
#
|
|
205
|
-
#include <alphatest_pars_fragment>
|
|
206
|
-
#endif
|
|
204
|
+
#include <alphatest_pars_fragment>
|
|
207
205
|
|
|
208
206
|
#include <aomap_pars_fragment>
|
|
209
207
|
// #include <lightmap_pars_fragment>
|
|
@@ -228,19 +226,11 @@ uniform float uvAnimationRotationPhase;
|
|
|
228
226
|
|
|
229
227
|
#include <lights_pars_begin>
|
|
230
228
|
|
|
231
|
-
#
|
|
232
|
-
#include <normal_pars_fragment>
|
|
233
|
-
#endif
|
|
229
|
+
#include <normal_pars_fragment>
|
|
234
230
|
|
|
235
231
|
// #include <lights_phong_pars_fragment>
|
|
236
232
|
varying vec3 vViewPosition;
|
|
237
233
|
|
|
238
|
-
#if THREE_VRM_THREE_REVISION < 132
|
|
239
|
-
#ifndef FLAT_SHADED
|
|
240
|
-
varying vec3 vNormal;
|
|
241
|
-
#endif
|
|
242
|
-
#endif
|
|
243
|
-
|
|
244
234
|
struct MToonMaterial {
|
|
245
235
|
vec3 diffuseColor;
|
|
246
236
|
vec3 shadeColor;
|
|
@@ -278,12 +268,6 @@ vec3 getDiffuse(
|
|
|
278
268
|
return vec3( BRDF_Lambert( shading * lightColor ) );
|
|
279
269
|
#endif
|
|
280
270
|
|
|
281
|
-
#if THREE_VRM_THREE_REVISION < 132
|
|
282
|
-
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
|
283
|
-
lightColor *= PI;
|
|
284
|
-
#endif
|
|
285
|
-
#endif
|
|
286
|
-
|
|
287
271
|
vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );
|
|
288
272
|
|
|
289
273
|
// The "comment out if you want to PBR absolutely" line
|
|
@@ -323,12 +307,6 @@ vec3 getDiffuse(
|
|
|
323
307
|
float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );
|
|
324
308
|
vec3 irradiance = directLight.color;
|
|
325
309
|
|
|
326
|
-
#if THREE_VRM_THREE_REVISION < 132
|
|
327
|
-
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
|
328
|
-
irradiance *= PI;
|
|
329
|
-
#endif
|
|
330
|
-
#endif
|
|
331
|
-
|
|
332
310
|
// directSpecular will be used for rim lighting, not an actual specular
|
|
333
311
|
reflectedLight.directSpecular += irradiance;
|
|
334
312
|
|
|
@@ -365,14 +343,16 @@ vec3 getDiffuse(
|
|
|
365
343
|
|
|
366
344
|
#endif
|
|
367
345
|
|
|
368
|
-
// COMPAT:
|
|
346
|
+
// COMPAT: pre-r151
|
|
347
|
+
// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
|
|
369
348
|
#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )
|
|
370
349
|
|
|
371
350
|
uniform mat3 normalMatrix;
|
|
372
351
|
|
|
373
352
|
#endif
|
|
374
353
|
|
|
375
|
-
// COMPAT:
|
|
354
|
+
// COMPAT: pre-r151
|
|
355
|
+
// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
|
|
376
356
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )
|
|
377
357
|
|
|
378
358
|
// Per-Pixel Tangent Space Normal Mapping
|
|
@@ -405,7 +385,7 @@ vec3 getDiffuse(
|
|
|
405
385
|
|
|
406
386
|
}
|
|
407
387
|
|
|
408
|
-
#
|
|
388
|
+
#else
|
|
409
389
|
|
|
410
390
|
vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
|
|
411
391
|
|
|
@@ -435,52 +415,6 @@ vec3 getDiffuse(
|
|
|
435
415
|
|
|
436
416
|
}
|
|
437
417
|
|
|
438
|
-
#else
|
|
439
|
-
|
|
440
|
-
vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
|
|
441
|
-
|
|
442
|
-
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
|
443
|
-
|
|
444
|
-
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
|
445
|
-
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
|
446
|
-
vec2 st0 = dFdx( uv.st );
|
|
447
|
-
vec2 st1 = dFdy( uv.st );
|
|
448
|
-
|
|
449
|
-
float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude
|
|
450
|
-
|
|
451
|
-
vec3 S = ( q0 * st1.t - q1 * st0.t ) * scale;
|
|
452
|
-
vec3 T = ( - q0 * st1.s + q1 * st0.s ) * scale;
|
|
453
|
-
|
|
454
|
-
// three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0
|
|
455
|
-
// TODO: Is this still required? Or shall I make a PR about it?
|
|
456
|
-
|
|
457
|
-
if ( length( S ) == 0.0 || length( T ) == 0.0 ) {
|
|
458
|
-
return surf_norm;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
S = normalize( S );
|
|
462
|
-
T = normalize( T );
|
|
463
|
-
vec3 N = normalize( surf_norm );
|
|
464
|
-
|
|
465
|
-
#ifdef DOUBLE_SIDED
|
|
466
|
-
|
|
467
|
-
// Workaround for Adreno GPUs gl_FrontFacing bug. See #15850 and #10331
|
|
468
|
-
|
|
469
|
-
bool frontFacing = dot( cross( S, T ), N ) > 0.0;
|
|
470
|
-
|
|
471
|
-
mapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );
|
|
472
|
-
|
|
473
|
-
#else
|
|
474
|
-
|
|
475
|
-
mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
|
476
|
-
|
|
477
|
-
#endif
|
|
478
|
-
|
|
479
|
-
mat3 tsn = mat3( S, T, N );
|
|
480
|
-
return normalize( tsn * mapN );
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
418
|
#endif
|
|
485
419
|
|
|
486
420
|
#endif
|
|
@@ -633,7 +567,8 @@ void main() {
|
|
|
633
567
|
|
|
634
568
|
// #include <normal_fragment_maps>
|
|
635
569
|
|
|
636
|
-
// COMPAT:
|
|
570
|
+
// COMPAT: pre-r151
|
|
571
|
+
// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
|
|
637
572
|
#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )
|
|
638
573
|
|
|
639
574
|
normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
|
|
@@ -646,23 +581,14 @@ void main() {
|
|
|
646
581
|
|
|
647
582
|
#ifdef DOUBLE_SIDED
|
|
648
583
|
|
|
649
|
-
|
|
650
|
-
// See: #21205, #21307, #21299
|
|
651
|
-
#if THREE_VRM_THREE_REVISION >= 126
|
|
652
|
-
|
|
653
|
-
normal = normal * faceDirection;
|
|
654
|
-
|
|
655
|
-
#else
|
|
656
|
-
|
|
657
|
-
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
|
|
658
|
-
|
|
659
|
-
#endif
|
|
584
|
+
normal = normal * faceDirection;
|
|
660
585
|
|
|
661
586
|
#endif
|
|
662
587
|
|
|
663
588
|
normal = normalize( normalMatrix * normal );
|
|
664
589
|
|
|
665
|
-
// COMPAT:
|
|
590
|
+
// COMPAT: pre-r151
|
|
591
|
+
// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
|
|
666
592
|
#elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )
|
|
667
593
|
|
|
668
594
|
vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;
|
|
@@ -675,16 +601,7 @@ void main() {
|
|
|
675
601
|
|
|
676
602
|
#else
|
|
677
603
|
|
|
678
|
-
|
|
679
|
-
#if THREE_VRM_THREE_REVISION >= 126
|
|
680
|
-
|
|
681
|
-
normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );
|
|
682
|
-
|
|
683
|
-
#else
|
|
684
|
-
|
|
685
|
-
normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN );
|
|
686
|
-
|
|
687
|
-
#endif
|
|
604
|
+
normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );
|
|
688
605
|
|
|
689
606
|
#endif
|
|
690
607
|
|
|
@@ -777,16 +694,20 @@ void main() {
|
|
|
777
694
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
778
695
|
#if THREE_VRM_THREE_REVISION >= 157
|
|
779
696
|
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
780
|
-
#elif THREE_VRM_THREE_REVISION >= 132
|
|
781
|
-
getPointLightInfo( pointLight, geometry, directLight );
|
|
782
697
|
#else
|
|
783
|
-
|
|
698
|
+
getPointLightInfo( pointLight, geometry, directLight );
|
|
784
699
|
#endif
|
|
785
700
|
|
|
786
701
|
shadow = 1.0;
|
|
787
702
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
788
703
|
pointLightShadow = pointLightShadows[ i ];
|
|
789
|
-
|
|
704
|
+
// COMPAT: pre-r166
|
|
705
|
+
// r166 introduced shadowIntensity
|
|
706
|
+
#if THREE_VRM_THREE_REVISION >= 166
|
|
707
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
708
|
+
#else
|
|
709
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
710
|
+
#endif
|
|
790
711
|
#endif
|
|
791
712
|
|
|
792
713
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
@@ -816,16 +737,20 @@ void main() {
|
|
|
816
737
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
817
738
|
#if THREE_VRM_THREE_REVISION >= 157
|
|
818
739
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
819
|
-
#elif THREE_VRM_THREE_REVISION >= 132
|
|
820
|
-
getSpotLightInfo( spotLight, geometry, directLight );
|
|
821
740
|
#else
|
|
822
|
-
|
|
741
|
+
getSpotLightInfo( spotLight, geometry, directLight );
|
|
823
742
|
#endif
|
|
824
743
|
|
|
825
744
|
shadow = 1.0;
|
|
826
745
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
827
746
|
spotLightShadow = spotLightShadows[ i ];
|
|
828
|
-
|
|
747
|
+
// COMPAT: pre-r166
|
|
748
|
+
// r166 introduced shadowIntensity
|
|
749
|
+
#if THREE_VRM_THREE_REVISION >= 166
|
|
750
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
|
751
|
+
#else
|
|
752
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
|
753
|
+
#endif
|
|
829
754
|
#endif
|
|
830
755
|
|
|
831
756
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
@@ -855,16 +780,20 @@ void main() {
|
|
|
855
780
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
856
781
|
#if THREE_VRM_THREE_REVISION >= 157
|
|
857
782
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
858
|
-
#elif THREE_VRM_THREE_REVISION >= 132
|
|
859
|
-
getDirectionalLightInfo( directionalLight, geometry, directLight );
|
|
860
783
|
#else
|
|
861
|
-
|
|
784
|
+
getDirectionalLightInfo( directionalLight, geometry, directLight );
|
|
862
785
|
#endif
|
|
863
786
|
|
|
864
787
|
shadow = 1.0;
|
|
865
788
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
866
789
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
867
|
-
|
|
790
|
+
// COMPAT: pre-r166
|
|
791
|
+
// r166 introduced shadowIntensity
|
|
792
|
+
#if THREE_VRM_THREE_REVISION >= 166
|
|
793
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
794
|
+
#else
|
|
795
|
+
shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
796
|
+
#endif
|
|
868
797
|
#endif
|
|
869
798
|
|
|
870
799
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
@@ -906,10 +835,8 @@ void main() {
|
|
|
906
835
|
#if defined( USE_LIGHT_PROBES )
|
|
907
836
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
908
837
|
#endif
|
|
909
|
-
#elif THREE_VRM_THREE_REVISION >= 133
|
|
910
|
-
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
911
838
|
#else
|
|
912
|
-
irradiance += getLightProbeIrradiance( lightProbe, geometry );
|
|
839
|
+
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
913
840
|
#endif
|
|
914
841
|
|
|
915
842
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
@@ -920,10 +847,8 @@ void main() {
|
|
|
920
847
|
// COMPAT: pre-r156 uses a struct GeometricContext
|
|
921
848
|
#if THREE_VRM_THREE_REVISION >= 157
|
|
922
849
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
923
|
-
#elif THREE_VRM_THREE_REVISION >= 133
|
|
924
|
-
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
925
850
|
#else
|
|
926
|
-
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
|
|
851
|
+
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
927
852
|
#endif
|
|
928
853
|
|
|
929
854
|
}
|
|
@@ -999,11 +924,11 @@ void main() {
|
|
|
999
924
|
gl_FragColor = vec4( col, diffuseColor.a );
|
|
1000
925
|
postCorrection();
|
|
1001
926
|
}
|
|
1002
|
-
`,
|
|
927
|
+
`,Ur={None:"none",Normal:"normal",LitShadeRate:"litShadeRate",UV:"uv"},it={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},Cr={3e3:"",3001:"srgb"};function rt(t){return parseInt(kn.REVISION,10)>=152?t.colorSpace:Cr[t.encoding]}var Or=class extends w.ShaderMaterial{constructor(t={}){var e;super({vertexShader:Vr,fragmentShader:Ir}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=w.TangentSpaceNormalMap,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=Ur.None,this._outlineWidthMode=it.None,this._isOutline=!1,t.transparentWithZWrite&&(t.depthWrite=!0),delete t.transparentWithZWrite,t.fog=!0,t.lights=!0,t.clipping=!0,this.uniforms=w.UniformsUtils.merge([w.UniformsLib.common,w.UniformsLib.normalmap,w.UniformsLib.emissivemap,w.UniformsLib.fog,w.UniformsLib.lights,{litFactor:{value:new w.Color(1,1,1)},mapUvTransform:{value:new w.Matrix3},colorAlpha:{value:1},normalMapUvTransform:{value:new w.Matrix3},shadeColorFactor:{value:new w.Color(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new w.Matrix3},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new w.Matrix3},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new w.Color(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new w.Matrix3},parametricRimColorFactor:{value:new w.Color(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new w.Matrix3},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new w.Color(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new w.Matrix3},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new w.Matrix3},outlineWidthFactor:{value:0},outlineColorFactor:{value:new w.Color(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new w.Matrix3},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},(e=t.uniforms)!=null?e:{}]),this.setValues(t),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([n,i])=>`${n}:${i}`),this.matcapTexture?`matcapTextureColorSpace:${rt(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${rt(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${rt(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=n=>{let i=parseInt(w.REVISION,10),r=Object.entries(Bn(Bn({},this._generateDefines()),this.defines)).filter(([s,a])=>!!a).map(([s,a])=>`#define ${s} ${a}`).join(`
|
|
1003
928
|
`)+`
|
|
1004
|
-
`;n.vertexShader=r+n.vertexShader,n.fragmentShader=r+n.fragmentShader,i<154&&(n.fragmentShader=n.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>")),i<132&&(n.fragmentShader=n.fragmentShader.replace("#include <normal_pars_fragment>",""),n.fragmentShader=n.fragmentShader.replace("#include <alphatest_pars_fragment>",""))}}get color(){return this.uniforms.litFactor.value}set color(e){this.uniforms.litFactor.value=e}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get normalMap(){return this.uniforms.normalMap.value}set normalMap(e){this.uniforms.normalMap.value=e}get normalScale(){return this.uniforms.normalScale.value}set normalScale(e){this.uniforms.normalScale.value=e}get emissive(){return this.uniforms.emissive.value}set emissive(e){this.uniforms.emissive.value=e}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(e){this.uniforms.emissiveIntensity.value=e}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(e){this.uniforms.emissiveMap.value=e}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(e){this.uniforms.shadeColorFactor.value=e}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(e){this.uniforms.shadeMultiplyTexture.value=e}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(e){this.uniforms.shadingShiftFactor.value=e}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(e){this.uniforms.shadingShiftTexture.value=e}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(e){this.uniforms.shadingShiftTextureScale.value=e}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(e){this.uniforms.shadingToonyFactor.value=e}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(e){this.uniforms.giEqualizationFactor.value=e}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(e){this.uniforms.matcapFactor.value=e}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(e){this.uniforms.matcapTexture.value=e}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(e){this.uniforms.parametricRimColorFactor.value=e}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(e){this.uniforms.rimMultiplyTexture.value=e}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(e){this.uniforms.rimLightingMixFactor.value=e}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(e){this.uniforms.parametricRimFresnelPowerFactor.value=e}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(e){this.uniforms.parametricRimLiftFactor.value=e}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(e){this.uniforms.outlineWidthMultiplyTexture.value=e}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(e){this.uniforms.outlineWidthFactor.value=e}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(e){this.uniforms.outlineColorFactor.value=e}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(e){this.uniforms.outlineLightingMixFactor.value=e}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(e){this.uniforms.uvAnimationMaskTexture.value=e}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(e){this.uniforms.uvAnimationScrollXOffset.value=e}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(e){this.uniforms.uvAnimationScrollYOffset.value=e}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(e){this.uniforms.uvAnimationRotationPhase.value=e}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(e){this._ignoreVertexColor=e,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(e){this._v0CompatShade=e,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(e){this._debugMode=e,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(e){this._outlineWidthMode=e,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(e){this._isOutline=e,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(e){this._uploadUniformsWorkaround(),this._updateUVAnimation(e)}copy(e){return super.copy(e),this.map=e.map,this.normalMap=e.normalMap,this.emissiveMap=e.emissiveMap,this.shadeMultiplyTexture=e.shadeMultiplyTexture,this.shadingShiftTexture=e.shadingShiftTexture,this.matcapTexture=e.matcapTexture,this.rimMultiplyTexture=e.rimMultiplyTexture,this.outlineWidthMultiplyTexture=e.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=e.uvAnimationMaskTexture,this.normalMapType=e.normalMapType,this.uvAnimationScrollXSpeedFactor=e.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=e.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=e.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=e.ignoreVertexColor,this.v0CompatShade=e.v0CompatShade,this.debugMode=e.debugMode,this.outlineWidthMode=e.outlineWidthMode,this.isOutline=e.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(e){this.uniforms.uvAnimationScrollXOffset.value+=e*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=e*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=e*this.uvAnimationRotationSpeedFactor,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),parseInt(S.REVISION,10)>=132&&(this.uniforms.alphaTest.value=this.alphaTest),this.uniformsNeedUpdate=!0}_generateDefines(){let e=parseInt(S.REVISION,10),t=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:e,OUTLINE:this._isOutline,MTOON_USE_UV:t||n,MTOON_UVS_VERTEX_ONLY:t&&!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_WORLD:this._isOutline&&this._outlineWidthMode===te.WorldCoordinates,OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===te.ScreenCoordinates}}_updateTextureMatrix(e,t){e.value&&(e.value.matrixAutoUpdate&&e.value.updateMatrix(),t.value.copy(e.value.matrix))}},to=new Set(["1.0","1.0-beta"]),oi=class Be{get name(){return Be.EXTENSION_NAME}constructor(t,n={}){var i,r,o;this.parser=t,this.renderOrderOffset=(i=n.renderOrderOffset)!=null?i:0,this.v0CompatShade=(r=n.v0CompatShade)!=null?r:!1,this.debugMode=(o=n.debugMode)!=null?o:"none",this._mToonMaterialSet=new Set}beforeRoot(){return ue(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(t){return ue(this,null,function*(){t.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(t){return this._getMToonExtension(t)?eo:null}extendMaterialParams(t,n){let i=this._getMToonExtension(t);return i?this._extendMaterialParams(i,n):null}loadMesh(t){return ue(this,null,function*(){var n;let i=this.parser,o=(n=i.json.meshes)==null?void 0:n[t];if(o==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${t}] of glTF but the mesh doesn't exist`);let l=o.primitives,a=yield i.loadMesh(t);if(l.length===1){let s=a,u=l[0].material;u!=null&&this._setupPrimitive(s,u)}else{let s=a;for(let u=0;u<l.length;u++){let d=s.children[u],c=l[u].material;c!=null&&this._setupPrimitive(d,c)}}return a})}_removeUnlitExtensionIfMToonExists(){let i=this.parser.json.materials;i==null||i.map((r,o)=>{var l;this._getMToonExtension(o)&&((l=r.extensions)!=null&&l.KHR_materials_unlit)&&delete r.extensions.KHR_materials_unlit})}_getMToonExtension(t){var n,i;let l=(n=this.parser.json.materials)==null?void 0:n[t];if(l==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}let a=(i=l.extensions)==null?void 0:i[Be.EXTENSION_NAME];if(a==null)return;let s=a.specVersion;if(!to.has(s)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${Be.EXTENSION_NAME} specVersion "${s}"`);return}return a}_extendMaterialParams(t,n){return ue(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new Yr(this.parser,n);r.assignPrimitive("transparentWithZWrite",t.transparentWithZWrite),r.assignColor("shadeColorFactor",t.shadeColorFactor),r.assignTexture("shadeMultiplyTexture",t.shadeMultiplyTexture,!0),r.assignPrimitive("shadingShiftFactor",t.shadingShiftFactor),r.assignTexture("shadingShiftTexture",t.shadingShiftTexture,!0),r.assignPrimitive("shadingShiftTextureScale",(i=t.shadingShiftTexture)==null?void 0:i.scale),r.assignPrimitive("shadingToonyFactor",t.shadingToonyFactor),r.assignPrimitive("giEqualizationFactor",t.giEqualizationFactor),r.assignColor("matcapFactor",t.matcapFactor),r.assignTexture("matcapTexture",t.matcapTexture,!0),r.assignColor("parametricRimColorFactor",t.parametricRimColorFactor),r.assignTexture("rimMultiplyTexture",t.rimMultiplyTexture,!0),r.assignPrimitive("rimLightingMixFactor",t.rimLightingMixFactor),r.assignPrimitive("parametricRimFresnelPowerFactor",t.parametricRimFresnelPowerFactor),r.assignPrimitive("parametricRimLiftFactor",t.parametricRimLiftFactor),r.assignPrimitive("outlineWidthMode",t.outlineWidthMode),r.assignPrimitive("outlineWidthFactor",t.outlineWidthFactor),r.assignTexture("outlineWidthMultiplyTexture",t.outlineWidthMultiplyTexture,!1),r.assignColor("outlineColorFactor",t.outlineColorFactor),r.assignPrimitive("outlineLightingMixFactor",t.outlineLightingMixFactor),r.assignTexture("uvAnimationMaskTexture",t.uvAnimationMaskTexture,!1),r.assignPrimitive("uvAnimationScrollXSpeedFactor",t.uvAnimationScrollXSpeedFactor),r.assignPrimitive("uvAnimationScrollYSpeedFactor",t.uvAnimationScrollYSpeedFactor),r.assignPrimitive("uvAnimationRotationSpeedFactor",t.uvAnimationRotationSpeedFactor),r.assignPrimitive("v0CompatShade",this.v0CompatShade),r.assignPrimitive("debugMode",this.debugMode),yield r.pending})}_setupPrimitive(t,n){let i=this._getMToonExtension(n);if(i){let r=this._parseRenderOrder(i);t.renderOrder=r+this.renderOrderOffset,this._generateOutline(t),this._addToMaterialSet(t);return}}_generateOutline(t){let n=t.material;if(!(n instanceof We.Material)||typeof n.outlineWidthMode!="string"||n.outlineWidthMode==="none"||typeof n.outlineWidthFactor!="number"||n.outlineWidthFactor<=0)return;t.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=We.BackSide,t.material.push(i);let r=t.geometry,o=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,o,0),r.addGroup(0,o,1)}_addToMaterialSet(t){let n=t.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(t){var n;return(t.transparentWithZWrite?0:19)+((n=t.renderQueueOffsetNumber)!=null?n:0)}};oi.EXTENSION_NAME="VRMC_materials_mtoon";var gt=oi,no=w.materialReference("color","color"),io=w.materialReference("map","texture"),ro=w.materialReference("normalMap","texture"),oo=w.materialReference("normalScale","vec2"),so=w.materialReference("emissive","color"),ao=w.materialReference("emissiveIntensity","float"),lo=w.materialReference("emissiveMap","texture"),uo=w.materialReference("shadeColorFactor","color"),ho=w.materialReference("shadingShiftFactor","float"),ei=w.materialReference("shadeMultiplyTexture","texture"),co=w.materialReference("shadeMultiplyTextureScale","float"),mo=w.materialReference("shadingToonyFactor","float"),po=w.materialReference("rimLightingMixFactor","float"),fo=w.materialReference("rimMultiplyTexture","texture"),go=w.materialReference("matcapFactor","color"),_o=w.materialReference("matcapTexture","texture"),vo=w.materialReference("parametricRimColorFactor","color"),Eo=w.materialReference("parametricRimLiftFactor","float"),Mo=w.materialReference("parametricRimFresnelPowerFactor","float"),Ro=w.materialReference("outlineWidthMultiplyTexture","texture"),To=w.materialReference("outlineWidthFactor","float"),ti=w.materialReference("outlineColorFactor","color"),xo=w.materialReference("outlineLightingMixFactor","float"),yo=w.materialReference("uvAnimationMaskTexture","texture"),So=w.materialReference("uvAnimationScrollXOffset","float"),Po=w.materialReference("uvAnimationScrollYOffset","float"),wo=w.materialReference("uvAnimationRotationPhase","float"),Lo=class extends O.TempNode{constructor(e){super("vec2"),this.hasMaskTexture=e}setup(){let e=1;this.hasMaskTexture&&(e=O.vec4(yo).context({getUV:()=>O.uv()}).r);let t=O.uv(),n=wo.mul(e),i=O.cos(n),r=O.sin(n);t=t.sub(O.vec2(.5,.5)),t=t.mul(O.mat2(i,r,r.negate(),i)),t=t.add(O.vec2(.5,.5));let o=O.vec2(So,Po).mul(e);return t=t.add(o),t.temp("AnimatedUV")}},si=F.nodeImmutable(F.PropertyNode,"vec3").temp("ShadeColor"),ai=F.nodeImmutable(F.PropertyNode,"float").temp("ShadingShift"),li=F.nodeImmutable(F.PropertyNode,"float").temp("ShadingToony"),ct=F.nodeImmutable(F.PropertyNode,"float").temp("RimLightingMix"),mt=F.nodeImmutable(F.PropertyNode,"vec3").temp("RimMultiply"),pt=F.nodeImmutable(F.PropertyNode,"vec3").temp("matcap"),ft=F.nodeImmutable(F.PropertyNode,"vec3").temp("ParametricRim"),Ao=A.tslFn(({a:e,b:t,t:n})=>{let i=n.sub(e),r=t.sub(e);return i.div(r).clamp()}),No=A.tslFn(({dotNL:e})=>{let n=A.float(1).sub(li),i=e.add(ai);return i=Ao({a:n.negate(),b:n,t:i}),i=i.mul(1),i}),Ho=A.tslFn(({shading:e,lightColor:t})=>{let n=A.mix(si,A.diffuseColor,e);return t.mul(A.BRDF_Lambert({diffuseColor:n}))}),Vo=class extends A.LightingModel{constructor(){super()}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let i=A.transformedNormalView.dot(e).clamp(-1,1),r=No({dotNL:i});n.directDiffuse.assign(n.directDiffuse.add(Ho({shading:r,lightColor:t}))),n.directSpecular.assign(n.directSpecular.add(ft.add(pt).mul(mt).mul(A.mix(A.vec3(0),A.BRDF_Lambert({diffuseColor:t}),ct))))}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.assign(t.indirectDiffuse.add(e.mul(A.BRDF_Lambert({diffuseColor:A.diffuseColor}))))}indirectSpecular({reflectedLight:e}){e.indirectSpecular.assign(e.indirectSpecular.add(ft.add(pt).mul(mt).mul(A.mix(A.vec3(1),A.vec3(0),ct))))}},bo=ne.tslFn(({parametricRimLift:e,parametricRimFresnelPower:t,parametricRimColor:n})=>{let i=ne.modelViewPosition.normalize(),r=ne.transformedNormalView.dot(i.negate());return ne.float(1).sub(r).add(e).clamp().pow(t).mul(n)}),Io=class extends y.NodeMaterial{customProgramCacheKey(){let e=super.customProgramCacheKey();return e+=`isOutline:${this.isOutline},`,e}constructor(e={}){super(),parseInt(B.REVISION,10)<161&&console.warn("MToonNodeMaterial requires Three.js r161 or higher. This would not work correctly."),e.transparentWithZWrite&&(e.depthWrite=!0),delete e.transparentWithZWrite,this.emissiveNode=null,this.lights=!0,this.color=new B.Color(1,1,1),this.map=null,this.emissive=new B.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new B.Vector2(1,1),this.shadeColorFactor=new B.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 B.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new B.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=te.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new B.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(e)}setupLightingModel(){return new Vo}setup(e){var t;this._animatedUVNode=new Lo((t=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?t:!1),super.setup(e)}setupDiffuseColor(e){let t=null;if(this.colorNode==null){if(t=no,this.map&&this.map.isTexture===!0){let n=io.context({getUV:()=>this._animatedUVNode});t=t.mul(n)}this.colorNode=t}this.vertexColors===!0&&e.geometry.hasAttribute("color")&&(console.warn("MToonNodeMaterial: MToon ignores vertex colors. Consider using a model without vertex colors instead."),this.vertexColors=!1),super.setupDiffuseColor(e),this.colorNode===t&&(this.colorNode=null)}setupVariants({stack:e}){e.assign(si,this._setupShadeColorNode()),e.assign(ai,this._setupShadingShiftNode()),e.assign(li,this._setupShadingToonyNode()),e.assign(ct,this._setupRimLightingMixNode()),e.assign(mt,this._setupRimMultiplyNode()),e.assign(pt,this._setupMatcapNode()),e.assign(ft,this._setupParametricRimNode())}setupNormal(e){let t=this.normalNode;if(this.normalNode==null){if(this.normalNode=y.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let n=ro.context({getUV:()=>this._animatedUVNode});this.normalNode=n.normalMap(oo)}this.isOutline&&(this.normalNode=this.normalNode.negate())}super.setupNormal(e),this.normalNode=t}setupLighting(e){let t=null;if(this.emissiveNode==null){if(t=so.mul(ao),this.emissiveMap&&this.emissiveMap.isTexture===!0){let i=lo.context({getUV:()=>this._animatedUVNode});t=t.mul(i)}this.emissiveNode=t}let n=super.setupLighting(e);return this.emissiveNode===t&&(this.emissiveNode=null),n}setupOutput(e,t){return this.isOutline&&this.outlineWidthMode!==te.None&&(t=y.vec4(y.mix(ti,t.xyz.mul(ti),xo),t.w)),this.transparent===!1&&this.blending===B.NormalBlending&&this.alphaToCoverage===!1&&t.a.assign(1),super.setupOutput(e,t)}setupPosition(e){var t,n;let i=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==te.None){(t=this.positionNode)!=null||(this.positionNode=y.positionLocal);let o=y.normalLocal.normalize(),l=To;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let u=Ro.context({getUV:()=>this._animatedUVNode});l=l.mul(u)}let a=y.length(y.modelNormalMatrix.mul(o)),s=l.mul(a).mul(o);if(this.outlineWidthMode===te.WorldCoordinates)this.positionNode=this.positionNode.add(s);else if(this.outlineWidthMode===te.ScreenCoordinates){let u=y.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(s.div(u).mul(y.positionView.z.negate()))}(n=this.positionNode)!=null||(this.positionNode=y.positionLocal)}let r=super.setupPosition(e);return r.z.add(r.w.mul(1e-6)),this.positionNode=i,r}copy(e){var t,n,i,r,o,l,a,s,u,d,c,f,m,p,h,g,_,R,E;return this.color.copy(e.color),this.map=(t=e.map)!=null?t:null,this.emissive.copy(e.emissive),this.emissiveIntensity=e.emissiveIntensity,this.emissiveMap=(n=e.emissiveMap)!=null?n:null,this.normalMap=(i=e.normalMap)!=null?i:null,this.normalScale.copy(e.normalScale),this.shadeColorFactor.copy(e.shadeColorFactor),this.shadeMultiplyTexture=(r=e.shadeMultiplyTexture)!=null?r:null,this.shadingShiftFactor=e.shadingShiftFactor,this.shadingShiftTexture=(o=e.shadingShiftTexture)!=null?o:null,this.shadingShiftTextureScale=e.shadingShiftTextureScale,this.shadingToonyFactor=e.shadingToonyFactor,this.rimLightingMixFactor=e.rimLightingMixFactor,this.rimMultiplyTexture=(l=e.rimMultiplyTexture)!=null?l:null,this.matcapFactor.copy(e.matcapFactor),this.matcapTexture=(a=e.matcapTexture)!=null?a:null,this.parametricRimColorFactor.copy(e.parametricRimColorFactor),this.parametricRimLiftFactor=e.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=e.parametricRimFresnelPowerFactor,this.outlineWidthMode=e.outlineWidthMode,this.outlineWidthMultiplyTexture=(s=e.outlineWidthMultiplyTexture)!=null?s:null,this.outlineWidthFactor=e.outlineWidthFactor,this.outlineColorFactor.copy(e.outlineColorFactor),this.outlineLightingMixFactor=e.outlineLightingMixFactor,this.uvAnimationScrollXSpeedFactor=e.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=e.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=e.uvAnimationRotationSpeedFactor,this.uvAnimationMaskTexture=(u=e.uvAnimationMaskTexture)!=null?u:null,this.shadeColorNode=(d=e.shadeColorNode)!=null?d:null,this.shadingShiftNode=(c=e.shadingShiftNode)!=null?c:null,this.shadingToonyNode=(f=e.shadingToonyNode)!=null?f:null,this.rimLightingMixNode=(m=e.rimLightingMixNode)!=null?m:null,this.rimMultiplyNode=(p=e.rimMultiplyNode)!=null?p:null,this.matcapNode=(h=e.matcapNode)!=null?h:null,this.parametricRimColorNode=(g=e.parametricRimColorNode)!=null?g:null,this.parametricRimLiftNode=(_=e.parametricRimLiftNode)!=null?_:null,this.parametricRimFresnelPowerNode=(R=e.parametricRimFresnelPowerNode)!=null?R:null,this.isOutline=(E=e.isOutline)!=null?E:null,super.copy(e)}update(e){this.uvAnimationScrollXOffset+=e*this.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYOffset+=e*this.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationPhase+=e*this.uvAnimationRotationSpeedFactor}_setupShadeColorNode(){if(this.shadeColorNode!=null)return y.vec3(this.shadeColorNode);let e=uo;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let t=ei.context({getUV:()=>this._animatedUVNode});e=e.mul(t)}return e}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return y.float(this.shadingShiftNode);let e=ho;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let t=ei.context({getUV:()=>this._animatedUVNode});e=e.add(t.mul(co))}return e}_setupShadingToonyNode(){return this.shadingToonyNode!=null?y.float(this.shadingToonyNode):mo}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?y.float(this.rimLightingMixNode):po}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?y.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?fo.context({getUV:()=>this._animatedUVNode}):y.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?y.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?_o.context({getUV:()=>y.matcapUV.mul(1,-1).add(0,1)}).mul(go):y.vec3(0)}_setupParametricRimNode(){let e=this.parametricRimColorNode!=null?y.vec3(this.parametricRimColorNode):vo,t=this.parametricRimLiftNode!=null?y.float(this.parametricRimLiftNode):Eo,n=this.parametricRimFresnelPowerNode!=null?y.float(this.parametricRimFresnelPowerNode):Mo;return bo({parametricRimLift:t,parametricRimFresnelPower:n,parametricRimColor:e})}},Zs=class extends gt{constructor(e,t={}){super(e,t)}getMaterialType(e){return this._getMToonExtension(e)?Io:null}};var Co=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())}),ui=class _t{get name(){return _t.EXTENSION_NAME}constructor(t){this.parser=t}extendMaterialParams(t,n){return Co(this,null,function*(){let i=this._getHDREmissiveMultiplierExtension(t);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(t){var n,i;let l=(n=this.parser.json.materials)==null?void 0:n[t];if(l==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${t}] of glTF but the material doesn't exist`);return}let a=(i=l.extensions)==null?void 0:i[_t.EXTENSION_NAME];if(a!=null)return a}};ui.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var di=ui;import*as pi from"three";var Uo=Object.defineProperty,Oo=Object.defineProperties,Fo=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Do=Object.prototype.hasOwnProperty,Bo=Object.prototype.propertyIsEnumerable,ci=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Do.call(t,n)&&ci(e,n,t[n]);if(hi)for(var n of hi(t))Bo.call(t,n)&&ci(e,n,t[n]);return e},mi=(e,t)=>Oo(e,Fo(t)),Wo=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())});function ge(e){return Math.pow(e,2.2)}var fi=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(e){var t;this.parser=e,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;let n=this.parser.json;n.extensionsUsed=(t=n.extensionsUsed)!=null?t:[],n.extensionsUsed.indexOf("KHR_texture_transform")===-1&&n.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return Wo(this,null,function*(){var e;let t=this.parser.json,n=(e=t.extensions)==null?void 0:e.VRM,i=n==null?void 0:n.materialProperties;i&&(this._populateRenderQueueMap(i),i.forEach((r,o)=>{var l,a;let s=(l=t.materials)==null?void 0:l[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);t.materials[o]=u}else if((a=r.shader)!=null&&a.startsWith("VRM/Unlit")){let u=this._parseV0UnlitProperties(r,s);t.materials[o]=u}else r.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${r.shader}`)}))})}_parseV0MToonProperties(e,t){var n,i,r,o,l,a,s,u,d,c,f,m,p,h,g,_,R,E,v,x,M,T,H,U,V,I,j,Me,yt,St,Pt,wt,Lt,At,Nt,Ht,Vt,bt,It,Ct,Ut,Ot,Ft,Dt,Bt,Wt,kt,zt,jt,Gt,Qt,qt,Xt,Yt,$t;let Zt=(i=(n=e.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,ki=((r=e.floatProperties)==null?void 0:r._ZWrite)===1&&Zt,zi=this._v0ParseRenderQueue(e),Jt=(l=(o=e.keywordMap)==null?void 0:o._ALPHATEST_ON)!=null?l:!1,ji=Zt?"BLEND":Jt?"MASK":"OPAQUE",Gi=Jt?(s=(a=e.floatProperties)==null?void 0:a._Cutoff)!=null?s:.5:void 0,Qi=((d=(u=e.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,se=this._portTextureTransform(e),qi=((f=(c=e.vectorProperties)==null?void 0:c._Color)!=null?f:[1,1,1,1]).map((ln,_r)=>_r===3?ln:ge(ln)),Kt=(m=e.textureProperties)==null?void 0:m._MainTex,Xi=Kt!=null?{index:Kt,extensions:Q({},se)}:void 0,Yi=(h=(p=e.floatProperties)==null?void 0:p._BumpScale)!=null?h:1,en=(g=e.textureProperties)==null?void 0:g._BumpMap,$i=en!=null?{index:en,scale:Yi,extensions:Q({},se)}:void 0,Zi=((R=(_=e.vectorProperties)==null?void 0:_._EmissionColor)!=null?R:[0,0,0,1]).map(ge),tn=(E=e.textureProperties)==null?void 0:E._EmissionMap,Ji=tn!=null?{index:tn,extensions:Q({},se)}:void 0,Ki=((x=(v=e.vectorProperties)==null?void 0:v._ShadeColor)!=null?x:[.97,.81,.86,1]).map(ge),nn=(M=e.textureProperties)==null?void 0:M._ShadeTexture,er=nn!=null?{index:nn,extensions:Q({},se)}:void 0,Ve=(H=(T=e.floatProperties)==null?void 0:T._ShadeShift)!=null?H:0,be=(V=(U=e.floatProperties)==null?void 0:U._ShadeToony)!=null?V:.9;be=pi.MathUtils.lerp(be,1,.5+.5*Ve),Ve=-Ve-(1-be);let rn=(j=(I=e.floatProperties)==null?void 0:I._IndirectLightIntensity)!=null?j:.1,tr=rn?1-rn:void 0,Ge=(Me=e.textureProperties)==null?void 0:Me._SphereAdd,nr=Ge!=null?[1,1,1]:void 0,ir=Ge!=null?{index:Ge}:void 0,rr=(St=(yt=e.floatProperties)==null?void 0:yt._RimLightingMix)!=null?St:0,on=(Pt=e.textureProperties)==null?void 0:Pt._RimTexture,or=on!=null?{index:on,extensions:Q({},se)}:void 0,sr=((Lt=(wt=e.vectorProperties)==null?void 0:wt._RimColor)!=null?Lt:[0,0,0,1]).map(ge),ar=(Nt=(At=e.floatProperties)==null?void 0:At._RimFresnelPower)!=null?Nt:1,lr=(Vt=(Ht=e.floatProperties)==null?void 0:Ht._RimLift)!=null?Vt:0,ur=["none","worldCoordinates","screenCoordinates"][(It=(bt=e.floatProperties)==null?void 0:bt._OutlineWidthMode)!=null?It:0],Qe=(Ut=(Ct=e.floatProperties)==null?void 0:Ct._OutlineWidth)!=null?Ut:0;Qe=.01*Qe;let sn=(Ot=e.textureProperties)==null?void 0:Ot._OutlineWidthTexture,dr=sn!=null?{index:sn,extensions:Q({},se)}:void 0,hr=((Dt=(Ft=e.vectorProperties)==null?void 0:Ft._OutlineColor)!=null?Dt:[0,0,0]).map(ge),cr=((Wt=(Bt=e.floatProperties)==null?void 0:Bt._OutlineColorMode)!=null?Wt:0)===1?(zt=(kt=e.floatProperties)==null?void 0:kt._OutlineLightingMix)!=null?zt:1:0,an=(jt=e.textureProperties)==null?void 0:jt._UvAnimMaskTexture,mr=an!=null?{index:an,extensions:Q({},se)}:void 0,pr=(Qt=(Gt=e.floatProperties)==null?void 0:Gt._UvAnimScrollX)!=null?Qt:0,Ie=(Xt=(qt=e.floatProperties)==null?void 0:qt._UvAnimScrollY)!=null?Xt:0;Ie!=null&&(Ie=-Ie);let fr=($t=(Yt=e.floatProperties)==null?void 0:Yt._UvAnimRotation)!=null?$t:0,gr={specVersion:"1.0",transparentWithZWrite:ki,renderQueueOffsetNumber:zi,shadeColorFactor:Ki,shadeMultiplyTexture:er,shadingShiftFactor:Ve,shadingToonyFactor:be,giEqualizationFactor:tr,matcapFactor:nr,matcapTexture:ir,rimLightingMixFactor:rr,rimMultiplyTexture:or,parametricRimColorFactor:sr,parametricRimFresnelPowerFactor:ar,parametricRimLiftFactor:lr,outlineWidthMode:ur,outlineWidthFactor:Qe,outlineWidthMultiplyTexture:dr,outlineColorFactor:hr,outlineLightingMixFactor:cr,uvAnimationMaskTexture:mr,uvAnimationScrollXSpeedFactor:pr,uvAnimationScrollYSpeedFactor:Ie,uvAnimationRotationSpeedFactor:fr};return mi(Q({},t),{pbrMetallicRoughness:{baseColorFactor:qi,baseColorTexture:Xi},normalTexture:$i,emissiveTexture:Ji,emissiveFactor:Zi,alphaMode:ji,alphaCutoff:Gi,doubleSided:Qi,extensions:{VRMC_materials_mtoon:gr}})}_parseV0UnlitProperties(e,t){var n,i,r,o,l;let a=e.shader==="VRM/UnlitTransparentZWrite",s=e.shader==="VRM/UnlitTransparent"||a,u=this._v0ParseRenderQueue(e),d=e.shader==="VRM/UnlitCutout",c=s?"BLEND":d?"MASK":"OPAQUE",f=d?(i=(n=e.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,m=this._portTextureTransform(e),p=((o=(r=e.vectorProperties)==null?void 0:r._Color)!=null?o:[1,1,1,1]).map(ge),h=(l=e.textureProperties)==null?void 0:l._MainTex,g=h!=null?{index:h,extensions:Q({},m)}:void 0,_={specVersion:"1.0",transparentWithZWrite:a,renderQueueOffsetNumber:u,shadeColorFactor:p,shadeMultiplyTexture:g};return mi(Q({},t),{pbrMetallicRoughness:{baseColorFactor:p,baseColorTexture:g},alphaMode:c,alphaCutoff:f,extensions:{VRMC_materials_mtoon:_}})}_portTextureTransform(e){var t,n,i,r,o;let l=(t=e.vectorProperties)==null?void 0:t._MainTex;if(l==null)return{};let a=[(n=l==null?void 0:l[0])!=null?n:0,(i=l==null?void 0:l[1])!=null?i:0],s=[(r=l==null?void 0:l[2])!=null?r:1,(o=l==null?void 0:l[3])!=null?o:1];return a[1]=1-s[1]-a[1],{KHR_texture_transform:{offset:a,scale:s}}}_v0ParseRenderQueue(e){var t,n,i;let r=(n=(t=e.keywordMap)==null?void 0:t._ALPHABLEND_ON)!=null?n:!1,o=((i=e.floatProperties)==null?void 0:i._ZWrite)===1,l=0;if(r){let a=e.renderQueue;a!=null&&(o?l=this._renderQueueMapTransparentZWrite.get(a):l=this._renderQueueMapTransparent.get(a))}return l}_populateRenderQueueMap(e){let t=new Set,n=new Set;e.forEach(i=>{var r,o,l;let a=(o=(r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null?o:!1,s=((l=i.floatProperties)==null?void 0:l._ZWrite)===1;if(a){let u=i.renderQueue;u!=null&&(s?n.add(u):t.add(u))}}),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.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(t).sort().forEach((i,r)=>{let o=Math.min(Math.max(r-t.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 D from"three";import*as q from"three";import*as Et from"three";import*as we from"three";import*as $ from"three";var gi=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())}),ie=new D.Vector3,vt=class extends D.Group{constructor(e){super(),this._attrPosition=new D.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(D.DynamicDrawUsage);let t=new D.BufferGeometry;t.setAttribute("position",this._attrPosition);let n=new D.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new D.Line(t,n),this.add(this._line),this.constraint=e}updateMatrixWorld(e){ie.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,ie.x,ie.y,ie.z),this.constraint.source&&ie.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,ie.x,ie.y,ie.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(e)}};function _i(e,t){return t.set(e.elements[12],e.elements[13],e.elements[14])}var ko=new Et.Vector3,zo=new Et.Vector3;function jo(e,t){return e.decompose(ko,t,zo),t}function ke(e){return e.invert?e.invert():e.inverse(),e}var Mt=class{constructor(e,t){this.destination=e,this.source=t,this.weight=1}},Go=new q.Vector3,Qo=new q.Vector3,qo=new q.Vector3,Xo=new q.Quaternion,Yo=new q.Quaternion,$o=new q.Quaternion,Zo=class extends Mt{get aimAxis(){return this._aimAxis}set aimAxis(e){this._aimAxis=e,this._v3AimAxis.set(e==="PositiveX"?1:e==="NegativeX"?-1:0,e==="PositiveY"?1:e==="NegativeY"?-1:0,e==="PositiveZ"?1:e==="NegativeZ"?-1:0)}get dependencies(){let e=new Set([this.source]);return this.destination.parent&&e.add(this.destination.parent),e}constructor(e,t){super(e,t),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 e=Xo.identity(),t=Yo.identity();this.destination.parent&&(jo(this.destination.parent.matrixWorld,e),ke(t.copy(e)));let n=Go.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(e),i=_i(this.source.matrixWorld,Qo).sub(_i(this.destination.matrixWorld,qo)).normalize(),r=$o.setFromUnitVectors(n,i).premultiply(t).multiply(e).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function Jo(e,t){let n=[e],i=e.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{t(r)})}var Ko=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(e){this._constraints.add(e);let t=this._objectConstraintsMap.get(e.destination);t==null&&(t=new Set,this._objectConstraintsMap.set(e.destination,t)),t.add(e)}deleteConstraint(e){this._constraints.delete(e),this._objectConstraintsMap.get(e.destination).delete(e)}setInitState(){let e=new Set,t=new Set;for(let n of this._constraints)this._processConstraint(n,e,t,i=>i.setInitState())}update(){let e=new Set,t=new Set;for(let n of this._constraints)this._processConstraint(n,e,t,i=>i.update())}_processConstraint(e,t,n,i){if(n.has(e))return;if(t.has(e))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");t.add(e);let r=e.dependencies;for(let o of r)Jo(o,l=>{let a=this._objectConstraintsMap.get(l);if(a)for(let s of a)this._processConstraint(s,t,n,i)});i(e),n.add(e)}},es=new we.Quaternion,ts=new we.Quaternion,ns=class extends Mt{get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),this._dstRestQuat=new we.Quaternion,this._invSrcRestQuat=new we.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),ke(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let e=es.copy(this._invSrcRestQuat).multiply(this.source.quaternion),t=ts.copy(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(t,this.weight)}},is=new $.Vector3,rs=new $.Quaternion,os=new $.Quaternion,ss=class extends Mt{get rollAxis(){return this._rollAxis}set rollAxis(e){this._rollAxis=e,this._v3RollAxis.set(e==="X"?1:0,e==="Y"?1:0,e==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(e,t){super(e,t),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),ke(this._invDstRestQuat.copy(this._dstRestQuat)),ke(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let e=rs.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),t=is.copy(this._v3RollAxis).applyQuaternion(e),i=os.setFromUnitVectors(t,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(e);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},as=new Set(["1.0","1.0-beta"]),vi=class Pe{get name(){return Pe.EXTENSION_NAME}constructor(t,n){this.parser=t,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(t){return gi(this,null,function*(){t.userData.vrmNodeConstraintManager=yield this._import(t)})}_import(t){return gi(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(Pe.EXTENSION_NAME))!==-1))return null;let o=new Ko,l=yield this.parser.getDependencies("node");return l.forEach((a,s)=>{var u;let d=i.nodes[s],c=(u=d==null?void 0:d.extensions)==null?void 0:u[Pe.EXTENSION_NAME];if(c==null)return;let f=c.specVersion;if(!as.has(f)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${Pe.EXTENSION_NAME} specVersion "${f}"`);return}let m=c.constraint;if(m.roll!=null){let p=this._importRollConstraint(a,l,m.roll);o.addConstraint(p)}else if(m.aim!=null){let p=this._importAimConstraint(a,l,m.aim);o.addConstraint(p)}else if(m.rotation!=null){let p=this._importRotationConstraint(a,l,m.rotation);o.addConstraint(p)}}),t.scene.updateMatrixWorld(),o.setInitState(),o})}_importRollConstraint(t,n,i){let{source:r,rollAxis:o,weight:l}=i,a=n[r],s=new ss(t,a);if(o!=null&&(s.rollAxis=o),l!=null&&(s.weight=l),this.helperRoot){let u=new vt(s);this.helperRoot.add(u)}return s}_importAimConstraint(t,n,i){let{source:r,aimAxis:o,weight:l}=i,a=n[r],s=new Zo(t,a);if(o!=null&&(s.aimAxis=o),l!=null&&(s.weight=l),this.helperRoot){let u=new vt(s);this.helperRoot.add(u)}return s}_importRotationConstraint(t,n,i){let{source:r,weight:o}=i,l=n[r],a=new ns(t,l);if(o!=null&&(a.weight=o),this.helperRoot){let s=new vt(a);this.helperRoot.add(s)}return a}};vi.EXTENSION_NAME="VRMC_node_constraint";var Ei=vi;import*as re from"three";import*as He from"three";import*as wi from"three";import*as J from"three";import*as ce from"three";import*as oe from"three";import*as me from"three";import*as Ai from"three";import*as C from"three";import*as Ni from"three";import*as Vi from"three";import*as he from"three";var ze=(e,t,n)=>new Promise((i,r)=>{var o=s=>{try{a(n.next(s))}catch(u){r(u)}},l=s=>{try{a(n.throw(s))}catch(u){r(u)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,l);a((n=n.apply(e,t)).next())}),Si=class{},Rt=new He.Vector3,de=new He.Vector3,Pi=class extends Si{get type(){return"capsule"}constructor(e){var t,n,i;super(),this.offset=(t=e==null?void 0:e.offset)!=null?t:new He.Vector3(0,0,0),this.tail=(n=e==null?void 0:e.tail)!=null?n:new He.Vector3(0,0,0),this.radius=(i=e==null?void 0:e.radius)!=null?i:0}calculateCollision(e,t,n,i){Rt.copy(this.offset).applyMatrix4(e),de.copy(this.tail).applyMatrix4(e),de.sub(Rt);let r=de.lengthSq();i.copy(t).sub(Rt);let o=de.dot(i);o<=0||(r<=o||de.multiplyScalar(o/r),i.sub(de));let l=n+this.radius,a=i.length()-l;return i.normalize(),a}},Li=class extends Si{get type(){return"sphere"}constructor(e){var t,n;super(),this.offset=(t=e==null?void 0:e.offset)!=null?t:new wi.Vector3(0,0,0),this.radius=(n=e==null?void 0:e.radius)!=null?n:0}calculateCollision(e,t,n,i){i.copy(this.offset).applyMatrix4(e),i.negate().add(t);let r=n+this.radius,o=i.length()-r;return i.normalize(),o}},X=new J.Vector3,ls=class extends J.BufferGeometry{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new J.Vector3,this._currentTail=new J.Vector3,this._shape=e,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 e=!1,t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let n=X.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),e=!0),e&&this._buildPosition()}_buildPosition(){X.copy(this._currentTail).sub(this._currentOffset);let e=X.length()/this._currentRadius;for(let i=0;i<=16;i++){let r=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(r),-Math.cos(r),0),this._attrPos.setXYZ(17+i,e+Math.sin(r),Math.cos(r),0),this._attrPos.setXYZ(34+i,-Math.sin(r),0,-Math.cos(r)),this._attrPos.setXYZ(51+i,e+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,e,Math.sin(r),Math.cos(r))}let t=Math.atan2(X.y,Math.sqrt(X.x*X.x+X.z*X.z)),n=-Math.atan2(X.z,X.x);this.rotateZ(t),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 e=0;e<34;e++){let t=(e+1)%34;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(68+e*2,34+e,34+t)}for(let e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+t),this._attrIndex.setXY(200+e*2,100+e,100+t)}this._attrIndex.needsUpdate=!0}},us=class extends ce.BufferGeometry{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new ce.Vector3,this._shape=e,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 e=!1,t=this._shape.radius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}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 e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.needsUpdate=!0}},ds=new re.Vector3,Mi=class extends re.Group{constructor(e){if(super(),this.matrixAutoUpdate=!1,this.collider=e,this.collider.shape instanceof Li)this._geometry=new us(this.collider.shape);else if(this.collider.shape instanceof Pi)this._geometry=new ls(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let t=new re.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new re.LineSegments(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let t=this.matrix.elements;this._geometry.worldScale=ds.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},hs=class extends me.BufferGeometry{constructor(e){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new me.Vector3,this._springBone=e,this._attrPos=new me.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new me.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,t=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==t&&(this._currentRadius=t,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let t=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(t),Math.sin(t),0),this._attrPos.setXYZ(32+e,0,Math.cos(t),Math.sin(t)),this._attrPos.setXYZ(64+e,Math.sin(t),0,Math.cos(t))}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 e=0;e<32;e++){let t=(e+1)%32;this._attrIndex.setXY(e*2,e,t),this._attrIndex.setXY(64+e*2,32+e,32+t),this._attrIndex.setXY(128+e*2,64+e,64+t)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},cs=new oe.Vector3,ms=class extends oe.Group{constructor(e){super(),this.matrixAutoUpdate=!1,this.springBone=e,this._geometry=new hs(this.springBone);let t=new oe.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new oe.LineSegments(this._geometry,t),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(e){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let t=this.matrix.elements;this._geometry.worldScale=cs.set(t[0],t[1],t[2]).length(),this._geometry.update(),super.updateMatrixWorld(e)}},Ri=class extends Ai.Object3D{constructor(e){super(),this.shape=e}},ps=new Ni.Matrix4;function Hi(e){return e.invert?e.invert():e.getInverse(ps.copy(e)),e}var fs=class{constructor(e){this._inverseCache=new Vi.Matrix4,this._shouldUpdateInverse=!0,this.matrix=e;let t={set:(n,i,r)=>(this._shouldUpdateInverse=!0,n[i]=r,!0)};this._originalElements=e.elements,e.elements=new Proxy(e.elements,t)}get inverse(){return this._shouldUpdateInverse&&(this._inverseCache.copy(this.matrix),Hi(this._inverseCache),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},gs=new C.Matrix4,Z=new C.Vector3,Le=new C.Vector3,_s=new C.Vector3,_e=new C.Vector3,Ti=new C.Vector3,Ae=new C.Vector3,xi=new C.Quaternion,ve=new C.Matrix4,vs=new C.Matrix4,Es=class{constructor(e,t,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,l,a,s,u;this.bone=e,this.bone.matrixAutoUpdate=!1,this.child=t,this.settings={hitRadius:(r=n.hitRadius)!=null?r:0,stiffness:(o=n.stiffness)!=null?o:1,gravityPower:(l=n.gravityPower)!=null?l:0,gravityDir:(s=(a=n.gravityDir)==null?void 0:a.clone())!=null?s:new C.Vector3(0,-1,0),dragForce:(u=n.dragForce)!=null?u:.4},this.colliderGroups=i}get center(){return this._center}set center(e){var t;(t=this._center)!=null&&t.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=e,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new fs(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:gs}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 e=this._getMatrixWorldToCenter(ve);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),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 e=this._getMatrixWorldToCenter(ve);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(e),this._prevTail.copy(this._currentTail)}update(e){if(e<=0)return;this._calcWorldSpaceBoneLength(),_e.setFromMatrixPosition(this.bone.matrixWorld);let t=this._getMatrixWorldToCenter(ve);Ti.copy(_e).applyMatrix4(t);let n=xi.setFromRotationMatrix(t),i=vs.copy(t).multiply(this._parentMatrixWorld),r=Le.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(i).sub(Ti).normalize(),o=_s.copy(this.settings.gravityDir).applyQuaternion(n).normalize(),l=this._getMatrixCenterToWorld(ve);Ae.copy(this._currentTail).add(Z.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.settings.dragForce)).add(Z.copy(r).multiplyScalar(this.settings.stiffness*e)).add(Z.copy(o).multiplyScalar(this.settings.gravityPower*e)).applyMatrix4(l),Ae.sub(_e).normalize().multiplyScalar(this._worldSpaceBoneLength).add(_e),this._collision(Ae),t=this._getMatrixWorldToCenter(ve),this._prevTail.copy(this._currentTail),this._currentTail.copy(Z.copy(Ae).applyMatrix4(t));let a=Hi(ve.copy(this._parentMatrixWorld).multiply(this._initialLocalMatrix)),s=xi.setFromUnitVectors(this._boneAxis,Z.copy(Ae).applyMatrix4(a).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(s),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(e){this.colliderGroups.forEach(t=>{t.colliders.forEach(n=>{let i=n.shape.calculateCollision(n.matrixWorld,e,this.settings.hitRadius,Z);i<0&&(e.add(Z.multiplyScalar(-i)),e.sub(_e).normalize().multiplyScalar(this._worldSpaceBoneLength).add(_e))})})}_calcWorldSpaceBoneLength(){Z.setFromMatrixPosition(this.bone.matrixWorld),this.child?Le.setFromMatrixPosition(this.child.matrixWorld):(Le.copy(this._initialLocalChildPosition),Le.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Z.sub(Le).length()}_getMatrixCenterToWorld(e){return this._center?e.copy(this._center.matrixWorld):e.identity(),e}_getMatrixWorldToCenter(e){return this._center?e.copy(this._center.userData.inverseCacheProxy.inverse):e.identity(),e}};function Ms(e,t){let n=[],i=e;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{t(r)})}function bi(e,t){e.children.forEach(n=>{t(n)||bi(n,t)})}var yi=class{constructor(){this._joints=new Set,this._objectSpringBonesMap=new Map}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let e=new Set;return this._joints.forEach(t=>{t.colliderGroups.forEach(n=>{e.add(n)})}),Array.from(e)}get colliders(){let e=new Set;return this.colliderGroups.forEach(t=>{t.colliders.forEach(n=>{e.add(n)})}),Array.from(e)}addJoint(e){this._joints.add(e);let t=this._objectSpringBonesMap.get(e.bone);t==null&&(t=new Set,this._objectSpringBonesMap.set(e.bone,t)),t.add(e)}addSpringBone(e){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(e)}deleteJoint(e){this._joints.delete(e),this._objectSpringBonesMap.get(e.bone).delete(e)}deleteSpringBone(e){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(e)}setInitState(){let e=new Set,t=new Set,n=new Set;for(let i of this._joints)this._processSpringBone(i,e,t,n,r=>r.setInitState())}reset(){let e=new Set,t=new Set,n=new Set;for(let i of this._joints)this._processSpringBone(i,e,t,n,r=>r.reset())}update(e){let t=new Set,n=new Set,i=new Set;for(let r of this._joints)this._processSpringBone(r,t,n,i,o=>o.update(e)),bi(r.bone,o=>{var l,a;return((a=(l=this._objectSpringBonesMap.get(o))==null?void 0:l.size)!=null?a:0)>0?!0:(o.updateWorldMatrix(!1,!1),!1)})}_processSpringBone(e,t,n,i,r){if(n.has(e))return;if(t.has(e))throw new Error("VRMSpringBoneManager: Circular dependency detected while updating springbones");t.add(e);let o=this._getDependencies(e);for(let l of o)Ms(l,a=>{let s=this._objectSpringBonesMap.get(a);if(s)for(let u of s)this._processSpringBone(u,t,n,i,r);else i.has(a)||(a.updateWorldMatrix(!1,!1),i.add(a))});e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),r(e),i.add(e.bone),n.add(e)}_getDependencies(e){let t=new Set,n=e.bone.parent;return n&&t.add(n),e.colliderGroups.forEach(i=>{i.colliders.forEach(r=>{t.add(r)})}),t}},Rs=new Set(["1.0","1.0-beta"]),Ii=class Ne{get name(){return Ne.EXTENSION_NAME}constructor(t,n){this.parser=t,this.jointHelperRoot=n==null?void 0:n.jointHelperRoot,this.colliderHelperRoot=n==null?void 0:n.colliderHelperRoot}afterRoot(t){return ze(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return ze(this,null,function*(){let n=yield this._v1Import(t);if(n!=null)return n;let i=yield this._v0Import(t);return i!=null?i:null})}_v1Import(t){return ze(this,null,function*(){var n,i,r,o,l;let a=t.parser.json;if(!(((n=a.extensionsUsed)==null?void 0:n.indexOf(Ne.EXTENSION_NAME))!==-1))return null;let u=new yi,d=yield t.parser.getDependencies("node"),c=(i=a.extensions)==null?void 0:i[Ne.EXTENSION_NAME];if(!c)return null;let f=c.specVersion;if(!Rs.has(f))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ne.EXTENSION_NAME} specVersion "${f}"`),null;let m=(r=c.colliders)==null?void 0:r.map((h,g)=>{var _,R,E,v,x;let M=d[h.node],T=h.shape;if(T.sphere)return this._importSphereCollider(M,{offset:new he.Vector3().fromArray((_=T.sphere.offset)!=null?_:[0,0,0]),radius:(R=T.sphere.radius)!=null?R:0});if(T.capsule)return this._importCapsuleCollider(M,{offset:new he.Vector3().fromArray((E=T.capsule.offset)!=null?E:[0,0,0]),radius:(v=T.capsule.radius)!=null?v:0,tail:new he.Vector3().fromArray((x=T.capsule.tail)!=null?x:[0,0,0])});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${g} has no valid shape`)}),p=(o=c.colliderGroups)==null?void 0:o.map((h,g)=>{var _;return{colliders:((_=h.colliders)!=null?_:[]).map(E=>{let v=m==null?void 0:m[E];if(v==null)throw new Error(`VRMSpringBoneLoaderPlugin: The colliderGroup #${g} attempted to use a collider #${E} but not found`);return v}),name:h.name}});return(l=c.springs)==null||l.forEach((h,g)=>{var _;let R=h.joints,E=(_=h.colliderGroups)==null?void 0:_.map(M=>{let T=p==null?void 0:p[M];if(T==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${g} attempted to use a colliderGroup ${M} but not found`);return T}),v=h.center!=null?d[h.center]:void 0,x;R.forEach(M=>{if(x){let T=x.node,H=d[T],U=M.node,V=d[U],I={hitRadius:x.hitRadius,dragForce:x.dragForce,gravityPower:x.gravityPower,stiffness:x.stiffness,gravityDir:x.gravityDir!=null?new he.Vector3().fromArray(x.gravityDir):void 0},j=this._importJoint(H,V,I,E);v&&(j.center=v),u.addJoint(j)}x=M})}),u.setInitState(),u})}_v0Import(t){return ze(this,null,function*(){var n,i,r;let o=t.parser.json;if(!(((n=o.extensionsUsed)==null?void 0:n.indexOf("VRM"))!==-1))return null;let a=(i=o.extensions)==null?void 0:i.VRM,s=a==null?void 0:a.secondaryAnimation;if(!s)return null;let u=s==null?void 0:s.boneGroups;if(!u)return null;let d=new yi,c=yield t.parser.getDependencies("node"),f=(r=s.colliderGroups)==null?void 0:r.map(m=>{var p;let h=c[m.node];return{colliders:((p=m.colliders)!=null?p:[]).map((_,R)=>{var E,v,x;let M=new he.Vector3(0,0,0);return _.offset&&M.set((E=_.offset.x)!=null?E:0,(v=_.offset.y)!=null?v:0,_.offset.z?-_.offset.z:0),this._importSphereCollider(h,{offset:M,radius:(x=_.radius)!=null?x:0})})}});return u==null||u.forEach((m,p)=>{let h=m.bones;h&&h.forEach(g=>{var _,R,E,v;let x=c[g],M=new he.Vector3;m.gravityDir?M.set((_=m.gravityDir.x)!=null?_:0,(R=m.gravityDir.y)!=null?R:0,(E=m.gravityDir.z)!=null?E:0):M.set(0,-1,0);let T=m.center!=null?c[m.center]:void 0,H={hitRadius:m.hitRadius,dragForce:m.dragForce,gravityPower:m.gravityPower,stiffness:m.stiffiness,gravityDir:M},U=(v=m.colliderGroups)==null?void 0:v.map(V=>{let I=f==null?void 0:f[V];if(I==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${p} attempted to use a colliderGroup ${V} but not found`);return I});x.traverse(V=>{var I;let j=(I=V.children[0])!=null?I:null,Me=this._importJoint(V,j,H,U);T&&(Me.center=T),d.addJoint(Me)})})}),t.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(t,n,i,r){let o=new Es(t,n,i,r);if(this.jointHelperRoot){let l=new ms(o);this.jointHelperRoot.add(l),l.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(t,n){let{offset:i,radius:r}=n,o=new Li({offset:i,radius:r}),l=new Ri(o);if(t.add(l),this.colliderHelperRoot){let a=new Mi(l);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return l}_importCapsuleCollider(t,n){let{offset:i,radius:r,tail:o}=n,l=new Pi({offset:i,radius:r,tail:o}),a=new Ri(l);if(t.add(a),this.colliderHelperRoot){let s=new Mi(a);this.colliderHelperRoot.add(s),s.renderOrder=this.colliderHelperRoot.renderOrder}return a}};Ii.EXTENSION_NAME="VRMC_springBone";var Ci=Ii;var Tt=class{get name(){return"VRMLoaderPlugin"}constructor(t,n){var o,l,a,s,u,d,c,f,m,p;this.parser=t;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 it(t),this.firstPersonPlugin=(l=n==null?void 0:n.firstPersonPlugin)!=null?l:new ot(t),this.humanoidPlugin=(a=n==null?void 0:n.humanoidPlugin)!=null?a:new st(t,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(s=n==null?void 0:n.lookAtPlugin)!=null?s:new lt(t,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new ut(t),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new gt(t),this.materialsHDREmissiveMultiplierPlugin=(c=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?c:new di(t),this.materialsV0CompatPlugin=(f=n==null?void 0:n.materialsV0CompatPlugin)!=null?f:new fi(t),this.springBonePlugin=(m=n==null?void 0:n.springBonePlugin)!=null?m:new Ci(t,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(p=n==null?void 0:n.nodeConstraintPlugin)!=null?p:new Ei(t,{helperRoot:i})}beforeRoot(){return Re(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(t){return Re(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(t)})}getMaterialType(t){let n=this.mtoonMaterialPlugin.getMaterialType(t);return n!=null?n:null}extendMaterialParams(t,n){return Re(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(t,n),yield this.mtoonMaterialPlugin.extendMaterialParams(t,n)})}afterRoot(t){return Re(this,null,function*(){yield this.metaPlugin.afterRoot(t),yield this.humanoidPlugin.afterRoot(t),yield this.expressionPlugin.afterRoot(t),yield this.lookAtPlugin.afterRoot(t),yield this.firstPersonPlugin.afterRoot(t),yield this.springBonePlugin.afterRoot(t),yield this.nodeConstraintPlugin.afterRoot(t),yield this.mtoonMaterialPlugin.afterRoot(t);let n=t.userData.vrmMeta,i=t.userData.vrmHumanoid;if(n&&i){let r=new Se({scene:t.scene,expressionManager:t.userData.vrmExpressionManager,firstPerson:t.userData.vrmFirstPerson,humanoid:i,lookAt:t.userData.vrmLookAt,meta:n,materials:t.userData.vrmMToonMaterials,springBoneManager:t.userData.vrmSpringBoneManager,nodeConstraintManager:t.userData.vrmNodeConstraintManager});t.userData.vrm=r}})}};function Ui(e){if(Object.values(e).forEach(t=>{t!=null&&t.isTexture&&t.dispose()}),e.isShaderMaterial){let t=e.uniforms;t&&Object.values(t).forEach(n=>{let i=n.value;i!=null&&i.isTexture&&i.dispose()})}e.dispose()}function Ts(e){let t=e.geometry;t&&t.dispose();let n=e.skeleton;n&&n.dispose();let i=e.material;i&&(Array.isArray(i)?i.forEach(r=>Ui(r)):i&&Ui(i))}function Oi(e){e.traverse(Ts)}import*as je from"three";function Fi(e,t){var l;let n=(l=t==null?void 0:t.experimentalSameBoneCounts)!=null?l:!1,i=[];e.traverse(a=>{a.type==="SkinnedMesh"&&i.push(a)});let r=new Map,o=0;for(let a of i){let u=a.geometry.getAttribute("skinIndex"),d=[],c=[],f={},m=u.array;for(let p=0;p<m.length;p++){let h=m[p];f[h]==null&&(f[h]=d.length,d.push(a.skeleton.bones[h]),c.push(a.skeleton.boneInverses[h])),m[p]=f[h]}u.copyArray(m),u.needsUpdate=!0,r.set(a,{bones:d,boneInverses:c}),o=Math.max(o,d.length)}for(let a of i){let{bones:s,boneInverses:u}=r.get(a);if(n)for(let c=s.length;c<o;c++)s[c]=s[0],u[c]=u[0];let d=new je.Skeleton(s,u);a.bind(d,new je.Matrix4)}}import*as Di from"three";import{BufferAttribute as xt}from"three";function Bi(e){let t=new Map;e.traverse(n=>{var c,f,m,p;if(!n.isMesh)return;let i=n,r=i.geometry,o=r.index;if(o==null)return;let l=t.get(r);if(l!=null){i.geometry=l;return}let a=new Di.BufferGeometry;a.name=r.name,a.morphTargetsRelative=r.morphTargetsRelative,r.groups.forEach(h=>{a.addGroup(h.start,h.count,h.materialIndex)}),a.boundingBox=(f=(c=r.boundingBox)==null?void 0:c.clone())!=null?f:null,a.boundingSphere=(p=(m=r.boundingSphere)==null?void 0:m.clone())!=null?p:null,a.setDrawRange(r.drawRange.start,r.drawRange.count),a.userData=r.userData,t.set(r,a);let s=[],u=[];{let h=o.array,g=new h.constructor(h.length),_=0;for(let R=0;R<h.length;R++){let E=h[R],v=s[E];v==null&&(s[E]=_,u[_]=E,v=_,_++),g[R]=v}a.setIndex(new xt(g,1,!1))}Object.keys(r.attributes).forEach(h=>{let g=r.attributes[h];if(g.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let _=g.array,{itemSize:R,normalized:E}=g,v=new _.constructor(u.length*R);u.forEach((x,M)=>{for(let T=0;T<R;T++)v[M*R+T]=_[x*R+T]}),a.setAttribute(h,new xt(v,R,E))});let d=!0;Object.keys(r.morphAttributes).forEach(h=>{a.morphAttributes[h]=[];let g=r.morphAttributes[h];for(let _=0;_<g.length;_++){let R=g[_];if(R.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let E=R.array,{itemSize:v,normalized:x}=R,M=new E.constructor(u.length*v);u.forEach((T,H)=>{for(let U=0;U<v;U++)M[H*v+U]=E[T*v+U]}),d=d&&M.every(T=>T===0),a.morphAttributes[h][_]=new xt(M,v,x)}}),d&&(a.morphAttributes={}),i.geometry=a}),Array.from(t.keys()).forEach(n=>{n.dispose()})}function Wi(e){var t;((t=e.meta)==null?void 0:t.metaVersion)==="0"&&(e.scene.rotation.y=Math.PI)}var Ee=class{constructor(){}};Ee.deepDispose=Oi,Ee.removeUnnecessaryJoints=Fi,Ee.removeUnnecessaryVertices=Bi,Ee.rotateVRM0=Wi;export{Lo as MToonAnimatedUVNode,Vo as MToonLightingModel,eo as MToonMaterial,Jr as MToonMaterialDebugMode,gt as MToonMaterialLoaderPlugin,te as MToonMaterialOutlineWidthMode,Io as MToonNodeMaterial,Zs as MToonNodeMaterialLoaderPlugin,Se as VRM,Zo as VRMAimConstraint,dt as VRMCore,Hs as VRMCoreLoaderPlugin,un as VRMExpression,it as VRMExpressionLoaderPlugin,mn as VRMExpressionManager,pn as VRMExpressionMaterialColorBind,Te as VRMExpressionMaterialColorType,fn as VRMExpressionMorphTargetBind,ws as VRMExpressionOverrideType,Ze as VRMExpressionPresetName,_n as VRMExpressionTextureTransformBind,vn as VRMFirstPerson,ot as VRMFirstPersonLoaderPlugin,Ls as VRMFirstPersonMeshAnnotationType,qe as VRMHumanBoneList,As as VRMHumanBoneName,xr as VRMHumanBoneParentMap,xn as VRMHumanoid,Rn as VRMHumanoidHelper,st as VRMHumanoidLoaderPlugin,Tt as VRMLoaderPlugin,Dr as VRMLookAt,Fe as VRMLookAtBoneApplier,tt as VRMLookAtExpressionApplier,Hr as VRMLookAtHelper,lt as VRMLookAtLoaderPlugin,Vn as VRMLookAtRangeMap,Ns as VRMLookAtTypeName,ut as VRMMetaLoaderPlugin,Mt as VRMNodeConstraint,vt as VRMNodeConstraintHelper,Ei as VRMNodeConstraintLoaderPlugin,Ko as VRMNodeConstraintManager,Pr as VRMRequiredHumanBoneName,ss as VRMRollConstraint,ns as VRMRotationConstraint,Ri as VRMSpringBoneCollider,Mi as VRMSpringBoneColliderHelper,Si as VRMSpringBoneColliderShape,Pi as VRMSpringBoneColliderShapeCapsule,Li as VRMSpringBoneColliderShapeSphere,Es as VRMSpringBoneJoint,ms as VRMSpringBoneJointHelper,Ci as VRMSpringBoneLoaderPlugin,yi as VRMSpringBoneManager,Ee as VRMUtils};
|
|
929
|
+
`;n.vertexShader=r+n.vertexShader,n.fragmentShader=r+n.fragmentShader,i<154&&(n.fragmentShader=n.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>"))}}get color(){return this.uniforms.litFactor.value}set color(t){this.uniforms.litFactor.value=t}get map(){return this.uniforms.map.value}set map(t){this.uniforms.map.value=t}get normalMap(){return this.uniforms.normalMap.value}set normalMap(t){this.uniforms.normalMap.value=t}get normalScale(){return this.uniforms.normalScale.value}set normalScale(t){this.uniforms.normalScale.value=t}get emissive(){return this.uniforms.emissive.value}set emissive(t){this.uniforms.emissive.value=t}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(t){this.uniforms.emissiveIntensity.value=t}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(t){this.uniforms.emissiveMap.value=t}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(t){this.uniforms.shadeColorFactor.value=t}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(t){this.uniforms.shadeMultiplyTexture.value=t}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(t){this.uniforms.shadingShiftFactor.value=t}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(t){this.uniforms.shadingShiftTexture.value=t}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(t){this.uniforms.shadingShiftTextureScale.value=t}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(t){this.uniforms.shadingToonyFactor.value=t}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(t){this.uniforms.giEqualizationFactor.value=t}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(t){this.uniforms.matcapFactor.value=t}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(t){this.uniforms.matcapTexture.value=t}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(t){this.uniforms.parametricRimColorFactor.value=t}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(t){this.uniforms.rimMultiplyTexture.value=t}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(t){this.uniforms.rimLightingMixFactor.value=t}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(t){this.uniforms.parametricRimFresnelPowerFactor.value=t}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(t){this.uniforms.parametricRimLiftFactor.value=t}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(t){this.uniforms.outlineWidthMultiplyTexture.value=t}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(t){this.uniforms.outlineWidthFactor.value=t}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(t){this.uniforms.outlineColorFactor.value=t}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(t){this.uniforms.outlineLightingMixFactor.value=t}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(t){this.uniforms.uvAnimationMaskTexture.value=t}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(t){this.uniforms.uvAnimationScrollXOffset.value=t}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(t){this.uniforms.uvAnimationScrollYOffset.value=t}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(t){this.uniforms.uvAnimationRotationPhase.value=t}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(t){this._ignoreVertexColor=t,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(t){this._v0CompatShade=t,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(t){this._debugMode=t,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(t){this._outlineWidthMode=t,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(t){this._isOutline=t,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(t){this._uploadUniformsWorkaround(),this._updateUVAnimation(t)}copy(t){return super.copy(t),this.map=t.map,this.normalMap=t.normalMap,this.emissiveMap=t.emissiveMap,this.shadeMultiplyTexture=t.shadeMultiplyTexture,this.shadingShiftTexture=t.shadingShiftTexture,this.matcapTexture=t.matcapTexture,this.rimMultiplyTexture=t.rimMultiplyTexture,this.outlineWidthMultiplyTexture=t.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=t.uvAnimationMaskTexture,this.normalMapType=t.normalMapType,this.uvAnimationScrollXSpeedFactor=t.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=t.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=t.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=t.ignoreVertexColor,this.v0CompatShade=t.v0CompatShade,this.debugMode=t.debugMode,this.outlineWidthMode=t.outlineWidthMode,this.isOutline=t.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(t){this.uniforms.uvAnimationScrollXOffset.value+=t*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=t*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=t*this.uvAnimationRotationSpeedFactor,this.uniforms.alphaTest.value=this.alphaTest,this.uniformsNeedUpdate=!0}_uploadUniformsWorkaround(){this.uniforms.opacity.value=this.opacity,this._updateTextureMatrix(this.uniforms.map,this.uniforms.mapUvTransform),this._updateTextureMatrix(this.uniforms.normalMap,this.uniforms.normalMapUvTransform),this._updateTextureMatrix(this.uniforms.emissiveMap,this.uniforms.emissiveMapUvTransform),this._updateTextureMatrix(this.uniforms.shadeMultiplyTexture,this.uniforms.shadeMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.shadingShiftTexture,this.uniforms.shadingShiftTextureUvTransform),this._updateTextureMatrix(this.uniforms.matcapTexture,this.uniforms.matcapTextureUvTransform),this._updateTextureMatrix(this.uniforms.rimMultiplyTexture,this.uniforms.rimMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.outlineWidthMultiplyTexture,this.uniforms.outlineWidthMultiplyTextureUvTransform),this._updateTextureMatrix(this.uniforms.uvAnimationMaskTexture,this.uniforms.uvAnimationMaskTextureUvTransform),this.uniformsNeedUpdate=!0}_generateDefines(){let t=parseInt(w.REVISION,10),e=this.outlineWidthMultiplyTexture!==null,n=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:t,OUTLINE:this._isOutline,MTOON_USE_UV:e||n,MTOON_UVS_VERTEX_ONLY:e&&!n,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_WORLD:this._isOutline&&this._outlineWidthMode===it.WorldCoordinates,OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===it.ScreenCoordinates}}_updateTextureMatrix(t,e){t.value&&(t.value.matrixAutoUpdate&&t.value.updateMatrix(),e.value.copy(t.value.matrix))}},Nr=new Set(["1.0","1.0-beta"]),zn=class Ve{get name(){return Ve.EXTENSION_NAME}constructor(e,n={}){var i,r,s,a;this.parser=e,this.materialType=(i=n.materialType)!=null?i:Or,this.renderOrderOffset=(r=n.renderOrderOffset)!=null?r:0,this.v0CompatShade=(s=n.v0CompatShade)!=null?s:!1,this.debugMode=(a=n.debugMode)!=null?a:"none",this._mToonMaterialSet=new Set}beforeRoot(){return te(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return te(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 te(this,null,function*(){var n;let i=this.parser,s=(n=i.json.meshes)==null?void 0:n[e];if(s==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);let a=s.primitives,l=yield i.loadMesh(e);if(a.length===1){let o=l,u=a[0].material;u!=null&&this._setupPrimitive(o,u)}else{let o=l;for(let u=0;u<a.length;u++){let d=o.children[u],c=a[u].material;c!=null&&this._setupPrimitive(d,c)}}return l})}_removeUnlitExtensionIfMToonExists(){let i=this.parser.json.materials;i==null||i.map((r,s)=>{var a;this._getMToonExtension(s)&&((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[Ve.EXTENSION_NAME];if(l==null)return;let o=l.specVersion;if(!Nr.has(o)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${Ve.EXTENSION_NAME} specVersion "${o}"`);return}return l}_extendMaterialParams(e,n){return te(this,null,function*(){var i;delete n.metalness,delete n.roughness;let r=new br(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 Ie.Material)||!this._shouldGenerateOutline(n))return;e.material=[n];let i=n.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=Ie.BackSide,e.material.push(i);let r=e.geometry,s=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,s,0),r.addGroup(0,s,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)}};zn.EXTENSION_NAME="VRMC_materials_mtoon";var jn=zn;var Dr=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())}),Gn=class ot{get name(){return ot.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,n){return Dr(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[ot.EXTENSION_NAME];if(l!=null)return l}};Gn.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var Qn=Gn;import*as $n from"three";var Br=Object.defineProperty,Fr=Object.defineProperties,Wr=Object.getOwnPropertyDescriptors,qn=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,zr=Object.prototype.propertyIsEnumerable,Xn=(t,e,n)=>e in t?Br(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,F=(t,e)=>{for(var n in e||(e={}))kr.call(e,n)&&Xn(t,n,e[n]);if(qn)for(var n of qn(e))zr.call(e,n)&&Xn(t,n,e[n]);return t},Yn=(t,e)=>Fr(t,Wr(e)),jr=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())});function le(t){return Math.pow(t,2.2)}var Zn=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 jr(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,s)=>{var a,l;let o=(a=e.materials)==null?void 0:a[s];if(o==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${s}] of glTF but the material doesn't exist`);return}if(r.shader==="VRM/MToon"){let u=this._parseV0MToonProperties(r,o);e.materials[s]=u}else if((l=r.shader)!=null&&l.startsWith("VRM/Unlit")){let u=this._parseV0UnlitProperties(r,o);e.materials[s]=u}else r.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${r.shader}`)}))})}_parseV0MToonProperties(t,e){var n,i,r,s,a,l,o,u,d,c,f,p,m,h,_,g,x,T,v,R,E,M,A,I,L,H,U,ce,ct,pt,mt,ft,_t,gt,vt,Et,Mt,Rt,Tt,xt,yt,wt,Pt,St,At,Lt,Ht,bt,Vt,It,Ut,Ct,Ot,Nt,Dt;let Bt=(i=(n=t.keywordMap)==null?void 0:n._ALPHABLEND_ON)!=null?i:!1,yi=((r=t.floatProperties)==null?void 0:r._ZWrite)===1&&Bt,wi=this._v0ParseRenderQueue(t),Ft=(a=(s=t.keywordMap)==null?void 0:s._ALPHATEST_ON)!=null?a:!1,Pi=Bt?"BLEND":Ft?"MASK":"OPAQUE",Si=Ft?(o=(l=t.floatProperties)==null?void 0:l._Cutoff)!=null?o:.5:void 0,Ai=((d=(u=t.floatProperties)==null?void 0:u._CullMode)!=null?d:2)===0,J=this._portTextureTransform(t),Li=((f=(c=t.vectorProperties)==null?void 0:c._Color)!=null?f:[1,1,1,1]).map((Yt,Ki)=>Ki===3?Yt:le(Yt)),Wt=(p=t.textureProperties)==null?void 0:p._MainTex,Hi=Wt!=null?{index:Wt,extensions:F({},J)}:void 0,bi=(h=(m=t.floatProperties)==null?void 0:m._BumpScale)!=null?h:1,kt=(_=t.textureProperties)==null?void 0:_._BumpMap,Vi=kt!=null?{index:kt,scale:bi,extensions:F({},J)}:void 0,Ii=((x=(g=t.vectorProperties)==null?void 0:g._EmissionColor)!=null?x:[0,0,0,1]).map(le),zt=(T=t.textureProperties)==null?void 0:T._EmissionMap,Ui=zt!=null?{index:zt,extensions:F({},J)}:void 0,Ci=((R=(v=t.vectorProperties)==null?void 0:v._ShadeColor)!=null?R:[.97,.81,.86,1]).map(le),jt=(E=t.textureProperties)==null?void 0:E._ShadeTexture,Oi=jt!=null?{index:jt,extensions:F({},J)}:void 0,ye=(A=(M=t.floatProperties)==null?void 0:M._ShadeShift)!=null?A:0,we=(L=(I=t.floatProperties)==null?void 0:I._ShadeToony)!=null?L:.9;we=$n.MathUtils.lerp(we,1,.5+.5*ye),ye=-ye-(1-we);let Gt=(U=(H=t.floatProperties)==null?void 0:H._IndirectLightIntensity)!=null?U:.1,Ni=Gt?1-Gt:void 0,Ne=(ce=t.textureProperties)==null?void 0:ce._SphereAdd,Di=Ne!=null?[1,1,1]:void 0,Bi=Ne!=null?{index:Ne}:void 0,Fi=(pt=(ct=t.floatProperties)==null?void 0:ct._RimLightingMix)!=null?pt:0,Qt=(mt=t.textureProperties)==null?void 0:mt._RimTexture,Wi=Qt!=null?{index:Qt,extensions:F({},J)}:void 0,ki=((_t=(ft=t.vectorProperties)==null?void 0:ft._RimColor)!=null?_t:[0,0,0,1]).map(le),zi=(vt=(gt=t.floatProperties)==null?void 0:gt._RimFresnelPower)!=null?vt:1,ji=(Mt=(Et=t.floatProperties)==null?void 0:Et._RimLift)!=null?Mt:0,Gi=["none","worldCoordinates","screenCoordinates"][(Tt=(Rt=t.floatProperties)==null?void 0:Rt._OutlineWidthMode)!=null?Tt:0],De=(yt=(xt=t.floatProperties)==null?void 0:xt._OutlineWidth)!=null?yt:0;De=.01*De;let qt=(wt=t.textureProperties)==null?void 0:wt._OutlineWidthTexture,Qi=qt!=null?{index:qt,extensions:F({},J)}:void 0,qi=((St=(Pt=t.vectorProperties)==null?void 0:Pt._OutlineColor)!=null?St:[0,0,0]).map(le),Xi=((Lt=(At=t.floatProperties)==null?void 0:At._OutlineColorMode)!=null?Lt:0)===1?(bt=(Ht=t.floatProperties)==null?void 0:Ht._OutlineLightingMix)!=null?bt:1:0,Xt=(Vt=t.textureProperties)==null?void 0:Vt._UvAnimMaskTexture,Yi=Xt!=null?{index:Xt,extensions:F({},J)}:void 0,$i=(Ut=(It=t.floatProperties)==null?void 0:It._UvAnimScrollX)!=null?Ut:0,Pe=(Ot=(Ct=t.floatProperties)==null?void 0:Ct._UvAnimScrollY)!=null?Ot:0;Pe!=null&&(Pe=-Pe);let Zi=(Dt=(Nt=t.floatProperties)==null?void 0:Nt._UvAnimRotation)!=null?Dt:0,Ji={specVersion:"1.0",transparentWithZWrite:yi,renderQueueOffsetNumber:wi,shadeColorFactor:Ci,shadeMultiplyTexture:Oi,shadingShiftFactor:ye,shadingToonyFactor:we,giEqualizationFactor:Ni,matcapFactor:Di,matcapTexture:Bi,rimLightingMixFactor:Fi,rimMultiplyTexture:Wi,parametricRimColorFactor:ki,parametricRimFresnelPowerFactor:zi,parametricRimLiftFactor:ji,outlineWidthMode:Gi,outlineWidthFactor:De,outlineWidthMultiplyTexture:Qi,outlineColorFactor:qi,outlineLightingMixFactor:Xi,uvAnimationMaskTexture:Yi,uvAnimationScrollXSpeedFactor:$i,uvAnimationScrollYSpeedFactor:Pe,uvAnimationRotationSpeedFactor:Zi};return Yn(F({},e),{pbrMetallicRoughness:{baseColorFactor:Li,baseColorTexture:Hi},normalTexture:Vi,emissiveTexture:Ui,emissiveFactor:Ii,alphaMode:Pi,alphaCutoff:Si,doubleSided:Ai,extensions:{VRMC_materials_mtoon:Ji}})}_parseV0UnlitProperties(t,e){var n,i,r,s,a;let l=t.shader==="VRM/UnlitTransparentZWrite",o=t.shader==="VRM/UnlitTransparent"||l,u=this._v0ParseRenderQueue(t),d=t.shader==="VRM/UnlitCutout",c=o?"BLEND":d?"MASK":"OPAQUE",f=d?(i=(n=t.floatProperties)==null?void 0:n._Cutoff)!=null?i:.5:void 0,p=this._portTextureTransform(t),m=((s=(r=t.vectorProperties)==null?void 0:r._Color)!=null?s:[1,1,1,1]).map(le),h=(a=t.textureProperties)==null?void 0:a._MainTex,_=h!=null?{index:h,extensions:F({},p)}:void 0,g={specVersion:"1.0",transparentWithZWrite:l,renderQueueOffsetNumber:u,shadeColorFactor:m,shadeMultiplyTexture:_};return Yn(F({},e),{pbrMetallicRoughness:{baseColorFactor:m,baseColorTexture:_},alphaMode:c,alphaCutoff:f,extensions:{VRMC_materials_mtoon:g}})}_portTextureTransform(t){var e,n,i,r,s;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],o=[(r=a==null?void 0:a[2])!=null?r:1,(s=a==null?void 0:a[3])!=null?s:1];return l[1]=1-o[1]-l[1],{KHR_texture_transform:{offset:l,scale:o}}}_v0ParseRenderQueue(t){var e,n,i;let r=(n=(e=t.keywordMap)==null?void 0:e._ALPHABLEND_ON)!=null?n:!1,s=((i=t.floatProperties)==null?void 0:i._ZWrite)===1,a=0;if(r){let l=t.renderQueue;l!=null&&(s?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,s,a;let l=(s=(r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null?s:!1,o=((a=i.floatProperties)==null?void 0:a._ZWrite)===1;if(l){let u=i.renderQueue;u!=null&&(o?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 s=Math.min(Math.max(r-e.size+1,-9),0);this._renderQueueMapTransparent.set(i,s)}),Array.from(n).sort().forEach((i,r)=>{let s=Math.min(Math.max(r,0),9);this._renderQueueMapTransparentZWrite.set(i,s)})}};import*as C from"three";import*as W from"three";import*as at from"three";import*as Ee from"three";import*as j from"three";var Jn=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())}),Y=new C.Vector3,st=class extends C.Group{constructor(t){super(),this._attrPosition=new C.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(C.DynamicDrawUsage);let e=new C.BufferGeometry;e.setAttribute("position",this._attrPosition);let n=new C.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new C.Line(e,n),this.add(this._line),this.constraint=t}updateMatrixWorld(t){Y.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,Y.x,Y.y,Y.z),this.constraint.source&&Y.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,Y.x,Y.y,Y.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};function Kn(t,e){return e.set(t.elements[12],t.elements[13],t.elements[14])}var Gr=new at.Vector3,Qr=new at.Vector3;function qr(t,e){return t.decompose(Gr,e,Qr),e}function Ue(t){return t.invert?t.invert():t.inverse(),t}var lt=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}},Xr=new W.Vector3,Yr=new W.Vector3,$r=new W.Vector3,Zr=new W.Quaternion,Jr=new W.Quaternion,Kr=new W.Quaternion,eo=class extends lt{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 W.Vector3(1,0,0),this._dstRestQuat=new W.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=Zr.identity(),e=Jr.identity();this.destination.parent&&(qr(this.destination.parent.matrixWorld,t),Ue(e.copy(t)));let n=Xr.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=Kn(this.source.matrixWorld,Yr).sub(Kn(this.destination.matrixWorld,$r)).normalize(),r=Kr.setFromUnitVectors(n,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function to(t,e){let n=[t],i=t.parent;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}var no=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 s of r)to(s,a=>{let l=this._objectConstraintsMap.get(a);if(l)for(let o of l)this._processConstraint(o,e,n,i)});i(t),n.add(t)}},io=new Ee.Quaternion,ro=new Ee.Quaternion,oo=class extends lt{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new Ee.Quaternion,this._invSrcRestQuat=new Ee.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Ue(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=io.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=ro.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},so=new j.Vector3,ao=new j.Quaternion,lo=new j.Quaternion,uo=class extends lt{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 j.Vector3(1,0,0),this._dstRestQuat=new j.Quaternion,this._invDstRestQuat=new j.Quaternion,this._invSrcRestQuatMulDstRestQuat=new j.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),Ue(this._invDstRestQuat.copy(this._dstRestQuat)),Ue(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=ao.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=so.copy(this._v3RollAxis).applyQuaternion(t),i=lo.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},ho=new Set(["1.0","1.0-beta"]),ei=class ve{get name(){return ve.EXTENSION_NAME}constructor(e,n){this.parser=e,this.helperRoot=n==null?void 0:n.helperRoot}afterRoot(e){return Jn(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return Jn(this,null,function*(){var n;let i=this.parser.json;if(!(((n=i.extensionsUsed)==null?void 0:n.indexOf(ve.EXTENSION_NAME))!==-1))return null;let s=new no,a=yield this.parser.getDependencies("node");return a.forEach((l,o)=>{var u;let d=i.nodes[o],c=(u=d==null?void 0:d.extensions)==null?void 0:u[ve.EXTENSION_NAME];if(c==null)return;let f=c.specVersion;if(!ho.has(f)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${ve.EXTENSION_NAME} specVersion "${f}"`);return}let p=c.constraint;if(p.roll!=null){let m=this._importRollConstraint(l,a,p.roll);s.addConstraint(m)}else if(p.aim!=null){let m=this._importAimConstraint(l,a,p.aim);s.addConstraint(m)}else if(p.rotation!=null){let m=this._importRotationConstraint(l,a,p.rotation);s.addConstraint(m)}}),e.scene.updateMatrixWorld(),s.setInitState(),s})}_importRollConstraint(e,n,i){let{source:r,rollAxis:s,weight:a}=i,l=n[r],o=new uo(e,l);if(s!=null&&(o.rollAxis=s),a!=null&&(o.weight=a),this.helperRoot){let u=new st(o);this.helperRoot.add(u)}return o}_importAimConstraint(e,n,i){let{source:r,aimAxis:s,weight:a}=i,l=n[r],o=new eo(e,l);if(s!=null&&(o.aimAxis=s),a!=null&&(o.weight=a),this.helperRoot){let u=new st(o);this.helperRoot.add(u)}return o}_importRotationConstraint(e,n,i){let{source:r,weight:s}=i,a=n[r],l=new oo(e,a);if(s!=null&&(l.weight=s),this.helperRoot){let o=new st(l);this.helperRoot.add(o)}return l}};ei.EXTENSION_NAME="VRMC_node_constraint";var ti=ei;import*as $ from"three";import*as xe from"three";import*as ui from"three";import*as Q from"three";import*as re from"three";import*as Z from"three";import*as oe from"three";import*as hi from"three";import*as V from"three";import*as ci from"three";import*as mi from"three";import*as ie from"three";var Ce=(t,e,n)=>new Promise((i,r)=>{var s=o=>{try{l(n.next(o))}catch(u){r(u)}},a=o=>{try{l(n.throw(o))}catch(u){r(u)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);l((n=n.apply(t,e)).next())}),ai=class{},ut=new xe.Vector3,ne=new xe.Vector3,li=class extends ai{get type(){return"capsule"}constructor(t){var e,n,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new xe.Vector3(0,0,0),this.tail=(n=t==null?void 0:t.tail)!=null?n:new xe.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0}calculateCollision(t,e,n,i){ut.copy(this.offset).applyMatrix4(t),ne.copy(this.tail).applyMatrix4(t),ne.sub(ut);let r=ne.lengthSq();i.copy(e).sub(ut);let s=ne.dot(i);s<=0||(r<=s||ne.multiplyScalar(s/r),i.sub(ne));let a=n+this.radius,l=i.length()-a;return i.normalize(),l}},di=class extends ai{get type(){return"sphere"}constructor(t){var e,n;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ui.Vector3(0,0,0),this.radius=(n=t==null?void 0:t.radius)!=null?n:0}calculateCollision(t,e,n,i){i.copy(this.offset).applyMatrix4(t),i.negate().add(e);let r=n+this.radius,s=i.length()-r;return i.normalize(),s}},k=new Q.Vector3,co=class extends Q.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new Q.Vector3,this._currentTail=new Q.Vector3,this._shape=t,this._attrPos=new Q.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Q.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=k.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(n)>1e-10&&(this._currentTail.copy(n),t=!0),t&&this._buildPosition()}_buildPosition(){k.copy(this._currentTail).sub(this._currentOffset);let t=k.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(k.y,Math.sqrt(k.x*k.x+k.z*k.z)),n=-Math.atan2(k.z,k.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 re.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new re.Vector3,this._shape=t,this._attrPos=new re.BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new re.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}},mo=new $.Vector3,ni=class extends $.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof di)this._geometry=new po(this.collider.shape);else if(this.collider.shape instanceof li)this._geometry=new co(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new $.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new $.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=mo.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},fo=class extends oe.BufferGeometry{constructor(t){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new oe.Vector3,this._springBone=t,this._attrPos=new oe.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new oe.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}},_o=new Z.Vector3,go=class extends Z.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new fo(this.springBone);let e=new Z.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new Z.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=_o.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}},ii=class extends hi.Object3D{constructor(t){super(),this.shape=t}},vo=new ci.Matrix4;function pi(t){return t.invert?t.invert():t.getInverse(vo.copy(t)),t}var Eo=class{constructor(t){this._inverseCache=new mi.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&&(pi(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},Mo=new V.Matrix4,G=new V.Vector3,Me=new V.Vector3,Ro=new V.Vector3,ue=new V.Vector3,ri=new V.Vector3,Re=new V.Vector3,oi=new V.Quaternion,de=new V.Matrix4,To=new V.Matrix4,xo=class{constructor(t,e,n={},i=[]){this._currentTail=new V.Vector3,this._prevTail=new V.Vector3,this._boneAxis=new V.Vector3,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new V.Matrix4,this._initialLocalRotation=new V.Quaternion,this._initialLocalChildPosition=new V.Vector3;var r,s,a,l,o,u;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(r=n.hitRadius)!=null?r:0,stiffness:(s=n.stiffness)!=null?s:1,gravityPower:(a=n.gravityPower)!=null?a:0,gravityDir:(o=(l=n.gravityDir)==null?void 0:l.clone())!=null?o:new V.Vector3(0,-1,0),dragForce:(u=n.dragForce)!=null?u:.4},this.colliderGroups=i}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 Eo(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:Mo}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(de);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(de);this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength(),ue.setFromMatrixPosition(this.bone.matrixWorld);let e=this._getMatrixWorldToCenter(de);ri.copy(ue).applyMatrix4(e);let n=oi.setFromRotationMatrix(e),i=To.copy(e).multiply(this._parentMatrixWorld),r=Me.copy(this._boneAxis).applyMatrix4(this._initialLocalMatrix).applyMatrix4(i).sub(ri).normalize(),s=Ro.copy(this.settings.gravityDir).applyQuaternion(n).normalize(),a=this._getMatrixCenterToWorld(de);Re.copy(this._currentTail).add(G.copy(this._currentTail).sub(this._prevTail).multiplyScalar(1-this.settings.dragForce)).add(G.copy(r).multiplyScalar(this.settings.stiffness*t)).add(G.copy(s).multiplyScalar(this.settings.gravityPower*t)).applyMatrix4(a),Re.sub(ue).normalize().multiplyScalar(this._worldSpaceBoneLength).add(ue),this._collision(Re),e=this._getMatrixWorldToCenter(de),this._prevTail.copy(this._currentTail),this._currentTail.copy(G.copy(Re).applyMatrix4(e));let l=pi(de.copy(this._parentMatrixWorld).multiply(this._initialLocalMatrix)),o=oi.setFromUnitVectors(this._boneAxis,G.copy(Re).applyMatrix4(l).normalize());this.bone.quaternion.copy(this._initialLocalRotation).multiply(o),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){this.colliderGroups.forEach(e=>{e.colliders.forEach(n=>{let i=n.shape.calculateCollision(n.matrixWorld,t,this.settings.hitRadius,G);i<0&&(t.add(G.multiplyScalar(-i)),t.sub(ue).normalize().multiplyScalar(this._worldSpaceBoneLength).add(ue))})})}_calcWorldSpaceBoneLength(){G.setFromMatrixPosition(this.bone.matrixWorld),this.child?Me.setFromMatrixPosition(this.child.matrixWorld):(Me.copy(this._initialLocalChildPosition),Me.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=G.sub(Me).length()}_getMatrixCenterToWorld(t){return this._center?t.copy(this._center.matrixWorld):t.identity(),t}_getMatrixWorldToCenter(t){return this._center?t.copy(this._center.userData.inverseCacheProxy.inverse):t.identity(),t}};function yo(t,e){let n=[],i=t;for(;i!==null;)n.unshift(i),i=i.parent;n.forEach(r=>{e(r)})}function fi(t,e){t.children.forEach(n=>{e(n)||fi(n,e)})}var si=class{constructor(){this._joints=new Set,this._objectSpringBonesMap=new Map}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)}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)}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){let t=new Set,e=new Set,n=new Set;for(let i of this._joints)this._processSpringBone(i,t,e,n,r=>r.setInitState())}reset(){let t=new Set,e=new Set,n=new Set;for(let i of this._joints)this._processSpringBone(i,t,e,n,r=>r.reset())}update(t){let e=new Set,n=new Set,i=new Set;for(let r of this._joints)this._processSpringBone(r,e,n,i,s=>s.update(t)),fi(r.bone,s=>{var a,l;return((l=(a=this._objectSpringBonesMap.get(s))==null?void 0:a.size)!=null?l:0)>0?!0:(s.updateWorldMatrix(!1,!1),!1)})}_processSpringBone(t,e,n,i,r){if(n.has(t))return;if(e.has(t))throw new Error("VRMSpringBoneManager: Circular dependency detected while updating springbones");e.add(t);let s=this._getDependencies(t);for(let a of s)yo(a,l=>{let o=this._objectSpringBonesMap.get(l);if(o)for(let u of o)this._processSpringBone(u,e,n,i,r);else i.has(l)||(l.updateWorldMatrix(!1,!1),i.add(l))});t.bone.updateMatrix(),t.bone.updateWorldMatrix(!1,!1),r(t),i.add(t.bone),n.add(t)}_getDependencies(t){let e=new Set,n=t.bone.parent;return n&&e.add(n),t.colliderGroups.forEach(i=>{i.colliders.forEach(r=>{e.add(r)})}),e}},wo=new Set(["1.0","1.0-beta"]),_i=class Te{get name(){return Te.EXTENSION_NAME}constructor(e,n){this.parser=e,this.jointHelperRoot=n==null?void 0:n.jointHelperRoot,this.colliderHelperRoot=n==null?void 0:n.colliderHelperRoot}afterRoot(e){return Ce(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return Ce(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 Ce(this,null,function*(){var n,i,r,s,a;let l=e.parser.json;if(!(((n=l.extensionsUsed)==null?void 0:n.indexOf(Te.EXTENSION_NAME))!==-1))return null;let u=new si,d=yield e.parser.getDependencies("node"),c=(i=l.extensions)==null?void 0:i[Te.EXTENSION_NAME];if(!c)return null;let f=c.specVersion;if(!wo.has(f))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Te.EXTENSION_NAME} specVersion "${f}"`),null;let p=(r=c.colliders)==null?void 0:r.map((h,_)=>{var g,x,T,v,R;let E=d[h.node],M=h.shape;if(M.sphere)return this._importSphereCollider(E,{offset:new ie.Vector3().fromArray((g=M.sphere.offset)!=null?g:[0,0,0]),radius:(x=M.sphere.radius)!=null?x:0});if(M.capsule)return this._importCapsuleCollider(E,{offset:new ie.Vector3().fromArray((T=M.capsule.offset)!=null?T:[0,0,0]),radius:(v=M.capsule.radius)!=null?v:0,tail:new ie.Vector3().fromArray((R=M.capsule.tail)!=null?R:[0,0,0])});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${_} has no valid shape`)}),m=(s=c.colliderGroups)==null?void 0:s.map((h,_)=>{var g;return{colliders:((g=h.colliders)!=null?g:[]).map(T=>{let v=p==null?void 0:p[T];if(v==null)throw new Error(`VRMSpringBoneLoaderPlugin: The colliderGroup #${_} attempted to use a collider #${T} but not found`);return v}),name:h.name}});return(a=c.springs)==null||a.forEach((h,_)=>{var g;let x=h.joints,T=(g=h.colliderGroups)==null?void 0:g.map(E=>{let M=m==null?void 0:m[E];if(M==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${_} attempted to use a colliderGroup ${E} but not found`);return M}),v=h.center!=null?d[h.center]:void 0,R;x.forEach(E=>{if(R){let M=R.node,A=d[M],I=E.node,L=d[I],H={hitRadius:R.hitRadius,dragForce:R.dragForce,gravityPower:R.gravityPower,stiffness:R.stiffness,gravityDir:R.gravityDir!=null?new ie.Vector3().fromArray(R.gravityDir):void 0},U=this._importJoint(A,L,H,T);v&&(U.center=v),u.addJoint(U)}R=E})}),u.setInitState(),u})}_v0Import(e){return Ce(this,null,function*(){var n,i,r;let s=e.parser.json;if(!(((n=s.extensionsUsed)==null?void 0:n.indexOf("VRM"))!==-1))return null;let l=(i=s.extensions)==null?void 0:i.VRM,o=l==null?void 0:l.secondaryAnimation;if(!o)return null;let u=o==null?void 0:o.boneGroups;if(!u)return null;let d=new si,c=yield e.parser.getDependencies("node"),f=(r=o.colliderGroups)==null?void 0:r.map(p=>{var m;let h=c[p.node];return{colliders:((m=p.colliders)!=null?m:[]).map((g,x)=>{var T,v,R;let E=new ie.Vector3(0,0,0);return g.offset&&E.set((T=g.offset.x)!=null?T:0,(v=g.offset.y)!=null?v:0,g.offset.z?-g.offset.z:0),this._importSphereCollider(h,{offset:E,radius:(R=g.radius)!=null?R:0})})}});return u==null||u.forEach((p,m)=>{let h=p.bones;h&&h.forEach(_=>{var g,x,T,v;let R=c[_],E=new ie.Vector3;p.gravityDir?E.set((g=p.gravityDir.x)!=null?g:0,(x=p.gravityDir.y)!=null?x:0,(T=p.gravityDir.z)!=null?T:0):E.set(0,-1,0);let M=p.center!=null?c[p.center]:void 0,A={hitRadius:p.hitRadius,dragForce:p.dragForce,gravityPower:p.gravityPower,stiffness:p.stiffiness,gravityDir:E},I=(v=p.colliderGroups)==null?void 0:v.map(L=>{let H=f==null?void 0:f[L];if(H==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${m} attempted to use a colliderGroup ${L} but not found`);return H});R.traverse(L=>{var H;let U=(H=L.children[0])!=null?H:null,ce=this._importJoint(L,U,A,I);M&&(ce.center=M),d.addJoint(ce)})})}),e.scene.updateMatrixWorld(),d.setInitState(),d})}_importJoint(e,n,i,r){let s=new xo(e,n,i,r);if(this.jointHelperRoot){let a=new go(s);this.jointHelperRoot.add(a),a.renderOrder=this.jointHelperRoot.renderOrder}return s}_importSphereCollider(e,n){let{offset:i,radius:r}=n,s=new di({offset:i,radius:r}),a=new ii(s);if(e.add(a),this.colliderHelperRoot){let l=new ni(a);this.colliderHelperRoot.add(l),l.renderOrder=this.colliderHelperRoot.renderOrder}return a}_importCapsuleCollider(e,n){let{offset:i,radius:r,tail:s}=n,a=new li({offset:i,radius:r,tail:s}),l=new ii(a);if(e.add(l),this.colliderHelperRoot){let o=new ni(l);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return l}};_i.EXTENSION_NAME="VRMC_springBone";var gi=_i;var dt=class{get name(){return"VRMLoaderPlugin"}constructor(e,n){var s,a,l,o,u,d,c,f,p,m;this.parser=e;let i=n==null?void 0:n.helperRoot,r=n==null?void 0:n.autoUpdateHumanBones;this.expressionPlugin=(s=n==null?void 0:n.expressionPlugin)!=null?s:new Ye(e),this.firstPersonPlugin=(a=n==null?void 0:n.firstPersonPlugin)!=null?a:new Ze(e),this.humanoidPlugin=(l=n==null?void 0:n.humanoidPlugin)!=null?l:new Je(e,{helperRoot:i,autoUpdateHumanBones:r}),this.lookAtPlugin=(o=n==null?void 0:n.lookAtPlugin)!=null?o:new et(e,{helperRoot:i}),this.metaPlugin=(u=n==null?void 0:n.metaPlugin)!=null?u:new tt(e),this.mtoonMaterialPlugin=(d=n==null?void 0:n.mtoonMaterialPlugin)!=null?d:new jn(e),this.materialsHDREmissiveMultiplierPlugin=(c=n==null?void 0:n.materialsHDREmissiveMultiplierPlugin)!=null?c:new Qn(e),this.materialsV0CompatPlugin=(f=n==null?void 0:n.materialsV0CompatPlugin)!=null?f:new Zn(e),this.springBonePlugin=(p=n==null?void 0:n.springBonePlugin)!=null?p:new gi(e,{colliderHelperRoot:i,jointHelperRoot:i}),this.nodeConstraintPlugin=(m=n==null?void 0:n.nodeConstraintPlugin)!=null?m:new ti(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 ge({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}})}};function vi(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 Po(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=>vi(r)):i&&vi(i))}function Ei(t){t.traverse(Po)}import*as Oe from"three";function Mi(t,e){var a;let n=(a=e==null?void 0:e.experimentalSameBoneCounts)!=null?a:!1,i=[];t.traverse(l=>{l.type==="SkinnedMesh"&&i.push(l)});let r=new Map,s=0;for(let l of i){let u=l.geometry.getAttribute("skinIndex"),d=[],c=[],f={},p=u.array;for(let m=0;m<p.length;m++){let h=p[m];f[h]==null&&(f[h]=d.length,d.push(l.skeleton.bones[h]),c.push(l.skeleton.boneInverses[h])),p[m]=f[h]}u.copyArray(p),u.needsUpdate=!0,r.set(l,{bones:d,boneInverses:c}),s=Math.max(s,d.length)}for(let l of i){let{bones:o,boneInverses:u}=r.get(l);if(n)for(let c=o.length;c<s;c++)o[c]=o[0],u[c]=u[0];let d=new Oe.Skeleton(o,u);l.bind(d,new Oe.Matrix4)}}import*as Ri from"three";import{BufferAttribute as ht}from"three";function Ti(t){let e=new Map;t.traverse(n=>{var c,f,p,m;if(!n.isMesh)return;let i=n,r=i.geometry,s=r.index;if(s==null)return;let a=e.get(r);if(a!=null){i.geometry=a;return}let l=new Ri.BufferGeometry;l.name=r.name,l.morphTargetsRelative=r.morphTargetsRelative,r.groups.forEach(h=>{l.addGroup(h.start,h.count,h.materialIndex)}),l.boundingBox=(f=(c=r.boundingBox)==null?void 0:c.clone())!=null?f:null,l.boundingSphere=(m=(p=r.boundingSphere)==null?void 0:p.clone())!=null?m:null,l.setDrawRange(r.drawRange.start,r.drawRange.count),l.userData=r.userData,e.set(r,l);let o=[],u=[];{let h=s.array,_=new h.constructor(h.length),g=0;for(let x=0;x<h.length;x++){let T=h[x],v=o[T];v==null&&(o[T]=g,u[g]=T,v=g,g++),_[x]=v}l.setIndex(new ht(_,1,!1))}Object.keys(r.attributes).forEach(h=>{let _=r.attributes[h];if(_.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let g=_.array,{itemSize:x,normalized:T}=_,v=new g.constructor(u.length*x);u.forEach((R,E)=>{for(let M=0;M<x;M++)v[E*x+M]=g[R*x+M]}),l.setAttribute(h,new ht(v,x,T))});let d=!0;Object.keys(r.morphAttributes).forEach(h=>{l.morphAttributes[h]=[];let _=r.morphAttributes[h];for(let g=0;g<_.length;g++){let x=_[g];if(x.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");let T=x.array,{itemSize:v,normalized:R}=x,E=new T.constructor(u.length*v);u.forEach((M,A)=>{for(let I=0;I<v;I++)E[A*v+I]=T[M*v+I]}),d=d&&E.every(M=>M===0),l.morphAttributes[h][g]=new ht(E,v,R)}}),d&&(l.morphAttributes={}),i.geometry=l}),Array.from(e.keys()).forEach(n=>{n.dispose()})}function xi(t){var e;((e=t.meta)==null?void 0:e.metaVersion)==="0"&&(t.scene.rotation.y=Math.PI)}var he=class{constructor(){}};he.deepDispose=Ei,he.removeUnnecessaryJoints=Mi,he.removeUnnecessaryVertices=Ti,he.rotateVRM0=xi;export{Or as MToonMaterial,Ur as MToonMaterialDebugMode,jn as MToonMaterialLoaderPlugin,it as MToonMaterialOutlineWidthMode,ge as VRM,eo as VRMAimConstraint,nt as VRMCore,Co as VRMCoreLoaderPlugin,$t as VRMExpression,Ye as VRMExpressionLoaderPlugin,Kt as VRMExpressionManager,en as VRMExpressionMaterialColorBind,me as VRMExpressionMaterialColorType,tn as VRMExpressionMorphTargetBind,bo as VRMExpressionOverrideType,ze as VRMExpressionPresetName,rn as VRMExpressionTextureTransformBind,on as VRMFirstPerson,Ze as VRMFirstPersonLoaderPlugin,Vo as VRMFirstPersonMeshAnnotationType,Be as VRMHumanBoneList,Io as VRMHumanBoneName,or as VRMHumanBoneParentMap,dn as VRMHumanoid,ln as VRMHumanoidHelper,Je as VRMHumanoidLoaderPlugin,dt as VRMLoaderPlugin,Rr as VRMLookAt,He as VRMLookAtBoneApplier,qe as VRMLookAtExpressionApplier,pr as VRMLookAtHelper,et as VRMLookAtLoaderPlugin,En as VRMLookAtRangeMap,Uo as VRMLookAtTypeName,tt as VRMMetaLoaderPlugin,lt as VRMNodeConstraint,st as VRMNodeConstraintHelper,ti as VRMNodeConstraintLoaderPlugin,no as VRMNodeConstraintManager,lr as VRMRequiredHumanBoneName,uo as VRMRollConstraint,oo as VRMRotationConstraint,ii as VRMSpringBoneCollider,ni as VRMSpringBoneColliderHelper,ai as VRMSpringBoneColliderShape,li as VRMSpringBoneColliderShapeCapsule,di as VRMSpringBoneColliderShapeSphere,xo as VRMSpringBoneJoint,go as VRMSpringBoneJointHelper,gi as VRMSpringBoneLoaderPlugin,si as VRMSpringBoneManager,he as VRMUtils};
|
|
1005
930
|
/*!
|
|
1006
|
-
* @pixiv/three-vrm-core v3.0.0-beta.
|
|
931
|
+
* @pixiv/three-vrm-core v3.0.0-beta.2
|
|
1007
932
|
* The implementation of core features of VRM, for @pixiv/three-vrm
|
|
1008
933
|
*
|
|
1009
934
|
* Copyright (c) 2019-2024 pixiv Inc.
|
|
@@ -1011,7 +936,7 @@ void main() {
|
|
|
1011
936
|
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
1012
937
|
*/
|
|
1013
938
|
/*!
|
|
1014
|
-
* @pixiv/three-vrm-materials-mtoon v3.0.0-beta.
|
|
939
|
+
* @pixiv/three-vrm-materials-mtoon v3.0.0-beta.2
|
|
1015
940
|
* MToon (toon material) module for @pixiv/three-vrm
|
|
1016
941
|
*
|
|
1017
942
|
* Copyright (c) 2019-2024 pixiv Inc.
|
|
@@ -1019,7 +944,7 @@ void main() {
|
|
|
1019
944
|
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
1020
945
|
*/
|
|
1021
946
|
/*!
|
|
1022
|
-
* @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.0.0-beta.
|
|
947
|
+
* @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.0.0-beta.2
|
|
1023
948
|
* Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
|
|
1024
949
|
*
|
|
1025
950
|
* Copyright (c) 2019-2024 pixiv Inc.
|
|
@@ -1027,7 +952,7 @@ void main() {
|
|
|
1027
952
|
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
1028
953
|
*/
|
|
1029
954
|
/*!
|
|
1030
|
-
* @pixiv/three-vrm-materials-v0compat v3.0.0-beta.
|
|
955
|
+
* @pixiv/three-vrm-materials-v0compat v3.0.0-beta.2
|
|
1031
956
|
* VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
|
|
1032
957
|
*
|
|
1033
958
|
* Copyright (c) 2019-2024 pixiv Inc.
|
|
@@ -1035,7 +960,7 @@ void main() {
|
|
|
1035
960
|
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
1036
961
|
*/
|
|
1037
962
|
/*!
|
|
1038
|
-
* @pixiv/three-vrm-node-constraint v3.0.0-beta.
|
|
963
|
+
* @pixiv/three-vrm-node-constraint v3.0.0-beta.2
|
|
1039
964
|
* Node constraint module for @pixiv/three-vrm
|
|
1040
965
|
*
|
|
1041
966
|
* Copyright (c) 2019-2024 pixiv Inc.
|
|
@@ -1043,7 +968,7 @@ void main() {
|
|
|
1043
968
|
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
1044
969
|
*/
|
|
1045
970
|
/*!
|
|
1046
|
-
* @pixiv/three-vrm-springbone v3.0.0-beta.
|
|
971
|
+
* @pixiv/three-vrm-springbone v3.0.0-beta.2
|
|
1047
972
|
* Spring bone module for @pixiv/three-vrm
|
|
1048
973
|
*
|
|
1049
974
|
* Copyright (c) 2019-2024 pixiv Inc.
|