diff options
author | hwc487 | 2012-03-23 14:59:51 -0700 |
---|---|---|
committer | hwc487 | 2012-03-23 14:59:51 -0700 |
commit | 86770d0dba6b137e651cbf5c8d240856be65857c (patch) | |
tree | c480e35abe9065733be9dd6326b91b46896b9e3a /js/controllers/elements | |
parent | 51478dbad8290f55eeab9efdfb8c2cbe24b12b10 (diff) | |
download | ninja-86770d0dba6b137e651cbf5c8d240856be65857c.tar.gz |
Fixed a problem switching from 3D to 2D and back to 3D.
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 28 |
1 files changed, 24 insertions, 4 deletions
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, { | |||
504 | var sm, | 504 | var sm, |
505 | fm, | 505 | fm, |
506 | world, | 506 | world, |
507 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 507 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
508 | if(worldData) | 508 | if(worldData) |
509 | { | 509 | { |
510 | worldData = this.flip3DSense (worldData ); | ||
510 | world = new World(el, true); | 511 | world = new World(el, true); |
511 | el.elementModel.shapeModel.GLWorld = world; | 512 | el.elementModel.shapeModel.GLWorld = world; |
512 | el.elementModel.shapeModel.useWebGl = true; | 513 | el.elementModel.shapeModel.useWebGl = true; |
513 | world.import(worldData); | 514 | world.importJSON(worldData); |
514 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 515 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
515 | 516 | ||
516 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | 517 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); |
@@ -540,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
540 | return; | 541 | return; |
541 | } | 542 | } |
542 | var world, | 543 | var world, |
543 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 544 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
544 | if(worldData) | 545 | if(worldData) |
545 | { | 546 | { |
547 | worldData = this.flip3DSense (worldData ); | ||
546 | world = new World(el, false); | 548 | world = new World(el, false); |
547 | el.elementModel.shapeModel.GLWorld = world; | 549 | el.elementModel.shapeModel.GLWorld = world; |
548 | el.elementModel.shapeModel.useWebGl = false; | 550 | el.elementModel.shapeModel.useWebGl = false; |
549 | world.import(worldData); | 551 | world.importJSON(worldData); |
550 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 552 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
551 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); | 553 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); |
552 | el.elementModel.shapeModel.strokeMaterial = null; | 554 | el.elementModel.shapeModel.strokeMaterial = null; |
@@ -558,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
558 | } | 560 | } |
559 | } | 561 | } |
560 | } | 562 | } |
563 | }, | ||
564 | |||
565 | flip3DSense: { | ||
566 | value: function( importStr ) | ||
567 | { | ||
568 | var jObj; | ||
569 | var index = importStr.indexOf( ';' ); | ||
570 | if ((importStr[0] === 'v') && (index < 24)) | ||
571 | { | ||
572 | // JSON format. separate the version info from the JSON info | ||
573 | //var vStr = importStr.substr( 0, index+1 ); | ||
574 | var jStr = importStr.substr( index+1 ); | ||
575 | jObj = JSON.parse( jStr ); | ||
576 | jObj.webGL = !jObj.webGL; | ||
577 | } | ||
578 | |||
579 | return jObj; | ||
580 | } | ||
561 | } | 581 | } |
562 | 582 | ||
563 | }); | 583 | }); |