Zahir Junejo Posted May 31, 2016 Share Posted May 31, 2016 I tried to export a .babylon model of lamborghini avantador which i imported from clara.io, this was how it looked in clara.io: https://d3ijcvgxwtkjmf.cloudfront.net/8a268a124e80c43c3c4bf291241aab70 And this is how it looks like in my project: This is the code <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script> <script src="http://www.babylonjs.com/cannon.js"></script> <script src="http://www.babylonjs.com/oimo.js"></script> <script src="http://www.babylonjs.com/babylon.js"></script> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; } #renderCanvas { width: 100%; height: 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); //Adding a light var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene); //Adding an Arc Rotate Camera var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera.attachControl(canvas, false); camera.setTarget(BABYLON.Vector3.Zero()); /* // The first parameter can be used to specify which mesh to import. Here we import all meshes BABYLON.SceneLoader.ImportMesh("", "scenes/nissan-gt-r-nismo-babylon/", "nissan-gt-r-nismo.babylon", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh camera.target = newMeshes[0].position; }); */ /*----------------------------------------------------------------------------------------------------------*/ BABYLON.SceneLoader.Load("scenes/av/", "lamborghini-aventador-pbribl.babylon", engine, function (newScene) { // Wait for textures and shaders to be ready newScene.executeWhenReady(function () { // Attach camera to canvas inputs newScene.activeCamera.attachControl(canvas); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { newScene.render(); }); }); }, function (progress) { // To do: give progress feedback to user }); /*------------------------------------------------------------------------------------------------------------*/ // Move the light with the camera scene.registerBeforeRender(function () { light.position = camera.position; }); return scene; } var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); }); </script> </body> </html> Also is there a difference between Load and import mesh method? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 31, 2016 Share Posted May 31, 2016 you can make it in PG : http://www.babylonjs-playground.com/ we can help you faster but if you wanna export from babylon side i think it is possible but is that useful? Quote Link to comment Share on other sites More sharing options...
Zahir Junejo Posted May 31, 2016 Author Share Posted May 31, 2016 This file is in .babylon format. But problem is babylon.js does not seem to render its own file format correctly. Plus how do i get it to playground and how will i upload the .babylon files? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted June 1, 2016 Share Posted June 1, 2016 1 of many possible ways: http://doc.babylonjs.com/classes/2.4/SceneLoader#static-load-rooturl-scenefilename-engine-onsuccess-progresscallback-onerror-rarr-void BABYLON.SceneLoader.Load("URL to Website", "lamborghini-aventador-pbribl.babylon", engine, function (newScene) { Quote Link to comment Share on other sites More sharing options...
ozRocker Posted June 1, 2016 Share Posted June 1, 2016 4 hours ago, Zahir Junejo said: This file is in .babylon format. But problem is babylon.js does not seem to render its own file format correctly. Plus how do i get it to playground and how will i upload the .babylon files? Put this in your .htaccess to allow CORS Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS" Quote Link to comment Share on other sites More sharing options...
Nabroski Posted June 1, 2016 Share Posted June 1, 2016 Hello im new to babylon too, and still learning: this works for me:http://www.babylonjs-playground.com/#2AYKFO#0 Best 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.