Scene.js 1.6 KB

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