aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/circle.js3
-rwxr-xr-xjs/lib/geom/rectangle.js6
-rw-r--r--js/lib/geom/shape-primitive.js27
3 files changed, 32 insertions, 4 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 425b869a..b60ad58f 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -311,6 +311,7 @@ exports.Circle = Object.create(GeomObj, {
311 311
312 if (fillPrim) { 312 if (fillPrim) {
313 fillMaterial = this.makeFillMaterial(); 313 fillMaterial = this.makeFillMaterial();
314 fillMaterial.fitToPrimitive( fillPrim );
314 315
315 this._primArray.push( fillPrim ); 316 this._primArray.push( fillPrim );
316 this._materialNodeArray.push( fillMaterial.getMaterialNode() ); 317 this._materialNodeArray.push( fillMaterial.getMaterialNode() );
@@ -318,6 +319,7 @@ exports.Circle = Object.create(GeomObj, {
318 319
319 if (strokePrim0) { 320 if (strokePrim0) {
320 strokeMaterial0 = this.makeStrokeMaterial(); 321 strokeMaterial0 = this.makeStrokeMaterial();
322 strokeMaterial0.fitToPrimitive( strokePrim0 );
321 323
322 this._primArray.push( strokePrim0 ); 324 this._primArray.push( strokePrim0 );
323 this._materialNodeArray.push( strokeMaterial0.getMaterialNode() ); 325 this._materialNodeArray.push( strokeMaterial0.getMaterialNode() );
@@ -325,6 +327,7 @@ exports.Circle = Object.create(GeomObj, {
325 327
326 if (strokePrim1) { 328 if (strokePrim1) {
327 strokeMaterial2 = this.makeStrokeMaterial(); 329 strokeMaterial2 = this.makeStrokeMaterial();
330 strokeMaterial2.fitToPrimitive( strokePrim1 );
328 331
329 this._primArray.push( strokePrim1 ); 332 this._primArray.push( strokePrim1 );
330 this._materialNodeArray.push( strokeMaterial2.getMaterialNode() ); 333 this._materialNodeArray.push( strokeMaterial2.getMaterialNode() );
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index d75abb05..cf0e7fc8 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -56,8 +56,6 @@ exports.Rectangle = Object.create(GeomObj, {
56 this._strokeStyle = strokeStyle; 56 this._strokeStyle = strokeStyle;
57 57
58 this._matrix = Matrix.I(4); 58 this._matrix = Matrix.I(4);
59 //this._matrix[12] = xoffset;
60 //this._matrix[13] = yoffset;
61 } 59 }
62 60
63 // the overall radius includes the fill and the stroke. separate the two based on the stroke width 61 // the overall radius includes the fill and the stroke. separate the two based on the stroke width
@@ -124,7 +122,6 @@ exports.Rectangle = Object.create(GeomObj, {
124 this._fillMaterial = m; 122 this._fillMaterial = m;
125 } 123 }
126 }, 124 },
127
128 /////////////////////////////////////////////////////////////////////// 125 ///////////////////////////////////////////////////////////////////////
129 // update the "color of the material 126 // update the "color of the material
130 getFillColor: { 127 getFillColor: {
@@ -138,7 +135,6 @@ exports.Rectangle = Object.create(GeomObj, {
138// this._fillColor = c; 135// this._fillColor = c;
139// } 136// }
140// }, 137// },
141
142 getStrokeColor: { 138 getStrokeColor: {
143 value: function() { 139 value: function() {
144 return this._strokeColor; 140 return this._strokeColor;
@@ -379,6 +375,7 @@ exports.Rectangle = Object.create(GeomObj, {
379 // stroke 375 // stroke
380 var strokeMaterial = this.makeStrokeMaterial(); 376 var strokeMaterial = this.makeStrokeMaterial();
381 var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial); 377 var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial);
378 strokeMaterial.fitToPrimitive( strokePrim );
382 this._primArray.push( strokePrim ); 379 this._primArray.push( strokePrim );
383 this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); 380 this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
384 381
@@ -392,6 +389,7 @@ exports.Rectangle = Object.create(GeomObj, {
392 var fillMaterial = this.makeFillMaterial(); 389 var fillMaterial = this.makeFillMaterial();
393 //console.log( "fillMaterial: " + fillMaterial.getName() ); 390 //console.log( "fillMaterial: " + fillMaterial.getName() );
394 var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); 391 var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial);
392 fillMaterial.fitToPrimitive( fillPrim );
395 this._primArray.push( fillPrim ); 393 this._primArray.push( fillPrim );
396 this._materialNodeArray.push( fillMaterial.getMaterialNode() ); 394 this._materialNodeArray.push( fillMaterial.getMaterialNode() );
397 395
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
52ShapePrimitive.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
52if (typeof exports === "object") { 79if (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