@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,1009 @@
|
|
|
1
|
+
import { BaseObject } from "../core/BaseObject";
|
|
2
|
+
import { DragonBones, } from "../core/DragonBones";
|
|
3
|
+
import { EventObject } from "../event/EventObject";
|
|
4
|
+
import { ColorTransform } from "../geom/ColorTransform";
|
|
5
|
+
import { Matrix } from "../geom/Matrix";
|
|
6
|
+
import { Armature } from "./Armature";
|
|
7
|
+
import { TransformObject } from "./TransformObject";
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export class DisplayFrame extends BaseObject {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.deformVertices = [];
|
|
15
|
+
}
|
|
16
|
+
static toString() {
|
|
17
|
+
return "[class dragonBones.DisplayFrame]";
|
|
18
|
+
}
|
|
19
|
+
_onClear() {
|
|
20
|
+
this.rawDisplayData = null;
|
|
21
|
+
this.displayData = null;
|
|
22
|
+
this.textureData = null;
|
|
23
|
+
this.display = null;
|
|
24
|
+
this.deformVertices.length = 0;
|
|
25
|
+
}
|
|
26
|
+
updateDeformVertices() {
|
|
27
|
+
if (this.rawDisplayData === null || this.deformVertices.length !== 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let rawGeometryData;
|
|
31
|
+
if (this.rawDisplayData.type === 2 /* DisplayType.Mesh */) {
|
|
32
|
+
rawGeometryData = this.rawDisplayData.geometry;
|
|
33
|
+
}
|
|
34
|
+
else if (this.rawDisplayData.type === 4 /* DisplayType.Path */) {
|
|
35
|
+
rawGeometryData = this.rawDisplayData.geometry;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let vertexCount = 0;
|
|
41
|
+
if (rawGeometryData.weight !== null) {
|
|
42
|
+
vertexCount = rawGeometryData.weight.count * 2;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
vertexCount =
|
|
46
|
+
rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* BinaryOffset.GeometryVertexCount */] * 2;
|
|
47
|
+
}
|
|
48
|
+
this.deformVertices.length = vertexCount;
|
|
49
|
+
for (let i = 0, l = this.deformVertices.length; i < l; ++i) {
|
|
50
|
+
this.deformVertices[i] = 0.0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getGeometryData() {
|
|
54
|
+
if (this.displayData !== null) {
|
|
55
|
+
if (this.displayData.type === 2 /* DisplayType.Mesh */) {
|
|
56
|
+
return this.displayData.geometry;
|
|
57
|
+
}
|
|
58
|
+
if (this.displayData.type === 4 /* DisplayType.Path */) {
|
|
59
|
+
return this.displayData.geometry;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (this.rawDisplayData !== null) {
|
|
63
|
+
if (this.rawDisplayData.type === 2 /* DisplayType.Mesh */) {
|
|
64
|
+
return this.rawDisplayData.geometry;
|
|
65
|
+
}
|
|
66
|
+
if (this.rawDisplayData.type === 4 /* DisplayType.Path */) {
|
|
67
|
+
return this.rawDisplayData.geometry;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
getBoundingBox() {
|
|
73
|
+
if (this.displayData !== null &&
|
|
74
|
+
this.displayData.type === 3 /* DisplayType.BoundingBox */) {
|
|
75
|
+
return this.displayData.boundingBox;
|
|
76
|
+
}
|
|
77
|
+
if (this.rawDisplayData !== null &&
|
|
78
|
+
this.rawDisplayData.type === 3 /* DisplayType.BoundingBox */) {
|
|
79
|
+
return this.rawDisplayData.boundingBox;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
getTextureData() {
|
|
84
|
+
if (this.displayData !== null) {
|
|
85
|
+
if (this.displayData.type === 0 /* DisplayType.Image */) {
|
|
86
|
+
return this.displayData.texture;
|
|
87
|
+
}
|
|
88
|
+
if (this.displayData.type === 2 /* DisplayType.Mesh */) {
|
|
89
|
+
return this.displayData.texture;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (this.textureData !== null) {
|
|
93
|
+
return this.textureData;
|
|
94
|
+
}
|
|
95
|
+
if (this.rawDisplayData !== null) {
|
|
96
|
+
if (this.rawDisplayData.type === 0 /* DisplayType.Image */) {
|
|
97
|
+
return this.rawDisplayData.texture;
|
|
98
|
+
}
|
|
99
|
+
if (this.rawDisplayData.type === 2 /* DisplayType.Mesh */) {
|
|
100
|
+
return this.rawDisplayData.texture;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* - The slot attached to the armature, controls the display status and properties of the display object.
|
|
108
|
+
* A bone can contain multiple slots.
|
|
109
|
+
* A slot can contain multiple display objects, displaying only one of the display objects at a time,
|
|
110
|
+
* but you can toggle the display object into frame animation while the animation is playing.
|
|
111
|
+
* The display object can be a normal texture, or it can be a display of a child armature, a grid display object,
|
|
112
|
+
* and a custom other display object.
|
|
113
|
+
* @see dragonBones.Armature
|
|
114
|
+
* @see dragonBones.Bone
|
|
115
|
+
* @see dragonBones.SlotData
|
|
116
|
+
* @version DragonBones 3.0
|
|
117
|
+
* @language en_US
|
|
118
|
+
*/
|
|
119
|
+
export class Slot extends TransformObject {
|
|
120
|
+
constructor() {
|
|
121
|
+
super(...arguments);
|
|
122
|
+
this._localMatrix = new Matrix();
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
this._colorTransform = new ColorTransform();
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
this._displayFrames = [];
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
this._geometryBones = [];
|
|
135
|
+
this._rawDisplay = null; // Initial value.
|
|
136
|
+
this._meshDisplay = null; // Initial value.
|
|
137
|
+
this._display = null;
|
|
138
|
+
}
|
|
139
|
+
_onClear() {
|
|
140
|
+
super._onClear();
|
|
141
|
+
const disposeDisplayList = [];
|
|
142
|
+
for (const dispayFrame of this._displayFrames) {
|
|
143
|
+
const display = dispayFrame.display;
|
|
144
|
+
if (display !== this._rawDisplay &&
|
|
145
|
+
display !== this._meshDisplay &&
|
|
146
|
+
disposeDisplayList.indexOf(display) < 0) {
|
|
147
|
+
disposeDisplayList.push(display);
|
|
148
|
+
}
|
|
149
|
+
dispayFrame.returnToPool();
|
|
150
|
+
}
|
|
151
|
+
for (const eachDisplay of disposeDisplayList) {
|
|
152
|
+
if (eachDisplay instanceof Armature) {
|
|
153
|
+
eachDisplay.dispose();
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this._disposeDisplay(eachDisplay, true);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) {
|
|
160
|
+
// May be _meshDisplay and _rawDisplay is the same one.
|
|
161
|
+
this._disposeDisplay(this._meshDisplay, false);
|
|
162
|
+
}
|
|
163
|
+
if (this._rawDisplay !== null) {
|
|
164
|
+
this._disposeDisplay(this._rawDisplay, false);
|
|
165
|
+
}
|
|
166
|
+
this.displayController = null;
|
|
167
|
+
this._displayDataDirty = false;
|
|
168
|
+
this._displayDirty = false;
|
|
169
|
+
this._geometryDirty = false;
|
|
170
|
+
this._textureDirty = false;
|
|
171
|
+
this._visibleDirty = false;
|
|
172
|
+
this._blendModeDirty = false;
|
|
173
|
+
this._zOrderDirty = false;
|
|
174
|
+
this._colorDirty = false;
|
|
175
|
+
this._verticesDirty = false;
|
|
176
|
+
this._transformDirty = false;
|
|
177
|
+
this._visible = true;
|
|
178
|
+
this._blendMode = 0 /* BlendMode.Normal */;
|
|
179
|
+
this._displayIndex = -1;
|
|
180
|
+
this._animationDisplayIndex = -1;
|
|
181
|
+
this._zOrder = 0;
|
|
182
|
+
this._zIndex = 0;
|
|
183
|
+
this._cachedFrameIndex = -1;
|
|
184
|
+
this._pivotX = 0.0;
|
|
185
|
+
this._pivotY = 0.0;
|
|
186
|
+
this._localMatrix.identity();
|
|
187
|
+
this._colorTransform.identity();
|
|
188
|
+
this._displayFrames.length = 0;
|
|
189
|
+
this._geometryBones.length = 0;
|
|
190
|
+
this._slotData = null; //
|
|
191
|
+
this._displayFrame = null;
|
|
192
|
+
this._geometryData = null;
|
|
193
|
+
this._boundingBoxData = null;
|
|
194
|
+
this._textureData = null;
|
|
195
|
+
this._rawDisplay = null;
|
|
196
|
+
this._meshDisplay = null;
|
|
197
|
+
this._display = null;
|
|
198
|
+
this._childArmature = null;
|
|
199
|
+
this._parent = null; //
|
|
200
|
+
this._cachedFrameIndices = null;
|
|
201
|
+
}
|
|
202
|
+
_hasDisplay(display) {
|
|
203
|
+
for (const displayFrame of this._displayFrames) {
|
|
204
|
+
if (displayFrame.display === display) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
_isBonesUpdate() {
|
|
214
|
+
for (const bone of this._geometryBones) {
|
|
215
|
+
if (bone !== null && bone._childrenTransformDirty) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
_updateAlpha() {
|
|
225
|
+
const globalAlpha = this._alpha * this._parent._globalAlpha;
|
|
226
|
+
if (this._globalAlpha !== globalAlpha) {
|
|
227
|
+
this._globalAlpha = globalAlpha;
|
|
228
|
+
this._colorDirty = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
_updateDisplayData() {
|
|
232
|
+
const prevDisplayFrame = this._displayFrame;
|
|
233
|
+
const prevGeometryData = this._geometryData;
|
|
234
|
+
const prevTextureData = this._textureData;
|
|
235
|
+
let rawDisplayData = null;
|
|
236
|
+
let displayData = null;
|
|
237
|
+
this._displayFrame = null;
|
|
238
|
+
this._geometryData = null;
|
|
239
|
+
this._boundingBoxData = null;
|
|
240
|
+
this._textureData = null;
|
|
241
|
+
if (this._displayIndex >= 0 &&
|
|
242
|
+
this._displayIndex < this._displayFrames.length) {
|
|
243
|
+
this._displayFrame = this._displayFrames[this._displayIndex];
|
|
244
|
+
rawDisplayData = this._displayFrame.rawDisplayData;
|
|
245
|
+
displayData = this._displayFrame.displayData;
|
|
246
|
+
this._geometryData = this._displayFrame.getGeometryData();
|
|
247
|
+
this._boundingBoxData = this._displayFrame.getBoundingBox();
|
|
248
|
+
this._textureData = this._displayFrame.getTextureData();
|
|
249
|
+
}
|
|
250
|
+
if (this._displayFrame !== prevDisplayFrame ||
|
|
251
|
+
this._geometryData !== prevGeometryData ||
|
|
252
|
+
this._textureData !== prevTextureData) {
|
|
253
|
+
// Update pivot offset.
|
|
254
|
+
if (this._geometryData === null && this._textureData !== null) {
|
|
255
|
+
const imageDisplayData = (displayData !== null && displayData.type === 0 /* DisplayType.Image */
|
|
256
|
+
? displayData
|
|
257
|
+
: rawDisplayData); //
|
|
258
|
+
const scale = this._textureData.parent.scale * this._armature._armatureData.scale;
|
|
259
|
+
const frame = this._textureData.frame;
|
|
260
|
+
this._pivotX = imageDisplayData.pivot.x;
|
|
261
|
+
this._pivotY = imageDisplayData.pivot.y;
|
|
262
|
+
const rect = frame !== null ? frame : this._textureData.region;
|
|
263
|
+
let width = rect.width;
|
|
264
|
+
let height = rect.height;
|
|
265
|
+
if (this._textureData.rotated && frame === null) {
|
|
266
|
+
width = rect.height;
|
|
267
|
+
height = rect.width;
|
|
268
|
+
}
|
|
269
|
+
this._pivotX *= width * scale;
|
|
270
|
+
this._pivotY *= height * scale;
|
|
271
|
+
if (frame !== null) {
|
|
272
|
+
this._pivotX += frame.x * scale;
|
|
273
|
+
this._pivotY += frame.y * scale;
|
|
274
|
+
}
|
|
275
|
+
// Update replace pivot. TODO
|
|
276
|
+
if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) {
|
|
277
|
+
rawDisplayData.transform.toMatrix(Slot._helpMatrix);
|
|
278
|
+
Slot._helpMatrix.invert();
|
|
279
|
+
Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint);
|
|
280
|
+
this._pivotX -= Slot._helpPoint.x;
|
|
281
|
+
this._pivotY -= Slot._helpPoint.y;
|
|
282
|
+
imageDisplayData.transform.toMatrix(Slot._helpMatrix);
|
|
283
|
+
Slot._helpMatrix.invert();
|
|
284
|
+
Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint);
|
|
285
|
+
this._pivotX += Slot._helpPoint.x;
|
|
286
|
+
this._pivotY += Slot._helpPoint.y;
|
|
287
|
+
}
|
|
288
|
+
if (!DragonBones.yDown) {
|
|
289
|
+
this._pivotY =
|
|
290
|
+
(this._textureData.rotated
|
|
291
|
+
? this._textureData.region.width
|
|
292
|
+
: this._textureData.region.height) *
|
|
293
|
+
scale -
|
|
294
|
+
this._pivotY;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
this._pivotX = 0.0;
|
|
299
|
+
this._pivotY = 0.0;
|
|
300
|
+
}
|
|
301
|
+
// Update original transform.
|
|
302
|
+
if (rawDisplayData !== null) {
|
|
303
|
+
// Compatible.
|
|
304
|
+
this.origin = rawDisplayData.transform;
|
|
305
|
+
}
|
|
306
|
+
else if (displayData !== null) {
|
|
307
|
+
// Compatible.
|
|
308
|
+
this.origin = displayData.transform;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.origin = null;
|
|
312
|
+
}
|
|
313
|
+
// TODO remove slot offset.
|
|
314
|
+
if (this.origin !== null) {
|
|
315
|
+
this.global
|
|
316
|
+
.copyFrom(this.origin)
|
|
317
|
+
.add(this.offset)
|
|
318
|
+
.toMatrix(this._localMatrix);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this.global.copyFrom(this.offset).toMatrix(this._localMatrix);
|
|
322
|
+
}
|
|
323
|
+
// Update geometry.
|
|
324
|
+
if (this._geometryData !== prevGeometryData) {
|
|
325
|
+
this._geometryDirty = true;
|
|
326
|
+
this._verticesDirty = true;
|
|
327
|
+
if (this._geometryData !== null) {
|
|
328
|
+
this._geometryBones.length = 0;
|
|
329
|
+
if (this._geometryData.weight !== null) {
|
|
330
|
+
for (let i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) {
|
|
331
|
+
const bone = this._armature.getBone(this._geometryData.weight.bones[i].name);
|
|
332
|
+
this._geometryBones.push(bone);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this._geometryBones.length = 0;
|
|
338
|
+
this._geometryData = null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
this._textureDirty = this._textureData !== prevTextureData;
|
|
342
|
+
this._transformDirty = true;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
_updateDisplay() {
|
|
346
|
+
const prevDisplay = this._display !== null ? this._display : this._rawDisplay;
|
|
347
|
+
const prevChildArmature = this._childArmature;
|
|
348
|
+
// Update display and child armature.
|
|
349
|
+
if (this._displayFrame !== null) {
|
|
350
|
+
this._display = this._displayFrame.display;
|
|
351
|
+
if (this._display !== null && this._display instanceof Armature) {
|
|
352
|
+
this._childArmature = this._display;
|
|
353
|
+
this._display = this._childArmature.display;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
this._childArmature = null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
this._display = null;
|
|
361
|
+
this._childArmature = null;
|
|
362
|
+
}
|
|
363
|
+
// Update display.
|
|
364
|
+
const currentDisplay = this._display !== null ? this._display : this._rawDisplay;
|
|
365
|
+
if (currentDisplay !== prevDisplay) {
|
|
366
|
+
this._textureDirty = true;
|
|
367
|
+
this._visibleDirty = true;
|
|
368
|
+
this._blendModeDirty = true;
|
|
369
|
+
// this._zOrderDirty = true;
|
|
370
|
+
this._colorDirty = true;
|
|
371
|
+
this._transformDirty = true;
|
|
372
|
+
this._onUpdateDisplay();
|
|
373
|
+
this._replaceDisplay(prevDisplay);
|
|
374
|
+
}
|
|
375
|
+
// Update child armature.
|
|
376
|
+
if (this._childArmature !== prevChildArmature) {
|
|
377
|
+
if (prevChildArmature !== null) {
|
|
378
|
+
prevChildArmature._parent = null; // Update child armature parent.
|
|
379
|
+
prevChildArmature.clock = null;
|
|
380
|
+
if (prevChildArmature.inheritAnimation) {
|
|
381
|
+
prevChildArmature.animation.reset();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (this._childArmature !== null) {
|
|
385
|
+
this._childArmature._parent = this; // Update child armature parent.
|
|
386
|
+
this._childArmature.clock = this._armature.clock;
|
|
387
|
+
if (this._childArmature.inheritAnimation) {
|
|
388
|
+
// Set child armature cache frameRate.
|
|
389
|
+
if (this._childArmature.cacheFrameRate === 0) {
|
|
390
|
+
const cacheFrameRate = this._armature.cacheFrameRate;
|
|
391
|
+
if (cacheFrameRate !== 0) {
|
|
392
|
+
this._childArmature.cacheFrameRate = cacheFrameRate;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Child armature action.
|
|
396
|
+
if (this._displayFrame !== null) {
|
|
397
|
+
let actions = null;
|
|
398
|
+
let displayData = this._displayFrame.displayData !== null
|
|
399
|
+
? this._displayFrame.displayData
|
|
400
|
+
: this._displayFrame.rawDisplayData;
|
|
401
|
+
if (displayData !== null &&
|
|
402
|
+
displayData.type === 1 /* DisplayType.Armature */) {
|
|
403
|
+
actions = displayData.actions;
|
|
404
|
+
}
|
|
405
|
+
if (actions !== null && actions.length > 0) {
|
|
406
|
+
for (const action of actions) {
|
|
407
|
+
const eventObject = BaseObject.borrowObject(EventObject);
|
|
408
|
+
EventObject.actionDataToInstance(action, eventObject, this._armature);
|
|
409
|
+
eventObject.slot = this;
|
|
410
|
+
this._armature._bufferAction(eventObject, false);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
this._childArmature.animation.play();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
_updateGlobalTransformMatrix(isCache) {
|
|
422
|
+
const parentMatrix = this._parent._boneData.type === 0 /* BoneType.Bone */
|
|
423
|
+
? this._parent.globalTransformMatrix
|
|
424
|
+
: this._parent._getGlobalTransformMatrix(this.global.x, this.global.y);
|
|
425
|
+
this.globalTransformMatrix.copyFrom(this._localMatrix);
|
|
426
|
+
this.globalTransformMatrix.concat(parentMatrix);
|
|
427
|
+
if (isCache) {
|
|
428
|
+
this.global.fromMatrix(this.globalTransformMatrix);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
this._globalDirty = true;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @internal
|
|
436
|
+
*/
|
|
437
|
+
_setDisplayIndex(value, isAnimation = false) {
|
|
438
|
+
if (isAnimation) {
|
|
439
|
+
if (this._animationDisplayIndex === value) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this._animationDisplayIndex = value;
|
|
443
|
+
}
|
|
444
|
+
if (this._displayIndex === value) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this._displayIndex =
|
|
448
|
+
value < this._displayFrames.length
|
|
449
|
+
? value
|
|
450
|
+
: this._displayFrames.length - 1;
|
|
451
|
+
this._displayDataDirty = true;
|
|
452
|
+
this._displayDirty =
|
|
453
|
+
this._displayIndex < 0 ||
|
|
454
|
+
this._display !== this._displayFrames[this._displayIndex].display;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @internal
|
|
458
|
+
*/
|
|
459
|
+
_setZOrder(value) {
|
|
460
|
+
if (this._zOrder === value) {
|
|
461
|
+
// return false;
|
|
462
|
+
}
|
|
463
|
+
this._zOrder = value;
|
|
464
|
+
this._zOrderDirty = true;
|
|
465
|
+
return this._zOrderDirty;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
_setColor(value) {
|
|
471
|
+
this._colorTransform.copyFrom(value);
|
|
472
|
+
return (this._colorDirty = true);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
init(slotData, armatureValue, rawDisplay, meshDisplay) {
|
|
478
|
+
if (this._slotData !== null) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
this._slotData = slotData;
|
|
482
|
+
this._colorDirty = true; //
|
|
483
|
+
this._blendModeDirty = true; //
|
|
484
|
+
this._blendMode = this._slotData.blendMode;
|
|
485
|
+
this._zOrder = this._slotData.zOrder;
|
|
486
|
+
this._zIndex = this._slotData.zIndex;
|
|
487
|
+
this._alpha = this._slotData.alpha;
|
|
488
|
+
this._colorTransform.copyFrom(this._slotData.color);
|
|
489
|
+
this._rawDisplay = rawDisplay;
|
|
490
|
+
this._meshDisplay = meshDisplay;
|
|
491
|
+
//
|
|
492
|
+
this._armature = armatureValue;
|
|
493
|
+
const slotParent = this._armature.getBone(this._slotData.parent.name);
|
|
494
|
+
if (slotParent !== null) {
|
|
495
|
+
this._parent = slotParent;
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
// Never;
|
|
499
|
+
}
|
|
500
|
+
this._armature._addSlot(this);
|
|
501
|
+
//
|
|
502
|
+
this._initDisplay(this._rawDisplay, false);
|
|
503
|
+
if (this._rawDisplay !== this._meshDisplay) {
|
|
504
|
+
this._initDisplay(this._meshDisplay, false);
|
|
505
|
+
}
|
|
506
|
+
this._onUpdateDisplay();
|
|
507
|
+
this._addDisplay();
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @internal
|
|
511
|
+
*/
|
|
512
|
+
update(cacheFrameIndex) {
|
|
513
|
+
if (this._displayDataDirty) {
|
|
514
|
+
this._updateDisplayData();
|
|
515
|
+
this._displayDataDirty = false;
|
|
516
|
+
}
|
|
517
|
+
if (this._displayDirty) {
|
|
518
|
+
this._updateDisplay();
|
|
519
|
+
this._displayDirty = false;
|
|
520
|
+
}
|
|
521
|
+
if (this._geometryDirty || this._textureDirty) {
|
|
522
|
+
if (this._display === null ||
|
|
523
|
+
this._display === this._rawDisplay ||
|
|
524
|
+
this._display === this._meshDisplay) {
|
|
525
|
+
this._updateFrame();
|
|
526
|
+
}
|
|
527
|
+
this._geometryDirty = false;
|
|
528
|
+
this._textureDirty = false;
|
|
529
|
+
}
|
|
530
|
+
if (this._display === null) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
if (this._visibleDirty) {
|
|
534
|
+
this._updateVisible();
|
|
535
|
+
this._visibleDirty = false;
|
|
536
|
+
}
|
|
537
|
+
if (this._blendModeDirty) {
|
|
538
|
+
this._updateBlendMode();
|
|
539
|
+
this._blendModeDirty = false;
|
|
540
|
+
}
|
|
541
|
+
if (this._colorDirty) {
|
|
542
|
+
this._updateColor();
|
|
543
|
+
this._colorDirty = false;
|
|
544
|
+
}
|
|
545
|
+
if (this._zOrderDirty) {
|
|
546
|
+
this._updateZOrder();
|
|
547
|
+
this._zOrderDirty = false;
|
|
548
|
+
}
|
|
549
|
+
if (this._geometryData !== null && this._display === this._meshDisplay) {
|
|
550
|
+
const isSkinned = this._geometryData.weight !== null;
|
|
551
|
+
const isSurface = this._parent._boneData.type !== 0 /* BoneType.Bone */;
|
|
552
|
+
if (this._verticesDirty ||
|
|
553
|
+
(isSkinned && this._isBonesUpdate()) ||
|
|
554
|
+
(isSurface && this._parent._childrenTransformDirty)) {
|
|
555
|
+
this._verticesDirty = false; // Allow update mesh to reset the dirty value.
|
|
556
|
+
this._updateMesh();
|
|
557
|
+
}
|
|
558
|
+
if (isSkinned || isSurface) {
|
|
559
|
+
// Compatible.
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) {
|
|
564
|
+
const cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex];
|
|
565
|
+
if (cachedFrameIndex >= 0 &&
|
|
566
|
+
this._cachedFrameIndex === cachedFrameIndex) {
|
|
567
|
+
// Same cache.
|
|
568
|
+
this._transformDirty = false;
|
|
569
|
+
}
|
|
570
|
+
else if (cachedFrameIndex >= 0) {
|
|
571
|
+
// Has been Cached.
|
|
572
|
+
this._transformDirty = true;
|
|
573
|
+
this._cachedFrameIndex = cachedFrameIndex;
|
|
574
|
+
}
|
|
575
|
+
else if (this._transformDirty || this._parent._childrenTransformDirty) {
|
|
576
|
+
// Dirty.
|
|
577
|
+
this._transformDirty = true;
|
|
578
|
+
this._cachedFrameIndex = -1;
|
|
579
|
+
}
|
|
580
|
+
else if (this._cachedFrameIndex >= 0) {
|
|
581
|
+
// Same cache, but not set index yet.
|
|
582
|
+
this._transformDirty = false;
|
|
583
|
+
this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex;
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
// Dirty.
|
|
587
|
+
this._transformDirty = true;
|
|
588
|
+
this._cachedFrameIndex = -1;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else if (this._transformDirty || this._parent._childrenTransformDirty) {
|
|
592
|
+
// Dirty.
|
|
593
|
+
cacheFrameIndex = -1;
|
|
594
|
+
this._transformDirty = true;
|
|
595
|
+
this._cachedFrameIndex = -1;
|
|
596
|
+
}
|
|
597
|
+
if (this._transformDirty) {
|
|
598
|
+
if (this._cachedFrameIndex < 0) {
|
|
599
|
+
const isCache = cacheFrameIndex >= 0;
|
|
600
|
+
this._updateGlobalTransformMatrix(isCache);
|
|
601
|
+
if (isCache && this._cachedFrameIndices !== null) {
|
|
602
|
+
this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] =
|
|
603
|
+
this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex);
|
|
608
|
+
}
|
|
609
|
+
this._updateTransform();
|
|
610
|
+
this._transformDirty = false;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* - Forces the slot to update the state of the display object in the next frame.
|
|
615
|
+
* @version DragonBones 4.5
|
|
616
|
+
* @language en_US
|
|
617
|
+
*/
|
|
618
|
+
invalidUpdate() {
|
|
619
|
+
this._displayDataDirty = true;
|
|
620
|
+
this._displayDirty = true;
|
|
621
|
+
//
|
|
622
|
+
this._transformDirty = true;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* @private
|
|
626
|
+
*/
|
|
627
|
+
updateTransformAndMatrix() {
|
|
628
|
+
if (this._transformDirty) {
|
|
629
|
+
this._updateGlobalTransformMatrix(false);
|
|
630
|
+
this._transformDirty = false;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* @private
|
|
635
|
+
*/
|
|
636
|
+
replaceRawDisplayData(displayData, index = -1) {
|
|
637
|
+
if (index < 0) {
|
|
638
|
+
index = this._displayIndex < 0 ? 0 : this._displayIndex;
|
|
639
|
+
}
|
|
640
|
+
else if (index >= this._displayFrames.length) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const displayFrame = this._displayFrames[index];
|
|
644
|
+
if (displayFrame.rawDisplayData !== displayData) {
|
|
645
|
+
displayFrame.deformVertices.length = 0;
|
|
646
|
+
displayFrame.rawDisplayData = displayData;
|
|
647
|
+
if (displayFrame.rawDisplayData === null) {
|
|
648
|
+
const defaultSkin = this._armature._armatureData.defaultSkin;
|
|
649
|
+
if (defaultSkin !== null) {
|
|
650
|
+
const defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name);
|
|
651
|
+
if (defaultRawDisplayDatas !== null &&
|
|
652
|
+
index < defaultRawDisplayDatas.length) {
|
|
653
|
+
displayFrame.rawDisplayData = defaultRawDisplayDatas[index];
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (index === this._displayIndex) {
|
|
658
|
+
this._displayDataDirty = true;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* @private
|
|
664
|
+
*/
|
|
665
|
+
replaceDisplayData(displayData, index = -1) {
|
|
666
|
+
if (index < 0) {
|
|
667
|
+
index = this._displayIndex < 0 ? 0 : this._displayIndex;
|
|
668
|
+
}
|
|
669
|
+
else if (index >= this._displayFrames.length) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const displayFrame = this._displayFrames[index];
|
|
673
|
+
if (displayFrame.displayData !== displayData &&
|
|
674
|
+
displayFrame.rawDisplayData !== displayData) {
|
|
675
|
+
displayFrame.displayData = displayData;
|
|
676
|
+
if (index === this._displayIndex) {
|
|
677
|
+
this._displayDataDirty = true;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* @private
|
|
683
|
+
*/
|
|
684
|
+
replaceTextureData(textureData, index = -1) {
|
|
685
|
+
if (index < 0) {
|
|
686
|
+
index = this._displayIndex < 0 ? 0 : this._displayIndex;
|
|
687
|
+
}
|
|
688
|
+
else if (index >= this._displayFrames.length) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
const displayFrame = this._displayFrames[index];
|
|
692
|
+
if (displayFrame.textureData !== textureData) {
|
|
693
|
+
displayFrame.textureData = textureData;
|
|
694
|
+
if (index === this._displayIndex) {
|
|
695
|
+
this._displayDataDirty = true;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* @private
|
|
701
|
+
*/
|
|
702
|
+
replaceDisplay(value, index = -1) {
|
|
703
|
+
if (index < 0) {
|
|
704
|
+
index = this._displayIndex < 0 ? 0 : this._displayIndex;
|
|
705
|
+
}
|
|
706
|
+
else if (index >= this._displayFrames.length) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const displayFrame = this._displayFrames[index];
|
|
710
|
+
if (displayFrame.display !== value) {
|
|
711
|
+
const prevDisplay = displayFrame.display;
|
|
712
|
+
displayFrame.display = value;
|
|
713
|
+
if (prevDisplay !== null &&
|
|
714
|
+
prevDisplay !== this._rawDisplay &&
|
|
715
|
+
prevDisplay !== this._meshDisplay &&
|
|
716
|
+
!this._hasDisplay(prevDisplay)) {
|
|
717
|
+
if (prevDisplay instanceof Armature) {
|
|
718
|
+
// (eachDisplay as Armature).dispose();
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
this._disposeDisplay(prevDisplay, true);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (value !== null &&
|
|
725
|
+
value !== this._rawDisplay &&
|
|
726
|
+
value !== this._meshDisplay &&
|
|
727
|
+
!this._hasDisplay(prevDisplay) &&
|
|
728
|
+
!(value instanceof Armature)) {
|
|
729
|
+
this._initDisplay(value, true);
|
|
730
|
+
}
|
|
731
|
+
if (index === this._displayIndex) {
|
|
732
|
+
this._displayDirty = true;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* - Check whether a specific point is inside a custom bounding box in the slot.
|
|
738
|
+
* The coordinate system of the point is the inner coordinate system of the armature.
|
|
739
|
+
* Custom bounding boxes need to be customized in Dragonbones Pro.
|
|
740
|
+
* @param x - The horizontal coordinate of the point.
|
|
741
|
+
* @param y - The vertical coordinate of the point.
|
|
742
|
+
* @version DragonBones 5.0
|
|
743
|
+
* @language en_US
|
|
744
|
+
*/
|
|
745
|
+
containsPoint(x, y) {
|
|
746
|
+
if (this._boundingBoxData === null) {
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
this.updateTransformAndMatrix();
|
|
750
|
+
Slot._helpMatrix.copyFrom(this.globalTransformMatrix);
|
|
751
|
+
Slot._helpMatrix.invert();
|
|
752
|
+
Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint);
|
|
753
|
+
return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y);
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* - Check whether a specific segment intersects a custom bounding box for the slot.
|
|
757
|
+
* The coordinate system of the segment and intersection is the inner coordinate system of the armature.
|
|
758
|
+
* Custom bounding boxes need to be customized in Dragonbones Pro.
|
|
759
|
+
* @param xA - The horizontal coordinate of the beginning of the segment.
|
|
760
|
+
* @param yA - The vertical coordinate of the beginning of the segment.
|
|
761
|
+
* @param xB - The horizontal coordinate of the end point of the segment.
|
|
762
|
+
* @param yB - The vertical coordinate of the end point of the segment.
|
|
763
|
+
* @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
|
|
764
|
+
* @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
|
|
765
|
+
* @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
|
|
766
|
+
* @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections]
|
|
767
|
+
* @version DragonBones 5.0
|
|
768
|
+
* @language en_US
|
|
769
|
+
*/
|
|
770
|
+
intersectsSegment(xA, yA, xB, yB, intersectionPointA = null, intersectionPointB = null, normalRadians = null) {
|
|
771
|
+
if (this._boundingBoxData === null) {
|
|
772
|
+
return 0;
|
|
773
|
+
}
|
|
774
|
+
this.updateTransformAndMatrix();
|
|
775
|
+
Slot._helpMatrix.copyFrom(this.globalTransformMatrix);
|
|
776
|
+
Slot._helpMatrix.invert();
|
|
777
|
+
Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint);
|
|
778
|
+
xA = Slot._helpPoint.x;
|
|
779
|
+
yA = Slot._helpPoint.y;
|
|
780
|
+
Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint);
|
|
781
|
+
xB = Slot._helpPoint.x;
|
|
782
|
+
yB = Slot._helpPoint.y;
|
|
783
|
+
const intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians);
|
|
784
|
+
if (intersectionCount > 0) {
|
|
785
|
+
if (intersectionCount === 1 || intersectionCount === 2) {
|
|
786
|
+
if (intersectionPointA !== null) {
|
|
787
|
+
this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA);
|
|
788
|
+
if (intersectionPointB !== null) {
|
|
789
|
+
intersectionPointB.x = intersectionPointA.x;
|
|
790
|
+
intersectionPointB.y = intersectionPointA.y;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
else if (intersectionPointB !== null) {
|
|
794
|
+
this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
if (intersectionPointA !== null) {
|
|
799
|
+
this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA);
|
|
800
|
+
}
|
|
801
|
+
if (intersectionPointB !== null) {
|
|
802
|
+
this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (normalRadians !== null) {
|
|
806
|
+
this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true);
|
|
807
|
+
normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x);
|
|
808
|
+
this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true);
|
|
809
|
+
normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return intersectionCount;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* @private
|
|
816
|
+
*/
|
|
817
|
+
getDisplayFrameAt(index) {
|
|
818
|
+
return this._displayFrames[index];
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* - The visible of slot's display object.
|
|
822
|
+
* @default true
|
|
823
|
+
* @version DragonBones 5.6
|
|
824
|
+
* @language en_US
|
|
825
|
+
*/
|
|
826
|
+
/**
|
|
827
|
+
* - 插槽的显示对象的可见。
|
|
828
|
+
* @default true
|
|
829
|
+
* @version DragonBones 5.6
|
|
830
|
+
* @language zh_CN
|
|
831
|
+
*/
|
|
832
|
+
get visible() {
|
|
833
|
+
return this._visible;
|
|
834
|
+
}
|
|
835
|
+
set visible(value) {
|
|
836
|
+
if (this._visible === value) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
this._visible = value;
|
|
840
|
+
this._updateVisible();
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* @private
|
|
844
|
+
*/
|
|
845
|
+
get displayFrameCount() {
|
|
846
|
+
return this._displayFrames.length;
|
|
847
|
+
}
|
|
848
|
+
set displayFrameCount(value) {
|
|
849
|
+
const prevCount = this._displayFrames.length;
|
|
850
|
+
if (prevCount < value) {
|
|
851
|
+
this._displayFrames.length = value;
|
|
852
|
+
for (let i = prevCount; i < value; ++i) {
|
|
853
|
+
this._displayFrames[i] = BaseObject.borrowObject(DisplayFrame);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
else if (prevCount > value) {
|
|
857
|
+
for (let i = prevCount - 1; i < value; --i) {
|
|
858
|
+
this.replaceDisplay(null, i);
|
|
859
|
+
this._displayFrames[i].returnToPool();
|
|
860
|
+
}
|
|
861
|
+
this._displayFrames.length = value;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* - The index of the display object displayed in the display list.
|
|
866
|
+
* @example
|
|
867
|
+
* <pre>
|
|
868
|
+
* let slot = armature.getSlot("weapon");
|
|
869
|
+
* slot.displayIndex = 3;
|
|
870
|
+
* slot.displayController = "none";
|
|
871
|
+
* </pre>
|
|
872
|
+
* @version DragonBones 4.5
|
|
873
|
+
* @language en_US
|
|
874
|
+
*/
|
|
875
|
+
get displayIndex() {
|
|
876
|
+
return this._displayIndex;
|
|
877
|
+
}
|
|
878
|
+
set displayIndex(value) {
|
|
879
|
+
this._setDisplayIndex(value);
|
|
880
|
+
this.update(-1);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* - The slot name.
|
|
884
|
+
* @see dragonBones.SlotData#name
|
|
885
|
+
* @version DragonBones 3.0
|
|
886
|
+
* @language en_US
|
|
887
|
+
*/
|
|
888
|
+
get name() {
|
|
889
|
+
return this._slotData.name;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* - Contains a display list of display objects or child armatures.
|
|
893
|
+
* @version DragonBones 3.0
|
|
894
|
+
* @language en_US
|
|
895
|
+
*/
|
|
896
|
+
get displayList() {
|
|
897
|
+
const displays = new Array();
|
|
898
|
+
for (const displayFrame of this._displayFrames) {
|
|
899
|
+
displays.push(displayFrame.display);
|
|
900
|
+
}
|
|
901
|
+
return displays;
|
|
902
|
+
}
|
|
903
|
+
set displayList(value) {
|
|
904
|
+
this.displayFrameCount = value.length;
|
|
905
|
+
let index = 0;
|
|
906
|
+
for (const eachDisplay of value) {
|
|
907
|
+
this.replaceDisplay(eachDisplay, index++);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* - The slot data.
|
|
912
|
+
* @see dragonBones.SlotData
|
|
913
|
+
* @version DragonBones 4.5
|
|
914
|
+
* @language en_US
|
|
915
|
+
*/
|
|
916
|
+
get slotData() {
|
|
917
|
+
return this._slotData;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* - The custom bounding box data for the slot at current time.
|
|
921
|
+
* @version DragonBones 5.0
|
|
922
|
+
* @language en_US
|
|
923
|
+
*/
|
|
924
|
+
get boundingBoxData() {
|
|
925
|
+
return this._boundingBoxData;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* @private
|
|
929
|
+
*/
|
|
930
|
+
get rawDisplay() {
|
|
931
|
+
return this._rawDisplay;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* @private
|
|
935
|
+
*/
|
|
936
|
+
get meshDisplay() {
|
|
937
|
+
return this._meshDisplay;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* - The display object that the slot displays at this time.
|
|
941
|
+
* @example
|
|
942
|
+
* <pre>
|
|
943
|
+
* let slot = armature.getSlot("text");
|
|
944
|
+
* slot.display = new yourEngine.TextField();
|
|
945
|
+
* </pre>
|
|
946
|
+
* @version DragonBones 3.0
|
|
947
|
+
* @language en_US
|
|
948
|
+
*/
|
|
949
|
+
get display() {
|
|
950
|
+
return this._display;
|
|
951
|
+
}
|
|
952
|
+
set display(value) {
|
|
953
|
+
if (this._display === value) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
if (this._displayFrames.length === 0) {
|
|
957
|
+
this.displayFrameCount = 1;
|
|
958
|
+
this._displayIndex = 0;
|
|
959
|
+
}
|
|
960
|
+
this.replaceDisplay(value, this._displayIndex);
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* - The child armature that the slot displayed at current time.
|
|
964
|
+
* @example
|
|
965
|
+
* <pre>
|
|
966
|
+
* let slot = armature.getSlot("weapon");
|
|
967
|
+
* let prevChildArmature = slot.childArmature;
|
|
968
|
+
* if (prevChildArmature) {
|
|
969
|
+
* prevChildArmature.dispose();
|
|
970
|
+
* }
|
|
971
|
+
* slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
|
|
972
|
+
* </pre>
|
|
973
|
+
* @version DragonBones 3.0
|
|
974
|
+
* @language en_US
|
|
975
|
+
*/
|
|
976
|
+
get childArmature() {
|
|
977
|
+
return this._childArmature;
|
|
978
|
+
}
|
|
979
|
+
set childArmature(value) {
|
|
980
|
+
if (this._childArmature === value) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
this.display = value;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* - The parent bone to which it belongs.
|
|
987
|
+
* @version DragonBones 3.0
|
|
988
|
+
* @language en_US
|
|
989
|
+
*/
|
|
990
|
+
get parent() {
|
|
991
|
+
return this._parent;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* - Deprecated, please refer to {@link #display}.
|
|
995
|
+
* @deprecated
|
|
996
|
+
* @language en_US
|
|
997
|
+
*/
|
|
998
|
+
getDisplay() {
|
|
999
|
+
return this._display;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* - Deprecated, please refer to {@link #display}.
|
|
1003
|
+
* @deprecated
|
|
1004
|
+
* @language en_US
|
|
1005
|
+
*/
|
|
1006
|
+
setDisplay(value) {
|
|
1007
|
+
this.display = value;
|
|
1008
|
+
}
|
|
1009
|
+
}
|