Scene.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Object3D } from '../core/Object3D.js';
  2. class Scene extends Object3D {
  3. constructor() {
  4. super();
  5. this.isScene = true;
  6. this.type = 'Scene';
  7. this.background = null;
  8. this.environment = null;
  9. this.fog = null;
  10. this.backgroundBlurriness = 0;
  11. this.backgroundIntensity = 1;
  12. this.overrideMaterial = null;
  13. if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
  14. __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
  15. }
  16. }
  17. copy( source, recursive ) {
  18. super.copy( source, recursive );
  19. if ( source.background !== null ) this.background = source.background.clone();
  20. if ( source.environment !== null ) this.environment = source.environment.clone();
  21. if ( source.fog !== null ) this.fog = source.fog.clone();
  22. this.backgroundBlurriness = source.backgroundBlurriness;
  23. this.backgroundIntensity = source.backgroundIntensity;
  24. if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
  25. this.matrixAutoUpdate = source.matrixAutoUpdate;
  26. return this;
  27. }
  28. toJSON( meta ) {
  29. const data = super.toJSON( meta );
  30. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  31. if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness;
  32. if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity;
  33. return data;
  34. }
  35. }
  36. export { Scene };