diff options
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-x | js/lib/geom/rectangle.js | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index d75abb05..ab0d7022 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 | /////////////////////////////////////////////////////////////////////// |
@@ -944,13 +947,13 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, | |||
944 | } | 947 | } |
945 | 948 | ||
946 | //refine the mesh for vertex deformations | 949 | //refine the mesh for vertex deformations |
947 | // if (material) { | 950 | if (material) { |
948 | // if (material.hasVertexDeformation()) { | 951 | if (material.hasVertexDeformation()) { |
949 | // var paramRange = material.getVertexDeformationRange(); | 952 | var paramRange = material.getVertexDeformationRange(); |
950 | // var tolerance = material.getVertexDeformationTolerance(); | 953 | var tolerance = material.getVertexDeformationTolerance(); |
951 | // nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); | 954 | nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); |
952 | // } | 955 | } |
953 | // } | 956 | } |
954 | 957 | ||
955 | // create the RDGE primitive | 958 | // create the RDGE primitive |
956 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); | 959 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
@@ -1176,13 +1179,15 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, | |||
1176 | } | 1179 | } |
1177 | 1180 | ||
1178 | //refine the mesh for vertex deformations | 1181 | //refine the mesh for vertex deformations |
1179 | // if (material) { | 1182 | if (material) |
1180 | // if (material.hasVertexDeformation()) { | 1183 | { |
1181 | // var paramRange = material.getVertexDeformationRange(); | 1184 | if (material.hasVertexDeformation()) |
1182 | // var tolerance = material.getVertexDeformationTolerance(); | 1185 | { |
1183 | // nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); | 1186 | var paramRange = material.getVertexDeformationRange(); |
1184 | // } | 1187 | var tolerance = material.getVertexDeformationTolerance(); |
1185 | // } | 1188 | nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); |
1189 | } | ||
1190 | } | ||
1186 | 1191 | ||
1187 | // create the RDGE primitive | 1192 | // create the RDGE primitive |
1188 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); | 1193 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
@@ -1260,15 +1265,15 @@ RectangleGeometry.create = function( ctr, width, height, material ) { | |||
1260 | RectangleGeometry.pushIndices( 0, 3, 2 ); | 1265 | RectangleGeometry.pushIndices( 0, 3, 2 ); |
1261 | 1266 | ||
1262 | //refine the mesh for vertex deformations | 1267 | //refine the mesh for vertex deformations |
1263 | // if (material) | 1268 | if (material) |
1264 | // { | 1269 | { |
1265 | // if (material.hasVertexDeformation()) | 1270 | if (material.hasVertexDeformation()) |
1266 | // { | 1271 | { |
1267 | // var paramRange = material.getVertexDeformationRange(); | 1272 | var paramRange = material.getVertexDeformationRange(); |
1268 | // var tolerance = material.getVertexDeformationTolerance(); | 1273 | var tolerance = material.getVertexDeformationTolerance(); |
1269 | // nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); | 1274 | nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); |
1270 | // } | 1275 | } |
1271 | // } | 1276 | } |
1272 | 1277 | ||
1273 | // create the RDGE primitive | 1278 | // create the RDGE primitive |
1274 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); | 1279 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
@@ -1281,5 +1286,36 @@ RectangleGeometry.pushIndices = RectangleFill.pushIndices; | |||
1281 | RectangleGeometry.getVertex = RectangleFill.getVertex; | 1286 | RectangleGeometry.getVertex = RectangleFill.getVertex; |
1282 | RectangleGeometry.getUV = RectangleFill.getUV; | 1287 | RectangleGeometry.getUV = RectangleFill.getUV; |
1283 | 1288 | ||
1289 | RectangleGeometry.init = function() | ||
1290 | { | ||
1291 | this.vertices = []; | ||
1292 | this.normals = []; | ||
1293 | this.uvs = []; | ||
1294 | this.indices = []; | ||
1295 | } | ||
1296 | |||
1297 | RectangleGeometry.addQuad = function( verts, normals, uvs ) | ||
1298 | { | ||
1299 | var offset = this.vertices.length/3; | ||
1300 | for (var i=0; i<4; i++) | ||
1301 | { | ||
1302 | RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]); | ||
1303 | RectangleGeometry.pushNormal( normals[i] ); | ||
1304 | RectangleGeometry.pushUV( uvs[i] ); | ||
1305 | } | ||
1306 | |||
1307 | RectangleGeometry.pushIndices( 0+offset, 1+offset, 2+offset ); | ||
1308 | RectangleGeometry.pushIndices( 2+offset, 3+offset, 0+offset ); | ||
1309 | } | ||
1310 | |||
1311 | RectangleGeometry.buildPrimitive = function() | ||
1312 | { | ||
1313 | var nVertices = this.vertices.length/3; | ||
1314 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); | ||
1315 | } | ||
1316 | |||
1317 | |||
1318 | |||
1319 | exports.RectangleGeometry = RectangleGeometry; | ||
1284 | 1320 | ||
1285 | 1321 | ||