* Averages pole normals. Used in spherical primitives * @private * @chainable
()
| 1253 | * @chainable |
| 1254 | */ |
| 1255 | averagePoleNormals() { |
| 1256 | //average the north pole |
| 1257 | let sum = new Vector(0, 0, 0); |
| 1258 | for (let i = 0; i < this.detailX; i++) { |
| 1259 | sum.add(this.vertexNormals[i]); |
| 1260 | } |
| 1261 | sum = Vector.div(sum, this.detailX); |
| 1262 | |
| 1263 | for (let i = 0; i < this.detailX; i++) { |
| 1264 | this.vertexNormals[i] = sum; |
| 1265 | } |
| 1266 | |
| 1267 | //average the south pole |
| 1268 | sum = new Vector(0, 0, 0); |
| 1269 | for ( |
| 1270 | let i = this.vertices.length - 1; |
| 1271 | i > this.vertices.length - 1 - this.detailX; |
| 1272 | i-- |
| 1273 | ) { |
| 1274 | sum.add(this.vertexNormals[i]); |
| 1275 | } |
| 1276 | sum = Vector.div(sum, this.detailX); |
| 1277 | |
| 1278 | for ( |
| 1279 | let i = this.vertices.length - 1; |
| 1280 | i > this.vertices.length - 1 - this.detailX; |
| 1281 | i-- |
| 1282 | ) { |
| 1283 | this.vertexNormals[i] = sum; |
| 1284 | } |
| 1285 | return this; |
| 1286 | } |
| 1287 | |
| 1288 | /** |
| 1289 | * Create a 2D array for establishing stroke connections |