Skip to content

Commit

Permalink
feat(cli): Add --weld option to 'optimize' command. (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy authored Jul 9, 2023
1 parent d0c86bd commit 7eb6f62
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ commands or using the scripting API.
validator: program.BOOLEAN,
default: true,
})
.option('--weld <bool>', 'Index geometry and merge similar vertices. Often required when simplifying geometry.', {
validator: program.BOOLEAN,
default: true,
})
.action(async ({ args, options, logger }) => {
const opts = options as {
instance: boolean;
Expand All @@ -282,6 +286,7 @@ commands or using the scripting API.
textureSize: number;
flatten: boolean;
join: boolean;
weld: boolean;
};

// Baseline transforms.
Expand All @@ -292,14 +297,12 @@ commands or using the scripting API.
if (opts.flatten) transforms.push(flatten());
if (opts.join) transforms.push(dequantize(), join());

// Simplification and welding.
if (opts.weld) {
transforms.push(weld({ tolerance: opts.simplify ? opts.simplifyError / 2 : WELD_DEFAULTS.tolerance }));
}

if (opts.simplify) {
transforms.push(
weld({ tolerance: opts.simplifyError / 2 }),
simplify({ simplifier: MeshoptSimplifier, error: opts.simplifyError })
);
} else {
transforms.push(weld());
transforms.push(simplify({ simplifier: MeshoptSimplifier, error: opts.simplifyError }));
}

transforms.push(
Expand Down Expand Up @@ -1048,7 +1051,7 @@ preserving original aspect ratio. Texture dimensions are never increased.
)
.argument('<input>', INPUT_DESC)
.argument('<output>', OUTPUT_DESC)
.option('--pattern <pattern>', 'Pattern (regex) to match textures, by name or URI.', {
.option('--pattern <pattern>', 'Pattern (glob) to match textures, by name or URI.', {
validator: program.STRING,
})
.option('--filter', 'Resampling filter', {
Expand Down

0 comments on commit 7eb6f62

Please sign in to comment.