Saltar al contenido principal
L

dsh-war3-model-viewer

luengzoen/dsh-war3-model-viewer

Opens Warcraft III .mdx models in the right-sidebar document preview: MDX and BLP parsing in the page, WebGL 2 skinned animation, a sequence tree grouped by standard action, and textures read from a local game install without unpacking it.

Instalar

dsh plugin --profile web add github:luengzoen/dsh-war3-model-viewer

README

dsh-war3-model-viewer

Warcraft III .mdx, .blp and .tga viewers for the DSH right sidebar.

License: MIT Version Platform Runtime

English · 简体中文

A model on the right, its action tree on the left

Table of contents

What it does

Open an .mdx file in the workspace and the right sidebar draws the model — animation included — without extracting the game to disk and without uploading anything. Parsing, texture decoding and rendering all happen in the page.

Open a .blp or .tga and the same panel becomes an image viewer built for textures: zoom anchored on the pointer, a switchable checkerboard for alpha, the BLP's mip levels, and the file's own format facts in the status line.

Features

Format support

  • MDLX container, sequences, node tree
  • KGTR / KGRT / KGSC animation tracks
  • Linear, Hermite and Bezier interpolation
  • Geosets, materials, pivots, billboard nodes
  • BLP0 / BLP1 / BLP2 textures, every mip level
  • Palette, DXT1, DXT3, DXT5 and BGRA payloads
  • Four-component embedded JPEG
  • TGA colour-mapped, true-colour and grayscale
  • TGA plain and RLE, 8 / 15 / 16 / 24 / 32 bit
  • Either TGA origin, top-left or bottom-left
  • MPQ v1 archives for game textures

Rendering

  • WebGL 2, no external 3D library
  • Skinned animation solved per frame
  • Per-layer blend state and alpha test
  • Team colour and team glow
  • Unlit shading, honouring baked lighting
  • Orientation gizmo and orbit camera
  • Pointer-anchored zoom for textures

Actions

Warcraft III names sequences freely, so the left column groups them by the standard action they belong to — Stand with its numbered and Alternate variants, Walk with Walk Fast, Attack with Attack Slam, and so on. Anything unrecognised still gets a row under Other and stays playable.

A group header only folds and expands; its leaves are the sequences you click. The dice button in the footer picks a variant weighted by the sequence's Rarity, the way the game does.

Textures

A model names its textures by game-root-relative path. They are looked up beside the model first, then in the local Warcraft III archives if the game is installed; a texture found nowhere falls back to a neutral fill, and the status line counts the misses. The game itself is never unpacked.

The installation is found automatically; set WAR3_DIR to name the directory explicitly.

Texture viewer

A .blp or .tga opens in the same right-sidebar seat:

  • Zoom anchors on the pointer. The pixel under the cursor stays under the cursor.
  • Three checkerboard states (light, dark, flat). A transparent texture on a flat fill is indistinguishable from a black one.
  • Every BLP mip level is selectable. Levels that only re-reference one JPEG stream are not listed.
  • The status line reports the file's format facts: dimensions, format, pixel format, alpha depth, mip count, TGA bit depth and origin.
  • Click any pixel to copy its RGBA.

Textures are decoded by this plugin, including Blizzard's four-plane JPEGs. A browser reads four-component JPEG as CMYK and inverts it, so those files need a decoder that keeps the planes apart.

Controls

InputAction
DragOrbit the camera (model), or pan the image (texture)
WheelZoom, anchored on the pointer
Right-drag, or Shift+dragPan the camera
Double-clickToggle fit and 1:1 (texture)
Ctrl + + / −Zoom in and out (texture)
Ctrl + 0 / 1Fit, and actual size (texture)
ToolbarPlay/pause, reset view, grid, wireframe, speed, team colour (model)
ToolbarZoom out, percentage, zoom in, fit, 1:1, checkerboard, mip level (texture)
FooterAction name, duration, loop toggle, progress, random variant

The loop toggle defaults to on, so a one-shot action does not freeze on its last frame; switching it off restores the authored behaviour.

A fitted texture is magnified at most 4x, so a 16x16 mipmap is findable without being turned into a 900px blur. Clicking the percentage returns to 1:1.

Requirements

DSH>=0.2.2-rc.3
BrowserAny engine with WebGL 2 (Chrome/Edge 120+, Firefox 121+, Safari 17+)
BuildNode 20 or newer
GameOptional — only for textures that live inside the game archives

Install

From DSH: Plugins → Discover, or Plugins → Add plugin, and pick dsh-war3-model-viewer.

From a shell:

dsh plugin --profile <profile> add dsh-war3-model-viewer

For development, install this directory as a link and rebuild in place — the page picks up a new dist/client.js after a refresh, with no reinstall:

dsh plugin --profile <profile> add link:<absolute path of this directory>

Build and test

# Bundle src/ into dist/client.js
node build.mjs

# Every suite
node tests/run.mjs

The result is a single dist/client.js that registers one module factory; DSH loads it directly, which is why the built file is part of the repository.

Project layout

src/
├── mdx/      container, tracks, sequences
├── blp/      BLP0/1/2 and embedded JPEG
├── tga/      TGA header, payloads and origin handling
├── view/     image decoding dispatch and the zoom model
├── mpq/      archive reader and installation discovery
├── render/   WebGL 2 renderer, skeleton, maths, textures
├── ui/       sidebar components, action tree, gizmo, styles, dictionaries
└── client.js client entry: preview registrations and bodies
FilePurpose
index.jsHost entry that enables the bundle row
build.mjsesbuild bundling and module registration wrapper
cordis.patch.ymlPlugin registration patch
dist/client.jsBuild output loaded directly by DSH
docs/DETAIL.mdLong description shown by plugin stores
tests/Test suites and model fixtures

Limitations

  • No particles, ribbons, lights, cameras, events or collision volumes. Spell effects built from them will look incomplete.
  • PTYP is drawn as triangle lists only. Strips and fans are rare in practice and unsupported.
  • Progressive (SOF2) JPEG payloads are decoded by the browser. The bundled decoder handles baseline streams.
  • Model and texture bytes arrive in one piece, so very large files are bounded by the host's file-size limit (32 MiB by default).
  • TGA types 32 and 33 are not read. They are Huffman and Delta-RLE compressions, and no Warcraft III asset uses them; the decoder reports the type.
  • TGA pixel interleave is ignored. That is descriptor bit 6, the two-way interleave.

Version

MAJOR.MINOR.PATCH, as declared in package.json.

License

MIT © Luengzoen

Plugins relacionados