()
| 34438 | |
| 34439 | if(!this._renderer.geometryInHash(gId)){ |
| 34440 | var _box = function(){ |
| 34441 | var cubeIndices = [ |
| 34442 | [0, 4, 2, 6],// -1, 0, 0],// -x |
| 34443 | [1, 3, 5, 7],// +1, 0, 0],// +x |
| 34444 | [0, 1, 4, 5],// 0, -1, 0],// -y |
| 34445 | [2, 6, 3, 7],// 0, +1, 0],// +y |
| 34446 | [0, 2, 1, 3],// 0, 0, -1],// -z |
| 34447 | [4, 5, 6, 7]// 0, 0, +1] // +z |
| 34448 | ]; |
| 34449 | var id=0; |
| 34450 | for (var i = 0; i < cubeIndices.length; i++) { |
| 34451 | var cubeIndex = cubeIndices[i]; |
| 34452 | var v = i * 4; |
| 34453 | for (var j = 0; j < 4; j++) { |
| 34454 | var d = cubeIndex[j]; |
| 34455 | //inspired by lightgl: |
| 34456 | //https://github.com/evanw/lightgl.js |
| 34457 | //octants:https://en.wikipedia.org/wiki/Octant_(solid_geometry) |
| 34458 | var octant = new p5.Vector( |
| 34459 | ((d & 1) * 2 - 1)*width/2, |
| 34460 | ((d & 2) - 1) *height/2, |
| 34461 | ((d & 4) / 2 - 1) * depth/2); |
| 34462 | this.vertices.push( octant ); |
| 34463 | this.uvs.push([j & 1, (j & 2) / 2]); |
| 34464 | id++; |
| 34465 | } |
| 34466 | this.faces.push([v, v + 1, v + 2]); |
| 34467 | this.faces.push([v + 2, v + 1, v + 3]); |
| 34468 | } |
| 34469 | }; |
| 34470 | var boxGeom = new p5.Geometry(detailX,detailY, _box); |
| 34471 | boxGeom.computeNormals(); |
| 34472 | //initialize our geometry buffer with |
nothing calls this directly
no outgoing calls
no test coverage detected