remove WrapMode from cc, instead make it as a member of AnimationClip (#4292)

* remove WrapMode from cc, instead make it as a member of AnimationClip

* fix bug in getChildByPath
This commit is contained in:
Leslie Leigh
2019-04-24 16:40:50 +08:00
committed by Weiliang Wang
parent 7d26b67071
commit 69c3363d05
3 changed files with 8 additions and 13 deletions
+5 -3
View File
@@ -10,7 +10,7 @@ import { CurveValue, DynamicAnimCurve, EasingMethodName, ICurveTarget, RatioSamp
import { AnimationState } from './animation-state';
import * as blending from './blending';
import { MotionPath, sampleMotionPaths } from './motion-path-helper';
import { ILerpable, isLerpable, WrapMode } from './types';
import { ILerpable, isLerpable, WrapMode as AnimationWrapMode } from './types';
interface IAnimationEvent {
frame: number;
@@ -43,6 +43,7 @@ interface ICurveData {
@ccclass('cc.AnimationClip')
export class AnimationClip extends Asset {
public static WrapMode = AnimationWrapMode;
/**
* !#en Duration of this animation.
@@ -114,7 +115,7 @@ export class AnimationClip extends Asset {
* !#zh 动画的循环模式。
*/
@property
public wrapMode = WrapMode.Normal;
public wrapMode = AnimationWrapMode.Normal;
/**
* !#en Curve data.
@@ -259,8 +260,9 @@ export class AnimationClip extends Asset {
(key) => key / this._duration)));
const curves: DynamicAnimCurve[] = [];
for (const path of Object.keys(this.curveDatas)) {
const target = find(path, root);
const target = root.getChildByPath(path);
if (!target) {
console.warn(`Target animation node referenced by path ${path} is not found(from ${root.name}).`);
continue;
}
const curveData = this.curveDatas[path];
-1
View File
@@ -61,7 +61,6 @@ export enum WrapMode {
}
ccenum(WrapMode);
cc.WrapMode = WrapMode;
/**
* For internal
+3 -9
View File
@@ -494,18 +494,12 @@ export class BaseNode extends CCObject {
* var child = node.getChildByPath("Test Node");
*/
public getChildByPath (path: string) {
if (path.length === 0) {
return this;
}
const segments = path.split('/');
// Starts with /
if (segments.length !== 0 && segments[0].length === 0) {
segments.shift();
}
let lastNode: this = this;
for (const segment of segments) {
if (segment.length === 0) {
continue;
}
const next = lastNode.children.find((childNode) => childNode.name === segment);
if (!next) {
return null;