Hi All,
I’m new to BabylonJS. MY code below is based off the babylon js tutorials.
I’ve created a scene in blender 2.8 and exported into .babylon format, using the blendr2babylon exporter 6.2.0
I’m trying to get babylon to make use of the camera and lights that i created in blendr.
I’ve managed to load my .babylon scene file using LoadAssetContainer.
U will notice i create an Arc camera first, because that was part of tutorial code. The only way i could find to make use of the Blendr camera was to explicitly set the active camera, but i realize it loses the “Arc” capabilty, and it results in a fixed camera which doesn’t move.
scene.activeCamera = container.cameras[0];
Questions:
-
Could someone show me how to make proper use of Blendr Camera thorugh code or settings? My camera type in Blendr is Universal which i thought would automatically be able to “move” around in babylon using the keys.
-
Could someone show me how to make use of Blendr lights? I have a “Sun” light in blendr which i understand is supposed to be converted to “directional” in babylon, but when rendering the babylon scene, its obvious my “sun” is not there, as its darkish and the trees don’t cast shadows?
Kevin
var canvas = document.getElementById(“renderCanvas”); // Get the canvas element
var engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D enginevar createScene = function () {
// Create the scene space var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("BabylonCamera", 0,0,5, new BABYLON.Vector3(0,0,0), scene); camera.attachControl(canvas, true); // Add lights to the scene var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene); var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 6, -1), scene);
BABYLON.SceneLoader.LoadAssetContainer(“assets/”, “NatureScene.babylon”, scene, function (container) {
var meshes = container.meshes;
var materials = container.materials;if(container.cameras[0]){ scene.removeCamera(camera) scene.activeCamera = container.cameras[0]; } // Adds all elements to the scene container.addAllToScene();
});
return scene;
};
/******* End of the create scene function ******/var scene = createScene(); //Call the createScene function
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function () {
scene.render();});