Scene.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Object3D } from '../core/Object3D.js';
  2. class Scene extends Object3D {
  3. constructor() {
  4. super();
  5. this.type = 'Scene';
  6. this.background = null;
  7. this.environment = null;
  8. this.fog = null;
  9. this.overrideMaterial = null;
  10. this.autoUpdate = true; // checked by the renderer
  11. if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
  12. __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
  13. }
  14. }
  15. copy( source, recursive ) {
  16. super.copy( source, recursive );
  17. if ( source.background !== null ) this.background = source.background.clone();
  18. if ( source.environment !== null ) this.environment = source.environment.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( meta ) {
  26. const data = super.toJSON( meta );
  27. if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
  28. if ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );
  29. if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
  30. return data;
  31. }
  32. }
  33. Scene.prototype.isScene = true;
  34. export { Scene };
粤ICP备19079148号