aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/drawing/world.js22
-rwxr-xr-xjs/lib/geom/circle.js128
-rwxr-xr-xjs/lib/geom/geom-obj.js25
-rwxr-xr-xjs/lib/geom/line.js57
-rwxr-xr-xjs/lib/geom/rectangle.js131
-rw-r--r--js/lib/geom/shape-primitive.js181
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js14
-rw-r--r--js/lib/rdge/materials/deform-material.js10
-rw-r--r--js/lib/rdge/materials/flag-material.js12
-rw-r--r--js/lib/rdge/materials/fly-material.js10
-rw-r--r--js/lib/rdge/materials/julia-material.js9
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js10
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js72
-rw-r--r--js/lib/rdge/materials/mandel-material.js9
-rwxr-xr-xjs/lib/rdge/materials/material.js29
-rw-r--r--js/lib/rdge/materials/plasma-material.js12
-rw-r--r--js/lib/rdge/materials/pulse-material.js12
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js10
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js92
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js10
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js10
-rw-r--r--js/lib/rdge/materials/star-material.js10
-rw-r--r--js/lib/rdge/materials/taper-material.js29
-rw-r--r--js/lib/rdge/materials/tunnel-material.js10
-rw-r--r--js/lib/rdge/materials/twist-material.js10
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js14
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js17
-rw-r--r--js/lib/rdge/materials/water-material.js13
-rw-r--r--js/lib/rdge/materials/z-invert-material.js10
29 files changed, 876 insertions, 102 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 08f9d319..71d0d098 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -466,6 +466,7 @@ World.prototype.updateObject = function (obj) {
466 if (prims.length != materialNodes.length) 466 if (prims.length != materialNodes.length)
467 throw new Error("inconsistent material and primitive counts"); 467 throw new Error("inconsistent material and primitive counts");
468 var nPrims = prims.length; 468 var nPrims = prims.length;
469 var iPrim = 0;
469 var ctrTrNode; 470 var ctrTrNode;
470 if (nPrims > 0) 471 if (nPrims > 0)
471 { 472 {
@@ -483,9 +484,13 @@ World.prototype.updateObject = function (obj) {
483 ); 484 );
484 ctrTrNode.meshes = []; 485 ctrTrNode.meshes = [];
485 486
486 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
487 ctrTrNode.attachMaterial(materialNodes[0]); 487 ctrTrNode.attachMaterial(materialNodes[0]);
488 while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0]))
489 {
490 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]);
491 iPrim++;
488 } 492 }
493 }
489 494
490 // delete all of the child nodes 495 // delete all of the child nodes
491 var i; 496 var i;
@@ -505,17 +510,19 @@ World.prototype.updateObject = function (obj) {
505 } 510 }
506 ctrTrNode.children = []; 511 ctrTrNode.children = [];
507 512
508 for (var i = 1; i < nPrims; i++) 513 while (iPrim < nPrims)
509 { 514 {
510 // get the next primitive
511 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); 515 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
512 ctrTrNode.insertAsChild(childTrNode); 516 ctrTrNode.insertAsChild(childTrNode);
517 var matNode = materialNodes[iPrim];
518 childTrNode.attachMaterial(matNode);
513 519
514 // attach the instanced box goe 520 while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode))
515 var prim = prims[i]; 521 {
516 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); 522 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]);
517 childTrNode.attachMaterial(materialNodes[i]); 523 iPrim++;
518 } 524 }
525 }
519 526
520 // send a notification that the tree has changed 527 // send a notification that the tree has changed
521 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); 528 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE );
@@ -647,6 +654,7 @@ World.prototype.clearTree = function()
647 654
648 if (this._useWebGL) 655 if (this._useWebGL)
649 { 656 {
657 this.stop();
650 var root = this._rootNode; 658 var root = this._rootNode;
651 root.children = new Array(); 659 root.children = new Array();
652 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid ); 660 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid );
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index e691f458..53847631 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -85,14 +85,28 @@ exports.Circle = Object.create(GeomObj, {
85 } else { 85 } else {
86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
87 } 87 }
88 if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); 88
89 if(strokeColor) {
90 if(this._strokeMaterial.hasProperty("color")) {
91 this._strokeMaterial.setProperty( "color", this._strokeColor );
92 } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) {
93 this._strokeMaterial.setGradientData(this._strokeColor.color);
94 }
95 }
89 96
90 if(fillMaterial) { 97 if(fillMaterial) {
91 this._fillMaterial = fillMaterial.dup(); 98 this._fillMaterial = fillMaterial.dup();
92 } else { 99 } else {
93 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 100 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
94 } 101 }
95 if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); 102
103 if(fillColor) {
104 if(this._fillMaterial.hasProperty("color")) {
105 this._fillMaterial.setProperty( "color", this._fillColor );
106 } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) {
107 this._fillMaterial.setGradientData(this._fillColor.color);
108 }
109 }
96 } 110 }
97 }, 111 },
98 112
@@ -308,7 +322,8 @@ exports.Circle = Object.create(GeomObj, {
308 innerStrokeScaleMat[0] = xInnRad - xStroke; 322 innerStrokeScaleMat[0] = xInnRad - xStroke;
309 innerStrokeScaleMat[5] = yInnRad - yStroke; 323 innerStrokeScaleMat[5] = yInnRad - yStroke;
310 324
311 var fillPrim, strokePrim0, strokePrim1; 325 var i;
326 var fillPrimArray, strokePrim0Array, strokePrim1Array;
312 var fillMaterial, strokeMaterial0, strokeMaterial2; 327 var fillMaterial, strokeMaterial0, strokeMaterial2;
313 328
314 this._primArray = []; 329 this._primArray = [];
@@ -322,42 +337,48 @@ exports.Circle = Object.create(GeomObj, {
322 var numStrokes = 1; 337 var numStrokes = 1;
323 if(this._innerRadius !== 0) { 338 if(this._innerRadius !== 0) {
324 strokeMaterial0 = this.makeStrokeMaterial(); 339 strokeMaterial0 = this.makeStrokeMaterial();
325 strokePrim0 = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles, strokeMaterial0); 340 strokePrim0Array = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles, strokeMaterial0);
326 } 341 }
327 342
328 strokeMaterial2 = this.makeStrokeMaterial(); 343 strokeMaterial2 = this.makeStrokeMaterial();
329 strokePrim1 = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles, strokeMaterial2); 344 strokePrim1Array = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles, strokeMaterial2);
330 } 345 }
331 346
332 if (strokePrim0) { 347 if (strokePrim0Array) {
333 strokeMaterial0.fitToPrimitive( strokePrim0 ); 348 strokeMaterial0.fitToPrimitiveArray( strokePrim0Array );
334 349 for (i=0; i<strokePrim0Array.length; i++)
335 this._primArray.push( strokePrim0 ); 350 {
351 this._primArray.push( strokePrim0Array[i] );
336 this._materialNodeArray.push( strokeMaterial0.getMaterialNode() ); 352 this._materialNodeArray.push( strokeMaterial0.getMaterialNode() );
337 } 353 }
354 }
338 355
339 if (strokePrim1) { 356 if (strokePrim1Array) {
340 strokeMaterial2.fitToPrimitive( strokePrim1 ); 357 strokeMaterial2.fitToPrimitiveArray( strokePrim1Array );
341 358 for (i=0; i<strokePrim1Array.length; i++)
342 this._primArray.push( strokePrim1 ); 359 {
360 this._primArray.push( strokePrim1Array[i] );
343 this._materialNodeArray.push( strokeMaterial2.getMaterialNode() ); 361 this._materialNodeArray.push( strokeMaterial2.getMaterialNode() );
344 } 362 }
363 }
345 364
346 ///////////////////////////////////////////////////////////// 365 /////////////////////////////////////////////////////////////
347 // Fill 366 // Fill
348 fillMaterial = this.makeFillMaterial(); 367 fillMaterial = this.makeFillMaterial();
349 if(this._innerRadius === 0) { 368 if(this._innerRadius === 0) {
350 fillPrim = this.generateOval(x, y, mat, fillScaleMat, nTriangles, fillMaterial); 369 fillPrimArray = this.generateOval(x, y, mat, fillScaleMat, nTriangles, fillMaterial);
351 } else { 370 } else {
352 fillPrim = this.generateOvalRing(x, y, reverseRotMat, innerRadiusScaleMat, fillScaleMat, nTriangles, fillMaterial); 371 fillPrimArray = this.generateOvalRing(x, y, reverseRotMat, innerRadiusScaleMat, fillScaleMat, nTriangles, fillMaterial);
353 } 372 }
354 373
355 if (fillPrim) { 374 if (fillPrimArray) {
356 fillMaterial.fitToPrimitive( fillPrim ); 375 fillMaterial.fitToPrimitiveArray( fillPrimArray );
357 376 for (i=0; i<fillPrimArray.length; i++)
358 this._primArray.push( fillPrim );