Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

layerImage

layerImage(inputOptions?): FragmentLayer

Defined in: packages/node-image/src/layer.ts:230

Creates an image layer that renders images inside nodes.

This layer includes lifecycle management for automatic texture handling. When used with createNodeProgram(), the layer will:

  • Create/use a TextureManager to load and manage images
  • Automatically bind textures before rendering
  • Regenerate shaders when texture count changes
  • Trigger re-renders when images finish loading

Parameters

inputOptions?

Partial<LayerImageOptions>

Image layer configuration options

Returns

FragmentLayer

FragmentLayer definition with lifecycle

Example

// Simple usage - TextureManager created automatically
const Program = createNodeProgram({
shapes: [sdfCircle()],
layers: [layerImage({ drawingMode: "image", padding: 0.1 })],
});
// Shared TextureManager across multiple programs
const sharedTM = new TextureManager();
const Program1 = createNodeProgram({
shapes: [sdfCircle()],
layers: [layerImage({ textureManager: sharedTM })],
});