diff --git a/examples/jsm/nodes/accessors/NormalNode.d.ts b/examples/jsm/nodes/accessors/NormalNode.d.ts index bfa5d4bd17f8757f6bb21c2d8a46e4d5d9bf7716..2a2dbc9f14d389cb2649176ccaf9576a69ee6512 100644 --- a/examples/jsm/nodes/accessors/NormalNode.d.ts +++ b/examples/jsm/nodes/accessors/NormalNode.d.ts @@ -12,5 +12,4 @@ export class NormalNode extends TempNode { static LOCAL: string; static WORLD: string; - static VIEW: string; } diff --git a/examples/jsm/nodes/accessors/NormalNode.js b/examples/jsm/nodes/accessors/NormalNode.js index a65982ac8d162b7ebb3ec1decbb81768b851f83b..5621a2a1b8027ef4f072ddbe12574b631befd113 100644 --- a/examples/jsm/nodes/accessors/NormalNode.js +++ b/examples/jsm/nodes/accessors/NormalNode.js @@ -15,23 +15,16 @@ function NormalNode( scope ) { NormalNode.LOCAL = 'local'; NormalNode.WORLD = 'world'; -NormalNode.VIEW = 'view'; NormalNode.prototype = Object.create( TempNode.prototype ); NormalNode.prototype.constructor = NormalNode; NormalNode.prototype.nodeType = "Normal"; -NormalNode.prototype.getShared = function ( /* builder */ ) { +NormalNode.prototype.getShared = function () { - switch ( this.scope ) { - - case NormalNode.WORLD: - - return true; + // if shared is false, TempNode will not create temp variable (for optimization) - } - - return false; + return this.scope === NormalNode.WORLD; }; @@ -43,9 +36,6 @@ NormalNode.prototype.generate = function ( builder, output ) { case NormalNode.LOCAL: - // to use vObjectNormal as vertex normal - //builder.requires.normal = true; - result = 'normal'; break; @@ -54,24 +44,16 @@ NormalNode.prototype.generate = function ( builder, output ) { if ( builder.isShader( 'vertex' ) ) { - return '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz'; + result = '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz'; } else { - builder.requires.worldNormal = true; - - result = 'vWNormal'; + result = 'inverseTransformDirection( normal, viewMatrix )'; } break; - case NormalNode.VIEW: - - result = 'vNormal'; - - break; - } return builder.format( result, this.getType( builder ), output ); @@ -116,10 +98,4 @@ NodeLib.addKeyword( 'worldNormal', function () { } ); -NodeLib.addKeyword( 'viewNormal', function () { - - return new NormalNode( NormalNode.VIEW ); - -} ); - export { NormalNode }; diff --git a/examples/jsm/nodes/accessors/PositionNode.js b/examples/jsm/nodes/accessors/PositionNode.js index a46525971fb9fdf1aeb658489097db24c100123b..b33f98a99c6a42c5d88ce1acde3d275fc903ddea 100644 --- a/examples/jsm/nodes/accessors/PositionNode.js +++ b/examples/jsm/nodes/accessors/PositionNode.js @@ -148,7 +148,7 @@ NodeLib.addKeyword( 'worldPosition', function () { NodeLib.addKeyword( 'viewPosition', function () { - return new PositionNode( NormalNode.VIEW ); + return new PositionNode( PositionNode.VIEW ); } ); diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index 7bb5577e6bc9571ef6274d0877cf01a3341a7dee..027a8b1554f0ff392dc8755eea33bbbe6e73c5a0 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -2280,8 +2280,7 @@ addGui( 'scope', { local: Nodes.NormalNode.LOCAL, - world: Nodes.NormalNode.WORLD, - view: Nodes.NormalNode.VIEW + world: Nodes.NormalNode.WORLD }, function ( val ) { node.scope = val;