mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
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:
committed by
Weiliang Wang
parent
7d26b67071
commit
69c3363d05
@@ -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];
|
||||
|
||||
@@ -61,7 +61,6 @@ export enum WrapMode {
|
||||
}
|
||||
|
||||
ccenum(WrapMode);
|
||||
cc.WrapMode = WrapMode;
|
||||
|
||||
/**
|
||||
* For internal
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user