donmccurdy/glTF-Transform

Dedup / instance / prune is breaking the model

Samsy opened this issue · 1 comments

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

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

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
})

Thanks @Samsy! Will be fixed in #1284.