Create a new ResourceLoader instance.
The application.
Add a ResourceHandler for a resource type. Handler should support at least load()
and open()
. Handlers can optionally support patch(asset, assets) to handle dependencies on
other assets.
The name of the resource type that the handler will be registered with. Can be:
An instance of a resource handler
supporting at least load()
and open()
.
Get a ResourceHandler for a resource type.
The name of the resource type that the handler is registered with.
The registered handler, or undefined if the requested handler is not registered.
Make a request for a resource from a remote URL. Parse the returned data using the handler for the specified type. When loaded and parsed, use the callback to return an instance of the resource.
The URL of the resource to load.
The type of resource expected.
The callback used when the resource is loaded or an error occurs. Passed (err, resource) where err is null if there are no errors.
Optional
asset: AssetOptional asset that is passed into handler.
Optional
options: { bundlesFilter?: BundlesFilterCallback; bundlesIgnore?: boolean }Additional options for loading.
Optional
bundlesFilter?: BundlesFilterCallbackA callback that will be called when loading an asset that is contained in any of the bundles. It provides an array of bundles and will ensure asset is loaded from bundle returned from a callback. By default smallest filesize bundle is choosen.
Optional
bundlesIgnore?: booleanIf set to true, then asset will not try to load from a bundle. Defaults to false.
Convert raw resource data into a resource instance. E.g. Take 3D model format JSON and return a Model.
The type of resource.
The raw resource data.
The parsed resource data.
Perform any operations on a resource, that requires a dependency on its asset data or any other asset data.
The asset to patch.
The asset registry.
Remove a ResourceHandler for a resource type.
The name of the type that the handler will be removed.
Load resource data, potentially from remote sources. Caches resource on load to prevent multiple requests. Add ResourceHandlers to handle different types of resources.