Skip to content

Commit

Permalink
Weld before Draco compression (#918)
Browse files Browse the repository at this point in the history
* [functions] Weld before Draco compression.

* Update CLI.
  • Loading branch information
donmccurdy committed Apr 19, 2023
1 parent 3e241f4 commit 496b8f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 1 addition & 5 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,7 @@ ${underline('References')}
default: DRACO_DEFAULTS.quantizationVolume,
})
.action(({ args, options, logger }) =>
// Include a lossless weld — Draco requires indices.
Session.create(io, logger, args.input, args.output).transform(
weld({ tolerance: 0 }),
draco(options as unknown as DracoOptions)
)
Session.create(io, logger, args.input, args.output).transform(draco(options as unknown as DracoOptions))
);

// MESHOPT
Expand Down
7 changes: 5 additions & 2 deletions packages/functions/src/draco.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Document, Transform } from '@gltf-transform/core';
import { KHRDracoMeshCompression } from '@gltf-transform/extensions';
import { createTransform } from './utils.js';
import { weld } from './weld.js';

const NAME = 'draco';

Expand Down Expand Up @@ -36,8 +37,10 @@ export const DRACO_DEFAULTS: DracoOptions = {
*/
export function draco(_options: DracoOptions = DRACO_DEFAULTS): Transform {
const options = { ...DRACO_DEFAULTS, ..._options } as Required<DracoOptions>;
return createTransform(NAME, (doc: Document): void => {
doc.createExtension(KHRDracoMeshCompression)
return createTransform(NAME, async (document: Document): Promise<void> => {
await document.transform(weld({ tolerance: 0 }));
document
.createExtension(KHRDracoMeshCompression)
.setRequired(true)
.setEncoderOptions({
method:
Expand Down

0 comments on commit 496b8f5

Please sign in to comment.