You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method calls BufferGeometry.toNonIndexed() to convert possibly indexed geometries to non-indexed ones but does not check whether a geometry is already non-indexed.
It seems that BufferGeometry.toNonIndexed() should not be called when the geometry is not indexed, producing the warning.
In this case and contrary to documentation, no new geometry is returned but this geometry, which may be the reason for the warning, and the functions that trigger such a warning would be working on the original geometry, not on a non-indexed copy.
Suggested solution
Alternatives:
Call BufferGeometry.toNonIndexed() only if geometry is indexed. Use the original geometry, as is already the case because BufferGeometry.toNonIndexed() returns this if the geometry is non-indexed.
✅ Simple solution that removes the warning without changing behavior otherwise
✅ Backwards compatible: drei's <RoundedBox> depends on this behavior.
❌ Keeps modifying the original geometry if it is non-indexed.
Clone the geometry if it is non-indexed. Always operate on a new geometry.
✅ Simple predictable behavior that follows the immutability pattern
❌ Breaking change
Require the provided geometry to be indexed, fail otherwise.
❌ Not very useful
❌ Breaking change
Add optional parameter (e.g. cloneIfNonIndexed) to control behavior. If missing or falsy, behave like in suggestion 1. If truthy, clone the geometry if it is already non-indexed like in 2.
✅ Optional immutability pattern
✅ Backwards compatible (unless someone had been calling toCreasedNormals() with a third argument that is truthy)
❌ Redundant additional checks that could run outside the method – the caller may have cloned already
Change BufferGeometry.toNonIndexed() to return a cloned geometry if it is already non-indexed
❌ The caller can check if a geometry is indexed by checking the BufferGeometry.index property, which is what other code does, and clone the geometry if needed
❌ Breaking change
Change BufferGeometry.toNonIndexed() to throw an error
❌ Same drawbacks as 5. in addition to:
❌ Breaks all downstream code – toCreasedNormals() would need to change, and some code like @react-three/drei's <RoundedBox> rely on toCreasedNormals() to mutate the original geometry (though I should mention that drei uses three-stdlib, not the code from three.js examples.
Description
BufferGeometryUtils.toCreasedNormals()
produces a warning if the provided geometry is non-indexed:The method calls
BufferGeometry.toNonIndexed()
to convert possibly indexed geometries to non-indexed ones but does not check whether a geometry is already non-indexed.It seems that
BufferGeometry.toNonIndexed()
should not be called when the geometry is not indexed, producing the warning.In this case and contrary to documentation, no new geometry is returned but
this
geometry, which may be the reason for the warning, and the functions that trigger such a warning would be working on the original geometry, not on a non-indexed copy.Suggested solution
Alternatives:
BufferGeometry.toNonIndexed()
only if geometry is indexed. Use the original geometry, as is already the case becauseBufferGeometry.toNonIndexed()
returnsthis
if the geometry is non-indexed.<RoundedBox>
depends on this behavior.cloneIfNonIndexed
) to control behavior. If missing or falsy, behave like in suggestion 1. If truthy, clone the geometry if it is already non-indexed like in 2.toCreasedNormals()
with a third argument that is truthy)BufferGeometry.toNonIndexed()
to return a cloned geometry if it is already non-indexedBufferGeometry.index
property, which is what other code does, and clone the geometry if neededBufferGeometry.toNonIndexed()
to throw an errortoCreasedNormals()
would need to change, and some code like @react-three/drei's<RoundedBox>
rely ontoCreasedNormals()
to mutate the original geometry (though I should mention that drei usesthree-stdlib
, not the code from three.js examples.I prefer solution 1. because it is the simplest.
See PR #26379
See also
BufferGeometryUtils.toCreasedNormals() produces warning for non-indexed geometries pmndrs/three-stdlib#268
BufferGeometry.toNonIndexed() warns about
BufferGeometry is already non-indexed
Reproduction steps
BufferGeometryUtils.toCreasedNormals()
on the geometryTHREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.
Code
Live example
Screenshots
No response
Version
154
Device
No response
Browser
No response
OS
No response
The text was updated successfully, but these errors were encountered: