|
@@ -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.getUnique = function () {
|
|
|
|
|
|
- switch ( this.scope ) {
|
|
|
-
|
|
|
- case NormalNode.WORLD:
|
|
|
-
|
|
|
- return true;
|
|
|
+ // if unique is true, TempNode will not create temp variable (for optimization)
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ return this.scope === NormalNode.LOCAL;
|
|
|
|
|
|
};
|
|
|
|
|
@@ -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 };
|