@safe-engine/cocos 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +61 -0
- package/@types/safex.d.ts +103 -0
- package/README.md +10 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +24 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosFactory.js +231 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosSlot.js +385 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
- package/dist/dragonbones/dragonBones.d.ts +3 -0
- package/dist/dragonbones/dragonBones.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones.js +4788 -0
- package/dist/dragonbones/index.d.ts +20 -0
- package/dist/dragonbones/index.d.ts.map +1 -0
- package/dist/dragonbones/index.js +112 -0
- package/dist/gworld/components/AnimationComponent.d.ts +65 -0
- package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
- package/dist/gworld/components/AnimationComponent.js +141 -0
- package/dist/gworld/components/CollideComponent.d.ts +64 -0
- package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
- package/dist/gworld/components/CollideComponent.js +266 -0
- package/dist/gworld/components/EnhancedComponent.d.ts +21 -0
- package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/components/EnhancedComponent.js +50 -0
- package/dist/gworld/components/GUIComponent.d.ts +62 -0
- package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
- package/dist/gworld/components/GUIComponent.js +158 -0
- package/dist/gworld/components/NoRenderComponent.d.ts +36 -0
- package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/NoRenderComponent.js +74 -0
- package/dist/gworld/components/NodeComp.d.ts +184 -0
- package/dist/gworld/components/NodeComp.d.ts.map +1 -0
- package/dist/gworld/components/NodeComp.js +425 -0
- package/dist/gworld/components/RenderComponent.d.ts +53 -0
- package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/RenderComponent.js +158 -0
- package/dist/gworld/core/Scene.d.ts +5 -0
- package/dist/gworld/core/Scene.d.ts.map +1 -0
- package/dist/gworld/core/Scene.js +38 -0
- package/dist/gworld/core/decorator.d.ts +9 -0
- package/dist/gworld/core/decorator.d.ts.map +1 -0
- package/dist/gworld/core/decorator.js +43 -0
- package/dist/gworld/index.d.ts +8 -0
- package/dist/gworld/index.d.ts.map +1 -0
- package/dist/gworld/index.js +43 -0
- package/dist/gworld/systems/AnimationSystem.d.ts +7 -0
- package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
- package/dist/gworld/systems/AnimationSystem.js +38 -0
- package/dist/gworld/systems/CollideSystem.d.ts +19 -0
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
- package/dist/gworld/systems/CollideSystem.js +183 -0
- package/dist/gworld/systems/GUISystem.d.ts +7 -0
- package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
- package/dist/gworld/systems/GUISystem.js +147 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts +7 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/NoRenderSystem.js +93 -0
- package/dist/gworld/systems/RenderSystem.d.ts +15 -0
- package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/RenderSystem.js +115 -0
- package/dist/helper/Intersection.d.ts +6 -0
- package/dist/helper/Intersection.d.ts.map +1 -0
- package/dist/helper/Intersection.js +117 -0
- package/dist/helper/NodePool.d.ts +9 -0
- package/dist/helper/NodePool.d.ts.map +1 -0
- package/dist/helper/NodePool.js +29 -0
- package/dist/helper/action.d.ts +9 -0
- package/dist/helper/action.d.ts.map +1 -0
- package/dist/helper/action.js +34 -0
- package/dist/helper/director.d.ts +3 -0
- package/dist/helper/director.d.ts.map +1 -0
- package/dist/helper/director.js +10 -0
- package/dist/helper/html-text-parser.d.ts +30 -0
- package/dist/helper/html-text-parser.d.ts.map +1 -0
- package/dist/helper/html-text-parser.js +354 -0
- package/dist/helper/math.d.ts +4 -0
- package/dist/helper/math.d.ts.map +1 -0
- package/dist/helper/math.js +9 -0
- package/dist/helper/utils.d.ts +14 -0
- package/dist/helper/utils.d.ts.map +1 -0
- package/dist/helper/utils.js +81 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/polyfills.d.ts +54 -0
- package/dist/polyfills.d.ts.map +1 -0
- package/dist/polyfills.js +168 -0
- package/dist/spine/CCSkeleton.d.ts +2 -0
- package/dist/spine/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/CCSkeleton.js +380 -0
- package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/CCSkeletonAnimation.js +353 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +229 -0
- package/dist/spine/CCSkeletonTexture.d.ts +2 -0
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/CCSkeletonTexture.js +98 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +317 -0
- package/package.json +32 -0
|
@@ -0,0 +1,98 @@
|
|
|
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"));
|
|
38
|
+
/****************************************************************************
|
|
39
|
+
Copyright (c) 2017 Chukong Technologies Inc.
|
|
40
|
+
|
|
41
|
+
http://www.cocos2d-x.org
|
|
42
|
+
|
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
45
|
+
in the Software without restriction, including without limitation the rights
|
|
46
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
48
|
+
furnished to do so, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
The above copyright notice and this permission notice shall be included in
|
|
51
|
+
all copies or substantial portions of the Software.
|
|
52
|
+
|
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
54
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
55
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
56
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
57
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
58
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
59
|
+
THE SOFTWARE.
|
|
60
|
+
****************************************************************************/
|
|
61
|
+
var gworld = gworld || {};
|
|
62
|
+
gworld.SkeletonTexture = function (image) {
|
|
63
|
+
// spine.Texture.call(this, image);
|
|
64
|
+
};
|
|
65
|
+
cc.inherits(gworld.SkeletonTexture, spine.Texture);
|
|
66
|
+
cc.extend(gworld.SkeletonTexture.prototype, {
|
|
67
|
+
name: 'gworld.SkeletonTexture',
|
|
68
|
+
_texture: null,
|
|
69
|
+
setRealTexture: function (tex) {
|
|
70
|
+
this._texture = tex;
|
|
71
|
+
},
|
|
72
|
+
getRealTexture: function () {
|
|
73
|
+
return this._texture;
|
|
74
|
+
},
|
|
75
|
+
setFilters: function (minFilter, magFilter) {
|
|
76
|
+
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
77
|
+
var gl = cc._renderContext;
|
|
78
|
+
this.bind();
|
|
79
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
80
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
setWraps: function (uWrap, vWrap) {
|
|
84
|
+
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
85
|
+
var gl = cc._renderContext;
|
|
86
|
+
this.bind();
|
|
87
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
|
|
88
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
dispose: function () { },
|
|
92
|
+
bind: function () {
|
|
93
|
+
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
94
|
+
cc.glBindTexture2D(this._texture);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
exports.SkeletonTexture = gworld.SkeletonTexture;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCSkeletonWebGLRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonWebGLRenderCmd.ts"],"names":[],"mappings":"AAyWA,eAAO,MAAM,cAAc,KAAwB,CAAA"}
|
|
@@ -0,0 +1,317 @@
|
|
|
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"));
|
|
38
|
+
/****************************************************************************
|
|
39
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
40
|
+
|
|
41
|
+
http://www.cocos2d-x.org
|
|
42
|
+
|
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
45
|
+
in the Software without restriction, including without limitation the rights
|
|
46
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
48
|
+
furnished to do so, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
The above copyright notice and this permission notice shall be included in
|
|
51
|
+
all copies or substantial portions of the Software.
|
|
52
|
+
|
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
54
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
55
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
56
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
57
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
58
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
59
|
+
THE SOFTWARE.
|
|
60
|
+
****************************************************************************/
|
|
61
|
+
var gworld = gworld || {};
|
|
62
|
+
(function () {
|
|
63
|
+
gworld.WebGLRenderCmd = function (renderableObject) {
|
|
64
|
+
this._rootCtor(renderableObject);
|
|
65
|
+
this._needDraw = true;
|
|
66
|
+
this._matrix = new cc.math.Matrix4();
|
|
67
|
+
this._matrix.identity();
|
|
68
|
+
this._currTexture = null;
|
|
69
|
+
this._currBlendFunc = {};
|
|
70
|
+
this.vertexType = cc.renderer.VertexType.CUSTOM;
|
|
71
|
+
this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_SPRITE_POSITION_TEXTURECOLOR));
|
|
72
|
+
};
|
|
73
|
+
var proto = (gworld.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype));
|
|
74
|
+
proto.constructor = gworld.WebGLRenderCmd;
|
|
75
|
+
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;
|
|
80
|
+
locSkeleton.r = color.r / 255;
|
|
81
|
+
locSkeleton.g = color.g / 255;
|
|
82
|
+
locSkeleton.b = color.b / 255;
|
|
83
|
+
locSkeleton.a = this._displayedOpacity / 255;
|
|
84
|
+
if (premultiAlpha) {
|
|
85
|
+
locSkeleton.r *= locSkeleton.a;
|
|
86
|
+
locSkeleton.g *= locSkeleton.a;
|
|
87
|
+
locSkeleton.b *= locSkeleton.a;
|
|
88
|
+
}
|
|
89
|
+
var debugSlotsInfo = null;
|
|
90
|
+
if (this._node._debugSlots) {
|
|
91
|
+
debugSlotsInfo = [];
|
|
92
|
+
}
|
|
93
|
+
for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) {
|
|
94
|
+
slot = locSkeleton.drawOrder[i];
|
|
95
|
+
if (!slot.attachment)
|
|
96
|
+
continue;
|
|
97
|
+
attachment = slot.attachment;
|
|
98
|
+
// get the vertices length
|
|
99
|
+
var vertCount = 0;
|
|
100
|
+
if (attachment instanceof spine.RegionAttachment) {
|
|
101
|
+
vertCount = 6; // a quad = two triangles = six vertices
|
|
102
|
+
}
|
|
103
|
+
else if (attachment instanceof spine.MeshAttachment) {
|
|
104
|
+
vertCount = attachment.regionUVs.length / 2;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// no vertices to render
|
|
110
|
+
if (vertCount === 0) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
var regionTextureAtlas = node.getTextureAtlas(attachment);
|
|
114
|
+
// Broken for changing batch info
|
|
115
|
+
var batchBroken;
|
|
116
|
+
if (regionTextureAtlas.texture) {
|
|
117
|
+
this._currTexture = regionTextureAtlas.texture.getRealTexture();
|
|
118
|
+
batchBroken = cc.renderer._updateBatchedInfo(this._currTexture, this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._glProgramState);
|
|
119
|
+
}
|
|
120
|
+
// keep the same logic with RendererWebGL.js, avoid vertex data overflow
|
|
121
|
+
var uploadAll = vertexDataOffset / 6 + vertCount > (cc.BATCH_VERTEX_COUNT - 200) * 0.5;
|
|
122
|
+
// Broken for vertex data overflow
|
|
123
|
+
if (!batchBroken && uploadAll) {
|
|
124
|
+
// render the cached data
|
|
125
|
+
cc.renderer._batchRendering();
|
|
126
|
+
batchBroken = true;
|
|
127
|
+
}
|
|
128
|
+
if (batchBroken) {
|
|
129
|
+
vertexDataOffset = 0;
|
|
130
|
+
}
|
|
131
|
+
// update the vertex buffer
|
|
132
|
+
var slotDebugPoints = null;
|
|
133
|
+
if (attachment instanceof spine.RegionAttachment) {
|
|
134
|
+
slotDebugPoints = this._uploadRegionAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
|
|
135
|
+
}
|
|
136
|
+
else if (attachment instanceof spine.MeshAttachment) {
|
|
137
|
+
this._uploadMeshAttachmentData(attachment, slot, premultiAlpha, f32buffer, ui32buffer, vertexDataOffset);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (this._node._debugSlots) {
|
|
143
|
+
debugSlotsInfo[i] = slotDebugPoints;
|
|
144
|
+
}
|
|
145
|
+
// update the index buffer
|
|
146
|
+
if (attachment instanceof spine.RegionAttachment) {
|
|
147
|
+
cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.TRIANGLE);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
cc.renderer._increaseBatchingSize(vertCount, cc.renderer.VertexType.CUSTOM, attachment.triangles);
|
|
151
|
+
}
|
|
152
|
+
// update the index data
|
|
153
|
+
vertexDataOffset += vertCount * 6;
|
|
154
|
+
}
|
|
155
|
+
if (node._debugBones || node._debugSlots) {
|
|
156
|
+
// flush previous vertices
|
|
157
|
+
cc.renderer._batchRendering();
|
|
158
|
+
var wt = this._worldTransform, mat = this._matrix.mat;
|
|
159
|
+
mat[0] = wt.a;
|
|
160
|
+
mat[4] = wt.c;
|
|
161
|
+
mat[12] = wt.tx;
|
|
162
|
+
mat[1] = wt.b;
|
|
163
|
+
mat[5] = wt.d;
|
|
164
|
+
mat[13] = wt.ty;
|
|
165
|
+
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
|
|
166
|
+
cc.current_stack.stack.push(cc.current_stack.top);
|
|
167
|
+
cc.current_stack.top = this._matrix;
|
|
168
|
+
var drawingUtil = cc._drawingUtil;
|
|
169
|
+
if (node._debugSlots && debugSlotsInfo && debugSlotsInfo.length > 0) {
|
|
170
|
+
// Slots.
|
|
171
|
+
drawingUtil.setDrawColor(0, 0, 255, 255);
|
|
172
|
+
drawingUtil.setLineWidth(1);
|
|
173
|
+
for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
|
|
174
|
+
var points = debugSlotsInfo[i];
|
|
175
|
+
if (points) {
|
|
176
|
+
drawingUtil.drawPoly(points, 4, true);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (node._debugBones) {
|
|
181
|
+
// Bone lengths.
|
|
182
|
+
var bone = void 0;
|
|
183
|
+
drawingUtil.setLineWidth(2);
|
|
184
|
+
drawingUtil.setDrawColor(255, 0, 0, 255);
|
|
185
|
+
for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
|
|
186
|
+
bone = locSkeleton.bones[i];
|
|
187
|
+
var x = bone.data.length * bone.a + bone.worldX;
|
|
188
|
+
var y = bone.data.length * bone.c + bone.worldY;
|
|
189
|
+
drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y));
|
|
190
|
+
}
|
|
191
|
+
// Bone origins.
|
|
192
|
+
drawingUtil.setPointSize(4);
|
|
193
|
+
drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
|
|
194
|
+
for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
|
|
195
|
+
bone = locSkeleton.bones[i];
|
|
196
|
+
drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY));
|
|
197
|
+
if (i == 0) {
|
|
198
|
+
drawingUtil.setDrawColor(0, 255, 0, 255);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
cc.kmGLPopMatrix();
|
|
203
|
+
}
|
|
204
|
+
return 0;
|
|
205
|
+
};
|
|
206
|
+
proto._getBlendFunc = function (blendMode, premultiAlpha) {
|
|
207
|
+
var ret = this._currBlendFunc;
|
|
208
|
+
switch (blendMode) {
|
|
209
|
+
case spine.BlendMode.Normal:
|
|
210
|
+
ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
|
|
211
|
+
ret.dst = cc.ONE_MINUS_SRC_ALPHA;
|
|
212
|
+
break;
|
|
213
|
+
case spine.BlendMode.Additive:
|
|
214
|
+
ret.src = premultiAlpha ? cc.ONE : cc.SRC_ALPHA;
|
|
215
|
+
ret.dst = cc.ONE;
|
|
216
|
+
break;
|
|
217
|
+
case spine.BlendMode.Multiply:
|
|
218
|
+
ret.src = cc.DST_COLOR;
|
|
219
|
+
ret.dst = cc.ONE_MINUS_SRC_ALPHA;
|
|
220
|
+
break;
|
|
221
|
+
case spine.BlendMode.Screen:
|
|
222
|
+
ret.src = cc.ONE;
|
|
223
|
+
ret.dst = cc.ONE_MINUS_SRC_COLOR;
|
|
224
|
+
break;
|
|
225
|
+
default:
|
|
226
|
+
ret = this._node._blendFunc;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return ret;
|
|
230
|
+
};
|
|
231
|
+
proto._createChildFormSkeletonData = function () { };
|
|
232
|
+
proto._updateChild = function () { };
|
|
233
|
+
proto._uploadRegionAttachmentData = function (attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) {
|
|
234
|
+
// the vertices in format:
|
|
235
|
+
// [
|
|
236
|
+
// X1, Y1, C1R, C1G, C1B, C1A, U1, V1, // bottom left
|
|
237
|
+
// X2, Y2, C2R, C2G, C2B, C2A, U2, V2, // top left
|
|
238
|
+
// X3, Y3, C3R, C3G, C3B, C3A, U3, V3, // top right
|
|
239
|
+
// X4, Y4, C4R, C4G, C4B, C4A, U4, V4 // bottom right
|
|
240
|
+
// ]
|
|
241
|
+
//
|
|
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);
|
|
245
|
+
attachment.computeWorldVertices(slot, vertices, 0, 2);
|
|
246
|
+
var uvs = attachment.uvs;
|
|
247
|
+
// 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;
|
|
255
|
+
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;
|
|
258
|
+
// generate 6 vertices data (two triangles) from the quad vertices
|
|
259
|
+
// 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;
|
|
266
|
+
f32buffer[offset] = x;
|
|
267
|
+
f32buffer[offset + 1] = y;
|
|
268
|
+
f32buffer[offset + 2] = z;
|
|
269
|
+
ui32buffer[offset + 3] = color;
|
|
270
|
+
f32buffer[offset + 4] = uvs[srcIdx * 2];
|
|
271
|
+
f32buffer[offset + 5] = uvs[srcIdx * 2 + 1];
|
|
272
|
+
offset += 6;
|
|
273
|
+
}
|
|
274
|
+
if (this._node._debugSlots) {
|
|
275
|
+
// return the quad points info if debug slot enabled
|
|
276
|
+
var VERTEX = spine.RegionAttachment;
|
|
277
|
+
return [
|
|
278
|
+
cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
|
|
279
|
+
cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
|
|
280
|
+
cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]),
|
|
281
|
+
cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]),
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
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;
|
|
287
|
+
// get the vertex data
|
|
288
|
+
var verticesLength = attachment.worldVerticesLength;
|
|
289
|
+
var vertices = spine.Utils.setArraySize([], verticesLength, 0);
|
|
290
|
+
attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
|
|
291
|
+
var uvs = attachment.uvs;
|
|
292
|
+
// 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;
|
|
298
|
+
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;
|
|
307
|
+
f32buffer[offset] = x;
|
|
308
|
+
f32buffer[offset + 1] = y;
|
|
309
|
+
f32buffer[offset + 2] = z;
|
|
310
|
+
ui32buffer[offset + 3] = color;
|
|
311
|
+
f32buffer[offset + 4] = uvs[i];
|
|
312
|
+
f32buffer[offset + 5] = uvs[i + 1];
|
|
313
|
+
offset += 6;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
})();
|
|
317
|
+
exports.WebGLRenderCmd = gworld.WebGLRenderCmd;
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@safe-engine/cocos",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "safe-engine with cocos renderer support",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "@types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"@types"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clean:build": "rimraf ./dist",
|
|
16
|
+
"lint": "eslint . --ext .js,.ts --fix",
|
|
17
|
+
"build": "tsc"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/lodash": "^4.17.14",
|
|
21
|
+
"typescript": "^5.7.3"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@cocos/dragonbones-js": "^1.0.2",
|
|
25
|
+
"@esotericsoftware/spine-core": "^4.2.70",
|
|
26
|
+
"cocos-html5-ts": "^1.1.3",
|
|
27
|
+
"entityx-ts": "^1.0.0",
|
|
28
|
+
"lodash": "^4.17.21"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC"
|
|
32
|
+
}
|