DirectionalLightNode.js 932 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. shadowMask: this.shadowMaskNode
  21. }, builder.stack, builder );
  22. }
  23. }
  24. export default DirectionalLightNode;
  25. addNodeClass( 'DirectionalLightNode', DirectionalLightNode );
  26. addLightNode( DirectionalLight, DirectionalLightNode );