iiceman Posted March 1, 2015 Share Posted March 1, 2015 Hey there folks, I am still playing around with my very simple mesh editor and I got to a point where I want to save the scene that I have created and later on load it again. I thought I can use the SceneSerializer (found here: http://www.html5gamedevs.com/topic/6039-exporting-a-babylon-scene-to-a-file/) and stringify my scene and then use the SceneLoader to load it again (because thats the only way I could think of to get my scene back) from that string. I ended up with an error that tells me I have no camera defined when reloading the saved scene. So I check and it seems to be true: after serializing the scene there is no camera.var serializedScene = BABYLON.SceneSerializer.Serialize(scene);var strScene = JSON.stringify(serializedScene);console.log(scene.cameras, serializedScene.cameras);The console shows a camera for scene.cameras but serializedScene.cameras is just an empty array. Am I doing something wrong here or is it just not how I am supposed to do it? Here is the current version of the editor: http://localhost/babylondev/mapEditor/ Edit: http://p215008.mittwaldserver.info/mapEditor/ (load and save buttons are in the file menu at the top) By the way: right mouse button to select a mesh. Hope you guys can help me out once again here jerome 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 1, 2015 Share Posted March 1, 2015 the only way to access your localhost address is to hack your computer :-)Would love to see your editor, if you have an online version of it. Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 1, 2015 Author Share Posted March 1, 2015 Ah, damn, how did I mess that up... guess I had the local and the online version open and accidentally mixed up the browser tabs :-/ fixed it now, thanks for the hint Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 2, 2015 Share Posted March 2, 2015 WOOOOOT! THis is so cool! And now you will be able to use the new shadow filter I introduced with 2.1 Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted March 2, 2015 Share Posted March 2, 2015 FYI your editor doesn't work in Firefox . I can see the grid and the GUI, but mouse clicks do nothing (left, double nor right). But in IE your editor rocks !!! Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 2, 2015 Share Posted March 2, 2015 regarding your question - the scene serializesr seems to only serialize FreeCamera instances and ignore the rest. And I guess you are using ArxRotate. Shouldn't be too hard adding it in. Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 2, 2015 Author Share Posted March 2, 2015 @Vousk-prodm, thanks for telling me, I'll check that out. It worked in chrome so I thought it was okay :-/ @Deltakosh, yeah, looking forward to that. Not sure when I'll have time to try it out, but can't wait @RaananW, I used your material editor to prepare the materials. I thought about making it dynamic somehow so that people can create materials with your editor on the fly and use them right away. About the ArcRotateCamera... well, could I just initialize a new camera after loading? But then the problem is that it doesn't even finish loading without the camera, right? I assume that there is a reason why the acr camera gets ignored.... well, if not.. if it's really that easy... would be great if somebody could fix that for me (not sure I can :-/ ) Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 2, 2015 Share Posted March 2, 2015 :-)If I find the time later today I'll add the ArcRotateCamera to the serializer. I don't see a problem, but will let you know if I find one. About the Material editor - please let me know if you need any help with changing it. I have created a "save" and "load" functionality which stores all images and the serialized babylon material, look at these implementations, maybe they can be handy. iiceman 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 2, 2015 Share Posted March 2, 2015 So, PR was sent (https://github.com/BabylonJS/Babylon.js/pull/417), I hope it will be validated soon and that 2.1 will have a full camera serialization. jerome 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 2, 2015 Share Posted March 2, 2015 I always validate your PR quickly Quote Link to comment Share on other sites More sharing options...
benoit-1842 Posted March 2, 2015 Share Posted March 2, 2015 Nice work !!!!!! Is it possible to load one of my own scene. Because when I use the load option I just got a spinning circle........ Nice work again, Benoit Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 3, 2015 Author Share Posted March 3, 2015 @RaananW: Thanks! @benoit-1842: it's still work in progress and the question that I asked was just about that loading problem. Thanks to RaananW it should be fixed very soon (as soon as I have time to update to the new 2.1 version of Babylon - maybe tonight ) Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 3, 2015 Share Posted March 3, 2015 @DK - You know they will just keep on coming @Benoit - Do you mean scenes that were extracted using the serializer? or just a general scene? the never-ending spinning circle usually means that something went wrong suring the scene's loading. Check your console log, or maybe upload the scene here (if possible) and allow it to be debugged. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 3, 2015 Share Posted March 3, 2015 @ranaan: I hope so!!! Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 4, 2015 Author Share Posted March 4, 2015 @Deltakosh: when can I expect RanaanWs changes to be in the compiled (babylon.2.1-alpha.js) version? Otherwise I would have to compile myself... I guess? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 4, 2015 Share Posted March 4, 2015 It is already the case my dear:) Quote Link to comment Share on other sites More sharing options...
joshcamas Posted March 5, 2015 Share Posted March 5, 2015 This is awesome! Me, Dad72, and you are all making editors, lol!!Each one is designed for a different game, it looks like though. :3 DesignVibe 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 5, 2015 Share Posted March 5, 2015 Love this! I want to see tons of babylon.js editors out there! DesignVibe 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 5, 2015 Author Share Posted March 5, 2015 Sweet, gonna try it out tonight for sure. I let you guys know how it went Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 5, 2015 Author Share Posted March 5, 2015 Okay, I tried it out now and got only half of a success that I can report. It seems I can now serialize the scene including the camera (good job raanan!) but I am still having trouble loading it back. You can see the error here http://p215008.mittwaldserver.info/mapEditor/ when you just save and then load a scene. In the console it loads the serialized string but says: babylon.2.1-alpha.debug.js:7438 - Uncaught TypeError: Cannot read property 'position' of nullArcRotateCamera.prototype._getTargetPosition = function () { return this.target.position || this.target;};It seems that it has something to do with the target of the ArcRotateCamera. I couldn't find the target property in the serialized camera object when I looked for it. Could it be that this is a bug in the newly added code for the ArcRotateCamera serialization or any idea what else might go wrong here? Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 5, 2015 Share Posted March 5, 2015 (edited) Looks like the target is not set. I'll find the possible and push a fix later today.In the meantime try setting the target manually and see if it works and that this is the only problem. Edit - https://github.com/BabylonJS/Babylon.js/pull/425 , the target property in the ArcRotate camera types has a different name than the rest :-) should be fine now. If yo ucan paste the scene so I can test with the serialized scene it would be great. Edited March 5, 2015 by RaananW Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks alot, there you go (I hope I really copied the whole thing).scene.txt Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 5, 2015 Share Posted March 5, 2015 Ok, so the file loader was not ready for an ArcRotate camera fully (the target array was not set). The serializer didn't export the target too... I hope I found a fix, commited to the same PR. Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 7, 2015 Author Share Posted March 7, 2015 I still can't get it to work am I doing something else wrong here? I made a playground: http://www.babylonjs-playground.com/#1HZD7X I want to serialize the scene then after 3 seconds reload it... that should be okay, no? Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 7, 2015 Share Posted March 7, 2015 That looks like my error.I am sending tags as an array and not as a string.Sorry!Here is the fix (for now) - http://www.babylonjs-playground.com/#1HZD7X#1 just setting the tags to null (line 32) and it works. I will push a fix in a few minutes. Other than that it looks like it's working :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.