Fix some floating positions

This commit is contained in:
Bill 2024-07-13 21:31:40 -04:00
parent d060d3f3b6
commit 19779eb2e2
5 changed files with 33 additions and 8 deletions

View File

@ -221,7 +221,8 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
point.x += avatarCanvas.regPoint.x; point.x += avatarCanvas.regPoint.x;
point.y += avatarCanvas.regPoint.y; point.y += avatarCanvas.regPoint.y;
partContainer.position.set(point.x, point.y); partContainer.x = Math.floor(point.x);
partContainer.y = Math.floor(point.y);
container.addChild(partContainer); container.addChild(partContainer);
} }
@ -282,8 +283,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
if(!this._activeTexture) return null; if(!this._activeTexture) return null;
this._activeTexture.source.scaleMode = 'nearest';
const container = this.buildAvatarContainer(avatarCanvas, setType); const container = this.buildAvatarContainer(avatarCanvas, setType);
GetRenderer().render({ GetRenderer().render({

View File

@ -73,7 +73,8 @@ export class FurnitureGuildIsometricBadgeVisualization extends IsometricImageFur
sprite.setFromMatrix(matrix); sprite.setFromMatrix(matrix);
sprite.position.set(0); sprite.x = 0;
sprite.y = 0;
return TextureUtils.generateTexture(sprite); return TextureUtils.generateTexture(sprite);

View File

@ -1,5 +1,6 @@
import { IAssetData, IAssetVisualizationData, IObjectVisualizationData } from '@nitrots/api'; import { IAssetData, IAssetVisualizationData, IObjectVisualizationData } from '@nitrots/api';
import { BLEND_MODES } from 'pixi.js'; import { BLEND_MODES } from 'pixi.js';
import { RoomGeometry } from '../../../utils';
import { ColorData, LayerData, SizeData } from '../data'; import { ColorData, LayerData, SizeData } from '../data';
export class FurnitureVisualizationData implements IObjectVisualizationData export class FurnitureVisualizationData implements IObjectVisualizationData
@ -105,11 +106,33 @@ export class FurnitureVisualizationData implements IObjectVisualizationData
this._sizes.push(size); this._sizes.push(size);
} }
this.removeInvalidSizes();
this._sizes.sort(); this._sizes.sort();
return true; return true;
} }
private removeInvalidSizes(): void
{
if(!this._sizes || !this._sizes.length) return;
const zoomedIn = this._sizeDatas.get(RoomGeometry.SCALE_ZOOMED_IN);
const zoomedOut = this._sizeDatas.get(RoomGeometry.SCALE_ZOOMED_OUT);
if(zoomedIn && zoomedOut)
{
if(zoomedIn.layerCount !== zoomedOut.layerCount)
{
this._sizeDatas.delete(RoomGeometry.SCALE_ZOOMED_OUT);
const index = this._sizes.indexOf(RoomGeometry.SCALE_ZOOMED_OUT);
if(index >= 0) this._sizes.splice(index, 1);
}
}
}
protected processVisualElement(sizeData: SizeData, key: string, data: any): boolean protected processVisualElement(sizeData: SizeData, key: string, data: any): boolean
{ {
if(!sizeData || !key || !data) return false; if(!sizeData || !key || !data) return false;

View File

@ -105,7 +105,8 @@ export class IsometricImageFurniVisualization extends FurnitureAnimatedVisualiza
const offsetX = ((background.width - sprite.width) / 2); const offsetX = ((background.width - sprite.width) / 2);
const offsetY = ((background.height - sprite.height) / 2); const offsetY = ((background.height - sprite.height) / 2);
sprite.position.set(offsetX, offsetY); sprite.x = Math.floor(offsetX);
sprite.y = Math.floor(offsetY);
container.addChild(background, sprite); container.addChild(background, sprite);

View File

@ -266,7 +266,8 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY)) if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY))
{ {
this._display.position.set(this._screenOffsetX, this._screenOffsetY); this._display.x = Math.floor(this._screenOffsetX);
this._display.y = Math.floor(this._screenOffsetY);
update = true; update = true;
} }
@ -562,8 +563,8 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
this.updateEnterRoomEffect(extendedSprite, objectSprite); this.updateEnterRoomEffect(extendedSprite, objectSprite);
} }
if(extendedSprite.x !== sprite.x) extendedSprite.x = sprite.x; extendedSprite.x = Math.round(sprite.x);
if(extendedSprite.y !== sprite.y) extendedSprite.y = sprite.y; extendedSprite.y = Math.round(sprite.y);
extendedSprite.offsetX = objectSprite.offsetX; extendedSprite.offsetX = objectSprite.offsetX;
extendedSprite.offsetY = objectSprite.offsetY; extendedSprite.offsetY = objectSprite.offsetY;