aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorEric Guzman2012-04-09 15:44:09 -0700
committerEric Guzman2012-04-09 15:44:09 -0700
commita27915e900eb768dd9db1f0dd441961ea80bfaa6 (patch)
tree593f429f0b3294103a059ae9f6ed03858288deb7 /js/lib
parentafcaa157f7bc067cf00de91b43b2a71e9b64b7b3 (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-a27915e900eb768dd9db1f0dd441961ea80bfaa6.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/NJUtils.js12
-rwxr-xr-xjs/lib/drawing/world.js2
-rwxr-xr-xjs/lib/geom/circle.js19
-rwxr-xr-xjs/lib/geom/geom-obj.js128
-rwxr-xr-xjs/lib/geom/line.js10
-rwxr-xr-xjs/lib/geom/rectangle.js15
6 files changed, 126 insertions, 60 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 96e1d6da..f6284b6c 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -96,7 +96,10 @@ exports.NJUtils = Object.create(Object.prototype, {
96 ///// TODO: find a different place for this function 96 ///// TODO: find a different place for this function
97 makeElementModel: { 97 makeElementModel: {
98 value: function(el, selection, controller, isShape) { 98 value: function(el, selection, controller, isShape) {
99 var p3d = Montage.create(Properties3D).init(el); 99 var p3d = Montage.create(Properties3D);
100 if(selection === "Stage") {
101 p3d.init(el, true);
102 }
100 var shapeProps = null; 103 var shapeProps = null;
101 var pi = controller + "Pi"; 104 var pi = controller + "Pi";
102 105
@@ -138,7 +141,8 @@ exports.NJUtils = Object.create(Object.prototype, {
138 controller: { value: ControllerFactory.getController(controller)}, 141 controller: { value: ControllerFactory.getController(controller)},
139 pi: { value: pi}, 142 pi: { value: pi},
140 props3D: { value: p3d}, 143 props3D: { value: p3d},
141 shapeModel: { value: shapeProps} 144 shapeModel: { value: shapeProps},
145 isShape: { value: isShape}
142 }); 146 });
143 147
144 } 148 }
@@ -170,6 +174,7 @@ exports.NJUtils = Object.create(Object.prototype, {
170 // TODO - Need more info about the shape 174 // TODO - Need more info about the shape
171 selection = "canvas"; 175 selection = "canvas";
172 controller = "shape"; 176 controller = "shape";
177 isShape = true;
173 } 178 }
174 else 179 else
175 { 180 {
@@ -181,6 +186,9 @@ exports.NJUtils = Object.create(Object.prototype, {
181 break; 186 break;
182 } 187 }
183 this.makeElementModel(el, selection, controller, isShape); 188 this.makeElementModel(el, selection, controller, isShape);
189 if(el.elementModel && el.elementModel.props3D) {
190 el.elementModel.props3D.init(el, (selection === "Stage"));
191 }
184 } 192 }
185 }, 193 },
186 194
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 657c849f..945c9883 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -854,7 +854,7 @@ World.prototype.importObjectsJSON = function (jObj, parentGeomObj) {
854 854
855 // determine if we have children 855 // determine if we have children
856 if (jObj.children) { 856 if (jObj.children) {
857 var nKids = ojObjbj.chilodren.length; 857 var nKids = jObj.children.length;
858 for (var i = 0; i < nKids; i++) { 858 for (var i = 0; i < nKids; i++) {
859 var child = jObj.children[i]; 859 var child = jObj.children[i];
860 this.importObjectsJSON( child, gObj ); 860 this.importObjectsJSON( child, gObj );
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 7fa78b12..1073c2db 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -42,8 +42,8 @@ var Circle = function GLCircle() {
42 42
43 this._strokeWidth = strokeSize; 43 this._strokeWidth = strokeSize;
44 this._innerRadius = innerRadius; 44 this._innerRadius = innerRadius;
45 if (strokeColor) this._strokeColor = strokeColor; 45 this._strokeColor = strokeColor;
46 if (fillColor) this._fillColor = fillColor; 46 this._fillColor = fillColor;
47 47
48 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 } 49 }
@@ -631,6 +631,21 @@ var Circle = function GLCircle() {
631 this._strokeStyle = jObj.strokeStyle; 631 this._strokeStyle = jObj.strokeStyle;
632 var strokeMaterialName = jObj.strokeMat; 632 var strokeMaterialName = jObj.strokeMat;
633 var fillMaterialName = jObj.fillMat; 633 var fillMaterialName = jObj.fillMat;
634
635 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
636 if (!strokeMat) {
637 console.log( "object material not found in library: " + strokeMaterialName );
638 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
639 }
640 this._strokeMaterial = strokeMat;
641
642 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
643 if (!fillMat) {
644 console.log( "object material not found in library: " + fillMaterialName );
645 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
646 }
647 this._fillMaterial = fillMat;
648
634 this.importMaterialsJSON( jObj.materials ); 649 this.importMaterialsJSON( jObj.materials );
635 }; 650 };
636 651
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index bb5b4a9a..2cde8a75 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -1,8 +1,8 @@
1/* <copyright> 1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5 </copyright> */
6 6
7var MaterialsModel = require("js/models/materials-model").MaterialsModel; 7var MaterialsModel = require("js/models/materials-model").MaterialsModel;
8 8
@@ -144,46 +144,65 @@ var GeomObj = function GLGeomObj() {
144 this.setMaterialColor = function (c, type) { 144 this.setMaterialColor = function (c, type) {
145 var i = 0, 145 var i = 0,
146 nMats = 0; 146 nMats = 0;
147 if (c.gradientMode) { 147 if (c) {
148 // Gradient support 148 if (c.gradientMode) {
149 if (this._materialArray && this._materialTypeArray) { 149 // Gradient support
150 nMats = this._materialArray.length; 150 if (this._materialArray && this._materialTypeArray) {
151 } 151 nMats = this._materialArray.length;
152 152 }
153 var stops = [],
154 colors = c.color;
155 153
156 var len = colors.length; 154 var stops = [],
157 // TODO - Current shaders only support 4 color stops 155 colors = c.color;
158 if (len > 4) {
159 len = 4;
160 }
161 156
162 for (var n = 0; n < len; n++) { 157 var len = colors.length;
163 var position = colors[n].position / 100; 158 // TODO - Current shaders only support 4 color stops
164 var cs = colors[n].value; 159 if (len > 4) {
165 var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a]; 160 len = 4;
166 stops.push(stop); 161 }
167 162
168 if (nMats === this._materialTypeArray.length) { 163 for (var n = 0; n < len; n++) {
169 for (i = 0; i < nMats; i++) { 164 var position = colors[n].position / 100;
170 if (this._materialTypeArray[i] == type) { 165 var cs = colors[n].value;
171 this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0)); 166 var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a];
172 this._materialArray[i].setProperty("colorStop" + (n + 1), position); 167 stops.push(stop);
168
169 if (nMats === this._materialTypeArray.length) {
170 for (i = 0; i < nMats; i++) {
171 if (this._materialTypeArray[i] == type) {
172 this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0));
173 this._materialArray[i].setProperty("colorStop" + (n + 1), position);
174 }
173 } 175 }
174 } 176 }
175 } 177 }
176 } 178 if (type === "fill") {
177 if (type === "fill") { 179 this._fillColor = c;
178 this._fillColor = c; 180 } else {
181 this._strokeColor = c;
182 }
179 } else { 183 } else {
180 this._strokeColor = c; 184 if (type === "fill") {
185 this._fillColor = c.slice(0);
186 } else {
187 this._strokeColor = c.slice(0);
188 }
189
190 if (this._materialArray && this._materialTypeArray) {
191 nMats = this._materialArray.length;
192 if (nMats === this._materialTypeArray.length) {
193 for (i = 0; i < nMats; i++) {
194 if (this._materialTypeArray[i] == type) {
195 this._materialArray[i].setProperty("color", c.slice(0));
196 }
197 }
198 }
199 }
181 } 200 }
182 } else { 201 } else {
183 if (type === "fill") { 202 if (type === "fill") {
184 this._fillColor = c.slice(0); 203 this._fillColor = null;
185 } else { 204 } else {
186 this._strokeColor = c.slice(0); 205 this._strokeColor = null;
187 } 206 }
188 207
189 if (this._materialArray && this._materialTypeArray) { 208 if (this._materialArray && this._materialTypeArray) {
@@ -191,7 +210,8 @@ var GeomObj = function GLGeomObj() {
191 if (nMats === this._materialTypeArray.length) { 210 if (nMats === this._materialTypeArray.length) {
192 for (i = 0; i < nMats; i++) { 211 for (i = 0; i < nMats; i++) {
193 if (this._materialTypeArray[i] == type) { 212 if (this._materialTypeArray[i] == type) {
194 this._materialArray[i].setProperty("color", c.slice(0)); 213 // TODO - Not sure how to set color to null values in shaders
214 this._materialArray[i].setProperty("color", [0, 0, 0, 0]);
195 } 215 }
196 } 216