|
284 | 284 | var x=0, z=R2, newx, newz |
285 | 285 | //var k = 1/Math.cos(dphi/2) // multiply z by k to stretch along the joint; only 1.00121, so approximate by 1 |
286 | 286 | var shape = [] // list of x,z points in the xz plane representing the shape at a joint |
287 | | - for (var c=0; c<N; c++) { |
| 287 | + for (var i=0; i<N; i++) { |
288 | 288 | //shape.push(vec(x,0,k*z-k*R2)) |
289 | 289 | shape.push(vec(x,0,z-R2)) // oval starts at outer edge of ring |
290 | 290 | newx = x*cosd + z*sind |
|
293 | 293 | z = newz |
294 | 294 | } |
295 | 295 |
|
296 | | - var m = new Mesh() |
297 | 296 | var y=0, z=R1+R2, newy, newz |
298 | | - var pts = [] |
299 | 297 | var normals = [] |
300 | 298 | for (var c=0; c<NC; c++) { |
301 | 299 | var r = vec(0, y, z) // vector from origin to outer edge of oval cross section |
302 | | - for (var i=0; i<N; i++) { |
303 | | - pts.push(shape[i]) |
304 | | - normals.push(r) // use normal to contain the vector from origin to outer edge of the oval |
305 | | - } |
| 300 | + normals.push(r) // use normal to contain the vector from origin to outer edge of the oval |
| 301 | + |
306 | 302 | newy = y*cphi + z*sphi |
307 | 303 | newz = z*cphi - y*sphi |
308 | 304 | y = newy |
309 | 305 | z = newz |
310 | 306 | } |
311 | | - |
| 307 | + |
| 308 | + var m = new Mesh() |
312 | 309 | for (var c=0; c<NC; c++) { |
313 | 310 | for (var i=0; i<N; i++) { |
314 | 311 | var inext = (i+1) % N |
315 | 312 | var cnext = (c+1) % NC |
316 | | - var v0 = pts[c*N+i] |
| 313 | + var v0 = shape[i] |
317 | 314 | m.pos.push( v0.x,v0.y,v0.z ) |
318 | 315 |
|
319 | | - v0 = normals[c*N+i] |
| 316 | + v0 = normals[c] |
320 | 317 | m.normal.push( v0.x,v0.y,v0.z ) |
321 | 318 |
|
322 | 319 | m.color.push( 1,1,1 ) |
323 | | - |
324 | 320 | m.opacity.push( 1 ) |
325 | | - |
326 | 321 | m.shininess.push( 1 ) |
327 | | - |
328 | 322 | m.emissive.push( 0 ) |
329 | 323 |
|
330 | 324 | m.texpos.push( i/N, c/NC ) |
331 | 325 |
|
332 | | - v0 = pts[c*N+inext].sub(pts[c*N+i]) |
| 326 | + v0 = shape[inext].sub(shape[i]) |
333 | 327 | m.bumpaxis.push( v0.x,v0.y,v0.z ) |
334 | 328 |
|
335 | 329 | m.index.push( N*c+i,N*cnext+i,N*cnext+inext, N*c+i,N*cnext+inext,N*c+inext ) |
|
357 | 351 | var x=0, z=R2, newx, newz |
358 | 352 | //var k = 1/Math.cos(dphi/2) // multiply z by k to stretch along the joint; only 1.00121, so approximate by 1 |
359 | 353 | var shape = [] // list of x,z points in the xz plane representing the shape at a joint |
360 | | - for (var c=0; c<N; c++) { |
| 354 | + for (var i=0; i<N; i++) { |
361 | 355 | //shape.push(vec(x,0,k*z-k*R2)) |
362 | 356 | shape.push(vec(x,0,z-R2)) // oval starts at outer edge of ring |
363 | 357 | newx = x*cosd + z*sind |
|
398 | 392 | m.normal.push( v0.x,v0.y,v0.z ) |
399 | 393 |
|
400 | 394 | m.color.push( 1,1,1 ) |
401 | | - |
402 | 395 | m.opacity.push( 1 ) |
403 | | - |
404 | 396 | m.shininess.push( 1 ) |
405 | | - |
406 | 397 | m.emissive.push( 0 ) |
407 | 398 |
|
408 | 399 | m.texpos.push( i/N, c/NC ) |
|
0 commit comments