* Averages the vertex normals. Used in curved * surfaces * @private * @chainable
()
| 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 |