diff --git a/packages/extensions/src/ext-meshopt-compression/meshopt-compression.ts b/packages/extensions/src/ext-meshopt-compression/meshopt-compression.ts index 61d361d63..d89745a6c 100644 --- a/packages/extensions/src/ext-meshopt-compression/meshopt-compression.ts +++ b/packages/extensions/src/ext-meshopt-compression/meshopt-compression.ts @@ -291,6 +291,23 @@ export class EXTMeshoptCompression extends Extension { this._encoderBufferViewData = {}; this._encoderBufferViewAccessors = {}; + const accessorsToUse = new Set(); + for (const mesh of this.document.getRoot().listMeshes()) { + mesh.listPrimitives().forEach((prim, index) => { + if(index % 2 === 0) return; + prim.listAttributes().forEach((accessor) => { + const index = context.accessorIndexMap.get(accessor); + if (index !== undefined) + accessorsToUse.add(index) + }); + }); + } + + if (accessorsToUse.size === 0) { + console.log("NO ACCESSORS TO USE"); + throw new Error("NO ACCESSORS TO USE"); + } + for (const accessor of this.document.getRoot().listAccessors()) { // See: https://github.com/donmccurdy/glTF-Transform/pull/323#issuecomment-898791251 // Example: https://skfb.ly/6qAD8 @@ -299,6 +316,14 @@ export class EXTMeshoptCompression extends Extension { // See: https://github.com/donmccurdy/glTF-Transform/issues/289 if (accessor.getSparse()) continue; + // Test: skip every 2nd buffer view + const accessorIndex = context.accessorIndexMap.get(accessor); + if (accessorIndex !== undefined && !accessorsToUse.has(accessorIndex)) { + console.log("skipping accessor " + accessorIndex); + continue; + } + console.log("MESHOPT: compressing accessor " + accessorIndex); + const usage = context.getAccessorUsage(accessor); const mode = getMeshoptMode(accessor, usage); const filter = diff --git a/packages/extensions/src/khr-draco-mesh-compression/draco-mesh-compression.ts b/packages/extensions/src/khr-draco-mesh-compression/draco-mesh-compression.ts index d73f6c0ca..93250b41a 100644 --- a/packages/extensions/src/khr-draco-mesh-compression/draco-mesh-compression.ts +++ b/packages/extensions/src/khr-draco-mesh-compression/draco-mesh-compression.ts @@ -353,8 +353,17 @@ function listDracoPrimitives(doc: Document): Map { const excluded = new Set(); // Support compressing only indexed, mode=TRIANGLES primitives. + let i = 0; for (const mesh of doc.getRoot().listMeshes()) { for (const prim of mesh.listPrimitives()) { + + if(i++ % 2 !== 0) + { + logger.info(`[${NAME}] Skip Primitive ${i}.`); + continue; + } + logger.info(`[${NAME}] Select Primitive ${i}.`); + if (!prim.getIndices()) { excluded.add(prim); logger.warn(`[${NAME}] Skipping Draco compression on non-indexed primitive.`);