Hi
I am trying to simplify the geometry of child objects when loading a .glb file using the reference link below.
The example using TorusKnotGeometry from the link works fine. However, it doesn’t work with the .glb file I’m using.
The link suggests using ‘gltf-transform weld input.glb output.glb’ to index the shape, but I used ‘npx gltfjsx [Model.glb] -T -S --weld’ to create the model.
Is it correct?
this.scene.add(this.loadedModel);
this.loadedModel.traverse((child) => {
if (child.isMesh) {
let geometry = child.geometry;
let dstGeometry = geometry.clone();
const srcIndexArray = geometry.index.array;
const srcPositionArray = geometry.attributes.position.array;
const targetCount = 3 * Math.floor(0.1 * srcIndexArray.length / 3);
const [dstIndexArray, error] = MeshoptSimplifier.simplify(
srcIndexArray,
srcPositionArray,
3,
targetCount,
0.25,
['LockBorder'],
);
dstGeometry.index.array.set(dstIndexArray);
dstGeometry.index.needsUpdate = true;
dstGeometry.setDrawRange(0, dstIndexArray.length);
}
})