webvr js meetup initial commit
This commit is contained in:
114
node_modules/three/examples/js/nodes/utils/BlurNode.js
generated
vendored
Normal file
114
node_modules/three/examples/js/nodes/utils/BlurNode.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.BlurNode = function( value, coord, radius, size ) {
|
||||
|
||||
THREE.TempNode.call( this, 'v4' );
|
||||
|
||||
this.requestUpdate = true;
|
||||
|
||||
this.value = value;
|
||||
this.coord = coord || new THREE.UVNode();
|
||||
this.radius = new THREE.Vector2Node( 1, 1 );
|
||||
this.size = size;
|
||||
|
||||
this.blurX = true;
|
||||
this.blurY = true;
|
||||
|
||||
this.horizontal = new THREE.FloatNode( 1 / 64 );
|
||||
this.vertical = new THREE.FloatNode( 1 / 64 );
|
||||
|
||||
};
|
||||
|
||||
THREE.BlurNode.fBlurX = new THREE.FunctionNode( [
|
||||
"vec4 blurX( sampler2D texture, vec2 uv, float s ) {",
|
||||
" vec4 sum = vec4( 0.0 );",
|
||||
" sum += texture2D( texture, vec2( uv.x - 4.0 * s, uv.y ) ) * 0.051;",
|
||||
" sum += texture2D( texture, vec2( uv.x - 3.0 * s, uv.y ) ) * 0.0918;",
|
||||
" sum += texture2D( texture, vec2( uv.x - 2.0 * s, uv.y ) ) * 0.12245;",
|
||||
" sum += texture2D( texture, vec2( uv.x - 1.0 * s, uv.y ) ) * 0.1531;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;",
|
||||
" sum += texture2D( texture, vec2( uv.x + 1.0 * s, uv.y ) ) * 0.1531;",
|
||||
" sum += texture2D( texture, vec2( uv.x + 2.0 * s, uv.y ) ) * 0.12245;",
|
||||
" sum += texture2D( texture, vec2( uv.x + 3.0 * s, uv.y ) ) * 0.0918;",
|
||||
" sum += texture2D( texture, vec2( uv.x + 4.0 * s, uv.y ) ) * 0.051;",
|
||||
" return sum;",
|
||||
"}"
|
||||
].join( "\n" ) );
|
||||
|
||||
THREE.BlurNode.fBlurY = new THREE.FunctionNode( [
|
||||
"vec4 blurY( sampler2D texture, vec2 uv, float s ) {",
|
||||
" vec4 sum = vec4( 0.0 );",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y - 4.0 * s ) ) * 0.051;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y - 3.0 * s ) ) * 0.0918;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y - 2.0 * s ) ) * 0.12245;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y - 1.0 * s ) ) * 0.1531;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y + 1.0 * s ) ) * 0.1531;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y + 2.0 * s ) ) * 0.12245;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y + 3.0 * s ) ) * 0.0918;",
|
||||
" sum += texture2D( texture, vec2( uv.x, uv.y + 4.0 * s ) ) * 0.051;",
|
||||
" return sum;",
|
||||
"}"
|
||||
].join( "\n" ) );
|
||||
|
||||
THREE.BlurNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.BlurNode.prototype.constructor = THREE.BlurNode;
|
||||
|
||||
THREE.BlurNode.prototype.updateFrame = function( delta ) {
|
||||
|
||||
if ( this.size ) {
|
||||
|
||||
this.horizontal.number = this.radius.x / this.size.x;
|
||||
this.vertical.number = this.radius.y / this.size.y;
|
||||
|
||||
} else if ( this.value.value && this.value.value.image ) {
|
||||
|
||||
var image = this.value.value.image;
|
||||
|
||||
this.horizontal.number = this.radius.x / image.width;
|
||||
this.vertical.number = this.radius.y / image.height;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
THREE.BlurNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material, blurX = THREE.BlurNode.fBlurX, blurY = THREE.BlurNode.fBlurY;
|
||||
|
||||
builder.include( blurX );
|
||||
builder.include( blurY );
|
||||
|
||||
if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
var blurCode = [], code;
|
||||
|
||||
if ( this.blurX ) {
|
||||
|
||||
blurCode.push( blurX.name + '(' + this.value.build( builder, 'sampler2D' ) + ',' + this.coord.build( builder, 'v2' ) + ',' + this.horizontal.build( builder, 'fv1' ) + ')' );
|
||||
|
||||
}
|
||||
|
||||
if ( this.blurY ) {
|
||||
|
||||
blurCode.push( blurY.name + '(' + this.value.build( builder, 'sampler2D' ) + ',' + this.coord.build( builder, 'v2' ) + ',' + this.vertical.build( builder, 'fv1' ) + ')' );
|
||||
|
||||
}
|
||||
|
||||
if ( blurCode.length == 2 ) code = '(' + blurCode.join( '+' ) + '/2.0)';
|
||||
else if ( blurCode.length ) code = '(' + blurCode[ 0 ] + ')';
|
||||
else code = 'vec4( 0.0 )';
|
||||
|
||||
return builder.format( code, this.getType( builder ), output );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( "THREE.BlurNode is not compatible with " + builder.shader + " shader." );
|
||||
|
||||
return builder.format( 'vec4( 0.0 )', this.getType( builder ), output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
49
node_modules/three/examples/js/nodes/utils/BumpNode.js
generated
vendored
Normal file
49
node_modules/three/examples/js/nodes/utils/BumpNode.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.BumpNode = function( value, coord, scale ) {
|
||||
|
||||
THREE.TempNode.call( this, 'v3' );
|
||||
|
||||
this.value = value;
|
||||
this.coord = coord || new THREE.UVNode();
|
||||
this.scale = scale || new THREE.Vector2Node( 1, 1 );
|
||||
|
||||
};
|
||||
|
||||
THREE.BumpNode.fBumpToNormal = new THREE.FunctionNode( [
|
||||
"vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, vec2 scale ) {",
|
||||
" vec2 dSTdx = dFdx( uv );",
|
||||
" vec2 dSTdy = dFdy( uv );",
|
||||
" float Hll = texture2D( bumpMap, uv ).x;",
|
||||
" float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;",
|
||||
" float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;",
|
||||
" return vec3( .5 + ( dBx * scale.x ), .5 + ( dBy * scale.y ), 1.0 );",
|
||||
"}"
|
||||
].join( "\n" ), null, { derivatives: true } );
|
||||
|
||||
THREE.BumpNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.BumpNode.prototype.constructor = THREE.BumpNode;
|
||||
|
||||
THREE.BumpNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material, func = THREE.BumpNode.fBumpToNormal;
|
||||
|
||||
builder.include( func );
|
||||
|
||||
if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
return builder.format( func.name + '(' + this.value.build( builder, 'sampler2D' ) + ',' +
|
||||
this.coord.build( builder, 'v2' ) + ',' +
|
||||
this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( "THREE.BumpNode is not compatible with " + builder.shader + " shader." );
|
||||
|
||||
return builder.format( 'vec3( 0.0 )', this.getType( builder ), output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
70
node_modules/three/examples/js/nodes/utils/ColorAdjustmentNode.js
generated
vendored
Normal file
70
node_modules/three/examples/js/nodes/utils/ColorAdjustmentNode.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.ColorAdjustmentNode = function( rgb, adjustment, method ) {
|
||||
|
||||
THREE.TempNode.call( this, 'v3' );
|
||||
|
||||
this.rgb = rgb;
|
||||
this.adjustment = adjustment;
|
||||
|
||||
this.method = method || THREE.ColorAdjustmentNode.SATURATION;
|
||||
|
||||
};
|
||||
|
||||
THREE.ColorAdjustmentNode.SATURATION = 'saturation';
|
||||
THREE.ColorAdjustmentNode.HUE = 'hue';
|
||||
THREE.ColorAdjustmentNode.VIBRANCE = 'vibrance';
|
||||
THREE.ColorAdjustmentNode.BRIGHTNESS = 'brightness';
|
||||
THREE.ColorAdjustmentNode.CONTRAST = 'contrast';
|
||||
|
||||
THREE.ColorAdjustmentNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.ColorAdjustmentNode.prototype.constructor = THREE.ColorAdjustmentNode;
|
||||
|
||||
THREE.ColorAdjustmentNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var rgb = this.rgb.build( builder, 'v3' );
|
||||
var adjustment = this.adjustment.build( builder, 'fv1' );
|
||||
|
||||
var name;
|
||||
|
||||
switch ( this.method ) {
|
||||
|
||||
case THREE.ColorAdjustmentNode.SATURATION:
|
||||
|
||||
name = 'saturation_rgb';
|
||||
|
||||
break;
|
||||
|
||||
case THREE.ColorAdjustmentNode.HUE:
|
||||
|
||||
name = 'hue_rgb';
|
||||
|
||||
break;
|
||||
|
||||
case THREE.ColorAdjustmentNode.VIBRANCE:
|
||||
|
||||
name = 'vibrance_rgb';
|
||||
|
||||
break;
|
||||
|
||||
case THREE.ColorAdjustmentNode.BRIGHTNESS:
|
||||
|
||||
return builder.format( '(' + rgb + '+' + adjustment + ')', this.getType( builder ), output );
|
||||
|
||||
break;
|
||||
|
||||
case THREE.ColorAdjustmentNode.CONTRAST:
|
||||
|
||||
return builder.format( '(' + rgb + '*' + adjustment + ')', this.getType( builder ), output );
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
builder.include( name );
|
||||
|
||||
return builder.format( name + '(' + rgb + ',' + adjustment + ')', this.getType( builder ), output );
|
||||
|
||||
};
|
||||
69
node_modules/three/examples/js/nodes/utils/JoinNode.js
generated
vendored
Normal file
69
node_modules/three/examples/js/nodes/utils/JoinNode.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.JoinNode = function( x, y, z, w ) {
|
||||
|
||||
THREE.TempNode.call( this, 'fv1' );
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
|
||||
};
|
||||
|
||||
THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ];
|
||||
|
||||
THREE.JoinNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.JoinNode.prototype.constructor = THREE.JoinNode;
|
||||
|
||||
THREE.JoinNode.prototype.getNumElements = function() {
|
||||
|
||||
var inputs = THREE.JoinNode.inputs;
|
||||
var i = inputs.length;
|
||||
|
||||
while ( i -- ) {
|
||||
|
||||
if ( this[ inputs[ i ] ] !== undefined ) {
|
||||
|
||||
++ i;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Math.max( i, 2 );
|
||||
|
||||
};
|
||||
|
||||
THREE.JoinNode.prototype.getType = function( builder ) {
|
||||
|
||||
return builder.getFormatFromLength( this.getNumElements() );
|
||||
|
||||
};
|
||||
|
||||
THREE.JoinNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material;
|
||||
|
||||
var type = this.getType( builder );
|
||||
var length = this.getNumElements();
|
||||
|
||||
var inputs = THREE.JoinNode.inputs;
|
||||
var outputs = [];
|
||||
|
||||
for ( var i = 0; i < length; i ++ ) {
|
||||
|
||||
var elm = this[ inputs[ i ] ];
|
||||
|
||||
outputs.push( elm ? elm.build( builder, 'fv1' ) : '0.' );
|
||||
|
||||
}
|
||||
|
||||
var code = ( length > 1 ? builder.getConstructorFromLength( length ) : '' ) + '(' + outputs.join( ',' ) + ')';
|
||||
|
||||
return builder.format( code, type, output );
|
||||
|
||||
};
|
||||
22
node_modules/three/examples/js/nodes/utils/LuminanceNode.js
generated
vendored
Normal file
22
node_modules/three/examples/js/nodes/utils/LuminanceNode.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.LuminanceNode = function( rgb ) {
|
||||
|
||||
THREE.TempNode.call( this, 'fv1' );
|
||||
|
||||
this.rgb = rgb;
|
||||
|
||||
};
|
||||
|
||||
THREE.LuminanceNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.LuminanceNode.prototype.constructor = THREE.LuminanceNode;
|
||||
|
||||
THREE.LuminanceNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
builder.include( 'luminance_rgb' );
|
||||
|
||||
return builder.format( 'luminance_rgb(' + this.rgb.build( builder, 'v3' ) + ')', this.getType( builder ), output );
|
||||
|
||||
};
|
||||
22
node_modules/three/examples/js/nodes/utils/NoiseNode.js
generated
vendored
Normal file
22
node_modules/three/examples/js/nodes/utils/NoiseNode.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.NoiseNode = function( coord ) {
|
||||
|
||||
THREE.TempNode.call( this, 'fv1' );
|
||||
|
||||
this.coord = coord;
|
||||
|
||||
};
|
||||
|
||||
THREE.NoiseNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.NoiseNode.prototype.constructor = THREE.NoiseNode;
|
||||
|
||||
THREE.NoiseNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
builder.include( 'snoise' );
|
||||
|
||||
return builder.format( 'snoise(' + this.coord.build( builder, 'v2' ) + ')', this.getType( builder ), output );
|
||||
|
||||
};
|
||||
42
node_modules/three/examples/js/nodes/utils/NormalMapNode.js
generated
vendored
Normal file
42
node_modules/three/examples/js/nodes/utils/NormalMapNode.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.NormalMapNode = function( value, uv, scale, normal, position ) {
|
||||
|
||||
THREE.TempNode.call( this, 'v3' );
|
||||
|
||||
this.value = value;
|
||||
this.scale = scale || new THREE.FloatNode( 1 );
|
||||
|
||||
this.normal = normal || new THREE.NormalNode( THREE.NormalNode.LOCAL );
|
||||
this.position = position || new THREE.PositionNode( THREE.NormalNode.VIEW );
|
||||
|
||||
};
|
||||
|
||||
THREE.NormalMapNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.NormalMapNode.prototype.constructor = THREE.NormalMapNode;
|
||||
|
||||
THREE.NormalMapNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material;
|
||||
|
||||
builder.include( 'perturbNormal2Arb' );
|
||||
|
||||
if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
return builder.format( 'perturbNormal2Arb(-' + this.position.build( builder, 'v3' ) + ',' +
|
||||
this.normal.build( builder, 'v3' ) + ',' +
|
||||
this.value.build( builder, 'v3' ) + ',' +
|
||||
this.value.coord.build( builder, 'v2' ) + ',' +
|
||||
this.scale.build( builder, 'v2' ) + ')', this.getType( builder ), output );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( "THREE.NormalMapNode is not compatible with " + builder.shader + " shader." );
|
||||
|
||||
return builder.format( 'vec3( 0.0 )', this.getType( builder ), output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
25
node_modules/three/examples/js/nodes/utils/ResolutionNode.js
generated
vendored
Normal file
25
node_modules/three/examples/js/nodes/utils/ResolutionNode.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.ResolutionNode = function( renderer ) {
|
||||
|
||||
THREE.Vector2Node.call( this );
|
||||
|
||||
this.requestUpdate = true;
|
||||
|
||||
this.renderer = renderer;
|
||||
|
||||
};
|
||||
|
||||
THREE.ResolutionNode.prototype = Object.create( THREE.Vector2Node.prototype );
|
||||
THREE.ResolutionNode.prototype.constructor = THREE.ResolutionNode;
|
||||
|
||||
THREE.ResolutionNode.prototype.updateFrame = function( delta ) {
|
||||
|
||||
var size = this.renderer.getSize();
|
||||
|
||||
this.x = size.width;
|
||||
this.y = size.height;
|
||||
|
||||
};
|
||||
64
node_modules/three/examples/js/nodes/utils/RoughnessToBlinnExponentNode.js
generated
vendored
Normal file
64
node_modules/three/examples/js/nodes/utils/RoughnessToBlinnExponentNode.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.RoughnessToBlinnExponentNode = function() {
|
||||
|
||||
THREE.TempNode.call( this, 'fv1' );
|
||||
|
||||
};
|
||||
|
||||
THREE.RoughnessToBlinnExponentNode.getSpecularMIPLevel = new THREE.FunctionNode( [
|
||||
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
|
||||
"float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {",
|
||||
|
||||
//float envMapWidth = pow( 2.0, maxMIPLevelScalar );
|
||||
//float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );
|
||||
"float maxMIPLevelScalar = float( maxMIPLevel );",
|
||||
"float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );",
|
||||
|
||||
// clamp to allowable LOD ranges.
|
||||
"return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );",
|
||||
"}"
|
||||
].join( "\n" ) );
|
||||
|
||||
THREE.RoughnessToBlinnExponentNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.RoughnessToBlinnExponentNode.prototype.constructor = THREE.RoughnessToBlinnExponentNode;
|
||||
|
||||
THREE.RoughnessToBlinnExponentNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material;
|
||||
|
||||
if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
if ( material.isDefined( 'PHYSICAL' ) ) {
|
||||
|
||||
builder.include( THREE.RoughnessToBlinnExponentNode.getSpecularMIPLevel );
|
||||
|
||||
if ( builder.isCache( 'clearCoat' ) ) {
|
||||
|
||||
return builder.format( 'getSpecularMIPLevel( Material_ClearCoat_BlinnShininessExponent( material ), 8 )', this.type, output );
|
||||
|
||||
} else {
|
||||
|
||||
return builder.format( 'getSpecularMIPLevel( Material_BlinnShininessExponent( material ), 8 )', this.type, output );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( "THREE.RoughnessToBlinnExponentNode is only compatible with PhysicalMaterial." );
|
||||
|
||||
return builder.format( '0.0', this.type, output );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( "THREE.RoughnessToBlinnExponentNode is not compatible with " + builder.shader + " shader." );
|
||||
|
||||
return builder.format( '0.0', this.type, output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
72
node_modules/three/examples/js/nodes/utils/SwitchNode.js
generated
vendored
Normal file
72
node_modules/three/examples/js/nodes/utils/SwitchNode.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.SwitchNode = function( node, components ) {
|
||||
|
||||
THREE.GLNode.call( this );
|
||||
|
||||
this.node = node;
|
||||
this.components = components || 'x';
|
||||
|
||||
};
|
||||
|
||||
THREE.SwitchNode.prototype = Object.create( THREE.GLNode.prototype );
|
||||
THREE.SwitchNode.prototype.constructor = THREE.SwitchNode;
|
||||
|
||||
THREE.SwitchNode.prototype.getType = function( builder ) {
|
||||
|
||||
return builder.getFormatFromLength( this.components.length );
|
||||
|
||||
};
|
||||
|
||||
THREE.SwitchNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var type = this.node.getType( builder );
|
||||
var inputLength = builder.getFormatLength( type ) - 1;
|
||||
|
||||
var node = this.node.build( builder, type );
|
||||
|
||||
if ( inputLength > 0 ) {
|
||||
|
||||
// get max length
|
||||
|
||||
var outputLength = 0;
|
||||
var components = builder.colorToVector( this.components );
|
||||
|
||||
var i, len = components.length;
|
||||
|
||||
for ( i = 0; i < len; i ++ ) {
|
||||
|
||||
outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) );
|
||||
|
||||
}
|
||||
|
||||
if ( outputLength > inputLength ) outputLength = inputLength;
|
||||
|
||||
// split
|
||||
|
||||
node += '.';
|
||||
|
||||
for ( i = 0; i < len; i ++ ) {
|
||||
|
||||
var elm = components.charAt( i );
|
||||
var idx = builder.getIndexByElement( components.charAt( i ) );
|
||||
|
||||
if ( idx > outputLength ) idx = outputLength;
|
||||
|
||||
node += builder.getElementByIndex( idx );
|
||||
|
||||
}
|
||||
|
||||
return builder.format( node, this.getType( builder ), output );
|
||||
|
||||
} else {
|
||||
|
||||
// join
|
||||
|
||||
return builder.format( node, type, output )
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
22
node_modules/three/examples/js/nodes/utils/TimerNode.js
generated
vendored
Normal file
22
node_modules/three/examples/js/nodes/utils/TimerNode.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.TimerNode = function( value, scale ) {
|
||||
|
||||
THREE.FloatNode.call( this, value );
|
||||
|
||||
this.requestUpdate = true;
|
||||
|
||||
this.scale = scale !== undefined ? scale : 1;
|
||||
|
||||
};
|
||||
|
||||
THREE.TimerNode.prototype = Object.create( THREE.FloatNode.prototype );
|
||||
THREE.TimerNode.prototype.constructor = THREE.TimerNode;
|
||||
|
||||
THREE.TimerNode.prototype.updateFrame = function( delta ) {
|
||||
|
||||
this.number += delta * this.scale;
|
||||
|
||||
};
|
||||
59
node_modules/three/examples/js/nodes/utils/VelocityNode.js
generated
vendored
Normal file
59
node_modules/three/examples/js/nodes/utils/VelocityNode.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.VelocityNode = function( target, params ) {
|
||||
|
||||
THREE.Vector3Node.call( this );
|
||||
|
||||
this.requestUpdate = true;
|
||||
|
||||
this.target = target;
|
||||
|
||||
this.position = this.target.position.clone();
|
||||
this.velocity = new THREE.Vector3();
|
||||
this.moment = new THREE.Vector3();
|
||||
|
||||
this.params = params || {};
|
||||
|
||||
};
|
||||
|
||||
THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype );
|
||||
THREE.VelocityNode.prototype.constructor = THREE.VelocityNode;
|
||||
|
||||
THREE.VelocityNode.prototype.updateFrame = function( delta ) {
|
||||
|
||||
this.velocity.subVectors( this.target.position, this.position );
|
||||
this.position.copy( this.target.position );
|
||||
|
||||
switch ( this.params.type ) {
|
||||
|
||||
case "elastic":
|
||||
|
||||
delta *= this.params.fps || 60;
|
||||
|
||||
var spring = Math.pow( this.params.spring, delta );
|
||||
var friction = Math.pow( this.params.friction, delta );
|
||||
|
||||
// spring
|
||||
this.moment.x += this.velocity.x * spring;
|
||||
this.moment.y += this.velocity.y * spring;
|
||||
this.moment.z += this.velocity.z * spring;
|
||||
|
||||
// friction
|
||||
this.moment.x *= friction;
|
||||
this.moment.y *= friction;
|
||||
this.moment.z *= friction;
|
||||
|
||||
this.value.copy( this.moment );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
this.value.copy( this.velocity );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user