Dedup / instance / prune is breaking the model
Samsy opened this issue · 1 comments
Samsy commented
Hello hello !
Did discover an issue with prune.
Using this model : https://github.com/Samsy/glbs/blob/main/testitest.glb
Original :
![Screenshot 2024-02-22 at 11 14 55](https://private-user-images.githubusercontent.com/3786958/306958155-44231e8a-4e42-4a6e-9c4a-728df595d510.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDk0ODIwOTcsIm5iZiI6MTcwOTQ4MTc5NywicGF0aCI6Ii8zNzg2OTU4LzMwNjk1ODE1NS00NDIzMWU4YS00ZTQyLTRhNmUtOWM0YS03MjhkZjU5NWQ1MTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMDNUMTYwMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YmM3NGFiOTFhZGQ2OGM4M2Q0OWY2OTc0N2FhZjQ4MzIzMGM3MDUwNmEyNzk5ODg0MTNhOGNmMzE4YThmM2RlMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.My5wux5cBrXUiQnufd9CJ98Uras8tCc0tPylXy3Ujl8)
This transformation using 4.0.0-alpha.7 tested on both Nodejs package + CLI / same version :
`import { Document, NodeIO, VertexLayout } from "@gltf-transform/core";
import { KHRONOS_EXTENSIONS, EXTTextureWebP, EXTMeshGPUInstancing } from "@gltf-transform/extensions";
import draco3d from "draco3dgltf";
import {
prune,
dedup,
resample,
simplify,
metalRough,
draco,
weld,
// textureCompress,
instance,
dequantize,
join,
palette,
clearNodeTransform,
transformMesh,
} from "@gltf-transform/functions";
import fs from 'fs'
async function process(url ){
const io = new NodeIO()
.registerExtensions(KHRONOS_EXTENSIONS)
.registerExtensions([EXTMeshGPUInstancing])
io.registerDependencies({
"draco3d.decoder": await draco3d.createDecoderModule(), // Optional.
"draco3d.encoder": await draco3d.createEncoderModule(), // Optional.
});
const originalDocument = await io.read(url);
await originalDocument.transform(
dedup(),
instance(),
// Losslessly resample animation frames.
resample(),
// Remove unused nodes, textures, or other data.
prune(),
);
// const clone = originalDocument.clone()
const glb = await io.writeBinary(originalDocument)
fs.writeFileSync('yolo.glb', glb)
}
process('testitest.glb')
`
Result : https://github.com/Samsy/glbs/blob/main/testitest-broken.glb
![Screenshot 2024-02-22 at 11 19 13](https://private-user-images.githubusercontent.com/3786958/306958405-c01db935-09f6-417e-bfc3-b14f6a25453f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDk0ODIwOTcsIm5iZiI6MTcwOTQ4MTc5NywicGF0aCI6Ii8zNzg2OTU4LzMwNjk1ODQwNS1jMDFkYjkzNS0wOWY2LTQxN2UtYmZjMy1iMTRmNmEyNTQ1M2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMDNUMTYwMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTRmZmNhYzhmZDI2ZjY1YzhhMzM3ZWIzMjY1ZDVhNWM4MDU0NmM2MzBhYmU3NzQyM2IwNTM2YjlkODY5NWJkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.j_rsdsWB-cPf0vukLJ2WRtarmfKxoNgFN5C6udisMmA)
I realised that removing the last prune transform does not break the model !
EDIT :
I just tested the options of prunes :
Seems like this option is not breaking the model :
prune({
keepIndices: true
})
donmccurdy commented