mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 22:36:27 +01:00
Fix FPS issue
This commit is contained in:
parent
3086a8446f
commit
7f0164c176
@ -1,5 +1,4 @@
|
||||
import { Application } from '@pixi/app';
|
||||
import { Ticker } from '@pixi/ticker';
|
||||
import { IAvatarRenderManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroCore, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager, IWorkerEventTracker } from '../api';
|
||||
|
||||
export interface INitro
|
||||
@ -32,8 +31,6 @@ export interface INitro
|
||||
soundManager: ISoundManager;
|
||||
width: number;
|
||||
height: number;
|
||||
ticker: Ticker;
|
||||
time: number;
|
||||
isReady: boolean;
|
||||
isDisposed: boolean;
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
import { Application, IApplicationOptions } from '@pixi/app';
|
||||
import { SCALE_MODES } from '@pixi/constants';
|
||||
import { settings } from '@pixi/settings';
|
||||
import { Ticker } from '@pixi/ticker';
|
||||
import { IAvatarRenderManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroCore, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager, IWorkerEventTracker, NitroConfiguration } from '../api';
|
||||
import { ConfigurationEvent, EventDispatcher, NitroCore } from '../core';
|
||||
import { NitroEvent, RoomEngineEvent } from '../events';
|
||||
import { PixiApplicationProxy } from '../pixi-proxy';
|
||||
import { GetTicker, PixiApplicationProxy } from '../pixi-proxy';
|
||||
import { RoomManager } from '../room';
|
||||
import { AvatarRenderManager } from './avatar';
|
||||
import { RoomCameraWidgetManager } from './camera';
|
||||
@ -200,9 +199,9 @@ export class Nitro implements INitro
|
||||
private onConfigurationLoadedEvent(event: ConfigurationEvent): void
|
||||
{
|
||||
const animationFPS = NitroConfiguration.getValue<number>('system.animation.fps', 24);
|
||||
const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', true);
|
||||
const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', false);
|
||||
|
||||
if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
|
||||
if(limitsFPS) GetTicker().maxFPS = animationFPS;
|
||||
}
|
||||
|
||||
private onRoomEngineReady(event: RoomEngineEvent): void
|
||||
@ -392,16 +391,6 @@ export class Nitro implements INitro
|
||||
return this._application.renderer.height;
|
||||
}
|
||||
|
||||
public get ticker(): Ticker
|
||||
{
|
||||
return Ticker.shared;
|
||||
}
|
||||
|
||||
public get time(): number
|
||||
{
|
||||
return this.ticker.lastTime;
|
||||
}
|
||||
|
||||
public get isReady(): boolean
|
||||
{
|
||||
return this._isReady;
|
||||
|
@ -4,11 +4,10 @@ import { Matrix, Point, Rectangle } from '@pixi/math';
|
||||
import { IConnection, IDisposable, IFurnitureStackingHeightMap, IGetImageListener, IImageResult, ILegacyWallGeometry, IMessageComposer, INitroCommunicationManager, INitroEvent, IObjectData, IPetColorResult, IPetCustomPart, IRoomContentListener, IRoomContentLoader, IRoomCreator, IRoomEngine, IRoomEngineServices, IRoomGeometry, IRoomInstance, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomObjectLogicFactory, IRoomObjectVisualizationFactory, IRoomRenderer, IRoomRendererFactory, IRoomRenderingCanvas, IRoomSessionManager, ISelectedRoomObjectData, ISessionDataManager, ITileObjectMap, IUpdateReceiver, IVector3D, LegacyDataType, MouseEventType, NitroConfiguration, NitroLogger, ObjectDataFactory, RoomControllerLevel, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, ToolbarIconEnum, Vector3d } from '../../api';
|
||||
import { NitroManager } from '../../core';
|
||||
import { BadgeImageReadyEvent, NitroToolbarAnimateIconEvent, RoomBackgroundColorEvent, RoomDragEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomObjectFurnitureActionEvent, RoomSessionEvent, RoomToObjectOwnAvatarMoveEvent } from '../../events';
|
||||
import { GetTickerTime, NitroSprite, TextureUtils } from '../../pixi-proxy';
|
||||
import { GetTicker, GetTickerTime, NitroSprite, TextureUtils } from '../../pixi-proxy';
|
||||
import { NumberBank, RoomEnterEffect, RoomGeometry, RoomInstance, RoomObjectEvent, RoomObjectMouseEvent, RoomObjectUpdateMessage, RoomRendererFactory } from '../../room';
|
||||
import { PetFigureData } from '../avatar';
|
||||
import { RenderRoomMessageComposer, RenderRoomThumbnailMessageComposer } from '../communication';
|
||||
import { Nitro } from '../Nitro';
|
||||
import { FurniId } from '../utils';
|
||||
import { ImageResult } from './ImageResult';
|
||||
import { ObjectAvatarCarryObjectUpdateMessage, ObjectAvatarChatUpdateMessage, ObjectAvatarDanceUpdateMessage, ObjectAvatarEffectUpdateMessage, ObjectAvatarExperienceUpdateMessage, ObjectAvatarExpressionUpdateMessage, ObjectAvatarFigureUpdateMessage, ObjectAvatarFlatControlUpdateMessage, ObjectAvatarGestureUpdateMessage, ObjectAvatarGuideStatusUpdateMessage, ObjectAvatarMutedUpdateMessage, ObjectAvatarOwnMessage, ObjectAvatarPetGestureUpdateMessage, ObjectAvatarPlayerValueUpdateMessage, ObjectAvatarPlayingGameUpdateMessage, ObjectAvatarPostureUpdateMessage, ObjectAvatarSignUpdateMessage, ObjectAvatarSleepUpdateMessage, ObjectAvatarTypingUpdateMessage, ObjectAvatarUpdateMessage, ObjectAvatarUseObjectUpdateMessage, ObjectDataUpdateMessage, ObjectGroupBadgeUpdateMessage, ObjectHeightUpdateMessage, ObjectItemDataUpdateMessage, ObjectModelDataUpdateMessage, ObjectMoveUpdateMessage, ObjectRoomColorUpdateMessage, ObjectRoomFloorHoleUpdateMessage, ObjectRoomMaskUpdateMessage, ObjectRoomPlanePropertyUpdateMessage, ObjectRoomPlaneVisibilityUpdateMessage, ObjectRoomUpdateMessage, ObjectStateUpdateMessage } from './messages';
|
||||
@ -151,7 +150,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
this.events.addEventListener(RoomContentLoader.LOADER_READY, this.onRoomContentLoaderReadyEvent);
|
||||
|
||||
Nitro.instance.ticker.add(this.update, this);
|
||||
GetTicker().add(this.update, this);
|
||||
|
||||
document.addEventListener('visibilitychange', this.runVisibilityUpdate);
|
||||
}
|
||||
@ -167,7 +166,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
document.removeEventListener('visibilitychange', this.runVisibilityUpdate);
|
||||
|
||||
Nitro.instance.ticker.remove(this.update, this);
|
||||
GetTicker().remove(this.update, this);
|
||||
|
||||
if(this._roomObjectEventHandler) this._roomObjectEventHandler.dispose();
|
||||
|
||||
@ -787,12 +786,12 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
Nitro.instance.ticker.remove(this.update, this);
|
||||
GetTicker().remove(this.update, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Nitro.instance.ticker.remove(this.update, this);
|
||||
Nitro.instance.ticker.add(this.update, this);
|
||||
GetTicker().remove(this.update, this);
|
||||
GetTicker().add(this.update, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ export class LandscapeRasterizer extends PlaneRasterizer
|
||||
const assetId = item.assetId;
|
||||
const x = this.getCoordinateValue(item.x || '', item.randomX || '');
|
||||
const y = this.getCoordinateValue(item.y || '', item.randomY || '');
|
||||
const speedX = item.speedX ? item.speedX / NitroConfiguration.getValue<number>('system.animation.fps') : 0;
|
||||
const speedY = item.speedY ? item.speedY / NitroConfiguration.getValue<number>('system.animation.fps') : 0;
|
||||
const speedX = item.speedX ? item.speedX / NitroConfiguration.getValue<number>('system.animation.fps', 24) : 0;
|
||||
const speedY = item.speedY ? item.speedY / NitroConfiguration.getValue<number>('system.animation.fps', 24) : 0;
|
||||
|
||||
animationItems.push({
|
||||
asset: assetId,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { GetTickerTime } from '../../../pixi-proxy';
|
||||
import { Nitro } from '../../Nitro';
|
||||
import { GetTickerFPS, GetTickerTime } from '../../../pixi-proxy';
|
||||
import { Motion } from './Motion';
|
||||
|
||||
export class Motions
|
||||
@ -12,7 +11,7 @@ export class Motions
|
||||
|
||||
public static get TIMER_TIME(): number
|
||||
{
|
||||
return (1000 / Nitro.instance.ticker.FPS);
|
||||
return (1000 / GetTickerFPS());
|
||||
}
|
||||
|
||||
public static runMotion(k: Motion): Motion
|
||||
|
3
src/pixi-proxy/GetTicker.ts
Normal file
3
src/pixi-proxy/GetTicker.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { PixiApplicationProxy } from './PixiApplicationProxy';
|
||||
|
||||
export const GetTicker = () => (PixiApplicationProxy.instance?.ticker || null);
|
3
src/pixi-proxy/GetTickerFPS.ts
Normal file
3
src/pixi-proxy/GetTickerFPS.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { GetTicker } from './GetTicker';
|
||||
|
||||
export const GetTickerFPS = () => (GetTicker()?.FPS || 0);
|
@ -1,3 +1,3 @@
|
||||
import { PixiApplicationProxy } from './PixiApplicationProxy';
|
||||
import { GetTicker } from './GetTicker';
|
||||
|
||||
export const GetTickerTime = () => (PixiApplicationProxy.instance?.ticker?.lastTime || 0);
|
||||
export const GetTickerTime = () => (GetTicker()?.lastTime || 0);
|
||||
|
@ -1,3 +1,5 @@
|
||||
export * from './GetTicker';
|
||||
export * from './GetTickerFPS';
|
||||
export * from './GetTickerTime';
|
||||
export * from './INitroPoint';
|
||||
export * from './NitroAdjustmentFilter';
|
||||
|
@ -5,7 +5,7 @@ import { Matrix, Point, Rectangle } from '@pixi/math';
|
||||
import { Sprite } from '@pixi/sprite';
|
||||
import { IRoomCanvasMouseListener, IRoomGeometry, IRoomObject, IRoomObjectSprite, IRoomObjectSpriteVisualization, IRoomRenderingCanvas, IRoomSpriteCanvasContainer, IRoomSpriteMouseEvent, MouseEventType, RoomObjectSpriteData, RoomObjectSpriteType, Vector3d } from '../../api';
|
||||
import { Nitro } from '../../nitro/Nitro';
|
||||
import { NitroContainer, NitroSprite, PixiApplicationProxy } from '../../pixi-proxy';
|
||||
import { GetTickerTime, NitroContainer, NitroSprite, PixiApplicationProxy } from '../../pixi-proxy';
|
||||
import { RoomSpriteMouseEvent } from '../events';
|
||||
import { RoomEnterEffect, RoomGeometry, RoomRotatingEffect, RoomShakingEffect } from '../utils';
|
||||
import { RoomObjectCache, RoomObjectCacheItem } from './cache';
|
||||
@ -322,7 +322,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
{
|
||||
this._canvasUpdated = false;
|
||||
|
||||
this._totalTimeRunning += PixiApplicationProxy.instance.ticker.deltaTime;
|
||||
this._totalTimeRunning = GetTickerTime();
|
||||
|
||||
if(this._totalTimeRunning === this._renderTimestamp) return;
|
||||
|
||||
@ -334,8 +334,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
|
||||
if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY))
|
||||
{
|
||||
this._display.x = this._screenOffsetX;
|
||||
this._display.y = this._screenOffsetY;
|
||||
this._display.position.set(this._screenOffsetX, this._screenOffsetY);
|
||||
|
||||
update = true;
|
||||
}
|
||||
@ -374,15 +373,9 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
}
|
||||
}
|
||||
|
||||
this._sortableSprites.sort((a, b) =>
|
||||
{
|
||||
return b.z - a.z;
|
||||
});
|
||||
this._sortableSprites.sort((a, b) => (b.z - a.z));
|
||||
|
||||
if(spriteCount < this._sortableSprites.length)
|
||||
{
|
||||
this._sortableSprites.splice(spriteCount);
|
||||
}
|
||||
if(spriteCount < this._sortableSprites.length) this._sortableSprites.splice(spriteCount);
|
||||
|
||||
let iterator = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user