Scene.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Object3D } from '../core/Object3D.js';
  2. class Scene extends Object3D {
  3. constructor() {
  4. super();
  5. Object.defineProperty( this, 'isScene', { value: true } );
  6. this.type = 'Scene';
  7. this.background = null;
  8. this.environment = null;
  9. this.fog = null;
  10. this.overrideMaterial = null;
  11. this.autoUpdate = true; // checked by the renderer
  12. if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
  13. __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
  14. }
  15. }
  16. copy( source, recursive ) {
  17. super.copy( source, recursive );
  18. if ( source.background !== null ) this.background = source.background.clone();
  19. if ( source.environment !== null ) this.environment = source.environment.clone();
  20. if ( source.fog !== null ) this.fog = source.fog.clone();
  21. if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
  22. this.autoUpdate = source.autoUpdate;
  23. this.matrixAutoUpdate = source.matrixAutoUpdate;
  24. return this;
  25. }
  26. toJSON( meta ) {
  27. const data = super.toJSON( meta );
  28. if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
  29. if ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );
  30. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  31. return data;
  32. }
  33. }
  34. export { Scene };