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

Merge pull request #16606 from DanielSturk/fix-functionNodes

Fixed bug with nested FunctionNodes (or ExpressionNodes) looping infinitely
......@@ -85,7 +85,13 @@ FunctionNode.prototype.generate = function ( builder, output ) {
}
while ( match = propertiesRegexp.exec( this.src ) ) {
var matches = [];
while ( match = propertiesRegexp.exec( this.src ) ) matches.push( match );
for ( var i = 0; i < matches.length; i++ ) {
var match = matches[i];
var prop = match[ 0 ],
isGlobal = this.isMethod ? ! this.getInputByName( prop ) : true,
......
......@@ -2198,11 +2198,14 @@
var speed = new THREE.FloatNode( .5 );
mtl.color = new THREE.ExpressionNode( "myCustomUv + (sin(time*speed)*.5) + (position * .05)", "vec3" );
mtl.color.keywords[ "speed" ] = speed;
var myspeed = new THREE.ExpressionNode( "speed * time", "float" );
myspeed.keywords[ "speed" ] = speed;
mtl.position = new THREE.ExpressionNode( "mod(time*speed,1.0) < 0.5 ? position + (worldNormal*(1.0+sin(time*speed*1.0))*3.0) : position + sin( position.x * sin(time*speed*2.0))", "vec3" );
mtl.position.keywords[ "speed" ] = speed;
mtl.color = new THREE.ExpressionNode( "myCustomUv + (sin(myspeed)*.5) + (position * .05)", "vec3" );
mtl.color.keywords[ "myspeed" ] = myspeed;
mtl.position = new THREE.ExpressionNode( "mod(myspeed,1.0) < 0.5 ? position + (worldNormal*(1.0+sin(myspeed*1.0))*3.0) : position + sin( position.x * sin(myspeed*2.0))", "vec3" );
mtl.position.keywords[ "myspeed" ] = myspeed;
// add global keyword ( variable or const )
THREE.NodeLib.addKeyword( 'myCustomUv', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册