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 by type:

getArray(type) {
return this.list.reduce((result, light) => {
result = result.concat(light[type]);
return result;
}, []);
}

This will be useful when we use uniform arrays later on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.193.172