@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,368 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
8
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
9
|
+
* the Software without restriction, including without limitation the rights to
|
|
10
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
11
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
12
|
+
* subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* 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, FITNESS
|
|
19
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
20
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
21
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
22
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { BaseObject, BinaryOffset, BoneType, Slot, Transform } from '@cocos/dragonbones-js';
|
|
25
|
+
import { CocosTextureAtlasData } from './CocosTextureAtlasData';
|
|
26
|
+
export class CocosSlot extends Slot {
|
|
27
|
+
_updateGlueMesh() { }
|
|
28
|
+
static toString() {
|
|
29
|
+
return '[class dragonBones.CocosSlot]';
|
|
30
|
+
}
|
|
31
|
+
_textureScale;
|
|
32
|
+
_renderDisplay;
|
|
33
|
+
_onClear() {
|
|
34
|
+
super._onClear();
|
|
35
|
+
this._textureScale = 1.0;
|
|
36
|
+
this._renderDisplay = null;
|
|
37
|
+
// this._updateTransform = cc[0] === '3' ? this._updateTransformV3 : this._updateTransformV4;
|
|
38
|
+
}
|
|
39
|
+
_initDisplay(value, isRetain) {
|
|
40
|
+
// tslint:disable-next-line:no-unused-expression
|
|
41
|
+
value;
|
|
42
|
+
// tslint:disable-next-line:no-unused-expression
|
|
43
|
+
isRetain;
|
|
44
|
+
}
|
|
45
|
+
_disposeDisplay(value, isRelease) {
|
|
46
|
+
// tslint:disable-next-line:no-unused-expression
|
|
47
|
+
value;
|
|
48
|
+
if (!isRelease) {
|
|
49
|
+
;
|
|
50
|
+
value.release();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_onUpdateDisplay() {
|
|
54
|
+
this._renderDisplay = (this._display ? this._display : this._rawDisplay);
|
|
55
|
+
}
|
|
56
|
+
_addDisplay() {
|
|
57
|
+
const container = this._armature.display;
|
|
58
|
+
container.addChild(this._renderDisplay);
|
|
59
|
+
}
|
|
60
|
+
_replaceDisplay(value) {
|
|
61
|
+
const container = this._armature.display;
|
|
62
|
+
const prevDisplay = value;
|
|
63
|
+
container.addChild(this._renderDisplay);
|
|
64
|
+
// container.swapChildren(this._renderDisplay, prevDisplay);
|
|
65
|
+
container.removeChild(prevDisplay);
|
|
66
|
+
this._textureScale = 1.0;
|
|
67
|
+
}
|
|
68
|
+
_removeDisplay() {
|
|
69
|
+
this._renderDisplay.parent.removeChild(this._renderDisplay);
|
|
70
|
+
}
|
|
71
|
+
_updateZOrder() {
|
|
72
|
+
if (this._renderDisplay.getLocalZOrder() === this._zOrder) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this._renderDisplay.setLocalZOrder(this._zOrder);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
_updateVisible() {
|
|
81
|
+
this._renderDisplay.visible = this._parent.visible && this._visible;
|
|
82
|
+
}
|
|
83
|
+
_updateBlendMode() {
|
|
84
|
+
if (this._renderDisplay instanceof cc.Sprite) {
|
|
85
|
+
}
|
|
86
|
+
// TODO child armature.
|
|
87
|
+
}
|
|
88
|
+
_updateColor() {
|
|
89
|
+
const alpha = this._colorTransform.alphaMultiplier * this._globalAlpha;
|
|
90
|
+
this._renderDisplay.alpha = alpha;
|
|
91
|
+
if (this._renderDisplay instanceof cc.Sprite || this._renderDisplay instanceof Cocos.SimpleMesh) {
|
|
92
|
+
const color = (Math.round(this._colorTransform.redMultiplier * 0xff) << 16) +
|
|
93
|
+
(Math.round(this._colorTransform.greenMultiplier * 0xff) << 8) +
|
|
94
|
+
Math.round(this._colorTransform.blueMultiplier * 0xff);
|
|
95
|
+
this._renderDisplay.tint = color;
|
|
96
|
+
}
|
|
97
|
+
// TODO child armature.
|
|
98
|
+
}
|
|
99
|
+
_updateFrame() {
|
|
100
|
+
let currentTextureData = this._textureData;
|
|
101
|
+
if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) {
|
|
102
|
+
let currentTextureAtlasData = currentTextureData.parent;
|
|
103
|
+
if (this._armature.replacedTexture !== null) {
|
|
104
|
+
// Update replaced texture atlas.
|
|
105
|
+
if (this._armature._replaceTextureAtlasData === null) {
|
|
106
|
+
currentTextureAtlasData = BaseObject.borrowObject(CocosTextureAtlasData);
|
|
107
|
+
currentTextureAtlasData.copyFrom(currentTextureData.parent);
|
|
108
|
+
currentTextureAtlasData.renderTexture = this._armature.replacedTexture;
|
|
109
|
+
this._armature._replaceTextureAtlasData = currentTextureAtlasData;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
currentTextureAtlasData = this._armature._replaceTextureAtlasData;
|
|
113
|
+
}
|
|
114
|
+
currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name);
|
|
115
|
+
}
|
|
116
|
+
const renderTexture = currentTextureData.renderTexture;
|
|
117
|
+
if (renderTexture !== null) {
|
|
118
|
+
if (this._geometryData) {
|
|
119
|
+
// Mesh.
|
|
120
|
+
const data = this._geometryData.data;
|
|
121
|
+
const intArray = data.intArray;
|
|
122
|
+
const floatArray = data.floatArray;
|
|
123
|
+
const vertexCount = intArray[this._geometryData.offset + BinaryOffset.GeometryVertexCount];
|
|
124
|
+
const triangleCount = intArray[this._geometryData.offset + BinaryOffset.GeometryTriangleCount];
|
|
125
|
+
let vertexOffset = intArray[this._geometryData.offset + BinaryOffset.GeometryFloatOffset];
|
|
126
|
+
if (vertexOffset < 0) {
|
|
127
|
+
vertexOffset += 65536; // Fixed out of bouds bug.
|
|
128
|
+
}
|
|
129
|
+
const uvOffset = vertexOffset + vertexCount * 2;
|
|
130
|
+
const scale = this._armature._armatureData.scale;
|
|
131
|
+
const meshDisplay = this._renderDisplay;
|
|
132
|
+
const vertices = new Float32Array(vertexCount * 2);
|
|
133
|
+
const uvs = new Float32Array(vertexCount * 2);
|
|
134
|
+
const indices = new Uint16Array(triangleCount * 3);
|
|
135
|
+
for (let i = 0, l = vertexCount * 2; i < l; ++i) {
|
|
136
|
+
vertices[i] = floatArray[vertexOffset + i] * scale;
|
|
137
|
+
}
|
|
138
|
+
for (let i = 0; i < triangleCount * 3; ++i) {
|
|
139
|
+
indices[i] = intArray[this._geometryData.offset + BinaryOffset.GeometryVertexIndices + i];
|
|
140
|
+
}
|
|
141
|
+
for (let i = 0, l = vertexCount * 2; i < l; i += 2) {
|
|
142
|
+
const u = floatArray[uvOffset + i];
|
|
143
|
+
const v = floatArray[uvOffset + i + 1];
|
|
144
|
+
if (currentTextureData.rotated) {
|
|
145
|
+
uvs[i] = 1 - v;
|
|
146
|
+
uvs[i + 1] = u;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
uvs[i] = u;
|
|
150
|
+
uvs[i + 1] = v;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
this._textureScale = 1.0;
|
|
154
|
+
meshDisplay.texture = renderTexture;
|
|
155
|
+
meshDisplay.vertices = vertices;
|
|
156
|
+
meshDisplay.uvBuffer.update(uvs);
|
|
157
|
+
meshDisplay.geometry.addIndex(indices);
|
|
158
|
+
const isSkinned = this._geometryData.weight !== null;
|
|
159
|
+
const isSurface = this._parent._boneData.type !== BoneType.Bone;
|
|
160
|
+
if (isSkinned || isSurface) {
|
|
161
|
+
this._identityTransform();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Normal texture.
|
|
166
|
+
this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale;
|
|
167
|
+
const normalDisplay = this._renderDisplay;
|
|
168
|
+
normalDisplay.setSpriteFrame(renderTexture);
|
|
169
|
+
}
|
|
170
|
+
this._visibleDirty = true;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (this._geometryData) {
|
|
175
|
+
const meshDisplay = this._renderDisplay;
|
|
176
|
+
meshDisplay.texture = null;
|
|
177
|
+
meshDisplay.x = 0.0;
|
|
178
|
+
meshDisplay.y = 0.0;
|
|
179
|
+
meshDisplay.visible = false;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const normalDisplay = this._renderDisplay;
|
|
183
|
+
normalDisplay.texture = null;
|
|
184
|
+
normalDisplay.x = 0.0;
|
|
185
|
+
normalDisplay.y = 0.0;
|
|
186
|
+
normalDisplay.visible = false;
|
|
187
|
+
}
|
|
188
|
+
this._renderDisplay.setPosition(0.0, 0.0);
|
|
189
|
+
}
|
|
190
|
+
_updateMesh() {
|
|
191
|
+
const scale = this._armature._armatureData.scale;
|
|
192
|
+
// console.log(this._renderDisplay)
|
|
193
|
+
const deformVertices = this._deformVertices;
|
|
194
|
+
const bones = this._geometryBones;
|
|
195
|
+
const geometryData = this._geometryData;
|
|
196
|
+
const weightData = deformVertices.verticesData.weight;
|
|
197
|
+
const hasDeform = deformVertices.length > 0 && deformVertices.verticesData.inheritDeform;
|
|
198
|
+
// const meshDisplay = (this._renderDisplay.getComponent(cc.Sprite) as any)._sgNode; // as cc.Scale9Sprite;
|
|
199
|
+
const polygonInfo = this._meshDisplay._polygonInfo;
|
|
200
|
+
if (!polygonInfo) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const verticesAndUVs = polygonInfo.triangles.verts;
|
|
204
|
+
const boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0);
|
|
205
|
+
if (weightData !== null) {
|
|
206
|
+
const data = geometryData.data;
|
|
207
|
+
const intArray = data.intArray;
|
|
208
|
+
const floatArray = data.floatArray;
|
|
209
|
+
const vertexCount = intArray[geometryData.offset + BinaryOffset.MeshVertexCount];
|
|
210
|
+
let weightFloatOffset = intArray[weightData.offset + BinaryOffset.WeigthFloatOffset];
|
|
211
|
+
if (weightFloatOffset < 0) {
|
|
212
|
+
weightFloatOffset += 65536; // Fixed out of bouds bug.
|
|
213
|
+
}
|
|
214
|
+
for (let i = 0, iB = weightData.offset + BinaryOffset.WeigthBoneIndices + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) {
|
|
215
|
+
const boneCount = intArray[iB++];
|
|
216
|
+
let xG = 0.0, yG = 0.0;
|
|
217
|
+
for (let j = 0; j < boneCount; ++j) {
|
|
218
|
+
const boneIndex = intArray[iB++];
|
|
219
|
+
const bone = bones[boneIndex];
|
|
220
|
+
if (bone !== null) {
|
|
221
|
+
const matrix = bone.globalTransformMatrix;
|
|
222
|
+
const weight = floatArray[iV++];
|
|
223
|
+
let xL = floatArray[iV++] * scale;
|
|
224
|
+
let yL = floatArray[iV++] * scale;
|
|
225
|
+
if (hasDeform) {
|
|
226
|
+
xL += deformVertices[iF++];
|
|
227
|
+
yL += deformVertices[iF++];
|
|
228
|
+
}
|
|
229
|
+
xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight;
|
|
230
|
+
yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const vertex = verticesAndUVs[i];
|
|
234
|
+
vertex.x = xG;
|
|
235
|
+
vertex.y = yG;
|
|
236
|
+
if (boundsRect.x > xG) {
|
|
237
|
+
boundsRect.x = xG;
|
|
238
|
+
}
|
|
239
|
+
if (boundsRect.width < xG) {
|
|
240
|
+
boundsRect.width = xG;
|
|
241
|
+
}
|
|
242
|
+
if (boundsRect.y > yG) {
|
|
243
|
+
boundsRect.y = yG;
|
|
244
|
+
}
|
|
245
|
+
if (boundsRect.height < yG) {
|
|
246
|
+
boundsRect.height = yG;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
const isSurface = this._parent._boneData.type !== BoneType.Bone;
|
|
252
|
+
const data = geometryData.data;
|
|
253
|
+
const intArray = data.intArray;
|
|
254
|
+
const floatArray = data.floatArray;
|
|
255
|
+
const vertexCount = intArray[geometryData.offset + BinaryOffset.MeshVertexCount];
|
|
256
|
+
let vertexOffset = intArray[geometryData.offset + BinaryOffset.MeshFloatOffset];
|
|
257
|
+
if (vertexOffset < 0) {
|
|
258
|
+
vertexOffset += 65536; // Fixed out of bouds bug.
|
|
259
|
+
}
|
|
260
|
+
for (let i = 0, l = vertexCount * 2; i < l; i += 2) {
|
|
261
|
+
const iH = i / 2; // int.
|
|
262
|
+
let x = floatArray[vertexOffset + i] * scale;
|
|
263
|
+
let y = floatArray[vertexOffset + i + 1] * scale;
|
|
264
|
+
if (hasDeform) {
|
|
265
|
+
x += deformVertices[i];
|
|
266
|
+
y += deformVertices[i + 1];
|
|
267
|
+
}
|
|
268
|
+
const vertex = verticesAndUVs[iH];
|
|
269
|
+
if (isSurface) {
|
|
270
|
+
const matrix = this._parent._getGlobalTransformMatrix(x, y);
|
|
271
|
+
vertex.x = matrix.a * x + matrix.c * y + matrix.tx;
|
|
272
|
+
vertex.y = matrix.b * x + matrix.d * y + matrix.ty;
|
|
273
|
+
//
|
|
274
|
+
x = vertex.x;
|
|
275
|
+
y = vertex.y;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
vertex.x = x;
|
|
279
|
+
y = vertex.y = -y;
|
|
280
|
+
}
|
|
281
|
+
if (boundsRect.x > x) {
|
|
282
|
+
boundsRect.x = x;
|
|
283
|
+
}
|
|
284
|
+
if (boundsRect.width < x) {
|
|
285
|
+
boundsRect.width = x;
|
|
286
|
+
}
|
|
287
|
+
if (boundsRect.y > y) {
|
|
288
|
+
boundsRect.y = y;
|
|
289
|
+
}
|
|
290
|
+
if (boundsRect.height < y) {
|
|
291
|
+
boundsRect.height = y;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
boundsRect.width -= boundsRect.x;
|
|
296
|
+
boundsRect.height -= boundsRect.y;
|
|
297
|
+
polygonInfo.rect = boundsRect;
|
|
298
|
+
meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height));
|
|
299
|
+
meshDisplay.setMeshPolygonInfo(polygonInfo);
|
|
300
|
+
if (weightData !== null) {
|
|
301
|
+
this._identityTransform();
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const transform = this.global;
|
|
305
|
+
const globalTransformMatrix = this.globalTransformMatrix;
|
|
306
|
+
this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
|
|
307
|
+
this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
|
|
308
|
+
this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * Transform.RAD_DEG;
|
|
309
|
+
this._renderDisplay.rotationY = -transform.rotation * Transform.RAD_DEG;
|
|
310
|
+
this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
|
|
311
|
+
this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
_updateTransform() {
|
|
315
|
+
this.updateGlobalTransform();
|
|
316
|
+
const transform = this.global;
|
|
317
|
+
// const globalTransformMatrix = this.globalTransformMatrix;
|
|
318
|
+
// if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
|
|
319
|
+
// this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY);
|
|
320
|
+
// this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY);
|
|
321
|
+
// }
|
|
322
|
+
// else {
|
|
323
|
+
this._renderDisplay.x = transform.x;
|
|
324
|
+
this._renderDisplay.y = transform.y;
|
|
325
|
+
// }
|
|
326
|
+
this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * Transform.RAD_DEG;
|
|
327
|
+
this._renderDisplay.rotationY = -transform.rotation * Transform.RAD_DEG;
|
|
328
|
+
this._renderDisplay.scaleX = transform.scaleX * this._textureScale;
|
|
329
|
+
this._renderDisplay.scaleY = -transform.scaleY * this._textureScale;
|
|
330
|
+
}
|
|
331
|
+
_updateTransformV3() {
|
|
332
|
+
this.updateGlobalTransform(); // Update transform.
|
|
333
|
+
const transform = this.global;
|
|
334
|
+
if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) {
|
|
335
|
+
const x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY);
|
|
336
|
+
const y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY);
|
|
337
|
+
// this._renderDisplay.transform = new cc.AffineTransform(
|
|
338
|
+
// x, y,
|
|
339
|
+
// transform.scaleX * this._textureScale, transform.scaleY * this._textureScale,
|
|
340
|
+
// transform.rotation,
|
|
341
|
+
// transform.skew, 0.0,
|
|
342
|
+
// );
|
|
343
|
+
this._renderDisplay.setPosition(x, y);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this._renderDisplay.setPosition(transform.x, transform.y);
|
|
347
|
+
this._renderDisplay.rotation = transform.rotation;
|
|
348
|
+
this._renderDisplay.skewX = transform.skew;
|
|
349
|
+
this._renderDisplay.setScale(transform.scaleX, transform.scaleY);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
_identityTransform() {
|
|
353
|
+
// const helpMatrix = TransformObject._helpMatrix;
|
|
354
|
+
// helpMatrix.a = 1.0;
|
|
355
|
+
// helpMatrix.b = 0.0;
|
|
356
|
+
// helpMatrix.c = -0.0;
|
|
357
|
+
// helpMatrix.d = -1.0;
|
|
358
|
+
// helpMatrix.tx = 0.0;
|
|
359
|
+
// helpMatrix.ty = 0.0;
|
|
360
|
+
// (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix);
|
|
361
|
+
this._renderDisplay.x = 0.0;
|
|
362
|
+
this._renderDisplay.y = 0.0;
|
|
363
|
+
this._renderDisplay.rotationX = 0.0;
|
|
364
|
+
this._renderDisplay.rotationY = 0.0;
|
|
365
|
+
this._renderDisplay.scaleX = 1.0;
|
|
366
|
+
this._renderDisplay.scaleY = 1.0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
import { TextureAtlasData, TextureData } from '@cocos/dragonbones-js';
|
|
24
|
+
export declare class CocosTextureAtlasData extends TextureAtlasData {
|
|
25
|
+
static toString(): string;
|
|
26
|
+
private _renderTexture;
|
|
27
|
+
protected _onClear(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
createTexture(): TextureData;
|
|
32
|
+
/**
|
|
33
|
+
* - The CocosJS texture.
|
|
34
|
+
* @version DragonBones 3.0
|
|
35
|
+
* @language en_US
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* - CocosJS 贴图。
|
|
39
|
+
* @version DragonBones 3.0
|
|
40
|
+
* @language zh_CN
|
|
41
|
+
*/
|
|
42
|
+
get renderTexture(): cc.Texture2D | null;
|
|
43
|
+
set renderTexture(value: cc.Texture2D | null);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare class CocosTextureData extends TextureData {
|
|
49
|
+
static toString(): string;
|
|
50
|
+
renderTexture: cc.SpriteFrame | null;
|
|
51
|
+
protected _onClear(): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=CocosTextureAtlasData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CocosTextureAtlasData.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosTextureAtlasData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAc,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEjF,qBAAa,qBAAsB,SAAQ,gBAAgB;WAC3C,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,cAAc,CAA4B;IAElD,SAAS,CAAC,QAAQ,IAAI,IAAI;IAS1B;;OAEG;IACI,aAAa,IAAI,WAAW;IAGnC;;;;OAIG;IACH;;;;OAIG;IACH,IAAW,aAAa,IAAI,EAAE,CAAC,SAAS,GAAG,IAAI,CAE9C;IACD,IAAW,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,GAAG,IAAI,EAoDlD;CACF;AACD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;WACjC,QAAQ,IAAI,MAAM;IAIzB,aAAa,EAAE,EAAE,CAAC,WAAW,GAAG,IAAI,CAAO;IAElD,SAAS,CAAC,QAAQ,IAAI,IAAI;CAS3B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
* the Software without restriction, including without limitation the rights to
|
|
9
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
import { BaseObject, TextureAtlasData, TextureData } from '@cocos/dragonbones-js';
|
|
24
|
+
export class CocosTextureAtlasData extends TextureAtlasData {
|
|
25
|
+
static toString() {
|
|
26
|
+
return '[class dragonBones.CocosTextureAtlasData]';
|
|
27
|
+
}
|
|
28
|
+
_renderTexture = null; // Initial value.
|
|
29
|
+
_onClear() {
|
|
30
|
+
super._onClear();
|
|
31
|
+
if (this._renderTexture !== null) {
|
|
32
|
+
// this._renderTexture.dispose();
|
|
33
|
+
}
|
|
34
|
+
this._renderTexture = null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
createTexture() {
|
|
40
|
+
return BaseObject.borrowObject(CocosTextureData);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* - The CocosJS texture.
|
|
44
|
+
* @version DragonBones 3.0
|
|
45
|
+
* @language en_US
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* - CocosJS 贴图。
|
|
49
|
+
* @version DragonBones 3.0
|
|
50
|
+
* @language zh_CN
|
|
51
|
+
*/
|
|
52
|
+
get renderTexture() {
|
|
53
|
+
return this._renderTexture;
|
|
54
|
+
}
|
|
55
|
+
set renderTexture(value) {
|
|
56
|
+
if (this._renderTexture === value) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._renderTexture = value;
|
|
60
|
+
if (this._renderTexture !== null) {
|
|
61
|
+
for (const k in this.textures) {
|
|
62
|
+
const textureData = this.textures[k];
|
|
63
|
+
// if (textureData.renderTexture !== null) {
|
|
64
|
+
// textureData.renderTexture.destroy();
|
|
65
|
+
// }
|
|
66
|
+
// console.log('textureData', this._renderTexture, textureData)
|
|
67
|
+
// console.log('this._renderTexture', this._renderTexture)
|
|
68
|
+
const x = textureData.region.x;
|
|
69
|
+
const y = textureData.region.y;
|
|
70
|
+
const rotated = textureData.rotated;
|
|
71
|
+
const width = rotated ? textureData.region.height : textureData.region.width;
|
|
72
|
+
const height = rotated ? textureData.region.width : textureData.region.height;
|
|
73
|
+
const rect = cc.rect(x, y, width, height);
|
|
74
|
+
const offset = cc.p(0, 0);
|
|
75
|
+
const originSize = cc.size(width, height);
|
|
76
|
+
if (textureData.frame) {
|
|
77
|
+
const px = -textureData.frame.x;
|
|
78
|
+
const py = -textureData.frame.y;
|
|
79
|
+
originSize.width = textureData.frame.width;
|
|
80
|
+
originSize.height = textureData.frame.height;
|
|
81
|
+
// offset = sprite center - trimed texture center
|
|
82
|
+
const cx1 = px + rect.width / 2;
|
|
83
|
+
const cy1 = originSize.height - py - rect.height / 2;
|
|
84
|
+
const cx2 = originSize.width / 2;
|
|
85
|
+
const cy2 = originSize.height / 2;
|
|
86
|
+
offset.x = cx2 - cx1;
|
|
87
|
+
offset.y = cy2 - cy1;
|
|
88
|
+
}
|
|
89
|
+
// sprite
|
|
90
|
+
const spriteFrame = new cc.SpriteFrame(this._renderTexture, rect, textureData.rotated, offset, originSize);
|
|
91
|
+
// console.log('sf', sf)
|
|
92
|
+
textureData.renderTexture = spriteFrame;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
for (const k in this.textures) {
|
|
97
|
+
const textureData = this.textures[k];
|
|
98
|
+
// if (textureData.renderTexture !== null) {
|
|
99
|
+
// textureData.renderTexture.destroy();
|
|
100
|
+
// }
|
|
101
|
+
textureData.renderTexture = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export class CocosTextureData extends TextureData {
|
|
110
|
+
static toString() {
|
|
111
|
+
return '[class dragonBones.CocosTextureData]';
|
|
112
|
+
}
|
|
113
|
+
renderTexture = null; // Initial value.
|
|
114
|
+
_onClear() {
|
|
115
|
+
super._onClear();
|
|
116
|
+
// if (this.renderTexture !== null) {
|
|
117
|
+
// this.renderTexture.destroy();
|
|
118
|
+
// }
|
|
119
|
+
this.renderTexture = null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
3
|
-
import { ComponentX } from '../core/decorator';
|
|
4
|
-
import { BaseComponentProps } from '../safex';
|
|
5
|
-
import { PixiDragonBonesSprite } from './PixiDragonBonesSprite';
|
|
6
|
-
export type DragonBonesEventData = {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
export interface DragonBonesData {
|
|
10
|
-
atlas: string;
|
|
11
|
-
skeleton: string;
|
|
12
|
-
texture: string;
|
|
13
|
-
}
|
|
14
|
-
interface DragonBonesProps {
|
|
15
|
-
data: DragonBonesData;
|
|
16
|
-
skin?: string;
|
|
17
|
-
animation?: string;
|
|
18
|
-
playTimes?: Integer;
|
|
19
|
-
timeScale?: Float;
|
|
20
|
-
onAnimationStart?: () => void;
|
|
21
|
-
onAnimationEnd?: () => void;
|
|
22
|
-
onAnimationComplete?: () => void;
|
|
23
|
-
}
|
|
24
|
-
export declare class DragonBonesComp extends ComponentX<DragonBonesProps & BaseComponentProps<DragonBonesComp>, PixiDragonBonesSprite> {
|
|
25
|
-
armature: PixiArmatureDisplay;
|
|
26
|
-
setAnimation(name: string, playTimes?: number): void;
|
|
27
|
-
getAnimationName(): any;
|
|
28
|
-
setFLipX(isFlipX: boolean): void;
|
|
29
|
-
setTimeScale(timeScale: Float): void;
|
|
30
|
-
}
|
|
31
|
-
export declare class DragonBonesSystem implements System {
|
|
32
|
-
configure(event_manager: EventManager): void;
|
|
33
|
-
update(entities: EntityManager): void;
|
|
34
|
-
}
|
|
1
|
+
export * from './DragonBonesComp';
|
|
35
2
|
export declare function setupDragonBones(): void;
|
|
36
|
-
export * from './PixiDragonBonesSprite';
|
|
37
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragonbones/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragonbones/index.ts"],"names":[],"mappings":"AAGA,cAAc,mBAAmB,CAAA;AAEjC,wBAAgB,gBAAgB,SAE/B"}
|
|
@@ -1,87 +1,6 @@
|
|
|
1
|
-
import { EventTypes } from 'entityx-ts';
|
|
2
|
-
import { NodeComp } from '../core/NodeComp';
|
|
3
|
-
import { ComponentX, render } from '../core/decorator';
|
|
4
1
|
import { GameWorld } from '../gworld';
|
|
5
|
-
import {
|
|
6
|
-
export
|
|
7
|
-
armature;
|
|
8
|
-
setAnimation(name, playTimes = 0) {
|
|
9
|
-
if (this.armature) {
|
|
10
|
-
if (this.armature.animation.lastAnimationName === name)
|
|
11
|
-
return;
|
|
12
|
-
this.armature.animation.gotoAndPlayByTime(name, 0, playTimes);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
getAnimationName() {
|
|
16
|
-
return this.armature.animation.lastAnimationName;
|
|
17
|
-
}
|
|
18
|
-
// setSkeletonData(data: string) {
|
|
19
|
-
// const skel = this.node.instance as CocosArmatureDisplay;
|
|
20
|
-
// const atlas = data.replace('.json', '.atlas');
|
|
21
|
-
// skel.armature.armatureData(data, atlas, this.node.scale);
|
|
22
|
-
// }
|
|
23
|
-
setFLipX(isFlipX) {
|
|
24
|
-
this.armature._armature.flipX = isFlipX;
|
|
25
|
-
}
|
|
26
|
-
setTimeScale(timeScale) {
|
|
27
|
-
this.armature.animation.timeScale = timeScale;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export class DragonBonesSystem {
|
|
31
|
-
configure(event_manager) {
|
|
32
|
-
event_manager.subscribe(EventTypes.ComponentAdded, DragonBonesComp, async ({ entity }) => {
|
|
33
|
-
const dbComp = entity.getComponent(DragonBonesComp);
|
|
34
|
-
const { data, animation, playTimes = 0, timeScale = 1 } = dbComp.props;
|
|
35
|
-
const { atlas, skeleton, texture } = data;
|
|
36
|
-
const dragon = new PixiDragonBonesSprite({
|
|
37
|
-
skeleton,
|
|
38
|
-
atlas,
|
|
39
|
-
texture,
|
|
40
|
-
animationName: animation,
|
|
41
|
-
playTimes,
|
|
42
|
-
// width: dataSkel.armature[0].aabb.width,
|
|
43
|
-
// height: dataSkel.armature[0].aabb.height,
|
|
44
|
-
});
|
|
45
|
-
dbComp.armature = dragon._armatureDisplay;
|
|
46
|
-
// console.log('armature', dbComp.armature)
|
|
47
|
-
dbComp.armature.animation.timeScale = timeScale;
|
|
48
|
-
dbComp.node = entity.assign(new NodeComp(dragon, entity));
|
|
49
|
-
if (dbComp.props.onAnimationStart)
|
|
50
|
-
dbComp.armature.addDBEventListener(dragonBones.EventObject.START, () => {
|
|
51
|
-
if (dbComp.node.active && dbComp.enabled)
|
|
52
|
-
dbComp.props.onAnimationStart();
|
|
53
|
-
}, dbComp);
|
|
54
|
-
if (dbComp.props.onAnimationEnd)
|
|
55
|
-
dbComp.armature.addDBEventListener(dragonBones.EventObject.COMPLETE, () => {
|
|
56
|
-
if (dbComp.node.active && dbComp.enabled)
|
|
57
|
-
dbComp.props.onAnimationEnd();
|
|
58
|
-
}, dbComp);
|
|
59
|
-
if (dbComp.props.onAnimationComplete)
|
|
60
|
-
dbComp.armature.addDBEventListener(dragonBones.EventObject.LOOP_COMPLETE, () => {
|
|
61
|
-
if (dbComp.node.active && dbComp.enabled)
|
|
62
|
-
dbComp.props.onAnimationComplete();
|
|
63
|
-
}, dbComp);
|
|
64
|
-
});
|
|
65
|
-
event_manager.subscribe(EventTypes.ComponentRemoved, DragonBonesComp, ({ component }) => {
|
|
66
|
-
const dbComp = component;
|
|
67
|
-
dbComp.armature.removeDBEventListener();
|
|
68
|
-
dbComp.node.removeAllChildren();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// update(entities: EntityManager, events: EventManager, dt: number)
|
|
72
|
-
update(entities) {
|
|
73
|
-
// console.log('update', dt)
|
|
74
|
-
const animations = entities.entities_with_components(DragonBonesComp);
|
|
75
|
-
animations.forEach((ett) => {
|
|
76
|
-
const dbComp = ett.getComponent(DragonBonesComp);
|
|
77
|
-
if (dbComp.node && dbComp.node.active) {
|
|
78
|
-
dbComp.node.instance.updateTexture();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
2
|
+
import { DragonBonesSystem } from './DragonBonesSystem';
|
|
3
|
+
export * from './DragonBonesComp';
|
|
83
4
|
export function setupDragonBones() {
|
|
84
5
|
GameWorld.Instance.addSystemAndUpdate(DragonBonesSystem);
|
|
85
6
|
}
|
|
86
|
-
export * from './PixiDragonBonesSprite';
|
|
87
|
-
Object.defineProperty(DragonBonesComp.prototype, 'render', { value: render });
|