Scene.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Object3D } from '../core/Object3D';
  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.create( Object3D.prototype );
  14. Scene.prototype.constructor = Scene;
  15. Scene.prototype.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. Scene.prototype.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. export { Scene };
粤ICP备19079148号