diff options
Diffstat (limited to 'js/lib')
-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 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 | ||
74 | ShapePrimitive.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 | |||
74 | ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance ) | 101 | ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance ) |
75 | { | 102 | { |
76 | var oldVrtCount = nVertices; | 103 | var oldVrtCount = nVertices; |