DirectionalLightNode.js 896 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import AnalyticLightNode from './AnalyticLightNode.js';
  2. import { lightTargetDirection } from './LightNode.js';
  3. import { addLightNode } from './LightsNode.js';
  4. import { addNodeClass } from '../core/Node.js';
  5. import { DirectionalLight } from 'three';
  6. class DirectionalLightNode extends AnalyticLightNode {
  7. constructor( light = null ) {
  8. super( light );
  9. }
  10. setup( builder ) {
  11. super.setup( builder );
  12. const lightingModel = builder.context.lightingModel;
  13. const lightColor = this.colorNode;
  14. const lightDirection = lightTargetDirection( this.light );
  15. const reflectedLight = builder.context.reflectedLight;
  16. lightingModel.direct( {
  17. lightDirection,
  18. lightColor,
  19. reflectedLight
  20. }, builder.stack, builder );
  21. }
  22. }
  23. export default DirectionalLightNode;
  24. addNodeClass( 'DirectionalLightNode', DirectionalLightNode );
  25. addLightNode( DirectionalLight, DirectionalLightNode );