Skip to content

Commit

Permalink
fix: update animation data (#55)
Browse files Browse the repository at this point in the history
* fix: update animation data and support bezier quaternion curve

* fix: add new value type

* fix: update clip data

* fix: revert

* chore: rename

* chore: update import path
  • Loading branch information
liuxi150 authored May 21, 2024
1 parent 9591457 commit cb21472
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/animation-clip-data.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { EffectsObjectData } from './components';
import type { FixedNumberExpression, FixedVec3Expression } from './number-expression';
import type { FixedNumberExpression, FixedVec3Expression, FixedQuatExpression } from './number-expression';

export interface AnimationClipData extends EffectsObjectData {
positionCurves: PositionCurveData[],
eulerCurves: EulerCurveData[],
rotationCurves: RotationCurveData[],
scaleCurves: ScaleCurveData[],
floatCurves: FloatCurveData[],
}
Expand All @@ -13,9 +13,9 @@ export interface PositionCurveData {
keyFrames: FixedVec3Expression,
}

export interface EulerCurveData {
export interface RotationCurveData {
path: string,
keyFrames: FixedVec3Expression,
keyFrames: FixedQuatExpression,
}

export interface ScaleCurveData {
Expand Down
1 change: 1 addition & 0 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum DataType {
CameraComponent = 'CameraComponent',
ModelPluginComponent = 'ModelPluginComponent',
TreeComponent = 'TreeComponent',
AnimationComponent = 'AnimationComponent',
}

export interface DataPath {
Expand Down
13 changes: 13 additions & 0 deletions src/item/model/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ModelAnimationTrackDataPointer } from './binary';
import type { BaseItem, BaseItemTransform } from '../base-item';
import type { SizeOverLifetime, RotationOverLifetime, PositionOverLifetime, ItemType } from '../../type';
import type { ComponentData, DataPath } from '../../components';
import type { AnimationClipData } from '../../animation-clip-data';

export interface TreeNodeOptions {
name?: string,
Expand Down Expand Up @@ -95,3 +96,15 @@ export interface ModelAnimationComponentData extends ComponentData {
*/
animations: ModelAnimationData[],
}

export interface AnimationComponentData extends ComponentData {
/**
* 默认动画索引,-1表示不播放动画
*/
animation?: number,
/**
* glTF中所有的动画数据
*/
animationClips: AnimationClipData[],
}

17 changes: 17 additions & 0 deletions src/number-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export enum ValueType {
* 贝塞尔曲线路径
*/
BEZIER_CURVE_PATH = 22,

/**
* 贝塞尔曲线四元数
*/
BEZIER_CURVE_QUAT = 23,
}

export type vec2 = [x: number, y: number];
Expand Down Expand Up @@ -100,6 +105,8 @@ export type NumberExpression = FixedNumberExpression | RandomValue;

export type FixedVec3Expression = ConstantVec3 | BezierPath | LinearPath | BezierCurvePath;

export type FixedQuatExpression = BezierCurveQuat;

/**
* 常数数值
* [0,5]
Expand Down Expand Up @@ -268,11 +275,21 @@ export type BezierValue = [type: ValueType.BEZIER_CURVE, value: BezierKeyframeVa
*/
export type BezierCurvePathValue = [easing: BezierKeyframeValue[], points: vec3[], controlePoints: vec3[]];

/**
* 贝塞尔曲线路径关键帧值
*/
export type BezierCurveQuatValue = [easing: BezierKeyframeValue[], points: vec4[], controlePoints: vec4[]];

/**
* 贝塞尔曲线路径关键帧
*/
export type BezierCurvePath = [type: ValueType.BEZIER_CURVE_PATH, value: BezierCurvePathValue];

/**
* 贝塞尔曲线路径关键帧
*/
export type BezierCurveQuat = [type: ValueType.BEZIER_CURVE_QUAT, value: BezierCurveQuatValue];

/*********************************************/
/* 颜色属性参数 */
/*********************************************/
Expand Down

0 comments on commit cb21472

Please sign in to comment.