diff options
author | Nivesh Rajbhandari | 2012-02-06 15:41:48 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-06 15:41:48 -0800 |
commit | 75486be2839494c9b54833aff8f5eef3f9542151 (patch) | |
tree | b31d26275087bb8b6014a8cb2c1ffca8a3a28ef3 | |
parent | f94b0c5ada403379b3ff8a900c2a2aabcecce49e (diff) | |
download | ninja-75486be2839494c9b54833aff8f5eef3f9542151.tar.gz |
Support toggling between 2d and 3d canvas context. This requires us to create a new canvas with all the same values as the canvas being replaced and copying over all the shape data.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rw-r--r-- | js/controllers/elements/shapes-controller.js | 11 | ||||
-rw-r--r-- | js/mediators/element-mediator.js | 7 | ||||
-rwxr-xr-x | js/preloader/Preloader.js | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 74c88084..ed45710d 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | CanvasController = require("js/controllers/elements/canvas-controller").CanvasController; | 8 | CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, |
9 | njModule = require("js/lib/NJUtils"); | ||
9 | 10 | ||
10 | exports.ShapesController = Montage.create(CanvasController, { | 11 | exports.ShapesController = Montage.create(CanvasController, { |
11 | 12 | ||
@@ -57,9 +58,11 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
57 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 58 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
58 | break; | 59 | break; |
59 | case "useWebGl": | 60 | case "useWebGl": |
60 | // this.toggleWebGlMode(el, value); | 61 | var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); |
61 | // el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 62 | this.application.ninja.elementMediator.replaceElement(el, canvas); |
62 | el.elementModel.shapeModel.useWebGl = value; | 63 | el = canvas; |
64 | this.toggleWebGlMode(el, value); | ||
65 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | ||
63 | break; | 66 | break; |
64 | default: | 67 | default: |
65 | CanvasController.setProperty(el, p, value); | 68 | CanvasController.setProperty(el, p, value); |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index c44e1cb5..9aefbca6 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -112,6 +112,13 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
112 | } | 112 | } |
113 | }, | 113 | }, |
114 | 114 | ||
115 | replaceElement: { | ||
116 | value: function(el, el2) { | ||
117 | el2.elementModel = el.elementModel; | ||
118 | this.application.ninja.currentDocument.documentRoot.replaceChild(el2, el); | ||
119 | } | ||
120 | }, | ||
121 | |||
115 | getNJProperty: { | 122 | getNJProperty: { |
116 | value: function(el, p) { | 123 | value: function(el, p) { |
117 | if(el.elementModel) { | 124 | if(el.elementModel) { |
diff --git a/js/preloader/Preloader.js b/js/preloader/Preloader.js index 93d71e8f..42460093 100755 --- a/js/preloader/Preloader.js +++ b/js/preloader/Preloader.js | |||
@@ -60,6 +60,7 @@ exports.Preloader = Montage.create(Component, { | |||
60 | {"type":"js", "url":"js/helper-classes/RDGE/src/core/script/util/dbgpanel.js"}, | 60 | {"type":"js", "url":"js/helper-classes/RDGE/src/core/script/util/dbgpanel.js"}, |
61 | /* */ | 61 | /* */ |
62 | 62 | ||
63 | {"type":"js", "url":"js/helper-classes/3D/ParseUtils.js"}, | ||
63 | {"type":"js", "url":"js/helper-classes/RDGE/GLLine.js"}, | 64 | {"type":"js", "url":"js/helper-classes/RDGE/GLLine.js"}, |
64 | {"type":"js", "url":"js/helper-classes/RDGE/GLMaterial.js"}, | 65 | {"type":"js", "url":"js/helper-classes/RDGE/GLMaterial.js"}, |
65 | {"type":"js", "url":"js/helper-classes/RDGE/GLLight.js"}, | 66 | {"type":"js", "url":"js/helper-classes/RDGE/GLLight.js"}, |