@@ -919,20 +919,28 @@ class Geometry {
919919 * <a href="#/p5.Geometry/vertexNormals">myGeometry.vertexNormals</a> array.
920920 *
921921 * The first parameter, `shadingType`, is optional. Passing the constant
922- * `FLAT`, as in `myGeometry.computeNormals(FLAT)`, provides neighboring
923- * faces with their own copies of the vertices they share. Surfaces appear
924- * tiled with flat shading. Passing the constant `SMOOTH`, as in
925- * `myGeometry.computeNormals(SMOOTH)`, makes neighboring faces reuse their
926- * shared vertices. Surfaces appear smoother with smooth shading. By
927- * default, `shadingType` is `FLAT`.
922+ * `KEEP_CONNECTIONS`, as in `myGeometry.computeNormals(KEEP_CONNECTIONS)`,
923+ * preserves the geometry's existing vertex connections. Each vertex normal
924+ * is calculated by averaging the face normals of its connected faces.
925+ * This may produce smooth transitions between connected faces rather
926+ * than true flat shading.
927+ *
928+ * Passing the constant `SMOOTH`, as in
929+ * `myGeometry.computeNormals(SMOOTH)`, calculates smooth normals by
930+ * grouping vertices with approximately matching positions, without
931+ * modifying the original vertices or their attributes.
932+ *
933+ * The constant `FLAT` is deprecated and behaves identically to
934+ * `KEEP_CONNECTIONS`. It is retained for backward compatibility.
935+ * By default, `shadingType` is `KEEP_CONNECTIONS`.
928936 *
929937 * The second parameter, `options`, is also optional. If an object with a
930938 * `roundToPrecision` property is passed, as in
931939 * `myGeometry.computeNormals(SMOOTH, { roundToPrecision: 5 })`, it sets the
932940 * number of decimal places to use for calculations. By default,
933941 * `roundToPrecision` uses 3 decimal places.
934942 *
935- * @param {(FLAT |SMOOTH) } [shadingType=FLAT ] shading type. either FLAT or SMOOTH. Defaults to `FLAT `.
943+ * @param {(KEEP_CONNECTIONS |SMOOTH) } [shadingType=KEEP_CONNECTIONS ] shading type. Defaults to `KEEP_CONNECTIONS `.
936944 * @param {Object } [options] shading options.
937945 * @chainable
938946 *
@@ -1055,8 +1063,8 @@ class Geometry {
10551063 * // Create a p5.Geometry object.
10561064 * myGeometry = buildGeometry(createShape);
10571065 *
1058- * // Compute normals using default (FLAT) shading .
1059- * myGeometry.computeNormals(FLAT );
1066+ * // Compute normals while preserving existing vertex connections .
1067+ * myGeometry.computeNormals(KEEP_CONNECTIONS );
10601068 *
10611069 * describe('A white, helical structure drawn on a dark gray background. Its faces appear faceted.');
10621070 * }
@@ -1191,7 +1199,7 @@ class Geometry {
11911199 * endShape();
11921200 * }
11931201 */
1194- computeNormals ( shadingType = constants . FLAT , { roundToPrecision = 3 } = { } ) {
1202+ computeNormals ( shadingType = constants . KEEP_CONNECTIONS , { roundToPrecision = 3 } = { } ) {
11951203 const vertexNormals = this . vertexNormals ;
11961204 const vertices = this . vertices ;
11971205 const faces = this . faces ;
0 commit comments