mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
This commit is contained in:
parent
f0f62670c5
commit
7e26256cac
4563 changed files with 1246712 additions and 17558 deletions
13
node_modules/three/examples/jsm/nodes/utils/BypassNode.d.ts
generated
vendored
Normal file
13
node_modules/three/examples/jsm/nodes/utils/BypassNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Node } from '../core/Node';
|
||||
|
||||
export class BypassNode extends Node {
|
||||
|
||||
constructor( code: Node, value?: Node );
|
||||
|
||||
code: Node;
|
||||
value: Node | undefined;
|
||||
nodeType: string;
|
||||
|
||||
copy( source: BypassNode ): this;
|
||||
|
||||
}
|
83
node_modules/three/examples/jsm/nodes/utils/BypassNode.js
generated
vendored
Normal file
83
node_modules/three/examples/jsm/nodes/utils/BypassNode.js
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
import { Node } from '../core/Node.js';
|
||||
|
||||
function BypassNode( code, value ) {
|
||||
|
||||
Node.call( this );
|
||||
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
|
||||
}
|
||||
|
||||
BypassNode.prototype = Object.create( Node.prototype );
|
||||
BypassNode.prototype.constructor = BypassNode;
|
||||
BypassNode.prototype.nodeType = 'Bypass';
|
||||
|
||||
BypassNode.prototype.getType = function ( builder ) {
|
||||
|
||||
if ( this.value ) {
|
||||
|
||||
return this.value.getType( builder );
|
||||
|
||||
} else if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
return 'f';
|
||||
|
||||
}
|
||||
|
||||
return 'void';
|
||||
|
||||
};
|
||||
|
||||
BypassNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
var code = this.code.build( builder, output ) + ';';
|
||||
|
||||
builder.addNodeCode( code );
|
||||
|
||||
if ( builder.isShader( 'vertex' ) ) {
|
||||
|
||||
if ( this.value ) {
|
||||
|
||||
return this.value.build( builder, output );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return this.value ? this.value.build( builder, output ) : builder.format( '0.0', 'f', output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BypassNode.prototype.copy = function ( source ) {
|
||||
|
||||
Node.prototype.copy.call( this, source );
|
||||
|
||||
this.code = source.code;
|
||||
this.value = source.value;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
BypassNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.code = this.code.toJSON( meta ).uuid;
|
||||
|
||||
if ( this.value ) data.value = this.value.toJSON( meta ).uuid;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { BypassNode };
|
57
node_modules/three/examples/jsm/nodes/utils/ColorSpaceNode.d.ts
generated
vendored
Normal file
57
node_modules/three/examples/jsm/nodes/utils/ColorSpaceNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
import { Node } from '../core/Node';
|
||||
import { TempNode } from '../core/TempNode';
|
||||
import { FunctionNode } from '../core/FunctionNode';
|
||||
|
||||
export class ColorSpaceNode extends TempNode {
|
||||
|
||||
constructor( input: Node, method?: string );
|
||||
|
||||
input: Node;
|
||||
method: string | undefined;
|
||||
nodeType: string;
|
||||
|
||||
fromEncoding( encoding: number ): void;
|
||||
fromDecoding( encoding: number ): void;
|
||||
copy( source: ColorSpaceNode ): this;
|
||||
|
||||
static Nodes: {
|
||||
LinearToLinear: FunctionNode;
|
||||
GammaToLinear: FunctionNode;
|
||||
LinearToGamma: FunctionNode;
|
||||
sRGBToLinear: FunctionNode;
|
||||
LinearTosRGB: FunctionNode;
|
||||
RGBEToLinear: FunctionNode;
|
||||
LinearToRGBE: FunctionNode;
|
||||
RGBMToLinear: FunctionNode;
|
||||
LinearToRGBM: FunctionNode;
|
||||
RGBDToLinear: FunctionNode;
|
||||
LinearToRGBD: FunctionNode;
|
||||
cLogLuvM: FunctionNode;
|
||||
LinearToLogLuv: FunctionNode;
|
||||
cLogLuvInverseM: FunctionNode;
|
||||
LogLuvToLinear: FunctionNode;
|
||||
};
|
||||
|
||||
static LINEAR_TO_LINEAR: string;
|
||||
|
||||
static GAMMA_TO_LINEAR: string;
|
||||
static LINEAR_TO_GAMMA: string;
|
||||
|
||||
static SRGB_TO_LINEAR: string;
|
||||
static LINEAR_TO_SRGB: string;
|
||||
|
||||
static RGBE_TO_LINEAR: string;
|
||||
static LINEAR_TO_RGBE: string;
|
||||
|
||||
static RGBM_TO_LINEAR: string;
|
||||
static LINEAR_TO_RGBM: string;
|
||||
|
||||
static RGBD_TO_LINEAR: string;
|
||||
static LINEAR_TO_RGBD: string;
|
||||
|
||||
static LINEAR_TO_LOG_LUV: string;
|
||||
static LOG_LUV_TO_LINEAR: string;
|
||||
|
||||
static getEncodingComponents( encoding: number ): any[];
|
||||
|
||||
}
|
316
node_modules/three/examples/jsm/nodes/utils/ColorSpaceNode.js
generated
vendored
Normal file
316
node_modules/three/examples/jsm/nodes/utils/ColorSpaceNode.js
generated
vendored
Normal file
|
@ -0,0 +1,316 @@
|
|||
import {
|
||||
GammaEncoding,
|
||||
LinearEncoding,
|
||||
RGBEEncoding,
|
||||
RGBM7Encoding,
|
||||
RGBM16Encoding,
|
||||
RGBDEncoding,
|
||||
sRGBEncoding
|
||||
} from '../../../../build/three.module.js';
|
||||
|
||||
import { TempNode } from '../core/TempNode.js';
|
||||
import { ConstNode } from '../core/ConstNode.js';
|
||||
import { FloatNode } from '../inputs/FloatNode.js';
|
||||
import { FunctionNode } from '../core/FunctionNode.js';
|
||||
import { ExpressionNode } from '../core/ExpressionNode.js';
|
||||
|
||||
function ColorSpaceNode( input, method ) {
|
||||
|
||||
TempNode.call( this, 'v4' );
|
||||
|
||||
this.input = input;
|
||||
|
||||
this.method = method || ColorSpaceNode.LINEAR_TO_LINEAR;
|
||||
|
||||
}
|
||||
|
||||
ColorSpaceNode.Nodes = ( function () {
|
||||
|
||||
// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/
|
||||
|
||||
var LinearToLinear = new FunctionNode( [
|
||||
'vec4 LinearToLinear( in vec4 value ) {',
|
||||
|
||||
' return value;',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var GammaToLinear = new FunctionNode( [
|
||||
'vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {',
|
||||
|
||||
' return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var LinearToGamma = new FunctionNode( [
|
||||
'vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {',
|
||||
|
||||
' return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var sRGBToLinear = new FunctionNode( [
|
||||
'vec4 sRGBToLinear( in vec4 value ) {',
|
||||
|
||||
' return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var LinearTosRGB = new FunctionNode( [
|
||||
'vec4 LinearTosRGB( in vec4 value ) {',
|
||||
|
||||
' return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var RGBEToLinear = new FunctionNode( [
|
||||
'vec4 RGBEToLinear( in vec4 value ) {',
|
||||
|
||||
' return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var LinearToRGBE = new FunctionNode( [
|
||||
'vec4 LinearToRGBE( in vec4 value ) {',
|
||||
|
||||
' float maxComponent = max( max( value.r, value.g ), value.b );',
|
||||
' float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );',
|
||||
' return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );',
|
||||
// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
|
||||
|
||||
var RGBMToLinear = new FunctionNode( [
|
||||
'vec3 RGBMToLinear( in vec4 value, in float maxRange ) {',
|
||||
|
||||
' return vec4( value.xyz * value.w * maxRange, 1.0 );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
var LinearToRGBM = new FunctionNode( [
|
||||
'vec3 LinearToRGBM( in vec4 value, in float maxRange ) {',
|
||||
|
||||
' float maxRGB = max( value.x, max( value.g, value.b ) );',
|
||||
' float M = clamp( maxRGB / maxRange, 0.0, 1.0 );',
|
||||
' M = ceil( M * 255.0 ) / 255.0;',
|
||||
' return vec4( value.rgb / ( M * maxRange ), M );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
|
||||
|
||||
var RGBDToLinear = new FunctionNode( [
|
||||
'vec3 RGBDToLinear( in vec4 value, in float maxRange ) {',
|
||||
|
||||
' return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
|
||||
var LinearToRGBD = new FunctionNode( [
|
||||
'vec3 LinearToRGBD( in vec4 value, in float maxRange ) {',
|
||||
|
||||
' float maxRGB = max( value.x, max( value.g, value.b ) );',
|
||||
' float D = max( maxRange / maxRGB, 1.0 );',
|
||||
' D = clamp( floor( D ) / 255.0, 0.0, 1.0 );',
|
||||
' return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
|
||||
|
||||
// M matrix, for encoding
|
||||
|
||||
var cLogLuvM = new ConstNode( 'const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );' );
|
||||
|
||||
var LinearToLogLuv = new FunctionNode( [
|
||||
'vec4 LinearToLogLuv( in vec4 value ) {',
|
||||
|
||||
' vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;',
|
||||
' Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));',
|
||||
' vec4 vResult;',
|
||||
' vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;',
|
||||
' float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;',
|
||||
' vResult.w = fract(Le);',
|
||||
' vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;',
|
||||
' return vResult;',
|
||||
|
||||
'}'
|
||||
].join( '\n' ), [ cLogLuvM ] );
|
||||
|
||||
// Inverse M matrix, for decoding
|
||||
|
||||
var cLogLuvInverseM = new ConstNode( 'const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );' );
|
||||
|
||||
var LogLuvToLinear = new FunctionNode( [
|
||||
'vec4 LogLuvToLinear( in vec4 value ) {',
|
||||
|
||||
' float Le = value.z * 255.0 + value.w;',
|
||||
' vec3 Xp_Y_XYZp;',
|
||||
' Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);',
|
||||
' Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;',
|
||||
' Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;',
|
||||
' vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;',
|
||||
' return vec4( max(vRGB, 0.0), 1.0 );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ), [ cLogLuvInverseM ] );
|
||||
|
||||
return {
|
||||
LinearToLinear: LinearToLinear,
|
||||
GammaToLinear: GammaToLinear,
|
||||
LinearToGamma: LinearToGamma,
|
||||
sRGBToLinear: sRGBToLinear,
|
||||
LinearTosRGB: LinearTosRGB,
|
||||
RGBEToLinear: RGBEToLinear,
|
||||
LinearToRGBE: LinearToRGBE,
|
||||
RGBMToLinear: RGBMToLinear,
|
||||
LinearToRGBM: LinearToRGBM,
|
||||
RGBDToLinear: RGBDToLinear,
|
||||
LinearToRGBD: LinearToRGBD,
|
||||
cLogLuvM: cLogLuvM,
|
||||
LinearToLogLuv: LinearToLogLuv,
|
||||
cLogLuvInverseM: cLogLuvInverseM,
|
||||
LogLuvToLinear: LogLuvToLinear
|
||||
};
|
||||
|
||||
} )();
|
||||
|
||||
ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
|
||||
|
||||
ColorSpaceNode.GAMMA_TO_LINEAR = 'GammaToLinear';
|
||||
ColorSpaceNode.LINEAR_TO_GAMMA = 'LinearToGamma';
|
||||
|
||||
ColorSpaceNode.SRGB_TO_LINEAR = 'sRGBToLinear';
|
||||
ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB';
|
||||
|
||||
ColorSpaceNode.RGBE_TO_LINEAR = 'RGBEToLinear';
|
||||
ColorSpaceNode.LINEAR_TO_RGBE = 'LinearToRGBE';
|
||||
|
||||
ColorSpaceNode.RGBM_TO_LINEAR = 'RGBMToLinear';
|
||||
ColorSpaceNode.LINEAR_TO_RGBM = 'LinearToRGBM';
|
||||
|
||||
ColorSpaceNode.RGBD_TO_LINEAR = 'RGBDToLinear';
|
||||
ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD';
|
||||
|
||||
ColorSpaceNode.LINEAR_TO_LOG_LUV = 'LinearToLogLuv';
|
||||
ColorSpaceNode.LOG_LUV_TO_LINEAR = 'LogLuvToLinear';
|
||||
|
||||
ColorSpaceNode.getEncodingComponents = function ( encoding ) {
|
||||
|
||||
switch ( encoding ) {
|
||||
|
||||
case LinearEncoding:
|
||||
return [ 'Linear' ];
|
||||
case sRGBEncoding:
|
||||
return [ 'sRGB' ];
|
||||
case RGBEEncoding:
|
||||
return [ 'RGBE' ];
|
||||
case RGBM7Encoding:
|
||||
return [ 'RGBM', new FloatNode( 7.0 ).setReadonly( true ) ];
|
||||
case RGBM16Encoding:
|
||||
return [ 'RGBM', new FloatNode( 16.0 ).setReadonly( true ) ];
|
||||
case RGBDEncoding:
|
||||
return [ 'RGBD', new FloatNode( 256.0 ).setReadonly( true ) ];
|
||||
case GammaEncoding:
|
||||
return [ 'Gamma', new ExpressionNode( 'float( GAMMA_FACTOR )', 'f' ) ];
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ColorSpaceNode.prototype = Object.create( TempNode.prototype );
|
||||
ColorSpaceNode.prototype.constructor = ColorSpaceNode;
|
||||
ColorSpaceNode.prototype.nodeType = 'ColorSpace';
|
||||
ColorSpaceNode.prototype.hashProperties = [ 'method' ];
|
||||
|
||||
ColorSpaceNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
var input = this.input.build( builder, 'v4' );
|
||||
var outputType = this.getType( builder );
|
||||
|
||||
var methodNode = ColorSpaceNode.Nodes[ this.method ];
|
||||
var method = builder.include( methodNode );
|
||||
|
||||
if ( method === ColorSpaceNode.LINEAR_TO_LINEAR ) {
|
||||
|
||||
return builder.format( input, outputType, output );
|
||||
|
||||
} else {
|
||||
|
||||
if ( methodNode.inputs.length === 2 ) {
|
||||
|
||||
var factor = this.factor.build( builder, 'f' );
|
||||
|
||||
return builder.format( method + '( ' + input + ', ' + factor + ' )', outputType, output );
|
||||
|
||||
} else {
|
||||
|
||||
return builder.format( method + '( ' + input + ' )', outputType, output );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ColorSpaceNode.prototype.fromEncoding = function ( encoding ) {
|
||||
|
||||
var components = ColorSpaceNode.getEncodingComponents( encoding );
|
||||
|
||||
this.method = 'LinearTo' + components[ 0 ];
|
||||
this.factor = components[ 1 ];
|
||||
|
||||
};
|
||||
|
||||
ColorSpaceNode.prototype.fromDecoding = function ( encoding ) {
|
||||
|
||||
var components = ColorSpaceNode.getEncodingComponents( encoding );
|
||||
|
||||
this.method = components[ 0 ] + 'ToLinear';
|
||||
this.factor = components[ 1 ];
|
||||
|
||||
};
|
||||
|
||||
ColorSpaceNode.prototype.copy = function ( source ) {
|
||||
|
||||
TempNode.prototype.copy.call( this, source );
|
||||
|
||||
this.input = source.input;
|
||||
this.method = source.method;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
ColorSpaceNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.input = this.input.toJSON( meta ).uuid;
|
||||
data.method = this.method;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { ColorSpaceNode };
|
16
node_modules/three/examples/jsm/nodes/utils/JoinNode.d.ts
generated
vendored
Normal file
16
node_modules/three/examples/jsm/nodes/utils/JoinNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { TempNode } from '../core/TempNode';
|
||||
|
||||
export class JoinNode extends TempNode {
|
||||
|
||||
constructor( x: Node, y: Node, z?: Node, w?: Node );
|
||||
|
||||
x: Node;
|
||||
y: Node;
|
||||
z: Node | undefined;
|
||||
w: Node | undefined;
|
||||
nodeType: string;
|
||||
|
||||
getNumElements(): number;
|
||||
copy( source: JoinNode ): this;
|
||||
|
||||
}
|
112
node_modules/three/examples/jsm/nodes/utils/JoinNode.js
generated
vendored
Normal file
112
node_modules/three/examples/jsm/nodes/utils/JoinNode.js
generated
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
import { TempNode } from '../core/TempNode.js';
|
||||
import { NodeUtils } from '../core/NodeUtils.js';
|
||||
|
||||
var inputs = NodeUtils.elements;
|
||||
|
||||
function JoinNode( x, y, z, w ) {
|
||||
|
||||
TempNode.call( this, 'f' );
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
|
||||
}
|
||||
|
||||
JoinNode.prototype = Object.create( TempNode.prototype );
|
||||
JoinNode.prototype.constructor = JoinNode;
|
||||
JoinNode.prototype.nodeType = 'Join';
|
||||
|
||||
JoinNode.prototype.getNumElements = function () {
|
||||
|
||||
var i = inputs.length;
|
||||
|
||||
while ( i -- ) {
|
||||
|
||||
if ( this[ inputs[ i ] ] !== undefined ) {
|
||||
|
||||
++ i;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Math.max( i, 2 );
|
||||
|
||||
};
|
||||
|
||||
JoinNode.prototype.getType = function ( builder ) {
|
||||
|
||||
return builder.getTypeFromLength( this.getNumElements() );
|
||||
|
||||
};
|
||||
|
||||
JoinNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
var type = this.getType( builder ),
|
||||
length = this.getNumElements(),
|
||||
outputs = [];
|
||||
|
||||
for ( var i = 0; i < length; i ++ ) {
|
||||
|
||||
var elm = this[ inputs[ i ] ];
|
||||
|
||||
outputs.push( elm ? elm.build( builder, 'f' ) : '0.0' );
|
||||
|
||||
}
|
||||
|
||||
var code = ( length > 1 ? builder.getConstructorFromLength( length ) : '' ) + '( ' + outputs.join( ', ' ) + ' )';
|
||||
|
||||
return builder.format( code, type, output );
|
||||
|
||||
};
|
||||
|
||||
JoinNode.prototype.copy = function ( source ) {
|
||||
|
||||
TempNode.prototype.copy.call( this, source );
|
||||
|
||||
for ( var prop in source.inputs ) {
|
||||
|
||||
this[ prop ] = source.inputs[ prop ];
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
JoinNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.inputs = {};
|
||||
|
||||
var length = this.getNumElements();
|
||||
|
||||
for ( var i = 0; i < length; i ++ ) {
|
||||
|
||||
var elm = this[ inputs[ i ] ];
|
||||
|
||||
if ( elm ) {
|
||||
|
||||
data.inputs[ inputs[ i ] ] = elm.toJSON( meta ).uuid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { JoinNode };
|
13
node_modules/three/examples/jsm/nodes/utils/MaxMIPLevelNode.d.ts
generated
vendored
Normal file
13
node_modules/three/examples/jsm/nodes/utils/MaxMIPLevelNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { FloatNode } from '../inputs/FloatNode';
|
||||
import { Node } from '../core/Node';
|
||||
|
||||
export class MaxMIPLevelNode extends FloatNode {
|
||||
|
||||
constructor( texture: Node );
|
||||
|
||||
texture: Node;
|
||||
maxMIPLevel: number;
|
||||
nodeType: string;
|
||||
value: number;
|
||||
|
||||
}
|
59
node_modules/three/examples/jsm/nodes/utils/MaxMIPLevelNode.js
generated
vendored
Normal file
59
node_modules/three/examples/jsm/nodes/utils/MaxMIPLevelNode.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { FloatNode } from '../inputs/FloatNode.js';
|
||||
|
||||
function MaxMIPLevelNode( texture ) {
|
||||
|
||||
FloatNode.call( this );
|
||||
|
||||
this.texture = texture;
|
||||
|
||||
this.maxMIPLevel = 0;
|
||||
|
||||
}
|
||||
|
||||
MaxMIPLevelNode.prototype = Object.create( FloatNode.prototype );
|
||||
MaxMIPLevelNode.prototype.constructor = MaxMIPLevelNode;
|
||||
MaxMIPLevelNode.prototype.nodeType = 'MaxMIPLevel';
|
||||
|
||||
Object.defineProperties( MaxMIPLevelNode.prototype, {
|
||||
|
||||
value: {
|
||||
|
||||
get: function () {
|
||||
|
||||
if ( this.maxMIPLevel === 0 ) {
|
||||
|
||||
var image = this.texture.value.image;
|
||||
|
||||
if ( Array.isArray( image ) ) image = image[ 0 ];
|
||||
|
||||
this.maxMIPLevel = image !== undefined ? Math.log( Math.max( image.width, image.height ) ) * Math.LOG2E : 0;
|
||||
|
||||
}
|
||||
|
||||
return this.maxMIPLevel;
|
||||
|
||||
},
|
||||
|
||||
set: function () { }
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
MaxMIPLevelNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.texture = this.texture.uuid;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { MaxMIPLevelNode };
|
19
node_modules/three/examples/jsm/nodes/utils/SpecularMIPLevelNode.d.ts
generated
vendored
Normal file
19
node_modules/three/examples/jsm/nodes/utils/SpecularMIPLevelNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { TempNode } from '../core/TempNode';
|
||||
import { MaxMIPLevelNode } from '../utils/MaxMIPLevelNode';
|
||||
import { FunctionNode } from '../core/FunctionNode';
|
||||
|
||||
export class SpecularMIPLevelNode extends TempNode {
|
||||
|
||||
constructor( texture: Node );
|
||||
|
||||
texture: Node;
|
||||
maxMIPLevel: MaxMIPLevelNode;
|
||||
nodeType: string;
|
||||
|
||||
copy( source: SpecularMIPLevelNode ): this;
|
||||
|
||||
static Nodes: {
|
||||
getSpecularMIPLevel: FunctionNode;
|
||||
};
|
||||
|
||||
}
|
98
node_modules/three/examples/jsm/nodes/utils/SpecularMIPLevelNode.js
generated
vendored
Normal file
98
node_modules/three/examples/jsm/nodes/utils/SpecularMIPLevelNode.js
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
import { TempNode } from '../core/TempNode.js';
|
||||
import { FunctionNode } from '../core/FunctionNode.js';
|
||||
import { MaxMIPLevelNode } from './MaxMIPLevelNode.js';
|
||||
|
||||
function SpecularMIPLevelNode( roughness, texture ) {
|
||||
|
||||
TempNode.call( this, 'f' );
|
||||
|
||||
this.roughness = roughness;
|
||||
this.texture = texture;
|
||||
|
||||
this.maxMIPLevel = undefined;
|
||||
|
||||
}
|
||||
|
||||
SpecularMIPLevelNode.Nodes = ( function () {
|
||||
|
||||
var getSpecularMIPLevel = new FunctionNode( [
|
||||
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
|
||||
'float getSpecularMIPLevel( const in float roughness, const in float maxMIPLevelScalar ) {',
|
||||
|
||||
' float sigma = PI * roughness * roughness / ( 1.0 + roughness );',
|
||||
' float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );',
|
||||
|
||||
// clamp to allowable LOD ranges.
|
||||
' return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );',
|
||||
|
||||
'}'
|
||||
].join( '\n' ) );
|
||||
|
||||
return {
|
||||
getSpecularMIPLevel: getSpecularMIPLevel
|
||||
};
|
||||
|
||||
} )();
|
||||
|
||||
SpecularMIPLevelNode.prototype = Object.create( TempNode.prototype );
|
||||
SpecularMIPLevelNode.prototype.constructor = SpecularMIPLevelNode;
|
||||
SpecularMIPLevelNode.prototype.nodeType = 'SpecularMIPLevel';
|
||||
|
||||
SpecularMIPLevelNode.prototype.setTexture = function ( texture ) {
|
||||
|
||||
this.texture = texture;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
SpecularMIPLevelNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
if ( builder.isShader( 'fragment' ) ) {
|
||||
|
||||
this.maxMIPLevel = this.maxMIPLevel || new MaxMIPLevelNode();
|
||||
this.maxMIPLevel.texture = this.texture;
|
||||
|
||||
var getSpecularMIPLevel = builder.include( SpecularMIPLevelNode.Nodes.getSpecularMIPLevel );
|
||||
|
||||
return builder.format( getSpecularMIPLevel + '( ' + this.roughness.build( builder, 'f' ) + ', ' + this.maxMIPLevel.build( builder, 'f' ) + ' )', this.type, output );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.SpecularMIPLevelNode is not compatible with ' + builder.shader + ' shader.' );
|
||||
|
||||
return builder.format( '0.0', this.type, output );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
SpecularMIPLevelNode.prototype.copy = function ( source ) {
|
||||
|
||||
TempNode.prototype.copy.call( this, source );
|
||||
|
||||
this.texture = source.texture;
|
||||
this.roughness = source.roughness;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
SpecularMIPLevelNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.texture = this.texture;
|
||||
data.roughness = this.roughness;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { SpecularMIPLevelNode };
|
11
node_modules/three/examples/jsm/nodes/utils/SubSlot.d.ts
generated
vendored
Normal file
11
node_modules/three/examples/jsm/nodes/utils/SubSlot.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { TempNode } from '../core/TempNode';
|
||||
|
||||
export class SubSlots extends TempNode {
|
||||
|
||||
constructor( slots?: object );
|
||||
|
||||
slots: Node[];
|
||||
|
||||
copy( source: SubSlots ): this;
|
||||
|
||||
}
|
75
node_modules/three/examples/jsm/nodes/utils/SubSlotNode.js
generated
vendored
Normal file
75
node_modules/three/examples/jsm/nodes/utils/SubSlotNode.js
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
import { TempNode } from '../core/TempNode.js';
|
||||
|
||||
function SubSlotNode( slots ) {
|
||||
|
||||
TempNode.call( this );
|
||||
|
||||
this.slots = slots || {};
|
||||
|
||||
}
|
||||
|
||||
SubSlotNode.prototype = Object.create( TempNode.prototype );
|
||||
SubSlotNode.prototype.constructor = SubSlotNode;
|
||||
SubSlotNode.prototype.nodeType = 'SubSlot';
|
||||
|
||||
SubSlotNode.prototype.getType = function ( builder, output ) {
|
||||
|
||||
return output;
|
||||
|
||||
};
|
||||
|
||||
SubSlotNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
if ( this.slots[ builder.slot ] ) {
|
||||
|
||||
return this.slots[ builder.slot ].build( builder, output );
|
||||
|
||||
}
|
||||
|
||||
return builder.format( '0.0', 'f', output );
|
||||
|
||||
};
|
||||
|
||||
SubSlotNode.prototype.copy = function ( source ) {
|
||||
|
||||
TempNode.prototype.copy.call( this, source );
|
||||
|
||||
for ( var prop in source.slots ) {
|
||||
|
||||
this.slots[ prop ] = source.slots[ prop ];
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
SubSlotNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.slots = {};
|
||||
|
||||
for ( var prop in this.slots ) {
|
||||
|
||||
var slot = this.slots[ prop ];
|
||||
|
||||
if ( slot ) {
|
||||
|
||||
data.slots[ prop ] = slot.toJSON( meta ).uuid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { SubSlotNode };
|
13
node_modules/three/examples/jsm/nodes/utils/SwitchNode.d.ts
generated
vendored
Normal file
13
node_modules/three/examples/jsm/nodes/utils/SwitchNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Node } from '../core/Node';
|
||||
|
||||
export class SwitchNode extends Node {
|
||||
|
||||
constructor( node: Node, components?: string );
|
||||
|
||||
node: Node;
|
||||
components: string;
|
||||
nodeType: string;
|
||||
|
||||
copy( source: SwitchNode ): this;
|
||||
|
||||
}
|
99
node_modules/three/examples/jsm/nodes/utils/SwitchNode.js
generated
vendored
Normal file
99
node_modules/three/examples/jsm/nodes/utils/SwitchNode.js
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
import { Node } from '../core/Node.js';
|
||||
|
||||
function SwitchNode( node, components ) {
|
||||
|
||||
Node.call( this );
|
||||
|
||||
this.node = node;
|
||||
this.components = components || 'x';
|
||||
|
||||
}
|
||||
|
||||
SwitchNode.prototype = Object.create( Node.prototype );
|
||||
SwitchNode.prototype.constructor = SwitchNode;
|
||||
SwitchNode.prototype.nodeType = 'Switch';
|
||||
|
||||
SwitchNode.prototype.getType = function ( builder ) {
|
||||
|
||||
return builder.getTypeFromLength( this.components.length );
|
||||
|
||||
};
|
||||
|
||||
SwitchNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
var type = this.node.getType( builder ),
|
||||
node = this.node.build( builder, type ),
|
||||
inputLength = builder.getTypeLength( type ) - 1;
|
||||
|
||||
if ( inputLength > 0 ) {
|
||||
|
||||
// get max length
|
||||
|
||||
var outputLength = 0,
|
||||
components = builder.colorToVectorProperties( 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 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 );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
SwitchNode.prototype.copy = function ( source ) {
|
||||
|
||||
Node.prototype.copy.call( this, source );
|
||||
|
||||
this.node = source.node;
|
||||
this.components = source.components;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
SwitchNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.node = this.node.toJSON( meta ).uuid;
|
||||
data.components = this.components;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { SwitchNode };
|
21
node_modules/three/examples/jsm/nodes/utils/TimerNode.d.ts
generated
vendored
Normal file
21
node_modules/three/examples/jsm/nodes/utils/TimerNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { NodeFrame } from '../core/NodeFrame';
|
||||
import { FloatNode } from '../inputs/FloatNode';
|
||||
|
||||
export class TimerNode extends FloatNode {
|
||||
|
||||
constructor( scale?: number, scope?: string, timeScale?: boolean );
|
||||
|
||||
scale: number;
|
||||
scope: string;
|
||||
timeScale: boolean;
|
||||
nodeType: string;
|
||||
|
||||
getUnique(): boolean;
|
||||
updateFrame( frame: NodeFrame ): void;
|
||||
copy( source: TimerNode ): this;
|
||||
|
||||
static GLOBAL: string;
|
||||
static LOCAL: string;
|
||||
static DELTA: string;
|
||||
|
||||
}
|
103
node_modules/three/examples/jsm/nodes/utils/TimerNode.js
generated
vendored
Normal file
103
node_modules/three/examples/jsm/nodes/utils/TimerNode.js
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
import { FloatNode } from '../inputs/FloatNode.js';
|
||||
import { NodeLib } from '../core/NodeLib.js';
|
||||
|
||||
function TimerNode( scale, scope, timeScale ) {
|
||||
|
||||
FloatNode.call( this );
|
||||
|
||||
this.scale = scale !== undefined ? scale : 1;
|
||||
this.scope = scope || TimerNode.GLOBAL;
|
||||
|
||||
this.timeScale = timeScale !== undefined ? timeScale : scale !== undefined;
|
||||
|
||||
}
|
||||
|
||||
TimerNode.GLOBAL = 'global';
|
||||
TimerNode.LOCAL = 'local';
|
||||
TimerNode.DELTA = 'delta';
|
||||
|
||||
TimerNode.prototype = Object.create( FloatNode.prototype );
|
||||
TimerNode.prototype.constructor = TimerNode;
|
||||
TimerNode.prototype.nodeType = 'Timer';
|
||||
|
||||
TimerNode.prototype.getReadonly = function () {
|
||||
|
||||
// never use TimerNode as readonly but aways as "uniform"
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
TimerNode.prototype.getUnique = function () {
|
||||
|
||||
// share TimerNode "uniform" input if is used on more time with others TimerNode
|
||||
|
||||
return this.timeScale && ( this.scope === TimerNode.GLOBAL || this.scope === TimerNode.DELTA );
|
||||
|
||||
};
|
||||
|
||||
TimerNode.prototype.updateFrame = function ( frame ) {
|
||||
|
||||
var scale = this.timeScale ? this.scale : 1;
|
||||
|
||||
switch ( this.scope ) {
|
||||
|
||||
case TimerNode.LOCAL:
|
||||
|
||||
this.value += frame.delta * scale;
|
||||
|
||||
break;
|
||||
|
||||
case TimerNode.DELTA:
|
||||
|
||||
this.value = frame.delta * scale;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
this.value = frame.time * scale;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TimerNode.prototype.copy = function ( source ) {
|
||||
|
||||
FloatNode.prototype.copy.call( this, source );
|
||||
|
||||
this.scope = source.scope;
|
||||
this.scale = source.scale;
|
||||
|
||||
this.timeScale = source.timeScale;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
TimerNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.scope = this.scope;
|
||||
data.scale = this.scale;
|
||||
|
||||
data.timeScale = this.timeScale;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
NodeLib.addKeyword( 'time', function () {
|
||||
|
||||
return new TimerNode();
|
||||
|
||||
} );
|
||||
|
||||
export { TimerNode };
|
17
node_modules/three/examples/jsm/nodes/utils/UVTransformNode.d.ts
generated
vendored
Normal file
17
node_modules/three/examples/jsm/nodes/utils/UVTransformNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { ExpressionNode } from '../core/ExpressionNode';
|
||||
import { Matrix3Node } from '../inputs/Matrix3Node';
|
||||
import { UVNode } from '../accessors/UVNode';
|
||||
|
||||
export class UVTransformNode extends ExpressionNode {
|
||||
|
||||
constructor( uv?: UVNode, position?: Matrix3Node );
|
||||
|
||||
uv: UVNode;
|
||||
position: Matrix3Node;
|
||||
|
||||
nodeType: string;
|
||||
|
||||
setUvTransform( tx: number, ty: number, sx: number, sy: number, rotation: number, cx?: number, cy?: number ): void;
|
||||
copy( source: UVTransformNode ): this;
|
||||
|
||||
}
|
64
node_modules/three/examples/jsm/nodes/utils/UVTransformNode.js
generated
vendored
Normal file
64
node_modules/three/examples/jsm/nodes/utils/UVTransformNode.js
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
import { ExpressionNode } from '../core/ExpressionNode.js';
|
||||
import { Matrix3Node } from '../inputs/Matrix3Node.js';
|
||||
import { UVNode } from '../accessors/UVNode.js';
|
||||
|
||||
function UVTransformNode( uv, position ) {
|
||||
|
||||
ExpressionNode.call( this, '( uvTransform * vec3( uvNode, 1 ) ).xy', 'vec2' );
|
||||
|
||||
this.uv = uv || new UVNode();
|
||||
this.position = position || new Matrix3Node();
|
||||
|
||||
}
|
||||
|
||||
UVTransformNode.prototype = Object.create( ExpressionNode.prototype );
|
||||
UVTransformNode.prototype.constructor = UVTransformNode;
|
||||
UVTransformNode.prototype.nodeType = 'UVTransform';
|
||||
|
||||
UVTransformNode.prototype.generate = function ( builder, output ) {
|
||||
|
||||
this.keywords[ 'uvNode' ] = this.uv;
|
||||
this.keywords[ 'uvTransform' ] = this.position;
|
||||
|
||||
return ExpressionNode.prototype.generate.call( this, builder, output );
|
||||
|
||||
};
|
||||
|
||||
UVTransformNode.prototype.setUvTransform = function ( tx, ty, sx, sy, rotation, cx, cy ) {
|
||||
|
||||
cx = cx !== undefined ? cx : .5;
|
||||
cy = cy !== undefined ? cy : .5;
|
||||
|
||||
this.position.value.setUvTransform( tx, ty, sx, sy, rotation, cx, cy );
|
||||
|
||||
};
|
||||
|
||||
UVTransformNode.prototype.copy = function ( source ) {
|
||||
|
||||
ExpressionNode.prototype.copy.call( this, source );
|
||||
|
||||
this.uv = source.uv;
|
||||
this.position = source.position;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
UVTransformNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
data.uv = this.uv.toJSON( meta ).uuid;
|
||||
data.position = this.position.toJSON( meta ).uuid;
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { UVTransformNode };
|
33
node_modules/three/examples/jsm/nodes/utils/VelocityNode.d.ts
generated
vendored
Normal file
33
node_modules/three/examples/jsm/nodes/utils/VelocityNode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
import {
|
||||
Object3D,
|
||||
Vector3
|
||||
} from '../../../../src/Three';
|
||||
|
||||
import { NodeFrame } from '../core/NodeFrame';
|
||||
import { Vector3Node } from '../inputs/Vector3Node';
|
||||
|
||||
export interface VelocityNodeParams {
|
||||
damping: number;
|
||||
spring: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export class VelocityNode extends Vector3Node {
|
||||
|
||||
constructor( target: Object3D, params?: VelocityNodeParams );
|
||||
|
||||
velocity: Vector3;
|
||||
moment: Vector3 | undefined;
|
||||
speed: Vector3 | undefined;
|
||||
springVelocity: Vector3 | undefined;
|
||||
lastVelocity: Vector3 | undefined;
|
||||
|
||||
nodeType: string;
|
||||
|
||||
setParams( params: VelocityNodeParams ): void;
|
||||
setTarget( target: Object3D ): void;
|
||||
updateFrameVelocity( frame: NodeFrame ): void;
|
||||
updateFrame( frame: NodeFrame ): void;
|
||||
copy( source: VelocityNode ): this;
|
||||
|
||||
}
|
174
node_modules/three/examples/jsm/nodes/utils/VelocityNode.js
generated
vendored
Normal file
174
node_modules/three/examples/jsm/nodes/utils/VelocityNode.js
generated
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
import { Vector3 } from '../../../../build/three.module.js';
|
||||
|
||||
import { Vector3Node } from '../inputs/Vector3Node.js';
|
||||
|
||||
function VelocityNode( target, params ) {
|
||||
|
||||
Vector3Node.call( this );
|
||||
|
||||
this.params = {};
|
||||
|
||||
this.velocity = new Vector3();
|
||||
|
||||
this.setTarget( target );
|
||||
this.setParams( params );
|
||||
|
||||
}
|
||||
|
||||
VelocityNode.prototype = Object.create( Vector3Node.prototype );
|
||||
VelocityNode.prototype.constructor = VelocityNode;
|
||||
VelocityNode.prototype.nodeType = 'Velocity';
|
||||
|
||||
VelocityNode.prototype.getReadonly = function ( /*builder*/ ) {
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.setParams = function ( params ) {
|
||||
|
||||
switch ( this.params.type ) {
|
||||
|
||||
case 'elastic':
|
||||
|
||||
delete this.moment;
|
||||
|
||||
delete this.speed;
|
||||
delete this.springVelocity;
|
||||
|
||||
delete this.lastVelocity;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
this.params = params || {};
|
||||
|
||||
switch ( this.params.type ) {
|
||||
|
||||
case 'elastic':
|
||||
|
||||
this.moment = new Vector3();
|
||||
|
||||
this.speed = new Vector3();
|
||||
this.springVelocity = new Vector3();
|
||||
|
||||
this.lastVelocity = new Vector3();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.setTarget = function ( target ) {
|
||||
|
||||
if ( this.target ) {
|
||||
|
||||
delete this.position;
|
||||
delete this.oldPosition;
|
||||
|
||||
}
|
||||
|
||||
this.target = target;
|
||||
|
||||
if ( target ) {
|
||||
|
||||
this.position = target.getWorldPosition( this.position || new Vector3() );
|
||||
this.oldPosition = this.position.clone();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.updateFrameVelocity = function ( /*frame*/ ) {
|
||||
|
||||
if ( this.target ) {
|
||||
|
||||
this.position = this.target.getWorldPosition( this.position || new Vector3() );
|
||||
this.velocity.subVectors( this.position, this.oldPosition );
|
||||
this.oldPosition.copy( this.position );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.updateFrame = function ( frame ) {
|
||||
|
||||
this.updateFrameVelocity( frame );
|
||||
|
||||
switch ( this.params.type ) {
|
||||
|
||||
case 'elastic':
|
||||
|
||||
// convert to real scale: 0 at 1 values
|
||||
var deltaFps = frame.delta * ( this.params.fps || 60 );
|
||||
|
||||
var spring = Math.pow( this.params.spring, deltaFps ),
|
||||
damping = Math.pow( this.params.damping, deltaFps );
|
||||
|
||||
// fix relative frame-rate
|
||||
this.velocity.multiplyScalar( Math.exp( - this.params.damping * deltaFps ) );
|
||||
|
||||
// elastic
|
||||
this.velocity.add( this.springVelocity );
|
||||
this.velocity.add( this.speed.multiplyScalar( damping ).multiplyScalar( 1 - spring ) );
|
||||
|
||||
// speed
|
||||
this.speed.subVectors( this.velocity, this.lastVelocity );
|
||||
|
||||
// spring velocity
|
||||
this.springVelocity.add( this.speed );
|
||||
this.springVelocity.multiplyScalar( spring );
|
||||
|
||||
// moment
|
||||
this.moment.add( this.springVelocity );
|
||||
|
||||
// damping
|
||||
this.moment.multiplyScalar( damping );
|
||||
|
||||
this.lastVelocity.copy( this.velocity );
|
||||
this.value.copy( this.moment );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
this.value.copy( this.velocity );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.copy = function ( source ) {
|
||||
|
||||
Vector3Node.prototype.copy.call( this, source );
|
||||
|
||||
if ( source.target ) this.setTarget( source.target );
|
||||
|
||||
this.setParams( source.params );
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
VelocityNode.prototype.toJSON = function ( meta ) {
|
||||
|
||||
var data = this.getJSONNode( meta );
|
||||
|
||||
if ( ! data ) {
|
||||
|
||||
data = this.createJSONNode( meta );
|
||||
|
||||
if ( this.target ) data.target = this.target.uuid;
|
||||
|
||||
// clone params
|
||||
data.params = JSON.parse( JSON.stringify( this.params ) );
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
export { VelocityNode };
|
Loading…
Add table
Add a link
Reference in a new issue