LightsNode.js 593 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Node from '../core/Node.js';
  2. import LightNode from './LightNode.js';
  3. class LightsNode extends Node {
  4. constructor( lightNodes = [] ) {
  5. super( 'vec3' );
  6. this.lightNodes = lightNodes;
  7. }
  8. generate( builder ) {
  9. const lightNodes = this.lightNodes;
  10. for ( const lightNode of lightNodes ) {
  11. lightNode.build( builder );
  12. }
  13. return 'vec3( 0.0 )';
  14. }
  15. static fromLights( lights ) {
  16. const lightNodes = [];
  17. for ( const light of lights ) {
  18. lightNodes.push( new LightNode( light ) );
  19. }
  20. return new LightsNode( lightNodes );
  21. }
  22. }
  23. export default LightsNode;