question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Geometry.fromBufferGeometry has an issue when reading InterleavedBuffer

See original GitHub issue
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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
WestLangleycommented, Oct 23, 2019

If we have indices in triangle strip mode, the resulting faces could go wrong

Related https://github.com/mrdoob/three.js/pull/17369#issuecomment-525567364.

Also see the discussion in https://github.com/mrdoob/three.js/issues/9869.

1reaction
WestLangleycommented, Oct 22, 2019

I can open a PR.

Sure, why not? I think WireframeGeometry supports interleaved buffers…

Read more comments on GitHub >

github_iconTop Results From Across the Web

three.js - Difference between buffer geometry and geometry
The difference is essentially in underlying data structures (how geometry stores and handles vertices, faces etc in memory).
Read more >
InterleavedBuffer – three.js docs
"Interleaved" means that multiple attributes, possibly of different types, (e.g., position, normal, uv, color) are packed into a single array buffer. An ...
Read more >
Updating THREE.Geometry to THREE.BufferGeometry
Geometry is more intuitive to read and edit from a human perspective, but it is slower to process in the WebGL shader code...
Read more >
Team:Munich/Hardware/threeJS
// We compute the minimum and maximum dot product values. If those values // are on the same side (back or front) of...
Read more >
JavaScript 3D library
InterleavedBufferAttribute ( interleavedBuffer, itemSize, offset, normalized ); function three. ... fromBufferGeometry ( geometry ); function three.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found