From 9c20f7051780332e92203a475683de3ddbf93413 Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Tue, 24 Dec 2024 22:40:12 +0100 Subject: [PATCH] feat: improve support for Buffer.buffer --- src/amb/AMB.ts | 2 +- src/amb/AmbHeader.ts | 2 +- src/amb/Key.ts | 2 +- src/amb/Setting.ts | 2 +- src/amb/Track.ts | 2 +- src/common/BinaryIO.ts | 16 +++++++++------- src/common/Color.ts | 2 +- src/dlf/DLF.ts | 2 +- src/dlf/DlfHeader.ts | 2 +- src/dlf/Fog.ts | 2 +- src/dlf/InteactiveObject.ts | 2 +- src/dlf/Scene.ts | 2 +- src/dlf/ZoneAndPathHeader.ts | 2 +- src/dlf/ZoneAndPathPoint.ts | 2 +- src/ftl/Action.ts | 2 +- src/ftl/FTL.ts | 2 +- src/ftl/Face.ts | 2 +- src/ftl/FtlHeader.ts | 2 +- src/ftl/FtlTextureContainer.ts | 2 +- src/ftl/FtlVertex.ts | 2 +- src/ftl/Group.ts | 2 +- src/ftl/Selections.ts | 2 +- src/fts/Anchor.ts | 2 +- src/fts/AnchorData.ts | 2 +- src/fts/Cell.ts | 2 +- src/fts/EPData.ts | 2 +- src/fts/FTS.ts | 2 +- src/fts/FtsHeader.ts | 2 +- src/fts/Polygon.ts | 2 +- src/fts/Portal.ts | 2 +- src/fts/PortalPolygon.ts | 2 +- src/fts/Room.ts | 2 +- src/fts/RoomData.ts | 2 +- src/fts/RoomDistance.ts | 2 +- src/fts/SceneHeader.ts | 2 +- src/fts/SceneInfo.ts | 2 +- src/fts/TextureContainer.ts | 2 +- src/fts/TextureVertex.ts | 2 +- src/fts/UniqueHeader.ts | 2 +- src/fts/Vertex.ts | 2 +- src/llf/LLF.ts | 2 +- src/llf/Light.ts | 2 +- src/llf/LightingHeader.ts | 2 +- src/llf/LlfHeader.ts | 2 +- src/tea/NewKeyFrame.ts | 2 +- src/tea/OldKeyFrame.ts | 2 +- src/tea/TEA.ts | 2 +- src/tea/TeaHeader.ts | 2 +- 48 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/amb/AMB.ts b/src/amb/AMB.ts index 405bd4d..5cc68c3 100644 --- a/src/amb/AMB.ts +++ b/src/amb/AMB.ts @@ -8,7 +8,7 @@ export type ArxAMB = { } export class AMB { - static load(decompressedFile: ArrayBuffer): ArxAMB { + static load(decompressedFile: ArrayBufferLike): ArxAMB { const file = new BinaryIO(decompressedFile) const { numberOfTracks, isNewerVersion } = AmbHeader.readFrom(file) diff --git a/src/amb/AmbHeader.ts b/src/amb/AmbHeader.ts index 3db3541..1777867 100644 --- a/src/amb/AmbHeader.ts +++ b/src/amb/AmbHeader.ts @@ -11,7 +11,7 @@ export class AmbHeader { /** * @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/audio/Ambiance.cpp#L627 */ - static readFrom(binary: BinaryIO): ArxAmbHeader { + static readFrom(binary: BinaryIO): ArxAmbHeader { binary.readString(4) // identifier - always "GAMB" const version = binary.readUint32() diff --git a/src/amb/Key.ts b/src/amb/Key.ts index 704171f..37bb510 100644 --- a/src/amb/Key.ts +++ b/src/amb/Key.ts @@ -24,7 +24,7 @@ export class Key { /** * @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/audio/Ambiance.cpp#L187 */ - static readFrom(binary: BinaryIO): ArxKey { + static readFrom(binary: BinaryIO): ArxKey { binary.readUint32() // flags - always 0 return { diff --git a/src/amb/Setting.ts b/src/amb/Setting.ts index 3de8c0e..64759ed 100644 --- a/src/amb/Setting.ts +++ b/src/amb/Setting.ts @@ -24,7 +24,7 @@ export class Setting { /** * @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/audio/Ambiance.cpp#L107 */ - static readFrom(binary: BinaryIO): ArxSetting { + static readFrom(binary: BinaryIO): ArxSetting { return { min: binary.readFloat32(), max: binary.readFloat32(), diff --git a/src/amb/Track.ts b/src/amb/Track.ts index d4bea5b..20f22b6 100644 --- a/src/amb/Track.ts +++ b/src/amb/Track.ts @@ -25,7 +25,7 @@ export class Track { /** * @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/audio/Ambiance.cpp#L531 */ - static readFrom(binary: BinaryIO, isNewerVersion: boolean): ArxTrack { + static readFrom(binary: BinaryIO, isNewerVersion: boolean): ArxTrack { const filename = Track.toRelativePath(binary.readString()) if (isNewerVersion) { diff --git a/src/common/BinaryIO.ts b/src/common/BinaryIO.ts index 7c8919c..55a2060 100644 --- a/src/common/BinaryIO.ts +++ b/src/common/BinaryIO.ts @@ -2,7 +2,9 @@ import { decodeText, encodeText, repeat } from '@common/helpers.js' import { LITTLE_ENDIAN, TRUNCATE_ZERO_BYTES, KEEP_ZERO_BYTES, BYTE_OF_AN_UNKNOWN_CHAR } from '@common/constants.js' import { type ArxQuaternion, type ArxRotation, type ArxVector3 } from '@common/types.js' -export class BinaryIO extends DataView { +export class BinaryIO< + TArrayBuffer extends ArrayBufferLike & { BYTES_PER_ELEMENT?: never }, +> extends DataView { static sizeOfFloat32(): 4 { return 4 as const } @@ -85,7 +87,7 @@ export class BinaryIO extends DataView { public position: number // TODO: make this private - this needs to be public because of TEA - constructor(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number) { + constructor(buffer: TArrayBuffer, byteOffset?: number, byteLength?: number) { super(buffer, byteOffset, byteLength) this.position = 0 } @@ -244,13 +246,13 @@ export class BinaryIO extends DataView { this.position = this.position + BinaryIO.sizeOfUint8() } - writeUint8Array(values: number[] | ArrayBuffer): void { - if (values instanceof ArrayBuffer) { - new Uint8Array(values).forEach((value) => { + writeUint8Array(values: number[] | ArrayBufferLike): void { + if (Array.isArray(values)) { + values.forEach((value) => { this.writeUint8(value) }) } else { - values.forEach((value) => { + new Uint8Array(values).forEach((value) => { this.writeUint8(value) }) } @@ -379,7 +381,7 @@ export class BinaryIO extends DataView { this.writeFloat32Array([w, x, y, z]) } - writeBuffer(buffer: ArrayBuffer): void { + writeBuffer(buffer: ArrayBufferLike): void { this.writeUint8Array(buffer) } } diff --git a/src/common/Color.ts b/src/common/Color.ts index d9d5d63..81046e7 100644 --- a/src/common/Color.ts +++ b/src/common/Color.ts @@ -19,7 +19,7 @@ export type ArxColor = { } export class Color { - static readFrom(binary: BinaryIO, mode: ColorMode): ArxColor { + static readFrom(binary: BinaryIO, mode: ColorMode): ArxColor { if (mode === 'bgra') { const [b, g, r, a] = binary.readUint8Array(4) return { r, g, b, a: a / 255 } diff --git a/src/dlf/DLF.ts b/src/dlf/DLF.ts index 28fe860..308af2f 100644 --- a/src/dlf/DLF.ts +++ b/src/dlf/DLF.ts @@ -29,7 +29,7 @@ export type ArxDLF = { } export class DLF { - static load(decompressedFile: ArrayBuffer): ArxDLF { + static load(decompressedFile: ArrayBufferLike): ArxDLF { const file = new BinaryIO(decompressedFile) const { numberOfInteractiveObjects, numberOfFogs, numberOfZonesAndPaths, ...header } = DlfHeader.readFrom(file) diff --git a/src/dlf/DlfHeader.ts b/src/dlf/DlfHeader.ts index 0e210a1..f3eb698 100644 --- a/src/dlf/DlfHeader.ts +++ b/src/dlf/DlfHeader.ts @@ -19,7 +19,7 @@ export type ArxDlfHeader = { } export class DlfHeader { - static readFrom(binary: BinaryIO): ArxDlfHeader { + static readFrom(binary: BinaryIO): ArxDlfHeader { binary.readFloat32() // version - always 1.44 binary.readString(16) // identifier - always "DANAE_FILE" diff --git a/src/dlf/Fog.ts b/src/dlf/Fog.ts index 0c1a188..744bf8f 100644 --- a/src/dlf/Fog.ts +++ b/src/dlf/Fog.ts @@ -24,7 +24,7 @@ export type ArxFog = { } export class Fog { - static readFrom(binary: BinaryIO): ArxFog { + static readFrom(binary: BinaryIO): ArxFog { const dataBlock1 = { pos: binary.readVector3(), color: Color.readFrom(binary, 'rgb'), diff --git a/src/dlf/InteactiveObject.ts b/src/dlf/InteactiveObject.ts index ebb0c35..f4d1b4a 100644 --- a/src/dlf/InteactiveObject.ts +++ b/src/dlf/InteactiveObject.ts @@ -13,7 +13,7 @@ export type ArxInteractiveObject = { } export class InteractiveObject { - static readFrom(binary: BinaryIO): ArxInteractiveObject { + static readFrom(binary: BinaryIO): ArxInteractiveObject { const data: ArxInteractiveObject = { name: InteractiveObject.toRelativePath(binary.readString(512)), pos: binary.readVector3(), diff --git a/src/dlf/Scene.ts b/src/dlf/Scene.ts index d5bcf40..8334506 100644 --- a/src/dlf/Scene.ts +++ b/src/dlf/Scene.ts @@ -9,7 +9,7 @@ export type ArxScene = { } export class Scene { - static readFrom(binary: BinaryIO): ArxScene { + static readFrom(binary: BinaryIO): ArxScene { const levelIdx = Scene.pathToLevelIdx(binary.readString(512)) binary.readInt32Array(16) // pad - ? diff --git a/src/dlf/ZoneAndPathHeader.ts b/src/dlf/ZoneAndPathHeader.ts index 02738fc..3865e1c 100644 --- a/src/dlf/ZoneAndPathHeader.ts +++ b/src/dlf/ZoneAndPathHeader.ts @@ -46,7 +46,7 @@ export type ArxZoneAndPathHeader = { } export class ZoneAndPathHeader { - static readFrom(binary: BinaryIO): ArxZoneAndPathHeader { + static readFrom(binary: BinaryIO): ArxZoneAndPathHeader { const name = binary.readString(64) binary.readInt16() // idx - always 0 diff --git a/src/dlf/ZoneAndPathPoint.ts b/src/dlf/ZoneAndPathPoint.ts index ab5cc92..6b7e245 100644 --- a/src/dlf/ZoneAndPathPoint.ts +++ b/src/dlf/ZoneAndPathPoint.ts @@ -19,7 +19,7 @@ export type ArxZoneAndPathPoint = { } export class ZoneAndPathPoint { - static readFrom(binary: BinaryIO, pos: ArxVector3): ArxZoneAndPathPoint { + static readFrom(binary: BinaryIO, pos: ArxVector3): ArxZoneAndPathPoint { const rpos = binary.readVector3() const data = { pos: { diff --git a/src/ftl/Action.ts b/src/ftl/Action.ts index 1292a3e..57f64d3 100644 --- a/src/ftl/Action.ts +++ b/src/ftl/Action.ts @@ -9,7 +9,7 @@ export type ArxAction = { } export class Action { - static readFrom(binary: BinaryIO): ArxAction { + static readFrom(binary: BinaryIO): ArxAction { return { name: binary.readString(256), vertexIdx: binary.readInt32(), diff --git a/src/ftl/FTL.ts b/src/ftl/FTL.ts index d401032..145822a 100644 --- a/src/ftl/FTL.ts +++ b/src/ftl/FTL.ts @@ -27,7 +27,7 @@ export type ArxFTL = { } export class FTL { - static load(decompressedFile: ArrayBuffer): ArxFTL { + static load(decompressedFile: ArrayBufferLike): ArxFTL { const file = new BinaryIO(decompressedFile) const { diff --git a/src/ftl/Face.ts b/src/ftl/Face.ts index b19c4d4..1c3348f 100644 --- a/src/ftl/Face.ts +++ b/src/ftl/Face.ts @@ -24,7 +24,7 @@ export type ArxFace = { } export class Face { - static readFrom(binary: BinaryIO): ArxFace { + static readFrom(binary: BinaryIO): ArxFace { const faceType = binary.readInt32() binary.readUint32Array(3) // rgb - always [0, 0, 0] diff --git a/src/ftl/FtlHeader.ts b/src/ftl/FtlHeader.ts index dbd16d0..fba150a 100644 --- a/src/ftl/FtlHeader.ts +++ b/src/ftl/FtlHeader.ts @@ -15,7 +15,7 @@ export type ArxFtlHeader = { } export class FtlHeader { - static readFrom(binary: BinaryIO): ArxFtlHeader { + static readFrom(binary: BinaryIO): ArxFtlHeader { binary.readString(4) // identifier - always "FTL\0" binary.readFloat32() // version - always 0.832_570_016_384_124_8 binary.readString(512) // checksum - contains data, but ArxLibertatis doesn't read it diff --git a/src/ftl/FtlTextureContainer.ts b/src/ftl/FtlTextureContainer.ts index 1717859..b9053d6 100644 --- a/src/ftl/FtlTextureContainer.ts +++ b/src/ftl/FtlTextureContainer.ts @@ -7,7 +7,7 @@ export type ArxFtlTextureContainer = { } export class FtlTextureContainer { - static readFrom(binary: BinaryIO): ArxFtlTextureContainer { + static readFrom(binary: BinaryIO): ArxFtlTextureContainer { return { filename: TextureContainer.toRelativePath(binary.readString(256)), } diff --git a/src/ftl/FtlVertex.ts b/src/ftl/FtlVertex.ts index 6a6e571..b657ae1 100644 --- a/src/ftl/FtlVertex.ts +++ b/src/ftl/FtlVertex.ts @@ -8,7 +8,7 @@ export type ArxFtlVertex = { } export class FtlVertex { - static readFrom(binary: BinaryIO): ArxFtlVertex { + static readFrom(binary: BinaryIO): ArxFtlVertex { binary.readUint8Array(32) // unused return { diff --git a/src/ftl/Group.ts b/src/ftl/Group.ts index 3f2c2d1..1798438 100644 --- a/src/ftl/Group.ts +++ b/src/ftl/Group.ts @@ -9,7 +9,7 @@ export type ArxGroup = { } export class Group { - static readFrom(binary: BinaryIO): ArxGroup & { numberOfIndices: number } { + static readFrom(binary: BinaryIO): ArxGroup & { numberOfIndices: number } { const data = { name: binary.readString(256), origin: binary.readUint32(), diff --git a/src/ftl/Selections.ts b/src/ftl/Selections.ts index c9a50f2..e6675d7 100644 --- a/src/ftl/Selections.ts +++ b/src/ftl/Selections.ts @@ -7,7 +7,7 @@ export type ArxSelection = { } export class Selection { - static readFrom(binary: BinaryIO): ArxSelection & { numberOfSelected: number } { + static readFrom(binary: BinaryIO): ArxSelection & { numberOfSelected: number } { const data = { name: binary.readString(64), numberOfSelected: binary.readInt32(), diff --git a/src/fts/Anchor.ts b/src/fts/Anchor.ts index f5a7a86..d620283 100644 --- a/src/fts/Anchor.ts +++ b/src/fts/Anchor.ts @@ -7,7 +7,7 @@ export type ArxAnchor = { } export class Anchor { - static readFrom(binary: BinaryIO): ArxAnchor { + static readFrom(binary: BinaryIO): ArxAnchor { const { numberOfLinkedAnchors, ...anchorData } = AnchorData.readFrom(binary) return { diff --git a/src/fts/AnchorData.ts b/src/fts/AnchorData.ts index 26f6557..8154e9f 100644 --- a/src/fts/AnchorData.ts +++ b/src/fts/AnchorData.ts @@ -26,7 +26,7 @@ export type ArxAnchorData = { } export class AnchorData { - static readFrom(binary: BinaryIO): ArxAnchorData { + static readFrom(binary: BinaryIO): ArxAnchorData { const data: ArxAnchorData = { pos: binary.readVector3(), radius: binary.readFloat32(), diff --git a/src/fts/Cell.ts b/src/fts/Cell.ts index 5d7411a..5524d7d 100644 --- a/src/fts/Cell.ts +++ b/src/fts/Cell.ts @@ -9,7 +9,7 @@ export type ArxCell = { } export class Cell { - static readFrom(binary: BinaryIO): ArxCell { + static readFrom(binary: BinaryIO): ArxCell { const { numberOfPolygons, numberOfAnchors } = SceneInfo.readFrom(binary) const data: ArxCell = { diff --git a/src/fts/EPData.ts b/src/fts/EPData.ts index e8ee0a6..7b1ff04 100644 --- a/src/fts/EPData.ts +++ b/src/fts/EPData.ts @@ -13,7 +13,7 @@ export type ArxEPData = { } export class EPData { - static readFrom(binary: BinaryIO): ArxEPData { + static readFrom(binary: BinaryIO): ArxEPData { const [px, py, idx] = binary.readInt16Array(4) return { cellX: px, cellY: py, polygonIdx: idx } } diff --git a/src/fts/FTS.ts b/src/fts/FTS.ts index 729456e..8d715e3 100644 --- a/src/fts/FTS.ts +++ b/src/fts/FTS.ts @@ -40,7 +40,7 @@ export type ArxFTS = { const IS_AN_UNCOMPRESSED_FTS = 0 export class FTS { - static load(decompressedFile: ArrayBuffer): ArxFTS { + static load(decompressedFile: ArrayBufferLike): ArxFTS { const file = new BinaryIO(decompressedFile) const { numberOfUniqueHeaders, ...header } = FtsHeader.readFrom(file) diff --git a/src/fts/FtsHeader.ts b/src/fts/FtsHeader.ts index 428d1a6..19c3fb0 100644 --- a/src/fts/FtsHeader.ts +++ b/src/fts/FtsHeader.ts @@ -12,7 +12,7 @@ export type ArxFtsHeader = { } export class FtsHeader { - static readFrom(binary: BinaryIO): ArxFtsHeader { + static readFrom(binary: BinaryIO): ArxFtsHeader { const path = binary.readString(256) const data: ArxFtsHeader = { diff --git a/src/fts/Polygon.ts b/src/fts/Polygon.ts index 648501a..0e58d3a 100644 --- a/src/fts/Polygon.ts +++ b/src/fts/Polygon.ts @@ -71,7 +71,7 @@ export type ArxPolygon = { } export class Polygon { - static readFrom(binary: BinaryIO): ArxPolygon { + static readFrom(binary: BinaryIO): ArxPolygon { return { vertices: times(() => { return Vertex.readFrom(binary) diff --git a/src/fts/Portal.ts b/src/fts/Portal.ts index a73b42e..4e23b7b 100644 --- a/src/fts/Portal.ts +++ b/src/fts/Portal.ts @@ -13,7 +13,7 @@ export type ArxPortal = { } export class Portal { - static readFrom(binary: BinaryIO): ArxPortal { + static readFrom(binary: BinaryIO): ArxPortal { return { polygon: PortalPolygon.readFrom(binary), room1: binary.readInt32(), // facing normal diff --git a/src/fts/PortalPolygon.ts b/src/fts/PortalPolygon.ts index 8d60bf6..9f2f75c 100644 --- a/src/fts/PortalPolygon.ts +++ b/src/fts/PortalPolygon.ts @@ -37,7 +37,7 @@ export type ArxPortalPolygon = { } export class PortalPolygon { - static readFrom(binary: BinaryIO): ArxPortalPolygon { + static readFrom(binary: BinaryIO): ArxPortalPolygon { binary.readInt32() // type - in 2 occasions on level 2 it's 0, all other cases it's 64 (ArxPolygonFlags.Quad) const dataBlock = { diff --git a/src/fts/Room.ts b/src/fts/Room.ts index ce1077a..fa93d61 100644 --- a/src/fts/Room.ts +++ b/src/fts/Room.ts @@ -9,7 +9,7 @@ export type ArxRoom = { } export class Room { - static readFrom(binary: BinaryIO): ArxRoom { + static readFrom(binary: BinaryIO): ArxRoom { const { numberOfPortals, numberOfPolygons } = RoomData.readFrom(binary) return { diff --git a/src/fts/RoomData.ts b/src/fts/RoomData.ts index 98f221a..78cfbd2 100644 --- a/src/fts/RoomData.ts +++ b/src/fts/RoomData.ts @@ -11,7 +11,7 @@ export type ArxRoomData = { } export class RoomData { - static readFrom(binary: BinaryIO): ArxRoomData { + static readFrom(binary: BinaryIO): ArxRoomData { const data: ArxRoomData = { numberOfPortals: binary.readInt32(), numberOfPolygons: binary.readInt32(), diff --git a/src/fts/RoomDistance.ts b/src/fts/RoomDistance.ts index 25a8ee2..84b32ee 100644 --- a/src/fts/RoomDistance.ts +++ b/src/fts/RoomDistance.ts @@ -11,7 +11,7 @@ export type ArxRoomDistance = { } export class RoomDistance { - static readFrom(binary: BinaryIO): ArxRoomDistance { + static readFrom(binary: BinaryIO): ArxRoomDistance { return { distance: binary.readFloat32(), // -1 means use truedist startPosition: binary.readVector3(), diff --git a/src/fts/SceneHeader.ts b/src/fts/SceneHeader.ts index f5fca95..4f7a638 100644 --- a/src/fts/SceneHeader.ts +++ b/src/fts/SceneHeader.ts @@ -17,7 +17,7 @@ export type ArxSceneHeader = { } export class SceneHeader { - static readFrom(binary: BinaryIO): ArxSceneHeader { + static readFrom(binary: BinaryIO): ArxSceneHeader { binary.readFloat32() // version - always 0.14100000262260437 binary.readInt32() // sizeX - always 160 binary.readInt32() // sizeZ - always 160 diff --git a/src/fts/SceneInfo.ts b/src/fts/SceneInfo.ts index 834ee24..f604d46 100644 --- a/src/fts/SceneInfo.ts +++ b/src/fts/SceneInfo.ts @@ -10,7 +10,7 @@ export type ArxSceneInfo = { } export class SceneInfo { - static readFrom(binary: BinaryIO): ArxSceneInfo { + static readFrom(binary: BinaryIO): ArxSceneInfo { return { numberOfPolygons: binary.readInt32(), numberOfAnchors: binary.readInt32(), diff --git a/src/fts/TextureContainer.ts b/src/fts/TextureContainer.ts index c109f49..084c860 100644 --- a/src/fts/TextureContainer.ts +++ b/src/fts/TextureContainer.ts @@ -9,7 +9,7 @@ export type ArxTextureContainer = { } export class TextureContainer { - static readFrom(binary: BinaryIO): ArxTextureContainer { + static readFrom(binary: BinaryIO): ArxTextureContainer { const id = binary.readInt32() binary.readInt32() // temp - always 0 diff --git a/src/fts/TextureVertex.ts b/src/fts/TextureVertex.ts index d0d6fe6..827bf10 100644 --- a/src/fts/TextureVertex.ts +++ b/src/fts/TextureVertex.ts @@ -52,7 +52,7 @@ export type ArxTextureVertex = { } export class TextureVertex { - static readFrom(binary: BinaryIO): ArxTextureVertex { + static readFrom(binary: BinaryIO): ArxTextureVertex { const data = { pos: binary.readVector3(), rhw: binary.readFloat32(), diff --git a/src/fts/UniqueHeader.ts b/src/fts/UniqueHeader.ts index 81f8de8..a7058b0 100644 --- a/src/fts/UniqueHeader.ts +++ b/src/fts/UniqueHeader.ts @@ -12,7 +12,7 @@ export type ArxUniqueHeader = { } export class UniqueHeader { - static readFrom(binary: BinaryIO): ArxUniqueHeader { + static readFrom(binary: BinaryIO): ArxUniqueHeader { return { path: binary.readString(256), check: binary.readUint8Array(512), diff --git a/src/fts/Vertex.ts b/src/fts/Vertex.ts index 6bc8ad5..1399441 100644 --- a/src/fts/Vertex.ts +++ b/src/fts/Vertex.ts @@ -13,7 +13,7 @@ export type ArxVertex = { } export class Vertex { - static readFrom(binary: BinaryIO): ArxVertex { + static readFrom(binary: BinaryIO): ArxVertex { // y before x is not a typo! const [y, x, z, u, v] = binary.readFloat32Array(5) return { x, y, z, u, v } diff --git a/src/llf/LLF.ts b/src/llf/LLF.ts index a4bfa1e..faf2995 100644 --- a/src/llf/LLF.ts +++ b/src/llf/LLF.ts @@ -12,7 +12,7 @@ export type ArxLLF = { } export class LLF { - static load(decompressedFile: ArrayBuffer): ArxLLF { + static load(decompressedFile: ArrayBufferLike): ArxLLF { const file = new BinaryIO(decompressedFile) const { numberOfLights, ...header } = LlfHeader.readFrom(file) diff --git a/src/llf/Light.ts b/src/llf/Light.ts index 2ee31ed..d2187fd 100644 --- a/src/llf/Light.ts +++ b/src/llf/Light.ts @@ -172,7 +172,7 @@ export type ArxLight = { } export class Light { - static readFrom(binary: BinaryIO): ArxLight { + static readFrom(binary: BinaryIO): ArxLight { const dataBlock1 = { pos: binary.readVector3(), color: Color.readFrom(binary, 'rgb'), diff --git a/src/llf/LightingHeader.ts b/src/llf/LightingHeader.ts index 5941171..4b3de69 100644 --- a/src/llf/LightingHeader.ts +++ b/src/llf/LightingHeader.ts @@ -9,7 +9,7 @@ export type ArxLightingHeader = { } export class LightingHeader { - static readFrom(binary: BinaryIO): ArxLightingHeader { + static readFrom(binary: BinaryIO): ArxLightingHeader { const numberOfColors = binary.readInt32() binary.readInt32() // view mode - unused diff --git a/src/llf/LlfHeader.ts b/src/llf/LlfHeader.ts index d7972a0..af105b1 100644 --- a/src/llf/LlfHeader.ts +++ b/src/llf/LlfHeader.ts @@ -14,7 +14,7 @@ export type ArxLlfHeader = { } export class LlfHeader { - static readFrom(binary: BinaryIO): ArxLlfHeader { + static readFrom(binary: BinaryIO): ArxLlfHeader { binary.readFloat32() // version - always 1.44 binary.readString(16) // identifier - always "DANAE_LLH_FILE" diff --git a/src/tea/NewKeyFrame.ts b/src/tea/NewKeyFrame.ts index 5f0a694..71de69e 100644 --- a/src/tea/NewKeyFrame.ts +++ b/src/tea/NewKeyFrame.ts @@ -11,7 +11,7 @@ export type ArxNewKeyFrame = ArxOldKeyFrame & { } export class NewKeyFrame { - static readFrom(binary: BinaryIO): ArxNewKeyFrame { + static readFrom(binary: BinaryIO): ArxNewKeyFrame { return { num_frame: binary.readInt32(), flag_frame: binary.readInt32(), diff --git a/src/tea/OldKeyFrame.ts b/src/tea/OldKeyFrame.ts index 44276e5..c5dde0f 100644 --- a/src/tea/OldKeyFrame.ts +++ b/src/tea/OldKeyFrame.ts @@ -16,7 +16,7 @@ export type ArxOldKeyFrame = { } export class OldKeyFrame { - static readFrom(binary: BinaryIO): ArxOldKeyFrame { + static readFrom(binary: BinaryIO): ArxOldKeyFrame { return { num_frame: binary.readInt32(), flag_frame: binary.readInt32(), diff --git a/src/tea/TEA.ts b/src/tea/TEA.ts index 71c744e..e6a4cd1 100644 --- a/src/tea/TEA.ts +++ b/src/tea/TEA.ts @@ -26,7 +26,7 @@ export type ArxTEA = { } export class TEA { - static load(decompressedFile: ArrayBuffer): ArxTEA { + static load(decompressedFile: ArrayBufferLike): ArxTEA { const file = new BinaryIO(decompressedFile) const { numberOfKeyFrames, numberOfGroups, ...header } = TeaHeader.readFrom(file) diff --git a/src/tea/TeaHeader.ts b/src/tea/TeaHeader.ts index 365fa47..8276935 100644 --- a/src/tea/TeaHeader.ts +++ b/src/tea/TeaHeader.ts @@ -15,7 +15,7 @@ export type ArxTeaHeader = { } export class TeaHeader { - static readFrom(binary: BinaryIO): ArxTeaHeader { + static readFrom(binary: BinaryIO): ArxTeaHeader { return { ident: binary.readString(20), version: binary.readUint32(),