@pixiv/three-vrm 2.1.2 → 3.0.0-beta.1
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 +36 -11
- package/lib/nodes/index.cjs +510 -0
- package/lib/nodes/index.min.cjs +10 -0
- package/lib/nodes/index.module.js +478 -0
- package/lib/nodes/index.module.min.js +10 -0
- package/lib/three-vrm.cjs +6175 -0
- package/lib/three-vrm.min.cjs +959 -0
- package/lib/three-vrm.module.js +6043 -6794
- package/lib/three-vrm.module.min.js +923 -19
- package/package.json +29 -25
- package/types/VRMUtils/removeUnnecessaryJoints.d.ts +11 -1
- package/types/nodes/index.d.ts +1 -0
- package/lib/three-vrm.js +0 -6974
- package/lib/three-vrm.min.js +0 -54
- package/ts3.4/types/VRM.d.ts +0 -39
- package/ts3.4/types/VRMLoaderPlugin.d.ts +0 -31
- package/ts3.4/types/VRMLoaderPluginOptions.d.ts +0 -32
- package/ts3.4/types/VRMParameters.d.ts +0 -12
- package/ts3.4/types/VRMUtils/deepDispose.d.ts +0 -2
- package/ts3.4/types/VRMUtils/index.d.ts +0 -11
- package/ts3.4/types/VRMUtils/removeUnnecessaryJoints.d.ts +0 -9
- package/ts3.4/types/VRMUtils/removeUnnecessaryVertices.d.ts +0 -12
- package/ts3.4/types/VRMUtils/rotateVRM0.d.ts +0 -7
- package/ts3.4/types/index.d.ts +0 -9
- package/ts3.4/types/utils/Matrix4InverseCache.d.ts +0 -28
- package/ts3.4/types/utils/mat4InvertCompat.d.ts +0 -8
- package/ts3.4/types/utils/math.d.ts +0 -40
- package/ts3.4/types/utils/quatInvertCompat.d.ts +0 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! (c) 2019-2024 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
|
|
2
|
+
import*as O from"three";import*as l from"three/addons/nodes/Nodes.js";import*as r from"three/addons/nodes/Nodes.js";import*as a from"three/addons/nodes/Nodes.js";import*as n from"three/addons/nodes/Nodes.js";import*as m from"three";import*as i from"three/addons/nodes/Nodes.js";import*as h from"three/addons/nodes/Nodes.js";var V=parseInt(O.REVISION,10);V<161&&console.warn(`MToonNodeMaterial requires Three.js r161 or higher (You are using r${V}). This would not work correctly.`);var D=r.materialReference("color","color"),H=r.materialReference("map","texture"),Y=r.materialReference("normalMap","texture"),X=r.materialReference("normalScale","vec2"),k=r.materialReference("emissive","color"),z=r.materialReference("emissiveIntensity","float"),B=r.materialReference("emissiveMap","texture"),j=r.materialReference("shadeColorFactor","color"),q=r.materialReference("shadingShiftFactor","float"),E=r.materialReference("shadeMultiplyTexture","texture"),K=r.materialReference("shadeMultiplyTextureScale","float"),Z=r.materialReference("shadingToonyFactor","float"),$=r.materialReference("rimLightingMixFactor","float"),G=r.materialReference("rimMultiplyTexture","texture"),J=r.materialReference("matcapFactor","color"),Q=r.materialReference("matcapTexture","texture"),ee=r.materialReference("parametricRimColorFactor","color"),te=r.materialReference("parametricRimLiftFactor","float"),ie=r.materialReference("parametricRimFresnelPowerFactor","float"),oe=r.materialReference("outlineWidthMultiplyTexture","texture"),re=r.materialReference("outlineWidthFactor","float"),W=r.materialReference("outlineColorFactor","color"),ae=r.materialReference("outlineLightingMixFactor","float"),se=r.materialReference("uvAnimationMaskTexture","texture"),le=r.materialReference("uvAnimationScrollXOffset","float"),ne=r.materialReference("uvAnimationScrollYOffset","float"),de=r.materialReference("uvAnimationRotationPhase","float"),me=class extends l.TempNode{constructor(e){super("vec2"),this.hasMaskTexture=e}setup(){let e=1;this.hasMaskTexture&&(e=l.vec4(se).context({getUV:()=>l.uv()}).r);let t=l.uv(),o=de.mul(e),s=l.cos(o),d=l.sin(o);t=t.sub(l.vec2(.5,.5)),t=t.mul(l.mat2(s,d,d.negate(),s)),t=t.add(l.vec2(.5,.5));let u=l.vec2(le,ne).mul(e);return t=t.add(u),t.temp("AnimatedUV")}},U=n.nodeImmutable(n.PropertyNode,"vec3").temp("ShadeColor"),b=n.nodeImmutable(n.PropertyNode,"float").temp("ShadingShift"),I=n.nodeImmutable(n.PropertyNode,"float").temp("ShadingToony"),g=n.nodeImmutable(n.PropertyNode,"float").temp("RimLightingMix"),M=n.nodeImmutable(n.PropertyNode,"vec3").temp("RimMultiply"),x=n.nodeImmutable(n.PropertyNode,"vec3").temp("matcap"),R=n.nodeImmutable(n.PropertyNode,"vec3").temp("ParametricRim"),ue=a.tslFn(({a:e,b:t,t:o})=>{let s=o.sub(e),d=t.sub(e);return s.div(d).clamp()}),he=a.tslFn(({dotNL:e})=>{let o=a.float(1).sub(I),s=e.add(b);return s=ue({a:o.negate(),b:o,t:s}),s=s.mul(1),s}),ce=a.tslFn(({shading:e,lightColor:t})=>{let o=a.mix(U,a.diffuseColor,e);return t.mul(a.BRDF_Lambert({diffuseColor:o}))}),pe=class extends a.LightingModel{constructor(){super()}direct({lightDirection:e,lightColor:t,reflectedLight:o}){let s=a.transformedNormalView.dot(e).clamp(-1,1),d=he({dotNL:s});o.directDiffuse.assign(o.directDiffuse.add(ce({shading:d,lightColor:t}))),o.directSpecular.assign(o.directSpecular.add(R.add(x).mul(M).mul(a.mix(a.vec3(0),a.BRDF_Lambert({diffuseColor:t}),g))))}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(R.add(x).mul(M).mul(a.mix(a.vec3(1),a.vec3(0),g))))}},f={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"},Ne=h.tslFn(({parametricRimLift:e,parametricRimFresnelPower:t,parametricRimColor:o})=>{let s=h.modelViewPosition.normalize(),d=h.transformedNormalView.dot(s.negate());return h.float(1).sub(d).add(e).clamp().pow(t).mul(o)}),fe=class extends i.NodeMaterial{customProgramCacheKey(){let e=super.customProgramCacheKey();return e+=`isOutline:${this.isOutline},`,e}get isMToonNodeMaterial(){return!0}constructor(e={}){super(),e.transparentWithZWrite&&(e.depthWrite=!0),delete e.transparentWithZWrite,delete e.giEqualizationFactor,delete e.v0CompatShade,delete e.debugMode,this.emissiveNode=null,this.lights=!0,this.color=new m.Color(1,1,1),this.map=null,this.emissive=new m.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new m.Vector2(1,1),this.shadeColorFactor=new m.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 m.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new m.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=f.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new m.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 pe}setup(e){var t;this._animatedUVNode=new me((t=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?t:!1),super.setup(e)}setupDiffuseColor(e){let t=null;if(this.colorNode==null){if(t=D,this.map&&this.map.isTexture===!0){let o=H.context({getUV:()=>this._animatedUVNode});t=t.mul(o)}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),parseInt(m.REVISION,10)<166&&this.transparent===!1&&this.blending===m.NormalBlending&&this.alphaToCoverage===!1&&i.diffuseColor.a.assign(1),this.colorNode===t&&(this.colorNode=null)}setupVariants({stack:e}){e.assign(U,this._setupShadeColorNode()),e.assign(b,this._setupShadingShiftNode()),e.assign(I,this._setupShadingToonyNode()),e.assign(g,this._setupRimLightingMixNode()),e.assign(M,this._setupRimMultiplyNode()),e.assign(x,this._setupMatcapNode()),e.assign(R,this._setupParametricRimNode())}setupNormal(e){let t=this.normalNode;if(this.normalNode==null){if(this.normalNode=i.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let o=Y.context({getUV:()=>this._animatedUVNode});this.normalNode=o.normalMap(X)}this.isOutline&&(this.normalNode=this.normalNode.negate())}super.setupNormal(e),this.normalNode=t}setupLighting(e){let t=null;if(this.emissiveNode==null){if(t=k.mul(z),this.emissiveMap&&this.emissiveMap.isTexture===!0){let s=B.context({getUV:()=>this._animatedUVNode});t=t.mul(s)}this.emissiveNode=t}let o=super.setupLighting(e);return this.emissiveNode===t&&(this.emissiveNode=null),o}setupOutput(e,t){return this.isOutline&&this.outlineWidthMode!==f.None&&(t=i.vec4(i.mix(W,t.xyz.mul(W),ae),t.w)),super.setupOutput(e,t)}setupPosition(e){var t,o;let s=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==f.None){(t=this.positionNode)!=null||(this.positionNode=i.positionLocal);let u=i.normalLocal.normalize(),c=re;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let p=oe.context({getUV:()=>this._animatedUVNode});c=c.mul(p)}let v=i.length(i.modelNormalMatrix.mul(u)),N=c.mul(v).mul(u);if(this.outlineWidthMode===f.WorldCoordinates)this.positionNode=this.positionNode.add(N);else if(this.outlineWidthMode===f.ScreenCoordinates){let p=i.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(N.div(p).mul(i.positionView.z.negate()))}(o=this.positionNode)!=null||(this.positionNode=i.positionLocal)}let d=super.setupPosition(e);return d.z.add(d.w.mul(1e-6)),this.positionNode=s,d}copy(e){var t,o,s,d,u,c,v,N,p,T,S,F,y,C,_,L,w,P,A;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=(o=e.emissiveMap)!=null?o:null,this.normalMap=(s=e.normalMap)!=null?s:null,this.normalScale.copy(e.normalScale),this.shadeColorFactor.copy(e.shadeColorFactor),this.shadeMultiplyTexture=(d=e.shadeMultiplyTexture)!=null?d:null,this.shadingShiftFactor=e.shadingShiftFactor,this.shadingShiftTexture=(u=e.shadingShiftTexture)!=null?u:null,this.shadingShiftTextureScale=e.shadingShiftTextureScale,this.shadingToonyFactor=e.shadingToonyFactor,this.rimLightingMixFactor=e.rimLightingMixFactor,this.rimMultiplyTexture=(c=e.rimMultiplyTexture)!=null?c:null,this.matcapFactor.copy(e.matcapFactor),this.matcapTexture=(v=e.matcapTexture)!=null?v:null,this.parametricRimColorFactor.copy(e.parametricRimColorFactor),this.parametricRimLiftFactor=e.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=e.parametricRimFresnelPowerFactor,this.outlineWidthMode=e.outlineWidthMode,this.outlineWidthMultiplyTexture=(N=e.outlineWidthMultiplyTexture)!=null?N: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=(p=e.uvAnimationMaskTexture)!=null?p:null,this.shadeColorNode=(T=e.shadeColorNode)!=null?T:null,this.shadingShiftNode=(S=e.shadingShiftNode)!=null?S:null,this.shadingToonyNode=(F=e.shadingToonyNode)!=null?F:null,this.rimLightingMixNode=(y=e.rimLightingMixNode)!=null?y:null,this.rimMultiplyNode=(C=e.rimMultiplyNode)!=null?C:null,this.matcapNode=(_=e.matcapNode)!=null?_:null,this.parametricRimColorNode=(L=e.parametricRimColorNode)!=null?L:null,this.parametricRimLiftNode=(w=e.parametricRimLiftNode)!=null?w:null,this.parametricRimFresnelPowerNode=(P=e.parametricRimFresnelPowerNode)!=null?P:null,this.isOutline=(A=e.isOutline)!=null?A: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 i.vec3(this.shadeColorNode);let e=j;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let t=E.context({getUV:()=>this._animatedUVNode});e=e.mul(t)}return e}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return i.float(this.shadingShiftNode);let e=q;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let t=E.context({getUV:()=>this._animatedUVNode});e=e.add(t.mul(K))}return e}_setupShadingToonyNode(){return this.shadingToonyNode!=null?i.float(this.shadingToonyNode):Z}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?i.float(this.rimLightingMixNode):$}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?i.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?G.context({getUV:()=>this._animatedUVNode}):i.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?i.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?Q.context({getUV:()=>i.matcapUV.mul(1,-1).add(0,1)}).mul(J):i.vec3(0)}_setupParametricRimNode(){let e=this.parametricRimColorNode!=null?i.vec3(this.parametricRimColorNode):ee,t=this.parametricRimLiftNode!=null?i.float(this.parametricRimLiftNode):te,o=this.parametricRimFresnelPowerNode!=null?i.float(this.parametricRimFresnelPowerNode):ie;return Ne({parametricRimLift:t,parametricRimFresnelPower:o,parametricRimColor:e})}};export{me as MToonAnimatedUVNode,pe as MToonLightingModel,fe as MToonNodeMaterial};
|
|
3
|
+
/*!
|
|
4
|
+
* @pixiv/three-vrm-materials-mtoon v3.0.0-beta.1
|
|
5
|
+
* MToon (toon material) module for @pixiv/three-vrm
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2019-2024 pixiv Inc.
|
|
8
|
+
* @pixiv/three-vrm-materials-mtoon is distributed under MIT License
|
|
9
|
+
* https://github.com/pixiv/three-vrm/blob/release/LICENSE
|
|
10
|
+
*/
|