@safe-engine/cocos 2.6.3 → 2.6.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 (89) hide show
  1. package/dist/dragonbones/DragonBonesSystem.js +3 -3
  2. package/dist/dragonbones/PixiDragonBonesSprite.d.ts +19 -0
  3. package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -0
  4. package/dist/dragonbones/PixiDragonBonesSprite.js +75 -0
  5. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -1
  6. package/dist/dragonbones/db-cocos/CocosFactory.js +2 -1
  7. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +1 -1
  8. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -1
  9. package/dist/dragonbones/db-cocos/SimpleMeshNode.js +1 -1
  10. package/dist/gui/GUISystem.js +1 -1
  11. package/dist/gworld/components/AnimationComponent.d.ts +65 -0
  12. package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
  13. package/dist/gworld/components/AnimationComponent.js +141 -0
  14. package/dist/gworld/components/CollideComponent.d.ts +64 -0
  15. package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
  16. package/dist/gworld/components/CollideComponent.js +269 -0
  17. package/dist/gworld/components/EnhancedComponent.d.ts +22 -0
  18. package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
  19. package/dist/gworld/components/EnhancedComponent.js +51 -0
  20. package/dist/gworld/components/GUIComponent.d.ts +67 -0
  21. package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
  22. package/dist/gworld/components/GUIComponent.js +166 -0
  23. package/dist/gworld/components/NoRenderComponent.d.ts +38 -0
  24. package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
  25. package/dist/gworld/components/NoRenderComponent.js +81 -0
  26. package/dist/gworld/components/NodeComp.d.ts +152 -0
  27. package/dist/gworld/components/NodeComp.d.ts.map +1 -0
  28. package/dist/gworld/components/NodeComp.js +405 -0
  29. package/dist/gworld/components/RenderComponent.d.ts +58 -0
  30. package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
  31. package/dist/gworld/components/RenderComponent.js +166 -0
  32. package/dist/gworld/core/NodePool.d.ts +9 -0
  33. package/dist/gworld/core/NodePool.d.ts.map +1 -0
  34. package/dist/gworld/core/NodePool.js +30 -0
  35. package/dist/gworld/core/Scene.d.ts +5 -0
  36. package/dist/gworld/core/Scene.d.ts.map +1 -0
  37. package/dist/gworld/core/Scene.js +38 -0
  38. package/dist/gworld/core/decorator.d.ts +9 -0
  39. package/dist/gworld/core/decorator.d.ts.map +1 -0
  40. package/dist/gworld/core/decorator.js +43 -0
  41. package/dist/gworld/index.d.ts +8 -0
  42. package/dist/gworld/index.d.ts.map +1 -0
  43. package/dist/gworld/index.js +43 -0
  44. package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
  45. package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
  46. package/dist/gworld/systems/AnimationSystem.js +30 -0
  47. package/dist/gworld/systems/CollideSystem.d.ts +20 -0
  48. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
  49. package/dist/gworld/systems/CollideSystem.js +171 -0
  50. package/dist/gworld/systems/GUISystem.d.ts +15 -0
  51. package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
  52. package/dist/gworld/systems/GUISystem.js +123 -0
  53. package/dist/gworld/systems/NoRenderSystem.d.ts +16 -0
  54. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
  55. package/dist/gworld/systems/NoRenderSystem.js +85 -0
  56. package/dist/gworld/systems/RenderSystem.d.ts +22 -0
  57. package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
  58. package/dist/gworld/systems/RenderSystem.js +104 -0
  59. package/dist/helper/NodePool.d.ts +9 -0
  60. package/dist/helper/NodePool.d.ts.map +1 -0
  61. package/dist/helper/NodePool.js +29 -0
  62. package/dist/helper/html-text-parser.d.ts +30 -0
  63. package/dist/helper/html-text-parser.d.ts.map +1 -0
  64. package/dist/helper/html-text-parser.js +354 -0
  65. package/dist/helper/index.d.ts +1 -0
  66. package/dist/helper/index.d.ts.map +1 -1
  67. package/dist/helper/index.js +1 -0
  68. package/dist/safex.d.ts +10 -0
  69. package/dist/safex.d.ts.map +1 -0
  70. package/dist/safex.js +25 -0
  71. package/dist/spine/CCSkeleton.d.ts +2 -0
  72. package/dist/spine/CCSkeleton.d.ts.map +1 -0
  73. package/dist/spine/CCSkeleton.js +344 -0
  74. package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
  75. package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
  76. package/dist/spine/CCSkeletonAnimation.js +317 -0
  77. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
  78. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  79. package/dist/spine/CCSkeletonCanvasRenderCmd.js +225 -0
  80. package/dist/spine/CCSkeletonTexture.d.ts +2 -0
  81. package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
  82. package/dist/spine/CCSkeletonTexture.js +62 -0
  83. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
  84. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  85. package/dist/spine/CCSkeletonWebGLRenderCmd.js +281 -0
  86. package/dist/spine/PixiSpineSprite.d.ts +19 -0
  87. package/dist/spine/PixiSpineSprite.d.ts.map +1 -0
  88. package/dist/spine/PixiSpineSprite.js +72 -0
  89. package/package.json +1 -1
@@ -0,0 +1,225 @@
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
+ let node = this._node, i, n, slot, slotNode;
35
+ wrapper = wrapper || cc._renderContext;
36
+ const locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
37
+ for (i = 0, n = drawOrder.length; i < n; i++) {
38
+ slot = drawOrder[i];
39
+ slotNode = slot._slotNode;
40
+ if (slotNode._visible && slotNode._renderCmd && slot.currentSprite) {
41
+ slotNode._renderCmd.transform(this, true);
42
+ slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY);
43
+ slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0;
44
+ }
45
+ }
46
+ if (!node._debugSlots && !node._debugBones)
47
+ return;
48
+ wrapper.setTransform(this._worldTransform, scaleX, scaleY);
49
+ wrapper.setGlobalAlpha(1);
50
+ let attachment, drawingUtil = cc._drawingUtil;
51
+ if (node._debugSlots) {
52
+ // Slots.
53
+ drawingUtil.setDrawColor(0, 0, 255, 255);
54
+ drawingUtil.setLineWidth(1);
55
+ const points = [];
56
+ for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
57
+ slot = locSkeleton.drawOrder[i];
58
+ if (!slot.attachment || !(slot.attachment instanceof spine.RegionAttachment))
59
+ continue;
60
+ attachment = slot.attachment;
61
+ this._updateRegionAttachmentSlot(attachment, slot, points);
62
+ drawingUtil.drawPoly(points, 4, true);
63
+ }
64
+ }
65
+ if (node._debugBones) {
66
+ // Bone lengths.
67
+ let bone;
68
+ drawingUtil.setLineWidth(2);
69
+ drawingUtil.setDrawColor(255, 0, 0, 255);
70
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
71
+ bone = locSkeleton.bones[i];
72
+ const x = bone.data.length * bone.a + bone.worldX;
73
+ const y = bone.data.length * bone.c + bone.worldY;
74
+ drawingUtil.drawLine({ x: bone.worldX, y: bone.worldY }, { x: x, y: y });
75
+ }
76
+ // Bone origins.
77
+ const pointSize = 4;
78
+ drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
79
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
80
+ bone = locSkeleton.bones[i];
81
+ drawingUtil.drawPoint({ x: bone.worldX, y: bone.worldY }, pointSize);
82
+ if (i === 0)
83
+ drawingUtil.setDrawColor(0, 255, 0, 255);
84
+ }
85
+ }
86
+ };
87
+ proto.updateStatus = function () {
88
+ this.originUpdateStatus();
89
+ this._updateCurrentRegions();
90
+ this._regionFlag = cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
91
+ this._dirtyFlag &= ~cc.Node._dirtyFlags.contentDirty;
92
+ };
93
+ proto.getLocalBB = function () {
94
+ return this._node.getBoundingBox();
95
+ };
96
+ proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
97
+ if (!points)
98
+ return;
99
+ const vertices = spine.Utils.setArraySize([], 8, 0);
100
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
101
+ const VERTEX = spine.RegionAttachment;
102
+ points.length = 0;
103
+ points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
104
+ points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
105
+ points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]));
106
+ points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
107
+ };
108
+ proto._createChildFormSkeletonData = function () {
109
+ const node = this._node;
110
+ let locSkeleton = node._skeleton, spriteName, sprite;
111
+ for (let i = 0, n = locSkeleton.slots.length; i < n; i++) {
112
+ const slot = locSkeleton.slots[i], attachment = slot.attachment;
113
+ const slotNode = new cc.Node();
114
+ slot._slotNode = slotNode;
115
+ if (attachment instanceof spine.RegionAttachment) {
116
+ spriteName = attachment.name;
117
+ sprite = this._createSprite(slot, attachment);
118
+ slot.currentSprite = sprite;
119
+ slot.currentSpriteName = spriteName;
120
+ slotNode.addChild(sprite);
121
+ }
122
+ else if (attachment instanceof spine.MeshAttachment) {
123
+ //todo for mesh
124
+ }
125
+ }
126
+ };
127
+ const loaded = function (sprite, texture, attachment) {
128
+ const rendererObject = attachment.region;
129
+ const rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
130
+ sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
131
+ sprite._rect.width = attachment.width;
132
+ sprite._rect.height = attachment.height;
133
+ sprite.setContentSize(attachment.width, attachment.height);
134
+ sprite.setRotation(-attachment.rotation);
135
+ sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
136
+ };
137
+ proto._createSprite = function (slot, attachment) {
138
+ const rendererObject = attachment.region;
139
+ const texture = rendererObject.texture.getRealTexture();
140
+ const sprite = new cc.Sprite();
141
+ if (texture.isLoaded()) {
142
+ loaded(sprite, texture, attachment);
143
+ }
144
+ else {
145
+ texture.addEventListener('load', function () {
146
+ loaded(sprite, texture, attachment);
147
+ }, this);
148
+ }
149
+ slot.sprites = slot.sprites || {};
150
+ slot.sprites[rendererObject.name] = sprite;
151
+ return sprite;
152
+ };
153
+ proto._updateChild = function () {
154
+ const locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
155
+ const color = this._displayedColor, opacity = this._displayedOpacity;
156
+ let i, n, selSprite, ax, ay;
157
+ let slot, attachment, slotNode;
158
+ for (i = 0, n = slots.length; i < n; i++) {
159
+ slot = slots[i];
160
+ attachment = slot.attachment;
161
+ slotNode = slot._slotNode;
162
+ if (!attachment) {
163
+ slotNode.setVisible(false);
164
+ continue;
165
+ }
166
+ if (attachment instanceof spine.RegionAttachment) {
167
+ if (attachment.region) {
168
+ if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
169
+ const spriteName = attachment.name;
170
+ if (slot.currentSprite !== undefined)
171
+ slot.currentSprite.setVisible(false);
172
+ slot.sprites = slot.sprites || {};
173
+ if (slot.sprites[spriteName] !== undefined)
174
+ slot.sprites[spriteName].setVisible(true);
175
+ else {
176
+ const sprite = this._createSprite(slot, attachment);
177
+ slotNode.addChild(sprite);
178
+ }
179
+ slot.currentSprite = slot.sprites[spriteName];
180
+ slot.currentSpriteName = spriteName;
181
+ }
182
+ }
183
+ const bone = slot.bone;
184
+ if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
185
+ ax = attachment.x;
186
+ ay = attachment.y;
187
+ }
188
+ else {
189
+ //var regionScaleX = attachment.width / attachment.regionOriginalWidth * attachment.scaleX;
190
+ //ax = attachment.x + attachment.regionOffsetX * regionScaleX - (attachment.width * attachment.scaleX - attachment.regionWidth * regionScaleX) / 2;
191
+ ax = (attachment.offset[0] + attachment.offset[4]) * 0.5;
192
+ ay = (attachment.offset[1] + attachment.offset[5]) * 0.5;
193
+ }
194
+ slotNode.setPosition(bone.worldX + ax * bone.a + ay * bone.b, bone.worldY + ax * bone.c + ay * bone.d);
195
+ slotNode.setScale(bone.getWorldScaleX(), bone.getWorldScaleY());
196
+ //set the color and opacity
197
+ selSprite = slot.currentSprite;
198
+ selSprite._flippedX = bone.skeleton.flipX;
199
+ selSprite._flippedY = bone.skeleton.flipY;
200
+ if (selSprite._flippedY || selSprite._flippedX) {
201
+ slotNode.setRotation(bone.getWorldRotationX());
202
+ selSprite.setRotation(attachment.rotation);
203
+ }
204
+ else {
205
+ slotNode.setRotation(-bone.getWorldRotationX());
206
+ selSprite.setRotation(-attachment.rotation);
207
+ }
208
+ //hack for sprite
209
+ selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
210
+ const r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
211
+ selSprite.setColor(cc.color(r, g, b));
212
+ selSprite._renderCmd._updateColor();
213
+ }
214
+ else if (attachment instanceof spine.MeshAttachment) {
215
+ // Can not render mesh
216
+ }
217
+ else {
218
+ slotNode.setVisible(false);
219
+ continue;
220
+ }
221
+ slotNode.setVisible(true);
222
+ }
223
+ };
224
+ })();
225
+ export const CanvasRenderCmd = gworld.CanvasRenderCmd;
@@ -0,0 +1,2 @@
1
+ export declare const SkeletonTexture: any;
2
+ //# sourceMappingURL=CCSkeletonTexture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonTexture.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,eAAe,KAAyB,CAAA"}
@@ -0,0 +1,62 @@
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
+ var gworld = gworld || {};
26
+ gworld.SkeletonTexture = function (image) {
27
+ // spine.Texture.call(this, image);
28
+ };
29
+ cc.inherits(gworld.SkeletonTexture, spine.Texture);
30
+ cc.extend(gworld.SkeletonTexture.prototype, {
31
+ name: 'gworld.SkeletonTexture',
32
+ _texture: null,
33
+ setRealTexture: function (tex) {
34
+ this._texture = tex;
35
+ },
36
+ getRealTexture: function () {
37
+ return this._texture;
38
+ },
39
+ setFilters: function (minFilter, magFilter) {
40
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
41
+ const gl = cc._renderContext;
42
+ this.bind();
43
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
44
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
45
+ }
46
+ },
47
+ setWraps: function (uWrap, vWrap) {
48
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
49
+ const gl = cc._renderContext;
50
+ this.bind();
51
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
52
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
53
+ }
54
+ },
55
+ dispose: function () { },
56
+ bind: function () {
57
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
58
+ cc.glBindTexture2D(this._texture);
59
+ }
60
+ },
61
+ });
62
+ export const SkeletonTexture = gworld.SkeletonTexture;
@@ -0,0 +1,2 @@
1
+ export declare const WebGLRenderCmd: any;
2
+ //# sourceMappingURL=CCSkeletonWebGLRenderCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonWebGLRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonWebGLRenderCmd.ts"],"names":[],"mappings":"AAyWA,eAAO,MAAM,cAAc,KAAwB,CAAA"}
@@ -0,0 +1,281 @@
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.WebGLRenderCmd = function (renderableObject) {
28
+ this._rootCtor(renderableObject);
29
+ this._needDraw = true;
30
+ this._matrix = new cc.math.Matrix4();
31
+ this._matrix.identity();
32
+ this._currTexture = null;
33
+ this._currBlendFunc = {};
34
+ this.vertexType = cc.renderer.VertexType.CUSTOM;
35
+ this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR));
36
+ };
37
+ const proto = (gworld.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype));
38
+ proto.constructor = gworld.WebGLRenderCmd;
39
+ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
40
+ const node = this._node;
41
+ const color = this._displayedColor, locSkeleton = node._skeleton;
42
+ let attachment, slot, i, n;
43
+ const premultiAlpha = node._premultipliedAlpha;
44
+ locSkeleton.r = color.r / 255;
45
+ locSkeleton.g = color.g / 255;
46
+ locSkeleton.b = color.b / 255;
47
+ locSkeleton.a = this._displayedOpacity / 255;
48
+ if (premultiAlpha) {
49
+ locSkeleton.r *= locSkeleton.a;
50
+ locSkeleton.g *= locSkeleton.a;
51
+ locSkeleton.b *= locSkeleton.a;
52
+ }
53
+ let debugSlotsInfo = null;
54
+ if (this._node._debugSlots) {
55
+ debugSlotsInfo = [];
56
+ }
57
+ for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) {
58
+ slot = locSkeleton.drawOrder[i];
59
+ if (!slot.attachment)
60
+ continue;
61
+ attachment = slot.attachment;
62
+ // get the vertices length
63
+ let vertCount = 0;
64
+ if (attachment instanceof spine.RegionAttachment) {
65
+ vertCount = 6; // a quad = two triangles = six vertices
66
+ }
67
+ else if (attachment instanceof spine.MeshAttachment) {
68
+ vertCount = attachment.regionUVs.length / 2;
69
+ }
70
+ else {
71
+ continue;
72
+ }
73
+ // no vertices to render
74
+ if (vertCount === 0) {
75
+ continue;
76
+ }
77
+ const regionTextureAtlas = node.getTextureAtlas(attachment);
78
+ // Broken for changing batch info
79
+ var batchBroken;
80
+ if (regionTextureAtlas.texture) {
81
+ this._currTexture = regionTextureAtlas.texture.getRealTexture();
82
+ batchBroken = cc.renderer._updateBatchedInfo(this._currTexture, this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._glProgramState);
83
+ }
84
+ // keep the same logic with RendererWebGL.js, avoid vertex data overflow
85
+ const uploadAll = vertexDataOffset / 6 + vertCount > (cc.BATCH_VERTEX_COUNT - 200) * 0.5;
86
+ // Broken for vertex data overflow
87
+ if (!batchBroken && uploadAll) {
88
+ // render the cached data
89
+ cc.renderer._batchRendering();
90
+ batchBroken = true;
91
+ }
92
+ if (batchBroken) {
93
+ vertexDataOffset = 0;
94
+ }
95
+ // update the vertex buffer
96
+ let slotDebugPoints = null;
97
+ if (attachment instanceof spine.RegionAttachment) {
98
+ slotDebugPoints = this._uploadRegionAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
99
+ }
100
+ else if (attachment instanceof spine.MeshAttachment) {
101
+ this._uploadMeshAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
102
+ }
103
+ else {
104
+ continue;
105
+ }
106
+ if (this._node._debugSlots) {
107
+ debugSlotsInfo[i] = slotDebugPoints;
108
+ }
109
+ // update the index buffer
110
+ if (attachment instanceof spine.RegionAttachment) {
111
+ cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.TRIANGLE);
112
+ }
113
+ else {
114
+ cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.CUSTOM, attachment.triangles);
115
+ }
116
+ // update the index data
117
+ vertexDataOffset += vertCount * 6;
118
+ }
119
+ if (node._debugBones || node._debugSlots) {
120
+ // flush previous vertices
121
+ cc.renderer._batchRendering();
122
+ const wt = this._worldTransform, mat = this._matrix.mat;
123
+ mat[0] = wt.a;
124
+ mat[4] = wt.c;
125
+ mat[12] = wt.tx;
126
+ mat[1] = wt.b;
127
+ mat[5] = wt.d;
128
+ mat[13] = wt.ty;
129
+ cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
130
+ cc.current_stack.stack.push(cc.current_stack.top);
131
+ cc.current_stack.top = this._matrix;
132
+ const drawingUtil = cc._drawingUtil;
133
+ if (node._debugSlots && debugSlotsInfo && debugSlotsInfo.length > 0) {
134
+ // Slots.
135
+ drawingUtil.setDrawColor(0, 0, 255, 255);
136
+ drawingUtil.setLineWidth(1);
137
+ for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
138
+ const points = debugSlotsInfo[i];
139
+ if (points) {
140
+ drawingUtil.drawPoly(points, 4, true);
141
+ }
142
+ }
143
+ }
144
+ if (node._debugBones) {
145
+ // Bone lengths.
146
+ let bone;
147
+ drawingUtil.setLineWidth(2);
148
+ drawingUtil.setDrawColor(255, 0, 0, 255);
149
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
150
+ bone = locSkeleton.bones[i];
151
+ const x = bone.data.length * bone.a + bone.worldX;
152
+ const y = bone.data.length * bone.c + bone.worldY;
153
+ drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y));
154
+ }
155
+ // Bone origins.
156
+ drawingUtil.setPointSize(4);
157
+ drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
158
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
159
+ bone = locSkeleton.bones[i];
160
+ drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY));
161
+ if (i == 0) {
162
+ drawingUtil.setDrawColor(0, 255, 0, 255);
163
+ }
164
+ }
165
+ }
166
+ cc.kmGLPopMatrix();
167
+ }
168
+ return 0;
169
+ };
170
+ proto._getBlendFunc = function (blendMode, premultiAlpha) {
171
+ let ret = this._currBlendFunc;
172
+ switch (blendMode) {
173
+ case spine.BlendMode.Normal:
174
+ ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
175
+ ret.dst = cc.ONE_MINUS_SRC_ALPHA;
176
+ break;
177
+ case spine.BlendMode.Additive:
178
+ ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
179
+ ret.dst = cc.ONE;
180
+ break;
181
+ case spine.BlendMode.Multiply:
182
+ ret.src = cc.DST_COLOR;
183
+ ret.dst = cc.ONE_MINUS_SRC_ALPHA;
184
+ break;
185
+ case spine.BlendMode.Screen:
186
+ ret.src = cc.ONE;
187
+ ret.dst = cc.ONE_MINUS_SRC_COLOR;
188
+ break;
189
+ default:
190
+ ret = this._node._blendFunc;
191
+ break;
192
+ }
193
+ return ret;
194
+ };
195
+ proto._createChildFormSkeletonData = function () { };
196
+ proto._updateChild = function () { };
197
+ proto._uploadRegionAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
198
+ // the vertices in format:
199
+ // [
200
+ // X1, Y1, C1R, C1G, C1B, C1A, U1, V1, // bottom left
201
+ // X2, Y2, C2R, C2G, C2B, C2A, U2, V2, // top left
202
+ // X3, Y3, C3R, C3G, C3B, C3A, U3, V3, // top right
203
+ // X4, Y4, C4R, C4G, C4B, C4A, U4, V4 // bottom right
204
+ // ]
205
+ //
206
+ const nodeColor = this._displayedColor;
207
+ const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
208
+ const vertices = spine.Utils.setArraySize([], 8, 0);
209
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
210
+ const uvs = attachment.uvs;
211
+ // get the colors data
212
+ const skeleton = slot.bone.skeleton;
213
+ const skeletonColor = skeleton.color;
214
+ const slotColor = slot.color;
215
+ const regionColor = attachment.color;
216
+ const alpha = skeletonColor.a * slotColor.a * regionColor.a;
217
+ const multiplier = premultipliedAlpha ? alpha : 1;
218
+ const colors = attachment.tempColor;
219
+ colors.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
220
+ 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;
221
+ let offset = vertexDataOffset;
222
+ // generate 6 vertices data (two triangles) from the quad vertices
223
+ // using two angles : (0, 1, 2) & (0, 2, 3)
224
+ for (let i = 0; i < 6; i++) {
225
+ const srcIdx = i < 4 ? i % 3 : i - 2;
226
+ const vx = vertices[srcIdx * 2], vy = vertices[srcIdx * 2 + 1];
227
+ const x = vx * wa + vy * wc + wx, y = vx * wb + vy * wd + wy;
228
+ const r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
229
+ const color = (a << 24) | (b << 16) | (g << 8) | r;
230
+ f32buffer[offset] = x;
231
+ f32buffer[offset + 1] = y;
232
+ f32buffer[offset + 2] = z;
233
+ ui32buffer[offset + 3] = color;
234
+ f32buffer[offset + 4] = uvs[srcIdx * 2];
235
+ f32buffer[offset + 5] = uvs[srcIdx * 2 + 1];
236
+ offset += 6;
237
+ }
238
+ if (this._node._debugSlots) {
239
+ // return the quad points info if debug slot enabled
240
+ const VERTEX = spine.RegionAttachment;
241
+ return [
242
+ cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
243
+ cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
244
+ cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]),
245
+ cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]),
246
+ ];
247
+ }
248
+ };
249
+ proto._uploadMeshAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
250
+ 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;
251
+ // get the vertex data
252
+ const verticesLength = attachment.worldVerticesLength;
253
+ const vertices = spine.Utils.setArraySize([], verticesLength, 0);
254
+ attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
255
+ const uvs = attachment.uvs;
256
+ // get the colors data
257
+ const skeleton = slot.bone.skeleton;
258
+ const skeletonColor = skeleton.color, slotColor = slot.color, meshColor = attachment.color;
259
+ const alpha = skeletonColor.a * slotColor.a * meshColor.a;
260
+ const multiplier = premultipliedAlpha ? alpha : 1;
261
+ const colors = attachment.tempColor;
262
+ colors.set(skeletonColor.r * slotColor.r * meshColor.r * multiplier, skeletonColor.g * slotColor.g * meshColor.g * multiplier, skeletonColor.b * slotColor.b * meshColor.b * multiplier, alpha);
263
+ let offset = vertexDataOffset;
264
+ const nodeColor = this._displayedColor;
265
+ const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
266
+ for (let i = 0, n = vertices.length; i < n; i += 2) {
267
+ const vx = vertices[i], vy = vertices[i + 1];
268
+ const x = vx * wa + vy * wb + wx, y = vx * wc + vy * wd + wy;
269
+ const r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
270
+ const color = (a << 24) | (b << 16) | (g << 8) | r;
271
+ f32buffer[offset] = x;
272
+ f32buffer[offset + 1] = y;
273
+ f32buffer[offset + 2] = z;
274
+ ui32buffer[offset + 3] = color;
275
+ f32buffer[offset + 4] = uvs[i];
276
+ f32buffer[offset + 5] = uvs[i + 1];
277
+ offset += 6;
278
+ }
279
+ };
280
+ })();
281
+ export const WebGLRenderCmd = gworld.WebGLRenderCmd;
@@ -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"}