aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorhwc4872012-05-25 09:25:37 -0700
committerhwc4872012-05-25 09:25:37 -0700
commitbc1b0276a3947e10f914e83f9750add4fa8b6c00 (patch)
tree6140d80589ff7707a5ae4b23a099f374be48ccd8 /js/lib/geom
parent44a8ec171bedac6921d796501e654f856d716855 (diff)
downloadninja-bc1b0276a3947e10f914e83f9750add4fa8b6c00.tar.gz
New functions on shape primitives.
Diffstat (limited to 'js/lib/geom')
-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 380cf334..5a44deb3 100644
--- a/js/lib/geom/shape-primitive.js
+++ b/js/lib/geom/shape-primitive.js
@@ -71,6 +71,33 @@ ShapePrimitive.getMeshBounds = function( verts, nVerts )
71 return bounds; 71 return bounds;
72}; 72};
73 73
74ShapePrimitive.getBounds = function( prim )
75{
76 var verts = prim.bufferStreams[0];
77 var nVerts = verts.length;
78 var xMin = verts[0], xMax = verts[0],
79 yMin = verts[1], yMax = verts[1],
80 zMin = verts[2], zMax = verts[2];
81
82 for (var index=3; index<verts.length; )
83 {
84 if (verts[index] < xMin) xMin = verts[index];
85 else if (verts[index] > xMax) xMax = verts[index];
86
87 index++;
88 if (verts[index] < yMin) yMin = verts[index];
89 else if (verts[index] > yMax) yMax = verts[index];
90
91 index++;
92 if (verts[index] < zMin) zMin = verts[index];
93 else if (verts[index] > zMax) zMax = verts[index];
94
95 index++;
96 }
97
98 return [xMin, yMin, zMin, xMax, yMax, zMax];
99};
100
74ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance ) 101ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance )
75{ 102{
76 var oldVrtCount = nVertices; 103 var oldVrtCount = nVertices;