提交 7b8aad6f 编写于 作者: S SUNAG

allow redefine nodes dynamically

上级 1599e1ac
......@@ -4,12 +4,28 @@
THREE.ConstNode = function( name, useDefine ) {
name = name || THREE.ConstNode.PI;
THREE.TempNode.call( this );
var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=(.*?)\;/i;
var type = 'fv1';
this.parse( name || THREE.ConstNode.PI, useDefine );
};
THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.ConstNode.prototype.constructor = THREE.ConstNode;
THREE.ConstNode.PI = 'PI';
THREE.ConstNode.PI2 = 'PI2';
THREE.ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI';
THREE.ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2';
THREE.ConstNode.LOG2 = 'LOG2';
THREE.ConstNode.EPSILON = 'EPSILON';
THREE.ConstNode.prototype.parse = function( src, useDefine ) {
var name, type;
var match = name.match( rDeclaration );
var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=(.*?)\;/i;
var match = src.match( rDeclaration );
if ( match && match.length > 1 ) {
......@@ -28,22 +44,17 @@ THREE.ConstNode = function( name, useDefine ) {
}
}
else {
this.name = name;
THREE.TempNode.call( this, type );
name = src;
type = 'fv1';
};
}
THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.ConstNode.prototype.constructor = THREE.ConstNode;
this.name = name;
this.type = type;
THREE.ConstNode.PI = 'PI';
THREE.ConstNode.PI2 = 'PI2';
THREE.ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI';
THREE.ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2';
THREE.ConstNode.LOG2 = 'LOG2';
THREE.ConstNode.EPSILON = 'EPSILON';
};
THREE.ConstNode.prototype.generate = function( builder, output ) {
......
......@@ -6,9 +6,34 @@ THREE.CameraNode = function( scope, camera ) {
THREE.TempNode.call( this, 'v3' );
this.scope = scope || THREE.CameraNode.POSITION;
this.setScope( scope || THREE.CameraNode.POSITION );
this.camera = camera;
this.requestUpdate = this.camera !== undefined;
};
THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.CameraNode.prototype.constructor = THREE.CameraNode;
THREE.CameraNode.POSITION = 'position';
THREE.CameraNode.DEPTH = 'depth';
THREE.CameraNode.prototype.setScope = function( scope ) {
switch ( this.scope ) {
case THREE.CameraNode.DEPTH:
delete this.near;
delete this.far;
break;
}
this.scope = scope;
switch ( scope ) {
case THREE.CameraNode.DEPTH:
......@@ -20,16 +45,8 @@ THREE.CameraNode = function( scope, camera ) {
}
this.requestUpdate = this.camera !== undefined;
};
THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.CameraNode.prototype.constructor = THREE.CameraNode;
THREE.CameraNode.POSITION = 'position';
THREE.CameraNode.DEPTH = 'depth';
THREE.CameraNode.prototype.getType = function( builder ) {
switch ( this.scope ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册