Scene.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Object3D } from '../core/Object3D.js';
  2. /**
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. function Scene() {
  6. Object3D.call( this );
  7. this.type = 'Scene';
  8. this.background = null;
  9. this.fog = null;
  10. this.overrideMaterial = null;
  11. this.autoUpdate = true; // checked by the renderer
  12. }
  13. Scene.prototype = Object.assign( Object.create( Object3D.prototype ), {
  14. constructor: Scene,
  15. isScene: true,
  16. copy: function ( source, recursive ) {
  17. Object3D.prototype.copy.call( this, source, recursive );
  18. if ( source.background !== null ) this.background = source.background.clone();
  19. if ( source.fog !== null ) this.fog = source.fog.clone();
  20. if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
  21. this.autoUpdate = source.autoUpdate;
  22. this.matrixAutoUpdate = source.matrixAutoUpdate;
  23. return this;
  24. },
  25. toJSON: function ( meta ) {
  26. var data = Object3D.prototype.toJSON.call( this, meta );
  27. if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
  28. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  29. return data;
  30. },
  31. dispose: function () {
  32. this.dispatchEvent( { type: 'dispose' } );
  33. }
  34. } );
  35. export { Scene };