Jump to content

OBJ and BABYLON 3D Export


Zahir Junejo
 Share

Recommended Posts

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?

crappy_avantador.PNG

Link to comment
Share on other sites

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"

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...