As we progress through this book, we continue to refine our architecture where appropriate to reflect what we’ve learned. On this occasion, we will improve how we pass uniforms to our program and add support for handling a large number of uniforms to define multiple lights.
Architectural Updates
Adding Support for Light Objects
Let's cover these changes in detail. We have created a new JavaScript module, Lights.js, that has two objects:
- Light: Aggregates light properties (position, diffuse, specular, and so on) in a single entity.
- LightsManager: Contains the lights in our scene. This allows us to retrieve each light by index or name.
LightsManager also contains the getArray method to flatten the arrays of properties...