This commit is contained in:
billsonnn 2024-03-30 22:53:11 -04:00
parent 9a403d72db
commit 8d7fc1e9b4
4 changed files with 16 additions and 17 deletions

View File

@ -4,7 +4,7 @@ import { IRoomCameraWidgetSelectedEffect } from './IRoomCameraWidgetSelectedEffe
export interface IRoomCameraWidgetManager export interface IRoomCameraWidgetManager
{ {
init(): void; init(): Promise<void>;
applyEffects(texture: Texture, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): Promise<HTMLImageElement>; applyEffects(texture: Texture, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): Promise<HTMLImageElement>;
effects: Map<string, IRoomCameraWidgetEffect>; effects: Map<string, IRoomCameraWidgetEffect>;
isLoaded: boolean; isLoaded: boolean;

View File

@ -295,16 +295,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
//@ts-ignore //@ts-ignore
this._activeTexture.source.hitMap = null; this._activeTexture.source.hitMap = null;
/*
if(this._avatarSpriteData)
{
if(this._avatarSpriteData.paletteIsGrayscale)
{
this._reusableTexture = this.applyPalette(this._reusableTexture, this._avatarSpriteData.reds, [], []);
}
}
*/
this._changes = false; this._changes = false;
return this._activeTexture; return this._activeTexture;

View File

@ -1,4 +1,5 @@
import { IRoomCameraWidgetEffect, IRoomCameraWidgetManager, IRoomCameraWidgetSelectedEffect } from '@nitrots/api'; import { IRoomCameraWidgetEffect, IRoomCameraWidgetManager, IRoomCameraWidgetSelectedEffect } from '@nitrots/api';
import { GetAssetManager } from '@nitrots/assets';
import { GetConfiguration } from '@nitrots/configuration'; import { GetConfiguration } from '@nitrots/configuration';
import { GetEventDispatcher, RoomCameraWidgetManagerEvent } from '@nitrots/events'; import { GetEventDispatcher, RoomCameraWidgetManagerEvent } from '@nitrots/events';
import { TextureUtils } from '@nitrots/utils'; import { TextureUtils } from '@nitrots/utils';
@ -16,7 +17,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
this._isLoaded = false; this._isLoaded = false;
} }
public init(): void public async init(): Promise<void>
{ {
if(this._isLoaded) return; if(this._isLoaded) return;
@ -37,7 +38,11 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
} }
else 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; cameraEffect.blendMode = effect.blendMode;
} }

View File

@ -1,5 +1,5 @@
import { AlphaTolerance, IRoomObjectSprite } from '@nitrots/api'; import { AlphaTolerance, IRoomObjectSprite } from '@nitrots/api';
import { TextureUtils } from '@nitrots/utils'; import { GetTexturePool } from '@nitrots/utils';
import { Texture } from 'pixi.js'; import { Texture } from 'pixi.js';
import { IAvatarAddition } from './IAvatarAddition'; import { IAvatarAddition } from './IAvatarAddition';
@ -18,15 +18,19 @@ export class GameClickTargetAddition implements IAvatarAddition
public dispose(): void public dispose(): void
{ {
if(this._asset)
{
GetTexturePool().putTexture(this._asset);
this._asset = null; this._asset = null;
} }
}
// TODO: needs testing
public update(sprite: IRoomObjectSprite, scale: number): void public update(sprite: IRoomObjectSprite, scale: number): void
{ {
if(!sprite) return; 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.visible = true;
sprite.texture = this._asset; sprite.texture = this._asset;