diff options
author | Pushkar Joshi | 2012-05-31 17:16:21 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-31 17:16:21 -0700 |
commit | 8915a7109d918a2e69b0999ebaa2deb84811fef8 (patch) | |
tree | 19a8af74c58c9ea261f0842f36efdab959be3256 /js/lib/geom/shape-primitive.js | |
parent | eea0a556e44c2b60d3aaf6e46d2432d3e6303812 (diff) | |
parent | 06b609df1ff7833592faddbd8d7abb5b9f15a74d (diff) | |
download | ninja-8915a7109d918a2e69b0999ebaa2deb84811fef8.tar.gz |
Merge branch 'pentool' into brushtool
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 |