unreal.js
Version:
A pak reader for games like VALORANT & Fortnite written in Node.JS
59 lines (58 loc) • 2.52 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FRawStaticIndexBuffer = void 0;
const FArchive_1 = require("../../../reader/FArchive");
const Versions_1 = require("../../../versions/Versions");
const FByteArchive_1 = require("../../../reader/FByteArchive");
class FRawStaticIndexBuffer {
constructor(...args) {
const arg = args[0];
if (arg != null) {
if (arg instanceof FArchive_1.FArchive) {
if (arg.ver < Versions_1.VER_UE4_SUPPORT_32BIT_STATIC_MESH_INDICES) {
this.indices16 = arg.readBulkArray(() => arg.readUInt16());
this.indices32 = [];
}
else {
// serialize all indices as byte array
const is32Bit = arg.readBoolean();
const data = arg.readBulkByteArray();
if (arg.versions.get("awIndexBuffer.HasShouldExpandTo32Bit"))
arg.readBoolean();
if (data.length === 0) {
this.indices16 = [];
this.indices32 = [];
return;
}
if (is32Bit) {
const count = data.length / 4;
const tempAr = new FByteArchive_1.FByteArchive(data);
tempAr.littleEndian = arg.littleEndian;
this.indices32 = new Array(count);
for (let i = 0; i < count; ++i)
this.indices32[i] = tempAr.readUInt32();
this.indices16 = [];
}
else {
const count = data.length / 4;
const tempAr = new FByteArchive_1.FByteArchive(data);
tempAr.littleEndian = arg.littleEndian;
this.indices16 = new Array(count);
for (let i = 0; i < count; ++i)
this.indices16[i] = tempAr.readUInt16();
this.indices32 = [];
}
}
}
else {
this.indices16 = arg;
this.indices32 = args[1];
}
}
else {
this.indices16 = [];
this.indices32 = [];
}
}
}
exports.FRawStaticIndexBuffer = FRawStaticIndexBuffer;