@safe-engine/cocos 2.3.4 → 2.3.6

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 (80) hide show
  1. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  2. package/dist/box2d-wasm/PhysicsComponent.js +3 -0
  3. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  4. package/dist/box2d-wasm/PhysicsSprite.js +2 -1
  5. package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -0
  6. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  7. package/dist/box2d-wasm/PhysicsSystem.js +20 -16
  8. package/dist/box2d-wasm/debugDraw.d.ts +0 -15
  9. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
  10. package/dist/box2d-wasm/debugDraw.js +8 -20
  11. package/dist/box2d-wasm/index.d.ts +19 -1
  12. package/dist/box2d-wasm/index.d.ts.map +1 -1
  13. package/dist/box2d-wasm/index.js +2 -2
  14. package/dist/core/index.d.ts +6 -0
  15. package/dist/core/index.d.ts.map +1 -0
  16. package/dist/core/index.js +5 -0
  17. package/dist/dragonbones/PixiDragonBonesSprite.d.ts +19 -0
  18. package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -0
  19. package/dist/dragonbones/PixiDragonBonesSprite.js +75 -0
  20. package/dist/dragonbones/db-cocos/CocosFactory.d.ts +2 -3
  21. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -1
  22. package/dist/dragonbones/db-cocos/CocosFactory.js +4 -8
  23. package/dist/dragonbones/db-cocos/CocosSlot.d.ts +6 -3
  24. package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -1
  25. package/dist/dragonbones/db-cocos/CocosSlot.js +36 -40
  26. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +1 -1
  27. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -1
  28. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +6 -6
  29. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +36 -0
  30. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -0
  31. package/dist/dragonbones/db-cocos/SimpleMeshNode.js +354 -0
  32. package/dist/gworld/EnhancedComponent.d.ts +22 -0
  33. package/dist/gworld/EnhancedComponent.d.ts.map +1 -0
  34. package/dist/gworld/EnhancedComponent.js +44 -0
  35. package/dist/gworld/NodeComp.d.ts +153 -0
  36. package/dist/gworld/NodeComp.d.ts.map +1 -0
  37. package/dist/gworld/NodeComp.js +337 -0
  38. package/dist/gworld/NodePool.d.ts +9 -0
  39. package/dist/gworld/NodePool.d.ts.map +1 -0
  40. package/dist/gworld/NodePool.js +23 -0
  41. package/dist/gworld/Scene.d.ts +5 -0
  42. package/dist/gworld/Scene.d.ts.map +1 -0
  43. package/dist/gworld/Scene.js +14 -0
  44. package/dist/gworld/decorator.d.ts +8 -0
  45. package/dist/gworld/decorator.d.ts.map +1 -0
  46. package/dist/gworld/decorator.js +12 -0
  47. package/dist/gworld/index.d.ts +8 -0
  48. package/dist/gworld/index.d.ts.map +1 -0
  49. package/dist/gworld/index.js +14 -0
  50. package/dist/render/TiledSprite.d.ts +13 -0
  51. package/dist/render/TiledSprite.d.ts.map +1 -0
  52. package/dist/render/TiledSprite.js +69 -0
  53. package/dist/safex.d.ts +10 -0
  54. package/dist/safex.d.ts.map +1 -0
  55. package/dist/safex.js +1 -0
  56. package/dist/spine/CCSkeleton.d.ts +189 -0
  57. package/dist/spine/CCSkeleton.d.ts.map +1 -0
  58. package/dist/spine/CCSkeleton.js +320 -0
  59. package/dist/spine/CCSkeletonAnimation.d.ts +146 -0
  60. package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
  61. package/dist/spine/CCSkeletonAnimation.js +311 -0
  62. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
  63. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  64. package/dist/spine/CCSkeletonCanvasRenderCmd.js +228 -0
  65. package/dist/spine/CCSkeletonTexture.d.ts +25 -0
  66. package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
  67. package/dist/spine/CCSkeletonTexture.js +60 -0
  68. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +28 -0
  69. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  70. package/dist/spine/CCSkeletonWebGLRenderCmd.js +277 -0
  71. package/dist/spine/PixiSpineSprite.d.ts +19 -0
  72. package/dist/spine/PixiSpineSprite.d.ts.map +1 -0
  73. package/dist/spine/PixiSpineSprite.js +72 -0
  74. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +2 -1
  75. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -1
  76. package/dist/spine/spine-cocos/CCSkeletonAnimation.js +1 -1
  77. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts +12 -1
  78. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -1
  79. package/dist/spine/spine-cocos/CCSkeletonTexture.js +18 -19
  80. package/package.json +3 -3
@@ -0,0 +1,228 @@
1
+ import * as spine from '@esotericsoftware/spine-core';
2
+ /****************************************************************************
3
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
4
+
5
+ http://www.cocos2d-x.org
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ ****************************************************************************/
25
+ var gworld = gworld || {};
26
+ (function () {
27
+ gworld.CanvasRenderCmd = function (renderableObject) {
28
+ this._rootCtor(renderableObject);
29
+ this._needDraw = true;
30
+ };
31
+ const proto = (gworld.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
32
+ proto.constructor = gworld.CanvasRenderCmd;
33
+ proto.rendering = function (wrapper, scaleX, scaleY) {
34
+ const node = this._node;
35
+ let i, n, slot, slotNode;
36
+ wrapper = wrapper || cc._renderContext;
37
+ const locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
38
+ for (i = 0, n = drawOrder.length; i < n; i++) {
39
+ slot = drawOrder[i];
40
+ slotNode = slot._slotNode;
41
+ if (slotNode._visible && slotNode._renderCmd && slot.currentSprite) {
42
+ slotNode._renderCmd.transform(this, true);
43
+ slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY);
44
+ slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0;
45
+ }
46
+ }
47
+ if (!node._debugSlots && !node._debugBones)
48
+ return;
49
+ wrapper.setTransform(this._worldTransform, scaleX, scaleY);
50
+ wrapper.setGlobalAlpha(1);
51
+ let attachment;
52
+ const drawingUtil = cc._drawingUtil;
53
+ if (node._debugSlots) {
54
+ // Slots.
55
+ drawingUtil.setDrawColor(0, 0, 255, 255);
56
+ drawingUtil.setLineWidth(1);
57
+ const points = [];
58
+ for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
59
+ slot = locSkeleton.drawOrder[i];
60
+ if (!slot.attachment || !(slot.attachment instanceof spine.RegionAttachment))
61
+ continue;
62
+ attachment = slot.attachment;
63
+ this._updateRegionAttachmentSlot(attachment, slot, points);
64
+ drawingUtil.drawPoly(points, 4, true);
65
+ }
66
+ }
67
+ if (node._debugBones) {
68
+ // Bone lengths.
69
+ let bone;
70
+ drawingUtil.setLineWidth(2);
71
+ drawingUtil.setDrawColor(255, 0, 0, 255);
72
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
73
+ bone = locSkeleton.bones[i];
74
+ const x = bone.data.length * bone.a + bone.worldX;
75
+ const y = bone.data.length * bone.c + bone.worldY;
76
+ drawingUtil.drawLine({ x: bone.worldX, y: bone.worldY }, { x: x, y: y });
77
+ }
78
+ // Bone origins.
79
+ const pointSize = 4;
80
+ drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
81
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
82
+ bone = locSkeleton.bones[i];
83
+ drawingUtil.drawPoint({ x: bone.worldX, y: bone.worldY }, pointSize);
84
+ if (i === 0)
85
+ drawingUtil.setDrawColor(0, 255, 0, 255);
86
+ }
87
+ }
88
+ };
89
+ proto.updateStatus = function () {
90
+ this.originUpdateStatus();
91
+ this._updateCurrentRegions();
92
+ this._regionFlag = cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
93
+ this._dirtyFlag &= ~cc.Node._dirtyFlags.contentDirty;
94
+ };
95
+ proto.getLocalBB = function () {
96
+ return this._node.getBoundingBox();
97
+ };
98
+ proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
99
+ if (!points)
100
+ return;
101
+ const vertices = spine.Utils.setArraySize([], 8, 0);
102
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
103
+ const VERTEX = spine.RegionAttachment;
104
+ points.length = 0;
105
+ points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
106
+ points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
107
+ points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]));
108
+ points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
109
+ };
110
+ proto._createChildFormSkeletonData = function () {
111
+ const node = this._node;
112
+ const locSkeleton = node._skeleton;
113
+ let spriteName, sprite;
114
+ for (let i = 0, n = locSkeleton.slots.length; i < n; i++) {
115
+ const slot = locSkeleton.slots[i], attachment = slot.attachment;
116
+ const slotNode = new cc.Node();
117
+ slot._slotNode = slotNode;
118
+ if (attachment instanceof spine.RegionAttachment) {
119
+ spriteName = attachment.name;
120
+ sprite = this._createSprite(slot, attachment);
121
+ slot.currentSprite = sprite;
122
+ slot.currentSpriteName = spriteName;
123
+ slotNode.addChild(sprite);
124
+ }
125
+ else if (attachment instanceof spine.MeshAttachment) {
126
+ //todo for mesh
127
+ }
128
+ }
129
+ };
130
+ const loaded = function (sprite, texture, attachment) {
131
+ const rendererObject = attachment.region;
132
+ const rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
133
+ sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
134
+ sprite._rect.width = attachment.width;
135
+ sprite._rect.height = attachment.height;
136
+ sprite.setContentSize(attachment.width, attachment.height);
137
+ sprite.setRotation(-attachment.rotation);
138
+ sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
139
+ };
140
+ proto._createSprite = function (slot, attachment) {
141
+ const rendererObject = attachment.region;
142
+ const texture = rendererObject.texture.getRealTexture();
143
+ const sprite = new cc.Sprite();
144
+ if (texture.isLoaded()) {
145
+ loaded(sprite, texture, attachment);
146
+ }
147
+ else {
148
+ texture.addEventListener('load', function () {
149
+ loaded(sprite, texture, attachment);
150
+ }, this);
151
+ }
152
+ slot.sprites = slot.sprites || {};
153
+ slot.sprites[rendererObject.name] = sprite;
154
+ return sprite;
155
+ };
156
+ proto._updateChild = function () {
157
+ const locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
158
+ const color = this._displayedColor, opacity = this._displayedOpacity;
159
+ let i, n, selSprite, ax, ay;
160
+ let slot, attachment, slotNode;
161
+ for (i = 0, n = slots.length; i < n; i++) {
162
+ slot = slots[i];
163
+ attachment = slot.attachment;
164
+ slotNode = slot._slotNode;
165
+ if (!attachment) {
166
+ slotNode.setVisible(false);
167
+ continue;
168
+ }
169
+ if (attachment instanceof spine.RegionAttachment) {
170
+ if (attachment.region) {
171
+ if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
172
+ const spriteName = attachment.name;
173
+ if (slot.currentSprite !== undefined)
174
+ slot.currentSprite.setVisible(false);
175
+ slot.sprites = slot.sprites || {};
176
+ if (slot.sprites[spriteName] !== undefined)
177
+ slot.sprites[spriteName].setVisible(true);
178
+ else {
179
+ const sprite = this._createSprite(slot, attachment);
180
+ slotNode.addChild(sprite);
181
+ }
182
+ slot.currentSprite = slot.sprites[spriteName];
183
+ slot.currentSpriteName = spriteName;
184
+ }
185
+ }
186
+ const bone = slot.bone;
187
+ if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
188
+ ax = attachment.x;
189
+ ay = attachment.y;
190
+ }
191
+ else {
192
+ //var regionScaleX = attachment.width / attachment.regionOriginalWidth * attachment.scaleX;
193
+ //ax = attachment.x + attachment.regionOffsetX * regionScaleX - (attachment.width * attachment.scaleX - attachment.regionWidth * regionScaleX) / 2;
194
+ ax = (attachment.offset[0] + attachment.offset[4]) * 0.5;
195
+ ay = (attachment.offset[1] + attachment.offset[5]) * 0.5;
196
+ }
197
+ slotNode.setPosition(bone.worldX + ax * bone.a + ay * bone.b, bone.worldY + ax * bone.c + ay * bone.d);
198
+ slotNode.setScale(bone.getWorldScaleX(), bone.getWorldScaleY());
199
+ //set the color and opacity
200
+ selSprite = slot.currentSprite;
201
+ selSprite._flippedX = bone.skeleton.flipX;
202
+ selSprite._flippedY = bone.skeleton.flipY;
203
+ if (selSprite._flippedY || selSprite._flippedX) {
204
+ slotNode.setRotation(bone.getWorldRotationX());
205
+ selSprite.setRotation(attachment.rotation);
206
+ }
207
+ else {
208
+ slotNode.setRotation(-bone.getWorldRotationX());
209
+ selSprite.setRotation(-attachment.rotation);
210
+ }
211
+ //hack for sprite
212
+ selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
213
+ const r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
214
+ selSprite.setColor(cc.color(r, g, b));
215
+ selSprite._renderCmd._updateColor();
216
+ }
217
+ else if (attachment instanceof spine.MeshAttachment) {
218
+ // Can not render mesh
219
+ }
220
+ else {
221
+ slotNode.setVisible(false);
222
+ continue;
223
+ }
224
+ slotNode.setVisible(true);
225
+ }
226
+ };
227
+ })();
228
+ export const CanvasRenderCmd = gworld.CanvasRenderCmd;
@@ -0,0 +1,25 @@
1
+ /****************************************************************************
2
+ Copyright (c) 2017 Chukong Technologies Inc.
3
+
4
+ http://www.cocos2d-x.org
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all 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,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ ****************************************************************************/
24
+ export declare const SkeletonTexture: (image: any) => void;
25
+ //# sourceMappingURL=CCSkeletonTexture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonTexture.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAE9E,eAAO,MAAM,eAAe,GAAa,UAAK,SAE7C,CAAA"}
@@ -0,0 +1,60 @@
1
+ import * as spine from '@esotericsoftware/spine-core';
2
+ /****************************************************************************
3
+ Copyright (c) 2017 Chukong Technologies Inc.
4
+
5
+ http://www.cocos2d-x.org
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ ****************************************************************************/
25
+ export const SkeletonTexture = function (image) {
26
+ // spine.Texture.call(this, image)
27
+ };
28
+ cc.inherits(SkeletonTexture, spine.Texture);
29
+ cc.extend(SkeletonTexture.prototype, {
30
+ name: 'gworld.SkeletonTexture',
31
+ _texture: null,
32
+ setRealTexture: function (tex) {
33
+ this._texture = tex;
34
+ },
35
+ getRealTexture: function () {
36
+ return this._texture;
37
+ },
38
+ setFilters: function (minFilter, magFilter) {
39
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
40
+ const gl = cc._renderContext;
41
+ this.bind();
42
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
43
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
44
+ }
45
+ },
46
+ setWraps: function (uWrap, vWrap) {
47
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
48
+ const gl = cc._renderContext;
49
+ this.bind();
50
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
51
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
52
+ }
53
+ },
54
+ dispose: function () { },
55
+ bind: function () {
56
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
57
+ cc.glBindTexture2D(this._texture);
58
+ }
59
+ },
60
+ });
@@ -0,0 +1,28 @@
1
+ /****************************************************************************
2
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
3
+
4
+ http://www.cocos2d-x.org
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all 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,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ ****************************************************************************/
24
+ export declare const WebGLRenderCmd: {
25
+ (renderableObject: any): void;
26
+ prototype: any;
27
+ };
28
+ //# sourceMappingURL=CCSkeletonWebGLRenderCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonWebGLRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonWebGLRenderCmd.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAE9E,eAAO,MAAM,cAAc;;;CAS1B,CAAA"}
@@ -0,0 +1,277 @@
1
+ import * as spine from '@esotericsoftware/spine-core';
2
+ /****************************************************************************
3
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
4
+
5
+ http://www.cocos2d-x.org
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ ****************************************************************************/
25
+ export const WebGLRenderCmd = function (renderableObject) {
26
+ this._rootCtor(renderableObject);
27
+ this._needDraw = true;
28
+ this._matrix = new cc.math.Matrix4();
29
+ this._matrix.identity();
30
+ this._currTexture = null;
31
+ this._currBlendFunc = {};
32
+ this.vertexType = cc.renderer.VertexType.CUSTOM;
33
+ this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR));
34
+ };
35
+ const proto = (WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype));
36
+ proto.constructor = WebGLRenderCmd;
37
+ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
38
+ const node = this._node;
39
+ const color = this._displayedColor, locSkeleton = node._skeleton;
40
+ let attachment, slot, i, n;
41
+ const premultiAlpha = node._premultipliedAlpha;
42
+ locSkeleton.r = color.r / 255;
43
+ locSkeleton.g = color.g / 255;
44
+ locSkeleton.b = color.b / 255;
45
+ locSkeleton.a = this._displayedOpacity / 255;
46
+ if (premultiAlpha) {
47
+ locSkeleton.r *= locSkeleton.a;
48
+ locSkeleton.g *= locSkeleton.a;
49
+ locSkeleton.b *= locSkeleton.a;
50
+ }
51
+ let debugSlotsInfo = null;
52
+ if (this._node._debugSlots) {
53
+ debugSlotsInfo = [];
54
+ }
55
+ for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) {
56
+ slot = locSkeleton.drawOrder[i];
57
+ if (!slot.attachment)
58
+ continue;
59
+ attachment = slot.attachment;
60
+ // get the vertices length
61
+ let vertCount = 0;
62
+ if (attachment instanceof spine.RegionAttachment) {
63
+ vertCount = 6; // a quad = two triangles = six vertices
64
+ }
65
+ else if (attachment instanceof spine.MeshAttachment) {
66
+ vertCount = attachment.regionUVs.length / 2;
67
+ }
68
+ else {
69
+ continue;
70
+ }
71
+ // no vertices to render
72
+ if (vertCount === 0) {
73
+ continue;
74
+ }
75
+ const regionTextureAtlas = node.getTextureAtlas(attachment);
76
+ // Broken for changing batch info
77
+ let batchBroken;
78
+ if (regionTextureAtlas.texture) {
79
+ this._currTexture = regionTextureAtlas.texture.getRealTexture();
80
+ batchBroken = cc.renderer._updateBatchedInfo(this._currTexture, this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._glProgramState);
81
+ }
82
+ // keep the same logic with RendererWebGL.js, avoid vertex data overflow
83
+ const uploadAll = vertexDataOffset / 6 + vertCount > (cc.BATCH_VERTEX_COUNT - 200) * 0.5;
84
+ // Broken for vertex data overflow
85
+ if (!batchBroken && uploadAll) {
86
+ // render the cached data
87
+ cc.renderer._batchRendering();
88
+ batchBroken = true;
89
+ }
90
+ if (batchBroken) {
91
+ vertexDataOffset = 0;
92
+ }
93
+ // update the vertex buffer
94
+ let slotDebugPoints = null;
95
+ if (attachment instanceof spine.RegionAttachment) {
96
+ slotDebugPoints = this._uploadRegionAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
97
+ }
98
+ else if (attachment instanceof spine.MeshAttachment) {
99
+ this._uploadMeshAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
100
+ }
101
+ else {
102
+ continue;
103
+ }
104
+ if (this._node._debugSlots) {
105
+ debugSlotsInfo[i] = slotDebugPoints;
106
+ }
107
+ // update the index buffer
108
+ if (attachment instanceof spine.RegionAttachment) {
109
+ cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.TRIANGLE);
110
+ }
111
+ else {
112
+ cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.CUSTOM, attachment.triangles);
113
+ }
114
+ // update the index data
115
+ vertexDataOffset += vertCount * 6;
116
+ }
117
+ if (node._debugBones || node._debugSlots) {
118
+ // flush previous vertices
119
+ cc.renderer._batchRendering();
120
+ const wt = this._worldTransform, mat = this._matrix.mat;
121
+ mat[0] = wt.a;
122
+ mat[4] = wt.c;
123
+ mat[12] = wt.tx;
124
+ mat[1] = wt.b;
125
+ mat[5] = wt.d;
126
+ mat[13] = wt.ty;
127
+ cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
128
+ cc.current_stack.stack.push(cc.current_stack.top);
129
+ cc.current_stack.top = this._matrix;
130
+ const drawingUtil = cc._drawingUtil;
131
+ if (node._debugSlots && debugSlotsInfo && debugSlotsInfo.length > 0) {
132
+ // Slots.
133
+ drawingUtil.setDrawColor(0, 0, 255, 255);
134
+ drawingUtil.setLineWidth(1);
135
+ for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
136
+ const points = debugSlotsInfo[i];
137
+ if (points) {
138
+ drawingUtil.drawPoly(points, 4, true);
139
+ }
140
+ }
141
+ }
142
+ if (node._debugBones) {
143
+ // Bone lengths.
144
+ let bone;
145
+ drawingUtil.setLineWidth(2);
146
+ drawingUtil.setDrawColor(255, 0, 0, 255);
147
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
148
+ bone = locSkeleton.bones[i];
149
+ const x = bone.data.length * bone.a + bone.worldX;
150
+ const y = bone.data.length * bone.c + bone.worldY;
151
+ drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y));
152
+ }
153
+ // Bone origins.
154
+ drawingUtil.setPointSize(4);
155
+ drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
156
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
157
+ bone = locSkeleton.bones[i];
158
+ drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY));
159
+ if (i == 0) {
160
+ drawingUtil.setDrawColor(0, 255, 0, 255);
161
+ }
162
+ }
163
+ }
164
+ cc.kmGLPopMatrix();
165
+ }
166
+ return 0;
167
+ };
168
+ proto._getBlendFunc = function (blendMode, premultiAlpha) {
169
+ let ret = this._currBlendFunc;
170
+ switch (blendMode) {
171
+ case spine.BlendMode.Normal:
172
+ ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
173
+ ret.dst = cc.ONE_MINUS_SRC_ALPHA;
174
+ break;
175
+ case spine.BlendMode.Additive:
176
+ ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
177
+ ret.dst = cc.ONE;
178
+ break;
179
+ case spine.BlendMode.Multiply:
180
+ ret.src = cc.DST_COLOR;
181
+ ret.dst = cc.ONE_MINUS_SRC_ALPHA;
182
+ break;
183
+ case spine.BlendMode.Screen:
184
+ ret.src = cc.ONE;
185
+ ret.dst = cc.ONE_MINUS_SRC_COLOR;
186
+ break;
187
+ default:
188
+ ret = this._node._blendFunc;
189
+ break;
190
+ }
191
+ return ret;
192
+ };
193
+ proto._createChildFormSkeletonData = function () { };
194
+ proto._updateChild = function () { };
195
+ proto._uploadRegionAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
196
+ // the vertices in format:
197
+ // [
198
+ // X1, Y1, C1R, C1G, C1B, C1A, U1, V1, // bottom left
199
+ // X2, Y2, C2R, C2G, C2B, C2A, U2, V2, // top left
200
+ // X3, Y3, C3R, C3G, C3B, C3A, U3, V3, // top right
201
+ // X4, Y4, C4R, C4G, C4B, C4A, U4, V4 // bottom right
202
+ // ]
203
+ //
204
+ const nodeColor = this._displayedColor;
205
+ const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
206
+ const vertices = spine.Utils.setArraySize([], 8, 0);
207
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
208
+ const uvs = attachment.uvs;
209
+ // get the colors data
210
+ const skeleton = slot.bone.skeleton;
211
+ const skeletonColor = skeleton.color;
212
+ const slotColor = slot.color;
213
+ const regionColor = attachment.color;
214
+ const alpha = skeletonColor.a * slotColor.a * regionColor.a;
215
+ const multiplier = premultipliedAlpha ? alpha : 1;
216
+ const colors = attachment.tempColor;
217
+ colors.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
218
+ const wt = this._worldTransform, wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d, wx = wt.tx, wy = wt.ty, z = this._node.vertexZ;
219
+ let offset = vertexDataOffset;
220
+ // generate 6 vertices data (two triangles) from the quad vertices
221
+ // using two angles : (0, 1, 2) & (0, 2, 3)
222
+ for (let i = 0; i < 6; i++) {
223
+ const srcIdx = i < 4 ? i % 3 : i - 2;
224
+ const vx = vertices[srcIdx * 2], vy = vertices[srcIdx * 2 + 1];
225
+ const x = vx * wa + vy * wc + wx, y = vx * wb + vy * wd + wy;
226
+ const r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
227
+ const color = (a << 24) | (b << 16) | (g << 8) | r;
228
+ f32buffer[offset] = x;
229
+ f32buffer[offset + 1] = y;
230
+ f32buffer[offset + 2] = z;
231
+ ui32buffer[offset + 3] = color;
232
+ f32buffer[offset + 4] = uvs[srcIdx * 2];
233
+ f32buffer[offset + 5] = uvs[srcIdx * 2 + 1];
234
+ offset += 6;
235
+ }
236
+ if (this._node._debugSlots) {
237
+ // return the quad points info if debug slot enabled
238
+ const VERTEX = spine.RegionAttachment;
239
+ return [
240
+ cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
241
+ cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
242
+ cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]),
243
+ cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]),
244
+ ];
245
+ }
246
+ };
247
+ proto._uploadMeshAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
248
+ const wt = this._worldTransform, wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d, wx = wt.tx, wy = wt.ty, z = this._node.vertexZ;
249
+ // get the vertex data
250
+ const verticesLength = attachment.worldVerticesLength;
251
+ const vertices = spine.Utils.setArraySize([], verticesLength, 0);
252
+ attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
253
+ const uvs = attachment.uvs;
254
+ // get the colors data
255
+ const skeleton = slot.bone.skeleton;
256
+ const skeletonColor = skeleton.color, slotColor = slot.color, meshColor = attachment.color;
257
+ const alpha = skeletonColor.a * slotColor.a * meshColor.a;
258
+ const multiplier = premultipliedAlpha ? alpha : 1;
259
+ const colors = attachment.tempColor;
260
+ colors.set(skeletonColor.r * slotColor.r * meshColor.r * multiplier, skeletonColor.g * slotColor.g * meshColor.g * multiplier, skeletonColor.b * slotColor.b * meshColor.b * multiplier, alpha);
261
+ let offset = vertexDataOffset;
262
+ const nodeColor = this._displayedColor;
263
+ const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
264
+ for (let i = 0, n = vertices.length; i < n; i += 2) {
265
+ const vx = vertices[i], vy = vertices[i + 1];
266
+ const x = vx * wa + vy * wb + wx, y = vx * wc + vy * wd + wy;
267
+ const r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
268
+ const color = (a << 24) | (b << 16) | (g << 8) | r;
269
+ f32buffer[offset] = x;
270
+ f32buffer[offset + 1] = y;
271
+ f32buffer[offset + 2] = z;
272
+ ui32buffer[offset + 3] = color;
273
+ f32buffer[offset + 4] = uvs[i];
274
+ f32buffer[offset + 5] = uvs[i + 1];
275
+ offset += 6;
276
+ }
277
+ };
@@ -0,0 +1,19 @@
1
+ import { Spine } from '@esotericsoftware/spine-pixi-v8';
2
+ import { Application } from 'pixi.js';
3
+ export declare function loadSpineAssets({ skeleton, atlas, texture }: {
4
+ skeleton: any;
5
+ atlas: any;
6
+ texture: any;
7
+ }): Promise<any>;
8
+ export declare class PixiSpineSprite extends cc.Sprite {
9
+ _canvas: any;
10
+ _pixiApp: Application;
11
+ _texture: cc.Texture2D;
12
+ _config: any;
13
+ _armatureDisplay: Spine;
14
+ constructor(config: any);
15
+ _setupSpine(): void;
16
+ updateTexture(): void;
17
+ onExit(): void;
18
+ }
19
+ //# sourceMappingURL=PixiSpineSprite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PixiSpineSprite.d.ts","sourceRoot":"","sources":["../../src/spine/PixiSpineSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AACvD,OAAO,EAAE,WAAW,EAAU,MAAM,SAAS,CAAA;AAE7C,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;;;;CAAA,gBAE3D;AAED,qBAAa,eAAgB,SAAQ,EAAE,CAAC,MAAM;IAC5C,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAA;IACtB,OAAO,MAAA;IACP,gBAAgB,EAAE,KAAK,CAAA;gBACX,MAAM,KAAA;IA4BlB,WAAW;IAsBX,aAAa;IAUb,MAAM;CAMP"}