Félix Flores

Problem loading babylon file from host

Recommended Posts

Hello

I want to load a scene generated from blender, the generated file is .babylon, in my local, I have no a problem loadding the sene but in the host I can´t, in the console I have the next problem:

Uncaught Error: Error status: 404 - Unable to load models/scene1/landScape.babylon at XMLHttpRequest.e.onreadystatechange (babylon.custom.js:3)

Searching in google I se that I need to add mime types but I don´t know how.

my html code is:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Entorno Mexicano</title>
        <link href="css/style.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    </head>
    <body>
        <canvas id="renderCanvas"></canvas>
        <!-- Carga de los js que se utilizan -->
        <!-- Babylon.js -->
        <script src="js/babylon.custom.js"></script>
        <script src="js/jquery-3.1.0.min.js"></script>
        <!-- codigo js personalizado -->
        <script src="js/main.js"></script>
    </body>
</html>

and my js file is:

if (BABYLON.Engine.isSupported()) {
        canvas = document.getElementById("renderCanvas");
        engine = new BABYLON.Engine(canvas, true);

        BABYLON.SceneLoader.Load("models/scene1/", "landScape.babylon", engine, function (newScene) {
            scene = newScene;
            
            // Wait for textures and shaders to be ready
            scene.executeWhenReady(function () {

                // Once the scene is loaded, just register a render loop to render it
                engine.runRenderLoop(function() {
                    scene.render();
                });
                
                // Funcion para cuando se redimensiona la ventana
                $(window).on('resize', function() {
                    engine.resize();
                });
            });
        }, function (progress) {
            $(".textoCarga").text( ((progress.loaded/progress.total)*100).toFixed(2) + "%");
        });
    }

Any idea why I can do

Thanks an regards 

Share this post


Link to post
Share on other sites

@Félix Flores 

404 error means "file not found" :) 
check your file path in the browser URL bar.

if you can see the file at "yourHost.com/models/scene1/landScape.babylon"
try writing " ./models/scene1/"  in your sceneLoader call.

if you can't see your file in the browser, it's the wrong path :P 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.