SceneNode.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Node from '../core/Node.js';
  2. import { addNodeClass } from '../core/Node.js';
  3. import { nodeImmutable } from '../shadernode/ShaderNode.js';
  4. import { reference } from './ReferenceNode.js';
  5. class SceneNode extends Node {
  6. constructor( scope = SceneNode.BACKGROUND_BLURRINESS, scene = null ) {
  7. super();
  8. this.scope = scope;
  9. this.scene = scene;
  10. }
  11. setup( builder ) {
  12. const scope = this.scope;
  13. const scene = this.scene !== null ? this.scene : builder.scene;
  14. let output;
  15. if ( scope === SceneNode.BACKGROUND_BLURRINESS ) {
  16. output = reference( 'backgroundBlurriness', 'float', scene );
  17. } else if ( scope === SceneNode.BACKGROUND_INTENSITY ) {
  18. output = reference( 'backgroundIntensity', 'float', scene );
  19. } else {
  20. console.error( 'THREE.SceneNode: Unknown scope:', scope );
  21. }
  22. return output;
  23. }
  24. }
  25. SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness';
  26. SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity';
  27. export default SceneNode;
  28. export const backgroundBlurriness = nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
  29. export const backgroundIntensity = nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
  30. addNodeClass( 'SceneNode', SceneNode );