@safe-engine/cocos 1.4.12 → 1.5.2

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 (74) hide show
  1. package/@types/index.d.ts +0 -7
  2. package/dist/app.d.ts +13 -2
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +6 -10
  5. package/dist/collider/CollideComponent.d.ts +64 -0
  6. package/dist/collider/CollideComponent.d.ts.map +1 -0
  7. package/dist/collider/CollideComponent.js +265 -0
  8. package/dist/collider/CollideSystem.d.ts +21 -0
  9. package/dist/collider/CollideSystem.d.ts.map +1 -0
  10. package/dist/collider/CollideSystem.js +181 -0
  11. package/dist/collider/index.d.ts +2 -0
  12. package/dist/collider/index.d.ts.map +1 -0
  13. package/dist/collider/index.js +10 -0
  14. package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -1
  15. package/dist/dragonbones/PixiDragonBonesSprite.js +11 -11
  16. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
  17. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
  18. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
  19. package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
  20. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
  21. package/dist/dragonbones/cocos/CocosFactory.js +231 -0
  22. package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
  23. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
  24. package/dist/dragonbones/cocos/CocosSlot.js +385 -0
  25. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
  26. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
  27. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
  28. package/dist/dragonbones/dragonBones.d.ts +3 -0
  29. package/dist/dragonbones/dragonBones.d.ts.map +1 -0
  30. package/dist/dragonbones/dragonBones.js +4788 -0
  31. package/dist/dragonbones/index.d.ts +3 -2
  32. package/dist/dragonbones/index.d.ts.map +1 -1
  33. package/dist/dragonbones/index.js +9 -9
  34. package/dist/gworld/components/CollideComponent.d.ts +3 -3
  35. package/dist/gworld/components/GUIComponent.d.ts +0 -4
  36. package/dist/gworld/components/GUIComponent.d.ts.map +1 -1
  37. package/dist/gworld/components/GUIComponent.js +1 -39
  38. package/dist/gworld/components/NodeComp.d.ts.map +1 -1
  39. package/dist/gworld/components/RenderComponent.d.ts.map +1 -1
  40. package/dist/gworld/systems/CollideSystem.d.ts +2 -1
  41. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
  42. package/dist/gworld/systems/CollideSystem.js +12 -2
  43. package/dist/gworld/systems/GUISystem.d.ts +0 -1
  44. package/dist/gworld/systems/GUISystem.d.ts.map +1 -1
  45. package/dist/gworld/systems/GUISystem.js +0 -11
  46. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
  47. package/dist/gworld/systems/RenderSystem.d.ts.map +1 -1
  48. package/dist/gworld/systems/RenderSystem.js +0 -15
  49. package/dist/helper/NodePool.d.ts +9 -0
  50. package/dist/helper/NodePool.d.ts.map +1 -0
  51. package/dist/helper/NodePool.js +29 -0
  52. package/dist/helper/action.d.ts +1 -1
  53. package/dist/helper/utils.d.ts +1 -2
  54. package/dist/helper/utils.d.ts.map +1 -1
  55. package/dist/helper/utils.js +0 -10
  56. package/dist/index.d.ts +0 -5
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +0 -5
  59. package/dist/richtext/RichTextComp.d.ts +13 -0
  60. package/dist/richtext/RichTextComp.d.ts.map +1 -0
  61. package/dist/richtext/RichTextComp.js +57 -0
  62. package/dist/richtext/RichTextSystem.d.ts +7 -0
  63. package/dist/richtext/RichTextSystem.d.ts.map +1 -0
  64. package/dist/richtext/RichTextSystem.js +28 -0
  65. package/dist/richtext/html-text-parser.d.ts +30 -0
  66. package/dist/richtext/html-text-parser.d.ts.map +1 -0
  67. package/dist/richtext/html-text-parser.js +354 -0
  68. package/dist/richtext/index.d.ts +2 -0
  69. package/dist/richtext/index.d.ts.map +1 -0
  70. package/dist/richtext/index.js +9 -0
  71. package/dist/spine/index.d.ts +31 -0
  72. package/dist/spine/index.d.ts.map +1 -0
  73. package/dist/spine/index.js +74 -0
  74. package/package.json +1 -1
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /**
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
+ * the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ */
25
+ var __extends = (this && this.__extends) || (function () {
26
+ var extendStatics = function (d, b) {
27
+ extendStatics = Object.setPrototypeOf ||
28
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
30
+ return extendStatics(d, b);
31
+ };
32
+ return function (d, b) {
33
+ if (typeof b !== "function" && b !== null)
34
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
35
+ extendStatics(d, b);
36
+ function __() { this.constructor = d; }
37
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.CocosFactory = void 0;
42
+ var dragonbones_js_1 = require("@cocos/dragonbones-js");
43
+ var CocosArmatureDisplay_1 = require("./CocosArmatureDisplay");
44
+ var CocosSlot_1 = require("./CocosSlot");
45
+ var CocosTextureAtlasData_1 = require("./CocosTextureAtlasData");
46
+ /**
47
+ * - The PixiJS factory.
48
+ * @version DragonBones 3.0
49
+ * @language en_US
50
+ */
51
+ /**
52
+ * - PixiJS 工厂。
53
+ * @version DragonBones 3.0
54
+ * @language zh_CN
55
+ */
56
+ var CocosFactory = /** @class */ (function (_super) {
57
+ __extends(CocosFactory, _super);
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ function CocosFactory(dataParser, useSharedTicker) {
62
+ if (dataParser === void 0) { dataParser = null; }
63
+ if (useSharedTicker === void 0) { useSharedTicker = true; }
64
+ var _this = _super.call(this, dataParser) || this;
65
+ if (CocosFactory._dragonBonesInstance === null) {
66
+ var eventManager = new CocosArmatureDisplay_1.CocosArmatureDisplay();
67
+ CocosFactory._dragonBonesInstance = new dragonbones_js_1.DragonBones(eventManager);
68
+ // if (useSharedTicker) {
69
+ // PIXI.Ticker.shared.add(CocosFactory._clockHandler, CocosFactory);
70
+ // }
71
+ }
72
+ _this._dragonBones = CocosFactory._dragonBonesInstance;
73
+ return _this;
74
+ }
75
+ CocosFactory._clockHandler = function (passedTime) {
76
+ this._dragonBonesInstance.advanceTime((passedTime));
77
+ };
78
+ /*
79
+ * `passedTime` is elapsed time, specified in seconds.
80
+ */
81
+ CocosFactory.advanceTime = function (passedTime) {
82
+ this._dragonBonesInstance.advanceTime(passedTime);
83
+ };
84
+ Object.defineProperty(CocosFactory, "factory", {
85
+ /**
86
+ * - A global factory instance that can be used directly.
87
+ * @version DragonBones 4.7
88
+ * @language en_US
89
+ */
90
+ /**
91
+ * - 一个可以直接使用的全局工厂实例。
92
+ * @version DragonBones 4.7
93
+ * @language zh_CN
94
+ */
95
+ get: function () {
96
+ if (CocosFactory._factory === null) {
97
+ CocosFactory._factory = new CocosFactory(null, CocosFactory.useSharedTicker);
98
+ }
99
+ return CocosFactory._factory;
100
+ },
101
+ enumerable: false,
102
+ configurable: true
103
+ });
104
+ /**
105
+ * - 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
106
+ * @version DragonBones 4.7
107
+ * @language zh_CN
108
+ */
109
+ CocosFactory.newInstance = function (useSharedTicker) {
110
+ if (useSharedTicker === void 0) { useSharedTicker = true; }
111
+ if (CocosFactory._factory === null) {
112
+ CocosFactory._factory = new CocosFactory(null, useSharedTicker);
113
+ }
114
+ return CocosFactory._factory;
115
+ };
116
+ CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) {
117
+ if (textureAtlasData) {
118
+ console.log(textureAtlasData, 'textureAtlasData', textureAtlas);
119
+ var scale = cc.director.getContentScaleFactor();
120
+ textureAtlasData.scale = scale;
121
+ textureAtlasData.renderTexture = textureAtlas;
122
+ }
123
+ else {
124
+ textureAtlasData = dragonbones_js_1.BaseObject.borrowObject(CocosTextureAtlasData_1.CocosTextureAtlasData);
125
+ }
126
+ return textureAtlasData;
127
+ };
128
+ CocosFactory.prototype._buildArmature = function (dataPackage) {
129
+ var armature = dragonbones_js_1.BaseObject.borrowObject(dragonbones_js_1.Armature);
130
+ var armatureDisplay = new CocosArmatureDisplay_1.CocosArmatureDisplay();
131
+ armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones);
132
+ return armature;
133
+ };
134
+ CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) {
135
+ var slot = dragonbones_js_1.BaseObject.borrowObject(CocosSlot_1.CocosSlot);
136
+ slot.init(slotData, armature, new cc.Sprite(), new cc.Sprite());
137
+ return slot;
138
+ };
139
+ /**
140
+ * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it.
141
+ * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update.
142
+ * @param armatureName - The armature data name.
143
+ * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
144
+ * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
145
+ * @returns The armature display container.
146
+ * @see dragonBones.IArmatureProxy
147
+ * @see dragonBones.BaseFactory#buildArmature
148
+ * @version DragonBones 4.5
149
+ * @example
150
+ * <pre>
151
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
152
+ * </pre>
153
+ * @language en_US
154
+ */
155
+ /**
156
+ * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。
157
+ * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。
158
+ * @param armatureName - 骨架数据名称。
159
+ * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
160
+ * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。 (如果未设置,则使用默认的皮肤数据)
161
+ * @returns 骨架的显示容器。
162
+ * @see dragonBones.IArmatureProxy
163
+ * @see dragonBones.BaseFactory#buildArmature
164
+ * @version DragonBones 4.5
165
+ * @example
166
+ * <pre>
167
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
168
+ * </pre>
169
+ * @language zh_CN
170
+ */
171
+ CocosFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) {
172
+ if (dragonBonesName === void 0) { dragonBonesName = ''; }
173
+ if (skinName === void 0) { skinName = ''; }
174
+ if (textureAtlasName === void 0) { textureAtlasName = ''; }
175
+ var armature = this.buildArmature(armatureName, dragonBonesName || '', skinName || '', textureAtlasName || '');
176
+ if (armature !== null) {
177
+ this._dragonBones.clock.add(armature);
178
+ return armature.display;
179
+ }
180
+ return null;
181
+ };
182
+ /**
183
+ * - Create the display object with the specified texture.
184
+ * @param textureName - The texture data name.
185
+ * @param textureAtlasName - The texture atlas data name (Of not set, all texture atlas data will be searched)
186
+ * @version DragonBones 3.0
187
+ * @language en_US
188
+ */
189
+ /**
190
+ * - 创建带有指定贴图的显示对象。
191
+ * @param textureName - 贴图数据名称。
192
+ * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据)
193
+ * @version DragonBones 3.0
194
+ * @language zh_CN
195
+ */
196
+ CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) {
197
+ if (textureAtlasName === void 0) { textureAtlasName = null; }
198
+ var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : '', textureName);
199
+ if (textureData !== null && textureData.renderTexture !== null) {
200
+ return new cc.Sprite(textureData.renderTexture);
201
+ }
202
+ return null;
203
+ };
204
+ Object.defineProperty(CocosFactory.prototype, "soundEventManager", {
205
+ /**
206
+ * - A global sound event manager.
207
+ * Sound events can be listened to uniformly from the manager.
208
+ * @version DragonBones 4.5
209
+ * @language en_US
210
+ */
211
+ /**
212
+ * - 全局声音事件管理器。
213
+ * 声音事件可以从该管理器统一侦听。
214
+ * @version DragonBones 4.5
215
+ * @language zh_CN
216
+ */
217
+ get: function () {
218
+ return this._dragonBones.eventManager;
219
+ },
220
+ enumerable: false,
221
+ configurable: true
222
+ });
223
+ CocosFactory._dragonBonesInstance = null;
224
+ CocosFactory._factory = null;
225
+ /*
226
+ * whether use `PIXI.Ticker.shared`
227
+ */
228
+ CocosFactory.useSharedTicker = true;
229
+ return CocosFactory;
230
+ }(dragonbones_js_1.BaseFactory));
231
+ exports.CocosFactory = CocosFactory;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ import { Slot } from '@cocos/dragonbones-js';
24
+ export declare class CocosSlot extends Slot {
25
+ _updateGlueMesh(): void;
26
+ static toString(): string;
27
+ private _textureScale;
28
+ private _renderDisplay;
29
+ protected _onClear(): void;
30
+ protected _initDisplay(value: any, isRetain: boolean): void;
31
+ protected _disposeDisplay(value: any, isRelease: boolean): void;
32
+ protected _onUpdateDisplay(): void;
33
+ protected _addDisplay(): void;
34
+ protected _replaceDisplay(value: any): void;
35
+ protected _removeDisplay(): void;
36
+ protected _updateZOrder(): void;
37
+ /**
38
+ * @internal
39
+ */
40
+ _updateVisible(): void;
41
+ protected _updateBlendMode(): void;
42
+ protected _updateColor(): void;
43
+ protected _updateFrame(): void;
44
+ protected _updateMesh(): void;
45
+ protected _updateTransform(): void;
46
+ protected _updateTransformV3(): void;
47
+ protected _identityTransform(): void;
48
+ }
49
+ //# sourceMappingURL=CocosSlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosSlot.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/cocos/CocosSlot.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAsC,IAAI,EAAa,MAAM,uBAAuB,CAAC;AAK5F,qBAAa,SAAU,SAAQ,IAAI;IACjC,eAAe,IAAI,IAAI;WAGT,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAU;IAEhC,SAAS,CAAC,QAAQ,IAAI,IAAI;IAQ1B,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI;IAO3D,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAQ/D,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAIlC,SAAS,CAAC,WAAW,IAAI,IAAI;IAK7B,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS3C,SAAS,CAAC,cAAc,IAAI,IAAI;IAIhC,SAAS,CAAC,aAAa,IAAI,IAAI;IAO/B;;OAEG;IACI,cAAc,IAAI,IAAI;IAI7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAOlC,SAAS,CAAC,YAAY,IAAI,IAAI;IAW9B,SAAS,CAAC,YAAY,IAAI,IAAI;IAyG9B,SAAS,CAAC,WAAW,IAAI,IAAI;IA0J7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAqBlC,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAwBpC,SAAS,CAAC,kBAAkB,IAAI,IAAI;CAiBrC"}
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /**
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
+ * the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ */
25
+ var __extends = (this && this.__extends) || (function () {
26
+ var extendStatics = function (d, b) {
27
+ extendStatics = Object.setPrototypeOf ||
28
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
30
+ return extendStatics(d, b);
31
+ };
32
+ return function (d, b) {
33
+ if (typeof b !== "function" && b !== null)
34
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
35
+ extendStatics(d, b);
36
+ function __() { this.constructor = d; }
37
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.CocosSlot = void 0;
42
+ var dragonbones_js_1 = require("@cocos/dragonbones-js");
43
+ var CocosTextureAtlasData_1 = require("./CocosTextureAtlasData");
44
+ var CocosSlot = /** @class */ (function (_super) {
45
+ __extends(CocosSlot, _super);
46
+ function CocosSlot() {
47
+ return _super !== null && _super.apply(this, arguments) || this;
48
+ }
49
+ CocosSlot.prototype._updateGlueMesh = function () {
50
+ };
51
+ CocosSlot.toString = function () {
52
+ return '[class dragonBones.CocosSlot]';
53
+ };
54
+ CocosSlot.prototype._onClear = function () {
55
+ _super.prototype._onClear.call(this);
56
+ this._textureScale = 1.0;
57
+ this._renderDisplay = null;
58
+ // this._updateTransform = cc[0] === '3' ? this._updateTransformV3 : this._updateTransformV4;
59
+ };
60
+ CocosSlot.prototype._initDisplay = function (value, isRetain) {
61
+ // tslint:disable-next-line:no-unused-expression
62
+ value;
63
+ // tslint:disable-next-line:no-unused-expression
64
+ isRetain;
65
+ };
66
+ CocosSlot.prototype._disposeDisplay = function (value, isRelease) {
67
+ // tslint:disable-next-line:no-unused-expression
68
+ value;
69
+ if (!isRelease) {
70
+ value.destroy();
71
+ }
72
+ };
73
+ CocosSlot.prototype._onUpdateDisplay = function () {
74
+ this._renderDisplay = (this._display ? this._display : this._rawDisplay);
75
+ };
76
+ CocosSlot.prototype._addDisplay = function () {
77
+ var container = this._armature.display;
78
+ container.addChild(this._renderDisplay);
79
+ };
80
+ CocosSlot.prototype._replaceDisplay = function (value) {
81
+ var container = this._armature.display;
82
+ var prevDisplay = value;
83
+ container.addChild(this._renderDisplay);
84
+ container.swapChildren(this._renderDisplay, prevDisplay);
85
+ container.removeChild(prevDisplay);
86
+ this._textureScale = 1.0;
87
+ };
88
+ CocosSlot.prototype._removeDisplay = function () {
89
+ this._renderDisplay.parent.removeChild(this._renderDisplay);
90
+ };
91
+ CocosSlot.prototype._updateZOrder = function () {
92
+ if (this._renderDisplay.getLocalZOrder() === this._zOrder) {
93
+ return;
94
+ }
95
+ this._renderDisplay.setLocalZOrder(this._zOrder);
96
+ };
97
+ /**
98
+ * @internal
99
+ */
100
+ CocosSlot.prototype._updateVisible = function () {
101
+ this._renderDisplay.visible = this._parent.visible && this._visible;
102
+ };
103
+ CocosSlot.prototype._updateBlendMode = function () {
104
+ if (this._renderDisplay instanceof cc.Sprite) {
105
+ }
106
+ // TODO child armature.
107
+ };
108
+ CocosSlot.prototype._updateColor = function () {
109
+ var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha;
110
+ this._renderDisplay.alpha = alpha;
111
+ if (this._renderDisplay instanceof cc.Sprite || this._renderDisplay instanceof Cocos.SimpleMesh) {
112
+ var color = (Math.round(this._colorTransform.redMultiplier * 0xFF) << 16) + (Math.round(this._colorTransform.greenMultiplier * 0xFF) << 8) + Math.round(this._colorTransform.blueMultiplier * 0xFF);
113
+ this._renderDisplay.tint = color;
114
+ }
115
+ // TODO child armature.
116
+ };
117
+ CocosSlot.prototype._updateFrame = function () {
118
+ var currentTextureData = this._textureData;
119
+ if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) {
120
+ var currentTextureAtlasData = currentTextureData.parent;
121
+ if (this._armature.replacedTexture !== null) { // Update replaced texture atlas.
122
+ if (this._armature._replaceTextureAtlasData === null) {
123
+ currentTextureAtlasData = dragonbones_js_1.BaseObject.borrowObject(CocosTextureAtlasData_1.CocosTextureAtlasData);
124
+ currentTextureAtlasData.copyFrom(currentTextureData.parent);
125
+ currentTextureAtlasData.renderTexture = this._armature.replacedTexture;
126
+ this._armature._replaceTextureAtlasData = currentTextureAtlasData;
127
+ }
128
+ else {
129
+ currentTextureAtlasData = this._armature._replaceTextureAtlasData;
130
+ }
131
+ currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name);
132
+ }
133
+ var renderTexture = currentTextureData.renderTexture;
134
+ if (renderTexture !== null) {
135
+ if (this._geometryData) { // Mesh.
136
+ var data = this._geometryData.data;
137
+ var intArray = data.intArray;
138
+ var floatArray = data.floatArray;
139
+ var vertexCount = intArray[this._geometryData.offset + dragonbones_js_1.BinaryOffset.GeometryVertexCount];
140
+ var triangleCount = intArray[this._geometryData.offset + dragonbones_js_1.BinaryOffset.GeometryTriangleCount];
141
+ var vertexOffset = intArray[this._geometryData.offset + dragonbones_js_1.BinaryOffset.GeometryFloatOffset];
142
+ if (vertexOffset < 0) {
143
+ vertexOffset += 65536; // Fixed out of bouds bug.
144
+ }
145
+ var uvOffset = vertexOffset + vertexCount * 2;
146
+ var scale = this._armature._armatureData.scale;
147
+ var meshDisplay = this._renderDisplay;
148
+ var vertices = new Float32Array(vertexCount * 2);
149
+ var uvs = new Float32Array(vertexCount * 2);
150
+ var indices = new Uint16Array(triangleCount * 3);
151
+ for (var i = 0, l = vertexCount * 2; i < l; ++i) {
152
+ vertices[i] = floatArray[vertexOffset + i] * scale;
153
+ }
154
+ for (var i = 0; i < triangleCount * 3; ++i) {
155
+ indices[i] = intArray[this._geometryData.offset + dragonbones_js_1.BinaryOffset.GeometryVertexIndices + i];
156
+ }
157
+ for (var i = 0, l = vertexCount * 2; i < l; i += 2) {
158
+ var u = floatArray[uvOffset + i];
159
+ var v = floatArray[uvOffset + i + 1];
160
+ if (currentTextureData.rotated) {
161
+ uvs[i] = 1 - v;
162
+ uvs[i + 1] = u;
163
+ }
164
+ else {
165
+ uvs[i] = u;
166
+ uvs[i + 1] = v;
167
+ }
168
+ }
169
+ this._textureScale = 1.0;
170
+ meshDisplay.texture = renderTexture;
171
+ meshDisplay.vertices = vertices;
172
+ meshDisplay.uvBuffer.update(uvs);
173
+ meshDisplay.geometry.addIndex(indices);
174
+ var isSkinned = this._geometryData.weight !== null;
175
+ var isSurface = this._parent._boneData.type !== dragonbones_js_1.BoneType.Bone;
176
+ if (isSkinned || isSurface) {
177
+ this._identityTransform();
178
+ }
179
+ }
180
+ else {
181
+ // Normal texture.
182
+ this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale;
183
+ var normalDisplay = this._renderDisplay;
184
+ normalDisplay.setSpriteFrame(renderTexture);
185
+ }
186
+ this._visibleDirty = true;
187
+ return;
188
+ }
189
+ }
190
+ if (this._geometryData) {
191
+ var meshDisplay = this._renderDisplay;
192
+ meshDisplay.texture = null;
193
+ meshDisplay.x = 0.0;
194
+ meshDisplay.y = 0.0;
195
+ meshDisplay.visible = false;
196
+ }
197
+ else {
198
+ var normalDisplay = this._renderDisplay;
199
+ normalDisplay.texture = null;
200
+ normalDisplay.x = 0.0;
201
+ normalDisplay.y = 0.0;
202
+ normalDisplay.visible = false;
203
+ }
204
+ this._renderDisplay.setPosition(0.0, 0.0);
205
+ };
206
+ CocosSlot.prototype._updateMesh = function () {
207
+ var scale = this._armature._armatureData.scale;
208
+ var deformVertices = this._displayFrame.deformVertices;
209
+ var bones = this._geometryBones;
210
+ var geometryData = this._geometryData;
211
+ var weightData = geometryData.weight;
212
+ var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform;
213
+ var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite;
214
+ var polygonInfo = meshDisplay.getMeshPolygonInfo();
215
+ if (!polygonInfo) {
216
+ return;
217
+ }
218
+ var verticesAndUVs = polygonInfo.triangles.verts;
219
+ var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0);
220
+ if (weightData !== null) {
221
+ var data = geometryData.data;
222
+ var intArray = data.intArray;
223
+ var floatArray = data.floatArray;
224
+ var vertexCount = intArray[geometryData.offset + dragonbones_js_1.BinaryOffset.MeshVertexCount];
225
+ var weightFloatOffset = intArray[weightData.offset + dragonbones_js_1.BinaryOffset.WeigthFloatOffset];
226
+ if (weightFloatOffset < 0) {
227
+ weightFloatOffset += 65536; // Fixed out of bouds bug.
228
+ }
229
+ for (var i = 0, iB = weightData.offset + dragonbones_js_1.BinaryOffset.WeigthBoneIndices + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) {
230
+ var boneCount = intArray[iB++];
231
+ var xG = 0.0, yG = 0.0;
232
+ for (var j = 0; j < boneCount; ++j) {
233
+ var boneIndex = intArray[iB++];
234
+ var bone = bones[boneIndex];
235
+ if (bone !== null) {
236
+ var matrix = bone.globalTransformMatrix;
237
+ var weight = floatArray[iV++];
238
+ var xL = floatArray[iV++] * scale;
239
+ var yL = floatArray[iV++] * scale;
240
+ if (hasDeform) {
241
+ xL += deformVertices[iF++];
242
+ yL += deformVertices[iF++];
243
+ }
244
+ xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight;
245
+ yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight;
246
+ }
247
+ }
248
+ var vertex = verticesAndUVs[i];
249
+ vertex.x = xG;
250
+ vertex.y = yG;
251
+ if (boundsRect.x > xG) {
252
+ boundsRect.x = xG;
253
+ }
254
+ if (boundsRect.width < xG) {
255
+ boundsRect.width = xG;
256
+ }
257
+ if (boundsRect.y > yG) {
258
+ boundsRect.y = yG;
259
+ }
260
+ if (boundsRect.height < yG) {
261
+ boundsRect.height = yG;
262
+ }
263
+ }
264
+ }
265
+ else {
266
+ var isSurface = this._parent._boneData.type !== dragonbones_js_1.BoneType.Bone;
267
+ var data = geometryData.data;
268
+ var intArray = data.intArray;
269
+ var floatArray = data.floatArray;
270
+ var vertexCount = intArray[geometryData.offset + dragonbones_js_1.BinaryOffset.MeshVertexCount];
271
+ var vertexOffset = intArray[geometryData.offset + dragonbones_js_1.BinaryOffset.MeshFloatOffset];
272
+ if (vertexOffset < 0) {
273
+ vertexOffset += 65536; // Fixed out of bouds bug.
274
+ }
275
+ for (var i = 0, l = vertexCount * 2; i < l; i += 2) {
276
+ var iH = i / 2; // int.
277
+ var x = floatArray[vertexOffset + i] * scale;
278
+ var y = floatArray[vertexOffset + i + 1] * scale;
279
+ if (hasDeform) {
280
+ x += deformVertices[i];
281
+ y += deformVertices[i + 1];
282
+ }
283
+ var vertex = verticesAndUVs[iH];
284
+ if (isSurface) {
285
+ var matrix = (this._parent)._getGlobalTransformMatrix(x, y);
286
+ vertex.x = matrix.a * x + matrix.c * y + matrix.tx;
287
+ vertex.y = matrix.b * x + matrix.d * y + matrix.ty;
288
+ //
289
+ x = vertex.x;
290
+ y = vertex.y;
291
+ }
292
+ else {
293
+ vertex.x = x;
294
+ y = vertex.y = -y;
295
+ }
296
+ if (boundsRect.x > x) {
297
+ boundsRect.x = x;
298
+ }
299
+ if (boundsRect.width < x) {
300
+ boundsRect.width = x;
301
+ }
302
+ if (boundsRect.y > y) {
303
+ boundsRect.y = y;
304
+ }
305
+ if (boundsRect.height < y) {
306
+ boundsRect.height = y;
307
+ }
308
+ }
309
+ }
310
+ boundsRect.width -= boundsRect.x;
311
+ boundsRect.height -= boundsRect.y;
312
+ polygonInfo.rect = boundsRect;
313
+ meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height));
314
+ meshDisplay.setMeshPolygonInfo(polygonInfo);
315
+ if (weightData !== null) {
316
+ this._identityTransform();
317
+ }
318
+ else {
319
+ var transform = this.global;
320
+ var globalTransformMatrix = this.globalTransformMatrix;
321
+ this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
322
+ this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
323
+ this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonbones_js_1.Transform.RAD_DEG;
324
+ this._renderDisplay.rotationY = -transform.rotation * dragonbones_js_1.Transform.RAD_DEG;
325
+ this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
326
+ this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
327
+ }
328
+ };
329
+ CocosSlot.prototype._updateTransform = function () {
330
+ this.updateGlobalTransform();
331
+ var transform = this.global;
332
+ // const globalTransformMatrix = this.globalTransformMatrix;
333
+ // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
334
+ // this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
335
+ // this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
336
+ // }
337
+ // else {
338
+ this._renderDisplay.x = transform.x;
339
+ this._renderDisplay.y = transform.y;
340
+ // }
341
+ this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonbones_js_1.Transform.RAD_DEG;
342
+ this._renderDisplay.rotationY = -transform.rotation * dragonbones_js_1.Transform.RAD_DEG;
343
+ this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
344
+ this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
345
+ };
346
+ CocosSlot.prototype._updateTransformV3 = function () {
347
+ this.updateGlobalTransform(); // Update transform.
348
+ var transform = this.global;
349
+ if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
350
+ var x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY);
351
+ var y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY);
352
+ // this._renderDisplay.transform = new cc.AffineTransform(
353
+ // x, y,
354
+ // transform.scaleX * this._textureScale, transform.scaleY * this._textureScale,
355
+ // transform.rotation,
356
+ // transform.skew, 0.0,
357
+ // );
358
+ this._renderDisplay.setPosition(x, y);
359
+ }
360
+ else {
361
+ this._renderDisplay.setPosition(transform.x, transform.y);
362
+ this._renderDisplay.rotation = transform.rotation;
363
+ this._renderDisplay.skewX = transform.skew;
364
+ this._renderDisplay.setScale(transform.scaleX, transform.scaleY);
365
+ }
366
+ };
367
+ CocosSlot.prototype._identityTransform = function () {
368
+ // const helpMatrix = TransformObject._helpMatrix;
369
+ // helpMatrix.a = 1.0;
370
+ // helpMatrix.b = 0.0;
371
+ // helpMatrix.c = -0.0;
372
+ // helpMatrix.d = -1.0;
373
+ // helpMatrix.tx = 0.0;
374
+ // helpMatrix.ty = 0.0;
375
+ // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix);
376
+ this._renderDisplay.x = 0.0;
377
+ this._renderDisplay.y = 0.0;
378
+ this._renderDisplay.rotationX = 0.0;
379
+ this._renderDisplay.rotationY = 0.0;
380
+ this._renderDisplay.scaleX = 1.0;
381
+ this._renderDisplay.scaleY = 1.0;
382
+ };
383
+ return CocosSlot;
384
+ }(dragonbones_js_1.Slot));
385
+ exports.CocosSlot = CocosSlot;