Scene.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. copy: function ( source, recursive ) {
  16. Object3D.prototype.copy.call( this, source, recursive );
  17. if ( source.background !== null ) this.background = source.background.clone();
  18. if ( source.fog !== null ) this.fog = source.fog.clone();
  19. if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
  20. this.autoUpdate = source.autoUpdate;
  21. this.matrixAutoUpdate = source.matrixAutoUpdate;
  22. return this;
  23. },
  24. toJSON: function ( meta ) {
  25. var data = Object3D.prototype.toJSON.call( this, meta );
  26. if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
  27. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  28. return data;
  29. },
  30. dispose: function () {
  31. this.dispatchEvent( { type: 'dispose' } );
  32. }
  33. } );
  34. export { Scene };