| 478 | |
| 479 | V primeru dodatnih kosov je potrebno ponastaviti transformacijo in narediti |
| 480 | novo mrežo, kot je to prikazano v naslednjem delčku kode. |
| 481 | {{{ |
| 482 | #!javascript |
| 483 | |
| 484 | xformMat.identity(); |
| 485 | rotMat.identity(); |
| 486 | rotMat.rotateAboutZAxis(180); |
| 487 | xformMat.multiply(rotMat); |
| 488 | xformMat.translate(500, 500, 0); |
| 489 | myMesh = new JSC3D.Mesh(); |
| 490 | myMesh.vertexBuffer = new Array( meshes[i].vertexBuffer.length); |
| 491 | myMesh.faceNormalBuffer = new Array( meshes[i].faceNormalBuffer.length); |
| 492 | myMesh.indexBuffer = meshes[i].indexBuffer; |
| 493 | |
| 494 | // transform and rewrite vertex coordinates |
| 495 | JSC3D.Math3D.transformVectors(xformMat, meshes[i].vertexBuffer, myMesh.vertexBuffer); |
| 496 | // transform and rewrite face normals |
| 497 | JSC3D.Math3D.transformVectors(rotMat, meshes[i].faceNormalBuffer, myMesh.faceNormalBuffer); |
| 498 | myMesh.setMaterial(material); |
| 499 | myMesh.init(); |
| 500 | theScene.addChild(myMesh); |
| 501 | }}} |