aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/shape-primitive.js
diff options
context:
space:
mode:
authorJonathan Duran2012-05-24 09:35:02 -0700
committerJonathan Duran2012-05-24 09:35:02 -0700
commit458714f5bf2ab095f6e96dfec3f9ff7042527c04 (patch)
tree779ba55d14f059572cb81d27024ca8b8a92956e0 /js/lib/geom/shape-primitive.js
parent2e4831cf0fe04f37a179f84b098ae0899d4e40b8 (diff)
parent862ee363584dfba4bdd9abacbc3a3244c7ec66b5 (diff)
downloadninja-458714f5bf2ab095f6e96dfec3f9ff7042527c04.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/lib/geom/shape-primitive.js')
-rw-r--r--js/lib/geom/shape-primitive.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/lib/geom/shape-primitive.js b/js/lib/geom/shape-primitive.js
index 97873d32..9864a8e9 100644
--- a/js/lib/geom/shape-primitive.js
+++ b/js/lib/geom/shape-primitive.js
@@ -49,6 +49,33 @@ ShapePrimitive.create = function(coords, normals, uvs, indices, primType, ver
49 return prim; 49 return prim;
50}; 50};
51 51
52ShapePrimitive.getBounds = function( prim )
53{
54 var verts = prim.bufferStreams[0];
55 var nVerts = verts.length;
56 var xMin = verts[0], xMax = verts[0],
57 yMin = verts[1], yMax = verts[1],
58 zMin = verts[2], zMax = verts[2];
59
60 for (var index=3; index<verts.length; )
61 {
62 if (verts[index] < xMin) xMin = verts[index];
63 else if (verts[index] > xMax) xMax = verts[index];
64
65 index++;
66 if (verts[index] < yMin) yMin = verts[index];
67 else if (verts[index] > yMax) yMax = verts[index];
68
69 index++;
70 if (verts[index] < zMin) zMin = verts[index];
71 else if (verts[index] > zMax) zMax = verts[index];
72
73 index++;
74 }
75
76 return [xMin, yMin, zMin, xMax, yMax, zMax];
77};
78
52if (typeof exports === "object") { 79if (typeof exports === "object") {
53 exports.ShapePrimitive = ShapePrimitive; 80 exports.ShapePrimitive = ShapePrimitive;
54} \ No newline at end of file 81} \ No newline at end of file