aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/controllers/elements/shapes-controller.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 48072309..22ba66b3 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -56,6 +56,10 @@ exports.ShapesController = Montage.create(CanvasController, {
56 el.elementModel.shapeModel.GLWorld.setViewportFromCanvas(el); 56 el.elementModel.shapeModel.GLWorld.setViewportFromCanvas(el);
57 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 57 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
58 break; 58 break;
59 case "useWebGl":
60 this.toggleWebGlMode(el, value);
61 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
62 break;
59 default: 63 default:
60 CanvasController.setProperty(el, p, value); 64 CanvasController.setProperty(el, p, value);
61 } 65 }
@@ -276,6 +280,60 @@ exports.ShapesController = Montage.create(CanvasController, {
276 { 280 {
277 return (el.elementModel && el.elementModel.isShape); 281 return (el.elementModel && el.elementModel.isShape);
278 } 282 }
283 },
284
285 toggleWebGlMode: {
286 value: function(el, useWebGl)
287 {
288 if(useWebGl)
289 {
290 this.convertToWebGlWorld(el);
291 }
292 else
293 {
294 this.convertTo2DWorld(el);
295 }
296 }
297 },
298
299 convertToWebGlWorld: {
300 value: function(el)
301 {
302 if(el.elementModel.shapeModel.useWebGl)
303 {
304 return;
305 }
306 var world,
307 worldData = el.elementModel.shapeModel.GLWorld.export();
308 if(worldData)
309 {
310 world = new GLWorld(el, true);
311 el.elementModel.shapeModel.GLWorld = world;
312 el.elementModel.shapeModel.useWebGl = true;
313 world.import(worldData);
314 }
315
316 }
317 },
318
319 convertTo2DWorld: {
320 value: function(el)
321 {
322 if(!el.elementModel.shapeModel.useWebGl)
323 {
324 return;
325 }
326 var world,
327 worldData = el.elementModel.shapeModel.GLWorld.export();
328 if(worldData)
329 {
330 world = new GLWorld(el, false);
331 el.elementModel.shapeModel.GLWorld = world;
332 el.elementModel.shapeModel.useWebGl = false;
333 world.import(worldData);
334 }
335
336 }
279 } 337 }
280 338
281}); 339});