Skip to content

API / Bone

类: Bone

定义于: armature/Bone.ts:44

骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 一个骨架中可以包含多个骨骼。

继承

继承于

构造函数

构造函数

ts
new Bone(): Bone;

返回

Bone

继承自

TransformObject.constructor

属性

_alpha

ts
_alpha: number;

定义于: armature/TransformObject.ts:78

Internal

继承自

TransformObject._alpha


_armature

ts
_armature: Armature;

定义于: armature/TransformObject.ts:86

Internal

继承自

TransformObject._armature


_boneData

ts
_boneData: BoneData;

定义于: armature/Bone.ts:79

Internal


_cachedFrameIndices

ts
_cachedFrameIndices: number[];

定义于: armature/Bone.ts:87

Internal


_childrenTransformDirty

ts
_childrenTransformDirty: boolean;

定义于: armature/Bone.ts:68

Internal


_globalAlpha

ts
_globalAlpha: number;

定义于: armature/TransformObject.ts:82

Internal

继承自

TransformObject._globalAlpha


_hasConstraint

ts
_hasConstraint: boolean;

定义于: armature/Bone.ts:73

Internal


_transformDirty

ts
_transformDirty: boolean;

定义于: armature/Bone.ts:64

Internal


animationPose

ts
readonly animationPose: Transform;

定义于: armature/Bone.ts:60

Internal


global

ts
readonly global: Transform;

定义于: armature/TransformObject.ts:56

相对于骨架坐标系的变换。

继承自

TransformObject.global


globalTransformMatrix

ts
readonly globalTransformMatrix: Matrix;

定义于: armature/TransformObject.ts:47

相对于骨架坐标系的矩阵。

继承自

TransformObject.globalTransformMatrix


hashCode

ts
readonly hashCode: number;

定义于: core/BaseObject.ts:156

分配给此实例的唯一标识号。

继承自

TransformObject.hashCode


offset

ts
readonly offset: Transform;

定义于: armature/TransformObject.ts:65

相对于骨架或父骨骼坐标系的偏移变换。

继承自

TransformObject.offset


offsetMode

ts
offsetMode: OffsetMode;

定义于: armature/Bone.ts:56

偏移模式。

访问器

armature

Getter 签名

ts
get armature(): Armature;

定义于: armature/TransformObject.ts:129

所属的骨架。

返回

Armature

继承自

TransformObject.armature


boneData

Getter 签名

ts
get boneData(): BoneData;

定义于: armature/Bone.ts:499

骨骼数据。

返回

BoneData


name

Getter 签名

ts
get name(): string;

定义于: armature/Bone.ts:534

骨骼名称。

返回

string


parent

Getter 签名

ts
get parent(): Bone;

定义于: armature/Bone.ts:544

所属的父骨骼。

返回

Bone


visible

Getter 签名

ts
get visible(): boolean;

定义于: armature/Bone.ts:511

此骨骼所有插槽的可见。

默认值
ts
true
返回

boolean

Setter 签名

ts
set visible(value: boolean): void;

定义于: armature/Bone.ts:514

参数
参数类型
valueboolean
返回

void

方法

_updateAlpha()

ts
_updateAlpha(): void;

定义于: armature/Bone.ts:331

Internal

返回

void


contains()

ts
contains(value: Bone): boolean;

定义于: armature/Bone.ts:480

检查该骨骼是否包含特定的骨骼。

参数

参数类型
valueBone

返回

boolean


init()

ts
init(boneData: BoneData, armatureValue: Armature): void;

定义于: armature/Bone.ts:342

Internal

参数

参数类型
boneDataBoneData
armatureValueArmature

返回

void


invalidUpdate()

ts
invalidUpdate(): void;

定义于: armature/Bone.ts:469

强制骨骼在下一帧更新变换。 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。

返回

void

示例

ts
    let bone = armature.getBone("arm");
    bone.offset.scaleX = 2.0;
    bone.invalidUpdate();

returnToPool()

ts
returnToPool(): void;

定义于: core/BaseObject.ts:167

清除该实例的所有数据并将其返还对象池。

返回

void

继承自

TransformObject.returnToPool


update()

ts
update(cacheFrameIndex: number): void;

定义于: armature/Bone.ts:362

Internal

参数

参数类型
cacheFrameIndexnumber

返回

void


updateByConstraint()

ts
updateByConstraint(): void;

定义于: armature/Bone.ts:442

Internal

返回

void


updateGlobalTransform()

ts
updateGlobalTransform(): void;

定义于: armature/TransformObject.ts:116

出于性能的考虑,骨骼或插槽的 #global 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 使用此方法可以保证访问到 #global 属性中正确的旋转或缩放。

返回

void

示例

ts
    bone.updateGlobalTransform();
    let rotation = bone.global.rotation;

继承自

TransformObject.updateGlobalTransform


borrowObject()

ts
static borrowObject<T>(objectConstructor: () => T): T;

定义于: core/BaseObject.ts:136

从对象池中获取特定类的实例。

类型参数

类型参数
T extends BaseObject

参数

参数类型描述
objectConstructor() => T特定的类。

返回

T

继承自

TransformObject.borrowObject


clearPool()

ts
static clearPool(objectConstructor: typeof BaseObject): void;

定义于: core/BaseObject.ts:111

清除特定对象池的缓存实例。

参数

参数类型默认值描述
objectConstructortypeof BaseObjectnull特定的类。 (不设置则清除所有缓存的实例)

返回

void

继承自

TransformObject.clearPool


setMaxCount()

ts
static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;

定义于: core/BaseObject.ts:72

设置特定对象池的最大缓存数量。

参数

参数类型描述
objectConstructortypeof BaseObject特定的类。 (不设置则设置所有对象池的最大缓存数量)
maxCountnumber最大缓存数量。

返回

void

继承自

TransformObject.setMaxCount


toString()

ts
static toString(): string;

定义于: armature/Bone.ts:45

返回

string

重写了

TransformObject.toString

Released under the MIT License.