importFiles
Imports a file or an array of files to be loaded to the scene. There are multiple ways that can be used to specify the source of the files.
importFiles(
files: string | string[] | Blob | Blob[] | FileList
): Promise<void>
Parameters
Description
Type
files
Defines the source files to be imported into the current scene.
Strings can be used to fetch URLs, Blobs can be used to pass down already available resources, and a FileList can be used to use local resources.
These are the file extensions that work out of the gate:
.zip (containing any of the following), .jpeg, .jpg, .png, .gif, .mp4, .json, .glb, .gltf, .fbx, .obj, .stl
string
| string[]
| Blob
| Blob[]
| FileList
Usage:
// String for URL, fetching happens inside the function
await modelApi.importFiles('URL');
// Blob, pre-fetched content
const blob = await fetch('URL').then(res => res.blob());
await modelApi.importFiles(blob);
// FilesList from <input type="file">
const input = document.querySelector('input[type="file"]');
input.addEventListener('change', async () => {
await modelApi.importFiles(input.files);
}
Last updated