Skip to content

Commit

Permalink
Merge pull request #4 from zhuxudong/animator
Browse files Browse the repository at this point in the history
refactor: use new addChannel api
  • Loading branch information
luzhuang authored Jun 2, 2021
2 parents bb5a292 + 2c019e4 commit 5ae17dd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/loader/src/gltf/parser/AnimationParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

0 comments on commit 5ae17dd

Please sign in to comment.