UnrealPackageReader.js
    Preparing search index...

    UnrealPackageReader.js

    A TypeScript reader for Unreal Tournament package files. It has been successfully tested with a few other Unreal Engine 1 games including Deus Ex, Rune, Harry Potter and the Philosopher's Stone/Chamber of Secrets, Clive Barker's Undying, Nerf Arena Blast, and The Wheel of Time.

    This reader is largely based on the following package readers:

    The main difference between UnrealPackageReader.js and the above readers (besides the programming language) is that this is web-oriented: textures can be rendered onto a canvas on the fly, and brush geometry can be read in a format that's easy to drop straight into three.js, to name a couple of features.

    Visit BunnyTrack.net's package explorer page and drag/drop a UT package (map, texture, sound, etc.) to see what the reader is capable of:

    Squid model shown using three.js DM-Pyramid wireframe shown using three.js Pulse Gun wireframe shown using three.js

    Load dist/UnrealPackageReader.js with a <script> tag; it defines a single global class, UnrealPackageReader. Load an ArrayBuffer with it:

    const utPackage = await UnrealPackageReader.load(arrayBuffer);

    utPackage.version; // 69
    utPackage.getLevelSummary(); // { Title: "Facing Worlds", ... }
    utPackage.getTextureObjects(); // one export table entry per texture

    Example with HTML

    <input type="file" id="file-input" />

    <script src="UnrealPackageReader.js"></script>
    <script>
    document
    .getElementById("file-input")
    .addEventListener("input", async function () {
    for (const file of this.files) {
    const buffer = await file.arrayBuffer();
    const utPackage = await UnrealPackageReader.load(buffer);

    // Get package version
    console.log(utPackage.version); // 69
    }
    });
    </script>

    The full API reference is generated from the source and published at bunnytrack.github.io/unreal-package-reader.

    What you're most likely after is the UnrealPackageReader class page, where you'll find the methods for fetching objects, textures, sounds, brushes, dependencies and level summaries.

    The modules are listed top down: starting from the general-purpose reader class, each one goes a level deeper into the package anatomy, ending at the raw bytes.

    • reader - the entry class above
    • package - the header, the three tables and the property block
    • natives - what follows the property block, for the classes the reader understands (Texture, Model, Sound, ...)
    • structs - the sequential field readers those are assembled from
    • constants - flag tables, enums, type codes and the stock package list
    • io - the byte cursor and codepage-aware text decoding

    Where a struct or field mirrors an engine type, the doc comment acknowledges the original naming (e.g. FBspNode) and describes it in terms verified against, and paraphrased from, the publicly released Unreal Tournament engine headers.

    This reader was originally written as a single plain-JavaScript file, and was ported to TypeScript by Claude under the author's supervision. The ported reader was tested field by field against the original implementation (fixing a number of bugs along the way), and verified against engine sources and other package readers.

    The original implementation has been retired and now lives in the legacy/ folder; it will not be worked on any further.