UNPKG

mdx-m3-viewer

Version:

A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.

40 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const binarystream_1 = require("../../../common/binarystream"); const modificationtable_1 = require("../w3u/modificationtable"); /** * war3map.w3d - the doodad modification file. * * Also used for war3map.w3a (abilities), and war3map.w3q (upgrades). */ class War3MapW3d { constructor() { this.version = 0; this.originalTable = new modificationtable_1.default(); this.customTable = new modificationtable_1.default(); } load(bufferOrStream) { let stream; if (bufferOrStream instanceof binarystream_1.default) { stream = bufferOrStream; } else { stream = new binarystream_1.default(bufferOrStream); } this.version = stream.readInt32(); this.originalTable.load(stream, true); this.customTable.load(stream, true); } save() { const stream = new binarystream_1.default(new ArrayBuffer(this.getByteLength())); stream.writeInt32(this.version); this.originalTable.save(stream, true); this.customTable.save(stream, true); return stream.uint8array; } getByteLength() { return 4 + this.originalTable.getByteLength(true) + this.customTable.getByteLength(true); } } exports.default = War3MapW3d; //# sourceMappingURL=file.js.map