Skip to content

Texture: Support update ranges with other formats than RGBA. #32469

@rotu

Description

@rotu

Description

Creating a non-RGBA texture and using the partial texture update via addUpdateRange doesn't update the intended part of the texture.

Reproduction steps

See fiddle https://jsfiddle.net/vx3u16zj/2/

Code

  const width = 8;
  const height = 8;
  const data = new Float32Array(width * height);
  for (let i = 0; i < data.length; ++i) {
    data[i] = i / data.length;
  }
  const dataTexture = new THREE.DataTexture(data, width, height);
  dataTexture.format = THREE.RedFormat;
  dataTexture.type = THREE.FloatType;
  dataTexture.internalFormat = 'RED32F';
  dataTexture.needsUpdate = true;


  setTimeout(() => {
    data.fill(0);
    // this should update the 12 texels starting at #32
    // instead it updates the 3 texels starting at #8
    dataTexture.addUpdateRange(32, 12);
    dataTexture.needsUpdate = true;
  }, 1000);

Live example

https://jsfiddle.net/vx3u16zj/2/

Screenshots

Image

Version

0.181.2

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions