Jump to content

can't fix manifest type file error


akashraihan05
 Share

Recommended Posts

As server i am using babyloninnode but i can not load any external .babylon file. For two weeks, I tried  a lot  to render any external babylon file on any browser but I can not .

so anyone can help to solve this problem?

server.js

Screenshot_3.png

<!DOCTYPE html>
<html>
<head>
    <title>BabylonJS - Espilit demo</title>
    <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script>
    <script src="http://www.babylonjs.com/Oimo.js"></script>
    <script src="http://www.babylonjs.com/babylon.js"></script>
  
    <style>
        html, body {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }

        #renderCanvas {
            width: 100%;
            height: 100%;
            touch-action: none;
            -ms-touch-action: none;
        }

        #lcContainer {
            position: absolute;
            top: 30px;
            left: 30px;
            color: gold;
        }
    </style>
</head>
<body>
    <canvas id="renderCanvas"></canvas>
    <div id="lcContainer">
        <ul id="listColliders">
        </ul>
    </div>
	<script>
	var engine;
var canvas;
var scene;

document.addEventListener("DOMContentLoaded", startGame, false);
function startGame() {
    if (BABYLON.Engine.isSupported()) {
        canvas = document.getElementById("renderCanvas");
        engine = new BABYLON.Engine(canvas, false);

        BABYLON.SceneLoader.Load("Espilit/", "Espilit.babylon", engine, function (loadedScene) {
            scene = loadedScene;
   
            // Wait for textures and shaders to be ready
            scene.executeWhenReady(function () {
                // Attach camera to canvas inputs
                scene.activeCamera.attachControl(canvas);
                
                // Once the scene is loaded, just register a render loop to render it
                engine.runRenderLoop(function () {
                    scene.render();
                });
            });
        }, function (progress) {
            // To do: give progress feedback to user
        });
    }
}
	</script>
	
	
	
</body>
</html>

 

Link to comment
Share on other sites

Yes, I also have the impression that since some week, I notice that if I load a babylon file and I do not use a manifest file, the file is still cached, because if I modify the file and I reload it, it shows me the previous version of the babylon file.
I am obliged to empty the caches of the browser or use: file.babylon?' + (new Date()).getTime() 

Can be a bug too.

Link to comment
Share on other sites

It's then not a manifest error. Indeed, as specified before, you just need to set the boolean enableOfflineSupport to false and babylon.js will stop trying to do a XHR to test for the availbility of a .manifest file. 

Your error seems to be linked to your node.js configuration. Have you set correctly the MIME type for .babylon file?

David

Link to comment
Share on other sites

 

this my node.js code

var http = require('http'),
    path = require('path'),
    fs = require('fs'),

extensions = {                                                          //<--specify MIME file types.
    ".html" : "text/html",
    ".css" : "text/css",
    ".js" : "application/javascript",
    ".png" : "image/png",
    ".gif" : "image/gif",
    ".jpg" : "image/jpeg",
    ".babylon" : "application/babylon"                                   //<--- ADD .babylon MIME type.
};

//helper function handles file verification
function getFile(filePath,res,page404,mimeType){
    //does the requested file exist?
    fs.exists(filePath,function(exists){
        //if it does...
        if(exists){
            //read file and send response.
            fs.readFile(filePath,function(err,contents){
                if(!err){
                    res.writeHead(200,{
                        "Content-type" : mimeType,                      //<-- SET dynamic MIME TYPE.
                        "Content-Length" : contents.length
                    });
                    res.end(contents);
                }
            });
        }
    });
};

//handler for HTTP requests
function requestHandler(req, res) {
    var fileName = path.basename(req.url) || 'index.html',
        ext = path.extname(fileName),
        localFolder = __dirname + '/public/',
        page404 = localFolder + '404.html';

    if(!extensions[ext]){                                                //<-- CHECK file MIME type.
        //for now just send a 404 and a short message
        res.writeHead(404, {'Content-Type': 'text/html'});
        res.end("Not Found");
    };

    getFile((localFolder + fileName),res,page404,extensions[ext]);
};

http.createServer(requestHandler).listen(8008);

console.log('Node server is running on http://localhost:8008');

 

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