-
-
Notifications
You must be signed in to change notification settings - Fork 391
v3.x.x
Alexander Buzin edited this page Jan 22, 2019
·
9 revisions
(WIP)
Components (for inheritance)
New!!!
-
ExampleBox
-
#build()
- Create.native
-
#bridge(bridgeName, data)
(formerly applyBridge) -
.native
- THREE.Mesh get geometry
set geometry
get material
set material
-
class ExampleBox extends Component {
public native: THREE.Mesh;
public build() { // this sets .native
return mesh;
}
public bridge(string bridgeName, any data) {
// Some work with modules
}
get test() {
return this.bridge('testBridge', 2); // 2 + 3 = 5
}
}
Modules (for composition)
-
ExampleModule
.name
#setup(Component component)
-
bridges = {}
For communication with components
class ExampleModule {
public setup(component, {dependencies, manager, warn}) {
console.log(component.test); // 5. Because bridges are set immediately
// Way 1. (not recommended, for advanced usage)
// "dependencies" is just an object accessible for all modules in a component
if ('prevTest' in dependencies) {
dependencies.nextTest = dependencies.prevTest + 10; // (will be seen by next module in queue)
} else {
throw new Error('prevTest was not found. Please use PrevExampleModule!');
}
// Way 2. (recommended, simplified)
// module is a set of helpful utils
warn('prevTest', 'prevTest was not found. Please use PrevExampleModule!');
manager.nextTest = manager.prevTest + 10;
}
bridges = {
testBridge(input) {
return input + 3;
}
}
}