Skip to content
sigma.js sigma.js
v4.0.6 Docs Examples GitHub 12.2K

NodeDataTexture

Defined in: packages/sigma/src/rendering/node-data-texture.ts:35

Manages a GPU texture storing node data, two RGBA32F texels per node.

Texel 0 - geometry, read by every node-data consumer:

  • R: x position (graph coordinates)
  • G: y position (graph coordinates)
  • B: size
  • A: shapeId (integer ID for shape registry lookup)

Texel 1 - rotation flags (0 = viewport/screen-upright, 1 = graph) and color:

  • R: nodeRotation (shape orientation follows the camera)
  • G: labelRotation (label orbits/turns with the camera)
  • B: color RGB packed as r65536 + g256 + b (< 2^24, exact in float32)
  • A: color alpha in [0, 1]

Node index N maps to a base texel N * 2; consumers fetch texel 0 there and texel 1 at N * 2 + 1 (see GLSL_READ_NODE_DATA / GLSL_READ_NODE_FLAGS / GLSL_READ_NODE_COLOR).

new NodeDataTexture(gl, initialCapacity?): NodeDataTexture

Defined in: packages/sigma/src/rendering/node-data-texture.ts:36

WebGL2RenderingContext

number

NodeDataTexture

DataTexture.constructor

allocate(key): number

Defined in: packages/sigma/src/rendering/data-texture.ts:152

Allocates a texture index for an item. Returns existing index if item already allocated.

string | number

number

DataTexture.allocate


bind(textureUnit): void

Defined in: packages/sigma/src/rendering/data-texture.ts:271

Binds the texture to a texture unit.

number

void

DataTexture.bind


clear(): void

Defined in: packages/sigma/src/rendering/data-texture.ts:339

Clears all item allocations (but keeps the texture).

void

DataTexture.clear


free(key): void

Defined in: packages/sigma/src/rendering/data-texture.ts:179

Frees an item’s texture index for reuse.

string | number

void

DataTexture.free


getCapacity(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:287

Gets the current capacity (max items).

number

DataTexture.getCapacity


getCount(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:316

Gets the number of allocated items.

number

DataTexture.getCount


getHighWaterMark(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:325

Highest index ever allocated + 1. Unlike getCount, this spans freed holes, so it bounds every live item’s row (what a per-row gl_VertexID pass must cover).

number

DataTexture.getHighWaterMark


getIndex(key): number

Defined in: packages/sigma/src/rendering/data-texture.ts:199

Gets the texture index for an item. Returns -1 if item not found.

string | number

number

DataTexture.getIndex


getTexelsPerItem(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:309

Gets the number of texels per item.

number

DataTexture.getTexelsPerItem


getTexture(): WebGLTexture | null

Defined in: packages/sigma/src/rendering/data-texture.ts:280

Gets the WebGL texture object.

WebGLTexture | null

DataTexture.getTexture


getTextureHeight(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:302

Gets the texture height (needed to cover the full texture when rendering into it).

number

DataTexture.getTextureHeight


getTextureWidth(): number

Defined in: packages/sigma/src/rendering/data-texture.ts:294

Gets the texture width (needed for 2D coordinate calculation in shaders).

number

DataTexture.getTextureWidth


has(key): boolean

Defined in: packages/sigma/src/rendering/data-texture.ts:206

Checks if an item has been allocated.

string | number

boolean

DataTexture.has


isDirty(): boolean

Defined in: packages/sigma/src/rendering/data-texture.ts:332

Checks if there are pending changes to upload.

boolean

DataTexture.isDirty


kill(): void

Defined in: packages/sigma/src/rendering/data-texture.ts:360

Destroys the texture and clears all data.

void

DataTexture.kill


restore(): void

Defined in: packages/sigma/src/rendering/data-texture.ts:350

Recreates the GPU texture after a context loss, re-uploading the CPU-side data.

void

DataTexture.restore


updateNode(nodeKey, x, y, size, shapeId, nodeRotation, labelRotation, color): void

Defined in: packages/sigma/src/rendering/node-data-texture.ts:44

Updates all data for a node. nodeRotation and labelRotation are the per-node rotation-alignment flags (0 = viewport, 1 = graph).

string

number

number

number

number

number

number

string

void


upload(): void

Defined in: packages/sigma/src/rendering/data-texture.ts:223

Uploads dirty data to the GPU texture. With 2D layout and multiple texels per item, uploads affected rows.

void

DataTexture.upload