mdx-m3-viewer
Version:
A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.
40 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const binarystream_1 = require("../../../common/binarystream");
const modificationtable_1 = require("./modificationtable");
/**
* war3map.w3u - the unit modification file.
*
* Also used for war3map.w3t (items), war3map.w3b (destructibles), and war3map.w3h (buffs).
*/
class War3MapW3u {
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, false);
this.customTable.load(stream, false);
}
save() {
const stream = new binarystream_1.default(new ArrayBuffer(this.getByteLength()));
stream.writeInt32(this.version);
this.originalTable.save(stream, false);
this.customTable.save(stream, false);
return stream.uint8array;
}
getByteLength() {
return 4 + this.originalTable.getByteLength(false) + this.customTable.getByteLength(false);
}
}
exports.default = War3MapW3u;
//# sourceMappingURL=file.js.map