diff --git a/packages/loader/src/gltf/parser/AnimationParser.ts b/packages/loader/src/gltf/parser/AnimationParser.ts index 7a7319a0e8..24cf856116 100644 --- a/packages/loader/src/gltf/parser/AnimationParser.ts +++ b/packages/loader/src/gltf/parser/AnimationParser.ts @@ -2,13 +2,12 @@ import { AnimationClip, InterpolationType } from "@oasis-engine/core"; import { GLTFResource } from "../GLTFResource"; import { GLTFUtil } from "../GLTFUtil"; import { AnimationChannelTargetPath, AnimationSamplerInterpolation } from "../Schema"; -import { EntityParser } from "./EntityParser"; import { AnimationClipParser } from "./AnimationClipParser"; 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 +75,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);