From 818582d389f504c915be0c9052fafa33e3e76c92 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 7 Mar 2012 16:48:48 -0800 Subject: File IO --- js/lib/drawing/world.js | 90 +++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 37 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 3d6c6fc4..b8bceda6 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -4,17 +4,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -// Useless Global variables. -// TODO: Remove this as soon as QE test pass -/* -var shaderProgramArray = new Array; -var glContextArray = new Array; -var vertexShaderSource = ""; -var fragmentShaderSource = ""; -var rdgeStarted = false; -*/ - -var nodeCounter = 0; var GeomObj = require("js/lib/geom/geom-obj").GeomObj; var Line = require("js/lib/geom/line").Line; @@ -22,6 +11,8 @@ var Rectangle = require("js/lib/geom/rectangle").Rectangle; var Circle = require("js/lib/geom/circle").Circle; var MaterialsModel = require("js/models/materials-model").MaterialsModel; +var worldCounter = 0; + /////////////////////////////////////////////////////////////////////// // Class GLWorld // Manages display in a canvas @@ -76,6 +67,12 @@ var World = function GLWorld( canvas, use3D ) { // no animated materials this._firstRender = true; + this._worldCount = worldCounter; + worldCounter++; + + // keep a counter for generating node names + this._nodeCounter = 0; + /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// @@ -350,9 +347,12 @@ var World = function GLWorld( canvas, use3D ) { return false; }; - - // END RDGE - //////////////////////////////////////////////////////////////////////////////////// + this.generateUniqueNodeID = function() + { + var str = String( this._nodeCounter ); + this._nodeCounter++; + return str; + } // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state @@ -391,7 +391,7 @@ World.prototype.updateObject = function (obj) { if (nPrims > 0) { ctrTrNode = obj.getTransformNode(); if (ctrTrNode == null) { - ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); + ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++); this._rootNode.insertAsChild( ctrTrNode ); obj.setTransformNode( ctrTrNode ); } @@ -401,7 +401,7 @@ World.prototype.updateObject = function (obj) { }); ctrTrNode.meshes = []; - ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); + ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); ctrTrNode.attachMaterial(materialNodes[0]); } @@ -420,12 +420,12 @@ World.prototype.updateObject = function (obj) { }); childTrNode.meshes = []; } else { - childTrNode = createTransformNode("objNode_" + nodeCounter++); + childTrNode = createTransformNode("objNode_" + this._nodeCounter++); ctrTrNode.insertAsChild(childTrNode); } // attach the instanced box goe - childTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prim); + childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); childTrNode.attachMaterial(materialNodes[i]); } }; @@ -727,7 +727,7 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; -World.prototype.export = function() { +World.prototype.export = function( exportForPublish ) { var exportStr = "GLWorld 1.0\n"; var id = this.getCanvas().getAttribute( "data-RDGE-id" ); exportStr += "id: " + id + "\n"; @@ -736,17 +736,28 @@ World.prototype.export = function() { exportStr += "zNear: " + this._zNear + "\n"; exportStr += "zFar: " + this._zFar + "\n"; exportStr += "viewDist: " + this._viewDist + "\n"; + if (this._useWebGL) + exportStr += "webGL: true\n"; // we need 2 export modes: One for save/restore, one for publish. // hardcoding for now - var exportForPublish = false; + //var exportForPublish = false; + if (!exportForPublish) exportForPublish = false; exportStr += "publish: " + exportForPublish + "\n"; - if (exportForPublish) { + if (exportForPublish && this._useWebGL) + { exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; - } else { + + // write out all of the objects + exportStr += "tree\n"; + exportStr += this.exportObjects( this._geomRoot ); + exportStr += "endtree\n"; + } + else + { // output the material library - exportStr += MaterialsModel.exportMaterials(); + //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL // write out all of the objects exportStr += "tree\n"; @@ -800,21 +811,26 @@ World.prototype.import = function( importStr ) { // determine if the data was written for export (no Ninja objects) // or for save/restore - var index = importStr.indexOf( "scenedata: " ); - if (index >= 0) { - var rdgeStr = importStr.substr( index+11 ); - var endIndex = rdgeStr.indexOf( "endscene\n" ); - if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); - var len = endIndex - index + 11; - rdgeStr = rdgeStr.substr( 0, endIndex ); - - this.myScene.importJSON( rdgeStr ); - } else { - // load the material library - importStr = MaterialsModel.importMaterials( importStr ); + //var index = importStr.indexOf( "scenedata: " ); + var index = importStr.indexOf( "webGL: " ); + this._useWebGL = (index >= 0) + if (this._useWebGL) + { + // start RDGE + rdgeStarted = true; + var id = this._canvas.getAttribute( "data-RDGE-id" ); + this._canvas.rdgeid = id; + g_Engine.registerCanvas(this._canvas, this); + RDGEStart( this._canvas ); + this._canvas.task.stop() + } + + this.importObjects( importStr, this._rootNode ); - // import the objects - this.importObjects( importStr, this._rootNode ); + if (!this._useWebGL) + { + // render using canvas 2D + this.render(); } }; -- cgit v1.2.3 From 7b6e8194b91168abdeb94702eb350d14f147858b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 17:29:18 -0800 Subject: Canvas IO --- js/lib/drawing/world.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b8bceda6..cffd0083 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -349,7 +349,7 @@ var World = function GLWorld( canvas, use3D ) { this.generateUniqueNodeID = function() { - var str = String( this._nodeCounter ); + var str = "" + this._nodeCounter; this._nodeCounter++; return str; } @@ -727,7 +727,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; -World.prototype.export = function( exportForPublish ) { +World.prototype.export = function( imagePath ) +{ var exportStr = "GLWorld 1.0\n"; var id = this.getCanvas().getAttribute( "data-RDGE-id" ); exportStr += "id: " + id + "\n"; @@ -742,9 +743,17 @@ World.prototype.export = function( exportForPublish ) { // we need 2 export modes: One for save/restore, one for publish. // hardcoding for now //var exportForPublish = false; - if (!exportForPublish) exportForPublish = false; + //if (!exportForPublish) exportForPublish = false; + var exportForPublish = true; exportStr += "publish: " + exportForPublish + "\n"; + // the relative path for local assets needs to be modified to + // the path specified by argument 'imagePath'. Save that path + // so exporting functions can call newPath = world.cleansePath( oldPath ); + this._imagePath = imagePath.slice(); + var endchar = this._imagePath[this._imagePath.length-1] + if (endchar != '/') this._imagePath += '/'; + if (exportForPublish && this._useWebGL) { exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; @@ -928,6 +937,20 @@ World.prototype.importSubObject = function( objStr, parentNode ) { return trNode; }; +World.prototype.cleansePath = function( url ) +{ + //this._imagePath + var searchStr = "assets/"; + var index = url.indexOf( searchStr ); + var rtnPath = url; + if (index >= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._imagePath + rtnPath; + } + return rtnPath; +} + if (typeof exports === "object") { exports.World = World; } \ No newline at end of file -- cgit v1.2.3 From 86784888a98a05523dbedcbe32fd4dea336878e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 9 Mar 2012 08:21:13 -0800 Subject: Eyedropper support for getting color value from webgl shapes. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 3d6c6fc4..04e4d96b 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -26,7 +26,7 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; // Class GLWorld // Manages display in a canvas /////////////////////////////////////////////////////////////////////// -var World = function GLWorld( canvas, use3D ) { +var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// @@ -39,7 +39,11 @@ var World = function GLWorld( canvas, use3D ) { this._canvas = canvas; if (this._useWebGL) { - this._glContext = canvas.getContext("experimental-webgl"); + if(preserveDrawingBuffer) { + this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); + } else { + this._glContext = canvas.getContext("experimental-webgl"); + } } else { this._2DContext = canvas.getContext( "2d" ); } @@ -680,7 +684,7 @@ World.prototype.render = function() { var root = this.getGeomRoot(); this.hRender( root ); } else { - g_Engine.setContext( this._canvas.rdgeId ); + g_Engine.setContext( this._canvas.rdgeid ); //this.draw(); this.restartRenderLoop(); } -- cgit v1.2.3 From e92a6da7b84c58803489d70efedf74837ddfe4cd Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 13:34:09 -0800 Subject: Removed asset path replacement at authortime. --- js/lib/drawing/world.js | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index cffd0083..44c9e37d 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -727,7 +727,7 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; -World.prototype.export = function( imagePath ) +World.prototype.export = function() { var exportStr = "GLWorld 1.0\n"; var id = this.getCanvas().getAttribute( "data-RDGE-id" ); @@ -747,13 +747,6 @@ World.prototype.export = function( imagePath ) var exportForPublish = true; exportStr += "publish: " + exportForPublish + "\n"; - // the relative path for local assets needs to be modified to - // the path specified by argument 'imagePath'. Save that path - // so exporting functions can call newPath = world.cleansePath( oldPath ); - this._imagePath = imagePath.slice(); - var endchar = this._imagePath[this._imagePath.length-1] - if (endchar != '/') this._imagePath += '/'; - if (exportForPublish && this._useWebGL) { exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; @@ -937,20 +930,6 @@ World.prototype.importSubObject = function( objStr, parentNode ) { return trNode; }; -World.prototype.cleansePath = function( url ) -{ - //this._imagePath - var searchStr = "assets/"; - var index = url.indexOf( searchStr ); - var rtnPath = url; - if (index >= 0) - { - rtnPath = url.substr( index + searchStr.length ); - rtnPath = this._imagePath + rtnPath; - } - return rtnPath; -} - if (typeof exports === "object") { exports.World = World; } \ No newline at end of file -- cgit v1.2.3 From ca985ed7031af3f4e76d26fd5b99846620fc5733 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 13 Mar 2012 18:11:48 -0700 Subject: Some code cleanup - removing unused assignments. Signed-off-by: Valerio Virgillito --- js/lib/drawing/world.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index df24f556..049145ce 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -351,20 +351,18 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { return false; }; - this.generateUniqueNodeID = function() - { + this.generateUniqueNodeID = function() { var str = "" + this._nodeCounter; this._nodeCounter++; return str; - } + }; // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state // in the case of a procedurally built scene an init state is not needed for loading data if (this._useWebGL) { rdgeStarted = true; - var id = this._canvas.getAttribute( "data-RDGE-id" ); - this._canvas.rdgeid = id; + this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); g_Engine.registerCanvas(this._canvas, this); RDGEStart( this._canvas ); this._canvas.task.stop() -- cgit v1.2.3 From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/lib/drawing/world.js | 147 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 049145ce..07a2c3ae 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -363,6 +363,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { if (this._useWebGL) { rdgeStarted = true; this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); + g_Engine.unregisterCanvas( this._canvas ) g_Engine.registerCanvas(this._canvas, this); RDGEStart( this._canvas ); this._canvas.task.stop() @@ -729,6 +730,72 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; +World.prototype.exportJSON = function() +{ + // world properties + var worldObj = + { + 'version' : 1.1, + 'id' : this.getCanvas().getAttribute( "data-RDGE-id" ), + 'fov' : this._fov, + 'zNear' : this._zNear, + 'zFar' : this._zFar, + 'viewDist' : this._viewDist, + 'webGL' : this._useWebGL + }; + + // RDGE scenegraph + if (this._useWebGL) + worldObj.scenedata = this.myScene.exportJSON(); + + // object data + var strArray = []; + this.exportObjectsJSON( this._geomRoot, worldObj ); + + // You would think that the RDGE export function + // would not be destructive of the data. You would be wrong... + // We need to rebuild everything + if (this._useWebGL) + { + var root = this._rootNode; + root.children = new Array(); + if (worldObj.children && (worldObj.children.length === 1)) + { + this.init(); + this._geomRoot = undefined; + this.importObjectsJSON( worldObj.children[0] ); + } + } + + // convert the object to a string + var jStr = JSON.stringify( worldObj ); + + // prepend some version information to the string. + // this string is also used to differentiate between JSON + // and pre-JSON versions of fileIO. + // the ending ';' in the version string is necessary + jStr = "v1.0;" + jStr; + + return jStr; +} + +World.prototype.exportObjectsJSON = function( obj, parentObj ) +{ + if (!obj) return; + + var jObj = obj.exportJSON(); + if (!parentObj.children) parentObj.children = []; + parentObj.children.push( jObj ); + + if (obj.getChild()) { + this.exportObjectsJSON( obj.getChild (), jObj ); + } + + if (obj.getNext()) + this.exportObjectsJSON( obj.getNext(), parentObj ); +} + +/* World.prototype.export = function() { var exportStr = "GLWorld 1.0\n"; @@ -791,6 +858,7 @@ World.prototype.exportObjects = function( obj ) { return rtnStr; }; +*/ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { //if (trNode == null) trNode = this._ctrNode; @@ -810,6 +878,85 @@ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) return rtnNode; }; +World.prototype.importJSON = function( jObj ) +{ + if (jObj.webGL) + { + // start RDGE + rdgeStarted = true; + var id = this._canvas.getAttribute( "data-RDGE-id" ); + this._canvas.rdgeid = id; + g_Engine.registerCanvas(this._canvas, this); + RDGEStart( this._canvas ); + this._canvas.task.stop() + } + + // import the objects + // there should be exactly one child of the parent object + if (jObj.children && (jObj.children.length === 1)) + this.importObjectsJSON( jObj.children[0] ); + else + throw new Error ("unrecoverable canvas import error - inconsistent root object: " + jObj.children ); + + if (!this._useWebGL) + { + // render using canvas 2D + this.render(); + } + else + this.restartRenderLoop(); +} + +World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) +{ + // read the next object + var gObj = this.importObjectJSON( jObj, parentGeomObj ); + + // determine if we have children + if (jObj.children) + { + var nKids = ojObjbj.chilodren.length; + for (var i=0; i --- js/lib/drawing/world.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 07a2c3ae..b87c6272 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -117,6 +117,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { this.getRenderer = function() { return this.renderer; }; + // Flag to play/pause animation at authortime + this._previewAnimation = true; //////////////////////////////////////////////////////////////////////////////////// // RDGE // local variables @@ -475,6 +477,10 @@ World.prototype.restartRenderLoop = function() { if (this._allMapsLoaded) { //console.log( "starting task" ); this._canvas.task.start(); + if(!this._previewAnimation) { + //render only once if authortime animation is turned off + this._canvas.task.stop(); + } } else { //console.log( "stopping task" ); this._canvas.task.stop(); -- cgit v1.2.3 From 2946d01666ff81f913bd06d1ac1381ed42b4a010 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 23 Mar 2012 13:37:31 -0700 Subject: Check for a authortime animation setting in the draw routine for WebGL. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b87c6272..fb787256 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -238,7 +238,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { if (this._canvas.task) { this._firstRender = false; - if (!this.hasAnimatedMaterials()) { + if (!this.hasAnimatedMaterials() || !this._previewAnimation) { this._canvas.task.stop(); //this._renderCount = 10; } @@ -477,10 +477,6 @@ World.prototype.restartRenderLoop = function() { if (this._allMapsLoaded) { //console.log( "starting task" ); this._canvas.task.start(); - if(!this._previewAnimation) { - //render only once if authortime animation is turned off - this._canvas.task.stop(); - } } else { //console.log( "stopping task" ); this._canvas.task.stop(); -- cgit v1.2.3 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/lib/drawing/world.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b87c6272..73273adc 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -736,6 +736,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; + + World.prototype.exportJSON = function() { // world properties -- cgit v1.2.3 From a806c422905adf0fa5c244d751535c615ec5d8c7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Sat, 24 Mar 2012 13:57:23 -0700 Subject: Check for a authortime animation setting in the draw routine for WebGL. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index fd833e4b..781695b6 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -238,7 +238,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { if (this._canvas.task) { this._firstRender = false; - if (!this.hasAnimatedMaterials() || !this._previewAnimation) { + if (!this.hasAnimatedMaterials() || !this._previewAnimation) { this._canvas.task.stop(); //this._renderCount = 10; } -- cgit v1.2.3 From 723ea402b74efa0424b96c7e125c8ebb2b72410c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 26 Mar 2012 17:36:27 -0700 Subject: Fixed issue with WebGL materials not working after file-save or chrome-preview. Also fixed Raiders material not showing in the PI or working during Chrome Preview. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 781695b6..fec6a478 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -761,13 +761,10 @@ World.prototype.exportJSON = function() // We need to rebuild everything if (this._useWebGL) { - var root = this._rootNode; - root.children = new Array(); if (worldObj.children && (worldObj.children.length === 1)) { - this.init(); - this._geomRoot = undefined; - this.importObjectsJSON( worldObj.children[0] ); + this.rebuildTree(this._geomRoot); + this.restartRenderLoop(); } } @@ -783,6 +780,20 @@ World.prototype.exportJSON = function() return jStr; } +World.prototype.rebuildTree = function( obj ) +{ + if (!obj) return; + + obj.buildBuffers(); + + if (obj.getChild()) { + this.rebuildTree( obj.getChild () ); + } + + if (obj.getNext()) + this.rebuildTree( obj.getNext() ); +} + World.prototype.exportObjectsJSON = function( obj, parentObj ) { if (!obj) return; -- cgit v1.2.3 From 903b01b9d0501e6f974034273385a0517107b1e3 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 27 Mar 2012 12:42:42 -0700 Subject: File IO for the brush stroke AND changing the data type of brush stroke from GEOM_TYPE_CUBIC_BEZIER to GEOM_TYPE_BRUSH_STROKE --- js/lib/drawing/world.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 781695b6..1552178d 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -931,6 +931,7 @@ World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) World.prototype.importObjectJSON = function( jObj, parentGeomObj ) { var type = jObj.type; + var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; var obj; switch (type) @@ -950,6 +951,11 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj ) obj.importJSON( jObj ); break; + case 6: //brush stroke + obj = new BrushStroke(); + obj.importJSON(jObj); + break; + default: throw new Error( "Unrecognized object type: " + type ); break; -- cgit v1.2.3