minerender 2.1.0-alpha.3 → 2.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6054,8 +6054,6 @@ var MapControls = class extends OrbitControls {
6054
6054
  var _Renderer = class _Renderer {
6055
6055
  constructor(options) {
6056
6056
  this._dirty = true;
6057
- this._animationTimer = void 0;
6058
- this._animationFrame = void 0;
6059
6057
  this._resizeListener = void 0;
6060
6058
  this._disposed = false;
6061
6059
  this._debugHelpers = [];
@@ -6065,7 +6063,7 @@ var _Renderer = class _Renderer {
6065
6063
  };
6066
6064
  this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6067
6065
  this._animationLoop = this.animate.bind(this);
6068
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6066
+ this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6069
6067
  this._scene = this.createScene();
6070
6068
  this._camera = this.createCamera();
6071
6069
  this._renderer = this.createRenderer();
@@ -6246,12 +6244,7 @@ var _Renderer = class _Renderer {
6246
6244
  stop() {
6247
6245
  if (this._disposed) return;
6248
6246
  this.renderer.setAnimationLoop(null);
6249
- if (this._animationTimer)
6250
- clearTimeout(this._animationTimer);
6251
- this._animationTimer = void 0;
6252
- if (this._animationFrame)
6253
- cancelAnimationFrame(this._animationFrame);
6254
- this._animationFrame = void 0;
6247
+ this._nextFrameTime = void 0;
6255
6248
  }
6256
6249
  /**
6257
6250
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -6295,21 +6288,26 @@ var _Renderer = class _Renderer {
6295
6288
  this.renderer.dispose();
6296
6289
  this.renderer.forceContextLoss();
6297
6290
  }
6298
- animate(t) {
6291
+ animate(t = performance.now()) {
6299
6292
  if (this._disposed) return;
6300
- if (this._stats) {
6301
- this._stats.begin();
6302
- }
6303
6293
  if (this._controls?.enabled) {
6304
6294
  this._controls.update();
6305
6295
  }
6306
6296
  if (this._disposed) return;
6307
- if (this.dirty || this.options.render.renderAlways) {
6308
- if (this.options.composer.enabled) {
6309
- this.composer.render();
6310
- } else {
6311
- this.renderer.render(this.scene, this.camera);
6312
- }
6297
+ if (!this.dirty && !this.options.render.renderAlways) return;
6298
+ const interval = this._frameInterval;
6299
+ if (interval) {
6300
+ const next = this._nextFrameTime;
6301
+ if (next !== void 0 && t + 0.1 < next) return;
6302
+ this._nextFrameTime = next !== void 0 && t - next < interval ? next + interval : t + interval;
6303
+ }
6304
+ if (this._stats) {
6305
+ this._stats.begin();
6306
+ }
6307
+ if (this.options.composer.enabled) {
6308
+ this.composer.render();
6309
+ } else {
6310
+ this.renderer.render(this.scene, this.camera);
6313
6311
  }
6314
6312
  this.dirty = false;
6315
6313
  if (this._stats) {