From 271a74a93e52a4748bc3b32c5e9ba153c8b45b99 Mon Sep 17 00:00:00 2001 From: "shensi.zxd" Date: Wed, 2 Jun 2021 15:58:38 +0800 Subject: [PATCH] refactor: use new addChannel api --- .../loader/src/gltf/parser/AnimationParser.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/loader/src/gltf/parser/AnimationParser.ts b/packages/loader/src/gltf/parser/AnimationParser.ts index 7a7319a0e8..f6b564711b 100644 --- a/packages/loader/src/gltf/parser/AnimationParser.ts +++ b/packages/loader/src/gltf/parser/AnimationParser.ts @@ -8,7 +8,7 @@ import { Parser } from "./Parser"; export class AnimationParser extends Parser { parse(context: GLTFResource): void { - const { gltf, buffers } = context; + const { gltf, buffers, entities } = context; const { animations, accessors, nodes } = gltf; if (!animations) return; @@ -76,11 +76,15 @@ export class AnimationParser extends Parser { targetPath = "weights"; break; } - animationClipParser.addChannel( - sampler, - nodes[target.node].name || `${EntityParser._defaultName}${target.node}`, - targetPath - ); + + const channelTargetEntity = entities[target.node]; + let path = channelTargetEntity.name; + let parent = channelTargetEntity.parent; + while (parent) { + path = `${parent.name}/${path};`; + parent = parent.parent; + } + animationClipParser.addChannel(sampler, path, targetPath); } const curveDatas = animationClipParser.getCurveDatas(); const animationClip = new AnimationClip(name);