0.1.0 • Published 9 years ago
whs-module-loader v0.1.0
whs-module-loader - Loading progress for components, textures, ...
Usage
constructor(expecting = [])
expecting-Arrayof keys[String]that will be added to.expecting
.expect(key) and .resolve(key) - Use for callbacks
const loader = new LoaderModule();
const app = new WHS.App([
// ...
])''
loader.expect('sphere1');
const sphere = new WHS.Sphere({
// ...
});
sphere.addTo(app).then(() => loader.resolve('sphere1'));.promise(key, promise) - Use for promises
No
.expect()required!
loader.promise('sphere1', sphere.addTo(app));.getProgress() - Get loading progress
Returns value from 0 to 1, where 1 means completed.
Can be transformed into percents simply muliplying by 100:
console.log(`Current percent is: ${loader.getProgress() * 100}`);Events
.on('step', [Callback])
loader.on('step', key => {
console.log(key);
});.on('complete', [Callback])
loader.on('complete', () => {
alert('completed!');
});Fires when .resolve() was called and .expecting is empty.
Attributes
.expecting
console.log(loader.expecting);
// Array of keys that aren't resolved yet.This attribute represents an
Arrayof keys[String]values that are not resolved yet.
.resolved
console.log(loader.resolved);
// Array of keys that have been resolved.
Arrayof resolved keys.
0.1.0
9 years ago