@pixiv/three-vrm-materials-mtoon 3.1.0-beta.0 → 3.1.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/lib/nodes/index.cjs +75 -56
- package/lib/nodes/index.min.cjs +1 -1
- package/lib/nodes/index.module.js +75 -56
- package/lib/nodes/index.module.min.js +1 -1
- package/lib/three-vrm-materials-mtoon.cjs +2 -2
- package/lib/three-vrm-materials-mtoon.module.js +2 -2
- package/package.json +6 -6
- package/types/MToonMaterialDebugMode.d.ts +1 -1
- package/types/MToonMaterialOutlineWidthMode.d.ts +1 -1
- package/types/nodes/MToonNodeMaterial.d.ts +1 -1
- package/types/nodes/mtoonParametricRim.d.ts +1 -1
- package/types/nodes/utils/FnCompat.d.ts +9 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! (c) 2019-2024 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
|
|
2
|
-
import*as z from"three";var _=parseInt(z.REVISION,10);_<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${_}). This would not work correctly.`);import*as l from"three/webgpu";import*as r from"three/webgpu";var k=r.materialReference("color","color"),D=r.materialReference("map","texture"),Y=r.materialReference("normalMap","texture"),X=r.materialReference("normalScale","vec2"),B=r.materialReference("emissive","color"),K=r.materialReference("emissiveIntensity","float"),q=r.materialReference("emissiveMap","texture"),Z=r.materialReference("shadeColorFactor","color"),$=r.materialReference("shadingShiftFactor","float"),v=r.materialReference("shadeMultiplyTexture","texture"),G=r.materialReference("shadeMultiplyTextureScale","float"),J=r.materialReference("shadingToonyFactor","float"),Q=r.materialReference("rimLightingMixFactor","float"),ee=r.materialReference("rimMultiplyTexture","texture"),te=r.materialReference("matcapFactor","color"),ie=r.materialReference("matcapTexture","texture"),oe=r.materialReference("parametricRimColorFactor","color"),re=r.materialReference("parametricRimLiftFactor","float"),ae=r.materialReference("parametricRimFresnelPowerFactor","float"),le=r.materialReference("outlineWidthMultiplyTexture","texture"),ne=r.materialReference("outlineWidthFactor","float"),y=r.materialReference("outlineColorFactor","color"),se=r.materialReference("outlineLightingMixFactor","float"),de=r.materialReference("uvAnimationMaskTexture","texture"),ue=r.materialReference("uvAnimationScrollXOffset","float"),ce=r.materialReference("uvAnimationScrollYOffset","float"),me=r.materialReference("uvAnimationRotationPhase","float");var R=class extends l.TempNode{constructor(e){super("vec2"),this.hasMaskTexture=e}setup(){let e=1;this.hasMaskTexture&&(e=l.vec4(de).context({getUV:()=>l.uv()}).r);let t=l.uv(),o=me.mul(e),n=l.cos(o),u=l.sin(o);t=t.sub(l.vec2(.5,.5)),t=t.mul(l.mat2(n,u,u.negate(),n)),t=t.add(l.vec2(.5,.5));let m=l.vec2(ue,ce).mul(e);return t=t.add(m),t.temp("AnimatedUV")}};import*as a from"three/webgpu";import*as s from"three/webgpu";var S=s.nodeImmutable(s.PropertyNode,"vec3").temp("ShadeColor"),b=s.nodeImmutable(s.PropertyNode,"float").temp("ShadingShift"),F=s.nodeImmutable(s.PropertyNode,"float").temp("ShadingToony"),f=s.nodeImmutable(s.PropertyNode,"float").temp("RimLightingMix"),N=s.nodeImmutable(s.PropertyNode,"vec3").temp("RimMultiply"),H=s.nodeImmutable(s.PropertyNode,"vec3").temp("matcap"),x=s.nodeImmutable(s.PropertyNode,"vec3").temp("ParametricRim");var he=a.tslFn(({a:d,b:e,t})=>{let o=t.sub(d),n=e.sub(d);return o.div(n).clamp()}),pe=a.tslFn(({dotNL:d})=>{let t=a.float(1).sub(F),o=d.add(b);return o=he({a:t.negate(),b:t,t:o}),o=o.mul(1),o}),Te=a.tslFn(({shading:d,lightColor:e})=>{let t=a.mix(S,a.diffuseColor,d);return e.mul(a.BRDF_Lambert({diffuseColor:t}))}),M=class extends a.LightingModel{constructor(){super()}direct({lightDirection:e,lightColor:t,reflectedLight:o}){let n=a.transformedNormalView.dot(e).clamp(-1,1),u=pe({dotNL:n});o.directDiffuse.assign(o.directDiffuse.add(Te({shading:u,lightColor:t}))),o.directSpecular.assign(o.directSpecular.add(x.add(H).mul(N).mul(a.mix(a.vec3(0),a.BRDF_Lambert({diffuseColor:t}),f))))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e)}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(x.add(H).mul(N).mul(a.mix(a.vec3(1),a.vec3(0),f))))}};import*as i from"three/webgpu";var p={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"};import*as c from"three/webgpu";var Ee=c.tslFn(({parametricRimLift:d,parametricRimFresnelPower:e,parametricRimColor:t})=>{let o=c.modelViewPosition.normalize(),n=c.transformedNormalView.dot(o.negate());return c.float(1).sub(n).add(d).clamp().pow(e).mul(t)});var C=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 i.Color(1,1,1),this.map=null,this.emissive=new i.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new i.Vector2(1,1),this.shadeColorFactor=new i.Color(0,0,0),this.shadeMultiplyTexture=null,this.shadingShiftFactor=0,this.shadingShiftTexture=null,this.shadingShiftTextureScale=1,this.shadingToonyFactor=.9,this.rimLightingMixFactor=1,this.rimMultiplyTexture=null,this.matcapFactor=new i.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new i.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=p.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new i.Color(0,0,0),this.outlineLightingMixFactor=1,this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.uvAnimationMaskTexture=null,this.shadeColorNode=null,this.shadingShiftNode=null,this.shadingToonyNode=null,this.rimLightingMixNode=null,this.rimMultiplyNode=null,this.matcapNode=null,this.parametricRimColorNode=null,this.parametricRimLiftNode=null,this.parametricRimFresnelPowerNode=null,this.uvAnimationScrollXOffset=0,this.uvAnimationScrollYOffset=0,this.uvAnimationRotationPhase=0,this.isOutline=!1,this._animatedUVNode=null,this.setValues(e)}setupLightingModel(){return new M}setup(e){var t;this._animatedUVNode=new R((t=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?t:!1),super.setup(e)}setupDiffuseColor(e){let t=null;if(this.colorNode==null){if(t=k,this.map&&this.map.isTexture===!0){let o=D.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(i.REVISION,10)<166&&this.transparent===!1&&this.blending===i.NormalBlending&&this.alphaToCoverage===!1&&i.diffuseColor.a.assign(1),this.colorNode===t&&(this.colorNode=null)}setupVariants(){S.assign(this._setupShadeColorNode()),b.assign(this._setupShadingShiftNode()),F.assign(this._setupShadingToonyNode()),f.assign(this._setupRimLightingMixNode()),N.assign(this._setupRimMultiplyNode()),H.assign(this._setupMatcapNode()),x.assign(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=B.mul(K),this.emissiveMap&&this.emissiveMap.isTexture===!0){let n=q.context({getUV:()=>this._animatedUVNode});t=t.mul(n)}this.emissiveNode=t}let o=super.setupLighting(e);return this.emissiveNode===t&&(this.emissiveNode=null),o}setupOutput(e,t){return this.isOutline&&this.outlineWidthMode!==p.None&&(t=i.vec4(i.mix(y,t.xyz.mul(y),se),t.w)),super.setupOutput(e,t)}setupPosition(e){var n,u;let t=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==p.None){(n=this.positionNode)!=null||(this.positionNode=i.positionLocal);let m=i.normalLocal.normalize(),E=ne;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let h=le.context({getUV:()=>this._animatedUVNode});E=E.mul(h)}let g=i.length(i.modelNormalMatrix.mul(m)),T=E.mul(g).mul(m);if(this.outlineWidthMode===p.WorldCoordinates)this.positionNode=this.positionNode.add(T);else if(this.outlineWidthMode===p.ScreenCoordinates){let h=i.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(T.div(h).mul(i.positionView.z.negate()))}(u=this.positionNode)!=null||(this.positionNode=i.positionLocal)}let o=super.setupPosition(e);return o.z.add(o.w.mul(1e-6)),this.positionNode=t,o}copy(e){var t,o,n,u,m,E,g,T,h,O,L,P,w,A,V,W,j,U,I;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=(n=e.normalMap)!=null?n:null,this.normalScale.copy(e.normalScale),this.shadeColorFactor.copy(e.shadeColorFactor),this.shadeMultiplyTexture=(u=e.shadeMultiplyTexture)!=null?u:null,this.shadingShiftFactor=e.shadingShiftFactor,this.shadingShiftTexture=(m=e.shadingShiftTexture)!=null?m:null,this.shadingShiftTextureScale=e.shadingShiftTextureScale,this.shadingToonyFactor=e.shadingToonyFactor,this.rimLightingMixFactor=e.rimLightingMixFactor,this.rimMultiplyTexture=(E=e.rimMultiplyTexture)!=null?E:null,this.matcapFactor.copy(e.matcapFactor),this.matcapTexture=(g=e.matcapTexture)!=null?g:null,this.parametricRimColorFactor.copy(e.parametricRimColorFactor),this.parametricRimLiftFactor=e.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=e.parametricRimFresnelPowerFactor,this.outlineWidthMode=e.outlineWidthMode,this.outlineWidthMultiplyTexture=(T=e.outlineWidthMultiplyTexture)!=null?T: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=(h=e.uvAnimationMaskTexture)!=null?h:null,this.shadeColorNode=(O=e.shadeColorNode)!=null?O:null,this.shadingShiftNode=(L=e.shadingShiftNode)!=null?L:null,this.shadingToonyNode=(P=e.shadingToonyNode)!=null?P:null,this.rimLightingMixNode=(w=e.rimLightingMixNode)!=null?w:null,this.rimMultiplyNode=(A=e.rimMultiplyNode)!=null?A:null,this.matcapNode=(V=e.matcapNode)!=null?V:null,this.parametricRimColorNode=(W=e.parametricRimColorNode)!=null?W:null,this.parametricRimLiftNode=(j=e.parametricRimLiftNode)!=null?j:null,this.parametricRimFresnelPowerNode=(U=e.parametricRimFresnelPowerNode)!=null?U:null,this.isOutline=(I=e.isOutline)!=null?I: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=Z;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let t=v.context({getUV:()=>this._animatedUVNode});e=e.mul(t)}return e}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return i.float(this.shadingShiftNode);let e=$;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let t=v.context({getUV:()=>this._animatedUVNode});e=e.add(t.mul(G))}return e}_setupShadingToonyNode(){return this.shadingToonyNode!=null?i.float(this.shadingToonyNode):J}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?i.float(this.rimLightingMixNode):Q}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?i.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?ee.context({getUV:()=>this._animatedUVNode}):i.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?i.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?ie.context({getUV:()=>i.matcapUV.mul(1,-1).add(0,1)}).mul(te):i.vec3(0)}_setupParametricRimNode(){let e=this.parametricRimColorNode!=null?i.vec3(this.parametricRimColorNode):oe,t=this.parametricRimLiftNode!=null?i.float(this.parametricRimLiftNode):re,o=this.parametricRimFresnelPowerNode!=null?i.float(this.parametricRimFresnelPowerNode):ae;return Ee({parametricRimLift:t,parametricRimFresnelPower:o,parametricRimColor:e})}};export{R as MToonAnimatedUVNode,M as MToonLightingModel,C as MToonNodeMaterial};
|
|
2
|
+
import*as D from"three";var k=parseInt(D.REVISION,10);k<167&&console.warn(`MToonNodeMaterial requires Three.js r167 or higher (You are using r${k}). This would not work correctly.`);import*as l from"three/webgpu";import*as r from"three/webgpu";var Y=r.materialReference("color","color"),X=r.materialReference("map","texture"),B=r.materialReference("normalMap","texture"),K=r.materialReference("normalScale","vec2"),q=r.materialReference("emissive","color"),Z=r.materialReference("emissiveIntensity","float"),$=r.materialReference("emissiveMap","texture"),G=r.materialReference("shadeColorFactor","color"),J=r.materialReference("shadingShiftFactor","float"),C=r.materialReference("shadeMultiplyTexture","texture"),Q=r.materialReference("shadeMultiplyTextureScale","float"),ee=r.materialReference("shadingToonyFactor","float"),te=r.materialReference("rimLightingMixFactor","float"),ie=r.materialReference("rimMultiplyTexture","texture"),oe=r.materialReference("matcapFactor","color"),re=r.materialReference("matcapTexture","texture"),ae=r.materialReference("parametricRimColorFactor","color"),ne=r.materialReference("parametricRimLiftFactor","float"),le=r.materialReference("parametricRimFresnelPowerFactor","float"),se=r.materialReference("outlineWidthMultiplyTexture","texture"),de=r.materialReference("outlineWidthFactor","float"),O=r.materialReference("outlineColorFactor","color"),ue=r.materialReference("outlineLightingMixFactor","float"),ce=r.materialReference("uvAnimationMaskTexture","texture"),me=r.materialReference("uvAnimationScrollXOffset","float"),Ee=r.materialReference("uvAnimationScrollYOffset","float"),he=r.materialReference("uvAnimationRotationPhase","float");var N=class extends l.TempNode{constructor(e){super("vec2"),this.hasMaskTexture=e}setup(){let e=1;this.hasMaskTexture&&(e=l.vec4(ce).context({getUV:()=>l.uv()}).r);let t=l.uv(),o=he.mul(e),n=l.cos(o),u=l.sin(o);t=t.sub(l.vec2(.5,.5)),t=t.mul(l.mat2(n,u,u.negate(),n)),t=t.add(l.vec2(.5,.5));let c=l.vec2(me,Ee).mul(e);return t=t.add(c),t.temp("AnimatedUV")}};import*as a from"three/webgpu";import*as s from"three/webgpu";var F=s.nodeImmutable(s.PropertyNode,"vec3").temp("ShadeColor"),v=s.nodeImmutable(s.PropertyNode,"float").temp("ShadingShift"),y=s.nodeImmutable(s.PropertyNode,"float").temp("ShadingToony"),H=s.nodeImmutable(s.PropertyNode,"float").temp("RimLightingMix"),x=s.nodeImmutable(s.PropertyNode,"vec3").temp("RimMultiply"),M=s.nodeImmutable(s.PropertyNode,"vec3").temp("matcap"),g=s.nodeImmutable(s.PropertyNode,"vec3").temp("ParametricRim");import*as h from"three/webgpu";var p=d=>parseInt(h.REVISION,10)>=168?h.Fn(d):h.tslFn(d);var Te=p(({a:d,b:e,t})=>{let o=t.sub(d),n=e.sub(d);return o.div(n).clamp()}),Re=p(({dotNL:d})=>{let t=a.float(1).sub(y),o=d.add(v);return o=Te({a:t.negate(),b:t,t:o}),o=o.mul(1),o}),fe=p(({shading:d,lightColor:e})=>{let t=a.mix(F,a.diffuseColor,d);return e.mul(a.BRDF_Lambert({diffuseColor:t}))}),S=class extends a.LightingModel{constructor(){super()}direct({lightDirection:e,lightColor:t,reflectedLight:o}){let n=a.transformedNormalView.dot(e).clamp(-1,1),u=Re({dotNL:n});o.directDiffuse.assign(o.directDiffuse.add(fe({shading:u,lightColor:t}))),o.directSpecular.assign(o.directSpecular.add(g.add(M).mul(x).mul(a.mix(a.vec3(0),a.BRDF_Lambert({diffuseColor:t}),H))))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e)}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(g.add(M).mul(x).mul(a.mix(a.vec3(1),a.vec3(0),H))))}};import*as i from"three/webgpu";var T={None:"none",WorldCoordinates:"worldCoordinates",ScreenCoordinates:"screenCoordinates"};import*as R from"three/webgpu";var pe=p(({parametricRimLift:d,parametricRimFresnelPower:e,parametricRimColor:t})=>{let o=R.modelViewPosition.normalize(),n=R.transformedNormalView.dot(o.negate());return R.float(1).sub(n).add(d).clamp().pow(e).mul(t)});var L=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 i.Color(1,1,1),this.map=null,this.emissive=new i.Color(0,0,0),this.emissiveIntensity=1,this.emissiveMap=null,this.normalMap=null,this.normalScale=new i.Vector2(1,1),this.shadeColorFactor=new i.Color(0,0,0),this.shadeMultiplyTexture=null,this.shadingShiftFactor=0,this.shadingShiftTexture=null,this.shadingShiftTextureScale=1,this.shadingToonyFactor=.9,this.rimLightingMixFactor=1,this.rimMultiplyTexture=null,this.matcapFactor=new i.Color(1,1,1),this.matcapTexture=null,this.parametricRimColorFactor=new i.Color(0,0,0),this.parametricRimLiftFactor=0,this.parametricRimFresnelPowerFactor=5,this.outlineWidthMode=T.None,this.outlineWidthMultiplyTexture=null,this.outlineWidthFactor=0,this.outlineColorFactor=new i.Color(0,0,0),this.outlineLightingMixFactor=1,this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.uvAnimationMaskTexture=null,this.shadeColorNode=null,this.shadingShiftNode=null,this.shadingToonyNode=null,this.rimLightingMixNode=null,this.rimMultiplyNode=null,this.matcapNode=null,this.parametricRimColorNode=null,this.parametricRimLiftNode=null,this.parametricRimFresnelPowerNode=null,this.uvAnimationScrollXOffset=0,this.uvAnimationScrollYOffset=0,this.uvAnimationRotationPhase=0,this.isOutline=!1,this._animatedUVNode=null,this.setValues(e)}setupLightingModel(){return new S}setup(e){var t;this._animatedUVNode=new N((t=this.uvAnimationMaskTexture&&this.uvAnimationMaskTexture.isTexture===!0)!=null?t:!1),super.setup(e)}setupDiffuseColor(e){let t=null;if(this.colorNode==null){if(t=Y,this.map&&this.map.isTexture===!0){let o=X.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(i.REVISION,10)<166&&this.transparent===!1&&this.blending===i.NormalBlending&&this.alphaToCoverage===!1&&i.diffuseColor.a.assign(1),this.colorNode===t&&(this.colorNode=null)}setupVariants(){F.assign(this._setupShadeColorNode()),v.assign(this._setupShadingShiftNode()),y.assign(this._setupShadingToonyNode()),H.assign(this._setupRimLightingMixNode()),x.assign(this._setupRimMultiplyNode()),M.assign(this._setupMatcapNode()),g.assign(this._setupParametricRimNode())}setupNormal(e){let t=this.normalNode;if(this.normalNode==null){if(this.normalNode=i.materialNormal,this.normalMap&&this.normalMap.isTexture===!0){let n=B.context({getUV:()=>this._animatedUVNode});this.normalNode=i.normalMap(n,K)}this.isOutline&&(this.normalNode=this.normalNode.negate())}if(parseInt(i.REVISION,10)>=168){let n=this.normalNode;return this.normalNode=t,n}else{super.setupNormal(e),this.normalNode=t;return}}setupLighting(e){let t=null;if(this.emissiveNode==null){if(t=q.mul(Z),this.emissiveMap&&this.emissiveMap.isTexture===!0){let n=$.context({getUV:()=>this._animatedUVNode});t=t.mul(n)}this.emissiveNode=t}let o=super.setupLighting(e);return this.emissiveNode===t&&(this.emissiveNode=null),o}setupOutput(e,t){return this.isOutline&&this.outlineWidthMode!==T.None&&(t=i.vec4(i.mix(O,t.xyz.mul(O),ue),t.w)),super.setupOutput(e,t)}setupPosition(e){var n,u;let t=this.positionNode;if(this.isOutline&&this.outlineWidthMode!==T.None){(n=this.positionNode)!=null||(this.positionNode=i.positionLocal);let c=i.normalLocal.normalize(),m=de;if(this.outlineWidthMultiplyTexture&&this.outlineWidthMultiplyTexture.isTexture===!0){let E=se.context({getUV:()=>this._animatedUVNode});m=m.mul(E)}let b=i.length(i.modelNormalMatrix.mul(c)),f=m.mul(b).mul(c);if(this.outlineWidthMode===T.WorldCoordinates)this.positionNode=this.positionNode.add(f);else if(this.outlineWidthMode===T.ScreenCoordinates){let E=i.cameraProjectionMatrix.element(1).element(1);this.positionNode=this.positionNode.add(f.div(E).mul(i.positionView.z.negate()))}(u=this.positionNode)!=null||(this.positionNode=i.positionLocal)}let o=super.setupPosition(e);return o.z.add(o.w.mul(1e-6)),this.positionNode=t,o}copy(e){var t,o,n,u,c,m,b,f,E,P,w,A,V,W,j,I,U,_,z;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=(n=e.normalMap)!=null?n:null,this.normalScale.copy(e.normalScale),this.shadeColorFactor.copy(e.shadeColorFactor),this.shadeMultiplyTexture=(u=e.shadeMultiplyTexture)!=null?u:null,this.shadingShiftFactor=e.shadingShiftFactor,this.shadingShiftTexture=(c=e.shadingShiftTexture)!=null?c:null,this.shadingShiftTextureScale=e.shadingShiftTextureScale,this.shadingToonyFactor=e.shadingToonyFactor,this.rimLightingMixFactor=e.rimLightingMixFactor,this.rimMultiplyTexture=(m=e.rimMultiplyTexture)!=null?m:null,this.matcapFactor.copy(e.matcapFactor),this.matcapTexture=(b=e.matcapTexture)!=null?b:null,this.parametricRimColorFactor.copy(e.parametricRimColorFactor),this.parametricRimLiftFactor=e.parametricRimLiftFactor,this.parametricRimFresnelPowerFactor=e.parametricRimFresnelPowerFactor,this.outlineWidthMode=e.outlineWidthMode,this.outlineWidthMultiplyTexture=(f=e.outlineWidthMultiplyTexture)!=null?f: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=(E=e.uvAnimationMaskTexture)!=null?E:null,this.shadeColorNode=(P=e.shadeColorNode)!=null?P:null,this.shadingShiftNode=(w=e.shadingShiftNode)!=null?w:null,this.shadingToonyNode=(A=e.shadingToonyNode)!=null?A:null,this.rimLightingMixNode=(V=e.rimLightingMixNode)!=null?V:null,this.rimMultiplyNode=(W=e.rimMultiplyNode)!=null?W:null,this.matcapNode=(j=e.matcapNode)!=null?j:null,this.parametricRimColorNode=(I=e.parametricRimColorNode)!=null?I:null,this.parametricRimLiftNode=(U=e.parametricRimLiftNode)!=null?U:null,this.parametricRimFresnelPowerNode=(_=e.parametricRimFresnelPowerNode)!=null?_:null,this.isOutline=(z=e.isOutline)!=null?z: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=G;if(this.shadeMultiplyTexture&&this.shadeMultiplyTexture.isTexture===!0){let t=C.context({getUV:()=>this._animatedUVNode});e=e.mul(t)}return e}_setupShadingShiftNode(){if(this.shadingShiftNode!=null)return i.float(this.shadingShiftNode);let e=J;if(this.shadingShiftTexture&&this.shadingShiftTexture.isTexture===!0){let t=C.context({getUV:()=>this._animatedUVNode});e=e.add(t.mul(Q))}return e}_setupShadingToonyNode(){return this.shadingToonyNode!=null?i.float(this.shadingToonyNode):ee}_setupRimLightingMixNode(){return this.rimLightingMixNode!=null?i.float(this.rimLightingMixNode):te}_setupRimMultiplyNode(){return this.rimMultiplyNode!=null?i.vec3(this.rimMultiplyNode):this.rimMultiplyTexture&&this.rimMultiplyTexture.isTexture===!0?ie.context({getUV:()=>this._animatedUVNode}):i.vec3(1)}_setupMatcapNode(){return this.matcapNode!=null?i.vec3(this.matcapNode):this.matcapTexture&&this.matcapTexture.isTexture===!0?re.context({getUV:()=>i.matcapUV.mul(1,-1).add(0,1)}).mul(oe):i.vec3(0)}_setupParametricRimNode(){let e=this.parametricRimColorNode!=null?i.vec3(this.parametricRimColorNode):ae,t=this.parametricRimLiftNode!=null?i.float(this.parametricRimLiftNode):ne,o=this.parametricRimFresnelPowerNode!=null?i.float(this.parametricRimFresnelPowerNode):le;return pe({parametricRimLift:t,parametricRimFresnelPower:o,parametricRimColor:e})}};export{N as MToonAnimatedUVNode,S as MToonLightingModel,L as MToonNodeMaterial};
|