📄 StorageTextureNode.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 10 |
🧱 Classes | 1 |
📦 Imports | 3 |
📊 Variables & Constants | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/nodes/accessors/StorageTextureNode.js
📦 Imports¶
Name | Source |
---|---|
TextureNode |
./TextureNode.js |
nodeProxy |
../tsl/TSLBase.js |
NodeAccess |
../core/constants.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
snippet |
any |
let/var | *not shown* |
✗ |
depthSnippet |
any |
let/var | depthNode ? depthNode.build( builder, 'int' ) : null |
✗ |
Functions¶
StorageTextureNode.getInputType(): string
¶
JSDoc:
/**
* Overwrites the default implementation to return a fixed value `'storageTexture'`.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
Returns: string
StorageTextureNode.setup(builder: any): any
¶
Parameters:
builder
any
Returns: any
Calls:
super.setup
builder.getNodeProperties
Code
StorageTextureNode.setAccess(value: string): StorageTextureNode
¶
JSDoc:
/**
* Defines the node access.
*
* @param {string} value - The node access.
* @return {StorageTextureNode} A reference to this node.
*/
Parameters:
value
string
Returns: StorageTextureNode
StorageTextureNode.generate(builder: NodeBuilder, output: string): string
¶
JSDoc:
/**
* Generates the code snippet of the storage node. If no `storeNode`
* is defined, the texture node is generated as normal texture.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} output - The current output.
* @return {string} The generated code snippet.
*/
Parameters:
builder
NodeBuilder
output
string
Returns: string
Calls:
this.generateStore
super.generate
Code
StorageTextureNode.toReadWrite(): StorageTextureNode
¶
JSDoc:
/**
* Convenience method for configuring a read/write node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
Returns: StorageTextureNode
Calls:
this.setAccess
StorageTextureNode.toReadOnly(): StorageTextureNode
¶
JSDoc:
/**
* Convenience method for configuring a read-only node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
Returns: StorageTextureNode
Calls:
this.setAccess
StorageTextureNode.toWriteOnly(): StorageTextureNode
¶
JSDoc:
/**
* Convenience method for configuring a write-only node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
Returns: StorageTextureNode
Calls:
this.setAccess
StorageTextureNode.generateStore(builder: NodeBuilder): void
¶
JSDoc:
/**
* Generates the code snippet of the storage texture node.
*
* @param {NodeBuilder} builder - The current node builder.
*/
Parameters:
builder
NodeBuilder
Returns: void
Calls:
builder.getNodeProperties
super.generate
uvNode.build
storeNode.build
depthNode.build
builder.generateTextureStore
builder.addLineFlowCode
Code
generateStore( builder ) {
const properties = builder.getNodeProperties( this );
const { uvNode, storeNode, depthNode } = properties;
const textureProperty = super.generate( builder, 'property' );
const uvSnippet = uvNode.build( builder, this.value.is3DTexture === true ? 'uvec3' : 'uvec2' );
const storeSnippet = storeNode.build( builder, 'vec4' );
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, depthSnippet, storeSnippet );
builder.addLineFlowCode( snippet, this );
}
StorageTextureNode.clone(): TextureNode
¶
Returns: TextureNode
Calls:
super.clone
textureStore(value: StorageTexture, uvNode: any, storeNode: Node): StorageTextureNode
¶
Parameters:
value
StorageTexture
uvNode
any
storeNode
Node
Returns: StorageTextureNode
Calls:
storageTexture
node.toStack
Code
Classes¶
StorageTextureNode
¶
Class Code
class StorageTextureNode extends TextureNode {
static get type() {
return 'StorageTextureNode';
}
/**
* Constructs a new storage texture node.
*
* @param {StorageTexture} value - The storage texture.
* @param {Node<vec2|vec3>} uvNode - The uv node.
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
*/
constructor( value, uvNode, storeNode = null ) {
super( value, uvNode );
/**
* The value node that should be stored in the texture.
*
* @type {?Node}
* @default null
*/
this.storeNode = storeNode;
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isStorageTextureNode = true;
/**
* The access type of the texture node.
*
* @type {string}
* @default 'writeOnly'
*/
this.access = NodeAccess.WRITE_ONLY;
}
/**
* Overwrites the default implementation to return a fixed value `'storageTexture'`.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
getInputType( /*builder*/ ) {
return 'storageTexture';
}
setup( builder ) {
super.setup( builder );
const properties = builder.getNodeProperties( this );
properties.storeNode = this.storeNode;
return properties;
}
/**
* Defines the node access.
*
* @param {string} value - The node access.
* @return {StorageTextureNode} A reference to this node.
*/
setAccess( value ) {
this.access = value;
return this;
}
/**
* Generates the code snippet of the storage node. If no `storeNode`
* is defined, the texture node is generated as normal texture.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} output - The current output.
* @return {string} The generated code snippet.
*/
generate( builder, output ) {
let snippet;
if ( this.storeNode !== null ) {
snippet = this.generateStore( builder );
} else {
snippet = super.generate( builder, output );
}
return snippet;
}
/**
* Convenience method for configuring a read/write node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
toReadWrite() {
return this.setAccess( NodeAccess.READ_WRITE );
}
/**
* Convenience method for configuring a read-only node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
toReadOnly() {
return this.setAccess( NodeAccess.READ_ONLY );
}
/**
* Convenience method for configuring a write-only node access.
*
* @return {StorageTextureNode} A reference to this node.
*/
toWriteOnly() {
return this.setAccess( NodeAccess.WRITE_ONLY );
}
/**
* Generates the code snippet of the storage texture node.
*
* @param {NodeBuilder} builder - The current node builder.
*/
generateStore( builder ) {
const properties = builder.getNodeProperties( this );
const { uvNode, storeNode, depthNode } = properties;
const textureProperty = super.generate( builder, 'property' );
const uvSnippet = uvNode.build( builder, this.value.is3DTexture === true ? 'uvec3' : 'uvec2' );
const storeSnippet = storeNode.build( builder, 'vec4' );
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, depthSnippet, storeSnippet );
builder.addLineFlowCode( snippet, this );
}
clone() {
const newNode = super.clone();
newNode.storeNode = this.storeNode;
return newNode;
}
}
Methods¶
getInputType(): string
¶
setup(builder: any): any
¶
Code
setAccess(value: string): StorageTextureNode
¶
generate(builder: NodeBuilder, output: string): string
¶
Code
toReadWrite(): StorageTextureNode
¶
toReadOnly(): StorageTextureNode
¶
toWriteOnly(): StorageTextureNode
¶
generateStore(builder: NodeBuilder): void
¶
Code
generateStore( builder ) {
const properties = builder.getNodeProperties( this );
const { uvNode, storeNode, depthNode } = properties;
const textureProperty = super.generate( builder, 'property' );
const uvSnippet = uvNode.build( builder, this.value.is3DTexture === true ? 'uvec3' : 'uvec2' );
const storeSnippet = storeNode.build( builder, 'vec4' );
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, depthSnippet, storeSnippet );
builder.addLineFlowCode( snippet, this );
}