aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-17 14:49:18 -0700
committerPushkar Joshi2012-04-17 14:49:18 -0700
commitdf903a01e14134cadf109b733d09c6eadfa3966b (patch)
tree2351f1c05b2f852053fa0be533072088a9ad4e7c /js/lib
parent036cf034e124dbc1f4893e90f7c6d240904a3faf (diff)
parentcacb4a21825818af392c2949967b0f3c1df509c5 (diff)
downloadninja-df903a01e14134cadf109b733d09c6eadfa3966b.tar.gz
Merge branch 'master' into pentool
Conflicts: js/tools/PenTool.js
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 904aa41e..67bb59c4 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -94,7 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, {
94 ///// TODO: find a different place for this function 94 ///// TODO: find a different place for this function
95 makeElementModel: { 95 makeElementModel: {
96 value: function(el, selection, controller, isShape) { 96 value: function(el, selection, controller, isShape) {
97 var p3d = Montage.create(Properties3D).init(el); 97 var p3d = Montage.create(Properties3D);
98 if(selection === "Stage") {
99 p3d.init(el, true);
100 }
98 var shapeProps = null; 101 var shapeProps = null;
99 var pi = controller + "Pi"; 102 var pi = controller + "Pi";
100 103
@@ -136,7 +139,8 @@ exports.NJUtils = Object.create(Object.prototype, {
136 controller: { value: ControllerFactory.getController(controller)}, 139 controller: { value: ControllerFactory.getController(controller)},
137 pi: { value: pi}, 140 pi: { value: pi},
138 props3D: { value: p3d}, 141 props3D: { value: p3d},
139 shapeModel: { value: shapeProps} 142 shapeModel: { value: shapeProps},
143 isShape: { value: isShape}
140 }); 144 });
141 145
142 } 146 }
@@ -168,6 +172,7 @@ exports.NJUtils = Object.create(Object.prototype, {
168 // TODO - Need more info about the shape 172 // TODO - Need more info about the shape
169 selection = "canvas"; 173 selection = "canvas";
170 controller = "shape"; 174 controller = "shape";
175 isShape = true;
171 } 176 }
172 else 177 else
173 { 178 {
@@ -179,6 +184,9 @@ exports.NJUtils = Object.create(Object.prototype, {
179 break; 184 break;
180 } 185 }
181 this.makeElementModel(el, selection, controller, isShape); 186 this.makeElementModel(el, selection, controller, isShape);
187 if(el.elementModel && el.elementModel.props3D) {
188 el.elementModel.props3D.init(el, (selection === "Stage"));
189 }
182 } 190 }
183 }, 191 },
184 192
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index d84a6aab..1a391338 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