Skip to content

Commit

Permalink
refactor: use new addChannel api
Browse files Browse the repository at this point in the history
  • Loading branch information
shensi.zxd committed Jun 2, 2021
1 parent bb5a292 commit 271a74a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/loader/src/gltf/parser/AnimationParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 271a74a

Please sign in to comment.