Fix zoom issues

This commit is contained in:
Bill 2024-07-12 23:10:56 -04:00
parent f5a44105c0
commit 8d9c11ff6e
7 changed files with 41 additions and 39 deletions

View File

@ -14,7 +14,7 @@ export interface IRoomEngine
setActiveRoomId(roomId: number): void;
createRoomInstance(roomId: number, roomMap: IRoomMapData): void;
getRoomInstanceDisplay(roomId: number, id: number, width: number, height: number, scale: number): Container;
setRoomInstanceRenderingCanvasScale(roomId: number, canvasId: number, scale: number, point?: Point, offsetPoint?: Point, override?: boolean, asDelta?: boolean): void;
setRoomInstanceRenderingCanvasScale(roomId: number, canvasId: number, level: number, point?: Point, offsetPoint?: Point, isFlipForced?: boolean): void;
setRoomInstanceRenderingCanvasMask(roomId: number, canvasId: number, flag: boolean): void;
getRoomInstanceRenderingCanvas(roomId: number, canvasId?: number): IRoomRenderingCanvas;
getRoomInstanceRenderingCanvasOffset(roomId: number, canvasId?: number): Point;

View File

@ -9,7 +9,7 @@ export interface IRoomRenderingCanvas
dispose(): void;
initialize(width: number, height: number): void;
setMask(flag: boolean): void;
setScale(scale: number, point?: Point, offsetPoint?: Point, override?: boolean, asDelta?: boolean): void;
setScale(scale: number, point?: Point, offsetPoint?: Point, isFlipForced?: boolean): void;
render(time: number, update?: boolean): void;
update(): void;
setMouseListener(listener: IRoomCanvasMouseListener): void;

View File

@ -271,8 +271,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
if(!avatarCanvas) return null;
const container = this.buildAvatarContainer(avatarCanvas, setType);
if(this._activeTexture && ((this._activeTexture.width !== avatarCanvas.width) || (this._activeTexture.height !== avatarCanvas.height)))
{
GetTexturePool().putTexture(this._activeTexture);
@ -284,6 +282,10 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
if(!this._activeTexture) return null;
this._activeTexture.source.scaleMode = 'nearest';
const container = this.buildAvatarContainer(avatarCanvas, setType);
GetRenderer().render({
target: this._activeTexture,
container: container,
@ -323,6 +325,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
return this.buildAvatarContainer(avatarCanvas, setType);
}
// TODO this needs to be added still
public applyPalette(texture: RenderTexture, reds: number[] = [], greens: number[] = [], blues: number[] = []): RenderTexture
{
const textureCanvas = TextureUtils.generateCanvas(texture);

View File

@ -5,16 +5,14 @@ export class RoomZoomEvent extends RoomEngineEvent
public static ROOM_ZOOM: string = 'REE_ROOM_ZOOM';
private _level: number;
private _forceFlip: boolean;
private _asDelta: boolean;
private _isFlipForced: boolean;
constructor(roomId: number, level: number, forceFlip: boolean = false, asDelta: boolean = false)
constructor(roomId: number, level: number, isFlipForced: boolean = false)
{
super(RoomZoomEvent.ROOM_ZOOM, roomId);
this._level = level;
this._forceFlip = forceFlip;
this._asDelta = asDelta;
this._isFlipForced = isFlipForced;
}
public get level(): number
@ -22,13 +20,8 @@ export class RoomZoomEvent extends RoomEngineEvent
return this._level;
}
public get forceFlip(): boolean
public get isFlipForced(): boolean
{
return this._forceFlip;
return this._isFlipForced;
}
public get asDelta(): boolean
{
return this._asDelta;
}
}
}

View File

@ -356,16 +356,19 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
if(roomCanvas) roomCanvas.setMask(flag);
}
public setRoomInstanceRenderingCanvasScale(roomId: number, canvasId: number, scale: number, point: Point = null, offsetPoint: Point = null, override: boolean = false, asDelta: boolean = false): void
public setRoomInstanceRenderingCanvasScale(roomId: number, canvasId: number, level: number, point: Point = null, offsetPoint: Point = null, isFlipForced: boolean = false, flag: boolean = false): void
{
if(!GetConfiguration().getValue('room.zoom.enabled', true)) return;
if(!flag) level = ((isFlipForced) ? -1 : ((level) < 1) ? 0.5 : Math.floor(level));
const roomCanvas = this.getRoomInstanceRenderingCanvas(roomId, canvasId);
if(roomCanvas)
{
roomCanvas.setScale(scale, point, offsetPoint, override, asDelta);
if(!roomCanvas) return;
GetEventDispatcher().dispatchEvent(new RoomEngineEvent(RoomEngineEvent.ROOM_ZOOMED, roomId));
}
roomCanvas.setScale(level, point, offsetPoint, isFlipForced);
GetEventDispatcher().dispatchEvent(new RoomEngineEvent(RoomEngineEvent.ROOM_ZOOMED, roomId));
}
public getRoomInstanceRenderingCanvas(roomId: number, canvasId: number = -1): IRoomRenderingCanvas

View File

@ -12,7 +12,10 @@ export class RoomPlane implements IRoomPlane
{
public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
public static VERTICAL_ANGLE_DEFAULT: number = 30;
public static PLANE_GEOMETRY: IRoomGeometry = new RoomGeometry(64, new Vector3d(RoomPlane.HORIZONTAL_ANGLE_DEFAULT, RoomPlane.VERTICAL_ANGLE_DEFAULT), new Vector3d(-10, 0, 0));
public static PLANE_GEOMETRY: { [index: number]: IRoomGeometry } = {
'32': new RoomGeometry(32, new Vector3d(RoomPlane.HORIZONTAL_ANGLE_DEFAULT, RoomPlane.VERTICAL_ANGLE_DEFAULT), new Vector3d(-10, 0, 0)),
'64': new RoomGeometry(64, new Vector3d(RoomPlane.HORIZONTAL_ANGLE_DEFAULT, RoomPlane.VERTICAL_ANGLE_DEFAULT), new Vector3d(-10, 0, 0))
};
private static LANDSCAPE_COLOR: number = 0x0082F0;
public static TYPE_UNDEFINED: number = 0;
@ -195,6 +198,7 @@ export class RoomPlane implements IRoomPlane
Randomizer.setSeed(this._randomSeed);
const planeGeometry = RoomPlane.PLANE_GEOMETRY[geometry.scale];
let width = (this._leftSide.length * geometry.scale);
let height = (this._rightSide.length * geometry.scale);
const normal = geometry.getCoordinatePosition(this._normal);
@ -206,7 +210,7 @@ export class RoomPlane implements IRoomPlane
const roomCollection = GetAssetManager().getCollection('room');
const planeVisualizationData = roomCollection?.data?.roomVisualization?.[dataType];
const plane = planeVisualizationData?.planes?.find(plane => (plane.id === planeId));
const planeVisualization = (dataType === 'landscapeData') ? plane?.animatedVisualization?.[0] : plane?.visualizations?.[0];
const planeVisualization = ((dataType === 'landscapeData') ? plane?.animatedVisualization : plane?.visualizations)?.find(visualization => (visualization.size === planeGeometry.scale)) ?? null;
const planeLayer = planeVisualization?.allLayers?.[0] as IAssetPlaneVisualizationLayer;
const planeMaterialId = planeLayer?.materialId;
const planeColor = planeLayer?.color;
@ -222,9 +226,9 @@ export class RoomPlane implements IRoomPlane
switch(this._type)
{
case RoomPlane.TYPE_FLOOR: {
const _local_10 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 0, 0));
const _local_11 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, (height / RoomPlane.PLANE_GEOMETRY.scale), 0));
const _local_12 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d((width / RoomPlane.PLANE_GEOMETRY.scale), 0, 0));
const _local_10 = planeGeometry.getScreenPoint(new Vector3d(0, 0, 0));
const _local_11 = planeGeometry.getScreenPoint(new Vector3d(0, (height / planeGeometry.scale), 0));
const _local_12 = planeGeometry.getScreenPoint(new Vector3d((width / planeGeometry.scale), 0, 0));
let x = 0;
let y = 0;
@ -234,7 +238,7 @@ export class RoomPlane implements IRoomPlane
width = Math.round(Math.abs((_local_10.x - _local_12.x)));
height = Math.round(Math.abs((_local_10.x - _local_11.x)));
const _local_15 = (_local_10.x - RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(1, 0, 0)).x);
const _local_15 = (_local_10.x - planeGeometry.getScreenPoint(new Vector3d(1, 0, 0)).x);
x = (this._textureOffsetX * Math.trunc(Math.abs(_local_15)));
y = (this._textureOffsetY * Math.trunc(Math.abs(_local_15)));
@ -261,9 +265,9 @@ export class RoomPlane implements IRoomPlane
break;
}
case RoomPlane.TYPE_WALL: {
const _local_8 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 0, 0));
const _local_9 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 0, (height / RoomPlane.PLANE_GEOMETRY.scale)));
const _local_10 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, (width / RoomPlane.PLANE_GEOMETRY.scale), 0));
const _local_8 = planeGeometry.getScreenPoint(new Vector3d(0, 0, 0));
const _local_9 = planeGeometry.getScreenPoint(new Vector3d(0, 0, (height / planeGeometry.scale)));
const _local_10 = planeGeometry.getScreenPoint(new Vector3d(0, (width / planeGeometry.scale), 0));
if(_local_8 && _local_9 && _local_10)
{
@ -285,19 +289,18 @@ export class RoomPlane implements IRoomPlane
break;
}
case RoomPlane.TYPE_LANDSCAPE: {
const _local_13 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 0, 0));
const _local_14 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 0, 1));
const _local_15 = RoomPlane.PLANE_GEOMETRY.getScreenPoint(new Vector3d(0, 1, 0));
const _local_13 = planeGeometry.getScreenPoint(new Vector3d(0, 0, 0));
const _local_14 = planeGeometry.getScreenPoint(new Vector3d(0, 0, 1));
const _local_15 = planeGeometry.getScreenPoint(new Vector3d(0, 1, 0));
if(_local_13 && _local_14 && _local_15)
{
width = Math.round(Math.abs((((_local_13.x - _local_15.x) * width) / RoomPlane.PLANE_GEOMETRY.scale)));
height = Math.round(Math.abs((((_local_13.y - _local_14.y) * height) / RoomPlane.PLANE_GEOMETRY.scale)));
width = Math.round(Math.abs((((_local_13.x - _local_15.x) * width) / planeGeometry.scale)));
height = Math.round(Math.abs((((_local_13.y - _local_14.y) * height) / planeGeometry.scale)));
}
const renderMaxX = Math.trunc(this._textureMaxX * Math.abs((_local_13.x - _local_15.x)));
const renderMaxY = Math.trunc(this._textureMaxY * Math.abs((_local_13.y - _local_14.y)));
const renderOffsetX = Math.trunc(this._textureOffsetX * Math.abs((_local_13.x - _local_15.x)));
const renderOffsetY = Math.trunc(this._textureOffsetY * Math.abs((_local_13.y - _local_14.y)));

View File

@ -234,7 +234,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
}
}
public setScale(scale: number, point: Point = null, offsetPoint: Point = null): void
public setScale(scale: number, point: Point = null, offsetPoint: Point = null, isFlipForced: boolean = false): void
{
if(!this._master || !this._display) return;