diff --git a/index.html b/index.html index 30a56ae..3c8724d 100644 --- a/index.html +++ b/index.html @@ -8,8 +8,8 @@ - + diff --git a/js/saveload.js b/js/saveload.js index 22ba313..afcf10a 100644 --- a/js/saveload.js +++ b/js/saveload.js @@ -12,14 +12,17 @@ function handleFileLoad(event){ console.log("JSON is Valid syntax - Loading file"); gitems.push(JSON.parse(reader.result)); } + if(gitems.length <= 1){ + loadLocal(gitems); + } }); reader.readAsText(f); } + console.log("hi"); - loadLocal(gitems); } @@ -69,8 +72,8 @@ function saveLocal(){ //Local Load - is called by handleFileLoad function loadLocal(json){ - - + console.log("hello"); + generateWorldFromFile(json); } diff --git a/js/world.js b/js/world.js index 6634622..99640d7 100644 --- a/js/world.js +++ b/js/world.js @@ -8,7 +8,7 @@ var selected_object; //block dealing with loading from JSON function buildWorld(){ - generateRandomWorld(20); + generateRandomWorld(0); //This should be removed or modified to always draw a set world } function getSelectedObject(){ @@ -34,6 +34,67 @@ function getEvalWorld(){ return scope; } +//THIS METHOD NEEDS TO BE CALLED ON RECEPTION OF MESSAGE TO WORKER THREAD rather than directly from saveload.js in order to get scope of bonsai +//gets passed a tree structure from saveload - TODO: Make sure library is loaded before user uploads world - will want to add check from library name of world load to library name on server +function generateWorldFromFile(worldTree){ + console.log("gets to here..."); + loadedLibrary = null; + var worldObjects = []; + var obj_list = []; //List of objects to draw to screen + var ind_list = []; //List of indexes mapped to same position as obj_list + if(loadedLibrary == null){ + loadedLibrary = worldTree[0]; //The library should be the only file in the buffer + } + + + for(var i = 0; i