More plane updates

This commit is contained in:
billsonnn 2024-03-26 21:27:28 -04:00
parent 2ef9d01fa4
commit fe20138abf
3 changed files with 7 additions and 19 deletions

View File

@ -13,6 +13,7 @@ export class RoomPlane implements IRoomPlane
public static HORIZONTAL_ANGLE_DEFAULT: number = 45; public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
public static VERTICAL_ANGLE_DEFAULT: number = 30; 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: IRoomGeometry = 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; public static TYPE_UNDEFINED: number = 0;
public static TYPE_WALL: number = 1; public static TYPE_WALL: number = 1;
@ -121,12 +122,10 @@ export class RoomPlane implements IRoomPlane
this._disposed = true; this._disposed = true;
} }
public update(geometry: IRoomGeometry, timeSinceStartMs: number): boolean public update(geometry: IRoomGeometry, timeSinceStartMs: number, needsUpdate: boolean = false): boolean
{ {
if(!geometry || this._disposed) return false; if(!geometry || this._disposed) return false;
let needsUpdate = false;
if(this._geometryUpdateId !== geometry.updateId) if(this._geometryUpdateId !== geometry.updateId)
{ {
this._geometryUpdateId = geometry.updateId; this._geometryUpdateId = geometry.updateId;
@ -200,17 +199,6 @@ export class RoomPlane implements IRoomPlane
let height = (this._rightSide.length * geometry.scale); let height = (this._rightSide.length * geometry.scale);
const normal = geometry.getCoordinatePosition(this._normal); const normal = geometry.getCoordinatePosition(this._normal);
const getRandomColor = () =>
{
const letters = '0123456789ABCDEF';
let color = '0x';
for(let i = 0; i < 6; i++)
{
color += letters[Math.floor(Math.random() * 16)];
}
return parseInt(color, 16);
};
const getTextureAndColorForPlane = (planeId: string, planeType: number) => const getTextureAndColorForPlane = (planeId: string, planeType: number) =>
{ {
const dataType: keyof IAssetRoomVisualizationData = (planeType === RoomPlane.TYPE_FLOOR) ? 'floorData' : (planeType === RoomPlane.TYPE_WALL) ? 'wallData' : 'landscapeData'; const dataType: keyof IAssetRoomVisualizationData = (planeType === RoomPlane.TYPE_FLOOR) ? 'floorData' : (planeType === RoomPlane.TYPE_WALL) ? 'wallData' : 'landscapeData';
@ -321,7 +309,7 @@ export class RoomPlane implements IRoomPlane
x: renderOffsetX, x: renderOffsetX,
y: renderOffsetY y: renderOffsetY
}, },
tint: getRandomColor() tint: RoomPlane.LANDSCAPE_COLOR
}); });
break; break;
} }

View File

@ -141,7 +141,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
if(this.updatePlaneTexturesAndVisibilities(objectModel)) needsUpdate = true; if(this.updatePlaneTexturesAndVisibilities(objectModel)) needsUpdate = true;
if(this.updatePlanes(geometry, geometryUpdate, time)) needsUpdate = true; if(this.updatePlanes(geometry, geometryUpdate, time, needsUpdate)) needsUpdate = true;
if(needsUpdate) if(needsUpdate)
{ {
@ -576,7 +576,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
return true; return true;
} }
protected updatePlanes(geometry: IRoomGeometry, geometryUpdate: boolean, timeSinceStartMs: number): boolean protected updatePlanes(geometry: IRoomGeometry, geometryUpdate: boolean, timeSinceStartMs: number, needsUpdate: boolean = false): boolean
{ {
if(!geometry || !this.object) return false; if(!geometry || !this.object) return false;
@ -614,7 +614,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
{ {
sprite.id = plane.uniqueId; sprite.id = plane.uniqueId;
if(plane.update(geometry, timeSinceStartMs)) if(plane.update(geometry, timeSinceStartMs, needsUpdate))
{ {
if(plane.visible) if(plane.visible)
{ {

View File

@ -155,7 +155,7 @@ export class PlaneMaskManager
if(!texture) return true; if(!texture) return true;
const point = new Point(Math.round(posX) + asset.offsetX, Math.round(posY) + asset.offsetY); const point = new Point((posX + asset.offsetX), (posY + asset.offsetY));
const matrix = new Matrix(); const matrix = new Matrix();