Three drops indices when converting from a Geometry > BufferGeometry
See original GitHub issueDescription of the problem
Every face in a Geometry
has a materialIndex
. When Three converts from a Geometry to a BufferGeometry…
var bufferGeometry = THREE.BufferGeometry.new().fromGeometry(geometry);
…there’s an intermediary step where a DirectGeometry is used…
fromGeometry: function ( geometry ) {
geometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );
Note that a DirectGeometry
defines an indices
array, then does nothing with it.
So it’s not surprising when BufferGeometry checks the intermediary directGeometry.indices.length
, it won’t ever be populated.
When the BufferGeometry comes out the other end, it has no indices. bufferGeometry.getIndex()
is null.
It looks like DirectGeometry’s ability to handle indices was removed two years ago.
Here’s a CodePen demonstrating the problem. Check the logs. The merged geometry should have indices returned, but it doesn’t. https://codepen.io/andrewray/pen/gRyrzR?editors=0010
Three.js version
- Dev
- r85
Browser
- All of them
OS
- All of them
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
update indices of a bufferGeometry in three.js - Stack Overflow
You want to update the indices of your indexed- BufferGeometry after the geometry has been rendered. To do so, you cannot reassign a...
Read more >3d - Which provides better intuition: THREE.Geometry or ...
Note that BufferGeometry still supports both indexed and non-indexed meshes. It contains arrays of vertex attributes and indices, and works ...
Read more >BufferGeometry – three.js docs
A representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing ...
Read more >Tips & Tricks for speeding up Three.js - Attacking Pixels
BufferGeometry is an efficient representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colours, UVs, ...
Read more >[Solved]-THREE.BufferGeometry - accessing face indices and ...
SphereGeometry , derived from BufferGeometry , is of the indexed type. You can access the face normals in the geometry data structure like...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Bryce-Summers If you mean the option to return indexed
BufferGeometry
, no, because in most cases it is not reasonable, and it adds a lot of additional logic to the loader.BTW, would returning non-indexed
BufferGeoemtry
and simply adding an attributeoriginalIndex
solve your problem?materialIndex
andindices
are different things though.materialIndex
refers to multi-materials.indices
refer to attribute indices.Good catch!
It was also added some weeks before that. Basically, I was trying to keep indices somehow but it was not really possible so I removed it.