New Module System

Modules

Modules are awesome. Modules can do anything you can do with plain THREE.Mesh, but much cleaner and in a flexible way.

Step 1. Manager

Manager is used to add and get dependencies. Let’s say my module A knows that there is module B that will use its API. Then module A leaves a dependency in the manager object for module B.

Module B can also provide a behavior like "What to do if component C overwrites component A's dependency" with the manager.update() method.

manager() in RenderingModule

Step 2. Integrate

Modules can have the integrate() method. It is automatically executed when the module is applied to a component or App. It is commonly used to add some functionality to a defined component.

Example of integrate function in SceneModule

Step 3. Bridges

Bridges allow developers to make a component-specific API. Each component can extend its flexibility by providing parts of the code that will be processed with "bridges."

Let’s say I have a material object. I can pass this material to modules — they can change its color, make it semi-transparent, or create and overwrite with a new one.

A part of WHS.Box code

The function .applyBridge() defines that the current object should go through the following bridge.

A part of TextureModule code

The bridge function accepts two parameters: the input object and module’s scope.

The bridge function’s scope is a component as in integrate().

Conclusion

You can start exploring other modules in WhitestormJS on GitHub, we will continue adding modules (probably to the README). Currently, you can use two modules that will help you in development—physics module + built-in modules.

Node.js application metrics sent directly to any statsd-compliant system. Get N|Solid