diff options
author | Pushkar Joshi | 2012-05-31 12:20:03 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-31 12:20:03 -0700 |
commit | 4bc52365b1f81a386c3c59fd7c6ad874bb387cb5 (patch) | |
tree | c5b17297aba04bd54a59cf6214d29486e089031b /js/lib/geom/shape-primitive.js | |
parent | 75a862d305bc4502e22bc5aa65fa271143b8cf6c (diff) | |
parent | 6042bdc5f2aada4412912fd01602d32c9088dc26 (diff) | |
download | ninja-4bc52365b1f81a386c3c59fd7c6ad874bb387cb5.tar.gz |
Merge branch 'master' into pentool
Diffstat (limited to 'js/lib/geom/shape-primitive.js')
-rw-r--r-- | js/lib/geom/shape-primitive.js | 27 |
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 | ||
52 | ShapePrimitive.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 | |||
52 | if (typeof exports === "object") { | 79 | if (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 |