From 853204a5b868b986e71568d7d9b657e775c9cbfb Mon Sep 17 00:00:00 2001 From: duckietm Date: Wed, 29 Apr 2026 13:23:30 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20Effect=20selection=20in=20user?= =?UTF-8?q?=20dropdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api/src/nitro/avatar/IAvatarImage.ts | 1 + packages/avatar/src/AvatarImage.ts | 5 ++++ .../avatar/AvatarVisualization.ts | 24 +++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/api/src/nitro/avatar/IAvatarImage.ts b/packages/api/src/nitro/avatar/IAvatarImage.ts index 72ce55e..c0ad032 100644 --- a/packages/api/src/nitro/avatar/IAvatarImage.ts +++ b/packages/api/src/nitro/avatar/IAvatarImage.ts @@ -17,6 +17,7 @@ export interface IAvatarImage processAsImageUrl(setType: string): string; processAsContainer(setType: string): Container; getDirection(): number; + getDirectionOffset(): number; getFigure(): IAvatarFigureContainer; getPartColor(_arg_1: string): IPartColor; getMainAction(): IActiveActionData; diff --git a/packages/avatar/src/AvatarImage.ts b/packages/avatar/src/AvatarImage.ts index 27b17e4..b34d1e5 100644 --- a/packages/avatar/src/AvatarImage.ts +++ b/packages/avatar/src/AvatarImage.ts @@ -399,6 +399,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener return this._mainDirection; } + public getDirectionOffset(): number + { + return this._directionOffset; + } + public initActionAppends(): void { this._actions = []; diff --git a/packages/room/src/object/visualization/avatar/AvatarVisualization.ts b/packages/room/src/object/visualization/avatar/AvatarVisualization.ts index 99643e6..4831392 100644 --- a/packages/room/src/object/visualization/avatar/AvatarVisualization.ts +++ b/packages/room/src/object/visualization/avatar/AvatarVisualization.ts @@ -1104,17 +1104,19 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement if(sprite?.texture) { - const currentDirection = this._avatarImage?.getDirection(); + const displayedDirection = this._avatarImage?.getDirection(); + const directionOffset = this._avatarImage?.getDirectionOffset() ?? 0; let oppositeTexture = sprite.texture; - if((currentDirection !== undefined) && this._avatarImage) + if((displayedDirection !== undefined) && this._avatarImage) { - const oppositeDirection = ((currentDirection + 4) % 8); + const rawCurrent = ((displayedDirection - directionOffset) % 8 + 8) % 8; + const rawOpposite = (rawCurrent + 4) % 8; + const displayedOpposite = (displayedDirection + 4) % 8; - if(oppositeDirection !== currentDirection) + if(displayedOpposite !== displayedDirection) { - // Reuse the cached opposite texture if direction and base texture haven't changed - if(this._reflectionOppositeTexture && (this._reflectionOppositeDirection === currentDirection) && (this._reflectionOppositeBaseTexture === sprite.texture)) + if(this._reflectionOppositeTexture && (this._reflectionOppositeDirection === displayedDirection) && (this._reflectionOppositeBaseTexture === sprite.texture)) { oppositeTexture = this._reflectionOppositeTexture; } @@ -1122,7 +1124,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement { const highlightEnabled = ((this.object.model.getValue(RoomObjectVariable.FIGURE_HIGHLIGHT_ENABLE) === 1) && (this.object.model.getValue(RoomObjectVariable.FIGURE_HIGHLIGHT) === 1)); - this._avatarImage.setDirection(AvatarSetType.FULL, oppositeDirection); + this._avatarImage.setDirection(AvatarSetType.FULL, rawOpposite); const renderedOpposite = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture); @@ -1133,14 +1135,10 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement } this._reflectionOppositeTexture = this.cloneTexture(renderedOpposite); - this._reflectionOppositeDirection = currentDirection; + this._reflectionOppositeDirection = displayedDirection; this._reflectionOppositeBaseTexture = sprite.texture; - oppositeTexture = (this._reflectionOppositeTexture || renderedOpposite); - - // Restore the live avatar direction and refresh the current texture so - // movement updates do not keep showing the opposite-facing texture. - this._avatarImage.setDirection(AvatarSetType.FULL, currentDirection); + this._avatarImage.setDirection(AvatarSetType.FULL, rawCurrent); sprite.texture = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture); }