DirectionalLightNode.js 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. construct( builder ) {
  11. super.construct( builder );
  12. const lightColor = this.colorNode;
  13. const lightDirection = lightTargetDirection( this.light );
  14. const lightingModelFunctionNode = builder.context.lightingModelNode;
  15. const reflectedLight = builder.context.reflectedLight;
  16. if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
  17. lightingModelFunctionNode.direct.call( {
  18. lightDirection,
  19. lightColor,
  20. reflectedLight
  21. }, builder );
  22. }
  23. }
  24. }
  25. export default DirectionalLightNode;
  26. addLightNode( DirectionalLight, DirectionalLightNode );
  27. addNodeClass( DirectionalLightNode );