diff --git a/src/nitro/INitro.ts b/src/nitro/INitro.ts index 8113de6b..90cac6ba 100644 --- a/src/nitro/INitro.ts +++ b/src/nitro/INitro.ts @@ -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; } diff --git a/src/nitro/Nitro.ts b/src/nitro/Nitro.ts index 18de6f0a..e4542a23 100644 --- a/src/nitro/Nitro.ts +++ b/src/nitro/Nitro.ts @@ -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('system.animation.fps', 24); - const limitsFPS = NitroConfiguration.getValue('system.limits.fps', true); + const limitsFPS = NitroConfiguration.getValue('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; diff --git a/src/nitro/room/RoomEngine.ts b/src/nitro/room/RoomEngine.ts index 1b23803e..61d567d1 100644 --- a/src/nitro/room/RoomEngine.ts +++ b/src/nitro/room/RoomEngine.ts @@ -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); } } diff --git a/src/nitro/room/object/visualization/room/rasterizer/animated/LandscapeRasterizer.ts b/src/nitro/room/object/visualization/room/rasterizer/animated/LandscapeRasterizer.ts index caf241be..c489781b 100644 --- a/src/nitro/room/object/visualization/room/rasterizer/animated/LandscapeRasterizer.ts +++ b/src/nitro/room/object/visualization/room/rasterizer/animated/LandscapeRasterizer.ts @@ -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('system.animation.fps') : 0; - const speedY = item.speedY ? item.speedY / NitroConfiguration.getValue('system.animation.fps') : 0; + const speedX = item.speedX ? item.speedX / NitroConfiguration.getValue('system.animation.fps', 24) : 0; + const speedY = item.speedY ? item.speedY / NitroConfiguration.getValue('system.animation.fps', 24) : 0; animationItems.push({ asset: assetId, diff --git a/src/nitro/window/motion/Motions.ts b/src/nitro/window/motion/Motions.ts index 962b6fc4..2f9a715b 100644 --- a/src/nitro/window/motion/Motions.ts +++ b/src/nitro/window/motion/Motions.ts @@ -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 diff --git a/src/pixi-proxy/GetTicker.ts b/src/pixi-proxy/GetTicker.ts new file mode 100644 index 00000000..cddd4a2f --- /dev/null +++ b/src/pixi-proxy/GetTicker.ts @@ -0,0 +1,3 @@ +import { PixiApplicationProxy } from './PixiApplicationProxy'; + +export const GetTicker = () => (PixiApplicationProxy.instance?.ticker || null); diff --git a/src/pixi-proxy/GetTickerFPS.ts b/src/pixi-proxy/GetTickerFPS.ts new file mode 100644 index 00000000..26224f6e --- /dev/null +++ b/src/pixi-proxy/GetTickerFPS.ts @@ -0,0 +1,3 @@ +import { GetTicker } from './GetTicker'; + +export const GetTickerFPS = () => (GetTicker()?.FPS || 0); diff --git a/src/pixi-proxy/GetTickerTime.ts b/src/pixi-proxy/GetTickerTime.ts index a6ef72b6..f5987e48 100644 --- a/src/pixi-proxy/GetTickerTime.ts +++ b/src/pixi-proxy/GetTickerTime.ts @@ -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); diff --git a/src/pixi-proxy/index.ts b/src/pixi-proxy/index.ts index 7ee75edb..fa6b203d 100644 --- a/src/pixi-proxy/index.ts +++ b/src/pixi-proxy/index.ts @@ -1,3 +1,5 @@ +export * from './GetTicker'; +export * from './GetTickerFPS'; export * from './GetTickerTime'; export * from './INitroPoint'; export * from './NitroAdjustmentFilter'; diff --git a/src/room/renderer/RoomSpriteCanvas.ts b/src/room/renderer/RoomSpriteCanvas.ts index d5abb918..47bad569 100644 --- a/src/room/renderer/RoomSpriteCanvas.ts +++ b/src/room/renderer/RoomSpriteCanvas.ts @@ -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;