Capítulo 166 de 859

Chapter 166: FileLoader

Core Idea

A low level class for loading resources with the Fetch API, used internally by most loaders. It can also be used directly to load any file type that does not have a loader.

This loader supports caching. If you want to use it, add THREE.Cache.enabled = true; once to your application.

Key Concepts

Code Examples

const loader = new THREE.FileLoader();
const data = await loader.loadAsync( 'example.txt' );
  • What it demonstrates: Typical usage of FileLoader.

Reference Tables

Constructor

Signature
new FileLoader( manager : LoadingManager )

Properties

PropertyDescription
.mimeType : stringThe expected mime type. Valid values can be found here
`.responseType : 'arraybuffer''blob'

Methods

MethodDescription
.abort() : FileLoaderAborts ongoing fetch requests.
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and pass the loaded response to the onLoad() callback.
.setMimeType( value : string ) : FileLoaderSets the expected mime type of the loaded file.
`.setResponseType( value : 'arraybuffer''blob'

Key Takeaways

  1. FileLoader extends: Loader
  2. Most relevant properties: mimeType, responseType.
  3. Key methods: abort, load, setMimeType, setResponseType.

Connects To