diff --git a/src/CompositeTilemap.ts b/src/CompositeTilemap.ts index 5b6ef0a..7158d08 100644 --- a/src/CompositeTilemap.ts +++ b/src/CompositeTilemap.ts @@ -74,10 +74,10 @@ export class CompositeTilemap extends Container * The animation frame vector specifies which animation frame texture to use. If the x/y coordinate is * larger than the `animCountX` or `animCountY` for a specific tile, the modulus is taken. */ - public tileAnim: [number, number] = null; + public tileAnim: [number, number] | null = null; /** The last modified tilemap. */ - protected lastModifiedTilemap: Tilemap = null; + protected lastModifiedTilemap: Tilemap | null = null; private modificationMarker = 0; // private shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]); @@ -103,7 +103,7 @@ export class CompositeTilemap extends Container * * @param tileTextures - The list of tile textures that make up the tileset. */ - tileset(tileTextures: Array): this + tileset(tileTextures?: Array): this { if (!tileTextures) { @@ -233,7 +233,7 @@ export class CompositeTilemap extends Container } = {} ): this { - let tilemap: Tilemap = null; + let tilemap: Tilemap | null = null; const children = this.children; this.lastModifiedTilemap = null; diff --git a/src/TileTextureArray.ts b/src/TileTextureArray.ts index b490007..943abaa 100644 --- a/src/TileTextureArray.ts +++ b/src/TileTextureArray.ts @@ -16,11 +16,11 @@ export class TileTextureArray count = 0; dirty = false; dirty_gpu = false; - bind_group: BindGroup = null; + bind_group: BindGroup | null = null; bind_group_resources: any = {}; - tex_sizes: Float32Array = null; + tex_sizes: Float32Array; null_color: Float32Array = new Float32Array([0, 0, 0, 0.5]); - tex_buf: Buffer = null; + tex_buf: Buffer; get length() { diff --git a/src/Tilemap.ts b/src/Tilemap.ts index c8b8568..227b4cd 100644 --- a/src/Tilemap.ts +++ b/src/Tilemap.ts @@ -94,7 +94,7 @@ export class Tilemap extends ViewContainer * * @see CompositeTilemap.tileAnim */ - public tileAnim: [number, number] = null; + public tileAnim: [number, number] | null = null; /** * This is the last uploaded size of the tilemap geometry. @@ -134,7 +134,7 @@ export class Tilemap extends ViewContainer this._bounds.maxY = bounds.maxY; } - public batched: boolean; + public batched = false; /** * @param tileset - The tileset to use for the tilemap. This can be reset later with {@link Tilemap.setTileset}. The @@ -401,10 +401,10 @@ export class Tilemap extends ViewContainer } private vbId = 0; - vb: TilemapGeometry = null; - private vbBuffer: ArrayBuffer = null; - private vbArray: Float32Array = null; - private vbInts: Uint32Array = null; + vb: TilemapGeometry | null = null; + private vbBuffer: ArrayBuffer | null = null; + private vbArray: Float32Array | null = null; + private vbInts: Uint32Array | null = null; private destroyVb(): void { @@ -459,8 +459,8 @@ export class Tilemap extends ViewContainer this.vbInts = new Uint32Array(this.vbBuffer); } - const arr = this.vbArray; - const ints = this.vbInts; + const arr = this.vbArray ?? new Float32Array(this.vbBuffer); + const ints = this.vbInts ?? new Uint32Array(this.vbBuffer); let sz = 0; let textureId = 0; diff --git a/src/TilemapPipe.ts b/src/TilemapPipe.ts index f5c930d..e9b3b4b 100644 --- a/src/TilemapPipe.ts +++ b/src/TilemapPipe.ts @@ -52,10 +52,10 @@ export class TilemapPipe implements RenderPipe, InstructionPipe, InstructionPipe, InstructionPipe, InstructionPipe