diff options
Diffstat (limited to 'js/lib')
28 files changed, 1556 insertions, 900 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 8068284e..39f97134 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -442,6 +442,7 @@ World.prototype.updateObject = function (obj) { | |||
442 | if (prims.length != materialNodes.length) | 442 | if (prims.length != materialNodes.length) |
443 | throw new Error("inconsistent material and primitive counts"); | 443 | throw new Error("inconsistent material and primitive counts"); |
444 | var nPrims = prims.length; | 444 | var nPrims = prims.length; |
445 | var iPrim = 0; | ||
445 | var ctrTrNode; | 446 | var ctrTrNode; |
446 | if (nPrims > 0) | 447 | if (nPrims > 0) |
447 | { | 448 | { |
@@ -459,8 +460,12 @@ World.prototype.updateObject = function (obj) { | |||
459 | ); | 460 | ); |
460 | ctrTrNode.meshes = []; | 461 | ctrTrNode.meshes = []; |
461 | 462 | ||
462 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); | ||
463 | ctrTrNode.attachMaterial(materialNodes[0]); | 463 | ctrTrNode.attachMaterial(materialNodes[0]); |
464 | while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0])) | ||
465 | { | ||
466 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); | ||
467 | iPrim++; | ||
468 | } | ||
464 | } | 469 | } |
465 | 470 | ||
466 | // delete all of the child nodes | 471 | // delete all of the child nodes |
@@ -481,16 +486,18 @@ World.prototype.updateObject = function (obj) { | |||
481 | } | 486 | } |
482 | ctrTrNode.children = []; | 487 | ctrTrNode.children = []; |
483 | 488 | ||
484 | for (var i = 1; i < nPrims; i++) | 489 | while (iPrim < nPrims) |
485 | { | 490 | { |
486 | // get the next primitive | ||
487 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); | 491 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); |
488 | ctrTrNode.insertAsChild(childTrNode); | 492 | ctrTrNode.insertAsChild(childTrNode); |
493 | var matNode = materialNodes[iPrim]; | ||
494 | childTrNode.attachMaterial(matNode); | ||
489 | 495 | ||
490 | // attach the instanced box goe | 496 | while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode)) |
491 | var prim = prims[i]; | 497 | { |
492 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); | 498 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); |
493 | childTrNode.attachMaterial(materialNodes[i]); | 499 | iPrim++; |
500 | } | ||
494 | } | 501 | } |
495 | 502 | ||
496 | // send a notification that the tree has changed | 503 | // send a notification that the tree has changed |
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index 086c1058..374dda58 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -18,173 +18,173 @@ var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | |||
18 | /////////////////////////////////////////////////////////////////////// | 18 | /////////////////////////////////////////////////////////////////////// |
19 | exports.Circle = Object.create(GeomObj, { | 19 | exports.Circle = Object.create(GeomObj, { |
20 | 20 | ||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | // Instance variables | 22 | // Instance variables |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | _width: { value : 2.0, writable: true }, | 24 | _width: { value : 2.0, writable: true }, |
25 | _height: { value : 2.0, writable: true }, | 25 | _height: { value : 2.0, writable: true }, |
26 | _xOffset: { value : 0, writable: true }, | 26 | _xOffset: { value : 0, writable: true }, |
27 | _yOffset: { value : 0, writable: true }, | 27 | _yOffset: { value : 0, writable: true }, |
28 | 28 | ||
29 | _radius: { value : 2.0, writable: true }, | 29 | _radius: { value : 2.0, writable: true }, |
30 | _strokeWidth: { value : 0.25, writable: true }, | 30 | _strokeWidth: { value : 0.25, writable: true }, |
31 | _innerRadius: { value : 0, writable: true }, | 31 | _innerRadius: { value : 0, writable: true }, |
32 | _ovalHeight: { value : 4.0, writable: true }, | 32 | _ovalHeight: { value : 4.0, writable: true }, |
33 | _strokeStyle: { value : "Solid", writable: true }, | 33 | _strokeStyle: { value : "Solid", writable: true }, |
34 | _aspectRatio: { value : 1.0, writable: true }, | 34 | _aspectRatio: { value : 1.0, writable: true }, |
35 | 35 | ||
36 | init: { | 36 | init: { |
37 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { | 37 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { |
38 | if(arguments.length > 0) { | 38 | if(arguments.length > 0) { |
39 | this._width = width; | 39 | this._width = width; |
40 | this._height = height; | 40 | this._height = height; |
41 | this._xOffset = xOffset; | 41 | this._xOffset = xOffset; |
42 | this._yOffset = yOffset; | 42 | this._yOffset = yOffset; |
43 | this._ovalHeight = 2.0 * this._radius; | 43 | this._ovalHeight = 2.0 * this._radius; |
44 | 44 | ||
45 | this._strokeWidth = strokeSize; | 45 | this._strokeWidth = strokeSize; |
46 | this._innerRadius = innerRadius; | 46 | this._innerRadius = innerRadius; |
47 | this._strokeColor = strokeColor; | 47 | this._strokeColor = strokeColor; |
48 | this._fillColor = fillColor; | 48 | this._fillColor = fillColor; |
49 | 49 | ||
50 | this._strokeStyle = strokeStyle; | 50 | this._strokeStyle = strokeStyle; |
51 | 51 | ||
52 | this._matrix = Matrix.I(4); | 52 | this._matrix = Matrix.I(4); |
53 | //this._matrix[12] = xOffset; | 53 | //this._matrix[12] = xOffset; |
54 | //this._matrix[13] = yOffset; | 54 | //this._matrix[13] = yOffset; |
55 | } | 55 | } |
56 | 56 | ||
57 | this.m_world = world; | 57 | this.m_world = world; |
58 | 58 | ||
59 | if(strokeMaterial) { | 59 | if(strokeMaterial) { |
60 | this._strokeMaterial = strokeMaterial.dup(); | 60 | this._strokeMaterial = strokeMaterial.dup(); |
61 | } else { | 61 | } else { |
62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
63 | } | 63 | } |
64 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); | 64 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); |
65 | 65 | ||
66 | if(fillMaterial) { | 66 | if(fillMaterial) { |
67 | this._fillMaterial = fillMaterial.dup(); | 67 | this._fillMaterial = fillMaterial.dup(); |
68 | } else { | 68 | } else { |
69 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 69 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
70 | } | 70 | } |
71 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); | 71 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); |
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | 74 | ||
75 | /////////////////////////////////////////////////////////////////////// | 75 | /////////////////////////////////////////////////////////////////////// |
76 | // Property Accessors | 76 | // Property Accessors |
77 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
78 | // TODO - Use getters/setters in the future | 78 | // TODO - Use getters/setters in the future |
79 | getStrokeWidth: { | 79 | getStrokeWidth: { |
80 | value: function() { | 80 | value: function() { |
81 | return this._strokeWidth; | 81 | return this._strokeWidth; |
82 | } | 82 | } |
83 | }, | 83 | }, |
84 | 84 | ||
85 | setStrokeWidth: { | 85 | setStrokeWidth: { |
86 | value: function(w) { | 86 | value: function(w) { |
87 | this._strokeWidth = w; | 87 | this._strokeWidth = w; |
88 | } | 88 | } |
89 | }, | 89 | }, |
90 | 90 | ||
91 | getStrokeMaterial: { | 91 | getStrokeMaterial: { |
92 | value: function() { | 92 | value: function() { |
93 | return this._strokeMaterial; | 93 | return this._strokeMaterial; |
94 | } | 94 | } |
95 | }, | 95 | }, |