diff options
author | Pushkar Joshi | 2012-03-27 12:43:50 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-27 12:43:50 -0700 |
commit | 02a34df0ec3201199d209d43f621898b5607c150 (patch) | |
tree | d520b35afb0a8154abe417dce232c263a89794ce | |
parent | 903b01b9d0501e6f974034273385a0517107b1e3 (diff) | |
parent | 675fffb08f570783f055471501f94fc273de2b9e (diff) | |
download | ninja-02a34df0ec3201199d209d43f621898b5607c150.tar.gz |
Merge branch 'master' into brushtool
-rw-r--r-- | assets/canvas-runtime.js | 1 | ||||
-rwxr-xr-x | js/controllers/color-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 4 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 21 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 2 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 18 | ||||
-rwxr-xr-x | js/models/materials-model.js | 1 | ||||
-rwxr-xr-x | js/tools/EyedropperTool.js | 28 |
8 files changed, 65 insertions, 14 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index dd909e26..f53a4ef6 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -527,6 +527,7 @@ function RuntimeGeomObj() | |||
527 | case "deform": | 527 | case "deform": |
528 | case "water": | 528 | case "water": |
529 | case "paris": | 529 | case "paris": |
530 | case "raiders": | ||
530 | case "tunnel": | 531 | case "tunnel": |
531 | case "reliefTunnel": | 532 | case "reliefTunnel": |
532 | case "squareTunnel": | 533 | case "squareTunnel": |
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index 8e000b19..c6d664cf 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js | |||
@@ -227,14 +227,14 @@ exports.ColorController = Montage.create(Component, { | |||
227 | // | 227 | // |
228 | this.fill = color; | 228 | this.fill = color; |
229 | // | 229 | // |
230 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 230 | if(e._event.wasSetByCode) return; |
231 | // | 231 | // |
232 | this.setColor(mode, color, true); | 232 | this.setColor(mode, color, true); |
233 | } else if (input === 'stroke') { | 233 | } else if (input === 'stroke') { |
234 | // | 234 | // |
235 | this.stroke = color; | 235 | this.stroke = color; |
236 | // | 236 | // |
237 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 237 | if(e._event.wasSetByCode) return; |
238 | 238 | ||
239 | this.setColor(mode, color, false); | 239 | this.setColor(mode, color, false); |
240 | } | 240 | } |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 68a82762..ef453bea 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -336,6 +336,10 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
336 | color = this.getShapeProperty(el, "stroke"); | 336 | color = this.getShapeProperty(el, "stroke"); |
337 | } | 337 | } |
338 | 338 | ||
339 | if(!css) { | ||
340 | return null; | ||
341 | } | ||
342 | |||
339 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); | 343 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); |
340 | return this.application.ninja.colorController.getColorObjFromCss(css); | 344 | return this.application.ninja.colorController.getColorObjFromCss(css); |
341 | } | 345 | } |
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 1552178d..5a054224 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -761,13 +761,10 @@ World.prototype.exportJSON = function() | |||
761 | // We need to rebuild everything | 761 | // We need to rebuild everything |
762 | if (this._useWebGL) | 762 | if (this._useWebGL) |
763 | { | 763 | { |
764 | var root = this._rootNode; | ||
765 | root.children = new Array(); | ||
766 | if (worldObj.children && (worldObj.children.length === 1)) | 764 | if (worldObj.children && (worldObj.children.length === 1)) |
767 | { | 765 | { |
768 | this.init(); | 766 | this.rebuildTree(this._geomRoot); |
769 | this._geomRoot = undefined; | 767 | this.restartRenderLoop(); |
770 | this.importObjectsJSON( worldObj.children[0] ); | ||
771 | } | 768 | } |
772 | } | 769 | } |
773 | 770 | ||
@@ -783,6 +780,20 @@ World.prototype.exportJSON = function() | |||
783 | return jStr; | 780 | return jStr; |
784 | } | 781 | } |
785 | 782 | ||
783 | World.prototype.rebuildTree = function( obj ) | ||
784 | { | ||
785 | if (!obj) return; | ||
786 | |||
787 | obj.buildBuffers(); | ||
788 | |||
789 | if (obj.getChild()) { | ||
790 | this.rebuildTree( obj.getChild () ); | ||
791 | } | ||
792 | |||
793 | if (obj.getNext()) | ||
794 | this.rebuildTree( obj.getNext() ); | ||
795 | } | ||
796 | |||
786 | World.prototype.exportObjectsJSON = function( obj, parentObj ) | 797 | World.prototype.exportObjectsJSON = function( obj, parentObj ) |
787 | { | 798 | { |
788 | if (!obj) return; | 799 | if (!obj) return; |
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index be80f1e4..f1aa9f8a 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -303,6 +303,7 @@ var GeomObj = function GLGeomObj() { | |||
303 | case "deform": | 303 | case "deform": |
304 | case "water": | 304 | case "water": |
305 | case "paris": | 305 | case "paris": |
306 | case "raiders": | ||
306 | case "tunnel": | 307 | case "tunnel": |
307 | case "reliefTunnel": | 308 | case "reliefTunnel": |
308 | case "squareTunnel": | 309 | case "squareTunnel": |
@@ -376,6 +377,7 @@ var GeomObj = function GLGeomObj() { | |||
376 | case "deform": | 377 | case "deform": |
377 | case "water": | 378 | case "water": |
378 | case "paris": | 379 | case "paris": |
380 | case "raiders": | ||
379 | case "tunnel": | 381 | case "tunnel": |
380 | case "reliefTunnel": | 382 | case "reliefTunnel": |
381 | case "squareTunnel": | 383 | case "squareTunnel": |
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index f4a4baa2..fee02a1d 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js | |||
@@ -282,10 +282,26 @@ var RaidersMaterial = function RaidersMaterial() | |||
282 | this.inheritedFrom(); | 282 | this.inheritedFrom(); |
283 | 283 | ||
284 | this._name = "RaidersMaterial"; | 284 | this._name = "RaidersMaterial"; |
285 | this._shaderName = "radialBlur"; | 285 | this._shaderName = "raiders"; |
286 | 286 | ||
287 | this._texMap = 'assets/images/raiders.png'; | 287 | this._texMap = 'assets/images/raiders.png'; |
288 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 288 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); |
289 | |||
290 | |||
291 | // duplcate method requirde | ||
292 | this.dup = function( world ) { | ||
293 | // allocate a new uber material | ||
294 | var newMat = new RaidersMaterial(); | ||
295 | |||
296 | // copy over the current values; | ||
297 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
298 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
299 | var n = propNames.length; | ||
300 | for (var i=0; i<n; i++) | ||
301 | newMat.setProperty( propNames[i], propValues[i] ); | ||
302 | |||
303 | return newMat; | ||
304 | }; | ||
289 | } | 305 | } |
290 | 306 | ||
291 | RaidersMaterial.prototype = new Material(); | 307 | RaidersMaterial.prototype = new Material(); |
diff --git a/js/models/materials-model.js b/js/models/materials-model.js index 692ac09a..44364aa2 100755 --- a/js/models/materials-model.js +++ b/js/models/materials-model.js | |||
@@ -238,6 +238,7 @@ exports.MaterialsModel = Montage.create(Component, { | |||
238 | case "fly": mat = new FlyMaterial(); break; | 238 | case "fly": mat = new FlyMaterial(); break; |
239 | case "water": mat = new WaterMaterial(); break; | 239 | case "water": mat = new WaterMaterial(); break; |
240 | case "paris": mat = new ParisMaterial(); break; | 240 | case "paris": mat = new ParisMaterial(); break; |
241 | case "raiders": mat = new RaidersMaterial(); break; | ||
241 | case "zinvert": mat = new ZInvertMaterial(); break; | 242 | case "zinvert": mat = new ZInvertMaterial(); break; |
242 | case "deform": mat = new DeformMaterial(); break; | 243 | case "deform": mat = new DeformMaterial(); break; |
243 | case "star": mat = new StarMaterial(); break; | 244 | case "star": mat = new StarMaterial(); break; |
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 927b86cf..d627f03b 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js | |||
@@ -148,7 +148,11 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
148 | c = this._getColorFromElement(obj, event); | 148 | c = this._getColorFromElement(obj, event); |
149 | } | 149 | } |
150 | 150 | ||
151 | if(typeof(c) === "string") | 151 | if(!c) |
152 | { | ||
153 | color = null; | ||
154 | } | ||
155 | else if(typeof(c) === "string") | ||
152 | { | 156 | { |
153 | color = this.application.ninja.colorController.getColorObjFromCss(c); | 157 | color = this.application.ninja.colorController.getColorObjFromCss(c); |
154 | } | 158 | } |
@@ -368,7 +372,7 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
368 | this._imageDataContext = this._imageDataCanvas.getContext("2d"); | 372 | this._imageDataContext = this._imageDataCanvas.getContext("2d"); |
369 | if(isWebGl) | 373 | if(isWebGl) |
370 | { | 374 | { |
371 | var worldData = elt.elementModel.shapeModel.GLWorld.export(); | 375 | var worldData = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
372 | if(worldData) | 376 | if(worldData) |
373 | { | 377 | { |
374 | this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); | 378 | this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); |
@@ -379,12 +383,24 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
379 | this._webGlDataCanvas.width = w; | 383 | this._webGlDataCanvas.width = w; |
380 | this._webGlDataCanvas.height = h; | 384 | this._webGlDataCanvas.height = h; |
381 | this._webGlWorld = new World(this._webGlDataCanvas, true, true); | 385 | this._webGlWorld = new World(this._webGlDataCanvas, true, true); |
382 | this._webGlWorld.import(worldData); | 386 | |
387 | var index = worldData.indexOf( ';' ); | ||
388 | if ((worldData[0] === 'v') && (index < 24)) | ||
389 | { | ||
390 | // JSON format. separate the version info from the JSON info | ||
391 | var jStr = worldData.substr( index+1 ); | ||
392 | worldData = JSON.parse( jStr ); | ||
393 | } | ||
394 | |||
395 | this._webGlWorld.importJSON(worldData); | ||
383 | this._webGlWorld.render(); | 396 | this._webGlWorld.render(); |
384 | setTimeout(function() { | 397 | setTimeout(function() { |