Search the Community
Showing results for tags 'JSON export BABYLON'.
-
Hi all This question might sound naive but I am a newbie to Babylon I created a simple scene which I want to export to a .babylon file Where do I put the following code ? Do I need to run from a server? Where do I define the name of the exported file? var serializedScene = BABYLON.SceneSerializer.Serialize(scene); var strScene = JSON.stringify(serializedScene); Here is my code <script type="text/javascript"> var canvas = document.querySelector("#renderCanvas"); var engine = new BABYLON.Engine(canvas, true); // ------------------------------------------------------------- // Here begins a function that we will 'call' just after it's built var createScene = function () { var scene = new BABYLON.Scene(engine); scene.collisionsEnabled = true; scene.clearColor = new BABYLON.Color3(0, 1, 0); var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 25, -10), scene); camera.applyGravity =true; camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, false); camera.checkCollisions = true; var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); sphere.position.y = 1; var ground = BABYLON.Mesh.CreateGround("ground1", 26, 26, 2, scene); ground.gravity = new BABYLON.Vector3(0, -9.8, 0); return scene; }; // End of createScene function // ------------------------------------------------------------- // Now, call the createScene function that you just finished creating var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); // Watch for browser/canvas resize events window.addEventListener("resize", function () { engine.resize(); }); </script>