3D model converter from .dff/.txd to glTF and glb
npm install dff2gltf-converterjs
import fs from 'fs';
import { DffConverter, ModelType } from 'dff2gltf-converter'; // Read .dff and .txd files
const dffBuffer = fs.readFileSync(
model.dff);
const txdBuffer = fs.readFileSync(model.txd); // Initialize the converter with buffers and model type
const dffConverter = new DffConverter(dffBuffer, txdBuffer, ModelType.OBJECT);
// Convert DFF to glTF
const result = await dffConverter.convertDffToGltf();
// Export the result as .glb (or .gltf) file
result.exportAs(
./output/result.glb); // Alternatively, get the buffer and write it manually
const gltfBuffer = await result.getBuffer();
fs.writeFileSync(
./output/${modelName}.glb, gltfBuffer);`
You can choose one of three model types for model conversion:
`js
ModelType.SKIN
ModelType.CAR
ModelType.OBJECT
`
Notes:
* Selecting the wrong type may result in unexpected output after conversion, so be sure to specify the type correctly.
* Cars and skins (III/VC) conversion are currently unavailable right now.$3
`sh
dff2gltf [dffPath] [txdPath] [ModelType (-s, -m, -c)] [outputPath]
dff2gltf model.dff model.txd -s output.glb
``