aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js82
1 files changed, 59 insertions, 23 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index b85433a0..42d51e74 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -17,6 +17,9 @@ exports.Rectangle = Object.create(GeomObj, {
17 // CONSTANTS 17 // CONSTANTS
18 N_TRIANGLES: { value : 15, writable: false }, // TODO - This is not being used anywhere. Remove? 18 N_TRIANGLES: { value : 15, writable: false }, // TODO - This is not being used anywhere. Remove?
19 19
20 //if (!MaterialsModel)
21 // MaterialsModel = require("js/models/materials-model").MaterialsModel;
22
20 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
21 // Instance variables 24 // Instance variables
22 /////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////
@@ -942,13 +945,13 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad,
942 } 945 }
943 946
944 //refine the mesh for vertex deformations 947 //refine the mesh for vertex deformations
945// if (material) { 948 if (material) {
946// if (material.hasVertexDeformation()) { 949 if (material.hasVertexDeformation()) {
947// var paramRange = material.getVertexDeformationRange(); 950 var paramRange = material.getVertexDeformationRange();
948// var tolerance = material.getVertexDeformationTolerance(); 951 var tolerance = material.getVertexDeformationTolerance();
949// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 952 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
950// } 953 }
951// } 954 }
952 955
953 // create the RDGE primitive 956 // create the RDGE primitive
954 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 957 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1174,13 +1177,15 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad,
1174 } 1177 }
1175 1178
1176 //refine the mesh for vertex deformations 1179 //refine the mesh for vertex deformations
1177// if (material) { 1180 if (material)
1178// if (material.hasVertexDeformation()) { 1181 {
1179// var paramRange = material.getVertexDeformationRange(); 1182 if (material.hasVertexDeformation())
1180// var tolerance = material.getVertexDeformationTolerance(); 1183 {
1181// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1184 var paramRange = material.getVertexDeformationRange();
1182// } 1185 var tolerance = material.getVertexDeformationTolerance();
1183// } 1186 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1187 }
1188 }
1184 1189
1185 // create the RDGE primitive 1190 // create the RDGE primitive
1186 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1191 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1258,15 +1263,15 @@ RectangleGeometry.create = function( ctr, width, height, material ) {
1258 RectangleGeometry.pushIndices( 0, 3, 2 ); 1263 RectangleGeometry.pushIndices( 0, 3, 2 );
1259 1264
1260 //refine the mesh for vertex deformations 1265 //refine the mesh for vertex deformations
1261// if (material) 1266 if (material)
1262// { 1267 {
1263// if (material.hasVertexDeformation()) 1268 if (material.hasVertexDeformation())
1264// { 1269 {
1265// var paramRange = material.getVertexDeformationRange(); 1270 var paramRange = material.getVertexDeformationRange();
1266// var tolerance = material.getVertexDeformationTolerance(); 1271 var tolerance = material.getVertexDeformationTolerance();
1267// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1272 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1268// } 1273 }
1269// } 1274 }
1270 1275
1271 // create the RDGE primitive 1276 // create the RDGE primitive
1272 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1277 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1279,5 +1284,36 @@ RectangleGeometry.pushIndices = RectangleFill.pushIndices;
1279RectangleGeometry.getVertex = RectangleFill.getVertex; 1284RectangleGeometry.getVertex = RectangleFill.getVertex;
1280RectangleGeometry.getUV = RectangleFill.getUV; 1285RectangleGeometry.getUV = RectangleFill.getUV;
1281 1286
1287RectangleGeometry.init = function()
1288{
1289 this.vertices = [];
1290 this.normals = [];
1291 this.uvs = [];
1292 this.indices = [];
1293}
1294
1295RectangleGeometry.addQuad = function( verts, normals, uvs )
1296{
1297 var offset = this.vertices.length/3;
1298 for (var i=0; i<4; i++)
1299 {
1300 RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]);
1301 RectangleGeometry.pushNormal( normals[i] );
1302 RectangleGeometry.pushUV( uvs[i] );
1303 }
1304
1305 RectangleGeometry.pushIndices( 0+offset, 1+offset, 2+offset );
1306 RectangleGeometry.pushIndices( 2+offset, 3+offset, 0+offset );
1307}
1308
1309RectangleGeometry.buildPrimitive = function()
1310{
1311 var nVertices = this.vertices.length/3;
1312 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
1313}
1314
1315
1316
1317 exports.RectangleGeometry = RectangleGeometry;
1282 1318
1283 1319