@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.
Files changed (146) hide show
  1. package/dist/app.d.ts +1 -0
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +20 -1
  4. package/dist/core/NodePool.d.ts +1 -1
  5. package/dist/core/Size.d.ts +0 -1
  6. package/dist/core/Size.d.ts.map +1 -1
  7. package/dist/dragonbones/DragonBonesComponent.d.ts +1 -1
  8. package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -1
  9. package/dist/dragonbones/DragonBonesComponent.js +1 -1
  10. package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
  11. package/dist/dragonbones/DragonBonesSystem.js +1 -1
  12. package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts +59 -0
  13. package/dist/dragonbones/db-pixi/PixiArmatureDisplay.d.ts.map +1 -0
  14. package/dist/dragonbones/db-pixi/PixiArmatureDisplay.js +180 -0
  15. package/dist/dragonbones/db-pixi/PixiFactory.d.ts +87 -0
  16. package/dist/dragonbones/db-pixi/PixiFactory.d.ts.map +1 -0
  17. package/dist/dragonbones/db-pixi/PixiFactory.js +159 -0
  18. package/dist/dragonbones/db-pixi/PixiSlot.d.ts +31 -0
  19. package/dist/dragonbones/db-pixi/PixiSlot.d.ts.map +1 -0
  20. package/dist/dragonbones/db-pixi/PixiSlot.js +332 -0
  21. package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts +38 -0
  22. package/dist/dragonbones/db-pixi/PixiTextureAtlasData.d.ts.map +1 -0
  23. package/dist/dragonbones/db-pixi/PixiTextureAtlasData.js +85 -0
  24. package/dist/dragonbones/db-pixi/index.d.ts +5 -0
  25. package/dist/dragonbones/db-pixi/index.d.ts.map +1 -0
  26. package/dist/dragonbones/db-pixi/index.js +4 -0
  27. package/dist/dragonbones/dragonBones/animation/Animation.d.ts +241 -0
  28. package/dist/dragonbones/dragonBones/animation/Animation.d.ts.map +1 -0
  29. package/dist/dragonbones/dragonBones/animation/Animation.js +692 -0
  30. package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts +323 -0
  31. package/dist/dragonbones/dragonBones/animation/AnimationState.d.ts.map +1 -0
  32. package/dist/dragonbones/dragonBones/animation/AnimationState.js +1161 -0
  33. package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts +100 -0
  34. package/dist/dragonbones/dragonBones/animation/BaseTimelineState.d.ts.map +1 -0
  35. package/dist/dragonbones/dragonBones/animation/BaseTimelineState.js +479 -0
  36. package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts +38 -0
  37. package/dist/dragonbones/dragonBones/animation/IAnimatable.d.ts.map +1 -0
  38. package/dist/dragonbones/dragonBones/animation/IAnimatable.js +9 -0
  39. package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts +159 -0
  40. package/dist/dragonbones/dragonBones/animation/TimelineState.d.ts.map +1 -0
  41. package/dist/dragonbones/dragonBones/animation/TimelineState.js +998 -0
  42. package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts +74 -0
  43. package/dist/dragonbones/dragonBones/animation/WorldClock.d.ts.map +1 -0
  44. package/dist/dragonbones/dragonBones/animation/WorldClock.js +162 -0
  45. package/dist/dragonbones/dragonBones/armature/Armature.d.ts +314 -0
  46. package/dist/dragonbones/dragonBones/armature/Armature.d.ts.map +1 -0
  47. package/dist/dragonbones/dragonBones/armature/Armature.js +650 -0
  48. package/dist/dragonbones/dragonBones/armature/Bone.d.ts +123 -0
  49. package/dist/dragonbones/dragonBones/armature/Bone.d.ts.map +1 -0
  50. package/dist/dragonbones/dragonBones/armature/Bone.js +438 -0
  51. package/dist/dragonbones/dragonBones/armature/Constraint.d.ts +99 -0
  52. package/dist/dragonbones/dragonBones/armature/Constraint.d.ts.map +1 -0
  53. package/dist/dragonbones/dragonBones/armature/Constraint.js +672 -0
  54. package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts +47 -0
  55. package/dist/dragonbones/dragonBones/armature/IArmatureProxy.d.ts.map +1 -0
  56. package/dist/dragonbones/dragonBones/armature/IArmatureProxy.js +1 -0
  57. package/dist/dragonbones/dragonBones/armature/Slot.d.ts +357 -0
  58. package/dist/dragonbones/dragonBones/armature/Slot.d.ts.map +1 -0
  59. package/dist/dragonbones/dragonBones/armature/Slot.js +1009 -0
  60. package/dist/dragonbones/dragonBones/armature/Surface.d.ts +41 -0
  61. package/dist/dragonbones/dragonBones/armature/Surface.d.ts.map +1 -0
  62. package/dist/dragonbones/dragonBones/armature/Surface.js +463 -0
  63. package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts +80 -0
  64. package/dist/dragonbones/dragonBones/armature/TransformObject.d.ts.map +1 -0
  65. package/dist/dragonbones/dragonBones/armature/TransformObject.js +77 -0
  66. package/dist/dragonbones/dragonBones/core/BaseObject.d.ts +53 -0
  67. package/dist/dragonbones/dragonBones/core/BaseObject.d.ts.map +1 -0
  68. package/dist/dragonbones/dragonBones/core/BaseObject.js +130 -0
  69. package/dist/dragonbones/dragonBones/core/DragonBones.d.ts +236 -0
  70. package/dist/dragonbones/dragonBones/core/DragonBones.d.ts.map +1 -0
  71. package/dist/dragonbones/dragonBones/core/DragonBones.js +61 -0
  72. package/dist/dragonbones/dragonBones/event/EventObject.d.ts +143 -0
  73. package/dist/dragonbones/dragonBones/event/EventObject.d.ts.map +1 -0
  74. package/dist/dragonbones/dragonBones/event/EventObject.js +99 -0
  75. package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts +48 -0
  76. package/dist/dragonbones/dragonBones/event/IEventDispatcher.d.ts.map +1 -0
  77. package/dist/dragonbones/dragonBones/event/IEventDispatcher.js +1 -0
  78. package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts +292 -0
  79. package/dist/dragonbones/dragonBones/factory/BaseFactory.d.ts.map +1 -0
  80. package/dist/dragonbones/dragonBones/factory/BaseFactory.js +735 -0
  81. package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts +17 -0
  82. package/dist/dragonbones/dragonBones/geom/ColorTransform.d.ts.map +1 -0
  83. package/dist/dragonbones/dragonBones/geom/ColorTransform.js +33 -0
  84. package/dist/dragonbones/dragonBones/geom/Curve.d.ts +10 -0
  85. package/dist/dragonbones/dragonBones/geom/Curve.d.ts.map +1 -0
  86. package/dist/dragonbones/dragonBones/geom/Curve.js +26 -0
  87. package/dist/dragonbones/dragonBones/geom/Matrix.d.ts +105 -0
  88. package/dist/dragonbones/dragonBones/geom/Matrix.d.ts.map +1 -0
  89. package/dist/dragonbones/dragonBones/geom/Matrix.js +207 -0
  90. package/dist/dragonbones/dragonBones/geom/Point.d.ts +38 -0
  91. package/dist/dragonbones/dragonBones/geom/Point.d.ts.map +1 -0
  92. package/dist/dragonbones/dragonBones/geom/Point.js +31 -0
  93. package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts +53 -0
  94. package/dist/dragonbones/dragonBones/geom/Rectangle.d.ts.map +1 -0
  95. package/dist/dragonbones/dragonBones/geom/Rectangle.js +37 -0
  96. package/dist/dragonbones/dragonBones/geom/Transform.d.ts +102 -0
  97. package/dist/dragonbones/dragonBones/geom/Transform.d.ts.map +1 -0
  98. package/dist/dragonbones/dragonBones/geom/Transform.js +170 -0
  99. package/dist/dragonbones/dragonBones/index.d.ts +37 -0
  100. package/dist/dragonbones/dragonBones/index.d.ts.map +1 -0
  101. package/dist/dragonbones/dragonBones/index.js +36 -0
  102. package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts +162 -0
  103. package/dist/dragonbones/dragonBones/model/AnimationConfig.d.ts.map +1 -0
  104. package/dist/dragonbones/dragonBones/model/AnimationConfig.js +81 -0
  105. package/dist/dragonbones/dragonBones/model/AnimationData.d.ts +174 -0
  106. package/dist/dragonbones/dragonBones/model/AnimationData.d.ts.map +1 -0
  107. package/dist/dragonbones/dragonBones/model/AnimationData.js +256 -0
  108. package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts +319 -0
  109. package/dist/dragonbones/dragonBones/model/ArmatureData.d.ts.map +1 -0
  110. package/dist/dragonbones/dragonBones/model/ArmatureData.js +450 -0
  111. package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts +188 -0
  112. package/dist/dragonbones/dragonBones/model/BoundingBoxData.d.ts.map +1 -0
  113. package/dist/dragonbones/dragonBones/model/BoundingBoxData.js +500 -0
  114. package/dist/dragonbones/dragonBones/model/CanvasData.d.ts +15 -0
  115. package/dist/dragonbones/dragonBones/model/CanvasData.d.ts.map +1 -0
  116. package/dist/dragonbones/dragonBones/model/CanvasData.js +17 -0
  117. package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts +46 -0
  118. package/dist/dragonbones/dragonBones/model/ConstraintData.d.ts.map +1 -0
  119. package/dist/dragonbones/dragonBones/model/ConstraintData.js +57 -0
  120. package/dist/dragonbones/dragonBones/model/DisplayData.d.ts +98 -0
  121. package/dist/dragonbones/dragonBones/model/DisplayData.d.ts.map +1 -0
  122. package/dist/dragonbones/dragonBones/model/DisplayData.js +174 -0
  123. package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts +108 -0
  124. package/dist/dragonbones/dragonBones/model/DragonBonesData.d.ts.map +1 -0
  125. package/dist/dragonbones/dragonBones/model/DragonBonesData.js +86 -0
  126. package/dist/dragonbones/dragonBones/model/SkinData.d.ts +40 -0
  127. package/dist/dragonbones/dragonBones/model/SkinData.d.ts.map +1 -0
  128. package/dist/dragonbones/dragonBones/model/SkinData.js +68 -0
  129. package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts +73 -0
  130. package/dist/dragonbones/dragonBones/model/TextureAtlasData.d.ts.map +1 -0
  131. package/dist/dragonbones/dragonBones/model/TextureAtlasData.js +102 -0
  132. package/dist/dragonbones/dragonBones/model/UserData.d.ts +73 -0
  133. package/dist/dragonbones/dragonBones/model/UserData.d.ts.map +1 -0
  134. package/dist/dragonbones/dragonBones/model/UserData.js +101 -0
  135. package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts +29 -0
  136. package/dist/dragonbones/dragonBones/parser/BinaryDataParser.d.ts.map +1 -0
  137. package/dist/dragonbones/dragonBones/parser/BinaryDataParser.js +356 -0
  138. package/dist/dragonbones/dragonBones/parser/DataParser.d.ts +153 -0
  139. package/dist/dragonbones/dragonBones/parser/DataParser.d.ts.map +1 -0
  140. package/dist/dragonbones/dragonBones/parser/DataParser.js +283 -0
  141. package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts +130 -0
  142. package/dist/dragonbones/dragonBones/parser/ObjectDataParser.d.ts.map +1 -0
  143. package/dist/dragonbones/dragonBones/parser/ObjectDataParser.js +2098 -0
  144. package/dist/dragonbones/index.js +1 -1
  145. package/dist/helper/utils.js +1 -1
  146. package/package.json +3 -4
@@ -0,0 +1,650 @@
1
+ import { BaseObject } from "../core/BaseObject";
2
+ import { Animation } from "../animation/Animation";
3
+ /**
4
+ * - Armature is the core of the skeleton animation system.
5
+ * @see dragonBones.ArmatureData
6
+ * @see dragonBones.Bone
7
+ * @see dragonBones.Slot
8
+ * @see dragonBones.Animation
9
+ * @version DragonBones 3.0
10
+ * @language en_US
11
+ */
12
+ export class Armature extends BaseObject {
13
+ constructor() {
14
+ super(...arguments);
15
+ this._bones = [];
16
+ this._slots = [];
17
+ /**
18
+ * @internal
19
+ */
20
+ this._constraints = [];
21
+ this._actions = [];
22
+ this._animation = null; // Initial value.
23
+ this._proxy = null; // Initial value.
24
+ /**
25
+ * @internal
26
+ */
27
+ this._replaceTextureAtlasData = null; // Initial value.
28
+ this._clock = null; // Initial value.
29
+ }
30
+ static toString() {
31
+ return "[class dragonBones.Armature]";
32
+ }
33
+ static _onSortSlots(a, b) {
34
+ return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1;
35
+ }
36
+ _onClear() {
37
+ if (this._clock !== null) {
38
+ // Remove clock first.
39
+ this._clock.remove(this);
40
+ }
41
+ for (const bone of this._bones) {
42
+ bone.returnToPool();
43
+ }
44
+ for (const slot of this._slots) {
45
+ slot.returnToPool();
46
+ }
47
+ for (const constraint of this._constraints) {
48
+ constraint.returnToPool();
49
+ }
50
+ for (const action of this._actions) {
51
+ action.returnToPool();
52
+ }
53
+ if (this._animation !== null) {
54
+ this._animation.returnToPool();
55
+ }
56
+ if (this._proxy !== null) {
57
+ this._proxy.dbClear();
58
+ }
59
+ if (this._replaceTextureAtlasData !== null) {
60
+ this._replaceTextureAtlasData.returnToPool();
61
+ }
62
+ this.inheritAnimation = true;
63
+ this.userData = null;
64
+ this._lockUpdate = false;
65
+ this._slotsDirty = true;
66
+ this._zOrderDirty = false;
67
+ this._zIndexDirty = false;
68
+ this._alphaDirty = true;
69
+ this._flipX = false;
70
+ this._flipY = false;
71
+ this._cacheFrameIndex = -1;
72
+ this._alpha = 1.0;
73
+ this._globalAlpha = 1.0;
74
+ this._bones.length = 0;
75
+ this._slots.length = 0;
76
+ this._constraints.length = 0;
77
+ this._actions.length = 0;
78
+ this._armatureData = null; //
79
+ this._animation = null; //
80
+ this._proxy = null; //
81
+ this._display = null;
82
+ this._replaceTextureAtlasData = null;
83
+ this._replacedTexture = null;
84
+ this._dragonBones = null; //
85
+ this._clock = null;
86
+ this._parent = null;
87
+ }
88
+ /**
89
+ * @internal
90
+ */
91
+ _sortZOrder(slotIndices, offset) {
92
+ const slotDatas = this._armatureData.sortedSlots;
93
+ const isOriginal = slotIndices === null;
94
+ if (this._zOrderDirty || !isOriginal) {
95
+ for (let i = 0, l = slotDatas.length; i < l; ++i) {
96
+ const slotIndex = isOriginal
97
+ ? i
98
+ : slotIndices[offset + i];
99
+ if (slotIndex < 0 || slotIndex >= l) {
100
+ continue;
101
+ }
102
+ const slotData = slotDatas[slotIndex];
103
+ const slot = this.getSlot(slotData.name);
104
+ if (slot !== null) {
105
+ slot._setZOrder(i);
106
+ }
107
+ }
108
+ this._slotsDirty = true;
109
+ this._zOrderDirty = !isOriginal;
110
+ }
111
+ }
112
+ /**
113
+ * @internal
114
+ */
115
+ _addBone(value) {
116
+ if (this._bones.indexOf(value) < 0) {
117
+ this._bones.push(value);
118
+ }
119
+ }
120
+ /**
121
+ * @internal
122
+ */
123
+ _addSlot(value) {
124
+ if (this._slots.indexOf(value) < 0) {
125
+ this._slots.push(value);
126
+ }
127
+ }
128
+ /**
129
+ * @internal
130
+ */
131
+ _addConstraint(value) {
132
+ if (this._constraints.indexOf(value) < 0) {
133
+ this._constraints.push(value);
134
+ }
135
+ }
136
+ /**
137
+ * @internal
138
+ */
139
+ _bufferAction(action, append) {
140
+ if (this._actions.indexOf(action) < 0) {
141
+ if (append) {
142
+ this._actions.push(action);
143
+ }
144
+ else {
145
+ this._actions.unshift(action);
146
+ }
147
+ }
148
+ }
149
+ /**
150
+ * - Dispose the armature. (Return to the object pool)
151
+ * @example
152
+ * <pre>
153
+ * removeChild(armature.display);
154
+ * armature.dispose();
155
+ * </pre>
156
+ * @version DragonBones 3.0
157
+ * @language en_US
158
+ */
159
+ dispose() {
160
+ if (this._armatureData !== null) {
161
+ this._lockUpdate = true;
162
+ this._dragonBones.bufferObject(this);
163
+ }
164
+ }
165
+ /**
166
+ * @internal
167
+ */
168
+ init(armatureData, proxy, display, dragonBones) {
169
+ if (this._armatureData !== null) {
170
+ return;
171
+ }
172
+ this._armatureData = armatureData;
173
+ this._animation = BaseObject.borrowObject(Animation);
174
+ this._proxy = proxy;
175
+ this._display = display;
176
+ this._dragonBones = dragonBones;
177
+ this._proxy.dbInit(this);
178
+ this._animation.init(this);
179
+ this._animation.animations = this._armatureData.animations;
180
+ }
181
+ /**
182
+ * @inheritDoc
183
+ */
184
+ advanceTime(passedTime) {
185
+ if (this._lockUpdate) {
186
+ return;
187
+ }
188
+ this._lockUpdate = true;
189
+ if (this._armatureData === null) {
190
+ console.warn("The armature has been disposed.");
191
+ return;
192
+ }
193
+ else if (this._armatureData.parent === null) {
194
+ console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");
195
+ return;
196
+ }
197
+ const prevCacheFrameIndex = this._cacheFrameIndex;
198
+ // Update animation.
199
+ this._animation.advanceTime(passedTime);
200
+ // Sort slots.
201
+ if (this._slotsDirty || this._zIndexDirty) {
202
+ this._slots.sort(Armature._onSortSlots);
203
+ if (this._zIndexDirty) {
204
+ for (let i = 0, l = this._slots.length; i < l; ++i) {
205
+ this._slots[i]._setZOrder(i); //
206
+ }
207
+ }
208
+ this._slotsDirty = false;
209
+ this._zIndexDirty = false;
210
+ }
211
+ // Update alpha.
212
+ if (this._alphaDirty) {
213
+ this._alphaDirty = false;
214
+ this._globalAlpha =
215
+ this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0);
216
+ for (const bone of this._bones) {
217
+ bone._updateAlpha();
218
+ }
219
+ for (const slot of this._slots) {
220
+ slot._updateAlpha();
221
+ }
222
+ }
223
+ // Update bones and slots.
224
+ if (this._cacheFrameIndex < 0 ||
225
+ this._cacheFrameIndex !== prevCacheFrameIndex) {
226
+ let i = 0, l = 0;
227
+ for (i = 0, l = this._bones.length; i < l; ++i) {
228
+ this._bones[i].update(this._cacheFrameIndex);
229
+ }
230
+ for (i = 0, l = this._slots.length; i < l; ++i) {
231
+ this._slots[i].update(this._cacheFrameIndex);
232
+ }
233
+ }
234
+ // Do actions.
235
+ if (this._actions.length > 0) {
236
+ for (const action of this._actions) {
237
+ const actionData = action.actionData;
238
+ if (actionData !== null) {
239
+ if (actionData.type === 0 /* ActionType.Play */) {
240
+ if (action.slot !== null) {
241
+ const childArmature = action.slot.childArmature;
242
+ if (childArmature !== null) {
243
+ childArmature.animation.fadeIn(actionData.name);
244
+ }
245
+ }
246
+ else if (action.bone !== null) {
247
+ for (const slot of this.getSlots()) {
248
+ if (slot.parent === action.bone) {
249
+ const childArmature = slot.childArmature;
250
+ if (childArmature !== null) {
251
+ childArmature.animation.fadeIn(actionData.name);
252
+ }
253
+ }
254
+ }
255
+ }
256
+ else {
257
+ this._animation.fadeIn(actionData.name);
258
+ }
259
+ }
260
+ }
261
+ action.returnToPool();
262
+ }
263
+ this._actions.length = 0;
264
+ }
265
+ this._lockUpdate = false;
266
+ this._proxy.dbUpdate();
267
+ }
268
+ /**
269
+ * - Forces a specific bone or its owning slot to update the transform or display property in the next frame.
270
+ * @param boneName - The bone name. (If not set, all bones will be update)
271
+ * @param updateSlot - Whether to update the bone's slots. (Default: false)
272
+ * @see dragonBones.Bone#invalidUpdate()
273
+ * @see dragonBones.Slot#invalidUpdate()
274
+ * @version DragonBones 3.0
275
+ * @language en_US
276
+ */
277
+ invalidUpdate(boneName = null, updateSlot = false) {
278
+ if (boneName !== null && boneName.length > 0) {
279
+ const bone = this.getBone(boneName);
280
+ if (bone !== null) {
281
+ bone.invalidUpdate();
282
+ if (updateSlot) {
283
+ for (const slot of this._slots) {
284
+ if (slot.parent === bone) {
285
+ slot.invalidUpdate();
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ else {
292
+ for (const bone of this._bones) {
293
+ bone.invalidUpdate();
294
+ }
295
+ if (updateSlot) {
296
+ for (const slot of this._slots) {
297
+ slot.invalidUpdate();
298
+ }
299
+ }
300
+ }
301
+ }
302
+ /**
303
+ * - Check whether a specific point is inside a custom bounding box in a slot.
304
+ * The coordinate system of the point is the inner coordinate system of the armature.
305
+ * Custom bounding boxes need to be customized in Dragonbones Pro.
306
+ * @param x - The horizontal coordinate of the point.
307
+ * @param y - The vertical coordinate of the point.
308
+ * @version DragonBones 5.0
309
+ * @language en_US
310
+ */
311
+ containsPoint(x, y) {
312
+ for (const slot of this._slots) {
313
+ if (slot.containsPoint(x, y)) {
314
+ return slot;
315
+ }
316
+ }
317
+ return null;
318
+ }
319
+ /**
320
+ * - Check whether a specific segment intersects a custom bounding box for a slot in the armature.
321
+ * The coordinate system of the segment and intersection is the inner coordinate system of the armature.
322
+ * Custom bounding boxes need to be customized in Dragonbones Pro.
323
+ * @param xA - The horizontal coordinate of the beginning of the segment.
324
+ * @param yA - The vertical coordinate of the beginning of the segment.
325
+ * @param xB - The horizontal coordinate of the end point of the segment.
326
+ * @param yB - The vertical coordinate of the end point of the segment.
327
+ * @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)
328
+ * @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)
329
+ * @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)
330
+ * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point.
331
+ * @version DragonBones 5.0
332
+ * @language en_US
333
+ */
334
+ intersectsSegment(xA, yA, xB, yB, intersectionPointA = null, intersectionPointB = null, normalRadians = null) {
335
+ const isV = xA === xB;
336
+ let dMin = 0.0;
337
+ let dMax = 0.0;
338
+ let intXA = 0.0;
339
+ let intYA = 0.0;
340
+ let intXB = 0.0;
341
+ let intYB = 0.0;
342
+ let intAN = 0.0;
343
+ let intBN = 0.0;
344
+ let intSlotA = null;
345
+ let intSlotB = null;
346
+ for (const slot of this._slots) {
347
+ const intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians);
348
+ if (intersectionCount > 0) {
349
+ if (intersectionPointA !== null || intersectionPointB !== null) {
350
+ if (intersectionPointA !== null) {
351
+ let d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA;
352
+ if (d < 0.0) {
353
+ d = -d;
354
+ }
355
+ if (intSlotA === null || d < dMin) {
356
+ dMin = d;
357
+ intXA = intersectionPointA.x;
358
+ intYA = intersectionPointA.y;
359
+ intSlotA = slot;
360
+ if (normalRadians) {
361
+ intAN = normalRadians.x;
362
+ }
363
+ }
364
+ }
365
+ if (intersectionPointB !== null) {
366
+ let d = intersectionPointB.x - xA;
367
+ if (d < 0.0) {
368
+ d = -d;
369
+ }
370
+ if (intSlotB === null || d > dMax) {
371
+ dMax = d;
372
+ intXB = intersectionPointB.x;
373
+ intYB = intersectionPointB.y;
374
+ intSlotB = slot;
375
+ if (normalRadians !== null) {
376
+ intBN = normalRadians.y;
377
+ }
378
+ }
379
+ }
380
+ }
381
+ else {
382
+ intSlotA = slot;
383
+ break;
384
+ }
385
+ }
386
+ }
387
+ if (intSlotA !== null && intersectionPointA !== null) {
388
+ intersectionPointA.x = intXA;
389
+ intersectionPointA.y = intYA;
390
+ if (normalRadians !== null) {
391
+ normalRadians.x = intAN;
392
+ }
393
+ }
394
+ if (intSlotB !== null && intersectionPointB !== null) {
395
+ intersectionPointB.x = intXB;
396
+ intersectionPointB.y = intYB;
397
+ if (normalRadians !== null) {
398
+ normalRadians.y = intBN;
399
+ }
400
+ }
401
+ return intSlotA;
402
+ }
403
+ /**
404
+ * - Get a specific bone.
405
+ * @param name - The bone name.
406
+ * @see dragonBones.Bone
407
+ * @version DragonBones 3.0
408
+ * @language en_US
409
+ */
410
+ getBone(name) {
411
+ for (const bone of this._bones) {
412
+ if (bone.name === name) {
413
+ return bone;
414
+ }
415
+ }
416
+ return null;
417
+ }
418
+ /**
419
+ * - Get a specific bone by the display.
420
+ * @param display - The display object.
421
+ * @see dragonBones.Bone
422
+ * @version DragonBones 3.0
423
+ * @language en_US
424
+ */
425
+ getBoneByDisplay(display) {
426
+ const slot = this.getSlotByDisplay(display);
427
+ return slot !== null ? slot.parent : null;
428
+ }
429
+ /**
430
+ * - Get a specific slot.
431
+ * @param name - The slot name.
432
+ * @see dragonBones.Slot
433
+ * @version DragonBones 3.0
434
+ * @language en_US
435
+ */
436
+ getSlot(name) {
437
+ for (const slot of this._slots) {
438
+ if (slot.name === name) {
439
+ return slot;
440
+ }
441
+ }
442
+ return null;
443
+ }
444
+ /**
445
+ * - Get a specific slot by the display.
446
+ * @param display - The display object.
447
+ * @see dragonBones.Slot
448
+ * @version DragonBones 3.0
449
+ * @language en_US
450
+ */
451
+ getSlotByDisplay(display) {
452
+ if (display !== null) {
453
+ for (const slot of this._slots) {
454
+ if (slot.display === display) {
455
+ return slot;
456
+ }
457
+ }
458
+ }
459
+ return null;
460
+ }
461
+ /**
462
+ * - Get all bones.
463
+ * @see dragonBones.Bone
464
+ * @version DragonBones 3.0
465
+ * @language en_US
466
+ */
467
+ getBones() {
468
+ return this._bones;
469
+ }
470
+ /**
471
+ * - Get all slots.
472
+ * @see dragonBones.Slot
473
+ * @version DragonBones 3.0
474
+ * @language en_US
475
+ */
476
+ getSlots() {
477
+ return this._slots;
478
+ }
479
+ /**
480
+ * - Whether to flip the armature horizontally.
481
+ * @version DragonBones 5.5
482
+ * @language en_US
483
+ */
484
+ get flipX() {
485
+ return this._flipX;
486
+ }
487
+ set flipX(value) {
488
+ if (this._flipX === value) {
489
+ return;
490
+ }
491
+ this._flipX = value;
492
+ this.invalidUpdate();
493
+ }
494
+ /**
495
+ * - Whether to flip the armature vertically.
496
+ * @version DragonBones 5.5
497
+ * @language en_US
498
+ */
499
+ get flipY() {
500
+ return this._flipY;
501
+ }
502
+ set flipY(value) {
503
+ if (this._flipY === value) {
504
+ return;
505
+ }
506
+ this._flipY = value;
507
+ this.invalidUpdate();
508
+ }
509
+ /**
510
+ * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0.
511
+ * There is a certain amount of memory overhead to improve performance by caching animation data in memory.
512
+ * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate.
513
+ * When the animation cache is turned on, some features will fail, such as the offset property of bone.
514
+ * @example
515
+ * <pre>
516
+ * armature.cacheFrameRate = 24;
517
+ * </pre>
518
+ * @see dragonBones.DragonBonesData#frameRate
519
+ * @see dragonBones.ArmatureData#frameRate
520
+ * @version DragonBones 4.5
521
+ * @language en_US
522
+ */
523
+ get cacheFrameRate() {
524
+ return this._armatureData.cacheFrameRate;
525
+ }
526
+ set cacheFrameRate(value) {
527
+ if (this._armatureData.cacheFrameRate !== value) {
528
+ this._armatureData.cacheFrames(value);
529
+ // Set child armature frameRate.
530
+ for (const slot of this._slots) {
531
+ const childArmature = slot.childArmature;
532
+ if (childArmature !== null) {
533
+ childArmature.cacheFrameRate = value;
534
+ }
535
+ }
536
+ }
537
+ }
538
+ /**
539
+ * - The armature name.
540
+ * @version DragonBones 3.0
541
+ * @language en_US
542
+ */
543
+ get name() {
544
+ return this._armatureData.name;
545
+ }
546
+ /**
547
+ * - The armature data.
548
+ * @see dragonBones.ArmatureData
549
+ * @version DragonBones 4.5
550
+ * @language en_US
551
+ */
552
+ get armatureData() {
553
+ return this._armatureData;
554
+ }
555
+ /**
556
+ * - The animation player.
557
+ * @see dragonBones.Animation
558
+ * @version DragonBones 3.0
559
+ * @language en_US
560
+ */
561
+ get animation() {
562
+ return this._animation;
563
+ }
564
+ /**
565
+ * @pivate
566
+ */
567
+ get proxy() {
568
+ return this._proxy;
569
+ }
570
+ /**
571
+ * - The EventDispatcher instance of the armature.
572
+ * @version DragonBones 4.5
573
+ * @language en_US
574
+ */
575
+ get eventDispatcher() {
576
+ return this._proxy;
577
+ }
578
+ /**
579
+ * - The display container.
580
+ * The display of the slot is displayed as the parent.
581
+ * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type.
582
+ * @version DragonBones 3.0
583
+ * @language en_US
584
+ */
585
+ get display() {
586
+ return this._display;
587
+ }
588
+ /**
589
+ * @private
590
+ */
591
+ get replacedTexture() {
592
+ return this._replacedTexture;
593
+ }
594
+ set replacedTexture(value) {
595
+ if (this._replacedTexture === value) {
596
+ return;
597
+ }
598
+ if (this._replaceTextureAtlasData !== null) {
599
+ this._replaceTextureAtlasData.returnToPool();
600
+ this._replaceTextureAtlasData = null;
601
+ }
602
+ this._replacedTexture = value;
603
+ for (const slot of this._slots) {
604
+ slot.invalidUpdate();
605
+ slot.update(-1);
606
+ }
607
+ }
608
+ /**
609
+ * @inheritDoc
610
+ */
611
+ get clock() {
612
+ return this._clock;
613
+ }
614
+ set clock(value) {
615
+ if (this._clock === value) {
616
+ return;
617
+ }
618
+ if (this._clock !== null) {
619
+ this._clock.remove(this);
620
+ }
621
+ this._clock = value;
622
+ if (this._clock) {
623
+ this._clock.add(this);
624
+ }
625
+ // Update childArmature clock.
626
+ for (const slot of this._slots) {
627
+ const childArmature = slot.childArmature;
628
+ if (childArmature !== null) {
629
+ childArmature.clock = this._clock;
630
+ }
631
+ }
632
+ }
633
+ /**
634
+ * - Get the parent slot which the armature belongs to.
635
+ * @see dragonBones.Slot
636
+ * @version DragonBones 4.5
637
+ * @language en_US
638
+ */
639
+ get parent() {
640
+ return this._parent;
641
+ }
642
+ /**
643
+ * - Deprecated, please refer to {@link #display}.
644
+ * @deprecated
645
+ * @language en_US
646
+ */
647
+ getDisplay() {
648
+ return this._display;
649
+ }
650
+ }