Jump to content

Skybox not shown in a scene loaded from a babylon file(exported from Blender)


AB95
 Share

Recommended Posts

Hi everybody,

I am very new to both Blender and Babylon. Basically I am trying to load a scene exported from Blender and create a skybox afterward, the scene is nothing more than a default blender scene(the one consists of a box, camera and light, I load this scene just to make sure I hadn't added or modified anything in the scene that may leads to other issues once I export the scene into babylon file). I try to create a skybox after loading the scene, using code below:

===============================================

var canvas;
var engine;
var scene;

function initScene() {
  canvas = document.getElementById("renderCanvas");
  engine = new BABYLON.Engine(canvas, true);
  scene = new BABYLON.Scene(engine);

BABYLON.SceneLoader.Load("babylon/","testScene.babylon",engine,function(newScene){

    newScene.executeWhenReady(function(){
      newScene.activeCamera.attachControl(canvas,false);

      var ground = BABYLON.Mesh.CreateGround("ground", 10, 10, 2, newScene);
      var skybox = BABYLON.Mesh.CreateBox("skyBox",1000.0,newScene);
      var skyboxMaterial = new BABYLON.StandardMaterial("skyBox",newScene);
      skyboxMaterial.backFaceCulling = false;
      skybox.infiniteDistance = true;
      skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("images/skybox/cloudSkyBox/DaySkybox", newScene);
      skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
      skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
      skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
      skyboxMaterial.disableLighting = true;
      skybox.material = skyboxMaterial;


      engine.runRenderLoop(function(){
        newScene.render();
      });

  });

},function(progress){});
}

function initBB(){
  if (BABYLON.Engine.isSupported()){
    initScene();
  }else{
    console.log("not support BB");
  }
}

document.addEventListener("DOMContentLoaded",initBB,false);
document.addEventListener("resize",function(){
  engine.resize();
});

===============================================

The blender scene "newScene" is loaded(I can see the box, a directional light of the blender default scene, I can use the free camera preset in blender scene), the ground mesh added into the newScene can be seen as well, but the skybox is not shown!

There is no error message shown on the browser console, I had tried to google for similar problem but couldn't find the solution... I am not sure if I set up the blender scene wrongly before I export or there is other factor that cause this issue. Any help would be greatly appreciated!

TestProject.zip

Link to comment
Share on other sites

After some trial and error, I figured it out.

I did not set the renderingGroupId of each of the meshes in scene properly, after setting them properly, I am able to see all of my meshes(including skybox).

also, I did not set up my free camera in blender properly which its clipping value is set too high. 

Feel good to figure out the problem!

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...