diff --git a/docs/examples/en/utils/BufferGeometryUtils.html b/docs/examples/en/utils/BufferGeometryUtils.html index 1b4fe1f4f83fa5..479d62d233e210 100644 --- a/docs/examples/en/utils/BufferGeometryUtils.html +++ b/docs/examples/en/utils/BufferGeometryUtils.html @@ -122,11 +122,19 @@

[method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [par

[method:BufferGeometry toCreasedNormals]( [param:BufferGeometry geometry], [param:Number creaseAngle] )

+ +

- geometry -- The input geometry.
- creaseAngle -- The crease angle.

+ Modifies the supplied geometry if it is non-indexed, otherwise creates a new, + non-indexed geometry. +

- Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at an angle greater than the crease angle. +

+ Returns the geometry with smooth normals everywhere except faces + that meet at an angle greater than the crease angle.

[method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )

diff --git a/docs/examples/zh/utils/BufferGeometryUtils.html b/docs/examples/zh/utils/BufferGeometryUtils.html index 4e8c9bbc3ad9bc..fcf71105d46443 100644 --- a/docs/examples/zh/utils/BufferGeometryUtils.html +++ b/docs/examples/zh/utils/BufferGeometryUtils.html @@ -120,12 +120,19 @@

[method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [par

[method:BufferGeometry toCreasedNormals]( [param:BufferGeometry geometry], [param:Number creaseAngle] )

+ +

- geometry -- The input geometry.
- creaseAngle -- The crease angle. + Modifies the supplied geometry if it is non-indexed, otherwise creates a new, + non-indexed geometry.

+

- Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at an angle greater than the crease angle. + Returns the geometry with smooth normals everywhere except faces + that meet at an angle greater than the crease angle.

[method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )

diff --git a/examples/jsm/utils/BufferGeometryUtils.js b/examples/jsm/utils/BufferGeometryUtils.js index ff86be0b7a8de9..56179a04d9e82c 100644 --- a/examples/jsm/utils/BufferGeometryUtils.js +++ b/examples/jsm/utils/BufferGeometryUtils.js @@ -1229,14 +1229,21 @@ function mergeGroups( geometry ) { } -// Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at -// an angle greater than the crease angle. +/** + * Modifies the supplied geometry if it is non-indexed, otherwise creates a new, + * non-indexed geometry. Returns the geometry with smooth normals everywhere except + * faces that meet at an angle greater than the crease angle. + * + * @param {BufferGeometry} geometry + * @param {number} [creaseAngle] + * @return {BufferGeometry} + */ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */ ) { const creaseDot = Math.cos( creaseAngle ); const hashMultiplier = ( 1 + 1e-10 ) * 1e2; - // reusable vertors + // reusable vectors const verts = [ new Vector3(), new Vector3(), new Vector3() ]; const tempVec1 = new Vector3(); const tempVec2 = new Vector3(); @@ -1253,7 +1260,9 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */ } - const resultGeometry = geometry.toNonIndexed(); + // BufferGeometry.toNonIndexed() warns if the geometry is non-indexed + // and returns the original geometry + const resultGeometry = geometry.index ? geometry.toNonIndexed() : geometry; const posAttr = resultGeometry.attributes.position; const vertexMap = {};