SquareDataTexture
Defined in: core/utils/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
unknown
Constructors
new SquareDataTexture()
new SquareDataTexture(
arrayType
,channels
,pixelsPerInstance
,capacity
,uniformMap
?,fetchInFragmentShader
?):SquareDataTexture
Defined in: core/utils/SquareDataTexture.ts:121
Parameters
arrayType
The constructor for the TypedArray.
channels
The number of channels in the texture.
pixelsPerInstance
number
The number of pixels required for each instance.
capacity
number
The total number of instances.
uniformMap?
Optional map for handling uniform values.
fetchInFragmentShader?
boolean
Optional flag that determines if uniform values should be fetched in the fragment shader instead of the vertex shader.
Returns
Overrides
DataTexture.constructor
Properties
maxUpdateCalls
maxUpdateCalls:
number
=Infinity
Defined in: core/utils/SquareDataTexture.ts:101
The maximum number of update calls per frame.
Default
Infinity
partialUpdate
partialUpdate:
boolean
=true
Defined in: core/utils/SquareDataTexture.ts:96
Whether to enable partial texture updates by row. If false
, the entire texture will be updated.
Default
true.
Methods
copy()
copy(
source
):this
Defined in: core/utils/SquareDataTexture.ts:403
Parameters
source
Returns
this
enqueueUpdate()
enqueueUpdate(
index
):void
Defined in: core/utils/SquareDataTexture.ts:161
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
index
number
The index of the instance to update.
Returns
void
getUniformAt()
getUniformAt(
id
,name
,target
?):any
Defined in: core/utils/SquareDataTexture.ts:274
Retrieves a uniform value at the specified instance ID from the texture.
Parameters
id
number
The instance ID to retrieve the uniform from.
name
string
The name of the uniform.
target?
any
Optional target object to store the uniform value.
Returns
any
The uniform value for the specified instance.
getUniformsGLSL()
getUniformsGLSL(
textureName
,indexName
,indexType
):object
Defined in: core/utils/SquareDataTexture.ts:292
Generates the GLSL code for accessing the uniform data stored in the texture.
Parameters
textureName
string
The name of the texture in the GLSL shader.
indexName
string
The name of the index in the GLSL shader.
indexType
string
The type of the index in the GLSL shader.
Returns
object
An object containing the GLSL code for the vertex and fragment shaders.
fragment
fragment:
string
vertex
vertex:
string
resize()
resize(
count
):void
Defined in: core/utils/SquareDataTexture.ts:138
Resizes the texture to accommodate a new number of instances.
Parameters
count
number
The new total number of instances.
Returns
void
setUniformAt()
setUniformAt(
id
,name
,value
):void
Defined in: core/utils/SquareDataTexture.ts:256
Sets a uniform value at the specified instance ID in the texture.
Parameters
id
number
The instance ID to set the uniform for.
name
string
The name of the uniform.
value
any
The value to set for the uniform.
Returns
void
update()
update(
renderer
):void
Defined in: core/utils/SquareDataTexture.ts:175
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
renderer
WebGLRenderer
The WebGLRenderer used for rendering.
Returns
void