@safe-engine/cocos 1.9.5 → 1.10.1
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.
- package/dist/app.d.ts +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -7
- package/dist/core/NodeComp.d.ts +4 -11
- package/dist/core/NodeComp.d.ts.map +1 -1
- package/dist/core/NodeComp.js +18 -15
- package/dist/gui/GUIComponent.d.ts +6 -31
- package/dist/gui/GUIComponent.d.ts.map +1 -1
- package/dist/gui/GUIComponent.js +3 -22
- package/dist/gui/GUISystem.d.ts +0 -2
- package/dist/gui/GUISystem.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +9 -17
- package/dist/helper/action.d.ts +2 -0
- package/dist/helper/action.d.ts.map +1 -1
- package/dist/helper/action.js +6 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/polyfills.d.ts +0 -1
- package/dist/polyfills.d.ts.map +1 -1
- package/dist/polyfills.js +0 -3
- package/dist/spine/CCSkeleton.d.ts +188 -1
- package/dist/spine/CCSkeleton.d.ts.map +1 -1
- package/dist/spine/CCSkeleton.js +103 -127
- package/dist/spine/CCSkeletonAnimation.d.ts +136 -6
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -1
- package/dist/spine/CCSkeletonAnimation.js +95 -101
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +6 -3
- package/dist/spine/CCSkeletonTexture.d.ts +24 -1
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -1
- package/dist/spine/CCSkeletonTexture.js +4 -6
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +27 -1
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -1
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +243 -247
- package/dist/spine/index.d.ts +4 -8
- package/dist/spine/index.d.ts.map +1 -1
- package/dist/spine/index.js +5 -11
- package/package.json +3 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -5
- package/dist/gworld/EnhancedComponent.d.ts +0 -22
- package/dist/gworld/EnhancedComponent.d.ts.map +0 -1
- package/dist/gworld/EnhancedComponent.js +0 -44
- package/dist/gworld/NodeComp.d.ts +0 -153
- package/dist/gworld/NodeComp.d.ts.map +0 -1
- package/dist/gworld/NodeComp.js +0 -337
- package/dist/gworld/NodePool.d.ts +0 -9
- package/dist/gworld/NodePool.d.ts.map +0 -1
- package/dist/gworld/NodePool.js +0 -23
- package/dist/gworld/Scene.d.ts +0 -5
- package/dist/gworld/Scene.d.ts.map +0 -1
- package/dist/gworld/Scene.js +0 -14
- package/dist/gworld/decorator.d.ts +0 -8
- package/dist/gworld/decorator.d.ts.map +0 -1
- package/dist/gworld/decorator.js +0 -12
- package/dist/gworld/index.d.ts +0 -8
- package/dist/gworld/index.d.ts.map +0 -1
- package/dist/gworld/index.js +0 -14
|
@@ -22,260 +22,256 @@ import * as spine from '@esotericsoftware/spine-core';
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
****************************************************************************/
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
locSkeleton.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
52
64
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
debugSlotsInfo = [];
|
|
65
|
+
else if (attachment instanceof spine.MeshAttachment) {
|
|
66
|
+
vertCount = attachment.regionUVs.length / 2;
|
|
56
67
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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;
|
|
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);
|
|
118
81
|
}
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
121
87
|
cc.renderer._batchRendering();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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();
|
|
88
|
+
batchBroken = true;
|
|
89
|
+
}
|
|
90
|
+
if (batchBroken) {
|
|
91
|
+
vertexDataOffset = 0;
|
|
167
92
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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;
|
|
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);
|
|
192
97
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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;
|
|
98
|
+
else if (attachment instanceof spine.MeshAttachment) {
|
|
99
|
+
this._uploadMeshAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
continue;
|
|
237
103
|
}
|
|
238
104
|
if (this._node._debugSlots) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]),
|
|
245
|
-
cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]),
|
|
246
|
-
];
|
|
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);
|
|
247
110
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
+
}
|
|
278
163
|
}
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
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
|
+
};
|
package/dist/spine/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
2
|
import { BaseComponentProps, ComponentX } from '..';
|
|
3
|
-
|
|
3
|
+
import { SkeletonAnimation } from './CCSkeletonAnimation';
|
|
4
|
+
export interface SpineData {
|
|
4
5
|
atlas: string;
|
|
5
6
|
skeleton: string;
|
|
6
7
|
texture?: string;
|
|
@@ -12,14 +13,9 @@ interface SpineSkeletonProps {
|
|
|
12
13
|
timeScale?: number;
|
|
13
14
|
loop?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare class SpineSkeleton extends ComponentX<SpineSkeletonProps & BaseComponentProps<SpineSkeleton
|
|
16
|
-
data: SpineData;
|
|
17
|
-
skin: string;
|
|
18
|
-
animation: string;
|
|
19
|
-
loop: boolean;
|
|
20
|
-
timeScale: number;
|
|
16
|
+
export declare class SpineSkeleton extends ComponentX<SpineSkeletonProps & BaseComponentProps<SpineSkeleton>, SkeletonAnimation> {
|
|
21
17
|
setAnimation(name: string, loop?: boolean): void;
|
|
22
|
-
setSkeletonData(data:
|
|
18
|
+
setSkeletonData(data: SpineData): void;
|
|
23
19
|
}
|
|
24
20
|
export declare class SpineSystem implements System {
|
|
25
21
|
configure(event_manager: EventManager): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAuB,MAAM,IAAI,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AACD,qBAAa,aAAc,SAAQ,UAAU,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACtH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,UAAQ;IAOvC,eAAe,CAAC,IAAI,EAAE,SAAS;CAKhC;AAED,qBAAa,WAAY,YAAW,MAAM;IACxC,SAAS,CAAC,aAAa,EAAE,YAAY;IAGrC,OAAO,CAAC,kBAAkB,CAYzB;IACD,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE;AAED,wBAAgB,UAAU,SAIzB"}
|
package/dist/spine/index.js
CHANGED
|
@@ -2,11 +2,6 @@ import { EventTypes } from 'entityx-ts';
|
|
|
2
2
|
import { ComponentX, GameWorld, NodeComp } from '..';
|
|
3
3
|
import { SkeletonAnimation } from './CCSkeletonAnimation';
|
|
4
4
|
export class SpineSkeleton extends ComponentX {
|
|
5
|
-
data;
|
|
6
|
-
skin;
|
|
7
|
-
animation;
|
|
8
|
-
loop;
|
|
9
|
-
timeScale;
|
|
10
5
|
setAnimation(name, loop = false) {
|
|
11
6
|
const skel = this.node.instance;
|
|
12
7
|
if (skel.setAnimation) {
|
|
@@ -15,19 +10,18 @@ export class SpineSkeleton extends ComponentX {
|
|
|
15
10
|
}
|
|
16
11
|
setSkeletonData(data) {
|
|
17
12
|
const skel = this.node.instance;
|
|
18
|
-
const atlas = data
|
|
19
|
-
skel.initWithArgs(
|
|
13
|
+
const { atlas, skeleton } = data;
|
|
14
|
+
skel.initWithArgs(skeleton, atlas);
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
17
|
export class SpineSystem {
|
|
23
18
|
configure(event_manager) {
|
|
24
19
|
event_manager.subscribe(EventTypes.ComponentAdded, SpineSkeleton, this.onAddSpineSkeleton);
|
|
25
20
|
}
|
|
26
|
-
onAddSpineSkeleton = ({ entity }) => {
|
|
27
|
-
const
|
|
28
|
-
const { data, skin, animation, loop, timeScale = 1 } = spineComp.props;
|
|
21
|
+
onAddSpineSkeleton = ({ entity, component: spineComp }) => {
|
|
22
|
+
const { data, skin, animation, loop = true, timeScale = 1 } = spineComp.props;
|
|
29
23
|
const { atlas, skeleton } = data;
|
|
30
|
-
//
|
|
24
|
+
// console.log('spineComp', spineComp)
|
|
31
25
|
const node = SkeletonAnimation.createWithJsonFile(skeleton, atlas, timeScale);
|
|
32
26
|
if (skin) {
|
|
33
27
|
node.setSkin(skin);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/cocos",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "safe-engine with cocos renderer support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@esotericsoftware/spine-core": "^4.2.88",
|
|
26
26
|
"box2d-wasm": "^7.0.0",
|
|
27
|
+
"pixi.js": "5.3.12",
|
|
28
|
+
"pixi5-dragonbones": "5.7.0-2b",
|
|
27
29
|
"entityx-ts": "^2.2.1"
|
|
28
30
|
},
|
|
29
31
|
"author": "",
|
package/dist/core/index.d.ts
DELETED
package/dist/core/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
package/dist/core/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Constructor } from 'entityx-ts';
|
|
2
|
-
import { BaseComponentProps } from '../safex';
|
|
3
|
-
import { NodeComp } from './NodeComp';
|
|
4
|
-
export declare class EnhancedComponent<Props = object, N extends NodeComp<any> = NodeComp<any>> {
|
|
5
|
-
static hasRender: boolean;
|
|
6
|
-
props: Props;
|
|
7
|
-
node: N;
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
constructor(data?: BaseComponentProps<EnhancedComponent> & Props);
|
|
10
|
-
init(data?: Props): void;
|
|
11
|
-
addComponent<T extends EnhancedComponent>(instance: T): T;
|
|
12
|
-
getComponent<T extends EnhancedComponent>(component: Constructor<T>): T;
|
|
13
|
-
schedule(callback: (arg: any) => void, interval: number, repeat?: number, delay?: number): void;
|
|
14
|
-
unschedule(callback: (arg: any) => void): void;
|
|
15
|
-
unscheduleAllCallbacks(): void;
|
|
16
|
-
scheduleOnce(callback: (arg: any) => void, delay: number, key?: string): void;
|
|
17
|
-
getComponentsInChildren<T extends ComponentType>(component: Constructor<T>): T[];
|
|
18
|
-
getComponentInChildren<T extends ComponentType>(component: Constructor<T>): T;
|
|
19
|
-
isEqual(other: EnhancedComponent): boolean;
|
|
20
|
-
}
|
|
21
|
-
export type ComponentType = EnhancedComponent | NodeComp;
|
|
22
|
-
//# sourceMappingURL=EnhancedComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedComponent.d.ts","sourceRoot":"","sources":["../../src/gworld/EnhancedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qBAAa,iBAAiB,CAAC,KAAK,GAAG,MAAM,EAAE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC;IACpF,MAAM,CAAC,SAAS,UAAO;IACvB,KAAK,EAAE,KAAK,CAAY;IACxB,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,UAAO;gBACF,IAAI,CAAC,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,KAAK;IAGhE,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK;IASjB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAGzD,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;IAGvE,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,MAAgC,EAAE,KAAK,SAAI;IAG5G,UAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI;IAGvC,sBAAsB;IAGtB,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAGtE,uBAAuB,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;IAGhF,sBAAsB,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;IAG7E,OAAO,CAAC,KAAK,EAAE,iBAAiB;CAGjC;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,QAAQ,CAAA"}
|