How to load directly from a File object?

I am trying to load an STL file from a File object obtained from the .files property of an <input type="file"> tag. The problem is that the data is not loaded from the file and the loader issues an HTTP request for a file with the same name.

Looking at the sceneLoader.ts source code it seems that what I want is the directLoad but the check (around line 393) looks for "data:" in the file name (this is obviously not the case for an File object).

I suppose I have two questions:

  1. Is it right to pass a File object and expecting that data will get loaded from there without network access?

  2. Should I just extract the File data into a data: URL and pass it as the file name?

As File is technically a blob, you could create a URL for it using URL.createObjectURL(fileObj); and use this URL with the scene loader. Would that be an acceptable solution?

Yes, that would work, thank you.

My question was more of a API design nature: why take a File and use it just for its name instead of calling createObjectURL on it or use the data directly? Even simpler: why does the API take a File and doesn’t do with it the expected thing? It is a feature I don’t understand? It is a bug?

You should also have a look at out FilesInput class which might help in this regard.