Skip to content

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.

  • unknown

new SquareDataTexture(arrayType, channels, pixelsPerInstance, capacity, uniformMap?, fetchInFragmentShader?): SquareDataTexture

Defined in: core/SquareDataTexture.ts:121

TypedArrayConstructor

The constructor for the TypedArray.

ChannelSize

The number of channels in the texture.

number

The number of pixels required for each instance.

number

The total number of instances.

UniformMap

Optional map for handling uniform values.

boolean

Optional flag that determines if uniform values should be fetched in the fragment shader instead of the vertex shader.

SquareDataTexture

DataTexture.constructor

maxUpdateCalls: number = Infinity

Defined in: core/SquareDataTexture.ts:101

The maximum number of update calls per frame.

Infinity

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.

true.

copy(source): this

Defined in: core/SquareDataTexture.ts:404

SquareDataTexture

this


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.

number

The index of the instance to update.

void


getUniformAt(id, name, target?): any

Defined in: core/SquareDataTexture.ts:275

Retrieves a uniform value at the specified instance ID from the texture.

number

The instance ID to retrieve the uniform from.

string

The name of the uniform.

any

Optional target object to store the uniform value.

any

The uniform value for the specified instance.


getUniformsGLSL(textureName, indexName, indexType): object

Defined in: core/SquareDataTexture.ts:293

Generates the GLSL code for accessing the uniform data stored in the texture.

string

The name of the texture in the GLSL shader.

string

The name of the index in the GLSL shader.

string

The type of the index in the GLSL shader.

object

An object containing the GLSL code for the vertex and fragment shaders.

fragment: string

vertex: string


resize(count): void

Defined in: core/SquareDataTexture.ts:139

Resizes the texture to accommodate a new number of instances.

number

The new total number of instances.

void


setUniformAt(id, name, value): void

Defined in: core/SquareDataTexture.ts:257

Sets a uniform value at the specified instance ID in the texture.

number

The instance ID to set the uniform for.

string

The name of the uniform.

any

The value to set for the uniform.

void


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.

WebGLRenderer

The WebGLRenderer used for rendering.

void