Scene.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
  13. __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
  14. }
  15. }
  16. Scene.prototype = Object.assign( Object.create( Object3D.prototype ), {
  17. constructor: Scene,
  18. isScene: true,
  19. copy: function ( source, recursive ) {
  20. Object3D.prototype.copy.call( this, source, recursive );
  21. if ( source.background !== null ) this.background = source.background.clone();
  22. if ( source.fog !== null ) this.fog = source.fog.clone();
  23. if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
  24. this.autoUpdate = source.autoUpdate;
  25. this.matrixAutoUpdate = source.matrixAutoUpdate;
  26. return this;
  27. },
  28. toJSON: function ( meta ) {
  29. var data = Object3D.prototype.toJSON.call( this, meta );
  30. if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
  31. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  32. return data;
  33. },
  34. dispose: function () {
  35. this.dispatchEvent( { type: 'dispose' } );
  36. }
  37. } );
  38. export { Scene };
粤ICP备19079148号