From 86770d0dba6b137e651cbf5c8d240856be65857c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 23 Mar 2012 14:59:51 -0700 Subject: Fixed a problem switching from 3D to 2D and back to 3D. --- js/controllers/elements/shapes-controller.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b060b751..5b9e4672 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -504,13 +504,14 @@ exports.ShapesController = Montage.create(CanvasController, { var sm, fm, world, - worldData = el.elementModel.shapeModel.GLWorld.export(); + worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); if(worldData) { + worldData = this.flip3DSense (worldData ); world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; - world.import(worldData); + world.importJSON(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); @@ -540,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { return; } var world, - worldData = el.elementModel.shapeModel.GLWorld.export(); + worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); if(worldData) { + worldData = this.flip3DSense (worldData ); world = new World(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; - world.import(worldData); + world.importJSON(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); el.elementModel.shapeModel.strokeMaterial = null; @@ -558,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { } } } + }, + + flip3DSense: { + value: function( importStr ) + { + var jObj; + var index = importStr.indexOf( ';' ); + if ((importStr[0] === 'v') && (index < 24)) + { + // JSON format. separate the version info from the JSON info + //var vStr = importStr.substr( 0, index+1 ); + var jStr = importStr.substr( index+1 ); + jObj = JSON.parse( jStr ); + jObj.webGL = !jObj.webGL; + } + + return jObj; + } } }); -- cgit v1.2.3