first commit
This commit is contained in:
39
web-app/node_modules/three/src/nodes/utils/ArrayElementNode.js
generated
vendored
Normal file
39
web-app/node_modules/three/src/nodes/utils/ArrayElementNode.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import Node from '../core/Node.js';
|
||||
|
||||
class ArrayElementNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'ArrayElementNode';
|
||||
|
||||
} // @TODO: If extending from TempNode it breaks webgpu_compute
|
||||
|
||||
constructor( node, indexNode ) {
|
||||
|
||||
super();
|
||||
|
||||
this.node = node;
|
||||
this.indexNode = indexNode;
|
||||
|
||||
this.isArrayElementNode = true;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
return this.node.getElementType( builder );
|
||||
|
||||
}
|
||||
|
||||
generate( builder ) {
|
||||
|
||||
const nodeSnippet = this.node.build( builder );
|
||||
const indexSnippet = this.indexNode.build( builder, 'uint' );
|
||||
|
||||
return `${nodeSnippet}[ ${indexSnippet} ]`;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ArrayElementNode;
|
||||
69
web-app/node_modules/three/src/nodes/utils/ConvertNode.js
generated
vendored
Normal file
69
web-app/node_modules/three/src/nodes/utils/ConvertNode.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import Node from '../core/Node.js';
|
||||
|
||||
class ConvertNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'ConvertNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( node, convertTo ) {
|
||||
|
||||
super();
|
||||
|
||||
this.node = node;
|
||||
this.convertTo = convertTo;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
const requestType = this.node.getNodeType( builder );
|
||||
|
||||
let convertTo = null;
|
||||
|
||||
for ( const overloadingType of this.convertTo.split( '|' ) ) {
|
||||
|
||||
if ( convertTo === null || builder.getTypeLength( requestType ) === builder.getTypeLength( overloadingType ) ) {
|
||||
|
||||
convertTo = overloadingType;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return convertTo;
|
||||
|
||||
}
|
||||
|
||||
serialize( data ) {
|
||||
|
||||
super.serialize( data );
|
||||
|
||||
data.convertTo = this.convertTo;
|
||||
|
||||
}
|
||||
|
||||
deserialize( data ) {
|
||||
|
||||
super.deserialize( data );
|
||||
|
||||
this.convertTo = data.convertTo;
|
||||
|
||||
}
|
||||
|
||||
generate( builder, output ) {
|
||||
|
||||
const node = this.node;
|
||||
const type = this.getNodeType( builder );
|
||||
|
||||
const snippet = node.build( builder, type );
|
||||
|
||||
return builder.format( snippet, type, output );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ConvertNode;
|
||||
160
web-app/node_modules/three/src/nodes/utils/CubeMapNode.js
generated
vendored
Normal file
160
web-app/node_modules/three/src/nodes/utils/CubeMapNode.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { NodeUpdateType } from '../core/constants.js';
|
||||
import { nodeProxy } from '../tsl/TSLBase.js';
|
||||
import { CubeTexture } from '../../textures/CubeTexture.js';
|
||||
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
||||
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
||||
import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js';
|
||||
|
||||
const _cache = new WeakMap();
|
||||
|
||||
class CubeMapNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'CubeMapNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( envNode ) {
|
||||
|
||||
super( 'vec3' );
|
||||
|
||||
this.envNode = envNode;
|
||||
|
||||
this._cubeTexture = null;
|
||||
this._cubeTextureNode = cubeTexture();
|
||||
|
||||
const defaultTexture = new CubeTexture();
|
||||
defaultTexture.isRenderTargetTexture = true;
|
||||
|
||||
this._defaultTexture = defaultTexture;
|
||||
|
||||
this.updateBeforeType = NodeUpdateType.RENDER;
|
||||
|
||||
}
|
||||
|
||||
updateBefore( frame ) {
|
||||
|
||||
const { renderer, material } = frame;
|
||||
|
||||
const envNode = this.envNode;
|
||||
|
||||
if ( envNode.isTextureNode || envNode.isMaterialReferenceNode ) {
|
||||
|
||||
const texture = ( envNode.isTextureNode ) ? envNode.value : material[ envNode.property ];
|
||||
|
||||
if ( texture && texture.isTexture ) {
|
||||
|
||||
const mapping = texture.mapping;
|
||||
|
||||
if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) {
|
||||
|
||||
// check for converted cubemap map
|
||||
|
||||
if ( _cache.has( texture ) ) {
|
||||
|
||||
const cubeMap = _cache.get( texture );
|
||||
|
||||
mapTextureMapping( cubeMap, texture.mapping );
|
||||
this._cubeTexture = cubeMap;
|
||||
|
||||
} else {
|
||||
|
||||
// create cube map from equirectangular map
|
||||
|
||||
const image = texture.image;
|
||||
|
||||
if ( isEquirectangularMapReady( image ) ) {
|
||||
|
||||
const renderTarget = new CubeRenderTarget( image.height );
|
||||
renderTarget.fromEquirectangularTexture( renderer, texture );
|
||||
|
||||
mapTextureMapping( renderTarget.texture, texture.mapping );
|
||||
this._cubeTexture = renderTarget.texture;
|
||||
|
||||
_cache.set( texture, renderTarget.texture );
|
||||
|
||||
texture.addEventListener( 'dispose', onTextureDispose );
|
||||
|
||||
} else {
|
||||
|
||||
// default cube texture as fallback when equirectangular texture is not yet loaded
|
||||
|
||||
this._cubeTexture = this._defaultTexture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this._cubeTextureNode.value = this._cubeTexture;
|
||||
|
||||
} else {
|
||||
|
||||
// envNode already refers to a cube map
|
||||
|
||||
this._cubeTextureNode = this.envNode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
this.updateBefore( builder );
|
||||
|
||||
return this._cubeTextureNode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CubeMapNode;
|
||||
|
||||
function isEquirectangularMapReady( image ) {
|
||||
|
||||
if ( image === null || image === undefined ) return false;
|
||||
|
||||
return image.height > 0;
|
||||
|
||||
}
|
||||
|
||||
function onTextureDispose( event ) {
|
||||
|
||||
const texture = event.target;
|
||||
|
||||
texture.removeEventListener( 'dispose', onTextureDispose );
|
||||
|
||||
const renderTarget = _cache.get( texture );
|
||||
|
||||
if ( renderTarget !== undefined ) {
|
||||
|
||||
_cache.delete( texture );
|
||||
|
||||
renderTarget.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mapTextureMapping( texture, mapping ) {
|
||||
|
||||
if ( mapping === EquirectangularReflectionMapping ) {
|
||||
|
||||
texture.mapping = CubeReflectionMapping;
|
||||
|
||||
} else if ( mapping === EquirectangularRefractionMapping ) {
|
||||
|
||||
texture.mapping = CubeRefractionMapping;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const cubeMapNode = /*@__PURE__*/ nodeProxy( CubeMapNode );
|
||||
8
web-app/node_modules/three/src/nodes/utils/Discard.js
generated
vendored
Normal file
8
web-app/node_modules/three/src/nodes/utils/Discard.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { select } from '../math/ConditionalNode.js';
|
||||
import { expression } from '../code/ExpressionNode.js';
|
||||
import { addMethodChaining } from '../tsl/TSLCore.js';
|
||||
|
||||
export const Discard = ( conditional ) => ( conditional ? select( conditional, expression( 'discard' ) ) : expression( 'discard' ) ).append();
|
||||
export const Return = () => expression( 'return' ).append();
|
||||
|
||||
addMethodChaining( 'discard', Discard );
|
||||
36
web-app/node_modules/three/src/nodes/utils/EquirectUVNode.js
generated
vendored
Normal file
36
web-app/node_modules/three/src/nodes/utils/EquirectUVNode.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { positionWorldDirection } from '../accessors/Position.js';
|
||||
import { nodeProxy, vec2 } from '../tsl/TSLBase.js';
|
||||
|
||||
class EquirectUVNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'EquirectUVNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( dirNode = positionWorldDirection ) {
|
||||
|
||||
super( 'vec2' );
|
||||
|
||||
this.dirNode = dirNode;
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
const dir = this.dirNode;
|
||||
|
||||
const u = dir.z.atan2( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
|
||||
const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
|
||||
|
||||
return vec2( u, v );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EquirectUVNode;
|
||||
|
||||
export const equirectUV = /*@__PURE__*/ nodeProxy( EquirectUVNode );
|
||||
68
web-app/node_modules/three/src/nodes/utils/FlipNode.js
generated
vendored
Normal file
68
web-app/node_modules/three/src/nodes/utils/FlipNode.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { vectorComponents } from '../core/constants.js';
|
||||
|
||||
class FlipNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'FlipNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( sourceNode, components ) {
|
||||
|
||||
super();
|
||||
|
||||
this.sourceNode = sourceNode;
|
||||
this.components = components;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
return this.sourceNode.getNodeType( builder );
|
||||
|
||||
}
|
||||
|
||||
generate( builder ) {
|
||||
|
||||
const { components, sourceNode } = this;
|
||||
|
||||
const sourceType = this.getNodeType( builder );
|
||||
const sourceSnippet = sourceNode.build( builder );
|
||||
|
||||
const sourceCache = builder.getVarFromNode( this );
|
||||
const sourceProperty = builder.getPropertyName( sourceCache );
|
||||
|
||||
builder.addLineFlowCode( sourceProperty + ' = ' + sourceSnippet, this );
|
||||
|
||||
const length = builder.getTypeLength( sourceType );
|
||||
const snippetValues = [];
|
||||
|
||||
let componentIndex = 0;
|
||||
|
||||
for ( let i = 0; i < length; i ++ ) {
|
||||
|
||||
const component = vectorComponents[ i ];
|
||||
|
||||
if ( component === components[ componentIndex ] ) {
|
||||
|
||||
snippetValues.push( '1.0 - ' + ( sourceProperty + '.' + component ) );
|
||||
|
||||
componentIndex ++;
|
||||
|
||||
} else {
|
||||
|
||||
snippetValues.push( sourceProperty + '.' + component );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return `${ builder.getType( sourceType ) }( ${ snippetValues.join( ', ' ) } )`;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default FlipNode;
|
||||
101
web-app/node_modules/three/src/nodes/utils/FunctionOverloadingNode.js
generated
vendored
Normal file
101
web-app/node_modules/three/src/nodes/utils/FunctionOverloadingNode.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { nodeProxy } from '../tsl/TSLBase.js';
|
||||
|
||||
class FunctionOverloadingNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'FunctionOverloadingNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( functionNodes = [], ...parametersNodes ) {
|
||||
|
||||
super();
|
||||
|
||||
this.functionNodes = functionNodes;
|
||||
this.parametersNodes = parametersNodes;
|
||||
|
||||
this._candidateFnCall = null;
|
||||
|
||||
this.global = true;
|
||||
|
||||
}
|
||||
|
||||
getNodeType() {
|
||||
|
||||
return this.functionNodes[ 0 ].shaderNode.layout.type;
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
const params = this.parametersNodes;
|
||||
|
||||
let candidateFnCall = this._candidateFnCall;
|
||||
|
||||
if ( candidateFnCall === null ) {
|
||||
|
||||
let candidateFn = null;
|
||||
let candidateScore = - 1;
|
||||
|
||||
for ( const functionNode of this.functionNodes ) {
|
||||
|
||||
const shaderNode = functionNode.shaderNode;
|
||||
const layout = shaderNode.layout;
|
||||
|
||||
if ( layout === null ) {
|
||||
|
||||
throw new Error( 'FunctionOverloadingNode: FunctionNode must be a layout.' );
|
||||
|
||||
}
|
||||
|
||||
const inputs = layout.inputs;
|
||||
|
||||
if ( params.length === inputs.length ) {
|
||||
|
||||
let score = 0;
|
||||
|
||||
for ( let i = 0; i < params.length; i ++ ) {
|
||||
|
||||
const param = params[ i ];
|
||||
const input = inputs[ i ];
|
||||
|
||||
if ( param.getNodeType( builder ) === input.type ) {
|
||||
|
||||
score ++;
|
||||
|
||||
} else {
|
||||
|
||||
score = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( score > candidateScore ) {
|
||||
|
||||
candidateFn = functionNode;
|
||||
candidateScore = score;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this._candidateFnCall = candidateFnCall = candidateFn( ...params );
|
||||
|
||||
}
|
||||
|
||||
return candidateFnCall;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default FunctionOverloadingNode;
|
||||
|
||||
const overloadingBaseFn = /*@__PURE__*/ nodeProxy( FunctionOverloadingNode );
|
||||
|
||||
export const overloadingFn = ( functionNodes ) => ( ...params ) => overloadingBaseFn( functionNodes, ...params );
|
||||
64
web-app/node_modules/three/src/nodes/utils/JoinNode.js
generated
vendored
Normal file
64
web-app/node_modules/three/src/nodes/utils/JoinNode.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
|
||||
class JoinNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'JoinNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( nodes = [], nodeType = null ) {
|
||||
|
||||
super( nodeType );
|
||||
|
||||
this.nodes = nodes;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
if ( this.nodeType !== null ) {
|
||||
|
||||
return builder.getVectorType( this.nodeType );
|
||||
|
||||
}
|
||||
|
||||
return builder.getTypeFromLength( this.nodes.reduce( ( count, cur ) => count + builder.getTypeLength( cur.getNodeType( builder ) ), 0 ) );
|
||||
|
||||
}
|
||||
|
||||
generate( builder, output ) {
|
||||
|
||||
const type = this.getNodeType( builder );
|
||||
const nodes = this.nodes;
|
||||
|
||||
const primitiveType = builder.getComponentType( type );
|
||||
|
||||
const snippetValues = [];
|
||||
|
||||
for ( const input of nodes ) {
|
||||
|
||||
let inputSnippet = input.build( builder );
|
||||
|
||||
const inputPrimitiveType = builder.getComponentType( input.getNodeType( builder ) );
|
||||
|
||||
if ( inputPrimitiveType !== primitiveType ) {
|
||||
|
||||
inputSnippet = builder.format( inputSnippet, inputPrimitiveType, primitiveType );
|
||||
|
||||
}
|
||||
|
||||
snippetValues.push( inputSnippet );
|
||||
|
||||
}
|
||||
|
||||
const snippet = `${ builder.getType( type ) }( ${ snippetValues.join( ', ' ) } )`;
|
||||
|
||||
return builder.format( snippet, type, output );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default JoinNode;
|
||||
211
web-app/node_modules/three/src/nodes/utils/LoopNode.js
generated
vendored
Normal file
211
web-app/node_modules/three/src/nodes/utils/LoopNode.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { expression } from '../code/ExpressionNode.js';
|
||||
import { nodeObject, nodeArray } from '../tsl/TSLBase.js';
|
||||
|
||||
class LoopNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'LoopNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( params = [] ) {
|
||||
|
||||
super();
|
||||
|
||||
this.params = params;
|
||||
|
||||
}
|
||||
|
||||
getVarName( index ) {
|
||||
|
||||
return String.fromCharCode( 'i'.charCodeAt() + index );
|
||||
|
||||
}
|
||||
|
||||
getProperties( builder ) {
|
||||
|
||||
const properties = builder.getNodeProperties( this );
|
||||
|
||||
if ( properties.stackNode !== undefined ) return properties;
|
||||
|
||||
//
|
||||
|
||||
const inputs = {};
|
||||
|
||||
for ( let i = 0, l = this.params.length - 1; i < l; i ++ ) {
|
||||
|
||||
const param = this.params[ i ];
|
||||
|
||||
const name = ( param.isNode !== true && param.name ) || this.getVarName( i );
|
||||
const type = ( param.isNode !== true && param.type ) || 'int';
|
||||
|
||||
inputs[ name ] = expression( name, type );
|
||||
|
||||
}
|
||||
|
||||
const stack = builder.addStack(); // TODO: cache() it
|
||||
|
||||
properties.returnsNode = this.params[ this.params.length - 1 ]( inputs, stack, builder );
|
||||
properties.stackNode = stack;
|
||||
|
||||
builder.removeStack();
|
||||
|
||||
return properties;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
const { returnsNode } = this.getProperties( builder );
|
||||
|
||||
return returnsNode ? returnsNode.getNodeType( builder ) : 'void';
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
// setup properties
|
||||
|
||||
this.getProperties( builder );
|
||||
|
||||
}
|
||||
|
||||
generate( builder ) {
|
||||
|
||||
const properties = this.getProperties( builder );
|
||||
|
||||
const params = this.params;
|
||||
const stackNode = properties.stackNode;
|
||||
|
||||
for ( let i = 0, l = params.length - 1; i < l; i ++ ) {
|
||||
|
||||
const param = params[ i ];
|
||||
|
||||
let start = null, end = null, name = null, type = null, condition = null, update = null;
|
||||
|
||||
if ( param.isNode ) {
|
||||
|
||||
type = 'int';
|
||||
name = this.getVarName( i );
|
||||
start = '0';
|
||||
end = param.build( builder, type );
|
||||
condition = '<';
|
||||
|
||||
} else {
|
||||
|
||||
type = param.type || 'int';
|
||||
name = param.name || this.getVarName( i );
|
||||
start = param.start;
|
||||
end = param.end;
|
||||
condition = param.condition;
|
||||
update = param.update;
|
||||
|
||||
if ( typeof start === 'number' ) start = builder.generateConst( type, start );
|
||||
else if ( start && start.isNode ) start = start.build( builder, type );
|
||||
|
||||
if ( typeof end === 'number' ) end = builder.generateConst( type, end );
|
||||
else if ( end && end.isNode ) end = end.build( builder, type );
|
||||
|
||||
if ( start !== undefined && end === undefined ) {
|
||||
|
||||
start = start + ' - 1';
|
||||
end = '0';
|
||||
condition = '>=';
|
||||
|
||||
} else if ( end !== undefined && start === undefined ) {
|
||||
|
||||
start = '0';
|
||||
condition = '<';
|
||||
|
||||
}
|
||||
|
||||
if ( condition === undefined ) {
|
||||
|
||||
if ( Number( start ) > Number( end ) ) {
|
||||
|
||||
condition = '>=';
|
||||
|
||||
} else {
|
||||
|
||||
condition = '<';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const internalParam = { start, end, condition };
|
||||
|
||||
//
|
||||
|
||||
const startSnippet = internalParam.start;
|
||||
const endSnippet = internalParam.end;
|
||||
|
||||
let declarationSnippet = '';
|
||||
let conditionalSnippet = '';
|
||||
let updateSnippet = '';
|
||||
|
||||
if ( ! update ) {
|
||||
|
||||
if ( type === 'int' || type === 'uint' ) {
|
||||
|
||||
if ( condition.includes( '<' ) ) update = '++';
|
||||
else update = '--';
|
||||
|
||||
} else {
|
||||
|
||||
if ( condition.includes( '<' ) ) update = '+= 1.';
|
||||
else update = '-= 1.';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declarationSnippet += builder.getVar( type, name ) + ' = ' + startSnippet;
|
||||
|
||||
conditionalSnippet += name + ' ' + condition + ' ' + endSnippet;
|
||||
updateSnippet += name + ' ' + update;
|
||||
|
||||
const forSnippet = `for ( ${ declarationSnippet }; ${ conditionalSnippet }; ${ updateSnippet } )`;
|
||||
|
||||
builder.addFlowCode( ( i === 0 ? '\n' : '' ) + builder.tab + forSnippet + ' {\n\n' ).addFlowTab();
|
||||
|
||||
}
|
||||
|
||||
const stackSnippet = stackNode.build( builder, 'void' );
|
||||
|
||||
const returnsSnippet = properties.returnsNode ? properties.returnsNode.build( builder ) : '';
|
||||
|
||||
builder.removeFlowTab().addFlowCode( '\n' + builder.tab + stackSnippet );
|
||||
|
||||
for ( let i = 0, l = this.params.length - 1; i < l; i ++ ) {
|
||||
|
||||
builder.addFlowCode( ( i === 0 ? '' : builder.tab ) + '}\n\n' ).removeFlowTab();
|
||||
|
||||
}
|
||||
|
||||
builder.addFlowTab();
|
||||
|
||||
return returnsSnippet;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LoopNode;
|
||||
|
||||
export const Loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params, 'int' ) ) ).append();
|
||||
export const Continue = () => expression( 'continue' ).append();
|
||||
export const Break = () => expression( 'break' ).append();
|
||||
|
||||
//
|
||||
|
||||
export const loop = ( ...params ) => { // @deprecated, r168
|
||||
|
||||
console.warn( 'TSL.LoopNode: loop() has been renamed to Loop().' );
|
||||
return Loop( ...params );
|
||||
|
||||
};
|
||||
33
web-app/node_modules/three/src/nodes/utils/MatcapUVNode.js
generated
vendored
Normal file
33
web-app/node_modules/three/src/nodes/utils/MatcapUVNode.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { transformedNormalView } from '../accessors/Normal.js';
|
||||
import { positionViewDirection } from '../accessors/Position.js';
|
||||
import { nodeImmutable, vec2, vec3 } from '../tsl/TSLBase.js';
|
||||
|
||||
class MatcapUVNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'MatcapUVNode';
|
||||
|
||||
}
|
||||
|
||||
constructor() {
|
||||
|
||||
super( 'vec2' );
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize();
|
||||
const y = positionViewDirection.cross( x );
|
||||
|
||||
return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 ); // 0.495 to remove artifacts caused by undersized matcap disks
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default MatcapUVNode;
|
||||
|
||||
export const matcapUV = /*@__PURE__*/ nodeImmutable( MatcapUVNode );
|
||||
55
web-app/node_modules/three/src/nodes/utils/MaxMipLevelNode.js
generated
vendored
Normal file
55
web-app/node_modules/three/src/nodes/utils/MaxMipLevelNode.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import UniformNode from '../core/UniformNode.js';
|
||||
import { NodeUpdateType } from '../core/constants.js';
|
||||
import { nodeProxy } from '../tsl/TSLBase.js';
|
||||
|
||||
class MaxMipLevelNode extends UniformNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'MaxMipLevelNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( textureNode ) {
|
||||
|
||||
super( 0 );
|
||||
|
||||
this._textureNode = textureNode;
|
||||
|
||||
this.updateType = NodeUpdateType.FRAME;
|
||||
|
||||
}
|
||||
|
||||
get textureNode() {
|
||||
|
||||
return this._textureNode;
|
||||
|
||||
}
|
||||
|
||||
get texture() {
|
||||
|
||||
return this._textureNode.value;
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
const texture = this.texture;
|
||||
const images = texture.images;
|
||||
const image = ( images && images.length > 0 ) ? ( ( images[ 0 ] && images[ 0 ].image ) || images[ 0 ] ) : texture.image;
|
||||
|
||||
if ( image && image.width !== undefined ) {
|
||||
|
||||
const { width, height } = image;
|
||||
|
||||
this.value = Math.log2( Math.max( width, height ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default MaxMipLevelNode;
|
||||
|
||||
export const maxMipLevel = /*@__PURE__*/ nodeProxy( MaxMipLevelNode );
|
||||
6
web-app/node_modules/three/src/nodes/utils/Oscillators.js
generated
vendored
Normal file
6
web-app/node_modules/three/src/nodes/utils/Oscillators.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { time } from './Timer.js';
|
||||
|
||||
export const oscSine = ( t = time ) => t.add( 0.75 ).mul( Math.PI * 2 ).sin().mul( 0.5 ).add( 0.5 );
|
||||
export const oscSquare = ( t = time ) => t.fract().round();
|
||||
export const oscTriangle = ( t = time ) => t.add( 0.5 ).fract().mul( 2 ).sub( 1 ).abs();
|
||||
export const oscSawtooth = ( t = time ) => t.fract();
|
||||
4
web-app/node_modules/three/src/nodes/utils/Packing.js
generated
vendored
Normal file
4
web-app/node_modules/three/src/nodes/utils/Packing.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { nodeObject } from '../tsl/TSLBase.js';
|
||||
|
||||
export const directionToColor = ( node ) => nodeObject( node ).mul( 0.5 ).add( 0.5 );
|
||||
export const colorToDirection = ( node ) => nodeObject( node ).mul( 2.0 ).sub( 1 );
|
||||
89
web-app/node_modules/three/src/nodes/utils/PostProcessingUtils.js
generated
vendored
Normal file
89
web-app/node_modules/three/src/nodes/utils/PostProcessingUtils.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import { abs, cross, float, Fn, normalize, ivec2, sub, vec2, vec3, vec4 } from '../tsl/TSLBase.js';
|
||||
import { textureSize } from '../accessors/TextureSizeNode.js';
|
||||
import { textureLoad } from '../accessors/TextureNode.js';
|
||||
import { WebGPUCoordinateSystem } from '../../constants.js';
|
||||
|
||||
/**
|
||||
* Computes a position in view space based on a fragment's screen position expressed as uv coordinates, the fragments
|
||||
* depth value and the camera's inverse projection matrix.
|
||||
*
|
||||
* @param {vec2} screenPosition - The fragment's screen position expressed as uv coordinates.
|
||||
* @param {float} depth - The fragment's depth value.
|
||||
* @param {mat4} projectionMatrixInverse - The camera's inverse projection matrix.
|
||||
* @return {vec3} The fragments position in view space.
|
||||
*/
|
||||
export const getViewPosition = /*@__PURE__*/ Fn( ( [ screenPosition, depth, projectionMatrixInverse ], builder ) => {
|
||||
|
||||
let clipSpacePosition;
|
||||
|
||||
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
||||
|
||||
screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
|
||||
clipSpacePosition = vec4( vec3( screenPosition, depth ), 1.0 );
|
||||
|
||||
} else {
|
||||
|
||||
clipSpacePosition = vec4( vec3( screenPosition.x, screenPosition.y.oneMinus(), depth ).mul( 2.0 ).sub( 1.0 ), 1.0 );
|
||||
|
||||
}
|
||||
|
||||
const viewSpacePosition = vec4( projectionMatrixInverse.mul( clipSpacePosition ) );
|
||||
|
||||
return viewSpacePosition.xyz.div( viewSpacePosition.w );
|
||||
|
||||
} );
|
||||
|
||||
/**
|
||||
* Computes a screen position expressed as uv coordinates based on a fragment's position in view space
|
||||
* and the camera's projection matrix
|
||||
*
|
||||
* @param {vec3} viewPosition - The fragments position in view space.
|
||||
* @param {mat4} projectionMatrix - The camera's projection matrix.
|
||||
* @return {vec2} The fragment's screen position expressed as uv coordinates.
|
||||
*/
|
||||
export const getScreenPosition = /*@__PURE__*/ Fn( ( [ viewPosition, projectionMatrix ] ) => {
|
||||
|
||||
const sampleClipPos = projectionMatrix.mul( vec4( viewPosition, 1.0 ) );
|
||||
const sampleUv = sampleClipPos.xy.div( sampleClipPos.w ).mul( 0.5 ).add( 0.5 ).toVar();
|
||||
return vec2( sampleUv.x, sampleUv.y.oneMinus() );
|
||||
|
||||
} );
|
||||
|
||||
/**
|
||||
* Computes a normal vector based on depth data. Can be used as a fallback when no normal render
|
||||
* target is available or if flat surface normals are required.
|
||||
*
|
||||
* @param {vec2} uv - The texture coordinate.
|
||||
* @param {DepthTexture} depthTexture - The depth texture.
|
||||
* @param {mat4} projectionMatrixInverse - The camera's inverse projection matrix.
|
||||
* @return {vec3} The computed normal vector.
|
||||
*/
|
||||
export const getNormalFromDepth = /*@__PURE__*/ Fn( ( [ uv, depthTexture, projectionMatrixInverse ] ) => {
|
||||
|
||||
const size = textureSize( textureLoad( depthTexture ) );
|
||||
const p = ivec2( uv.mul( size ) ).toVar();
|
||||
|
||||
const c0 = textureLoad( depthTexture, p ).toVar();
|
||||
|
||||
const l2 = textureLoad( depthTexture, p.sub( ivec2( 2, 0 ) ) ).toVar();
|
||||
const l1 = textureLoad( depthTexture, p.sub( ivec2( 1, 0 ) ) ).toVar();
|
||||
const r1 = textureLoad( depthTexture, p.add( ivec2( 1, 0 ) ) ).toVar();
|
||||
const r2 = textureLoad( depthTexture, p.add( ivec2( 2, 0 ) ) ).toVar();
|
||||
const b2 = textureLoad( depthTexture, p.add( ivec2( 0, 2 ) ) ).toVar();
|
||||
const b1 = textureLoad( depthTexture, p.add( ivec2( 0, 1 ) ) ).toVar();
|
||||
const t1 = textureLoad( depthTexture, p.sub( ivec2( 0, 1 ) ) ).toVar();
|
||||
const t2 = textureLoad( depthTexture, p.sub( ivec2( 0, 2 ) ) ).toVar();
|
||||
|
||||
const dl = abs( sub( float( 2 ).mul( l1 ).sub( l2 ), c0 ) ).toVar();
|
||||
const dr = abs( sub( float( 2 ).mul( r1 ).sub( r2 ), c0 ) ).toVar();
|
||||
const db = abs( sub( float( 2 ).mul( b1 ).sub( b2 ), c0 ) ).toVar();
|
||||
const dt = abs( sub( float( 2 ).mul( t1 ).sub( t2 ), c0 ) ).toVar();
|
||||
|
||||
const ce = getViewPosition( uv, c0, projectionMatrixInverse ).toVar();
|
||||
|
||||
const dpdx = dl.lessThan( dr ).select( ce.sub( getViewPosition( uv.sub( vec2( float( 1 ).div( size.x ), 0 ) ), l1, projectionMatrixInverse ) ), ce.negate().add( getViewPosition( uv.add( vec2( float( 1 ).div( size.x ), 0 ) ), r1, projectionMatrixInverse ) ) );
|
||||
const dpdy = db.lessThan( dt ).select( ce.sub( getViewPosition( uv.add( vec2( 0, float( 1 ).div( size.y ) ) ), b1, projectionMatrixInverse ) ), ce.negate().add( getViewPosition( uv.sub( vec2( 0, float( 1 ).div( size.y ) ) ), t1, projectionMatrixInverse ) ) );
|
||||
|
||||
return normalize( cross( dpdx, dpdy ) );
|
||||
|
||||
} );
|
||||
133
web-app/node_modules/three/src/nodes/utils/RTTNode.js
generated
vendored
Normal file
133
web-app/node_modules/three/src/nodes/utils/RTTNode.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
import { nodeObject } from '../tsl/TSLCore.js';
|
||||
import TextureNode from '../accessors/TextureNode.js';
|
||||
import { NodeUpdateType } from '../core/constants.js';
|
||||
import { uv } from '../accessors/UV.js';
|
||||
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
||||
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
||||
|
||||
import { RenderTarget } from '../../core/RenderTarget.js';
|
||||
import { Vector2 } from '../../math/Vector2.js';
|
||||
import { HalfFloatType } from '../../constants.js';
|
||||
|
||||
const _size = /*@__PURE__*/ new Vector2();
|
||||
|
||||
class RTTNode extends TextureNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'RTTNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( node, width = null, height = null, options = { type: HalfFloatType } ) {
|
||||
|
||||
const renderTarget = new RenderTarget( width, height, options );
|
||||
|
||||
super( renderTarget.texture, uv() );
|
||||
|
||||
this.node = node;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.renderTarget = renderTarget;
|
||||
|
||||
this.textureNeedsUpdate = true;
|
||||
this.autoUpdate = true;
|
||||
|
||||
this.updateMap = new WeakMap();
|
||||
|
||||
this._rttNode = null;
|
||||
this._quadMesh = new QuadMesh( new NodeMaterial() );
|
||||
|
||||
this.updateBeforeType = NodeUpdateType.RENDER;
|
||||
|
||||
}
|
||||
|
||||
get autoSize() {
|
||||
|
||||
return this.width === null;
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
this._rttNode = this.node.context( builder.getSharedContext() );
|
||||
this._quadMesh.material.name = 'RTT';
|
||||
this._quadMesh.material.needsUpdate = true;
|
||||
|
||||
return super.setup( builder );
|
||||
|
||||
}
|
||||
|
||||
setSize( width, height ) {
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
const effectiveWidth = width * this.pixelRatio;
|
||||
const effectiveHeight = height * this.pixelRatio;
|
||||
|
||||
this.renderTarget.setSize( effectiveWidth, effectiveHeight );
|
||||
|
||||
this.textureNeedsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
setPixelRatio( pixelRatio ) {
|
||||
|
||||
this.pixelRatio = pixelRatio;
|
||||
|
||||
this.setSize( this.width, this.height );
|
||||
|
||||
}
|
||||
|
||||
updateBefore( { renderer } ) {
|
||||
|
||||
if ( this.textureNeedsUpdate === false && this.autoUpdate === false ) return;
|
||||
|
||||
this.textureNeedsUpdate = false;
|
||||
|
||||
//
|
||||
|
||||
if ( this.autoSize === true ) {
|
||||
|
||||
this.pixelRatio = renderer.getPixelRatio();
|
||||
|
||||
const size = renderer.getSize( _size );
|
||||
|
||||
this.setSize( size.width, size.height );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this._quadMesh.material.fragmentNode = this._rttNode;
|
||||
|
||||
//
|
||||
|
||||
const currentRenderTarget = renderer.getRenderTarget();
|
||||
|
||||
renderer.setRenderTarget( this.renderTarget );
|
||||
|
||||
this._quadMesh.render( renderer );
|
||||
|
||||
renderer.setRenderTarget( currentRenderTarget );
|
||||
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
||||
const newNode = new TextureNode( this.value, this.uvNode, this.levelNode );
|
||||
newNode.sampler = this.sampler;
|
||||
newNode.referenceNode = this;
|
||||
|
||||
return newNode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RTTNode;
|
||||
|
||||
export const rtt = ( node, ...params ) => nodeObject( new RTTNode( nodeObject( node ), ...params ) );
|
||||
export const convertToTexture = ( node, ...params ) => node.isTextureNode ? node : rtt( node, ...params );
|
||||
329
web-app/node_modules/three/src/nodes/utils/ReflectorNode.js
generated
vendored
Normal file
329
web-app/node_modules/three/src/nodes/utils/ReflectorNode.js
generated
vendored
Normal file
@@ -0,0 +1,329 @@
|
||||
import Node from '../core/Node.js';
|
||||
import TextureNode from '../accessors/TextureNode.js';
|
||||
import { nodeObject } from '../tsl/TSLBase.js';
|
||||
import { NodeUpdateType } from '../core/constants.js';
|
||||
import { screenUV } from '../display/ScreenNode.js';
|
||||
|
||||
import { HalfFloatType, LinearMipMapLinearFilter, WebGPUCoordinateSystem } from '../../constants.js';
|
||||
import { Plane } from '../../math/Plane.js';
|
||||
import { Object3D } from '../../core/Object3D.js';
|
||||
import { Vector2 } from '../../math/Vector2.js';
|
||||
import { Vector3 } from '../../math/Vector3.js';
|
||||
import { Vector4 } from '../../math/Vector4.js';
|
||||
import { Matrix4 } from '../../math/Matrix4.js';
|
||||
import { RenderTarget } from '../../core/RenderTarget.js';
|
||||
import { DepthTexture } from '../../textures/DepthTexture.js';
|
||||
|
||||
const _reflectorPlane = new Plane();
|
||||
const _normal = new Vector3();
|
||||
const _reflectorWorldPosition = new Vector3();
|
||||
const _cameraWorldPosition = new Vector3();
|
||||
const _rotationMatrix = new Matrix4();
|
||||
const _lookAtPosition = new Vector3( 0, 0, - 1 );
|
||||
const clipPlane = new Vector4();
|
||||
|
||||
const _view = new Vector3();
|
||||
const _target = new Vector3();
|
||||
const _q = new Vector4();
|
||||
|
||||
const _size = new Vector2();
|
||||
|
||||
const _defaultRT = new RenderTarget();
|
||||
const _defaultUV = screenUV.flipX();
|
||||
|
||||
_defaultRT.depthTexture = new DepthTexture( 1, 1 );
|
||||
|
||||
let _inReflector = false;
|
||||
|
||||
class ReflectorNode extends TextureNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'ReflectorNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( parameters = {} ) {
|
||||
|
||||
super( parameters.defaultTexture || _defaultRT.texture, _defaultUV );
|
||||
|
||||
this._reflectorBaseNode = parameters.reflector || new ReflectorBaseNode( this, parameters );
|
||||
this._depthNode = null;
|
||||
|
||||
this.setUpdateMatrix( false );
|
||||
|
||||
}
|
||||
|
||||
get reflector() {
|
||||
|
||||
return this._reflectorBaseNode;
|
||||
|
||||
}
|
||||
|
||||
get target() {
|
||||
|
||||
return this._reflectorBaseNode.target;
|
||||
|
||||
}
|
||||
|
||||
getDepthNode() {
|
||||
|
||||
if ( this._depthNode === null ) {
|
||||
|
||||
if ( this._reflectorBaseNode.depth !== true ) {
|
||||
|
||||
throw new Error( 'THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ' );
|
||||
|
||||
}
|
||||
|
||||
this._depthNode = nodeObject( new ReflectorNode( {
|
||||
defaultTexture: _defaultRT.depthTexture,
|
||||
reflector: this._reflectorBaseNode
|
||||
} ) );
|
||||
|
||||
}
|
||||
|
||||
return this._depthNode;
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
// ignore if used in post-processing
|
||||
if ( ! builder.object.isQuadMesh ) this._reflectorBaseNode.build( builder );
|
||||
|
||||
return super.setup( builder );
|
||||
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
||||
const texture = new this.constructor( this.reflectorNode );
|
||||
texture._reflectorBaseNode = this._reflectorBaseNode;
|
||||
|
||||
return texture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ReflectorBaseNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'ReflectorBaseNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( textureNode, parameters = {} ) {
|
||||
|
||||
super();
|
||||
|
||||
const {
|
||||
target = new Object3D(),
|
||||
resolution = 1,
|
||||
generateMipmaps = false,
|
||||
bounces = true,
|
||||
depth = false
|
||||
} = parameters;
|
||||
|
||||
//
|
||||
|
||||
this.textureNode = textureNode;
|
||||
|
||||
this.target = target;
|
||||
this.resolution = resolution;
|
||||
this.generateMipmaps = generateMipmaps;
|
||||
this.bounces = bounces;
|
||||
this.depth = depth;
|
||||
|
||||
this.updateBeforeType = bounces ? NodeUpdateType.RENDER : NodeUpdateType.FRAME;
|
||||
|
||||
this.virtualCameras = new WeakMap();
|
||||
this.renderTargets = new WeakMap();
|
||||
|
||||
}
|
||||
|
||||
_updateResolution( renderTarget, renderer ) {
|
||||
|
||||
const resolution = this.resolution;
|
||||
|
||||
renderer.getDrawingBufferSize( _size );
|
||||
|
||||
renderTarget.setSize( Math.round( _size.width * resolution ), Math.round( _size.height * resolution ) );
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
this._updateResolution( _defaultRT, builder.renderer );
|
||||
|
||||
return super.setup( builder );
|
||||
|
||||
}
|
||||
|
||||
getVirtualCamera( camera ) {
|
||||
|
||||
let virtualCamera = this.virtualCameras.get( camera );
|
||||
|
||||
if ( virtualCamera === undefined ) {
|
||||
|
||||
virtualCamera = camera.clone();
|
||||
|
||||
this.virtualCameras.set( camera, virtualCamera );
|
||||
|
||||
}
|
||||
|
||||
return virtualCamera;
|
||||
|
||||
}
|
||||
|
||||
getRenderTarget( camera ) {
|
||||
|
||||
let renderTarget = this.renderTargets.get( camera );
|
||||
|
||||
if ( renderTarget === undefined ) {
|
||||
|
||||
renderTarget = new RenderTarget( 0, 0, { type: HalfFloatType } );
|
||||
|
||||
if ( this.generateMipmaps === true ) {
|
||||
|
||||
renderTarget.texture.minFilter = LinearMipMapLinearFilter;
|
||||
renderTarget.texture.generateMipmaps = true;
|
||||
|
||||
}
|
||||
|
||||
if ( this.depth === true ) {
|
||||
|
||||
renderTarget.depthTexture = new DepthTexture();
|
||||
|
||||
}
|
||||
|
||||
this.renderTargets.set( camera, renderTarget );
|
||||
|
||||
}
|
||||
|
||||
return renderTarget;
|
||||
|
||||
}
|
||||
|
||||
updateBefore( frame ) {
|
||||
|
||||
if ( this.bounces === false && _inReflector ) return;
|
||||
|
||||
_inReflector = true;
|
||||
|
||||
const { scene, camera, renderer, material } = frame;
|
||||
const { target } = this;
|
||||
|
||||
const virtualCamera = this.getVirtualCamera( camera );
|
||||
const renderTarget = this.getRenderTarget( virtualCamera );
|
||||
|
||||
renderer.getDrawingBufferSize( _size );
|
||||
|
||||
this._updateResolution( renderTarget, renderer );
|
||||
|
||||
//
|
||||
|
||||
_reflectorWorldPosition.setFromMatrixPosition( target.matrixWorld );
|
||||
_cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld );
|
||||
|
||||
_rotationMatrix.extractRotation( target.matrixWorld );
|
||||
|
||||
_normal.set( 0, 0, 1 );
|
||||
_normal.applyMatrix4( _rotationMatrix );
|
||||
|
||||
_view.subVectors( _reflectorWorldPosition, _cameraWorldPosition );
|
||||
|
||||
// Avoid rendering when reflector is facing away
|
||||
|
||||
if ( _view.dot( _normal ) > 0 ) return;
|
||||
|
||||
_view.reflect( _normal ).negate();
|
||||
_view.add( _reflectorWorldPosition );
|
||||
|
||||
_rotationMatrix.extractRotation( camera.matrixWorld );
|
||||
|
||||
_lookAtPosition.set( 0, 0, - 1 );
|
||||
_lookAtPosition.applyMatrix4( _rotationMatrix );
|
||||
_lookAtPosition.add( _cameraWorldPosition );
|
||||
|
||||
_target.subVectors( _reflectorWorldPosition, _lookAtPosition );
|
||||
_target.reflect( _normal ).negate();
|
||||
_target.add( _reflectorWorldPosition );
|
||||
|
||||
//
|
||||
|
||||
virtualCamera.coordinateSystem = camera.coordinateSystem;
|
||||
virtualCamera.position.copy( _view );
|
||||
virtualCamera.up.set( 0, 1, 0 );
|
||||
virtualCamera.up.applyMatrix4( _rotationMatrix );
|
||||
virtualCamera.up.reflect( _normal );
|
||||
virtualCamera.lookAt( _target );
|
||||
|
||||
virtualCamera.near = camera.near;
|
||||
virtualCamera.far = camera.far;
|
||||
|
||||
virtualCamera.updateMatrixWorld();
|
||||
virtualCamera.projectionMatrix.copy( camera.projectionMatrix );
|
||||
|
||||
// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
|
||||
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
|
||||
_reflectorPlane.setFromNormalAndCoplanarPoint( _normal, _reflectorWorldPosition );
|
||||
_reflectorPlane.applyMatrix4( virtualCamera.matrixWorldInverse );
|
||||
|
||||
clipPlane.set( _reflectorPlane.normal.x, _reflectorPlane.normal.y, _reflectorPlane.normal.z, _reflectorPlane.constant );
|
||||
|
||||
const projectionMatrix = virtualCamera.projectionMatrix;
|
||||
|
||||
_q.x = ( Math.sign( clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ];
|
||||
_q.y = ( Math.sign( clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ];
|
||||
_q.z = - 1.0;
|
||||
_q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ];
|
||||
|
||||
// Calculate the scaled plane vector
|
||||
clipPlane.multiplyScalar( 1.0 / clipPlane.dot( _q ) );
|
||||
|
||||
const clipBias = 0;
|
||||
|
||||
// Replacing the third row of the projection matrix
|
||||
projectionMatrix.elements[ 2 ] = clipPlane.x;
|
||||
projectionMatrix.elements[ 6 ] = clipPlane.y;
|
||||
projectionMatrix.elements[ 10 ] = ( renderer.coordinateSystem === WebGPUCoordinateSystem ) ? ( clipPlane.z - clipBias ) : ( clipPlane.z + 1.0 - clipBias );
|
||||
projectionMatrix.elements[ 14 ] = clipPlane.w;
|
||||
|
||||
//
|
||||
|
||||
this.textureNode.value = renderTarget.texture;
|
||||
|
||||
if ( this.depth === true ) {
|
||||
|
||||
this.textureNode.getDepthNode().value = renderTarget.depthTexture;
|
||||
|
||||
}
|
||||
|
||||
material.visible = false;
|
||||
|
||||
const currentRenderTarget = renderer.getRenderTarget();
|
||||
const currentMRT = renderer.getMRT();
|
||||
|
||||
renderer.setMRT( null );
|
||||
renderer.setRenderTarget( renderTarget );
|
||||
|
||||
renderer.render( scene, virtualCamera );
|
||||
|
||||
renderer.setMRT( currentMRT );
|
||||
renderer.setRenderTarget( currentRenderTarget );
|
||||
|
||||
material.visible = true;
|
||||
|
||||
_inReflector = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const reflector = ( parameters ) => nodeObject( new ReflectorNode( parameters ) );
|
||||
|
||||
export default ReflectorNode;
|
||||
46
web-app/node_modules/three/src/nodes/utils/RemapNode.js
generated
vendored
Normal file
46
web-app/node_modules/three/src/nodes/utils/RemapNode.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { float, addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
||||
|
||||
class RemapNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'RemapNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( node, inLowNode, inHighNode, outLowNode = float( 0 ), outHighNode = float( 1 ) ) {
|
||||
|
||||
super();
|
||||
|
||||
this.node = node;
|
||||
this.inLowNode = inLowNode;
|
||||
this.inHighNode = inHighNode;
|
||||
this.outLowNode = outLowNode;
|
||||
this.outHighNode = outHighNode;
|
||||
|
||||
this.doClamp = true;
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
const { node, inLowNode, inHighNode, outLowNode, outHighNode, doClamp } = this;
|
||||
|
||||
let t = node.sub( inLowNode ).div( inHighNode.sub( inLowNode ) );
|
||||
|
||||
if ( doClamp === true ) t = t.clamp();
|
||||
|
||||
return t.mul( outHighNode.sub( outLowNode ) ).add( outLowNode );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RemapNode;
|
||||
|
||||
export const remap = /*@__PURE__*/ nodeProxy( RemapNode, null, null, { doClamp: false } );
|
||||
export const remapClamp = /*@__PURE__*/ nodeProxy( RemapNode );
|
||||
|
||||
addMethodChaining( 'remap', remap );
|
||||
addMethodChaining( 'remapClamp', remapClamp );
|
||||
63
web-app/node_modules/three/src/nodes/utils/RotateNode.js
generated
vendored
Normal file
63
web-app/node_modules/three/src/nodes/utils/RotateNode.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { nodeProxy, vec4, mat2, mat4 } from '../tsl/TSLBase.js';
|
||||
import { cos, sin } from '../math/MathNode.js';
|
||||
|
||||
class RotateNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'RotateNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( positionNode, rotationNode ) {
|
||||
|
||||
super();
|
||||
|
||||
this.positionNode = positionNode;
|
||||
this.rotationNode = rotationNode;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
return this.positionNode.getNodeType( builder );
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
const { rotationNode, positionNode } = this;
|
||||
|
||||
const nodeType = this.getNodeType( builder );
|
||||
|
||||
if ( nodeType === 'vec2' ) {
|
||||
|
||||
const cosAngle = rotationNode.cos();
|
||||
const sinAngle = rotationNode.sin();
|
||||
|
||||
const rotationMatrix = mat2(
|
||||
cosAngle, sinAngle,
|
||||
sinAngle.negate(), cosAngle
|
||||
);
|
||||
|
||||
return rotationMatrix.mul( positionNode );
|
||||
|
||||
} else {
|
||||
|
||||
const rotation = rotationNode;
|
||||
const rotationXMatrix = mat4( vec4( 1.0, 0.0, 0.0, 0.0 ), vec4( 0.0, cos( rotation.x ), sin( rotation.x ).negate(), 0.0 ), vec4( 0.0, sin( rotation.x ), cos( rotation.x ), 0.0 ), vec4( 0.0, 0.0, 0.0, 1.0 ) );
|
||||
const rotationYMatrix = mat4( vec4( cos( rotation.y ), 0.0, sin( rotation.y ), 0.0 ), vec4( 0.0, 1.0, 0.0, 0.0 ), vec4( sin( rotation.y ).negate(), 0.0, cos( rotation.y ), 0.0 ), vec4( 0.0, 0.0, 0.0, 1.0 ) );
|
||||
const rotationZMatrix = mat4( vec4( cos( rotation.z ), sin( rotation.z ).negate(), 0.0, 0.0 ), vec4( sin( rotation.z ), cos( rotation.z ), 0.0, 0.0 ), vec4( 0.0, 0.0, 1.0, 0.0 ), vec4( 0.0, 0.0, 0.0, 1.0 ) );
|
||||
|
||||
return rotationXMatrix.mul( rotationYMatrix ).mul( rotationZMatrix ).mul( vec4( positionNode, 1.0 ) ).xyz;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RotateNode;
|
||||
|
||||
export const rotate = /*@__PURE__*/ nodeProxy( RotateNode );
|
||||
65
web-app/node_modules/three/src/nodes/utils/SetNode.js
generated
vendored
Normal file
65
web-app/node_modules/three/src/nodes/utils/SetNode.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import TempNode from '../core/TempNode.js';
|
||||
import { vectorComponents } from '../core/constants.js';
|
||||
|
||||
class SetNode extends TempNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'SetNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( sourceNode, components, targetNode ) {
|
||||
|
||||
super();
|
||||
|
||||
this.sourceNode = sourceNode;
|
||||
this.components = components;
|
||||
this.targetNode = targetNode;
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
return this.sourceNode.getNodeType( builder );
|
||||
|
||||
}
|
||||
|
||||
generate( builder ) {
|
||||
|
||||
const { sourceNode, components, targetNode } = this;
|
||||
|
||||
const sourceType = this.getNodeType( builder );
|
||||
const targetType = builder.getTypeFromLength( components.length, targetNode.getNodeType( builder ) );
|
||||
|
||||
const targetSnippet = targetNode.build( builder, targetType );
|
||||
const sourceSnippet = sourceNode.build( builder, sourceType );
|
||||
|
||||
const length = builder.getTypeLength( sourceType );
|
||||
const snippetValues = [];
|
||||
|
||||
for ( let i = 0; i < length; i ++ ) {
|
||||
|
||||
const component = vectorComponents[ i ];
|
||||
|
||||
if ( component === components[ 0 ] ) {
|
||||
|
||||
snippetValues.push( targetSnippet );
|
||||
|
||||
i += components.length - 1;
|
||||
|
||||
} else {
|
||||
|
||||
snippetValues.push( sourceSnippet + '.' + component );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return `${ builder.getType( sourceType ) }( ${ snippetValues.join( ', ' ) } )`;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SetNode;
|
||||
116
web-app/node_modules/three/src/nodes/utils/SplitNode.js
generated
vendored
Normal file
116
web-app/node_modules/three/src/nodes/utils/SplitNode.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { vectorComponents } from '../core/constants.js';
|
||||
|
||||
const stringVectorComponents = vectorComponents.join( '' );
|
||||
|
||||
class SplitNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'SplitNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( node, components = 'x' ) {
|
||||
|
||||
super();
|
||||
|
||||
this.node = node;
|
||||
this.components = components;
|
||||
|
||||
this.isSplitNode = true;
|
||||
|
||||
}
|
||||
|
||||
getVectorLength() {
|
||||
|
||||
let vectorLength = this.components.length;
|
||||
|
||||
for ( const c of this.components ) {
|
||||
|
||||
vectorLength = Math.max( vectorComponents.indexOf( c ) + 1, vectorLength );
|
||||
|
||||
}
|
||||
|
||||
return vectorLength;
|
||||
|
||||
}
|
||||
|
||||
getComponentType( builder ) {
|
||||
|
||||
return builder.getComponentType( this.node.getNodeType( builder ) );
|
||||
|
||||
}
|
||||
|
||||
getNodeType( builder ) {
|
||||
|
||||
return builder.getTypeFromLength( this.components.length, this.getComponentType( builder ) );
|
||||
|
||||
}
|
||||
|
||||
generate( builder, output ) {
|
||||
|
||||
const node = this.node;
|
||||
const nodeTypeLength = builder.getTypeLength( node.getNodeType( builder ) );
|
||||
|
||||
let snippet = null;
|
||||
|
||||
if ( nodeTypeLength > 1 ) {
|
||||
|
||||
let type = null;
|
||||
|
||||
const componentsLength = this.getVectorLength();
|
||||
|
||||
if ( componentsLength >= nodeTypeLength ) {
|
||||
|
||||
// needed expand the input node
|
||||
|
||||
type = builder.getTypeFromLength( this.getVectorLength(), this.getComponentType( builder ) );
|
||||
|
||||
}
|
||||
|
||||
const nodeSnippet = node.build( builder, type );
|
||||
|
||||
if ( this.components.length === nodeTypeLength && this.components === stringVectorComponents.slice( 0, this.components.length ) ) {
|
||||
|
||||
// unnecessary swizzle
|
||||
|
||||
snippet = builder.format( nodeSnippet, type, output );
|
||||
|
||||
} else {
|
||||
|
||||
snippet = builder.format( `${nodeSnippet}.${this.components}`, this.getNodeType( builder ), output );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// ignore .components if .node returns float/integer
|
||||
|
||||
snippet = node.build( builder, output );
|
||||
|
||||
}
|
||||
|
||||
return snippet;
|
||||
|
||||
}
|
||||
|
||||
serialize( data ) {
|
||||
|
||||
super.serialize( data );
|
||||
|
||||
data.components = this.components;
|
||||
|
||||
}
|
||||
|
||||
deserialize( data ) {
|
||||
|
||||
super.deserialize( data );
|
||||
|
||||
this.components = data.components;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SplitNode;
|
||||
45
web-app/node_modules/three/src/nodes/utils/SpriteSheetUVNode.js
generated
vendored
Normal file
45
web-app/node_modules/three/src/nodes/utils/SpriteSheetUVNode.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { uv } from '../accessors/UV.js';
|
||||
import { nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
|
||||
|
||||
class SpriteSheetUVNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'SpriteSheetUVNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( countNode, uvNode = uv(), frameNode = float( 0 ) ) {
|
||||
|
||||
super( 'vec2' );
|
||||
|
||||
this.countNode = countNode;
|
||||
this.uvNode = uvNode;
|
||||
this.frameNode = frameNode;
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
const { frameNode, uvNode, countNode } = this;
|
||||
|
||||
const { width, height } = countNode;
|
||||
|
||||
const frameNum = frameNode.mod( width.mul( height ) ).floor();
|
||||
|
||||
const column = frameNum.mod( width );
|
||||
const row = height.sub( frameNum.add( 1 ).div( width ).ceil() );
|
||||
|
||||
const scale = countNode.reciprocal();
|
||||
const uvFrameOffset = vec2( column, row );
|
||||
|
||||
return uvNode.add( uvFrameOffset ).mul( scale );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SpriteSheetUVNode;
|
||||
|
||||
export const spritesheetUV = /*@__PURE__*/ nodeProxy( SpriteSheetUVNode );
|
||||
47
web-app/node_modules/three/src/nodes/utils/SpriteUtils.js
generated
vendored
Normal file
47
web-app/node_modules/three/src/nodes/utils/SpriteUtils.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { modelWorldMatrix } from '../accessors/ModelNode.js';
|
||||
import { cameraViewMatrix, cameraProjectionMatrix } from '../accessors/Camera.js';
|
||||
import { positionLocal } from '../accessors/Position.js';
|
||||
import { Fn, defined } from '../tsl/TSLBase.js';
|
||||
|
||||
export const billboarding = /*@__PURE__*/ Fn( ( { position = null, horizontal = true, vertical = false } ) => {
|
||||
|
||||
let worldMatrix;
|
||||
|
||||
if ( position !== null ) {
|
||||
|
||||
worldMatrix = modelWorldMatrix.toVar();
|
||||
worldMatrix[ 3 ][ 0 ] = position.x;
|
||||
worldMatrix[ 3 ][ 1 ] = position.y;
|
||||
worldMatrix[ 3 ][ 2 ] = position.z;
|
||||
|
||||
} else {
|
||||
|
||||
worldMatrix = modelWorldMatrix;
|
||||
|
||||
}
|
||||
|
||||
const modelViewMatrix = cameraViewMatrix.mul( worldMatrix );
|
||||
|
||||
if ( defined( horizontal ) ) {
|
||||
|
||||
modelViewMatrix[ 0 ][ 0 ] = modelWorldMatrix[ 0 ].length();
|
||||
modelViewMatrix[ 0 ][ 1 ] = 0;
|
||||
modelViewMatrix[ 0 ][ 2 ] = 0;
|
||||
|
||||
}
|
||||
|
||||
if ( defined( vertical ) ) {
|
||||
|
||||
modelViewMatrix[ 1 ][ 0 ] = 0;
|
||||
modelViewMatrix[ 1 ][ 1 ] = modelWorldMatrix[ 1 ].length();
|
||||
modelViewMatrix[ 1 ][ 2 ] = 0;
|
||||
|
||||
}
|
||||
|
||||
modelViewMatrix[ 2 ][ 0 ] = 0;
|
||||
modelViewMatrix[ 2 ][ 1 ] = 0;
|
||||
modelViewMatrix[ 2 ][ 2 ] = 1;
|
||||
|
||||
return cameraProjectionMatrix.mul( modelViewMatrix ).mul( positionLocal );
|
||||
|
||||
} );
|
||||
90
web-app/node_modules/three/src/nodes/utils/StorageArrayElementNode.js
generated
vendored
Normal file
90
web-app/node_modules/three/src/nodes/utils/StorageArrayElementNode.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import { nodeProxy } from '../tsl/TSLBase.js';
|
||||
import ArrayElementNode from './ArrayElementNode.js';
|
||||
|
||||
class StorageArrayElementNode extends ArrayElementNode {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'StorageArrayElementNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( storageBufferNode, indexNode ) {
|
||||
|
||||
super( storageBufferNode, indexNode );
|
||||
|
||||
this.isStorageArrayElementNode = true;
|
||||
|
||||
}
|
||||
|
||||
set storageBufferNode( value ) {
|
||||
|
||||
this.node = value;
|
||||
|
||||
}
|
||||
|
||||
get storageBufferNode() {
|
||||
|
||||
return this.node;
|
||||
|
||||
}
|
||||
|
||||
setup( builder ) {
|
||||
|
||||
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
||||
|
||||
if ( this.node.bufferObject === true ) {
|
||||
|
||||
builder.setupPBO( this.node );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.setup( builder );
|
||||
|
||||
}
|
||||
|
||||
generate( builder, output ) {
|
||||
|
||||
let snippet;
|
||||
|
||||
const isAssignContext = builder.context.assign;
|
||||
|
||||
//
|
||||
|
||||
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
||||
|
||||
if ( this.node.bufferObject === true && isAssignContext !== true ) {
|
||||
|
||||
snippet = builder.generatePBO( this );
|
||||
|
||||
} else {
|
||||
|
||||
snippet = this.node.build( builder );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
snippet = super.generate( builder );
|
||||
|
||||
}
|
||||
|
||||
if ( isAssignContext !== true ) {
|
||||
|
||||
const type = this.getNodeType( builder );
|
||||
|
||||
snippet = builder.format( snippet, type, output );
|
||||
|
||||
}
|
||||
|
||||
return snippet;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default StorageArrayElementNode;
|
||||
|
||||
export const storageElement = /*@__PURE__*/ nodeProxy( StorageArrayElementNode );
|
||||
29
web-app/node_modules/three/src/nodes/utils/Timer.js
generated
vendored
Normal file
29
web-app/node_modules/three/src/nodes/utils/Timer.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { renderGroup } from '../core/UniformGroupNode.js';
|
||||
import { uniform } from '../core/UniformNode.js';
|
||||
|
||||
export const time = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.time );
|
||||
export const deltaTime = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.deltaTime );
|
||||
export const frameId = /*@__PURE__*/ uniform( 0, 'uint' ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.frameId );
|
||||
|
||||
// Deprecated
|
||||
|
||||
export const timerLocal = ( timeScale = 1 ) => { // @deprecated, r170
|
||||
|
||||
console.warn( 'TSL: timerLocal() is deprecated. Use "time" instead.' );
|
||||
return time.mul( timeScale );
|
||||
|
||||
};
|
||||
|
||||
export const timerGlobal = ( timeScale = 1 ) => { // @deprecated, r170
|
||||
|
||||
console.warn( 'TSL: timerGlobal() is deprecated. Use "time" instead.' );
|
||||
return time.mul( timeScale );
|
||||
|
||||
};
|
||||
|
||||
export const timerDelta = ( timeScale = 1 ) => { // @deprecated, r170
|
||||
|
||||
console.warn( 'TSL: timerDelta() is deprecated. Use "deltaTime" instead.' );
|
||||
return deltaTime.mul( timeScale );
|
||||
|
||||
};
|
||||
64
web-app/node_modules/three/src/nodes/utils/TriplanarTexturesNode.js
generated
vendored
Normal file
64
web-app/node_modules/three/src/nodes/utils/TriplanarTexturesNode.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import Node from '../core/Node.js';
|
||||
import { add } from '../math/OperatorNode.js';
|
||||
import { normalLocal } from '../accessors/Normal.js';
|
||||
import { positionLocal } from '../accessors/Position.js';
|
||||
import { texture } from '../accessors/TextureNode.js';
|
||||
import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
|
||||
|
||||
class TriplanarTexturesNode extends Node {
|
||||
|
||||
static get type() {
|
||||
|
||||
return 'TriplanarTexturesNode';
|
||||
|
||||
}
|
||||
|
||||
constructor( textureXNode, textureYNode = null, textureZNode = null, scaleNode = float( 1 ), positionNode = positionLocal, normalNode = normalLocal ) {
|
||||
|
||||
super( 'vec4' );
|
||||
|
||||
this.textureXNode = textureXNode;
|
||||
this.textureYNode = textureYNode;
|
||||
this.textureZNode = textureZNode;
|
||||
|
||||
this.scaleNode = scaleNode;
|
||||
|
||||
this.positionNode = positionNode;
|
||||
this.normalNode = normalNode;
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
const { textureXNode, textureYNode, textureZNode, scaleNode, positionNode, normalNode } = this;
|
||||
|
||||
// Ref: https://github.com/keijiro/StandardTriplanar
|
||||
|
||||
// Blending factor of triplanar mapping
|
||||
let bf = normalNode.abs().normalize();
|
||||
bf = bf.div( bf.dot( vec3( 1.0 ) ) );
|
||||
|
||||
// Triplanar mapping
|
||||
const tx = positionNode.yz.mul( scaleNode );
|
||||
const ty = positionNode.zx.mul( scaleNode );
|
||||
const tz = positionNode.xy.mul( scaleNode );
|
||||
|
||||
// Base color
|
||||
const textureX = textureXNode.value;
|
||||
const textureY = textureYNode !== null ? textureYNode.value : textureX;
|
||||
const textureZ = textureZNode !== null ? textureZNode.value : textureX;
|
||||
|
||||
const cx = texture( textureX, tx ).mul( bf.x );
|
||||
const cy = texture( textureY, ty ).mul( bf.y );
|
||||
const cz = texture( textureZ, tz ).mul( bf.z );
|
||||
|
||||
return add( cx, cy, cz );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default TriplanarTexturesNode;
|
||||
|
||||
export const triplanarTextures = /*@__PURE__*/ nodeProxy( TriplanarTexturesNode );
|
||||
export const triplanarTexture = ( ...params ) => triplanarTextures( ...params );
|
||||
19
web-app/node_modules/three/src/nodes/utils/UVUtils.js
generated
vendored
Normal file
19
web-app/node_modules/three/src/nodes/utils/UVUtils.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Fn, vec2 } from '../tsl/TSLBase.js';
|
||||
import { rotate } from './RotateNode.js';
|
||||
|
||||
export const rotateUV = /*@__PURE__*/ Fn( ( [ uv, rotation, center = vec2( 0.5 ) ] ) => {
|
||||
|
||||
return rotate( uv.sub( center ), rotation ).add( center );
|
||||
|
||||
} );
|
||||
|
||||
export const spherizeUV = /*@__PURE__*/ Fn( ( [ uv, strength, center = vec2( 0.5 ) ] ) => {
|
||||
|
||||
const delta = uv.sub( center );
|
||||
const delta2 = delta.dot( delta );
|
||||
const delta4 = delta2.mul( delta2 );
|
||||
const deltaOffset = delta4.mul( strength );
|
||||
|
||||
return uv.add( delta.mul( deltaOffset ) );
|
||||
|
||||
} );
|
||||
14
web-app/node_modules/three/src/nodes/utils/ViewportUtils.js
generated
vendored
Normal file
14
web-app/node_modules/three/src/nodes/utils/ViewportUtils.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Fn } from '../tsl/TSLBase.js';
|
||||
import { screenUV } from '../display/ScreenNode.js';
|
||||
import { viewportDepthTexture } from '../display/ViewportDepthTextureNode.js';
|
||||
import { linearDepth } from '../display/ViewportDepthNode.js';
|
||||
|
||||
export const viewportSafeUV = /*@__PURE__*/ Fn( ( [ uv = null ] ) => {
|
||||
|
||||
const depth = linearDepth();
|
||||
const depthDiff = linearDepth( viewportDepthTexture( uv ) ).sub( depth );
|
||||
const finalUV = depthDiff.lessThan( 0 ).select( screenUV, uv );
|
||||
|
||||
return finalUV;
|
||||
|
||||
} );
|
||||
Reference in New Issue
Block a user