timetocode

Loading models in NullEngine

Recommended Posts

How does one load a *.obj in NullEngine?

const BABYLON = require('babylonjs')
require('babylonjs-loaders') // mutates something globally
global.XMLHttpRequest = require('xhr2').XMLHttpRequest

...

BABYLON.SceneLoader.LoadAssetContainer("./", "cubio.obj", scene, function (container) {
    console.log('CONTAINER', container)
    container.addAllToScene()
})

Error:

...\node_modules\xhr2\lib\xhr2.js:206
           throw new NetworkError("Unsupported protocol " + this._url.protocol);

Do I need to do something to xhr2 to teach it about obj?

Share this post


Link to post
Share on other sites

Looks like the answer is that './' and '/' are not valid paths for either babylon or xhr (not sure which). This syntax will work in the client, but not on the server.

I was able to get it working with the full path:

BABYLON.SceneLoader.LoadAssetContainer('http://localhost:8080/', 'cubio.obj', scene, (container) => { //etc...

 

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.