Skip to content

geometry.setAttribute is not working #29795

@Lafeu-p

Description

@Lafeu-p

Description

I used to work with WebGLRenderer and often had requirements for custom meshes, such as defining an IconMesh that includes IconGeometry (extending from BufferGeometry) and an IconMaterial. IconGeometry requires an attribute for rendering, and I use geometry.setAttribute('position', new Float32BufferAttribute(array, 3)) to update the attribute.
For example, during initialization, I use geometry.setAttribute('position', new Float32BufferAttribute(array, 3)) with array.length being 1200. Later, I have an update requirement where the array changes and array.length becomes 2400. At this point, I again use geometry.setAttribute('position', new Float32BufferAttribute(array, 3)) to update the attribute. This worked well with WebGLRenderer, but recently when using WebGPURenderer, it results in an error
image

At this point, I need to call material.needsUpdate = true to update the material for it to take effect. It doesn’t seem reasonable that updating an attribute would require recompiling the material.
I understand that it’s best not to modify the size of the buffer in BufferGeometry, as doing so would likely cause the buffer to be recreated. However, in my use case (based on WebGLRenderer), this hasn’t caused any noticeable performance issues, and being able to reset the size of the attribute is what I want.

Reproduction steps

  1. init geometry based on WebGPURenderer
  2. geometry.setAttribute('position', new Float32BufferAttribute(array, 3)),array.length being 1200
  3. geometry.setAttribute('position', new Float32BufferAttribute(array, 3)),array.length being 2400

Code

geometry.setAttribute('position', new Float32BufferAttribute(array, 3))

Live example

empty

Screenshots

No response

Version

170dev

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions