From 1990133564bc6c8e528271134456fa57b374f40e Mon Sep 17 00:00:00 2001 From: Rafael Heros de Almeida Date: Thu, 21 Dec 2023 18:04:09 -0300 Subject: [PATCH] Fix/101: Type 'GLTFActions' constraint to 'AnimationClip' (#193) * Fix/101: Type 'GLTFActions' does not satisfy the constraint 'AnimationClip' * Update parser.js * Update cli.js --------- Co-authored-by: drcmda --- cli.js | 2 +- src/utils/parser.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cli.js b/cli.js index 4ea0d56..6d471ed 100755 --- a/cli.js +++ b/cli.js @@ -63,7 +63,7 @@ const cli = meow( keepmeshes: { type: 'boolean', shortFlag: 'j', default: false }, keepmaterials: { type: 'boolean', shortFlag: 'M', default: false }, format: { type: 'string', shortFlag: 'f', default: 'webp' }, - exportdefault: { type: 'boolean', alias: 'E' }, + exportdefault: { type: 'boolean', shortFlag: 'E' }, weld: { type: 'number', default: 0.0001 }, ratio: { type: 'number', default: 0.75 }, error: { type: 'number', default: 0.001 }, diff --git a/src/utils/parser.js b/src/utils/parser.js index 4c47f5e..d68627d 100644 --- a/src/utils/parser.js +++ b/src/utils/parser.js @@ -101,7 +101,9 @@ function parse(gltf, { fileName = 'model', ...options } = {}) { if (animations.length) { animationTypes = `\n type ActionName = ${animations.map((clip, i) => `"${clip.name}"`).join(' | ')}; - type GLTFActions = Record;\n` + interface GLTFAction extends THREE.AnimationClip {\n + name: ActionName;\n + }` } const types = [...new Set([...meshes, ...bones].map((o) => getType(o)))] @@ -117,6 +119,7 @@ function parse(gltf, { fileName = 'model', ...options } = {}) { materials: { ${materials.map(({ name, type }) => (isVarName(name) ? name : `['${name}']`) + ': THREE.' + type).join(',')} } + animations: GLTFAction[] }\n${animationTypes}\n${contextType}` } @@ -376,9 +379,7 @@ function parse(gltf, { fileName = 'model', ...options } = {}) { } function printAnimations(animations) { - return animations.length - ? `\nconst { actions } = useAnimations${options.types ? '' : ''}(animations, group)` - : '' + return animations.length ? `\nconst { actions } = useAnimations(animations, group)` : '' } function parseExtras(extras) {