MCPcopy Index your code
hub / github.com/processing/p5.js / averageNormals

Method averageNormals

src/webgl/p5.Geometry.js:1235–1248  ·  view source on GitHub ↗

* Averages the vertex normals. Used in curved * surfaces * @private * @chainable

()

Source from the content-addressed store, hash-verified

1233 * @chainable
1234 */
1235 averageNormals() {
1236 for (let i = 0; i <= this.detailY; i++) {
1237 const offset = this.detailX + 1;
1238 let temp = Vector.add(
1239 this.vertexNormals[i * offset],
1240 this.vertexNormals[i * offset + this.detailX]
1241 );
1242
1243 temp = Vector.div(temp, 2);
1244 this.vertexNormals[i * offset] = temp;
1245 this.vertexNormals[i * offset + this.detailX] = temp;
1246 }
1247 return this;
1248 }
1249
1250 /**
1251 * Averages pole normals. Used in spherical primitives

Callers

nothing calls this directly

Calls 2

divMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected