mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-26 17:30:52 +01:00
FPS update
This commit is contained in:
parent
56ef76361b
commit
c56f0d86c1
@ -221,7 +221,7 @@ export class Nitro extends Application implements INitro
|
|||||||
const animationFPS = this.getConfiguration<number>('animation.fps', 24);
|
const animationFPS = this.getConfiguration<number>('animation.fps', 24);
|
||||||
const limitsFPS = this.getConfiguration<boolean>('limits.fps', true);
|
const limitsFPS = this.getConfiguration<boolean>('limits.fps', true);
|
||||||
|
|
||||||
Nitro.instance.ticker.maxFPS = animationFPS;
|
if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRoomEngineReady(event: RoomEngineEvent): void
|
private onRoomEngineReady(event: RoomEngineEvent): void
|
||||||
|
@ -26,7 +26,10 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
|||||||
private _container: IRoomSpriteCanvasContainer;
|
private _container: IRoomSpriteCanvasContainer;
|
||||||
|
|
||||||
private _geometry: RoomGeometry;
|
private _geometry: RoomGeometry;
|
||||||
|
private _animationFPS: number;
|
||||||
private _renderTimestamp: number;
|
private _renderTimestamp: number;
|
||||||
|
private _totalTimeRunning: number;
|
||||||
|
private _lastFrame: number;
|
||||||
|
|
||||||
private _master: Sprite;
|
private _master: Sprite;
|
||||||
private _display: Container;
|
private _display: Container;
|
||||||
@ -71,7 +74,10 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
|||||||
this._container = container;
|
this._container = container;
|
||||||
|
|
||||||
this._geometry = new RoomGeometry(scale, new Vector3d(-135, 30, 0), new Vector3d(11, 11, 5), new Vector3d(-135, 0.5, 0));
|
this._geometry = new RoomGeometry(scale, new Vector3d(-135, 30, 0), new Vector3d(11, 11, 5), new Vector3d(-135, 0.5, 0));
|
||||||
|
this._animationFPS = Nitro.instance.getConfiguration<number>('animation.fps', 24);
|
||||||
this._renderTimestamp = 0;
|
this._renderTimestamp = 0;
|
||||||
|
this._totalTimeRunning = 0;
|
||||||
|
this._lastFrame = 0;
|
||||||
|
|
||||||
this._master = null;
|
this._master = null;
|
||||||
this._display = null;
|
this._display = null;
|
||||||
@ -321,12 +327,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
|||||||
{
|
{
|
||||||
this._canvasUpdated = false;
|
this._canvasUpdated = false;
|
||||||
|
|
||||||
|
this._totalTimeRunning += Nitro.instance.ticker.deltaTime;
|
||||||
|
|
||||||
|
if(this._totalTimeRunning === this._renderTimestamp) return;
|
||||||
|
|
||||||
if(time === -1) time = (this._renderTimestamp + 1);
|
if(time === -1) time = (this._renderTimestamp + 1);
|
||||||
|
|
||||||
if(!this._container || !this._geometry) return;
|
if(!this._container || !this._geometry) return;
|
||||||
|
|
||||||
if(time === this._renderTimestamp) return;
|
|
||||||
|
|
||||||
if((this._width !== this._renderedWidth) || (this._height !== this._renderedHeight)) update = true;
|
if((this._width !== this._renderedWidth) || (this._height !== this._renderedHeight)) update = true;
|
||||||
|
|
||||||
if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY))
|
if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY))
|
||||||
@ -344,6 +352,12 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
|||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const frame = Math.round(this._totalTimeRunning / (60 / this._animationFPS));
|
||||||
|
|
||||||
|
if(frame !== this._lastFrame)
|
||||||
|
{
|
||||||
|
this._lastFrame = frame;
|
||||||
|
|
||||||
let spriteCount = 0;
|
let spriteCount = 0;
|
||||||
|
|
||||||
const objects = this._container.objects;
|
const objects = this._container.objects;
|
||||||
@ -380,10 +394,11 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._Str_20677(spriteCount);
|
this._Str_20677(spriteCount);
|
||||||
|
}
|
||||||
|
|
||||||
if(update) this._canvasUpdated = true;
|
if(update) this._canvasUpdated = true;
|
||||||
|
|
||||||
this._renderTimestamp = time;
|
this._renderTimestamp = this._totalTimeRunning;
|
||||||
this._renderedWidth = this._width;
|
this._renderedWidth = this._width;
|
||||||
this._renderedHeight = this._height;
|
this._renderedHeight = this._height;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user