Utility to load different types of files (and also some WebRTC related stuff, see below)
- Source:
Methods
(static) load()
Load a text file and return it's contents in the callback.
- Source:
(static) loadAssets(paths, callback, progressCallback)
Load multiple assets of type:
- text, including GLSL code
- JSON, including model, geometry, scene. etc...
- image (jpg, gif, png), video (mp4, webm)
- webcam (it will initiate the webcam, ask user for permisions, and return a ready to use stream)
Each file will be availabke from the asset object passed to the callback
under it's name, ex. assets['normal2color.glsl']
It's also possible ot specify an alias. Instead of a String,
use an Array, where [0] is the path, and [1] is the alias.
Parameters:
Name | Type | Description |
---|---|---|
paths |
object | list of file paths (with optinal aliases) to load, as in example below. |
callback |
function | called when all the files are loaded. The assets are passed as argument as in the example below. |
progressCallback |
function | called each time when on of the files is loaded |
- Source:
Example
SQR.Loader.loadAssets([
['some-image.jpg', 'image'],
['some-video.mp4', 'video'],
['a-shader.glsl', 'shader'],
'another-shader.glsl',
'webcam' // special case, but useful :)
], function(assets) {
var image = assets['image'];
});
(static) loadImage()
Load an image file and return it's contents in the callback as Image object.
- Source:
(static) loadJSON()
Load a JSON file and return it's contents in the callback. This function will parse the JSON data for you and return an Object.
- Source:
(static) loadVideo()
Preload a video so that it can be used as a texture (typically)
- Source:
(static) loadWebcam()
Initiate user stream (webcam).
- Source: