@safe-engine/cocos 1.5.2 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/animation/AnimationComponent.d.ts +63 -0
  2. package/dist/animation/AnimationComponent.d.ts.map +1 -0
  3. package/dist/animation/AnimationComponent.js +119 -0
  4. package/dist/animation/AnimationSystem.d.ts +6 -0
  5. package/dist/animation/AnimationSystem.d.ts.map +1 -0
  6. package/dist/animation/AnimationSystem.js +22 -0
  7. package/dist/animation/index.d.ts +2 -0
  8. package/dist/animation/index.d.ts.map +1 -0
  9. package/dist/animation/index.js +7 -0
  10. package/dist/app.d.ts.map +1 -1
  11. package/dist/app.js +40 -65
  12. package/dist/box2d-wasm/ContactListener.d.ts +12 -0
  13. package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
  14. package/dist/box2d-wasm/ContactListener.js +64 -0
  15. package/dist/box2d-wasm/PhysicsComponent.d.ts +50 -0
  16. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
  17. package/dist/box2d-wasm/PhysicsComponent.js +16 -0
  18. package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
  19. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
  20. package/dist/box2d-wasm/PhysicsSprite.js +51 -0
  21. package/dist/box2d-wasm/PhysicsSystem.d.ts +15 -0
  22. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
  23. package/dist/box2d-wasm/PhysicsSystem.js +139 -0
  24. package/dist/box2d-wasm/debugDraw.d.ts +66 -0
  25. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
  26. package/dist/box2d-wasm/debugDraw.js +210 -0
  27. package/dist/box2d-wasm/index.d.ts +6 -0
  28. package/dist/box2d-wasm/index.d.ts.map +1 -0
  29. package/dist/box2d-wasm/index.js +10 -0
  30. package/dist/collider/CollideComponent.js +98 -159
  31. package/dist/collider/CollideSystem.js +63 -79
  32. package/dist/collider/index.d.ts +1 -1
  33. package/dist/collider/index.d.ts.map +1 -1
  34. package/dist/collider/index.js +11 -9
  35. package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
  36. package/dist/dragonbones/index.js +38 -68
  37. package/dist/gworld/components/AnimationComponent.d.ts +2 -2
  38. package/dist/gworld/components/CollideComponent.d.ts +3 -3
  39. package/dist/gworld/components/EnhancedComponent.js +29 -36
  40. package/dist/gworld/components/GUIComponent.js +50 -118
  41. package/dist/gworld/components/NoRenderComponent.js +25 -65
  42. package/dist/gworld/components/NodeComp.d.ts.map +1 -1
  43. package/dist/gworld/components/NodeComp.js +237 -317
  44. package/dist/gworld/components/RenderComponent.js +46 -104
  45. package/dist/gworld/core/NodePool.js +13 -20
  46. package/dist/gworld/core/Scene.js +11 -35
  47. package/dist/gworld/core/decorator.js +12 -42
  48. package/dist/gworld/index.js +13 -42
  49. package/dist/gworld/systems/CollideSystem.d.ts +1 -2
  50. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
  51. package/dist/gworld/systems/CollideSystem.js +2 -12
  52. package/dist/gworld/systems/GUISystem.js +105 -120
  53. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
  54. package/dist/gworld/systems/NoRenderSystem.js +70 -80
  55. package/dist/gworld/systems/RenderSystem.js +64 -78
  56. package/dist/helper/Intersection.js +33 -40
  57. package/dist/helper/action.js +8 -21
  58. package/dist/helper/director.js +2 -6
  59. package/dist/helper/math.js +9 -15
  60. package/dist/helper/utils.js +28 -37
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +20 -31
  64. package/dist/polyfills.js +69 -97
  65. package/dist/richtext/RichTextComp.js +27 -55
  66. package/dist/richtext/RichTextSystem.js +17 -25
  67. package/dist/richtext/html-text-parser.js +36 -40
  68. package/dist/richtext/index.js +5 -8
  69. package/dist/safex.js +1 -2
  70. package/dist/spine/CCSkeleton.d.ts.map +1 -1
  71. package/dist/spine/CCSkeleton.js +25 -61
  72. package/dist/spine/CCSkeletonAnimation.js +18 -54
  73. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
  74. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
  75. package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
  76. package/dist/spine/CCSkeletonTexture.js +4 -40
  77. package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
  78. package/dist/spine/index.js +37 -63
  79. package/package.json +4 -1
  80. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
  81. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
  82. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
  83. package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
  84. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
  85. package/dist/dragonbones/cocos/CocosFactory.js +0 -231
  86. package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
  87. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
  88. package/dist/dragonbones/cocos/CocosSlot.js +0 -385
  89. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
  90. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
  91. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
  92. package/dist/dragonbones/dragonBones.d.ts +0 -3
  93. package/dist/dragonbones/dragonBones.d.ts.map +0 -1
  94. package/dist/dragonbones/dragonBones.js +0 -4788
  95. package/dist/helper/NodePool.d.ts +0 -9
  96. package/dist/helper/NodePool.d.ts.map +0 -1
  97. package/dist/helper/NodePool.js +0 -29
@@ -1,9 +1,4 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var spine_core_1 = __importDefault(require("@esotericsoftware/spine-core"));
1
+ import * as spine from '@esotericsoftware/spine-core';
7
2
  /****************************************************************************
8
3
  Copyright (c) 2013-2014 Chukong Technologies Inc.
9
4
 
@@ -29,16 +24,16 @@ var spine_core_1 = __importDefault(require("@esotericsoftware/spine-core"));
29
24
  ****************************************************************************/
30
25
  var gworld = gworld || {};
31
26
  (function () {
32
- gworld.Skeleton.CanvasRenderCmd = function (renderableObject) {
27
+ gworld.CanvasRenderCmd = function (renderableObject) {
33
28
  this._rootCtor(renderableObject);
34
29
  this._needDraw = true;
35
30
  };
36
- var proto = (gworld.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
37
- proto.constructor = gworld.Skeleton.CanvasRenderCmd;
31
+ const proto = (gworld.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
32
+ proto.constructor = gworld.CanvasRenderCmd;
38
33
  proto.rendering = function (wrapper, scaleX, scaleY) {
39
- var node = this._node, i, n, slot, slotNode;
34
+ let node = this._node, i, n, slot, slotNode;
40
35
  wrapper = wrapper || cc._renderContext;
41
- var locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
36
+ const locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
42
37
  for (i = 0, n = drawOrder.length; i < n; i++) {
43
38
  slot = drawOrder[i];
44
39
  slotNode = slot._slotNode;
@@ -52,15 +47,15 @@ var gworld = gworld || {};
52
47
  return;
53
48
  wrapper.setTransform(this._worldTransform, scaleX, scaleY);
54
49
  wrapper.setGlobalAlpha(1);
55
- var attachment, drawingUtil = cc._drawingUtil;
50
+ let attachment, drawingUtil = cc._drawingUtil;
56
51
  if (node._debugSlots) {
57
52
  // Slots.
58
53
  drawingUtil.setDrawColor(0, 0, 255, 255);
59
54
  drawingUtil.setLineWidth(1);
60
- var points = [];
55
+ const points = [];
61
56
  for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
62
57
  slot = locSkeleton.drawOrder[i];
63
- if (!slot.attachment || !(slot.attachment instanceof spine_core_1.default.RegionAttachment))
58
+ if (!slot.attachment || !(slot.attachment instanceof spine.RegionAttachment))
64
59
  continue;
65
60
  attachment = slot.attachment;
66
61
  this._updateRegionAttachmentSlot(attachment, slot, points);
@@ -69,17 +64,17 @@ var gworld = gworld || {};
69
64
  }
70
65
  if (node._debugBones) {
71
66
  // Bone lengths.
72
- var bone = void 0;
67
+ let bone;
73
68
  drawingUtil.setLineWidth(2);
74
69
  drawingUtil.setDrawColor(255, 0, 0, 255);
75
70
  for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
76
71
  bone = locSkeleton.bones[i];
77
- var x = bone.data.length * bone.a + bone.worldX;
78
- var y = bone.data.length * bone.c + bone.worldY;
72
+ const x = bone.data.length * bone.a + bone.worldX;
73
+ const y = bone.data.length * bone.c + bone.worldY;
79
74
  drawingUtil.drawLine({ x: bone.worldX, y: bone.worldY }, { x: x, y: y });
80
75
  }
81
76
  // Bone origins.
82
- var pointSize = 4;
77
+ const pointSize = 4;
83
78
  drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
84
79
  for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
85
80
  bone = locSkeleton.bones[i];
@@ -101,9 +96,9 @@ var gworld = gworld || {};
101
96
  proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
102
97
  if (!points)
103
98
  return;
104
- var vertices = spine_core_1.default.Utils.setArraySize([], 8, 0);
99
+ const vertices = spine.Utils.setArraySize([], 8, 0);
105
100
  attachment.computeWorldVertices(slot, vertices, 0, 2);
106
- var VERTEX = spine_core_1.default.RegionAttachment;
101
+ const VERTEX = spine.RegionAttachment;
107
102
  points.length = 0;
108
103
  points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
109
104
  points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
@@ -111,27 +106,27 @@ var gworld = gworld || {};
111
106
  points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
112
107
  };
113
108
  proto._createChildFormSkeletonData = function () {
114
- var node = this._node;
115
- var locSkeleton = node._skeleton, spriteName, sprite;
116
- for (var i = 0, n = locSkeleton.slots.length; i < n; i++) {
117
- var slot = locSkeleton.slots[i], attachment = slot.attachment;
118
- var slotNode = new cc.Node();
109
+ const node = this._node;
110
+ let locSkeleton = node._skeleton, spriteName, sprite;
111
+ for (let i = 0, n = locSkeleton.slots.length; i < n; i++) {
112
+ const slot = locSkeleton.slots[i], attachment = slot.attachment;
113
+ const slotNode = new cc.Node();
119
114
  slot._slotNode = slotNode;
120
- if (attachment instanceof spine_core_1.default.RegionAttachment) {
115
+ if (attachment instanceof spine.RegionAttachment) {
121
116
  spriteName = attachment.name;
122
117
  sprite = this._createSprite(slot, attachment);
123
118
  slot.currentSprite = sprite;
124
119
  slot.currentSpriteName = spriteName;
125
120
  slotNode.addChild(sprite);
126
121
  }
127
- else if (attachment instanceof spine_core_1.default.MeshAttachment) {
122
+ else if (attachment instanceof spine.MeshAttachment) {
128
123
  //todo for mesh
129
124
  }
130
125
  }
131
126
  };
132
- var loaded = function (sprite, texture, attachment) {
133
- var rendererObject = attachment.region;
134
- var rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
127
+ const loaded = function (sprite, texture, attachment) {
128
+ const rendererObject = attachment.region;
129
+ const rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
135
130
  sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
136
131
  sprite._rect.width = attachment.width;
137
132
  sprite._rect.height = attachment.height;
@@ -140,9 +135,9 @@ var gworld = gworld || {};
140
135
  sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
141
136
  };
142
137
  proto._createSprite = function (slot, attachment) {
143
- var rendererObject = attachment.region;
144
- var texture = rendererObject.texture.getRealTexture();
145
- var sprite = new cc.Sprite();
138
+ const rendererObject = attachment.region;
139
+ const texture = rendererObject.texture.getRealTexture();
140
+ const sprite = new cc.Sprite();
146
141
  if (texture.isLoaded()) {
147
142
  loaded(sprite, texture, attachment);
148
143
  }
@@ -156,10 +151,10 @@ var gworld = gworld || {};
156
151
  return sprite;
157
152
  };
158
153
  proto._updateChild = function () {
159
- var locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
160
- var color = this._displayedColor, opacity = this._displayedOpacity;
161
- var i, n, selSprite, ax, ay;
162
- var slot, attachment, slotNode;
154
+ const locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
155
+ const color = this._displayedColor, opacity = this._displayedOpacity;
156
+ let i, n, selSprite, ax, ay;
157
+ let slot, attachment, slotNode;
163
158
  for (i = 0, n = slots.length; i < n; i++) {
164
159
  slot = slots[i];
165
160
  attachment = slot.attachment;
@@ -168,24 +163,24 @@ var gworld = gworld || {};
168
163
  slotNode.setVisible(false);
169
164
  continue;
170
165
  }
171
- if (attachment instanceof spine_core_1.default.RegionAttachment) {
166
+ if (attachment instanceof spine.RegionAttachment) {
172
167
  if (attachment.region) {
173
168
  if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
174
- var spriteName = attachment.name;
169
+ const spriteName = attachment.name;
175
170
  if (slot.currentSprite !== undefined)
176
171
  slot.currentSprite.setVisible(false);
177
172
  slot.sprites = slot.sprites || {};
178
173
  if (slot.sprites[spriteName] !== undefined)
179
174
  slot.sprites[spriteName].setVisible(true);
180
175
  else {
181
- var sprite = this._createSprite(slot, attachment);
176
+ const sprite = this._createSprite(slot, attachment);
182
177
  slotNode.addChild(sprite);
183
178
  }
184
179
  slot.currentSprite = slot.sprites[spriteName];
185
180
  slot.currentSpriteName = spriteName;
186
181
  }
187
182
  }
188
- var bone = slot.bone;
183
+ const bone = slot.bone;
189
184
  if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
190
185
  ax = attachment.x;
191
186
  ay = attachment.y;
@@ -212,11 +207,11 @@ var gworld = gworld || {};
212
207
  }
213
208
  //hack for sprite
214
209
  selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
215
- var r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
210
+ const r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
216
211
  selSprite.setColor(cc.color(r, g, b));
217
212
  selSprite._renderCmd._updateColor();
218
213
  }
219
- else if (attachment instanceof spine_core_1.default.MeshAttachment) {
214
+ else if (attachment instanceof spine.MeshAttachment) {
220
215
  // Can not render mesh
221
216
  }
222
217
  else {
@@ -227,3 +222,4 @@ var gworld = gworld || {};
227
222
  }
228
223
  };
229
224
  })();
225
+ export const CanvasRenderCmd = gworld.CanvasRenderCmd;
@@ -1,40 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SkeletonTexture = void 0;
37
- var spine = __importStar(require("@esotericsoftware/spine-core"));
1
+ import * as spine from '@esotericsoftware/spine-core';
38
2
  /****************************************************************************
39
3
  Copyright (c) 2017 Chukong Technologies Inc.
40
4
 
@@ -74,7 +38,7 @@ cc.extend(gworld.SkeletonTexture.prototype, {
74
38
  },
75
39
  setFilters: function (minFilter, magFilter) {
76
40
  if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
77
- var gl = cc._renderContext;
41
+ const gl = cc._renderContext;
78
42
  this.bind();
79
43
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
80
44
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
@@ -82,7 +46,7 @@ cc.extend(gworld.SkeletonTexture.prototype, {
82
46
  },
83
47
  setWraps: function (uWrap, vWrap) {
84
48
  if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
85
- var gl = cc._renderContext;
49
+ const gl = cc._renderContext;
86
50
  this.bind();
87
51
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
88
52
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
@@ -95,4 +59,4 @@ cc.extend(gworld.SkeletonTexture.prototype, {
95
59
  }
96
60
  },
97
61
  });
98
- exports.SkeletonTexture = gworld.SkeletonTexture;
62
+ export const SkeletonTexture = gworld.SkeletonTexture;
@@ -1,40 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.WebGLRenderCmd = void 0;
37
- var spine = __importStar(require("@esotericsoftware/spine-core"));
1
+ import * as spine from '@esotericsoftware/spine-core';
38
2
  /****************************************************************************
39
3
  Copyright (c) 2013-2014 Chukong Technologies Inc.
40
4
 
@@ -70,13 +34,13 @@ var gworld = gworld || {};
70
34
  this.vertexType = cc.renderer.VertexType.CUSTOM;
71
35
  this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR));
72
36
  };
73
- var proto = (gworld.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype));
37
+ const proto = (gworld.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype));
74
38
  proto.constructor = gworld.WebGLRenderCmd;
75
39
  proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
76
- var node = this._node;
77
- var color = this._displayedColor, locSkeleton = node._skeleton;
78
- var attachment, slot, i, n;
79
- var premultiAlpha = node._premultipliedAlpha;
40
+ const node = this._node;
41
+ const color = this._displayedColor, locSkeleton = node._skeleton;
42
+ let attachment, slot, i, n;
43
+ const premultiAlpha = node._premultipliedAlpha;
80
44
  locSkeleton.r = color.r / 255;
81
45
  locSkeleton.g = color.g / 255;
82
46
  locSkeleton.b = color.b / 255;
@@ -86,7 +50,7 @@ var gworld = gworld || {};
86
50
  locSkeleton.g *= locSkeleton.a;
87
51
  locSkeleton.b *= locSkeleton.a;
88
52
  }
89
- var debugSlotsInfo = null;
53
+ let debugSlotsInfo = null;
90
54
  if (this._node._debugSlots) {
91
55
  debugSlotsInfo = [];
92
56
  }
@@ -96,7 +60,7 @@ var gworld = gworld || {};
96
60
  continue;
97
61
  attachment = slot.attachment;
98
62
  // get the vertices length
99
- var vertCount = 0;
63
+ let vertCount = 0;
100
64
  if (attachment instanceof spine.RegionAttachment) {
101
65
  vertCount = 6; // a quad = two triangles = six vertices
102
66
  }
@@ -110,7 +74,7 @@ var gworld = gworld || {};
110
74
  if (vertCount === 0) {
111
75
  continue;
112
76
  }
113
- var regionTextureAtlas = node.getTextureAtlas(attachment);
77
+ const regionTextureAtlas = node.getTextureAtlas(attachment);
114
78
  // Broken for changing batch info
115
79
  var batchBroken;
116
80
  if (regionTextureAtlas.texture) {
@@ -118,7 +82,7 @@ var gworld = gworld || {};
118
82
  batchBroken = cc.renderer._updateBatchedInfo(this._currTexture, this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._glProgramState);
119
83
  }
120
84
  // keep the same logic with RendererWebGL.js, avoid vertex data overflow
121
- var uploadAll = vertexDataOffset / 6 + vertCount > (cc.BATCH_VERTEX_COUNT - 200) * 0.5;
85
+ const uploadAll = vertexDataOffset / 6 + vertCount > (cc.BATCH_VERTEX_COUNT - 200) * 0.5;
122
86
  // Broken for vertex data overflow
123
87
  if (!batchBroken && uploadAll) {
124
88
  // render the cached data
@@ -129,7 +93,7 @@ var gworld = gworld || {};
129
93
  vertexDataOffset = 0;
130
94
  }
131
95
  // update the vertex buffer
132
- var slotDebugPoints = null;
96
+ let slotDebugPoints = null;
133
97
  if (attachment instanceof spine.RegionAttachment) {
134
98
  slotDebugPoints = this._uploadRegionAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
135
99
  }
@@ -155,7 +119,7 @@ var gworld = gworld || {};
155
119
  if (node._debugBones || node._debugSlots) {
156
120
  // flush previous vertices
157
121
  cc.renderer._batchRendering();
158
- var wt = this._worldTransform, mat = this._matrix.mat;
122
+ const wt = this._worldTransform, mat = this._matrix.mat;
159
123
  mat[0] = wt.a;
160
124
  mat[4] = wt.c;
161
125
  mat[12] = wt.tx;
@@ -165,13 +129,13 @@ var gworld = gworld || {};
165
129
  cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
166
130
  cc.current_stack.stack.push(cc.current_stack.top);
167
131
  cc.current_stack.top = this._matrix;
168
- var drawingUtil = cc._drawingUtil;
132
+ const drawingUtil = cc._drawingUtil;
169
133
  if (node._debugSlots && debugSlotsInfo && debugSlotsInfo.length > 0) {
170
134
  // Slots.
171
135
  drawingUtil.setDrawColor(0, 0, 255, 255);
172
136
  drawingUtil.setLineWidth(1);
173
137
  for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
174
- var points = debugSlotsInfo[i];
138
+ const points = debugSlotsInfo[i];
175
139
  if (points) {
176
140
  drawingUtil.drawPoly(points, 4, true);
177
141
  }
@@ -179,13 +143,13 @@ var gworld = gworld || {};
179
143
  }
180
144
  if (node._debugBones) {
181
145
  // Bone lengths.
182
- var bone = void 0;
146
+ let bone;
183
147
  drawingUtil.setLineWidth(2);
184
148
  drawingUtil.setDrawColor(255, 0, 0, 255);
185
149
  for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
186
150
  bone = locSkeleton.bones[i];
187
- var x = bone.data.length * bone.a + bone.worldX;
188
- var y = bone.data.length * bone.c + bone.worldY;
151
+ const x = bone.data.length * bone.a + bone.worldX;
152
+ const y = bone.data.length * bone.c + bone.worldY;
189
153
  drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y));
190
154
  }
191
155
  // Bone origins.
@@ -204,7 +168,7 @@ var gworld = gworld || {};
204
168
  return 0;
205
169
  };
206
170
  proto._getBlendFunc = function (blendMode, premultiAlpha) {
207
- var ret = this._currBlendFunc;
171
+ let ret = this._currBlendFunc;
208
172
  switch (blendMode) {
209
173
  case spine.BlendMode.Normal:
210
174
  ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
@@ -239,30 +203,30 @@ var gworld = gworld || {};
239
203
  // X4, Y4, C4R, C4G, C4B, C4A, U4, V4 // bottom right
240
204
  // ]
241
205
  //
242
- var nodeColor = this._displayedColor;
243
- var nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
244
- var vertices = spine.Utils.setArraySize([], 8, 0);
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);
245
209
  attachment.computeWorldVertices(slot, vertices, 0, 2);
246
- var uvs = attachment.uvs;
210
+ const uvs = attachment.uvs;
247
211
  // get the colors data
248
- var skeleton = slot.bone.skeleton;
249
- var skeletonColor = skeleton.color;
250
- var slotColor = slot.color;
251
- var regionColor = attachment.color;
252
- var alpha = skeletonColor.a * slotColor.a * regionColor.a;
253
- var multiplier = premultipliedAlpha ? alpha : 1;
254
- var colors = attachment.tempColor;
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;
255
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);
256
- var 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;
257
- var offset = vertexDataOffset;
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;
258
222
  // generate 6 vertices data (two triangles) from the quad vertices
259
223
  // using two angles : (0, 1, 2) & (0, 2, 3)
260
- for (var i = 0; i < 6; i++) {
261
- var srcIdx = i < 4 ? i % 3 : i - 2;
262
- var vx = vertices[srcIdx * 2], vy = vertices[srcIdx * 2 + 1];
263
- var x = vx * wa + vy * wc + wx, y = vx * wb + vy * wd + wy;
264
- var r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
265
- var color = (a << 24) | (b << 16) | (g << 8) | r;
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;
266
230
  f32buffer[offset] = x;
267
231
  f32buffer[offset + 1] = y;
268
232
  f32buffer[offset + 2] = z;
@@ -273,7 +237,7 @@ var gworld = gworld || {};
273
237
  }
274
238
  if (this._node._debugSlots) {
275
239
  // return the quad points info if debug slot enabled
276
- var VERTEX = spine.RegionAttachment;
240
+ const VERTEX = spine.RegionAttachment;
277
241
  return [
278
242
  cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
279
243
  cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
@@ -283,27 +247,27 @@ var gworld = gworld || {};
283
247
  }
284
248
  };
285
249
  proto._uploadMeshAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
286
- var 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;
250
+ const wt = this._worldTransform, wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d, wx = wt.tx, wy = wt.ty, z = this._node.vertexZ;
287
251
  // get the vertex data
288
- var verticesLength = attachment.worldVerticesLength;
289
- var vertices = spine.Utils.setArraySize([], verticesLength, 0);
252
+ const verticesLength = attachment.worldVerticesLength;
253
+ const vertices = spine.Utils.setArraySize([], verticesLength, 0);
290
254
  attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
291
- var uvs = attachment.uvs;
255
+ const uvs = attachment.uvs;
292
256
  // get the colors data
293
- var skeleton = slot.bone.skeleton;
294
- var skeletonColor = skeleton.color, slotColor = slot.color, meshColor = attachment.color;
295
- var alpha = skeletonColor.a * slotColor.a * meshColor.a;
296
- var multiplier = premultipliedAlpha ? alpha : 1;
297
- var colors = attachment.tempColor;
257
+ const skeleton = slot.bone.skeleton;
258
+ const skeletonColor = skeleton.color, slotColor = slot.color, meshColor = attachment.color;
259
+ const alpha = skeletonColor.a * slotColor.a * meshColor.a;
260
+ const multiplier = premultipliedAlpha ? alpha : 1;
261
+ const colors = attachment.tempColor;
298
262
  colors.set(skeletonColor.r * slotColor.r * meshColor.r * multiplier, skeletonColor.g * slotColor.g * meshColor.g * multiplier, skeletonColor.b * slotColor.b * meshColor.b * multiplier, alpha);
299
- var offset = vertexDataOffset;
300
- var nodeColor = this._displayedColor;
301
- var nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
302
- for (var i = 0, n = vertices.length; i < n; i += 2) {
303
- var vx = vertices[i], vy = vertices[i + 1];
304
- var x = vx * wa + vy * wb + wx, y = vx * wc + vy * wd + wy;
305
- var r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
306
- var color = (a << 24) | (b << 16) | (g << 8) | r;
263
+ let offset = vertexDataOffset;
264
+ const nodeColor = this._displayedColor;
265
+ const nodeR = nodeColor.r, nodeG = nodeColor.g, nodeB = nodeColor.b, nodeA = this._displayedOpacity;
266
+ for (let i = 0, n = vertices.length; i < n; i += 2) {
267
+ const vx = vertices[i], vy = vertices[i + 1];
268
+ const x = vx * wa + vy * wb + wx, y = vx * wc + vy * wd + wy;
269
+ const r = colors.r * nodeR, g = colors.g * nodeG, b = colors.b * nodeB, a = colors.a * nodeA;
270
+ const color = (a << 24) | (b << 16) | (g << 8) | r;
307
271
  f32buffer[offset] = x;
308
272
  f32buffer[offset + 1] = y;
309
273
  f32buffer[offset + 2] = z;
@@ -314,4 +278,4 @@ var gworld = gworld || {};
314
278
  }
315
279
  };
316
280
  })();
317
- exports.WebGLRenderCmd = gworld.WebGLRenderCmd;
281
+ export const WebGLRenderCmd = gworld.WebGLRenderCmd;
@@ -1,73 +1,47 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.SpineSystem = exports.SpineSkeleton = void 0;
19
- exports.setupSpine = setupSpine;
20
- var entityx_ts_1 = require("entityx-ts");
21
- var __1 = require("..");
22
- var CCSkeletonAnimation_1 = require("./CCSkeletonAnimation");
23
- var SpineSkeleton = /** @class */ (function (_super) {
24
- __extends(SpineSkeleton, _super);
25
- function SpineSkeleton() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- SpineSkeleton.prototype.setAnimation = function (name, loop) {
29
- if (loop === void 0) { loop = false; }
30
- var skel = this.node.instance;
1
+ import { EventTypes } from 'entityx-ts';
2
+ import { ComponentX, NodeComp } from '..';
3
+ import { SkeletonAnimation } from './CCSkeletonAnimation';
4
+ export class SpineSkeleton extends ComponentX {
5
+ data;
6
+ skin;
7
+ animation;
8
+ loop;
9
+ timeScale;
10
+ setAnimation(name, loop = false) {
11
+ const skel = this.node.instance;
31
12
  if (skel.setAnimation) {
32
13
  skel.setAnimation(0, name, loop);
33
14
  }
34
- };
35
- SpineSkeleton.prototype.setSkeletonData = function (data) {
36
- var skel = this.node.instance;
37
- var atlas = data.replace('.json', '.atlas');
15
+ }
16
+ setSkeletonData(data) {
17
+ const skel = this.node.instance;
18
+ const atlas = data.replace('.json', '.atlas');
38
19
  skel.initWithArgs(data, atlas, this.node.scale);
39
- };
40
- return SpineSkeleton;
41
- }(__1.ComponentX));
42
- exports.SpineSkeleton = SpineSkeleton;
43
- var SpineSystem = /** @class */ (function () {
44
- function SpineSystem() {
45
- this.onAddSpineSkeleton = function (_a) {
46
- var entity = _a.entity;
47
- var spineComp = entity.getComponent(SpineSkeleton);
48
- var _b = spineComp.props, data = _b.data, skin = _b.skin, animation = _b.animation, loop = _b.loop, _c = _b.timeScale, timeScale = _c === void 0 ? 1 : _c;
49
- var atlas = data.atlas, skeleton = data.skeleton;
50
- // cc.log(skel, atlas);
51
- var node = CCSkeletonAnimation_1.SkeletonAnimation.createWithJsonFile(skeleton, atlas, timeScale);
52
- if (skin) {
53
- node.setSkin(skin);
54
- }
55
- if (animation) {
56
- node.setAnimation(0, animation, loop);
57
- }
58
- spineComp.node = entity.assign(new __1.NodeComp(node, entity));
59
- };
60
20
  }
61
- SpineSystem.prototype.configure = function (event_manager) {
62
- event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, SpineSkeleton, this.onAddSpineSkeleton);
21
+ }
22
+ export class SpineSystem {
23
+ configure(event_manager) {
24
+ event_manager.subscribe(EventTypes.ComponentAdded, SpineSkeleton, this.onAddSpineSkeleton);
25
+ }
26
+ onAddSpineSkeleton = ({ entity }) => {
27
+ const spineComp = entity.getComponent(SpineSkeleton);
28
+ const { data, skin, animation, loop, timeScale = 1 } = spineComp.props;
29
+ const { atlas, skeleton } = data;
30
+ // cc.log(skel, atlas);
31
+ const node = SkeletonAnimation.createWithJsonFile(skeleton, atlas, timeScale);
32
+ if (skin) {
33
+ node.setSkin(skin);
34
+ }
35
+ if (animation) {
36
+ node.setAnimation(0, animation, loop);
37
+ }
38
+ spineComp.node = entity.assign(new NodeComp(node, entity));
63
39
  };
64
- SpineSystem.prototype.update = function () {
40
+ update() {
65
41
  // throw new Error('Method not implemented.');
66
- };
67
- return SpineSystem;
68
- }());
69
- exports.SpineSystem = SpineSystem;
70
- function setupSpine(world) {
42
+ }
43
+ }
44
+ export function setupSpine(world) {
71
45
  world.systems.add(SpineSystem);
72
46
  // world.listUpdate.push(SpineSystem)
73
47
  world.systems.configureOnce(SpineSystem);
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@safe-engine/cocos",
3
- "version": "1.5.2",
3
+ "version": "1.5.5",
4
4
  "description": "safe-engine with cocos renderer support",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "files": [
@@ -21,6 +22,8 @@
21
22
  "typescript": "^5.7.3"
22
23
  },
23
24
  "dependencies": {
25
+ "@esotericsoftware/spine-core": "^4.2.84",
26
+ "box2d-wasm": "^7.0.0",
24
27
  "entityx-ts": "^2.2.1"
25
28
  },
26
29
  "author": "",