forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
52 lines (49 loc) · 2.09 KB
/
handler.js
File metadata and controls
52 lines (49 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @interface
* @name ResourceHandler
* @description Interface for ResourceHandlers used by {@link ResourceLoader}.
*/
class ResourceHandler {
/**
* @function
* @name ResourceHandler#load
* @description Load a resource from a remote URL. When loaded (or failed),
* use the callback to return an the raw resource data (or error).
* @param {string|object} url - Either the URL of the resource to load or a structure containing the
* load and original URL.
* @param {string} [url.load] - The URL to be used for loading the resource.
* @param {string} [url.original] - The original URL to be used for identifying the resource
* format. This is necessary when loading, for example from blob.
* @param {callbacks.ResourceHandler} callback - The callback used when the resource is loaded or an error occurs.
* @param {Asset} [asset] - Optional asset that is passed by ResourceLoader.
*/
load(url, callback, asset) {
throw new Error('not implemented');
}
/**
* @function
* @name ResourceHandler#open
* @description Convert raw resource data into a resource instance. E.g. Take 3D model format JSON and return a {@link Model}.
* @param {string} url - The URL of the resource to open.
* @param {*} data - The raw resource data passed by callback from {@link ResourceHandler#load}.
* @param {Asset} [asset] - Optional asset that is passed by ResourceLoader.
* @returns {*} The parsed resource data.
*/
/* eslint-disable jsdoc/require-returns-check */
open(url, data, asset) {
throw new Error('not implemented');
}
/* eslint-enable jsdoc/require-returns-check */
/**
* @function
* @name ResourceHandler#[patch]
* @description Optional function to perform any operations on a resource, that requires a dependency on its asset data
* or any other asset data.
* @param {Asset} asset - The asset to patch.
* @param {AssetRegistry} assets - The asset registry.
*/
patch(asset, assets) {
// optional function
}
}
export { ResourceHandler };