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.
@@ -1325,10 +1325,9 @@ declare class Renderer implements Disposable {
1325
1325
  protected _stats?: Stats;
1326
1326
  protected _dirty: boolean;
1327
1327
  protected _animationLoop: any;
1328
- protected _fpsTimer: any;
1329
- protected _animationTimer?: NodeJS.Timeout;
1330
- protected _animationFrame?: number;
1328
+ protected _frameInterval?: number;
1331
1329
  protected _resizeListener?: () => void;
1330
+ private _nextFrameTime?;
1332
1331
  private _disposed;
1333
1332
  private readonly _debugHelpers;
1334
1333
  private readonly _eventDispatchers;
@@ -1395,6 +1394,7 @@ interface CameraOptions {
1395
1394
  lookingAt: Vector3 | TripleArray;
1396
1395
  }
1397
1396
  interface RenderOptions {
1397
+ /** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
1398
1398
  fpsLimit: number;
1399
1399
  stats: boolean;
1400
1400
  antialias: boolean;
@@ -1325,10 +1325,9 @@ declare class Renderer implements Disposable {
1325
1325
  protected _stats?: Stats;
1326
1326
  protected _dirty: boolean;
1327
1327
  protected _animationLoop: any;
1328
- protected _fpsTimer: any;
1329
- protected _animationTimer?: NodeJS.Timeout;
1330
- protected _animationFrame?: number;
1328
+ protected _frameInterval?: number;
1331
1329
  protected _resizeListener?: () => void;
1330
+ private _nextFrameTime?;
1332
1331
  private _disposed;
1333
1332
  private readonly _debugHelpers;
1334
1333
  private readonly _eventDispatchers;
@@ -1395,6 +1394,7 @@ interface CameraOptions {
1395
1394
  lookingAt: Vector3 | TripleArray;
1396
1395
  }
1397
1396
  interface RenderOptions {
1397
+ /** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
1398
1398
  fpsLimit: number;
1399
1399
  stats: boolean;
1400
1400
  antialias: boolean;
@@ -6164,8 +6164,6 @@ var MapControls = class extends OrbitControls {
6164
6164
  var _Renderer = class _Renderer {
6165
6165
  constructor(options) {
6166
6166
  this._dirty = true;
6167
- this._animationTimer = void 0;
6168
- this._animationFrame = void 0;
6169
6167
  this._resizeListener = void 0;
6170
6168
  this._disposed = false;
6171
6169
  this._debugHelpers = [];
@@ -6175,7 +6173,7 @@ var _Renderer = class _Renderer {
6175
6173
  };
6176
6174
  this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6177
6175
  this._animationLoop = this.animate.bind(this);
6178
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6176
+ this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6179
6177
  this._scene = this.createScene();
6180
6178
  this._camera = this.createCamera();
6181
6179
  this._renderer = this.createRenderer();
@@ -6357,12 +6355,7 @@ var _Renderer = class _Renderer {
6357
6355
  stop() {
6358
6356
  if (this._disposed) return;
6359
6357
  this.renderer.setAnimationLoop(null);
6360
- if (this._animationTimer)
6361
- clearTimeout(this._animationTimer);
6362
- this._animationTimer = void 0;
6363
- if (this._animationFrame)
6364
- cancelAnimationFrame(this._animationFrame);
6365
- this._animationFrame = void 0;
6358
+ this._nextFrameTime = void 0;
6366
6359
  }
6367
6360
  /**
6368
6361
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -6407,22 +6400,27 @@ var _Renderer = class _Renderer {
6407
6400
  this.renderer.dispose();
6408
6401
  this.renderer.forceContextLoss();
6409
6402
  }
6410
- animate(t) {
6403
+ animate(t = performance.now()) {
6411
6404
  var _a;
6412
6405
  if (this._disposed) return;
6413
- if (this._stats) {
6414
- this._stats.begin();
6415
- }
6416
6406
  if ((_a = this._controls) == null ? void 0 : _a.enabled) {
6417
6407
  this._controls.update();
6418
6408
  }
6419
6409
  if (this._disposed) return;
6420
- if (this.dirty || this.options.render.renderAlways) {
6421
- if (this.options.composer.enabled) {
6422
- this.composer.render();
6423
- } else {
6424
- this.renderer.render(this.scene, this.camera);
6425
- }
6410
+ if (!this.dirty && !this.options.render.renderAlways) return;
6411
+ const interval = this._frameInterval;
6412
+ if (interval) {
6413
+ const next = this._nextFrameTime;
6414
+ if (next !== void 0 && t + 0.1 < next) return;
6415
+ this._nextFrameTime = next !== void 0 && t - next < interval ? next + interval : t + interval;
6416
+ }
6417
+ if (this._stats) {
6418
+ this._stats.begin();
6419
+ }
6420
+ if (this.options.composer.enabled) {
6421
+ this.composer.render();
6422
+ } else {
6423
+ this.renderer.render(this.scene, this.camera);
6426
6424
  }
6427
6425
  this.dirty = false;
6428
6426
  if (this._stats) {