0.2.4 • Published 3 years ago

source-mdl v0.2.4

Weekly downloads
18
License
ISC
Repository
-
Last release
3 years ago

Source MDL

This package can read source engines MDL files. To parse a model, it needs the VTX, VVD and MDL file.

It may not work with every model. It was tested with models from Portal 2.

After the model was imported, it can be exported in GLTF format. This conversion is lossy. Prop data like surface property, mouths, eyes and special source stuff will not be exported.

Currently it does not support bones or animations!

Demo

Check out an online working demo

How to use

const MDL = require('./src/MDL.js');
const fs = require('fs').promises;

(async () => {
  // Read files or get the buffers from somewhere else
  let mdlData = await fs.readFile('./test/candles.mdl');
  let vtxData = await fs.readFile('./test/candles.dx90.vtx');
  let vvdData = await fs.readFile('./test/candles.vvd');

  // Create an MDL instance
  let model = new MDL();

  // Import the three buffers
  model.import({mdlData, vtxData, vvdData});

  // If you want, look at some metadata
  console.log(model.getMetadata());

  // Export as GLTF
  await fs.writeFile("test/test.gltf", JSON.stringify(model.toGLTF()));

  // Export as OBJ
  await fs.writeFile("test/test.obj", model.toObj());

  // You can import only the MDL buffer if you are only interested in metadata without geometry
  let modelNoGeometry = new MDL();
  modelNoGeometry.import({mdlData});
  console.log(model.getMetadata());
})();

Export

This module can convert MDL to different formats. | Format | Geometry | UVs | Armature | Animations | ----------------------------------------------------------|-------------|-----|----------|----------- | GLTF | Yes | Yes | No | No | OBJ | Yes | Yes | No | No | XMODEL (exporter by johndoe) | Yes | Yes | No | No

Or you can create your own exporter with the object obtained by model.getData() or use an external GLTF/OBJ to anything converter.

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago