@safe-engine/cocos 2.2.7 → 2.3.4
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/@types/index.d.ts +0 -61
- package/dist/app.d.ts +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +25 -23
- package/dist/box2d-wasm/PhysicsComponent.d.ts +1 -1
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/collider/CollideComponent.d.ts +21 -3
- package/dist/collider/CollideComponent.d.ts.map +1 -1
- package/dist/collider/CollideSystem.d.ts.map +1 -1
- package/dist/collider/CollideSystem.js +6 -5
- package/dist/core/EnhancedComponent.d.ts +1 -1
- package/dist/core/EnhancedComponent.d.ts.map +1 -1
- package/dist/core/NodeComp.d.ts +1 -1
- package/dist/core/NodeComp.d.ts.map +1 -1
- package/dist/dragonbones/DragonBonesComp.d.ts +27 -0
- package/dist/dragonbones/DragonBonesComp.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesComp.js +29 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts +9 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesSystem.js +69 -0
- package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts +87 -0
- package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/db-cocos/CocosArmatureDisplay.js +240 -0
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts +128 -0
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -0
- package/dist/dragonbones/db-cocos/CocosFactory.js +190 -0
- package/dist/dragonbones/db-cocos/CocosSlot.d.ts +49 -0
- package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -0
- package/dist/dragonbones/db-cocos/CocosSlot.js +368 -0
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +53 -0
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +121 -0
- package/dist/dragonbones/index.d.ts +1 -35
- package/dist/dragonbones/index.d.ts.map +1 -1
- package/dist/dragonbones/index.js +2 -83
- package/dist/gui/GUIComponent.d.ts +1 -1
- package/dist/gui/GUIComponent.d.ts.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/polyfills.d.ts +1 -1
- package/dist/polyfills.d.ts.map +1 -1
- package/dist/polyfills.js +1 -2
- package/dist/render/RenderComponent.d.ts +1 -1
- package/dist/render/RenderComponent.d.ts.map +1 -1
- package/dist/render/RenderComponent.js +1 -0
- package/dist/render/RenderSystem.d.ts.map +1 -1
- package/dist/render/RenderSystem.js +34 -2
- package/dist/richtext/RichTextComp.d.ts +1 -1
- package/dist/richtext/RichTextComp.d.ts.map +1 -1
- package/dist/richtext/RichTextComp.js +1 -1
- package/dist/spine/SpineSkeleton.d.ts +22 -0
- package/dist/spine/SpineSkeleton.d.ts.map +1 -0
- package/dist/spine/SpineSkeleton.js +18 -0
- package/dist/spine/SpineSystem.d.ts +6 -0
- package/dist/spine/SpineSystem.d.ts.map +1 -0
- package/dist/spine/SpineSystem.js +34 -0
- package/dist/spine/index.d.ts +1 -24
- package/dist/spine/index.d.ts.map +1 -1
- package/dist/spine/index.js +16 -42
- package/dist/spine/spine-cocos/CCSkeleton.d.ts +86 -0
- package/dist/spine/spine-cocos/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/{CCSkeleton.js → spine-cocos/CCSkeleton.js} +39 -128
- package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +87 -0
- package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/{CCSkeletonAnimation.js → spine-cocos/CCSkeletonAnimation.js} +37 -97
- package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts +28 -0
- package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.js +224 -0
- package/dist/spine/{CCSkeletonTexture.d.ts → spine-cocos/CCSkeletonTexture.d.ts} +1 -1
- package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/{CCSkeletonTexture.js → spine-cocos/CCSkeletonTexture.js} +5 -5
- package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/{CCSkeletonWebGLRenderCmd.js → spine-cocos/CCSkeletonWebGLRenderCmd.js} +13 -13
- package/package.json +5 -6
- 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/dragonbones/PixiDragonBonesSprite.d.ts +0 -15
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +0 -1
- package/dist/dragonbones/PixiDragonBonesSprite.js +0 -71
- 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
- package/dist/render/TiledSprite.d.ts +0 -13
- package/dist/render/TiledSprite.d.ts.map +0 -1
- package/dist/render/TiledSprite.js +0 -69
- package/dist/safex.d.ts +0 -10
- package/dist/safex.d.ts.map +0 -1
- package/dist/safex.js +0 -25
- package/dist/spine/CCSkeleton.d.ts +0 -189
- package/dist/spine/CCSkeleton.d.ts.map +0 -1
- package/dist/spine/CCSkeletonAnimation.d.ts +0 -146
- package/dist/spine/CCSkeletonAnimation.d.ts.map +0 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +0 -2
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +0 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +0 -228
- package/dist/spine/CCSkeletonTexture.d.ts.map +0 -1
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +0 -1
- package/dist/spine/PixiSpineSprite.d.ts +0 -15
- package/dist/spine/PixiSpineSprite.d.ts.map +0 -1
- package/dist/spine/PixiSpineSprite.js +0 -70
- /package/dist/spine/{CCSkeletonWebGLRenderCmd.d.ts → spine-cocos/CCSkeletonWebGLRenderCmd.d.ts} +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
import { MeshAttachment, RegionAttachment, Utils } from '@esotericsoftware/spine-core';
|
|
25
|
+
export const CanvasRenderCmd = function (renderableObject) {
|
|
26
|
+
this._rootCtor(renderableObject);
|
|
27
|
+
this._needDraw = true;
|
|
28
|
+
};
|
|
29
|
+
const proto = (CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
|
|
30
|
+
proto.constructor = CanvasRenderCmd;
|
|
31
|
+
proto.rendering = function (wrapper, scaleX, scaleY) {
|
|
32
|
+
const node = this._node;
|
|
33
|
+
let i, n, slot, slotNode;
|
|
34
|
+
wrapper = wrapper || cc._renderContext;
|
|
35
|
+
const locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
|
|
36
|
+
for (i = 0, n = drawOrder.length; i < n; i++) {
|
|
37
|
+
slot = drawOrder[i];
|
|
38
|
+
slotNode = slot._slotNode;
|
|
39
|
+
if (slotNode._visible && slotNode._renderCmd && slot.currentSprite) {
|
|
40
|
+
slotNode._renderCmd.transform(this, true);
|
|
41
|
+
slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY);
|
|
42
|
+
slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!node._debugSlots && !node._debugBones)
|
|
46
|
+
return;
|
|
47
|
+
wrapper.setTransform(this._worldTransform, scaleX, scaleY);
|
|
48
|
+
wrapper.setGlobalAlpha(1);
|
|
49
|
+
let attachment;
|
|
50
|
+
const 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 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 = Utils.setArraySize([], 8, 0);
|
|
100
|
+
attachment.computeWorldVertices(slot, vertices, 0, 2);
|
|
101
|
+
const VERTEX = 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
|
+
const locSkeleton = node._skeleton;
|
|
111
|
+
let spriteName, sprite;
|
|
112
|
+
for (let i = 0, n = locSkeleton.slots.length; i < n; i++) {
|
|
113
|
+
const slot = locSkeleton.slots[i], attachment = slot.attachment;
|
|
114
|
+
const slotNode = new cc.Node();
|
|
115
|
+
slot._slotNode = slotNode;
|
|
116
|
+
if (attachment instanceof RegionAttachment) {
|
|
117
|
+
spriteName = attachment.name;
|
|
118
|
+
sprite = this._createSprite(slot, attachment);
|
|
119
|
+
slot.currentSprite = sprite;
|
|
120
|
+
slot.currentSpriteName = spriteName;
|
|
121
|
+
slotNode.addChild(sprite);
|
|
122
|
+
}
|
|
123
|
+
else if (attachment instanceof MeshAttachment) {
|
|
124
|
+
//todo for mesh
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const loaded = function (sprite, texture, attachment) {
|
|
129
|
+
const rendererObject = attachment.region;
|
|
130
|
+
const rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
|
|
131
|
+
sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
|
|
132
|
+
sprite._rect.width = attachment.width;
|
|
133
|
+
sprite._rect.height = attachment.height;
|
|
134
|
+
sprite.setContentSize(attachment.width, attachment.height);
|
|
135
|
+
sprite.setRotation(-attachment.rotation);
|
|
136
|
+
sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
|
|
137
|
+
};
|
|
138
|
+
proto._createSprite = function (slot, attachment) {
|
|
139
|
+
const rendererObject = attachment.region;
|
|
140
|
+
const texture = rendererObject.texture.getRealTexture();
|
|
141
|
+
const sprite = new cc.Sprite();
|
|
142
|
+
if (texture.isLoaded()) {
|
|
143
|
+
loaded(sprite, texture, attachment);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
texture.addEventListener('load', function () {
|
|
147
|
+
loaded(sprite, texture, attachment);
|
|
148
|
+
}, this);
|
|
149
|
+
}
|
|
150
|
+
slot.sprites = slot.sprites || {};
|
|
151
|
+
slot.sprites[rendererObject.name] = sprite;
|
|
152
|
+
return sprite;
|
|
153
|
+
};
|
|
154
|
+
proto._updateChild = function () {
|
|
155
|
+
const locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
|
|
156
|
+
const color = this._displayedColor, opacity = this._displayedOpacity;
|
|
157
|
+
let i, n, selSprite, ax, ay;
|
|
158
|
+
let slot, attachment, slotNode;
|
|
159
|
+
for (i = 0, n = slots.length; i < n; i++) {
|
|
160
|
+
slot = slots[i];
|
|
161
|
+
attachment = slot.attachment;
|
|
162
|
+
slotNode = slot._slotNode;
|
|
163
|
+
if (!attachment) {
|
|
164
|
+
slotNode.setVisible(false);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (attachment instanceof RegionAttachment) {
|
|
168
|
+
if (attachment.region) {
|
|
169
|
+
if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
|
|
170
|
+
const spriteName = attachment.name;
|
|
171
|
+
if (slot.currentSprite !== undefined)
|
|
172
|
+
slot.currentSprite.setVisible(false);
|
|
173
|
+
slot.sprites = slot.sprites || {};
|
|
174
|
+
if (slot.sprites[spriteName] !== undefined)
|
|
175
|
+
slot.sprites[spriteName].setVisible(true);
|
|
176
|
+
else {
|
|
177
|
+
const sprite = this._createSprite(slot, attachment);
|
|
178
|
+
slotNode.addChild(sprite);
|
|
179
|
+
}
|
|
180
|
+
slot.currentSprite = slot.sprites[spriteName];
|
|
181
|
+
slot.currentSpriteName = spriteName;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const bone = slot.bone;
|
|
185
|
+
if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
|
|
186
|
+
ax = attachment.x;
|
|
187
|
+
ay = attachment.y;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
//var regionScaleX = attachment.width / attachment.regionOriginalWidth * attachment.scaleX;
|
|
191
|
+
//ax = attachment.x + attachment.regionOffsetX * regionScaleX - (attachment.width * attachment.scaleX - attachment.regionWidth * regionScaleX) / 2;
|
|
192
|
+
ax = (attachment.offset[0] + attachment.offset[4]) * 0.5;
|
|
193
|
+
ay = (attachment.offset[1] + attachment.offset[5]) * 0.5;
|
|
194
|
+
}
|
|
195
|
+
slotNode.setPosition(bone.worldX + ax * bone.a + ay * bone.b, bone.worldY + ax * bone.c + ay * bone.d);
|
|
196
|
+
slotNode.setScale(bone.getWorldScaleX(), bone.getWorldScaleY());
|
|
197
|
+
//set the color and opacity
|
|
198
|
+
selSprite = slot.currentSprite;
|
|
199
|
+
selSprite._flippedX = bone.skeleton.flipX;
|
|
200
|
+
selSprite._flippedY = bone.skeleton.flipY;
|
|
201
|
+
if (selSprite._flippedY || selSprite._flippedX) {
|
|
202
|
+
slotNode.setRotation(bone.getWorldRotationX());
|
|
203
|
+
selSprite.setRotation(attachment.rotation);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
slotNode.setRotation(-bone.getWorldRotationX());
|
|
207
|
+
selSprite.setRotation(-attachment.rotation);
|
|
208
|
+
}
|
|
209
|
+
//hack for sprite
|
|
210
|
+
selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
|
|
211
|
+
const r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
|
|
212
|
+
selSprite.setColor(cc.color(r, g, b));
|
|
213
|
+
selSprite._renderCmd._updateColor();
|
|
214
|
+
}
|
|
215
|
+
else if (attachment instanceof MeshAttachment) {
|
|
216
|
+
// Can not render mesh
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
slotNode.setVisible(false);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
slotNode.setVisible(true);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
22
|
THE SOFTWARE.
|
|
23
23
|
****************************************************************************/
|
|
24
|
-
export declare const SkeletonTexture: (
|
|
24
|
+
export declare const SkeletonTexture: () => void;
|
|
25
25
|
//# sourceMappingURL=CCSkeletonTexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAI9E,eAAO,MAAM,eAAe,YAE3B,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as spine from '@esotericsoftware/spine-core';
|
|
2
1
|
/****************************************************************************
|
|
3
2
|
Copyright (c) 2017 Chukong Technologies Inc.
|
|
4
3
|
|
|
@@ -22,12 +21,13 @@ import * as spine from '@esotericsoftware/spine-core';
|
|
|
22
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
22
|
THE SOFTWARE.
|
|
24
23
|
****************************************************************************/
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
import { Texture } from '@esotericsoftware/spine-core';
|
|
25
|
+
export const SkeletonTexture = function () {
|
|
26
|
+
// Texture.call(this, image);
|
|
27
27
|
};
|
|
28
|
-
cc.inherits(SkeletonTexture,
|
|
28
|
+
cc.inherits(SkeletonTexture, Texture);
|
|
29
29
|
cc.extend(SkeletonTexture.prototype, {
|
|
30
|
-
name: '
|
|
30
|
+
name: 'SkeletonTexture',
|
|
31
31
|
_texture: null,
|
|
32
32
|
setRealTexture: function (tex) {
|
|
33
33
|
this._texture = tex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCSkeletonWebGLRenderCmd.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonWebGLRenderCmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAI9E,eAAO,MAAM,cAAc;;;CAS1B,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as spine from '@esotericsoftware/spine-core';
|
|
2
1
|
/****************************************************************************
|
|
3
2
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
4
3
|
|
|
@@ -22,6 +21,7 @@ import * as spine from '@esotericsoftware/spine-core';
|
|
|
22
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
22
|
THE SOFTWARE.
|
|
24
23
|
****************************************************************************/
|
|
24
|
+
import { BlendMode, MeshAttachment, RegionAttachment, Utils } from '@esotericsoftware/spine-core';
|
|
25
25
|
export const WebGLRenderCmd = function (renderableObject) {
|
|
26
26
|
this._rootCtor(renderableObject);
|
|
27
27
|
this._needDraw = true;
|
|
@@ -59,10 +59,10 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
|
|
|
59
59
|
attachment = slot.attachment;
|
|
60
60
|
// get the vertices length
|
|
61
61
|
let vertCount = 0;
|
|
62
|
-
if (attachment instanceof
|
|
62
|
+
if (attachment instanceof RegionAttachment) {
|
|
63
63
|
vertCount = 6; // a quad = two triangles = six vertices
|
|
64
64
|
}
|
|
65
|
-
else if (attachment instanceof
|
|
65
|
+
else if (attachment instanceof MeshAttachment) {
|
|
66
66
|
vertCount = attachment.regionUVs.length / 2;
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
@@ -92,10 +92,10 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
|
|
|
92
92
|
}
|
|
93
93
|
// update the vertex buffer
|
|
94
94
|
let slotDebugPoints = null;
|
|
95
|
-
if (attachment instanceof
|
|
95
|
+
if (attachment instanceof RegionAttachment) {
|
|
96
96
|
slotDebugPoints = this._uploadRegionAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
|
|
97
97
|
}
|
|
98
|
-
else if (attachment instanceof
|
|
98
|
+
else if (attachment instanceof MeshAttachment) {
|
|
99
99
|
this._uploadMeshAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
@@ -105,7 +105,7 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
|
|
|
105
105
|
debugSlotsInfo[i] = slotDebugPoints;
|
|
106
106
|
}
|
|
107
107
|
// update the index buffer
|
|
108
|
-
if (attachment instanceof
|
|
108
|
+
if (attachment instanceof RegionAttachment) {
|
|
109
109
|
cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.TRIANGLE);
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
@@ -168,19 +168,19 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
|
|
|
168
168
|
proto._getBlendFunc = function (blendMode, premultiAlpha) {
|
|
169
169
|
let ret = this._currBlendFunc;
|
|
170
170
|
switch (blendMode) {
|
|
171
|
-
case
|
|
171
|
+
case BlendMode.Normal:
|
|
172
172
|
ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
|
|
173
173
|
ret.dst = cc.ONE_MINUS_SRC_ALPHA;
|
|
174
174
|
break;
|
|
175
|
-
case
|
|
175
|
+
case BlendMode.Additive:
|
|
176
176
|
ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
|
|
177
177
|
ret.dst = cc.ONE;
|
|
178
178
|
break;
|
|
179
|
-
case
|
|
179
|
+
case BlendMode.Multiply:
|
|
180
180
|
ret.src = cc.DST_COLOR;
|
|
181
181
|
ret.dst = cc.ONE_MINUS_SRC_ALPHA;
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
183
|
+
case BlendMode.Screen:
|
|
184
184
|
ret.src = cc.ONE;
|
|
185
185
|
ret.dst = cc.ONE_MINUS_SRC_COLOR;
|
|
186
186
|
break;
|
|
@@ -203,7 +203,7 @@ proto._uploadRegionAttachmentData = function (attachment, slot, premultipliedAlp
|
|
|
203
203
|
//
|
|
204
204
|
const nodeColor = this._displayedColor;
|
|
205
205
|
const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
|
|
206
|
-
const vertices =
|
|
206
|
+
const vertices = Utils.setArraySize([], 8, 0);
|
|
207
207
|
attachment.computeWorldVertices(slot, vertices, 0, 2);
|
|
208
208
|
const uvs = attachment.uvs;
|
|
209
209
|
// get the colors data
|
|
@@ -235,7 +235,7 @@ proto._uploadRegionAttachmentData = function (attachment, slot, premultipliedAlp
|
|
|
235
235
|
}
|
|
236
236
|
if (this._node._debugSlots) {
|
|
237
237
|
// return the quad points info if debug slot enabled
|
|
238
|
-
const VERTEX =
|
|
238
|
+
const VERTEX = RegionAttachment;
|
|
239
239
|
return [
|
|
240
240
|
cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
|
|
241
241
|
cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
|
|
@@ -248,7 +248,7 @@ proto._uploadMeshAttachmentData = function (attachment, slot, premultipliedAlpha
|
|
|
248
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
249
|
// get the vertex data
|
|
250
250
|
const verticesLength = attachment.worldVerticesLength;
|
|
251
|
-
const vertices =
|
|
251
|
+
const vertices = Utils.setArraySize([], verticesLength, 0);
|
|
252
252
|
attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
|
|
253
253
|
const uvs = attachment.uvs;
|
|
254
254
|
// get the colors data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/cocos",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "safe-engine with cocos renderer support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,12 +21,11 @@
|
|
|
21
21
|
"typescript": "^5.9.2"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@
|
|
24
|
+
"@cocos/dragonbones-js": "^1.0.2",
|
|
25
|
+
"@esotericsoftware/spine-core": "^4.2.93",
|
|
25
26
|
"box2d-wasm": "^7.0.0",
|
|
26
|
-
"cocos-html5-ts": "^1.2.
|
|
27
|
-
"
|
|
28
|
-
"entityx-ts": "^2.3.1",
|
|
29
|
-
"pixi.js": "^8.13.2"
|
|
27
|
+
"cocos-html5-ts": "^1.2.4",
|
|
28
|
+
"entityx-ts": "^2.3.1"
|
|
30
29
|
},
|
|
31
30
|
"author": "",
|
|
32
31
|
"license": "ISC"
|
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,15 +0,0 @@
|
|
|
1
|
-
import { PixiArmatureDisplay } from 'dragonbones-pixijs';
|
|
2
|
-
import { Application } from 'pixi.js';
|
|
3
|
-
export declare function loadDragonBonesAssets(skeleton: any, atlas: any, texture: any): Promise<any>;
|
|
4
|
-
export declare class PixiDragonBonesSprite extends cc.Sprite {
|
|
5
|
-
_canvas: any;
|
|
6
|
-
_pixiApp: Application;
|
|
7
|
-
_texture: cc.Texture2D;
|
|
8
|
-
_config: any;
|
|
9
|
-
_armatureDisplay: PixiArmatureDisplay;
|
|
10
|
-
constructor(config: any);
|
|
11
|
-
_setupArmature(): void;
|
|
12
|
-
updateTexture(): void;
|
|
13
|
-
onExit(): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=PixiDragonBonesSprite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PixiDragonBonesSprite.d.ts","sourceRoot":"","sources":["../../src/dragonbones/PixiDragonBonesSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAU,MAAM,SAAS,CAAA;AAE7C,wBAAgB,qBAAqB,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,EAAE,OAAO,KAAA,gBAE7D;AACD,qBAAa,qBAAsB,SAAQ,EAAE,CAAC,MAAM;IAClD,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAA;IACtB,OAAO,MAAA;IACP,gBAAgB,EAAE,mBAAmB,CAAA;gBACzB,MAAM,KAAA;IA+BlB,cAAc;IAsBd,aAAa;IASb,MAAM;CAMP"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { PixiFactory } from 'dragonbones-pixijs';
|
|
2
|
-
import { Application, Assets } from 'pixi.js';
|
|
3
|
-
export function loadDragonBonesAssets(skeleton, atlas, texture) {
|
|
4
|
-
return Assets.load([skeleton, atlas, texture]);
|
|
5
|
-
}
|
|
6
|
-
export class PixiDragonBonesSprite extends cc.Sprite {
|
|
7
|
-
_canvas;
|
|
8
|
-
_pixiApp;
|
|
9
|
-
_texture;
|
|
10
|
-
_config;
|
|
11
|
-
_armatureDisplay;
|
|
12
|
-
constructor(config) {
|
|
13
|
-
super();
|
|
14
|
-
super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
15
|
-
this._canvas = document.createElement('canvas');
|
|
16
|
-
this._canvas.width = config.width || 1024;
|
|
17
|
-
this._canvas.height = config.height || 1024;
|
|
18
|
-
this._pixiApp = new Application();
|
|
19
|
-
this._pixiApp.init({
|
|
20
|
-
view: this._canvas,
|
|
21
|
-
width: this._canvas.width,
|
|
22
|
-
height: this._canvas.height,
|
|
23
|
-
backgroundAlpha: 0, // nền trong suốt
|
|
24
|
-
// transparent: true, // bắt buộc để alpha hoạt động
|
|
25
|
-
clearBeforeRender: true, // xoá trước khi vẽ frame mới
|
|
26
|
-
preserveDrawingBuffer: true, // giúp lấy ảnh từ canvas
|
|
27
|
-
antialias: true,
|
|
28
|
-
});
|
|
29
|
-
this._texture = new cc.Texture2D();
|
|
30
|
-
this._texture.initWithElement(this._canvas);
|
|
31
|
-
this._texture.handleLoadedTexture();
|
|
32
|
-
this.initWithTexture(this._texture);
|
|
33
|
-
this._config = config;
|
|
34
|
-
this._armatureDisplay = null;
|
|
35
|
-
this._setupArmature();
|
|
36
|
-
// this.schedule(this.updateTexture, 1 / 30);
|
|
37
|
-
}
|
|
38
|
-
_setupArmature() {
|
|
39
|
-
const { key, skeleton, atlas, texture, playTimes, animationName, scale = 1 } = this._config;
|
|
40
|
-
const factory = PixiFactory.factory;
|
|
41
|
-
const dragonData = factory.parseDragonBonesData(Assets.get(skeleton), key);
|
|
42
|
-
factory.parseTextureAtlasData(Assets.get(atlas), Assets.get(texture), key);
|
|
43
|
-
const { armatureNames } = dragonData;
|
|
44
|
-
const armatureName = armatureNames[0];
|
|
45
|
-
const display = factory.buildArmatureDisplay(armatureName, key);
|
|
46
|
-
if (!display) {
|
|
47
|
-
console.error('Cannot build armature:', armatureName);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
display.animation.play(animationName, playTimes);
|
|
51
|
-
display.x = this._canvas.width / 2;
|
|
52
|
-
display.y = this._canvas.height / 2;
|
|
53
|
-
display.scale.set(scale);
|
|
54
|
-
this._pixiApp.stage.addChild(display);
|
|
55
|
-
this._armatureDisplay = display;
|
|
56
|
-
}
|
|
57
|
-
updateTexture() {
|
|
58
|
-
if (this._armatureDisplay && this._pixiApp.renderer) {
|
|
59
|
-
this._pixiApp.renderer.render(this._pixiApp.stage);
|
|
60
|
-
this._texture.initWithElement(this._canvas);
|
|
61
|
-
this._texture.handleLoadedTexture();
|
|
62
|
-
this.setTexture(this._texture);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
onExit() {
|
|
66
|
-
// this.unschedule(this.updateTexture);
|
|
67
|
-
this._pixiApp.destroy(true, { children: true });
|
|
68
|
-
this._canvas.remove();
|
|
69
|
-
super.onExit();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -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"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export class EnhancedComponent {
|
|
2
|
-
static hasRender = true;
|
|
3
|
-
props = {};
|
|
4
|
-
node;
|
|
5
|
-
enabled = true;
|
|
6
|
-
constructor(data) {
|
|
7
|
-
this.init(data);
|
|
8
|
-
}
|
|
9
|
-
init(data) {
|
|
10
|
-
if (data) {
|
|
11
|
-
// console.log('constructor', this.constructor.name, data)
|
|
12
|
-
Object.keys(data).forEach((key) => {
|
|
13
|
-
this.props[key] = data[key];
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
addComponent(instance) {
|
|
18
|
-
return this.node.addComponent(instance);
|
|
19
|
-
}
|
|
20
|
-
getComponent(component) {
|
|
21
|
-
return this.node.getComponent(component);
|
|
22
|
-
}
|
|
23
|
-
schedule(callback, interval, repeat = cc.macro.REPEAT_FOREVER, delay = 0) {
|
|
24
|
-
this.node.instance.schedule(callback.bind(this), interval, repeat, delay);
|
|
25
|
-
}
|
|
26
|
-
unschedule(callback) {
|
|
27
|
-
this.node.instance.unschedule(callback.bind(this));
|
|
28
|
-
}
|
|
29
|
-
unscheduleAllCallbacks() {
|
|
30
|
-
this.node.instance.unscheduleAllCallbacks();
|
|
31
|
-
}
|
|
32
|
-
scheduleOnce(callback, delay, key) {
|
|
33
|
-
this.node.instance.scheduleOnce(callback, delay, key);
|
|
34
|
-
}
|
|
35
|
-
getComponentsInChildren(component) {
|
|
36
|
-
return this.node.getComponentsInChildren(component);
|
|
37
|
-
}
|
|
38
|
-
getComponentInChildren(component) {
|
|
39
|
-
return this.node.getComponentInChildren(component);
|
|
40
|
-
}
|
|
41
|
-
isEqual(other) {
|
|
42
|
-
return this.node.entity.id === other.node.entity.id;
|
|
43
|
-
}
|
|
44
|
-
}
|