@safe-engine/cocos 2.2.8 → 2.3.5

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 (78) hide show
  1. package/@types/index.d.ts +0 -59
  2. package/dist/app.d.ts +1 -1
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +25 -23
  5. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  6. package/dist/box2d-wasm/PhysicsComponent.js +3 -0
  7. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  8. package/dist/box2d-wasm/PhysicsSprite.js +2 -1
  9. package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -0
  10. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  11. package/dist/box2d-wasm/PhysicsSystem.js +20 -16
  12. package/dist/box2d-wasm/debugDraw.d.ts +0 -15
  13. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
  14. package/dist/box2d-wasm/debugDraw.js +8 -20
  15. package/dist/box2d-wasm/index.d.ts +19 -1
  16. package/dist/box2d-wasm/index.d.ts.map +1 -1
  17. package/dist/box2d-wasm/index.js +2 -2
  18. package/dist/collider/CollideComponent.d.ts +21 -3
  19. package/dist/collider/CollideComponent.d.ts.map +1 -1
  20. package/dist/core/NodeComp.d.ts +1 -1
  21. package/dist/core/NodeComp.d.ts.map +1 -1
  22. package/dist/dragonbones/DragonBonesComp.d.ts +4 -6
  23. package/dist/dragonbones/DragonBonesComp.d.ts.map +1 -1
  24. package/dist/dragonbones/DragonBonesComp.js +15 -13
  25. package/dist/dragonbones/DragonBonesSystem.d.ts +1 -1
  26. package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
  27. package/dist/dragonbones/DragonBonesSystem.js +42 -35
  28. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts +87 -0
  29. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts.map +1 -0
  30. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.js +240 -0
  31. package/dist/dragonbones/db-cocos/CocosFactory.d.ts +127 -0
  32. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -0
  33. package/dist/dragonbones/db-cocos/CocosFactory.js +186 -0
  34. package/dist/dragonbones/db-cocos/CocosSlot.d.ts +52 -0
  35. package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -0
  36. package/dist/dragonbones/db-cocos/CocosSlot.js +365 -0
  37. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +53 -0
  38. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -0
  39. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +121 -0
  40. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +36 -0
  41. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -0
  42. package/dist/dragonbones/db-cocos/SimpleMeshNode.js +354 -0
  43. package/dist/dragonbones/index.d.ts +0 -1
  44. package/dist/dragonbones/index.d.ts.map +1 -1
  45. package/dist/dragonbones/index.js +0 -1
  46. package/dist/polyfills.d.ts +1 -1
  47. package/dist/polyfills.d.ts.map +1 -1
  48. package/dist/polyfills.js +1 -2
  49. package/dist/render/RenderComponent.d.ts.map +1 -1
  50. package/dist/render/RenderComponent.js +1 -0
  51. package/dist/render/RenderSystem.d.ts.map +1 -1
  52. package/dist/render/RenderSystem.js +34 -2
  53. package/dist/richtext/RichTextComp.js +1 -1
  54. package/dist/spine/SpineSkeleton.d.ts +5 -3
  55. package/dist/spine/SpineSkeleton.d.ts.map +1 -1
  56. package/dist/spine/SpineSkeleton.js +12 -5
  57. package/dist/spine/SpineSystem.d.ts +1 -2
  58. package/dist/spine/SpineSystem.d.ts.map +1 -1
  59. package/dist/spine/SpineSystem.js +22 -24
  60. package/dist/spine/index.d.ts +0 -1
  61. package/dist/spine/index.d.ts.map +1 -1
  62. package/dist/spine/index.js +14 -2
  63. package/dist/spine/spine-cocos/CCSkeleton.d.ts +86 -0
  64. package/dist/spine/spine-cocos/CCSkeleton.d.ts.map +1 -0
  65. package/dist/spine/spine-cocos/CCSkeleton.js +231 -0
  66. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +88 -0
  67. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -0
  68. package/dist/spine/spine-cocos/CCSkeletonAnimation.js +251 -0
  69. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts +28 -0
  70. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  71. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.js +224 -0
  72. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts +36 -0
  73. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -0
  74. package/dist/spine/spine-cocos/CCSkeletonTexture.js +59 -0
  75. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts +28 -0
  76. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  77. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.js +277 -0
  78. package/package.json +6 -7
@@ -0,0 +1,186 @@
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 { Armature, BaseFactory, BaseObject, DragonBones, } from '@cocos/dragonbones-js';
24
+ import { CocosArmatureDisplay } from './CocosArmatureDisplay';
25
+ import { CocosSlot } from './CocosSlot';
26
+ import { CocosTextureAtlasData } from './CocosTextureAtlasData';
27
+ /**
28
+ * - The Cocos factory.
29
+ * @version DragonBones 3.0
30
+ * @language en_US
31
+ */
32
+ /**
33
+ * - Cocos 工厂。
34
+ * @version DragonBones 3.0
35
+ * @language zh_CN
36
+ */
37
+ export class CocosFactory extends BaseFactory {
38
+ static _dragonBonesInstance = null;
39
+ static _factory = null;
40
+ static _clockHandler(passedTime) {
41
+ this._dragonBonesInstance.advanceTime(passedTime);
42
+ }
43
+ /*
44
+ * `passedTime` is elapsed time, specified in seconds.
45
+ */
46
+ static advanceTime(passedTime) {
47
+ this._dragonBonesInstance.advanceTime(passedTime);
48
+ }
49
+ /**
50
+ * - A global factory instance that can be used directly.
51
+ * @version DragonBones 4.7
52
+ * @language en_US
53
+ */
54
+ /**
55
+ * - 一个可以直接使用的全局工厂实例。
56
+ * @version DragonBones 4.7
57
+ * @language zh_CN
58
+ */
59
+ static get factory() {
60
+ if (CocosFactory._factory === null) {
61
+ CocosFactory._factory = new CocosFactory(null);
62
+ }
63
+ return CocosFactory._factory;
64
+ }
65
+ /**
66
+ * - 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
67
+ * @version DragonBones 4.7
68
+ * @language zh_CN
69
+ */
70
+ static newInstance() {
71
+ if (CocosFactory._factory === null) {
72
+ CocosFactory._factory = new CocosFactory(null);
73
+ }
74
+ return CocosFactory._factory;
75
+ }
76
+ /**
77
+ * @inheritDoc
78
+ */
79
+ constructor(dataParser = null) {
80
+ super(dataParser);
81
+ if (CocosFactory._dragonBonesInstance === null) {
82
+ const eventManager = new CocosArmatureDisplay();
83
+ CocosFactory._dragonBonesInstance = new DragonBones(eventManager);
84
+ }
85
+ this._dragonBones = CocosFactory._dragonBonesInstance;
86
+ }
87
+ _buildTextureAtlasData(textureAtlasData, textureAtlas) {
88
+ if (textureAtlasData) {
89
+ // console.log(textureAtlasData, 'textureAtlasData', textureAtlas)
90
+ const scale = cc.director.getContentScaleFactor();
91
+ textureAtlasData.scale = scale;
92
+ textureAtlasData.renderTexture = textureAtlas;
93
+ }
94
+ else {
95
+ textureAtlasData = BaseObject.borrowObject(CocosTextureAtlasData);
96
+ }
97
+ return textureAtlasData;
98
+ }
99
+ _buildArmature(dataPackage) {
100
+ const armature = BaseObject.borrowObject(Armature);
101
+ const armatureDisplay = new CocosArmatureDisplay();
102
+ armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones);
103
+ return armature;
104
+ }
105
+ _buildSlot(_dataPackage, slotData, armature) {
106
+ const slot = BaseObject.borrowObject(CocosSlot);
107
+ slot.init(slotData, armature, new cc.Sprite(), new cc.Sprite());
108
+ return slot;
109
+ }
110
+ /**
111
+ * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it.
112
+ * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update.
113
+ * @param armatureName - The armature data name.
114
+ * @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)
115
+ * @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)
116
+ * @returns The armature display container.
117
+ * @see dragonBones.IArmatureProxy
118
+ * @see dragonBones.BaseFactory#buildArmature
119
+ * @version DragonBones 4.5
120
+ * @example
121
+ * <pre>
122
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
123
+ * </pre>
124
+ * @language en_US
125
+ */
126
+ /**
127
+ * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。
128
+ * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。
129
+ * @param armatureName - 骨架数据名称。
130
+ * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
131
+ * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。 (如果未设置,则使用默认的皮肤数据)
132
+ * @returns 骨架的显示容器。
133
+ * @see dragonBones.IArmatureProxy
134
+ * @see dragonBones.BaseFactory#buildArmature
135
+ * @version DragonBones 4.5
136
+ * @example
137
+ * <pre>
138
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
139
+ * </pre>
140
+ * @language zh_CN
141
+ */
142
+ buildArmatureDisplay(armatureName, dragonBonesName = '', skinName = '', textureAtlasName = '') {
143
+ const armature = this.buildArmature(armatureName, dragonBonesName || '', skinName || '', textureAtlasName || '');
144
+ if (armature !== null) {
145
+ this._dragonBones.clock.add(armature);
146
+ return armature.display;
147
+ }
148
+ return null;
149
+ }
150
+ /**
151
+ * - Create the display object with the specified texture.
152
+ * @param textureName - The texture data name.
153
+ * @param textureAtlasName - The texture atlas data name (Of not set, all texture atlas data will be searched)
154
+ * @version DragonBones 3.0
155
+ * @language en_US
156
+ */
157
+ /**
158
+ * - 创建带有指定贴图的显示对象。
159
+ * @param textureName - 贴图数据名称。
160
+ * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据)
161
+ * @version DragonBones 3.0
162
+ * @language zh_CN
163
+ */
164
+ getTextureDisplay(textureName, textureAtlasName = null) {
165
+ const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : '', textureName);
166
+ if (textureData !== null && textureData.spriteFrame !== null) {
167
+ return new cc.Sprite(textureData.spriteFrame);
168
+ }
169
+ return null;
170
+ }
171
+ /**
172
+ * - A global sound event manager.
173
+ * Sound events can be listened to uniformly from the manager.
174
+ * @version DragonBones 4.5
175
+ * @language en_US
176
+ */
177
+ /**
178
+ * - 全局声音事件管理器。
179
+ * 声音事件可以从该管理器统一侦听。
180
+ * @version DragonBones 4.5
181
+ * @language zh_CN
182
+ */
183
+ get soundEventManager() {
184
+ return this._dragonBones.eventManager;
185
+ }
186
+ }
@@ -0,0 +1,52 @@
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 _ccMeshDirty;
28
+ private _textureScale;
29
+ private _renderDisplay;
30
+ _geometryData: any;
31
+ _geometryBones: any;
32
+ protected _onClear(): void;
33
+ protected _initDisplay(): void;
34
+ protected _disposeDisplay(value: any, isRelease: boolean): void;
35
+ protected _onUpdateDisplay(): void;
36
+ protected _addDisplay(): void;
37
+ protected _replaceDisplay(value: any): void;
38
+ protected _removeDisplay(): void;
39
+ protected _updateZOrder(): void;
40
+ /**
41
+ * @internal
42
+ */
43
+ _updateVisible(): void;
44
+ protected _updateBlendMode(): void;
45
+ protected _updateColor(): void;
46
+ protected _updateFrame(): void;
47
+ protected _updateMesh(): void;
48
+ protected _updateTransform(): void;
49
+ protected _updateTransformV3(): void;
50
+ protected _identityTransform(): void;
51
+ }
52
+ //# sourceMappingURL=CocosSlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosSlot.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosSlot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAsC,IAAI,EAAa,MAAM,uBAAuB,CAAA;AAM3F,qBAAa,SAAU,SAAQ,IAAI;IACjC,eAAe,IAAI,IAAI;WACT,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,cAAc,CAAS;IAC/B,aAAa,MAAA;IACb,cAAc,MAAA;IAEd,SAAS,CAAC,QAAQ,IAAI,IAAI;IAQ1B,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAM/D,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAIlC,SAAS,CAAC,WAAW,IAAI,IAAI;IAI7B,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAe3C,SAAS,CAAC,cAAc,IAAI,IAAI;IAIhC,SAAS,CAAC,aAAa,IAAI,IAAI;IAO/B;;OAEG;IACI,cAAc,IAAI,IAAI;IAI7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAWlC,SAAS,CAAC,YAAY,IAAI,IAAI;IAU9B,SAAS,CAAC,YAAY,IAAI,IAAI;IAyG9B,SAAS,CAAC,WAAW,IAAI,IAAI;IAyJ7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAqBlC,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAuBpC,SAAS,CAAC,kBAAkB,IAAI,IAAI;CAiBrC"}
@@ -0,0 +1,365 @@
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 { BaseObject, BinaryOffset, BoneType, Slot, Transform } from '@cocos/dragonbones-js';
24
+ import { CocosTextureAtlasData } from './CocosTextureAtlasData';
25
+ export class CocosSlot extends Slot {
26
+ _updateGlueMesh() { }
27
+ static toString() {
28
+ return '[class dragonBones.CocosSlot]';
29
+ }
30
+ _ccMeshDirty = false;
31
+ _textureScale;
32
+ _renderDisplay;
33
+ _geometryData;
34
+ _geometryBones;
35
+ _onClear() {
36
+ super._onClear();
37
+ this._textureScale = 1.0;
38
+ this._renderDisplay = null;
39
+ // this._updateTransform = cc[0] === '3' ? this._updateTransformV3 : this._updateTransformV4;
40
+ }
41
+ _initDisplay() { }
42
+ _disposeDisplay(value, isRelease) {
43
+ if (!isRelease) {
44
+ ;
45
+ value.release();
46
+ }
47
+ }
48
+ _onUpdateDisplay() {
49
+ this._renderDisplay = (this._display ? this._display : this._rawDisplay);
50
+ }
51
+ _addDisplay() {
52
+ const container = this._armature.display;
53
+ container.addChild(this._renderDisplay, this._zOrder);
54
+ }
55
+ _replaceDisplay(value) {
56
+ const container = this._armature.display;
57
+ const prevDisplay = value;
58
+ if (this._renderDisplay.parent !== container) {
59
+ container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder());
60
+ }
61
+ // container.removeChild(prevDisplay, false);
62
+ // this._renderDisplay.active = true
63
+ // prevDisplay.active = false
64
+ this._textureScale = 1.0;
65
+ }
66
+ _removeDisplay() {
67
+ this._renderDisplay.parent.removeChild(this._renderDisplay, false);
68
+ }
69
+ _updateZOrder() {
70
+ if (this._renderDisplay.getLocalZOrder() === this._zOrder) {
71
+ return;
72
+ }
73
+ this._renderDisplay.setLocalZOrder(this._zOrder);
74
+ }
75
+ /**
76
+ * @internal
77
+ */
78
+ _updateVisible() {
79
+ this._renderDisplay.visible = this._parent.visible && this._visible;
80
+ }
81
+ _updateBlendMode() {
82
+ if (this._childArmature) {
83
+ const childSlots = this._childArmature.getSlots();
84
+ for (let i = 0, l = childSlots.length; i < l; i++) {
85
+ const slot = childSlots[i];
86
+ slot._blendMode = this._blendMode;
87
+ slot._updateBlendMode();
88
+ }
89
+ }
90
+ }
91
+ _updateColor() {
92
+ const color = cc.color(Math.round(this._colorTransform.redMultiplier * 255), Math.round(this._colorTransform.greenMultiplier * 255), Math.round(this._colorTransform.blueMultiplier * 255), Math.round(this._colorTransform.alphaMultiplier * 255));
93
+ this._renderDisplay.color = color;
94
+ }
95
+ _updateFrame() {
96
+ let currentTextureData = this._textureData;
97
+ if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) {
98
+ let currentTextureAtlasData = currentTextureData.parent;
99
+ if (this._armature.replacedTexture !== null) {
100
+ // Update replaced texture atlas.
101
+ if (this._armature._replaceTextureAtlasData === null) {
102
+ currentTextureAtlasData = BaseObject.borrowObject(CocosTextureAtlasData);
103
+ currentTextureAtlasData.copyFrom(currentTextureData.parent);
104
+ currentTextureAtlasData.renderTexture = this._armature.replacedTexture;
105
+ this._armature._replaceTextureAtlasData = currentTextureAtlasData;
106
+ }
107
+ else {
108
+ currentTextureAtlasData = this._armature._replaceTextureAtlasData;
109
+ }
110
+ currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name);
111
+ }
112
+ const renderTexture = currentTextureData.spriteFrame;
113
+ if (renderTexture !== null) {
114
+ if (this._geometryData) {
115
+ // Mesh.
116
+ const data = this._geometryData.data;
117
+ const intArray = data.intArray;
118
+ const floatArray = data.floatArray;
119
+ const vertexCount = intArray[this._geometryData.offset + BinaryOffset.MeshVertexCount];
120
+ const triangleCount = intArray[this._geometryData.offset + BinaryOffset.MeshTriangleCount];
121
+ let vertexOffset = intArray[this._geometryData.offset + BinaryOffset.MeshFloatOffset];
122
+ if (vertexOffset < 0) {
123
+ vertexOffset += 65536; // Fixed out of bouds bug.
124
+ }
125
+ const uvOffset = vertexOffset + vertexCount * 2;
126
+ const scale = this._armature._armatureData.scale;
127
+ const meshDisplay = this._renderDisplay;
128
+ const vertices = new Float32Array(vertexCount * 2);
129
+ const uvs = new Float32Array(vertexCount * 2);
130
+ const indices = new Uint16Array(triangleCount * 3);
131
+ for (let i = 0, l = vertexCount * 2; i < l; ++i) {
132
+ vertices[i] = floatArray[vertexOffset + i] * scale;
133
+ }
134
+ for (let i = 0; i < triangleCount * 3; ++i) {
135
+ indices[i] = intArray[this._geometryData.offset + BinaryOffset.MeshVertexIndices + i];
136
+ }
137
+ for (let i = 0, l = vertexCount * 2; i < l; i += 2) {
138
+ const u = floatArray[uvOffset + i];
139
+ const v = floatArray[uvOffset + i + 1];
140
+ if (currentTextureData.rotated) {
141
+ uvs[i] = 1 - v;
142
+ uvs[i + 1] = u;
143
+ }
144
+ else {
145
+ uvs[i] = u;
146
+ uvs[i + 1] = v;
147
+ }
148
+ }
149
+ this._textureScale = 1.0;
150
+ meshDisplay.setTexture(renderTexture);
151
+ meshDisplay.setVertices(vertices);
152
+ // meshDisplay.uvBuffer.update(uvs)
153
+ // meshDisplay.geometry.addIndex(indices)
154
+ const isSkinned = this._geometryData.weight !== null;
155
+ const isSurface = this._parent._boneData.type !== BoneType.Bone;
156
+ if (isSkinned || isSurface) {
157
+ this._identityTransform();
158
+ }
159
+ }
160
+ else {
161
+ // Normal texture.
162
+ this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale;
163
+ const normalDisplay = this._renderDisplay;
164
+ // console.log(normalDisplay, renderTexture)
165
+ normalDisplay.setSpriteFrame(renderTexture);
166
+ }
167
+ this._visibleDirty = true;
168
+ return;
169
+ }
170
+ }
171
+ if (this._geometryData) {
172
+ const meshDisplay = this._renderDisplay;
173
+ meshDisplay.setTexture(null);
174
+ meshDisplay.x = 0.0;
175
+ meshDisplay.y = 0.0;
176
+ meshDisplay.visible = false;
177
+ }
178
+ else {
179
+ const normalDisplay = this._renderDisplay;
180
+ normalDisplay.texture = null;
181
+ normalDisplay.x = 0.0;
182
+ normalDisplay.y = 0.0;
183
+ normalDisplay.visible = false;
184
+ }
185
+ this._renderDisplay.setPosition(0.0, 0.0);
186
+ }
187
+ _updateMesh() {
188
+ const scale = this._armature._armatureData.scale;
189
+ // console.log(this._renderDisplay)
190
+ const deformVertices = this._deformVertices;
191
+ const bones = this._geometryBones;
192
+ const geometryData = this._geometryData;
193
+ const weightData = deformVertices.verticesData.weight;
194
+ const hasDeform = deformVertices.vertices.length > 0 && deformVertices.verticesData.inheritDeform;
195
+ // const meshDisplay = (this._renderDisplay.getComponent(cc.Sprite) as any)._sgNode; // as cc.Scale9Sprite;
196
+ const polygonInfo = this._meshDisplay._polygonInfo;
197
+ if (!polygonInfo) {
198
+ return;
199
+ }
200
+ const verticesAndUVs = polygonInfo.triangles.verts;
201
+ const boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0);
202
+ if (weightData !== null) {
203
+ const data = geometryData.data;
204
+ const intArray = data.intArray;
205
+ const floatArray = data.floatArray;
206
+ const vertexCount = intArray[geometryData.offset + BinaryOffset.MeshVertexCount];
207
+ let weightFloatOffset = intArray[weightData.offset + BinaryOffset.WeigthFloatOffset];
208
+ if (weightFloatOffset < 0) {
209
+ weightFloatOffset += 65536; // Fixed out of bouds bug.
210
+ }
211
+ for (let i = 0, iB = weightData.offset + BinaryOffset.WeigthBoneIndices + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) {
212
+ const boneCount = intArray[iB++];
213
+ let xG = 0.0, yG = 0.0;
214
+ for (let j = 0; j < boneCount; ++j) {
215
+ const boneIndex = intArray[iB++];
216
+ const bone = bones[boneIndex];
217
+ if (bone !== null) {
218
+ const matrix = bone.globalTransformMatrix;
219
+ const weight = floatArray[iV++];
220
+ let xL = floatArray[iV++] * scale;
221
+ let yL = floatArray[iV++] * scale;
222
+ if (hasDeform) {
223
+ xL += deformVertices[iF++];
224
+ yL += deformVertices[iF++];
225
+ }
226
+ xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight;
227
+ yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight;
228
+ }
229
+ }
230
+ const vertex = verticesAndUVs[i];
231
+ vertex.x = xG;
232
+ vertex.y = yG;
233
+ if (boundsRect.x > xG) {
234
+ boundsRect.x = xG;
235
+ }
236
+ if (boundsRect.width < xG) {
237
+ boundsRect.width = xG;
238
+ }
239
+ if (boundsRect.y > yG) {
240
+ boundsRect.y = yG;
241
+ }
242
+ if (boundsRect.height < yG) {
243
+ boundsRect.height = yG;
244
+ }
245
+ }
246
+ }
247
+ else {
248
+ const isSurface = this._parent._boneData.type !== BoneType.Bone;
249
+ const data = geometryData.data;
250
+ const intArray = data.intArray;
251
+ const floatArray = data.floatArray;
252
+ const vertexCount = intArray[geometryData.offset + BinaryOffset.MeshVertexCount];
253
+ let vertexOffset = intArray[geometryData.offset + BinaryOffset.MeshFloatOffset];
254
+ if (vertexOffset < 0) {
255
+ vertexOffset += 65536; // Fixed out of bouds bug.
256
+ }
257
+ for (let i = 0, l = vertexCount * 2; i < l; i += 2) {
258
+ const iH = i / 2; // int.
259
+ let x = floatArray[vertexOffset + i] * scale;
260
+ let y = floatArray[vertexOffset + i + 1] * scale;
261
+ if (hasDeform) {
262
+ x += deformVertices[i];
263
+ y += deformVertices[i + 1];
264
+ }
265
+ const vertex = verticesAndUVs[iH];
266
+ if (isSurface) {
267
+ const matrix = this._parent._getGlobalTransformMatrix(x, y);
268
+ vertex.x = matrix.a * x + matrix.c * y + matrix.tx;
269
+ vertex.y = matrix.b * x + matrix.d * y + matrix.ty;
270
+ //
271
+ x = vertex.x;
272
+ y = vertex.y;
273
+ }
274
+ else {
275
+ vertex.x = x;
276
+ y = vertex.y = -y;
277
+ }
278
+ if (boundsRect.x > x) {
279
+ boundsRect.x = x;
280
+ }
281
+ if (boundsRect.width < x) {
282
+ boundsRect.width = x;
283
+ }
284
+ if (boundsRect.y > y) {
285
+ boundsRect.y = y;
286
+ }
287
+ if (boundsRect.height < y) {
288
+ boundsRect.height = y;
289
+ }
290
+ }
291
+ }
292
+ boundsRect.width -= boundsRect.x;
293
+ boundsRect.height -= boundsRect.y;
294
+ polygonInfo.rect = boundsRect;
295
+ this.meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height));
296
+ this.meshDisplay.setMeshPolygonInfo(polygonInfo);
297
+ if (weightData !== null) {
298
+ this._identityTransform();
299
+ }
300
+ else {
301
+ const transform = this.global;
302
+ const globalTransformMatrix = this.globalTransformMatrix;
303
+ this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
304
+ this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
305
+ this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * Transform.RAD_DEG;
306
+ this._renderDisplay.rotationY = -transform.rotation * Transform.RAD_DEG;
307
+ this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
308
+ this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
309
+ }
310
+ }
311
+ _updateTransform() {
312
+ this.updateGlobalTransform();
313
+ const transform = this.global;
314
+ // const globalTransformMatrix = this.globalTransformMatrix;
315
+ // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
316
+ // this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
317
+ // this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
318
+ // }
319
+ // else {
320
+ this._renderDisplay.x = transform.x;
321
+ this._renderDisplay.y = transform.y;
322
+ // }
323
+ this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * Transform.RAD_DEG;
324
+ this._renderDisplay.rotationY = -transform.rotation * Transform.RAD_DEG;
325
+ this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
326
+ this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
327
+ }
328
+ _updateTransformV3() {
329
+ this.updateGlobalTransform(); // Update transform.
330
+ const transform = this.global;
331
+ if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
332
+ const x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY);
333
+ const y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY);
334
+ // this._renderDisplay.transform = new cc.AffineTransform(
335
+ // x, y,
336
+ // transform.scaleX * this._textureScale, transform.scaleY * this._textureScale,
337
+ // transform.rotation,
338
+ // transform.skew, 0.0,
339
+ // );
340
+ this._renderDisplay.setPosition(x, y);
341
+ }
342
+ else {
343
+ this._renderDisplay.setPosition(transform.x, transform.y);
344
+ this._renderDisplay.rotation = transform.rotation;
345
+ this._renderDisplay.skewX = transform.skew;
346
+ this._renderDisplay.setScale(transform.scaleX, transform.scaleY);
347
+ }
348
+ }
349
+ _identityTransform() {
350
+ // const helpMatrix = TransformObject._helpMatrix;
351
+ // helpMatrix.a = 1.0;
352
+ // helpMatrix.b = 0.0;
353
+ // helpMatrix.c = -0.0;
354
+ // helpMatrix.d = -1.0;
355
+ // helpMatrix.tx = 0.0;
356
+ // helpMatrix.ty = 0.0;
357
+ // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix);
358
+ this._renderDisplay.x = 0.0;
359
+ this._renderDisplay.y = 0.0;
360
+ this._renderDisplay.rotationX = 0.0;
361
+ this._renderDisplay.rotationY = 0.0;
362
+ this._renderDisplay.scaleX = 1.0;
363
+ this._renderDisplay.scaleY = 1.0;
364
+ }
365
+ }
@@ -0,0 +1,53 @@
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 { TextureAtlasData, TextureData } from '@cocos/dragonbones-js';
24
+ export declare class CocosTextureAtlasData extends TextureAtlasData {
25
+ static toString(): string;
26
+ private _renderTexture;
27
+ protected _onClear(): void;
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ createTexture(): TextureData;
32
+ /**
33
+ * - The CocosJS texture.
34
+ * @version DragonBones 3.0
35
+ * @language en_US
36
+ */
37
+ /**
38
+ * - CocosJS 贴图。
39
+ * @version DragonBones 3.0
40
+ * @language zh_CN
41
+ */
42
+ get renderTexture(): cc.Texture2D | null;
43
+ set renderTexture(value: cc.Texture2D | null);
44
+ }
45
+ /**
46
+ * @internal
47
+ */
48
+ export declare class CocosTextureData extends TextureData {
49
+ static toString(): string;
50
+ spriteFrame: cc.SpriteFrame | null;
51
+ protected _onClear(): void;
52
+ }
53
+ //# sourceMappingURL=CocosTextureAtlasData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosTextureAtlasData.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosTextureAtlasData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAc,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEjF,qBAAa,qBAAsB,SAAQ,gBAAgB;WAC3C,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,cAAc,CAA4B;IAElD,SAAS,CAAC,QAAQ,IAAI,IAAI;IAS1B;;OAEG;IACI,aAAa,IAAI,WAAW;IAGnC;;;;OAIG;IACH;;;;OAIG;IACH,IAAW,aAAa,IAAI,EAAE,CAAC,SAAS,GAAG,IAAI,CAE9C;IACD,IAAW,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,GAAG,IAAI,EAoDlD;CACF;AACD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;WACjC,QAAQ,IAAI,MAAM;IAIzB,WAAW,EAAE,EAAE,CAAC,WAAW,GAAG,IAAI,CAAO;IAEhD,SAAS,CAAC,QAAQ,IAAI,IAAI;CAS3B"}