diff options
author | Ananya Sen | 2012-05-31 10:13:40 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-31 10:13:40 -0700 |
commit | 286457b4f23974277274ba388afd283e8aa085cb (patch) | |
tree | c21bf791e7c4f572d12f97987ea6b89e74da67fe /js/lib/geom/shape-primitive.js | |
parent | 4d9b481c58090e8f1fc7b0e9d73a81b0f49cccc8 (diff) | |
parent | d49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff) | |
download | ninja-286457b4f23974277274ba388afd283e8aa085cb.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Conflicts:
js/controllers/styles-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
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 |