SquareDataTexture
Defined in: core/SquareDataTexture.ts:91
A class that extends DataTexture
to manage a square texture optimized for instances rendering.
It supports dynamic resizing, partial update based on rows, and allows setting/getting uniforms per instance.
Extends
Section titled “Extends”unknown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SquareDataTexture(
arrayType
,channels
,pixelsPerInstance
,capacity
,uniformMap?
,fetchInFragmentShader?
):SquareDataTexture
Defined in: core/SquareDataTexture.ts:121
Parameters
Section titled “Parameters”arrayType
Section titled “arrayType”The constructor for the TypedArray.
channels
Section titled “channels”The number of channels in the texture.
pixelsPerInstance
Section titled “pixelsPerInstance”number
The number of pixels required for each instance.
capacity
Section titled “capacity”number
The total number of instances.
uniformMap?
Section titled “uniformMap?”Optional map for handling uniform values.
fetchInFragmentShader?
Section titled “fetchInFragmentShader?”boolean
Optional flag that determines if uniform values should be fetched in the fragment shader instead of the vertex shader.
Returns
Section titled “Returns”SquareDataTexture
Overrides
Section titled “Overrides”DataTexture.constructor
Properties
Section titled “Properties”maxUpdateCalls
Section titled “maxUpdateCalls”maxUpdateCalls:
number
=Infinity
Defined in: core/SquareDataTexture.ts:101
The maximum number of update calls per frame.
Default
Section titled “Default”Infinity
partialUpdate
Section titled “partialUpdate”partialUpdate:
boolean
=true
Defined in: core/SquareDataTexture.ts:96
Whether to enable partial texture updates by row. If false
, the entire texture will be updated.
Default
Section titled “Default”true.
Methods
Section titled “Methods”copy()
Section titled “copy()”copy(
source
):this
Defined in: core/SquareDataTexture.ts:404
Parameters
Section titled “Parameters”source
Section titled “source”SquareDataTexture
Returns
Section titled “Returns”this
enqueueUpdate()
Section titled “enqueueUpdate()”enqueueUpdate(
index
):void
Defined in: core/SquareDataTexture.ts:162
Marks a row of the texture for update during the next render cycle. This helps in optimizing texture updates by only modifying the rows that have changed.
Parameters
Section titled “Parameters”number
The index of the instance to update.
Returns
Section titled “Returns”void
getUniformAt()
Section titled “getUniformAt()”getUniformAt(
id
,name
,target?
):any
Defined in: core/SquareDataTexture.ts:275
Retrieves a uniform value at the specified instance ID from the texture.
Parameters
Section titled “Parameters”number
The instance ID to retrieve the uniform from.
string
The name of the uniform.
target?
Section titled “target?”any
Optional target object to store the uniform value.
Returns
Section titled “Returns”any
The uniform value for the specified instance.
getUniformsGLSL()
Section titled “getUniformsGLSL()”getUniformsGLSL(
textureName
,indexName
,indexType
):object
Defined in: core/SquareDataTexture.ts:293
Generates the GLSL code for accessing the uniform data stored in the texture.
Parameters
Section titled “Parameters”textureName
Section titled “textureName”string
The name of the texture in the GLSL shader.
indexName
Section titled “indexName”string
The name of the index in the GLSL shader.
indexType
Section titled “indexType”string
The type of the index in the GLSL shader.
Returns
Section titled “Returns”object
An object containing the GLSL code for the vertex and fragment shaders.
fragment
Section titled “fragment”fragment:
string
vertex
Section titled “vertex”vertex:
string
resize()
Section titled “resize()”resize(
count
):void
Defined in: core/SquareDataTexture.ts:139
Resizes the texture to accommodate a new number of instances.
Parameters
Section titled “Parameters”number
The new total number of instances.
Returns
Section titled “Returns”void
setUniformAt()
Section titled “setUniformAt()”setUniformAt(
id
,name
,value
):void
Defined in: core/SquareDataTexture.ts:257
Sets a uniform value at the specified instance ID in the texture.
Parameters
Section titled “Parameters”number
The instance ID to set the uniform for.
string
The name of the uniform.
any
The value to set for the uniform.
Returns
Section titled “Returns”void
update()
Section titled “update()”update(
renderer
):void
Defined in: core/SquareDataTexture.ts:176
Updates the texture data based on the rows that need updating. This method is optimized to only update the rows that have changed, improving performance.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”WebGLRenderer
The WebGLRenderer used for rendering.
Returns
Section titled “Returns”void