From 8d7fc1e9b4e01661f6ece1bead4205371cda100c Mon Sep 17 00:00:00 2001 From: billsonnn Date: Sat, 30 Mar 2024 22:53:11 -0400 Subject: [PATCH] Updates --- .../api/src/nitro/camera/IRoomCameraWidgetManager.ts | 2 +- packages/avatar/src/AvatarImage.ts | 10 ---------- packages/camera/src/RoomCameraWidgetManager.ts | 9 +++++++-- .../avatar/additions/GameClickTargetAddition.ts | 12 ++++++++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/api/src/nitro/camera/IRoomCameraWidgetManager.ts b/packages/api/src/nitro/camera/IRoomCameraWidgetManager.ts index 0247f0ef..bf557c00 100644 --- a/packages/api/src/nitro/camera/IRoomCameraWidgetManager.ts +++ b/packages/api/src/nitro/camera/IRoomCameraWidgetManager.ts @@ -4,7 +4,7 @@ import { IRoomCameraWidgetSelectedEffect } from './IRoomCameraWidgetSelectedEffe export interface IRoomCameraWidgetManager { - init(): void; + init(): Promise; applyEffects(texture: Texture, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): Promise; effects: Map; isLoaded: boolean; diff --git a/packages/avatar/src/AvatarImage.ts b/packages/avatar/src/AvatarImage.ts index 4dc2f109..f23bfd75 100644 --- a/packages/avatar/src/AvatarImage.ts +++ b/packages/avatar/src/AvatarImage.ts @@ -295,16 +295,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener //@ts-ignore this._activeTexture.source.hitMap = null; - /* - if(this._avatarSpriteData) - { - if(this._avatarSpriteData.paletteIsGrayscale) - { - this._reusableTexture = this.applyPalette(this._reusableTexture, this._avatarSpriteData.reds, [], []); - } - } - */ - this._changes = false; return this._activeTexture; diff --git a/packages/camera/src/RoomCameraWidgetManager.ts b/packages/camera/src/RoomCameraWidgetManager.ts index 59d39160..34ed50ec 100644 --- a/packages/camera/src/RoomCameraWidgetManager.ts +++ b/packages/camera/src/RoomCameraWidgetManager.ts @@ -1,4 +1,5 @@ import { IRoomCameraWidgetEffect, IRoomCameraWidgetManager, IRoomCameraWidgetSelectedEffect } from '@nitrots/api'; +import { GetAssetManager } from '@nitrots/assets'; import { GetConfiguration } from '@nitrots/configuration'; import { GetEventDispatcher, RoomCameraWidgetManagerEvent } from '@nitrots/events'; import { TextureUtils } from '@nitrots/utils'; @@ -16,7 +17,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager this._isLoaded = false; } - public init(): void + public async init(): Promise { if(this._isLoaded) return; @@ -37,7 +38,11 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager } else { - cameraEffect.texture = Texture.from(imagesUrl + effect.name + '.png'); + const url = `${ imagesUrl }${ effect.name }.png`; + + await GetAssetManager().downloadAsset(url); + + cameraEffect.texture = GetAssetManager().getTexture(url); cameraEffect.blendMode = effect.blendMode; } diff --git a/packages/room/src/object/visualization/avatar/additions/GameClickTargetAddition.ts b/packages/room/src/object/visualization/avatar/additions/GameClickTargetAddition.ts index de285078..6ff9cce1 100644 --- a/packages/room/src/object/visualization/avatar/additions/GameClickTargetAddition.ts +++ b/packages/room/src/object/visualization/avatar/additions/GameClickTargetAddition.ts @@ -1,5 +1,5 @@ import { AlphaTolerance, IRoomObjectSprite } from '@nitrots/api'; -import { TextureUtils } from '@nitrots/utils'; +import { GetTexturePool } from '@nitrots/utils'; import { Texture } from 'pixi.js'; import { IAvatarAddition } from './IAvatarAddition'; @@ -18,15 +18,19 @@ export class GameClickTargetAddition implements IAvatarAddition public dispose(): void { - this._asset = null; + if(this._asset) + { + GetTexturePool().putTexture(this._asset); + + this._asset = null; + } } - // TODO: needs testing public update(sprite: IRoomObjectSprite, scale: number): void { if(!sprite) return; - if(!this._asset) this._asset = TextureUtils.createRenderTexture(GameClickTargetAddition.WIDTH, GameClickTargetAddition.HEIGHT); + if(!this._asset) this._asset = GetTexturePool().getTexture(GameClickTargetAddition.WIDTH, GameClickTargetAddition.HEIGHT); sprite.visible = true; sprite.texture = this._asset;