novo corpo
This commit is contained in:
1 parent
270cdbb965
commit
12342f442d
5 files changed
+230
-125
No files matched your search
@@ -0,0 +1,29 @@
|
||||
// Otimiza o GLB bruto exportado pelo repose_and_export.py: solda vértices
|
||||
// duplicados, remove dados não usados e quantiza as posições/normais pra
|
||||
// menos bytes por vértice — sem precisar de um decoder novo no frontend
|
||||
// (KHR_mesh_quantization já é suportado nativamente pelo GLTFLoader do
|
||||
// three.js). A malha não tem textura (só cor sólida), então a UV é
|
||||
// descartada antes de tudo — ela não serve pra nada e ainda impedia o
|
||||
// quantize de comprimir aquele atributo.
|
||||
import { NodeIO } from "@gltf-transform/core";
|
||||
import { ALL_EXTENSIONS } from "@gltf-transform/extensions";
|
||||
import { prune, dedup, weld, quantize } from "@gltf-transform/functions";
|
||||
|
||||
const INPUT = "/tmp/mannequin-realistic.glb";
|
||||
const OUTPUT = "/tmp/mannequin-realistic.optimized.glb";
|
||||
|
||||
const io = new NodeIO().registerExtensions(ALL_EXTENSIONS);
|
||||
const doc = await io.read(INPUT);
|
||||
|
||||
for (const mesh of doc.getRoot().listMeshes()) {
|
||||
for (const prim of mesh.listPrimitives()) {
|
||||
if (prim.getAttribute("TEXCOORD_0")) {
|
||||
prim.setAttribute("TEXCOORD_0", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await doc.transform(weld({ tolerance: 0.0001 }), dedup(), quantize(), prune());
|
||||
|
||||
await io.write(OUTPUT, doc);
|
||||
console.log(`Otimizado: ${INPUT} -> ${OUTPUT}`);
|
||||
Reference in new issue
Block a user