未验证 提交 c5a779eb 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17096 from sunag/dev-fix-nodenormal

fix NormalNode
......@@ -12,5 +12,4 @@ export class NormalNode extends TempNode {
static LOCAL: string;
static WORLD: string;
static VIEW: string;
}
......@@ -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 };
......@@ -148,7 +148,7 @@ NodeLib.addKeyword( 'worldPosition', function () {
NodeLib.addKeyword( 'viewPosition', function () {
return new PositionNode( NormalNode.VIEW );
return new PositionNode( PositionNode.VIEW );
} );
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册