API Reference

Class List

ContainerHandler

Loads files that contain multiple resources. For example glTF files can contain textures, models and animations. For glTF files, the asset options object can be used to pass load time callbacks for handling the various resources at different stages of loading. The table below lists the resource types and the corresponding supported process functions.

|---------------------------------------------------------------------|
|  resource   |  preprocess |   process   |processAsync | postprocess |
|-------------+-------------+-------------+-------------+-------------|
| global      |      x      |             |             |      x      |
| node        |      x      |      x      |             |      x      |
| light       |      x      |      x      |             |      x      |
| camera      |      x      |      x      |             |      x      |
| animation   |      x      |             |             |      x      |
| material    |      x      |      x      |             |      x      |
| image       |      x      |             |      x      |      x      |
| texture     |      x      |             |      x      |      x      |
| buffer      |      x      |             |      x      |      x      |
| bufferView  |      x      |             |      x      |      x      |
|---------------------------------------------------------------------|

For example, to receive a texture preprocess callback:

var containerAsset = new pc.Asset(filename, 'container', { url: url, filename: filename }, null, {
    texture: {
        preprocess(gltfTexture) { console.log("texture preprocess"); }
    },
});

Summary

Methods

load

Load a resource from a remote URL.

open

Convert raw resource data into a resource instance.

Details

Constructor

ContainerHandler(device, assets, defaultMaterial)

Parameters

deviceGraphicsDevice

The graphics device that will be rendering.

assetsAssetRegistry

The asset registry

defaultMaterialStandardMaterial

The shared default material that is used in any place that a material is not specified.

Methods

load(url, callback, [asset])

Load a resource from a remote URL. When loaded (or failed), use the callback to return an the raw resource data (or error).

Parameters

urlstring, object

Either the URL of the resource to load or a structure containing the load and original URL.

url.loadstring

The URL to be used for loading the resource.

url.originalstring

The original URL to be used for identifying the resource format. This is necessary when loading, for example from blob.

callbackcallbacks.ResourceHandler

The callback used when the resource is loaded or an error occurs.

assetAsset

Optional asset that is passed by ResourceLoader.

open(url, data, [asset])

Convert raw resource data into a resource instance. E.g. Take 3D model format JSON and return a Model.

Parameters

urlstring

The URL of the resource to open.

data*

The raw resource data passed by callback from ResourceHandler#load.

assetAsset

Optional asset that is passed by ResourceLoader.

Returns

*

The parsed resource data.