Skip to content

Geometry.fromBufferGeometry has an issue when reading InterleavedBuffer #17793

@Julianouyang

Description

@Julianouyang
Geometry.fromBufferGeometry produces wrong data when working with InterleavedBuffer

Assume we have a bufferGeometry with interleavedBufferAttribute as its attribute type.

There is an issue in geometry.js if we call Geometry.fromBufferGeometry(bufferGeometry).
The current code assumes that the type of attribute is BufferAttribute, but it also can be InterleavedBufferAttribute, and they cannot be read in the same way.

For BufferAttribute, we read attribute like position, normal individually. But for InterleavedBufferAttribute, it returns a typed array that bundles all attributes together. So we need to read the data based on its offset and itemsize.

It might be better to support reading attribute individually in InterleavedBufferAttribute class, but at least we need a quick fix in the geometry method.

If you all think this is a bug and nobody is fixing it right now, I can open a PR. I can also create a jsfiddle if you think it's necessary to demonstrate the wrong data output.

Three.js version
  • Dev
  • r109
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions