Scene.js 1.5 KB

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