@safe-engine/pixi 8.8.1 → 8.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +20 -1
- package/dist/core/NodePool.d.ts +1 -1
- package/dist/core/Size.d.ts +0 -1
- package/dist/core/Size.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.d.ts +1 -1
- package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComponent.js +1 -1
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesSystem.js +1 -1
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts +59 -0
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiArmatureDisplay.js +180 -0
- package/dist/dragonbones/db-pixi/PixiFactory.d.ts +87 -0
- package/dist/dragonbones/db-pixi/PixiFactory.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiFactory.js +159 -0
- package/dist/dragonbones/db-pixi/PixiSlot.d.ts +31 -0
- package/dist/dragonbones/db-pixi/PixiSlot.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiSlot.js +332 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts +38 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/PixiTextureAtlasData.js +85 -0
- package/dist/dragonbones/db-pixi/index.d.ts +5 -0
- package/dist/dragonbones/db-pixi/index.d.ts.map +1 -0
- package/dist/dragonbones/db-pixi/index.js +4 -0
- package/dist/dragonbones/dragonBones/animation/Animation.d.ts +241 -0
- package/dist/dragonbones/dragonBones/animation/Animation.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/Animation.js +692 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts +323 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/AnimationState.js +1161 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts +100 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/BaseTimelineState.js +479 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts +38 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/IAnimatable.js +9 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts +159 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/TimelineState.js +998 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts +74 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/animation/WorldClock.js +162 -0
- package/dist/dragonbones/dragonBones/armature/Armature.d.ts +314 -0
- package/dist/dragonbones/dragonBones/armature/Armature.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Armature.js +650 -0
- package/dist/dragonbones/dragonBones/armature/Bone.d.ts +123 -0
- package/dist/dragonbones/dragonBones/armature/Bone.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Bone.js +438 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.d.ts +99 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Constraint.js +672 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts +47 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/IArmatureProxy.js +1 -0
- package/dist/dragonbones/dragonBones/armature/Slot.d.ts +357 -0
- package/dist/dragonbones/dragonBones/armature/Slot.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Slot.js +1009 -0
- package/dist/dragonbones/dragonBones/armature/Surface.d.ts +41 -0
- package/dist/dragonbones/dragonBones/armature/Surface.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/Surface.js +463 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts +80 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/armature/TransformObject.js +77 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.d.ts +53 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/core/BaseObject.js +130 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.d.ts +236 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/core/DragonBones.js +61 -0
- package/dist/dragonbones/dragonBones/event/EventObject.d.ts +143 -0
- package/dist/dragonbones/dragonBones/event/EventObject.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/event/EventObject.js +99 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts +48 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/event/IEventDispatcher.js +1 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts +292 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/factory/BaseFactory.js +735 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts +17 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/ColorTransform.js +33 -0
- package/dist/dragonbones/dragonBones/geom/Curve.d.ts +10 -0
- package/dist/dragonbones/dragonBones/geom/Curve.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Curve.js +26 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.d.ts +105 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Matrix.js +207 -0
- package/dist/dragonbones/dragonBones/geom/Point.d.ts +38 -0
- package/dist/dragonbones/dragonBones/geom/Point.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Point.js +31 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts +53 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Rectangle.js +37 -0
- package/dist/dragonbones/dragonBones/geom/Transform.d.ts +102 -0
- package/dist/dragonbones/dragonBones/geom/Transform.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/geom/Transform.js +170 -0
- package/dist/dragonbones/dragonBones/index.d.ts +37 -0
- package/dist/dragonbones/dragonBones/index.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/index.js +36 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts +162 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/AnimationConfig.js +81 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.d.ts +174 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/AnimationData.js +256 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts +319 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/ArmatureData.js +450 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts +188 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/BoundingBoxData.js +500 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.d.ts +15 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/CanvasData.js +17 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts +46 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/ConstraintData.js +57 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.d.ts +98 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/DisplayData.js +174 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts +108 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/DragonBonesData.js +86 -0
- package/dist/dragonbones/dragonBones/model/SkinData.d.ts +40 -0
- package/dist/dragonbones/dragonBones/model/SkinData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/SkinData.js +68 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts +73 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/TextureAtlasData.js +102 -0
- package/dist/dragonbones/dragonBones/model/UserData.d.ts +73 -0
- package/dist/dragonbones/dragonBones/model/UserData.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/model/UserData.js +101 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts +29 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/BinaryDataParser.js +356 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.d.ts +153 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/DataParser.js +283 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts +130 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones/parser/ObjectDataParser.js +2098 -0
- package/dist/dragonbones/index.js +1 -1
- package/dist/helper/utils.js +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Matrix } from "../geom/Matrix";
|
|
2
|
+
import { SurfaceData } from "../model/ArmatureData";
|
|
3
|
+
import { Armature } from "./Armature";
|
|
4
|
+
import { Bone } from "./Bone";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class Surface extends Bone {
|
|
9
|
+
static toString(): string;
|
|
10
|
+
private _dX;
|
|
11
|
+
private _dY;
|
|
12
|
+
private _k;
|
|
13
|
+
private _kX;
|
|
14
|
+
private _kY;
|
|
15
|
+
readonly _vertices: Array<number>;
|
|
16
|
+
readonly _deformVertices: Array<number>;
|
|
17
|
+
/**
|
|
18
|
+
* - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y
|
|
19
|
+
*/
|
|
20
|
+
private readonly _hullCache;
|
|
21
|
+
/**
|
|
22
|
+
* - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty]
|
|
23
|
+
*/
|
|
24
|
+
private readonly _matrixCahce;
|
|
25
|
+
_bone: Bone | null;
|
|
26
|
+
protected _onClear(): void;
|
|
27
|
+
private _getAffineTransform;
|
|
28
|
+
private _updateVertices;
|
|
29
|
+
protected _updateGlobalTransformMatrix(isCache: boolean): void;
|
|
30
|
+
_getGlobalTransformMatrix(x: number, y: number): Matrix;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
init(surfaceData: SurfaceData, armatureValue: Armature): void;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
update(cacheFrameIndex: number): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Surface.d.ts","sourceRoot":"","sources":["../../../../src/dragonbones/dragonBones/armature/Surface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,qBAAa,OAAQ,SAAQ,IAAI;WACjB,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,GAAG,CAAS;IAEpB,SAAgB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IAC9C,SAAgB,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IACpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAE3C,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,SAAS,CAAC,QAAQ,IAAI,IAAI;IAe1B,OAAO,CAAC,mBAAmB;IAmC3B,OAAO,CAAC,eAAe;IAmDvB,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IA8CvD,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IA2U9D;;;OAGG;IACI,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,GAAG,IAAI;IAuCpE;;OAEG;IACI,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI;CAyH7C"}
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { Bone } from "./Bone";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export class Surface extends Bone {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._vertices = [];
|
|
9
|
+
this._deformVertices = [];
|
|
10
|
+
/**
|
|
11
|
+
* - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y
|
|
12
|
+
*/
|
|
13
|
+
this._hullCache = [];
|
|
14
|
+
/**
|
|
15
|
+
* - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty]
|
|
16
|
+
*/
|
|
17
|
+
this._matrixCahce = [];
|
|
18
|
+
}
|
|
19
|
+
static toString() {
|
|
20
|
+
return "[class dragonBones.Surface]";
|
|
21
|
+
}
|
|
22
|
+
_onClear() {
|
|
23
|
+
super._onClear();
|
|
24
|
+
this._dX = 0.0;
|
|
25
|
+
this._dY = 0.0;
|
|
26
|
+
this._k = 0.0;
|
|
27
|
+
this._kX = 0.0;
|
|
28
|
+
this._kY = 0.0;
|
|
29
|
+
this._vertices.length = 0;
|
|
30
|
+
this._deformVertices.length = 0;
|
|
31
|
+
this._matrixCahce.length = 0;
|
|
32
|
+
this._hullCache.length = 0;
|
|
33
|
+
this._bone = null;
|
|
34
|
+
}
|
|
35
|
+
_getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) {
|
|
36
|
+
const dabX = bX - aX;
|
|
37
|
+
const dabY = bY - aY;
|
|
38
|
+
const dacX = cX - aX;
|
|
39
|
+
const dacY = cY - aY;
|
|
40
|
+
transform.rotation = Math.atan2(dabY, dabX);
|
|
41
|
+
transform.skew =
|
|
42
|
+
Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation;
|
|
43
|
+
if (isDown) {
|
|
44
|
+
transform.rotation += Math.PI;
|
|
45
|
+
}
|
|
46
|
+
transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX;
|
|
47
|
+
transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY;
|
|
48
|
+
transform.toMatrix(matrix);
|
|
49
|
+
transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y);
|
|
50
|
+
transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y);
|
|
51
|
+
}
|
|
52
|
+
_updateVertices() {
|
|
53
|
+
const data = this._armature.armatureData.parent;
|
|
54
|
+
const geometry = this._boneData.geometry;
|
|
55
|
+
const intArray = data.intArray;
|
|
56
|
+
const floatArray = data.floatArray;
|
|
57
|
+
const vertexCount = intArray[geometry.offset + 0 /* BinaryOffset.GeometryVertexCount */];
|
|
58
|
+
const verticesOffset = intArray[geometry.offset + 2 /* BinaryOffset.GeometryFloatOffset */];
|
|
59
|
+
const vertices = this._vertices;
|
|
60
|
+
const animationVertices = this._deformVertices;
|
|
61
|
+
if (this._parent !== null) {
|
|
62
|
+
if (this._parent._boneData.type === 1 /* BoneType.Surface */) {
|
|
63
|
+
for (let i = 0, l = vertexCount; i < l; ++i) {
|
|
64
|
+
const iD = i * 2;
|
|
65
|
+
const x = floatArray[verticesOffset + iD] + animationVertices[iD];
|
|
66
|
+
const y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1];
|
|
67
|
+
const matrix = this._parent._getGlobalTransformMatrix(x, y);
|
|
68
|
+
//
|
|
69
|
+
vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx;
|
|
70
|
+
vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const parentMatrix = this._parent.globalTransformMatrix;
|
|
75
|
+
for (let i = 0, l = vertexCount; i < l; ++i) {
|
|
76
|
+
const iD = i * 2;
|
|
77
|
+
const x = floatArray[verticesOffset + iD] + animationVertices[iD];
|
|
78
|
+
const y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1];
|
|
79
|
+
//
|
|
80
|
+
vertices[iD] =
|
|
81
|
+
parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx;
|
|
82
|
+
vertices[iD + 1] =
|
|
83
|
+
parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
for (let i = 0, l = vertexCount; i < l; ++i) {
|
|
89
|
+
const iD = i * 2;
|
|
90
|
+
vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD];
|
|
91
|
+
vertices[iD + 1] =
|
|
92
|
+
floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
_updateGlobalTransformMatrix(isCache) {
|
|
97
|
+
// tslint:disable-next-line:no-unused-expression
|
|
98
|
+
isCache;
|
|
99
|
+
const segmentXD = this._boneData.segmentX * 2;
|
|
100
|
+
const lastIndex = this._vertices.length - 2;
|
|
101
|
+
const lA = 200.0;
|
|
102
|
+
//
|
|
103
|
+
const raX = this._vertices[0];
|
|
104
|
+
const raY = this._vertices[1];
|
|
105
|
+
const rbX = this._vertices[segmentXD];
|
|
106
|
+
const rbY = this._vertices[segmentXD + 1];
|
|
107
|
+
const rcX = this._vertices[lastIndex];
|
|
108
|
+
const rcY = this._vertices[lastIndex + 1];
|
|
109
|
+
const rdX = this._vertices[lastIndex - segmentXD];
|
|
110
|
+
const rdY = this._vertices[lastIndex - segmentXD + 1];
|
|
111
|
+
//
|
|
112
|
+
const dacX = raX + (rcX - raX) * 0.5;
|
|
113
|
+
const dacY = raY + (rcY - raY) * 0.5;
|
|
114
|
+
const dbdX = rbX + (rdX - rbX) * 0.5;
|
|
115
|
+
const dbdY = rbY + (rdY - rbY) * 0.5;
|
|
116
|
+
const aX = dacX + (dbdX - dacX) * 0.5;
|
|
117
|
+
const aY = dacY + (dbdY - dacY) * 0.5;
|
|
118
|
+
const bX = rbX + (rcX - rbX) * 0.5;
|
|
119
|
+
const bY = rbY + (rcY - rbY) * 0.5;
|
|
120
|
+
const cX = rdX + (rcX - rdX) * 0.5;
|
|
121
|
+
const cY = rdY + (rcY - rdY) * 0.5;
|
|
122
|
+
// TODO interpolation
|
|
123
|
+
this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false);
|
|
124
|
+
this._globalDirty = false;
|
|
125
|
+
}
|
|
126
|
+
_getGlobalTransformMatrix(x, y) {
|
|
127
|
+
const lA = 200.0;
|
|
128
|
+
const lB = 1000.0;
|
|
129
|
+
if (x < -lB || lB < x || y < -lB || lB < y) {
|
|
130
|
+
return this.globalTransformMatrix;
|
|
131
|
+
}
|
|
132
|
+
let isDown = false;
|
|
133
|
+
const surfaceData = this._boneData;
|
|
134
|
+
const segmentX = surfaceData.segmentX;
|
|
135
|
+
const segmentY = surfaceData.segmentY;
|
|
136
|
+
const segmentXD = surfaceData.segmentX * 2;
|
|
137
|
+
const dX = this._dX;
|
|
138
|
+
const dY = this._dY;
|
|
139
|
+
const indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1
|
|
140
|
+
const indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1
|
|
141
|
+
let matrixIndex = 0;
|
|
142
|
+
let pX = indexX * dX - lA;
|
|
143
|
+
let pY = indexY * dY - lA;
|
|
144
|
+
//
|
|
145
|
+
const matrices = this._matrixCahce;
|
|
146
|
+
const helpMatrix = Surface._helpMatrix;
|
|
147
|
+
if (x < -lA) {
|
|
148
|
+
if (y < -lA || y >= lA) {
|
|
149
|
+
// Out.
|
|
150
|
+
return this.globalTransformMatrix;
|
|
151
|
+
}
|
|
152
|
+
// Left.
|
|
153
|
+
isDown = y > this._kX * (x + lA) + pY;
|
|
154
|
+
matrixIndex =
|
|
155
|
+
((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 +
|
|
156
|
+
(isDown ? 1 : 0)) *
|
|
157
|
+
7;
|
|
158
|
+
if (matrices[matrixIndex] > 0.0) {
|
|
159
|
+
helpMatrix.copyFromArray(matrices, matrixIndex + 1);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const vertexIndex = indexY * (segmentXD + 2);
|
|
163
|
+
const ddX = this._hullCache[4];
|
|
164
|
+
const ddY = this._hullCache[5];
|
|
165
|
+
const sX = this._hullCache[2] - (segmentY - indexY) * ddX;
|
|
166
|
+
const sY = this._hullCache[3] - (segmentY - indexY) * ddY;
|
|
167
|
+
const vertices = this._vertices;
|
|
168
|
+
if (isDown) {
|
|
169
|
+
this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false);
|
|
173
|
+
}
|
|
174
|
+
matrices[matrixIndex] = 1.0;
|
|
175
|
+
matrices[matrixIndex + 1] = helpMatrix.a;
|
|
176
|
+
matrices[matrixIndex + 2] = helpMatrix.b;
|
|
177
|
+
matrices[matrixIndex + 3] = helpMatrix.c;
|
|
178
|
+
matrices[matrixIndex + 4] = helpMatrix.d;
|
|
179
|
+
matrices[matrixIndex + 5] = helpMatrix.tx;
|
|
180
|
+
matrices[matrixIndex + 6] = helpMatrix.ty;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (x >= lA) {
|
|
184
|
+
if (y < -lA || y >= lA) {
|
|
185
|
+
// Out.
|
|
186
|
+
return this.globalTransformMatrix;
|
|
187
|
+
}
|
|
188
|
+
// Right.
|
|
189
|
+
isDown = y > this._kX * (x - lB) + pY;
|
|
190
|
+
matrixIndex =
|
|
191
|
+
((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7;
|
|
192
|
+
if (matrices[matrixIndex] > 0.0) {
|
|
193
|
+
helpMatrix.copyFromArray(matrices, matrixIndex + 1);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const vertexIndex = (indexY + 1) * (segmentXD + 2) - 2;
|
|
197
|
+
const ddX = this._hullCache[4];
|
|
198
|
+
const ddY = this._hullCache[5];
|
|
199
|
+
const sX = this._hullCache[0] + indexY * ddX;
|
|
200
|
+
const sY = this._hullCache[1] + indexY * ddY;
|
|
201
|
+
const vertices = this._vertices;
|
|
202
|
+
if (isDown) {
|
|
203
|
+
this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false);
|
|
207
|
+
}
|
|
208
|
+
matrices[matrixIndex] = 1.0;
|
|
209
|
+
matrices[matrixIndex + 1] = helpMatrix.a;
|
|
210
|
+
matrices[matrixIndex + 2] = helpMatrix.b;
|
|
211
|
+
matrices[matrixIndex + 3] = helpMatrix.c;
|
|
212
|
+
matrices[matrixIndex + 4] = helpMatrix.d;
|
|
213
|
+
matrices[matrixIndex + 5] = helpMatrix.tx;
|
|
214
|
+
matrices[matrixIndex + 6] = helpMatrix.ty;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (y < -lA) {
|
|
218
|
+
if (x < -lA || x >= lA) {
|
|
219
|
+
// Out.
|
|
220
|
+
return this.globalTransformMatrix;
|
|
221
|
+
}
|
|
222
|
+
// Up.
|
|
223
|
+
isDown = y > this._kY * (x - pX - dX) - lB;
|
|
224
|
+
matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7;
|
|
225
|
+
if (matrices[matrixIndex] > 0.0) {
|
|
226
|
+
helpMatrix.copyFromArray(matrices, matrixIndex + 1);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const vertexIndex = indexX * 2;
|
|
230
|
+
const ddX = this._hullCache[10];
|
|
231
|
+
const ddY = this._hullCache[11];
|
|
232
|
+
const sX = this._hullCache[8] + indexX * ddX;
|
|
233
|
+
const sY = this._hullCache[9] + indexX * ddY;
|
|
234
|
+
const vertices = this._vertices;
|
|
235
|
+
if (isDown) {
|
|
236
|
+
this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false);
|
|
240
|
+
}
|
|
241
|
+
matrices[matrixIndex] = 1.0;
|
|
242
|
+
matrices[matrixIndex + 1] = helpMatrix.a;
|
|
243
|
+
matrices[matrixIndex + 2] = helpMatrix.b;
|
|
244
|
+
matrices[matrixIndex + 3] = helpMatrix.c;
|
|
245
|
+
matrices[matrixIndex + 4] = helpMatrix.d;
|
|
246
|
+
matrices[matrixIndex + 5] = helpMatrix.tx;
|
|
247
|
+
matrices[matrixIndex + 6] = helpMatrix.ty;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else if (y >= lA) {
|
|
251
|
+
if (x < -lA || x >= lA) {
|
|
252
|
+
// Out.
|
|
253
|
+
return this.globalTransformMatrix;
|
|
254
|
+
}
|
|
255
|
+
// Down
|
|
256
|
+
isDown = y > this._kY * (x - pX - dX) + lA;
|
|
257
|
+
matrixIndex =
|
|
258
|
+
((segmentX * segmentY + segmentX + segmentY + indexX) * 2 +
|
|
259
|
+
(isDown ? 1 : 0)) *
|
|
260
|
+
7;
|
|
261
|
+
if (matrices[matrixIndex] > 0.0) {
|
|
262
|
+
helpMatrix.copyFromArray(matrices, matrixIndex + 1);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const vertexIndex = segmentY * (segmentXD + 2) + indexX * 2;
|
|
266
|
+
const ddX = this._hullCache[10];
|
|
267
|
+
const ddY = this._hullCache[11];
|
|
268
|
+
const sX = this._hullCache[6] - (segmentX - indexX) * ddX;
|
|
269
|
+
const sY = this._hullCache[7] - (segmentX - indexX) * ddY;
|
|
270
|
+
const vertices = this._vertices;
|
|
271
|
+
if (isDown) {
|
|
272
|
+
this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false);
|
|
276
|
+
}
|
|
277
|
+
matrices[matrixIndex] = 1.0;
|
|
278
|
+
matrices[matrixIndex + 1] = helpMatrix.a;
|
|
279
|
+
matrices[matrixIndex + 2] = helpMatrix.b;
|
|
280
|
+
matrices[matrixIndex + 3] = helpMatrix.c;
|
|
281
|
+
matrices[matrixIndex + 4] = helpMatrix.d;
|
|
282
|
+
matrices[matrixIndex + 5] = helpMatrix.tx;
|
|
283
|
+
matrices[matrixIndex + 6] = helpMatrix.ty;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// Center.
|
|
288
|
+
isDown = y > this._k * (x - pX - dX) + pY;
|
|
289
|
+
matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7;
|
|
290
|
+
if (matrices[matrixIndex] > 0.0) {
|
|
291
|
+
helpMatrix.copyFromArray(matrices, matrixIndex + 1);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
const vertexIndex = indexX * 2 + indexY * (segmentXD + 2);
|
|
295
|
+
const vertices = this._vertices;
|
|
296
|
+
if (isDown) {
|
|
297
|
+
this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false);
|
|
301
|
+
}
|
|
302
|
+
matrices[matrixIndex] = 1.0;
|
|
303
|
+
matrices[matrixIndex + 1] = helpMatrix.a;
|
|
304
|
+
matrices[matrixIndex + 2] = helpMatrix.b;
|
|
305
|
+
matrices[matrixIndex + 3] = helpMatrix.c;
|
|
306
|
+
matrices[matrixIndex + 4] = helpMatrix.d;
|
|
307
|
+
matrices[matrixIndex + 5] = helpMatrix.tx;
|
|
308
|
+
matrices[matrixIndex + 6] = helpMatrix.ty;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return helpMatrix;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @internal
|
|
315
|
+
* @private
|
|
316
|
+
*/
|
|
317
|
+
init(surfaceData, armatureValue) {
|
|
318
|
+
if (this._boneData !== null) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
super.init(surfaceData, armatureValue);
|
|
322
|
+
const segmentX = surfaceData.segmentX;
|
|
323
|
+
const segmentY = surfaceData.segmentY;
|
|
324
|
+
const vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* BinaryOffset.GeometryVertexCount */];
|
|
325
|
+
const lB = 1000.0;
|
|
326
|
+
const lA = 200.0;
|
|
327
|
+
//
|
|
328
|
+
this._dX = (lA * 2.0) / segmentX;
|
|
329
|
+
this._dY = (lA * 2.0) / segmentY;
|
|
330
|
+
this._k = -this._dY / this._dX;
|
|
331
|
+
this._kX = -this._dY / (lB - lA);
|
|
332
|
+
this._kY = -(lB - lA) / this._dX;
|
|
333
|
+
this._vertices.length = vertexCount * 2;
|
|
334
|
+
this._deformVertices.length = vertexCount * 2;
|
|
335
|
+
this._matrixCahce.length =
|
|
336
|
+
(segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7;
|
|
337
|
+
this._hullCache.length = 10;
|
|
338
|
+
for (let i = 0; i < vertexCount * 2; ++i) {
|
|
339
|
+
this._deformVertices[i] = 0.0;
|
|
340
|
+
}
|
|
341
|
+
if (this._parent !== null) {
|
|
342
|
+
if (this._parent.boneData.type === 0 /* BoneType.Bone */) {
|
|
343
|
+
this._bone = this._parent;
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this._bone = this._parent._bone;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
update(cacheFrameIndex) {
|
|
354
|
+
if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) {
|
|
355
|
+
const cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex];
|
|
356
|
+
if (cachedFrameIndex >= 0 &&
|
|
357
|
+
this._cachedFrameIndex === cachedFrameIndex) {
|
|
358
|
+
// Same cache.
|
|
359
|
+
this._transformDirty = false;
|
|
360
|
+
}
|
|
361
|
+
else if (cachedFrameIndex >= 0) {
|
|
362
|
+
// Has been Cached.
|
|
363
|
+
this._transformDirty = true;
|
|
364
|
+
this._cachedFrameIndex = cachedFrameIndex;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
if (this._hasConstraint) {
|
|
368
|
+
// Update constraints.
|
|
369
|
+
for (const constraint of this._armature._constraints) {
|
|
370
|
+
if (constraint._root === this) {
|
|
371
|
+
constraint.update();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (this._transformDirty ||
|
|
376
|
+
(this._parent !== null && this._parent._childrenTransformDirty)) {
|
|
377
|
+
// Dirty.
|
|
378
|
+
this._transformDirty = true;
|
|
379
|
+
this._cachedFrameIndex = -1;
|
|
380
|
+
}
|
|
381
|
+
else if (this._cachedFrameIndex >= 0) {
|
|
382
|
+
// Same cache, but not set index yet.
|
|
383
|
+
this._transformDirty = false;
|
|
384
|
+
this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
// Dirty.
|
|
388
|
+
this._transformDirty = true;
|
|
389
|
+
this._cachedFrameIndex = -1;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
if (this._hasConstraint) {
|
|
395
|
+
// Update constraints.
|
|
396
|
+
for (const constraint of this._armature._constraints) {
|
|
397
|
+
if (constraint._root === this) {
|
|
398
|
+
constraint.update();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (this._transformDirty ||
|
|
403
|
+
(this._parent !== null && this._parent._childrenTransformDirty)) {
|
|
404
|
+
// Dirty.
|
|
405
|
+
cacheFrameIndex = -1;
|
|
406
|
+
this._transformDirty = true;
|
|
407
|
+
this._cachedFrameIndex = -1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (this._transformDirty) {
|
|
411
|
+
this._transformDirty = false;
|
|
412
|
+
this._childrenTransformDirty = true;
|
|
413
|
+
//
|
|
414
|
+
for (let i = 0, l = this._matrixCahce.length; i < l; i += 7) {
|
|
415
|
+
this._matrixCahce[i] = -1.0;
|
|
416
|
+
}
|
|
417
|
+
//
|
|
418
|
+
this._updateVertices();
|
|
419
|
+
//
|
|
420
|
+
if (this._cachedFrameIndex < 0) {
|
|
421
|
+
const isCache = cacheFrameIndex >= 0;
|
|
422
|
+
if (this._localDirty) {
|
|
423
|
+
this._updateGlobalTransformMatrix(isCache);
|
|
424
|
+
}
|
|
425
|
+
if (isCache && this._cachedFrameIndices !== null) {
|
|
426
|
+
this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] =
|
|
427
|
+
this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex);
|
|
432
|
+
}
|
|
433
|
+
// Update hull vertices.
|
|
434
|
+
const lB = 1000.0;
|
|
435
|
+
const lA = 200.0;
|
|
436
|
+
const ddX = 2 * this.global.x;
|
|
437
|
+
const ddY = 2 * this.global.y;
|
|
438
|
+
//
|
|
439
|
+
const helpPoint = Surface._helpPoint;
|
|
440
|
+
this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint);
|
|
441
|
+
this._hullCache[0] = helpPoint.x;
|
|
442
|
+
this._hullCache[1] = helpPoint.y;
|
|
443
|
+
this._hullCache[2] = ddX - helpPoint.x;
|
|
444
|
+
this._hullCache[3] = ddY - helpPoint.y;
|
|
445
|
+
this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true);
|
|
446
|
+
this._hullCache[4] = helpPoint.x;
|
|
447
|
+
this._hullCache[5] = helpPoint.y;
|
|
448
|
+
//
|
|
449
|
+
this.globalTransformMatrix.transformPoint(lA, lB, helpPoint);
|
|
450
|
+
this._hullCache[6] = helpPoint.x;
|
|
451
|
+
this._hullCache[7] = helpPoint.y;
|
|
452
|
+
this._hullCache[8] = ddX - helpPoint.x;
|
|
453
|
+
this._hullCache[9] = ddY - helpPoint.y;
|
|
454
|
+
this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true);
|
|
455
|
+
this._hullCache[10] = helpPoint.x;
|
|
456
|
+
this._hullCache[11] = helpPoint.y;
|
|
457
|
+
}
|
|
458
|
+
else if (this._childrenTransformDirty) {
|
|
459
|
+
this._childrenTransformDirty = false;
|
|
460
|
+
}
|
|
461
|
+
this._localDirty = true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BaseObject } from "../core/BaseObject";
|
|
2
|
+
import { Matrix } from "../geom/Matrix";
|
|
3
|
+
import { Point } from "../geom/Point";
|
|
4
|
+
import { Transform } from "../geom/Transform";
|
|
5
|
+
import { Armature } from "./Armature";
|
|
6
|
+
/**
|
|
7
|
+
* - The base class of the transform object.
|
|
8
|
+
* @see dragonBones.Transform
|
|
9
|
+
* @version DragonBones 4.5
|
|
10
|
+
* @language en_US
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class TransformObject extends BaseObject {
|
|
13
|
+
protected static readonly _helpMatrix: Matrix;
|
|
14
|
+
protected static readonly _helpTransform: Transform;
|
|
15
|
+
protected static readonly _helpPoint: Point;
|
|
16
|
+
/**
|
|
17
|
+
* - A matrix relative to the armature coordinate system.
|
|
18
|
+
* @version DragonBones 3.0
|
|
19
|
+
* @language en_US
|
|
20
|
+
*/
|
|
21
|
+
readonly globalTransformMatrix: Matrix;
|
|
22
|
+
/**
|
|
23
|
+
* - A transform relative to the armature coordinate system.
|
|
24
|
+
* @see #updateGlobalTransform()
|
|
25
|
+
* @version DragonBones 3.0
|
|
26
|
+
* @language en_US
|
|
27
|
+
*/
|
|
28
|
+
readonly global: Transform;
|
|
29
|
+
/**
|
|
30
|
+
* - The offset transform relative to the armature or the parent bone coordinate system.
|
|
31
|
+
* @see #dragonBones.Bone#invalidUpdate()
|
|
32
|
+
* @version DragonBones 3.0
|
|
33
|
+
* @language en_US
|
|
34
|
+
*/
|
|
35
|
+
readonly offset: Transform;
|
|
36
|
+
/**
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
origin: Transform | null;
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
userData: any;
|
|
44
|
+
protected _globalDirty: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
_alpha: number;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
_globalAlpha: number;
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
_armature: Armature;
|
|
57
|
+
/**
|
|
58
|
+
*/
|
|
59
|
+
protected _onClear(): void;
|
|
60
|
+
/**
|
|
61
|
+
* - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible,
|
|
62
|
+
* some engines do not rely on these attributes to update rendering, such as Egret.
|
|
63
|
+
* The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale.
|
|
64
|
+
* @example
|
|
65
|
+
* <pre>
|
|
66
|
+
* bone.updateGlobalTransform();
|
|
67
|
+
* let rotation = bone.global.rotation;
|
|
68
|
+
* </pre>
|
|
69
|
+
* @version DragonBones 3.0
|
|
70
|
+
* @language en_US
|
|
71
|
+
*/
|
|
72
|
+
updateGlobalTransform(): void;
|
|
73
|
+
/**
|
|
74
|
+
* - The armature to which it belongs.
|
|
75
|
+
* @version DragonBones 3.0
|
|
76
|
+
* @language en_US
|
|
77
|
+
*/
|
|
78
|
+
get armature(): Armature;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=TransformObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformObject.d.ts","sourceRoot":"","sources":["../../../../src/dragonbones/dragonBones/armature/TransformObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC;;;;;GAKG;AACH,8BAAsB,eAAgB,SAAQ,UAAU;IACtD,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAgB;IAC7D,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,SAAS,CAAmB;IACtE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAe;IAC1D;;;;OAIG;IACH,SAAgB,qBAAqB,EAAE,MAAM,CAAgB;IAC7D;;;;;OAKG;IACH,SAAgB,MAAM,EAAE,SAAS,CAAmB;IACpD;;;;;OAKG;IACH,SAAgB,MAAM,EAAE,SAAS,CAAmB;IACpD;;OAEG;IACI,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC;;OAEG;IACI,QAAQ,EAAE,GAAG,CAAC;IACrB,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAChC;;OAEG;IACI,MAAM,EAAE,MAAM,CAAC;IACtB;;OAEG;IACI,YAAY,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACI,SAAS,EAAE,QAAQ,CAAC;IAC3B;OACG;IACH,SAAS,CAAC,QAAQ,IAAI,IAAI;IAY1B;;;;;;;;;;;OAWG;IACI,qBAAqB,IAAI,IAAI;IAMpC;;;;OAIG;IACH,IAAW,QAAQ,IAAI,QAAQ,CAE9B;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BaseObject } from "../core/BaseObject";
|
|
2
|
+
import { Matrix } from "../geom/Matrix";
|
|
3
|
+
import { Point } from "../geom/Point";
|
|
4
|
+
import { Transform } from "../geom/Transform";
|
|
5
|
+
/**
|
|
6
|
+
* - The base class of the transform object.
|
|
7
|
+
* @see dragonBones.Transform
|
|
8
|
+
* @version DragonBones 4.5
|
|
9
|
+
* @language en_US
|
|
10
|
+
*/
|
|
11
|
+
export class TransformObject extends BaseObject {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
/**
|
|
15
|
+
* - A matrix relative to the armature coordinate system.
|
|
16
|
+
* @version DragonBones 3.0
|
|
17
|
+
* @language en_US
|
|
18
|
+
*/
|
|
19
|
+
this.globalTransformMatrix = new Matrix();
|
|
20
|
+
/**
|
|
21
|
+
* - A transform relative to the armature coordinate system.
|
|
22
|
+
* @see #updateGlobalTransform()
|
|
23
|
+
* @version DragonBones 3.0
|
|
24
|
+
* @language en_US
|
|
25
|
+
*/
|
|
26
|
+
this.global = new Transform();
|
|
27
|
+
/**
|
|
28
|
+
* - The offset transform relative to the armature or the parent bone coordinate system.
|
|
29
|
+
* @see #dragonBones.Bone#invalidUpdate()
|
|
30
|
+
* @version DragonBones 3.0
|
|
31
|
+
* @language en_US
|
|
32
|
+
*/
|
|
33
|
+
this.offset = new Transform();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*/
|
|
37
|
+
_onClear() {
|
|
38
|
+
this.globalTransformMatrix.identity();
|
|
39
|
+
this.global.identity();
|
|
40
|
+
this.offset.identity();
|
|
41
|
+
this.origin = null;
|
|
42
|
+
this.userData = null;
|
|
43
|
+
this._globalDirty = false;
|
|
44
|
+
this._alpha = 1.0;
|
|
45
|
+
this._globalAlpha = 1.0;
|
|
46
|
+
this._armature = null; //
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible,
|
|
50
|
+
* some engines do not rely on these attributes to update rendering, such as Egret.
|
|
51
|
+
* The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale.
|
|
52
|
+
* @example
|
|
53
|
+
* <pre>
|
|
54
|
+
* bone.updateGlobalTransform();
|
|
55
|
+
* let rotation = bone.global.rotation;
|
|
56
|
+
* </pre>
|
|
57
|
+
* @version DragonBones 3.0
|
|
58
|
+
* @language en_US
|
|
59
|
+
*/
|
|
60
|
+
updateGlobalTransform() {
|
|
61
|
+
if (this._globalDirty) {
|
|
62
|
+
this._globalDirty = false;
|
|
63
|
+
this.global.fromMatrix(this.globalTransformMatrix);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* - The armature to which it belongs.
|
|
68
|
+
* @version DragonBones 3.0
|
|
69
|
+
* @language en_US
|
|
70
|
+
*/
|
|
71
|
+
get armature() {
|
|
72
|
+
return this._armature;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
TransformObject._helpMatrix = new Matrix();
|
|
76
|
+
TransformObject._helpTransform = new Transform();
|
|
77
|
+
TransformObject._helpPoint = new Point();
|