Jump to content

Loader not detected when loading scene from data


Numa
 Share

Recommended Posts

Hi there, 

If you try to use one of the loaders (for .obj files for instance) and you are loading your scene from a data string, not a file, babylon will use the default load function and fail.

SceneLoader._getPluginForFilename = function (sceneFilename) {
            var dotPosition = sceneFilename.lastIndexOf(".");
            var queryStringPosition = sceneFilename.indexOf("?");
            if (queryStringPosition === -1) {
                queryStringPosition = sceneFilename.length;
            }
            var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
            for (var index = 0; index < this._registeredPlugins.length; index++) {
                var plugin = this._registeredPlugins[index];
                if (plugin.extensions.indexOf(extension) !== -1) {
                    return plugin;
                }
            }
            return this._registeredPlugins[0];
        };

It can't find the extension of course, as the fileName variable contains the scene data.

In 2.3 this use to work accidentally because the function would return _registeredPlugins[this._registeredPlugins.length - 1], which if you had an extra loader registered wold return it.

How do you guys want to go about fixing that one? optional Extension parameter? LoadFromData overload?

Thanks

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