UNPKG

unreal.js

Version:

A pak reader for games like VALORANT & Fortnite written in Node.JS

39 lines (38 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FColorVertexBuffer = void 0; const FStripDataFlags_1 = require("../../../objects/engine/FStripDataFlags"); const FColor_1 = require("../../../objects/core/math/FColor"); const FArchive_1 = require("../../../reader/FArchive"); const Versions_1 = require("../../../versions/Versions"); const Exceptions_1 = require("../../../../exceptions/Exceptions"); class FColorVertexBuffer { constructor(...args) { const arg = args[0]; if (arg instanceof FArchive_1.FArchive) { this.stripFlags = new FStripDataFlags_1.FStripDataFlags(arg, Versions_1.VER_UE4_STATIC_SKELETAL_MESH_SERIALIZATION_FIX); this.stride = arg.readInt32(); this.numVertices = arg.readInt32(); if (!this.stripFlags.isDataStrippedForServer && this.numVertices > 0) { const elemSize = arg.readInt32(); const elemCount = arg.readInt32(); const savePos = arg.pos; const array = new Array(elemCount); for (let i = 0; i < elemCount; ++i) array[i] = new FColor_1.FColor(arg); if (arg.pos != savePos + array.length * elemSize) throw new Exceptions_1.ParserException(`RawArray item size mismatch: expected ${elemSize}, serialized ${(arg.pos - savePos) / array.length}`); this.data = array; } else this.data = []; } else { this.stripFlags = arg; this.stride = args[1]; this.numVertices = args[2]; this.data = args[3]; } } } exports.FColorVertexBuffer = FColorVertexBuffer;