ModuleSystem
This class includes basic event system
.on(),.off(),.emit()methods are supported
ModuleSystem provides API for classes that will use Modules
.integrateModules(source[optional])
This method applies all modules from .modules collection. If source (should be a component) is provided - will replace .modules with source's one before executing modules.
This method is frequently used in core
.applyBridge(bridgeMap)
.applyBridge() makes component-specific API to work with modules. Let's say your bridgeMap is:
{
"geometry": new THREE.Geometry()
}
Then .applyBridge() will pass this value (THREE.Geometry) to first module if it has the following bridge in it's structure.
Helper
Remember that
bridgethat we talk about is a function that hasinputandoutput.bridgemodifies yourinputand returns you anoutput.
The following implementation allows modules access your geometry & material objects and modify them and is strongly recommended if you want to get maximum flexibility from WhitestormJS.
// ...
export default class BasicSphere extends MeshComponent {
build() {
const {geometry, material} = this.applyBridge({
geometry: new THREE.SphereGeometry(3, 16, 16),
material: new THREE.MeshBasicMaterial({color: 0xff0000})
})
return new THREE.Mesh(
geometry,
material
);
}
}
Returns object of modified values.
.applyModule(module, push = true)
.applyModule is also used in .integrateModules() function. It does exactly what its name says (applies module to component or app).
app.applyModule(new WHS.controls.OrbitModule()); // OrbitControls.
Returns module that was applied.
.module()
.module()is a piped version of.applyModule(). It returnsthis- app/component.
component
.module(new Module1())
.module(new Module2())
.module(new Module3())
Updated almost 9 years ago
