📄 CubeTextureNode.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 7 |
🧱 Classes | 1 |
📦 Imports | 11 |
📊 Variables & Constants | 4 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/nodes/accessors/CubeTextureNode.js
📦 Imports¶
Name | Source |
---|---|
TextureNode |
./TextureNode.js |
reflectVector |
./ReflectVector.js |
refractVector |
./ReflectVector.js |
nodeObject |
../tsl/TSLBase.js |
nodeProxy |
../tsl/TSLBase.js |
vec3 |
../tsl/TSLBase.js |
CubeReflectionMapping |
../../constants.js |
CubeRefractionMapping |
../../constants.js |
WebGPUCoordinateSystem |
../../constants.js |
materialEnvRotation |
./MaterialProperties.js |
CubeTexture |
../../textures/CubeTexture.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
EmptyTexture |
CubeTexture |
let/var | new CubeTexture() |
✗ |
texture |
Texture |
let/var | this.value |
✗ |
texture |
Texture |
let/var | this.value |
✗ |
textureNode |
any |
let/var | *not shown* |
✗ |
Functions¶
CubeTextureNode.getInputType(): string
¶
JSDoc:
/**
* Overwrites the default implementation to return a fixed value `'cubeTexture'`.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
Returns: string
CubeTextureNode.getDefaultUV(): any
¶
JSDoc:
/**
* Returns a default uvs based on the mapping type of the cube texture.
*
* @return {Node<vec3>} The default uv attribute.
*/
Returns: any
Calls:
console.error
vec3 (from ../tsl/TSLBase.js)
Code
getDefaultUV() {
const texture = this.value;
if ( texture.mapping === CubeReflectionMapping ) {
return reflectVector;
} else if ( texture.mapping === CubeRefractionMapping ) {
return refractVector;
} else {
console.error( 'THREE.CubeTextureNode: Mapping "%s" not supported.', texture.mapping );
return vec3( 0, 0, 0 );
}
}
CubeTextureNode.setUpdateMatrix(): void
¶
JSDoc:
/**
* Overwritten with an empty implementation since the `updateMatrix` flag is ignored
* for cube textures. The uv transformation matrix is not applied to cube textures.
*
* @param {boolean} value - The update toggle.
*/
Returns: void
CubeTextureNode.setupUV(builder: NodeBuilder, uvNode: Node): Node
¶
JSDoc:
/**
* Setups the uv node. Depending on the backend as well as the texture type, it might be necessary
* to modify the uv node for correct sampling.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {Node} uvNode - The uv node to setup.
* @return {Node} The updated uv node.
*/
Parameters:
builder
NodeBuilder
uvNode
Node
Returns: Node
Calls:
vec3 (from ../tsl/TSLBase.js)
uvNode.x.negate
materialEnvRotation.mul
Code
CubeTextureNode.generateUV(builder: NodeBuilder, cubeUV: Node): string
¶
JSDoc:
/**
* Generates the uv code snippet.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {Node} cubeUV - The uv node to generate code for.
* @return {string} The generated code snippet.
*/
Parameters:
builder
NodeBuilder
cubeUV
Node
Returns: string
Calls:
cubeUV.build
cubeTexture(value: CubeTexture | CubeTextureNode, uvNode: any, levelNode: any, biasNode: any): CubeTextureNode
¶
Parameters:
value
CubeTexture | CubeTextureNode
uvNode
any
levelNode
any
biasNode
any
Returns: CubeTextureNode
Calls:
nodeObject (from ../tsl/TSLBase.js)
value.clone
value.getSelf
cubeTextureBase
Code
( value = EmptyTexture, uvNode = null, levelNode = null, biasNode = null ) => {
let textureNode;
if ( value && value.isCubeTextureNode === true ) {
textureNode = nodeObject( value.clone() );
textureNode.referenceNode = value.getSelf(); // Ensure the reference is set to the original node
if ( uvNode !== null ) textureNode.uvNode = nodeObject( uvNode );
if ( levelNode !== null ) textureNode.levelNode = nodeObject( levelNode );
if ( biasNode !== null ) textureNode.biasNode = nodeObject( biasNode );
} else {
textureNode = cubeTextureBase( value, uvNode, levelNode, biasNode );
}
return textureNode;
}
uniformCubeTexture(value: CubeTexture): CubeTextureNode
¶
Parameters:
value
CubeTexture
Returns: CubeTextureNode
Calls:
cubeTextureBase
Classes¶
CubeTextureNode
¶
Class Code
class CubeTextureNode extends TextureNode {
static get type() {
return 'CubeTextureNode';
}
/**
* Constructs a new cube texture node.
*
* @param {CubeTexture} value - The cube texture.
* @param {?Node<vec3>} [uvNode=null] - The uv node.
* @param {?Node<int>} [levelNode=null] - The level node.
* @param {?Node<float>} [biasNode=null] - The bias node.
*/
constructor( value, uvNode = null, levelNode = null, biasNode = null ) {
super( value, uvNode, levelNode, biasNode );
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isCubeTextureNode = true;
}
/**
* Overwrites the default implementation to return a fixed value `'cubeTexture'`.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
getInputType( /*builder*/ ) {
return 'cubeTexture';
}
/**
* Returns a default uvs based on the mapping type of the cube texture.
*
* @return {Node<vec3>} The default uv attribute.
*/
getDefaultUV() {
const texture = this.value;
if ( texture.mapping === CubeReflectionMapping ) {
return reflectVector;
} else if ( texture.mapping === CubeRefractionMapping ) {
return refractVector;
} else {
console.error( 'THREE.CubeTextureNode: Mapping "%s" not supported.', texture.mapping );
return vec3( 0, 0, 0 );
}
}
/**
* Overwritten with an empty implementation since the `updateMatrix` flag is ignored
* for cube textures. The uv transformation matrix is not applied to cube textures.
*
* @param {boolean} value - The update toggle.
*/
setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for CubeTextureNode
/**
* Setups the uv node. Depending on the backend as well as the texture type, it might be necessary
* to modify the uv node for correct sampling.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {Node} uvNode - The uv node to setup.
* @return {Node} The updated uv node.
*/
setupUV( builder, uvNode ) {
const texture = this.value;
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem || ! texture.isRenderTargetTexture ) {
uvNode = vec3( uvNode.x.negate(), uvNode.yz );
}
return materialEnvRotation.mul( uvNode );
}
/**
* Generates the uv code snippet.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {Node} cubeUV - The uv node to generate code for.
* @return {string} The generated code snippet.
*/
generateUV( builder, cubeUV ) {
return cubeUV.build( builder, 'vec3' );
}
}
Methods¶
getInputType(): string
¶
getDefaultUV(): any
¶
Code
getDefaultUV() {
const texture = this.value;
if ( texture.mapping === CubeReflectionMapping ) {
return reflectVector;
} else if ( texture.mapping === CubeRefractionMapping ) {
return refractVector;
} else {
console.error( 'THREE.CubeTextureNode: Mapping "%s" not supported.', texture.mapping );
return vec3( 0, 0, 0 );
}
}