import { NodeIO } from '@gltf-transform/core'; import { ALL_EXTENSIONS } from '@gltf-transform/extensions'; import { weld, dedup, prune, draco } from '@gltf-transform/functions'; import draco3d from 'draco3dgltf'; const [,, inPath, outPath] = process.argv; if (!inPath || !outPath) { console.error('usage: compress.mjs in.glb out.glb'); process.exit(1); } const io = new NodeIO() .registerExtensions(ALL_EXTENSIONS) .registerDependencies({ 'draco3d.encoder': await draco3d.createEncoderModule(), 'draco3d.decoder': await draco3d.createDecoderModule(), }); const doc = await io.read(inPath); await doc.transform( weld(), dedup(), prune(), draco({ method: 'edgebreaker', quantizePosition: 14, quantizeNormal: 10, quantizeGeneric: 12 }), ); await io.write(outPath, doc); console.log('compressed ->', outPath);