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.
package/dist/bundle.js CHANGED
@@ -85191,8 +85191,6 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
85191
85191
  var _Renderer = class _Renderer {
85192
85192
  constructor(options) {
85193
85193
  this._dirty = true;
85194
- this._animationTimer = void 0;
85195
- this._animationFrame = void 0;
85196
85194
  this._resizeListener = void 0;
85197
85195
  this._disposed = false;
85198
85196
  this._debugHelpers = [];
@@ -85202,7 +85200,7 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
85202
85200
  };
85203
85201
  this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
85204
85202
  this._animationLoop = this.animate.bind(this);
85205
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
85203
+ this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
85206
85204
  this._scene = this.createScene();
85207
85205
  this._camera = this.createCamera();
85208
85206
  this._renderer = this.createRenderer();
@@ -85383,12 +85381,7 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
85383
85381
  stop() {
85384
85382
  if (this._disposed) return;
85385
85383
  this.renderer.setAnimationLoop(null);
85386
- if (this._animationTimer)
85387
- clearTimeout(this._animationTimer);
85388
- this._animationTimer = void 0;
85389
- if (this._animationFrame)
85390
- cancelAnimationFrame(this._animationFrame);
85391
- this._animationFrame = void 0;
85384
+ this._nextFrameTime = void 0;
85392
85385
  }
85393
85386
  /**
85394
85387
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -85432,21 +85425,26 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
85432
85425
  this.renderer.dispose();
85433
85426
  this.renderer.forceContextLoss();
85434
85427
  }
85435
- animate(t5) {
85428
+ animate(t5 = performance.now()) {
85436
85429
  if (this._disposed) return;
85437
- if (this._stats) {
85438
- this._stats.begin();
85439
- }
85440
85430
  if (this._controls?.enabled) {
85441
85431
  this._controls.update();
85442
85432
  }
85443
85433
  if (this._disposed) return;
85444
- if (this.dirty || this.options.render.renderAlways) {
85445
- if (this.options.composer.enabled) {
85446
- this.composer.render();
85447
- } else {
85448
- this.renderer.render(this.scene, this.camera);
85449
- }
85434
+ if (!this.dirty && !this.options.render.renderAlways) return;
85435
+ const interval = this._frameInterval;
85436
+ if (interval) {
85437
+ const next = this._nextFrameTime;
85438
+ if (next !== void 0 && t5 + 0.1 < next) return;
85439
+ this._nextFrameTime = next !== void 0 && t5 - next < interval ? next + interval : t5 + interval;
85440
+ }
85441
+ if (this._stats) {
85442
+ this._stats.begin();
85443
+ }
85444
+ if (this.options.composer.enabled) {
85445
+ this.composer.render();
85446
+ } else {
85447
+ this.renderer.render(this.scene, this.camera);
85450
85448
  }
85451
85449
  this.dirty = false;
85452
85450
  if (this._stats) {