From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/lib/geom/circle.js | 216 +++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'js/lib/geom/circle.js') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index 39cde514..a06355eb 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. var GeomObj = require("js/lib/geom/geom-obj").GeomObj; var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; var MaterialsModel = require("js/models/materials-model").MaterialsModel; -var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; -var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; +var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; +var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; /////////////////////////////////////////////////////////////////////// // Class GLCircle // GL representation of a circle. // Derived from class GLGeomObj -// The position and dimensions of the stroke, fill, and inner Radius should be in pixels +// The position and dimensions of the stroke, fill, and inner Radius should be in pixels /////////////////////////////////////////////////////////////////////// exports.Circle = Object.create(GeomObj, { @@ -57,7 +57,7 @@ exports.Circle = Object.create(GeomObj, { _strokeStyle: { value : "Solid", writable: true }, _aspectRatio: { value : 1.0, writable: true }, - init: { + init: { value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { if(arguments.length > 0) { this._width = width; @@ -85,14 +85,14 @@ exports.Circle = Object.create(GeomObj, { } else { this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); + if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); } else { this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); + if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); } }, @@ -203,7 +203,7 @@ exports.Circle = Object.create(GeomObj, { }, /////////////////////////////////////////////////////////////////////// - // update the "color of the material + // update the "color of the material getFillColor: { value: function() { return this._fillColor; @@ -251,15 +251,15 @@ exports.Circle = Object.create(GeomObj, { // get the normalized device coordinates (NDC) for // all position and dimensions. - var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); - var xNDC = 2*this._xOffset/vpw, yNDC = -2*this._yOffset/vph, + var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); + var xNDC = 2*this._xOffset/vpw, yNDC = -2*this._yOffset/vph, xRadNDC = this._width/vpw, yRadNDC = this._height/vph, xStrokeNDC = 2*this._strokeWidth/vpw, yStrokeNDC = 2*this._strokeWidth/vph, xInnRadNDC = this._innerRadius*xRadNDC, yInnRadNDC = this._innerRadius*yRadNDC; var aspect = world.getAspect(); var zn = world.getZNear(), zf = world.getZFar(); - var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), + var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), b = -t, r = aspect*t, l = -r; @@ -321,7 +321,7 @@ exports.Circle = Object.create(GeomObj, { if(this._strokeWidth > 0) { var numStrokes = 1; if(this._innerRadius !== 0) { - strokeMaterial0 = this.makeStrokeMaterial(); + strokeMaterial0 = this.makeStrokeMaterial(); strokePrim0 = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles, strokeMaterial0); } @@ -330,14 +330,14 @@ exports.Circle = Object.create(GeomObj, { } if (strokePrim0) { - strokeMaterial0.fitToPrimitive( strokePrim0 ); + strokeMaterial0.fitToPrimitive( strokePrim0 ); this._primArray.push( strokePrim0 ); this._materialNodeArray.push( strokeMaterial0.getMaterialNode() ); } if (strokePrim1) { - strokeMaterial2.fitToPrimitive( strokePrim1 ); + strokeMaterial2.fitToPrimitive( strokePrim1 ); this._primArray.push( strokePrim1 ); this._materialNodeArray.push( strokeMaterial2.getMaterialNode() ); @@ -353,7 +353,7 @@ exports.Circle = Object.create(GeomObj, { } if (fillPrim) { - fillMaterial.fitToPrimitive( fillPrim ); + fillMaterial.fitToPrimitive( fillPrim ); this._primArray.push( fillPrim ); this._materialNodeArray.push( fillMaterial.getMaterialNode() ); @@ -371,7 +371,7 @@ exports.Circle = Object.create(GeomObj, { var x = pts[0], y = pts[1], z = 0; var xs = scaleMat[0], ys = scaleMat[4]; - var vrts = [], nrms = [], uvs = [], indices = []; + var vrts = [], nrms = [], uvs = [], indices = []; var index = 0; for (var i=0; i xMax) xMax = vrts[index]; - - if (vrts[index+1] < yMin) yMin = vrts[index+1]; - else if (vrts[index+1] > yMax) yMax = vrts[index+1]; - - index += 3; - } - var ovalWidth = xMax - xMin, - ovalHeight = yMax - yMin; - for (i=0; i uMax) uMax = uvs[iuv]; - - iuv++; ivrt++; - uvs[iuv] = (vrts[ivrt]-yMin)/ovalHeight; - if (uvs[iuv] < vMin) vMin = uvs[iuv]; - if (uvs[iuv] > vMax) vMax = uvs[iuv]; - iuv++; ivrt += 2; - } - - //console.log( "remap" ); - //console.log( "uRange: " + uMin + " => " + uMax ); - //console.log( "vRange: " + vMin + " => " + vMax ); - } - } + recalcTexMapCoords: { + value: function(vrts, uvs) { + var n = vrts.length/3; + if (n === 0) return; + var ivrt = 0, iuv = 0; + var uMin = 1.e8, uMax = -1.e8, + vMin = 1.e8, vMax = -1.e8; + + var i, index = 3; + var xMin = vrts[0], xMax = vrts[0], + yMin = vrts[1], yMax = vrts[1]; + for (i=1; i xMax) xMax = vrts[index]; + + if (vrts[index+1] < yMin) yMin = vrts[index+1]; + else if (vrts[index+1] > yMax) yMax = vrts[index+1]; + + index += 3; + } + var ovalWidth = xMax - xMin, + ovalHeight = yMax - yMin; + for (i=0; i uMax) uMax = uvs[iuv]; + + iuv++; ivrt++; + uvs[iuv] = (vrts[ivrt]-yMin)/ovalHeight; + if (uvs[iuv] < vMin) vMin = uvs[iuv]; + if (uvs[iuv] > vMax) vMax = uvs[iuv]; + iuv++; ivrt += 2; + } + + //console.log( "remap" ); + //console.log( "uRange: " + uMin + " => " + uMax ); + //console.log( "vRange: " + vMin + " => " + vMax ); + } + } }); -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/lib/geom/circle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/geom/circle.js') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index a06355eb..e691f458 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -861,7 +861,7 @@ exports.Circle = Object.create(GeomObj, { var ivrt = 0, iuv = 0; var uMin = 1.e8, uMax = -1.e8, vMin = 1.e8, vMax = -1.e8; - + var i, index = 3; var xMin = vrts[0], xMax = vrts[0], yMin = vrts[1], yMax = vrts[1]; -- cgit v1.2.3