提交 d675c3f0 编写于 作者: M Mr.doob

Merge pull request #7876 from sunag/dev

add sqrt and fix getType Math1Node
......@@ -18,7 +18,8 @@ THREE.Math1Node.EXP = 'exp';
THREE.Math1Node.EXP2 = 'exp2';
THREE.Math1Node.LOG = 'log';
THREE.Math1Node.LOG2 = 'log2';
THREE.Math1Node.INVERSE_SQRT = 'inversesqrt';
THREE.Math1Node.SQRT = 'sqrt';
THREE.Math1Node.INV_SQRT = 'inversesqrt';
THREE.Math1Node.FLOOR = 'floor';
THREE.Math1Node.CEIL = 'ceil';
THREE.Math1Node.NORMALIZE = 'normalize';
......@@ -42,7 +43,7 @@ THREE.Math1Node.prototype.constructor = THREE.Math1Node;
THREE.Math1Node.prototype.getType = function( builder ) {
switch ( this.method ) {
case THREE.Math1Node.DISTANCE:
case THREE.Math1Node.LENGTH:
return 'fv1';
}
......
......@@ -4,7 +4,7 @@
THREE.SwitchNode = function( node, components ) {
THREE.GLNode.call( this, 'fv1' );
THREE.GLNode.call( this );
this.node = node;
this.components = components || 'x';
......@@ -24,45 +24,49 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
var type = this.node.getType( builder );
var inputLength = builder.getFormatLength( type ) - 1;
var components = builder.colorToVector( this.components );
var node = this.node.build( builder, type );
var outputLength = 0;
if ( inputLength > 0 ) {
var i, len = components.length;
// get max length
// get max length
var outputLength = 0;
var components = builder.colorToVector( this.components );
for ( i = 0; i < len; i ++ ) {
var i, len = components.length;
outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) );
for ( i = 0; i < len; i ++ ) {
}
outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) );
if ( outputLength > inputLength ) outputLength = inputLength;
}
// build switch
if ( outputLength > inputLength ) outputLength = inputLength;
node += '.';
// split
for ( i = 0; i < len; i ++ ) {
node += '.';
var elm = components.charAt( i );
var idx = builder.getIndexByElement( components.charAt( i ) );
for ( i = 0; i < len; i ++ ) {
if ( idx > outputLength ) idx = outputLength;
var elm = components.charAt( i );
var idx = builder.getIndexByElement( components.charAt( i ) );
if ( builder.getElementByIndex( idx ) == undefined ) {
if ( idx > outputLength ) idx = outputLength;
console.log( builder.getElementByIndex( idx ) );
node += builder.getElementByIndex( idx );
}
node += builder.getElementByIndex( idx );
return builder.format( node, this.getType( builder ), output );
}
} else {
return builder.format( node, this.getType( builder ), output );
// join
return builder.format( node, type, output )
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册