diff --git a/src/Polygon.ts b/src/Polygon.ts index afd2523f..99d74510 100644 --- a/src/Polygon.ts +++ b/src/Polygon.ts @@ -10,6 +10,8 @@ import { ArxVertexWithColor } from '@src/types.js' export type TransparencyType = 'multiplicative' | 'additive' | 'blended' | 'subtractive' +const DEFAULT_ROOM_ID = 1 + type PolygonConfig = { /** setting this to true will prevent calculation of norm, norm2 and normals properties */ areNormalsCalculated: boolean @@ -64,7 +66,7 @@ export class Polygon { this.normals = props.normals this.transval = props.transval ?? 0 this.area = props.area ?? 0 - this.room = props.room ?? 1 + this.room = props.room ?? DEFAULT_ROOM_ID this.paddy = props.paddy this.config = { ...this.config, ...(props.config ?? {}) } } diff --git a/src/Polygons.ts b/src/Polygons.ts index 6a5ec517..a8f6e3d6 100644 --- a/src/Polygons.ts +++ b/src/Polygons.ts @@ -22,6 +22,10 @@ export type MeshImportProps = { tryToQuadify?: typeof QUADIFY | typeof DONT_QUADIFY shading?: typeof SHADING_FLAT | typeof SHADING_SMOOTH flags?: ArxPolygonFlags + /** + * room id - used when a map has portals, default value is undefined (the Polygon constructor will handle it) + */ + room?: number } type TextureContainer = ArxTextureContainer & { remaining: number; maxRemaining: number } @@ -140,7 +144,7 @@ export class Polygons extends Array { applyTransformations(threeJsObj) } - const { tryToQuadify = QUADIFY, shading = SHADING_FLAT, flags = ArxPolygonFlags.None } = meshImportProps + const { tryToQuadify = QUADIFY, shading = SHADING_FLAT, flags = ArxPolygonFlags.None, room } = meshImportProps const polygons = new Polygons() if (threeJsObj instanceof Mesh) { @@ -221,6 +225,7 @@ export class Polygons extends Array { texture: currentTexture, flags: currentTexture instanceof Material ? currentTexture.flags | flags : flags, isQuad: true, + room, }) if (currentTexture instanceof Material && currentTexture.opacity !== 100) { polygon.setOpacity(currentTexture.opacity, currentTexture.opacityMode)