Jump to content

Issue exporting animations and light from Blender


hit2501
 Share

Recommended Posts

Hello.
 
I have some problems when I want to export a simple scenario with an animation of a door closing and opening from Blender to Babylon, when I exported the door does not move, part of the door is distorted and the whole scene is with low light.
 
Someone can help me have successfully exported my scenario?
 
 
This is the code I use to import babylon:
 
<!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>Door</title>        <!-- Babylon.js -->        <script src="js/hand.minified-1.2.js"></script>        <script src="js/cannon.js"></script>        <script src="js/oimo.js"></script>        <script src="js/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);			//SKYBOX           	var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);			var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);			skyboxMaterial.backFaceCulling = false;			skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("skybox/skybox", scene);			skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;			skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);			skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);			skybox.material = skyboxMaterial;			//CAMERA        	var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);        	scene.activeCamera = camera;       		scene.activeCamera.attachControl(canvas);        	scene.activeCamera.keysUp.push(87); // W        	scene.activeCamera.keysLeft.push(65); // A         	scene.activeCamera.keysDown.push(83); // S         	scene.activeCamera.keysRight.push(68); // D                	camera.setTarget(BABYLON.Vector3.Zero());           	camera.attachControl(canvas, true);                        	var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);            light.intensity = 0.7;     		BABYLON.SceneLoader.ImportMesh("", "THE FOLDER WITH .BABYLON/", "MYBABYLONNAME.babylon", scene, function (newMeshes) {            	camera.target = newMeshes[0];        	});        	camera.speed = 1;            	camera.maxZ = -250;            	return scene;                	};                	var scene = createScene();        	engine.runRenderLoop(function () {            	scene.render();        	});           	window.addEventListener("resize", function () {            	engine.resize();        	});    </script></body></html>

Sorry if the solution is obvious, I have not much experience with babylon.

 

Thank you very much to all.

Link to comment
Share on other sites

First, probably a good idea to actively confirm the load worked.  Chasing ghosts is a fool's game. 

BABYLON.SceneLoader.ImportMesh("", "THE FOLDER WITH .BABYLON/", "MYBABYLONNAME.babylon", scene, function (newMeshes) {    console.log("was successful " + newMeshes.length);    if (newMeshes[0].getAnimatables()) console.log("n skeleton animations: " + newMeshes[0].getAnimatables().length);    if (newMeshes[0].animations) console.log("n position, rotation, & scaling animations " + newMeshes[0].animations.length);    camera.target = newMeshes[0];});

Skeletal animations DO not auto play from Blender.   Need something like:

var skeleton = scene.getSkeletonById(0); scene.beginAnimation(skeleton, 1, XXX, true, 1);
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...