Append/Import OBJ model from memory or input file

Hi all,

I am working in a model preview, where the user can select a model (through a html input file component) and it loads the preview before uploading it to a server.

Reading the documentation, I got that I can read from a string base64, a regular string or a File object.

To the first 2 options (base64 string or regular string), it is leading to a error as you can see through the link below:

Edit: I noticed that on some browsers it doesn’t load properly to show the current error

Error: too much recursion

In fact, I have a few models that are quite big (not complex, just big).

The the third option, it is not well documented, but we can load directly from files only if we set the rootUrl as file: protocol (the documentation does not explains that).

You can take the code below, as file being an instance of File

SceneLoader.AppendAsync('file:', file, scene, null, '.obj');

In that case, is it possible to update the documentation?

For instance:

Even though, for instance, the documentation of SceneLoader.Append states that sceneFilename can be a File object, It does not state that rootUrl must contain file:

a string that defines the name of the scene file or starts with “data:” following by the stringified version of the scene or a File object (default: empty string)

Also, I only noticed that it was possible looking into the code. Thus, It seems that on version 5.0 it was fixed to work without file: but it does not on 4.2.

1 Like

Thanks a lot for the feedback, adding @PirateJC for the update :slight_smile:

1 Like

thanks for flagging this @gabrielheming!

How would you feel about making the proposed change and submitting a PR for the doc update?

You can add me as a reviewer.

I can do that. Also, I am trying to find a solution to the recursion problem.

1 Like