AnalyticLightNode.js 633 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import LightingNode from './LightingNode.js';
  2. import { NodeUpdateType } from '../core/constants.js';
  3. import { uniform } from '../shadernode/ShaderNodeElements.js';
  4. import { Color } from 'three';
  5. class AnalyticLightNode extends LightingNode {
  6. constructor( light = null ) {
  7. super();
  8. this.updateType = NodeUpdateType.Object;
  9. this.light = light;
  10. this.colorNode = uniform( new Color() );
  11. }
  12. getHash( /*builder*/ ) {
  13. return this.light.uuid;
  14. }
  15. update( /*frame*/ ) {
  16. const { light } = this;
  17. this.colorNode.value.copy( light.color ).multiplyScalar( light.intensity );
  18. }
  19. }
  20. export default AnalyticLightNode;