0

I made a scene in Blender that I exported into a .babylon, and now I am importing it into the game. The map is 351KB, and I am loading it into the game like this:

var BABYLON;
var canvas = document.getElementById('gamecanvas');
var engine = new BABYLON.Engine(canvas, true);
var scene = new BABYLON.Scene(engine);
var light = new BABYLON.PointLight('light', new BABYLON.Vector3(0,0,10), scene);
var player = new BABYLON.FreeCamera('player', new BABYLON.Vector3(1,1,1), scene); //IMPORTANT LINE
var player_height = 2;
var player_speed = 1;
var player_inertia = 0.9;
var mouse_position = new BABYLON.Vector2(mouse_position.x, mouse_position.y);

function INIT_GAME(){

    engine.runRenderLoop(function(){ //IMPORTANT LINE
        scene.render();
    });

    canvas.height = window.innerHeight;
    canvas.width = window.innerWidth;
    canvas.requestPointerLock = canvas.requestPointerLock || canvas.mozRequestPointerLock;
    canvas.requestPointerLock();

    scene.enablePhysics(); //IMPORTANT LINE
    scene.setGravity(new BABYLON.Vector3(0, -10, 0)); //IMPORTANT LINE

    player.attachControl(canvas, true); //IMPORTANT LINE
    player.ellipsoid = new BABYLON.Vector3(1, player_height, 1);
    player.checkCollisions = true;
    player.applyGravity = true;
    player.keysUp = [87];
    player.keysDown = [83];
    player.keysLeft = [65];
    player.keysRight = [68];
    player.inertia = player_inertia;
    player.speed = player_speed;

    window.addEventListener('resize', function(){
        engine.resize();
    });

    BABYLON.SceneLoader.Load('Scenes', 'zombie_map.babylon', engine); //IMPORTANT LINE
}

I've attempted to narrow everything down to what you should need to look at, but I left it all there just in case there was something I missed. (INIT_GAME is loaded on page load). My problem is, I think the scene is loading, but it just gives me a strange loading icon, which I presume is just Babylon trying to load in the scene I passed it. My questions are:

  • Am I loading everything in properly?
  • What is the proper format to import a .babylon scene?
  • Is the size of the map too big for the browser, and if so, how can I compress it?

I can provide a link to the site if you need to see the results head-on. Let me know, thanks!

JAAulde
  • 19,250
  • 5
  • 52
  • 63
Taylor Brown
  • 89
  • 1
  • 1
  • 9

1 Answers1

1

I think the solution is very simple.

Add a slash after your rootURL.

So replace

BABYLON.SceneLoader.Load('Scenes', 'zombie_map.babylon', engine); //IMPORTANT LINE

with

BABYLON.SceneLoader.Load('Scenes/', 'zombie_map.babylon', engine); //IMPORTANT LINE

Try this and let me know how it goes.

Jeremy Hanlon
  • 317
  • 1
  • 3