更新文档到 2.4.9-v1.0.0

This commit is contained in:
SmallMain 2022-07-05 18:10:58 +08:00
parent b89bb48ce7
commit 746d9ce5cd
267 changed files with 8506 additions and 5284 deletions

View File

@ -24,15 +24,21 @@
### 更新版本号
1. 修改 `engine``jsb-adapter``cocos2d-x` 根目录的 `VERSION` 文件。
1. 修改 `engine``jsb-adapter``cocos2d-x` 根目录的 `VERSION.md` 文件。
2. 修改 `sp.js``version` 属性。
3. 修改 `extension``package.json` 文件中的 `version` 属性。
4. 修改文档中相关的版本号。
### 更新 DEMO
1.编译 `web-mobile``web-desktop` 项目。
2.将这两个项目目录放在名称是当前版本号的目录中,然后放在 `docs/static/demo` 中。
3.修改文档中相关的演示项目路径。
### 准备压缩包
1.将对 engine 的改动整合到 Git Patch然后将 Patch 按相应的引擎目录放置在仓库的 `patches` 目录中,并放在压缩包根目录内。
2.将三个引擎目录放到压缩包根目录内,包括类型提示文件。
2.编译 JavaScript 引擎和原生模拟器,再将三个引擎目录放到压缩包根目录内,包括类型提示文件。
3.将 `service-pack-support` 目录放在压缩包根目录内。
4.更新文档的更新日志。
@ -43,8 +49,8 @@
## 版本计划
- Spine 组件使用多纹理材质时支持 useTint 选项
- Char 模式因为 bleed 问题只能复用完全相同宽高的区域,试着增加一个选项,能够先用空纹理覆盖,之所以做选项是不知道性能消耗大不大
- 引擎扩展,初始项目没有 settings.json 会导致扩展无法正常运行
- 原生平台上支持 Spine 与其它组件合批
- 补充原理文档
- 适配原生平台
- Char 模式因为 bleed 问题只能复用完全相同宽高的区域,试着增加一个选项,能够先用空纹理覆盖,之所以做选项是不知道性能消耗大不大
- 新增静态合批:在一个节点树的根节点挂上一个组件,该组件会快照这个节点树并显示为一张图片,然后只接管渲染,不影响其它逻辑,也可以选择直接删除掉被快照的所有节点

View File

@ -2,8 +2,6 @@
![logo](/docs/static/img/logo2.png)
> 该项目当前为内部预览版只提供未适配原生平台cocos2d-x、jsb-adapter的 Cocos Creator v2.4.5 版本
这是一个提供 Cocos Creator 引擎特性增强、修复与优化的**开源非官方服务包**。
该项目使用自定义引擎的方式在符合原始引擎架构设计的基础上为 Cocos Creator 引擎加入新的特性、修复已知问题以及性能优化。
@ -41,18 +39,27 @@
## 重要特性
- **支持多纹理渲染**(多纹理材质、多纹理合批)
- **支持高 DPI 文本渲染**Label、RichText 组件)
- **重构动态合图**(支持自动多纹理合批、优化算法、复用废弃空间等特性)
- **重构 Label 组件的 CHAR 缓存模式**(支持自动多纹理合批、多图集、复用废弃空间等特性)
- **Spine 组件支持与其它组件合批、合入动态图集与 SpriteFrame 换装**
![demo1](/docs/static/demo-imgs/demo1.png)
> 服务包对引擎的改动完全开源,每个改动会带有原理说明文档,当你发现问题时请与我们进行反馈,如果你有兴致,可以默默帅气地提交一个 PR帮助我们一起完善这个项目。
- **支持高 DPI 文本渲染**Label、RichText 组件)
![demo4](/docs/static/demo-imgs/demo4.png)
- **重构动态合图**(支持自动多纹理合批、优化算法、复用废弃空间等特性)
![demo2](/docs/static/demo-imgs/demo2.png)
- **重构 Label 组件的 CHAR 缓存模式**(支持自动多纹理合批、多图集、复用废弃空间等特性)
![demo3](/docs/static/demo-imgs/demo3.png)
- **Spine 组件支持与其它组件合批、合入动态图集与 SpriteFrame 换装**
![demo5](/docs/static/demo-imgs/demo5.png)
## 功能演示
[Web Desktop 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html)
[Web Desktop 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-desktop/index.html)
[Web Mobile 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-mobile/index.html)(请将设备横屏)
[Web Mobile 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-mobile/index.html)(请将设备横屏)
> 服务包对引擎的改动完全开源,每个改动会带有原理说明文档,当你发现问题时请与我们进行反馈,如果你有兴致,可以默默帅气地提交一个 PR帮助我们一起完善这个项目。
## 使用方法
@ -105,4 +112,4 @@
### 启动 Cocos Creator 报 Error: Can not parse this input:undefined 错误
没有找到服务包的内置资源,请记得安装配套的引擎扩展
这是你可能忘记安装配套的引擎扩展,所以没有找到服务包的内置资源导致的报错

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "db4cffdc-d84c-4572-9dda-3d00e0d6302c",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": "2",

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "50a4982f-e892-44a2-9d49-202a0a10a446",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.25",
"ver": "1.0.27",
"uuid": "3edf42b2-00b8-4d91-9b6d-cae5b403a114",
"importer": "effect",
"compiledShaders": [
{
"glsl1": {

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "cbc55b3e-df40-4e8f-9499-8ee247cdbf84",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,5 +1,6 @@
{
"ver": "1.1.0",
"ver": "1.1.2",
"uuid": "e8aa5e1c-0730-4ebe-81a1-e7fa0db9be7d",
"importer": "ttf-font",
"subMetas": {}
}

View File

@ -1,6 +1,7 @@
{
"ver": "2.1.0",
"ver": "2.1.2",
"uuid": "80011fce-9411-4ea1-a8d3-f7d86d2d8789",
"importer": "bitmap-font",
"textureUuid": "45be59f3-5655-4369-9e9f-455c81d2ddd9",
"fontSize": 64,
"subMetas": {}

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "45be59f3-5655-4369-9e9f-455c81d2ddd9",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"normalFont": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "926aac08-9aad-4893-b1ab-052167293176",
"importer": "sprite-frame",
"rawTextureUuid": "45be59f3-5655-4369-9e9f-455c81d2ddd9",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "e59a44db-4029-4fa6-96af-71fc9321ed0e",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "c11dfdd2-97c6-409c-9c0f-fdfa681f16a9",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112479313": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "a766c72a-5fe2-4221-9452-d79edb33286a",
"importer": "sprite-frame",
"rawTextureUuid": "c11dfdd2-97c6-409c-9c0f-fdfa681f16a9",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "6231041a-75a5-4af2-a40d-f27e9498901a",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112514006": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "85c932be-f6c8-48a3-b450-7d0d530c4522",
"importer": "sprite-frame",
"rawTextureUuid": "6231041a-75a5-4af2-a40d-f27e9498901a",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "398d85b3-4934-44c0-8d8e-3812b99f015e",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112526123": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "09a373ff-f600-4ffd-873b-027c54059f90",
"importer": "sprite-frame",
"rawTextureUuid": "398d85b3-4934-44c0-8d8e-3812b99f015e",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "d06d24ff-c18a-4940-82f9-4fe3c2ab8e96",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112538161": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "705578c6-1342-4c52-a1a5-8b48e60a64c5",
"importer": "sprite-frame",
"rawTextureUuid": "d06d24ff-c18a-4940-82f9-4fe3c2ab8e96",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "6843f00b-0ef4-4b7c-aac0-42ee42635e55",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112548981": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "87ffc647-0445-4890-a78d-c666a5ae7f6b",
"importer": "sprite-frame",
"rawTextureUuid": "6843f00b-0ef4-4b7c-aac0-42ee42635e55",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "702455ac-9b92-4dd7-b143-cb02342dbe48",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112563832": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "d006ef1c-d8c0-4228-973e-98a056ce3b09",
"importer": "sprite-frame",
"rawTextureUuid": "702455ac-9b92-4dd7-b143-cb02342dbe48",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "1c8a3cc1-a452-4276-848d-2bdf30e6852a",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655112624336": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "80dbdc44-7f81-47cb-8f5d-5a8e8d2bc73b",
"importer": "sprite-frame",
"rawTextureUuid": "1c8a3cc1-a452-4276-848d-2bdf30e6852a",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "a9ecf19b-0a3b-4d8e-bfe1-614049509de9",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1655799093442": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "345a6df9-6652-4102-980a-cadc95156857",
"importer": "sprite-frame",
"rawTextureUuid": "a9ecf19b-0a3b-4d8e-bfe1-614049509de9",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "5a439075-0bd8-494f-8742-e6398c12d1b7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.3",
"ver": "1.0.5",
"uuid": "2c0c62f8-3805-4dd1-96c4-977c36bab4fc",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "d791af13-cba7-4b15-a4e6-9d2b72b5ba01",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,5 +1,6 @@
{
"ver": "1.0.1",
"ver": "1.0.3",
"uuid": "69163ff4-f84e-4d78-8ea7-946f62007fcd",
"importer": "asset",
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.3",
"ver": "1.2.5",
"uuid": "9374ce8a-ae46-427f-9760-3694307fb4fa",
"importer": "spine",
"textures": [
"804e11b5-bf4f-4a78-ac4a-8443e7166be1"
],

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "804e11b5-bf4f-4a78-ac4a-8443e7166be1",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"huatuo": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "b539b334-af1d-460c-a18d-de4e55947d2c",
"importer": "sprite-frame",
"rawTextureUuid": "804e11b5-bf4f-4a78-ac4a-8443e7166be1",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -0,0 +1,13 @@
shengxing_kuang.png
size: 180,351
format: RGBA8888
filter: Linear,Linear
repeat: none
fx_frame_red
rotate: false
xy: 2, 2
size: 176, 347
orig: 180, 351
offset: 2, 2
index: -1

View File

@ -0,0 +1,6 @@
{
"ver": "1.0.3",
"uuid": "37fc5ad1-36a0-4089-a773-f530ea4a9471",
"importer": "asset",
"subMetas": {}
}

View File

@ -0,0 +1 @@
{"skeleton":{"hash":"X8GrJN5Hvt74DISCwkkMDigOeyA","spine":"3.8.99","x":-180,"y":-351,"width":360,"height":702,"images":"./images/","audio":""},"bones":[{"name":"root"},{"name":"fx_frame","parent":"root"}],"slots":[{"name":"fx_frame","bone":"fx_frame","color":"ffffff00","dark":"000000","attachment":"fx_frame_red","blend":"additive"}],"skins":[{"name":"default","attachments":{"fx_frame":{"fx_frame_red":{"scaleX":2,"scaleY":2,"width":180,"height":351}}}}],"animations":{"shengxing_kuang_r":{"slots":{"fx_frame":{"twoColor":[{"light":"4aff91c6","dark":"009a3e","curve":0.25,"c3":0.75},{"time":0.5,"light":"49ff9100","dark":"009a3e"}]}}},"shengxing_kuang_s":{"slots":{"fx_frame":{"twoColor":[{"light":"ffffffc6","dark":"fc00ff","curve":0.25,"c3":0.75},{"time":0.5,"light":"ffffff00","dark":"fc00ff"}]}}},"shengxing_kuang_sr":{"slots":{"fx_frame":{"twoColor":[{"light":"ffffffc6","dark":"ff7300","curve":0.25,"c3":0.75},{"time":0.5,"light":"ffffff00","dark":"ff7300"}]}}},"shengxing_kuang_ssr":{"slots":{"fx_frame":{"twoColor":[{"light":"ffffffc5","dark":"000000","curve":0.25,"c3":0.75},{"time":0.5,"light":"ffffff00","dark":"000000"}]}}}}}

View File

@ -0,0 +1,10 @@
{
"ver": "1.2.5",
"uuid": "34efd27a-22e4-4ecf-bad9-8626699fadf2",
"importer": "spine",
"textures": [
"aa62bd8a-67ec-4f0e-a78b-b111d42b1440"
],
"scale": 1,
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "aa62bd8a-67ec-4f0e-a78b-b111d42b1440",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 180,
"height": 351,
"platformSettings": {},
"subMetas": {
"shengxing_kuang": {
"ver": "1.0.6",
"uuid": "0719c0e4-f113-4665-b72b-1c0ab994f6a0",
"importer": "sprite-frame",
"rawTextureUuid": "aa62bd8a-67ec-4f0e-a78b-b111d42b1440",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 2,
"width": 176,
"height": 347,
"rawWidth": 180,
"rawHeight": 351,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.3",
"ver": "1.2.5",
"uuid": "bcd99389-a393-426e-b234-157c62b44bc4",
"importer": "spine",
"textures": [
"d9c4530a-ef05-45c1-b012-eb4686f4c70f"
],

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "d9c4530a-ef05-45c1-b012-eb4686f4c70f",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"spineboy": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "f23f461c-0a3b-470e-a79b-9ee329e02319",
"importer": "sprite-frame",
"rawTextureUuid": "d9c4530a-ef05-45c1-b012-eb4686f4c70f",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,5 +1,6 @@
{
"ver": "2.0.0",
"ver": "2.0.2",
"uuid": "b63a4c13-b26d-4b2b-972f-453c057a18b2",
"importer": "text",
"subMetas": {}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "ec375606-0adb-4461-aa8a-c7e374bc920b",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "e311a003-c0a1-4ff9-9983-2154de145eb7",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -26,6 +26,11 @@ export default class Home extends cc.Component {
this.prefabs = this.objects.children.concat();
this.objects.removeAllChildren(false);
// Native 暂不支持 Spine 组件与其它组件合批
if (CC_JSB) {
this.prefabs = this.prefabs.filter(v => !v.getComponent(sp.Skeleton));
}
this.objectNumSlider.node.on('slide', (slider: cc.Slider) => {
const offset = (this.nums[1] - this.nums[0]) * slider.progress;
this.num = this.nums[0] + Math.ceil(offset);

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "fae4abc1-6681-4884-b234-b65d986d909e",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "853f5bb2-1b9a-451e-911a-5de5ed6b530b",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "cab4af66-dc74-41b5-8826-79b3a30ba99a",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}

View File

@ -15,4 +15,6 @@ export default class Main extends cc.Component {
cc.sp.labelRetinaScale = 2;
cc.sp.charAtlasAutoBatchCount = 2;
cc.macro.CLEANUP_IMAGE_CACHE = false;
cc.dynamicAtlasManager.maxFrameSize = 2048;

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "2454f641-d633-4d4d-b624-73baf25e6af5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "1f1fc03d-012f-470f-bf1d-5108b0b2d09f",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "6aa6d587-b168-40f9-b961-78e28fc4e9a7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "805c842a-631c-48df-a8bc-2381a7ca3674",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "77844f44-c0da-4c94-a97f-fac1ab844551",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"1": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "c4f9ea14-b9a8-4039-ae25-982ff81e4762",
"importer": "sprite-frame",
"rawTextureUuid": "77844f44-c0da-4c94-a97f-fac1ab844551",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "b6161231-4d65-475c-a6bb-a8199e851e88",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"etc1_rgb_a": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "ea8530c6-52b6-4157-863e-8be26c953b96",
"importer": "sprite-frame",
"rawTextureUuid": "b6161231-4d65-475c-a6bb-a8199e851e88",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "eb72a5a2-8837-4f45-a24a-2486eef5fb78",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"png": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "0ae51d4d-4f69-43c6-a708-da9c2d81f6f5",
"importer": "sprite-frame",
"rawTextureUuid": "eb72a5a2-8837-4f45-a24a-2486eef5fb78",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "22247785-ef30-4b66-a9d2-ebcaf6a7f6e8",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"pvrtc2_rgb_a": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "41673f76-dab9-4965-9999-9c566a3f154a",
"importer": "sprite-frame",
"rawTextureUuid": "22247785-ef30-4b66-a9d2-ebcaf6a7f6e8",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "438c0fd3-74ca-4503-b2bc-2088cd6dbf4c",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"sheep_down_0": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "8f1f3994-e88e-4406-a8e9-1c46f45e5de2",
"importer": "sprite-frame",
"rawTextureUuid": "438c0fd3-74ca-4503-b2bc-2088cd6dbf4c",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "100eba2c-cfa2-4fb0-a5ac-a95f9b461fc0",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"sheep_jump_2": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "2d3ce116-db4a-424c-bb3b-f5cd16c99569",
"importer": "sprite-frame",
"rawTextureUuid": "100eba2c-cfa2-4fb0-a5ac-a95f9b461fc0",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "44999d18-51d1-4017-9ea6-98dcad8ecdf5",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"sheep_jump_3": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "b4f1cb90-0aa4-4c2d-a233-7fd2357d36d6",
"importer": "sprite-frame",
"rawTextureUuid": "44999d18-51d1-4017-9ea6-98dcad8ecdf5",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "2.3.5",
"ver": "2.3.7",
"uuid": "7a788430-6621-4bd5-86ce-0957a216dd69",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
@ -12,8 +13,9 @@
"platformSettings": {},
"subMetas": {
"sheep_run_1": {
"ver": "1.0.4",
"ver": "1.0.6",
"uuid": "555112d2-35fe-4adc-8c99-05ecdf88c29a",
"importer": "sprite-frame",
"rawTextureUuid": "7a788430-6621-4bd5-86ce-0957a216dd69",
"trimType": "auto",
"trimThreshold": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "145bba41-1962-49ee-aec9-08fb154e8bf2",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "3e918f03-10af-4509-8958-78bfa3be6ad0",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "6021871d-94b0-46eb-babf-799b228ea695",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "c5f3051e-1b4f-4384-939c-b838bcb8f5bf",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -28,6 +28,9 @@
},
"texture5": {
"__uuid__": "d9c4530a-ef05-45c1-b012-eb4686f4c70f"
},
"texture6": {
"__uuid__": "aa62bd8a-67ec-4f0e-a78b-b111d42b1440"
}
}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.3",
"ver": "1.0.5",
"uuid": "0e00cf72-1eb0-457b-83d2-0171cc1cd97e",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "b420e7e4-907e-46c1-b7dd-4796fb1edebe",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "21700e21-cd6e-4f4e-88f8-c97c886e2e5c",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "76663793-b023-4931-89fb-febc115c2a43",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "51588566-10c7-4926-847c-4b69bf536e7b",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -436,7 +436,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "fbSLTYNutL174TDvzvU3nT",
"sync": false
@ -689,7 +689,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "7bbZkXUthKFpkeTLu7Uq1L",
"sync": false
@ -797,7 +797,7 @@
"_N$debugBones": false,
"_N$debugMesh": false,
"_N$useTint": false,
"_N$enableBatch": false,
"_N$enableBatch": true,
"_N$autoSwitchMaterial": 0,
"_N$allowDynamicAtlas": 0,
"_id": ""
@ -808,7 +808,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "61gMCsdq9POrIJoQLY+PPC",
"sync": false
@ -851,7 +851,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "08CQVCWaVPeLehXD9SK0Mz",
"sync": false
@ -1101,7 +1101,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "02Dr9jm5FDT5rrHE9he5tC",
"sync": false
@ -1173,7 +1173,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "b6JHPAtQpGgpx4Ld6CjPLs",
"sync": false
@ -1266,7 +1266,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "7fPVLMrpJFs6JBCXaQeyw2",
"sync": false
@ -1516,7 +1516,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "af40R7NOBLV4dST86rj08s",
"sync": false
@ -1588,7 +1588,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "cdT6mmSeFBvoVdKbkDM3sx",
"sync": false
@ -1681,7 +1681,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "ffH62SPyxFdq/E/BRFN4Qw",
"sync": false
@ -1931,7 +1931,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "f266YXrhtBuJSJ4WrL3o2U",
"sync": false
@ -2003,7 +2003,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "5dgAOFIUdIGaUKPwvIV/pr",
"sync": false
@ -2096,7 +2096,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "82yna7uEpKUoZdYNueETrY",
"sync": false
@ -2107,7 +2107,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "ecYMQYD9NOl7LadhXHQHYH",
"sync": false
@ -2189,7 +2189,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "98B5382ANHgKQw5BkMsWAq",
"sync": false
@ -2227,7 +2227,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "645yltQ0dFpbIcIgDazPDc",
"sync": false
@ -2410,7 +2410,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "29pI3SelxAU6ODrNe5LS2g",
"sync": false
@ -2531,7 +2531,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "c2cC2kA1NNeozY+5ZzkcSY",
"sync": false
@ -2603,7 +2603,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "b5RxDsAgFOW6xOyBdbz2rI",
"sync": false
@ -2683,7 +2683,7 @@
"__id__": 1
},
"asset": {
"__uuid__": "03129ae1-98e5-4264-a51b-6f95f23d742a"
"__id__": 0
},
"fileId": "",
"sync": false

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "03129ae1-98e5-4264-a51b-6f95f23d742a",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -20,12 +20,15 @@ export default class SpineSkin extends cc.Component {
boys: cc.Node[] = [];
datas: sp.SkeletonData[] = [];
protected start(): void {
const boySpine = this.boy.getComponentInChildren(sp.Skeleton);
const newSkeletonData = boySpine.skeletonData.clone();
boySpine.skeletonData = newSkeletonData;
boySpine.animation = 'attack';
this.datas.push(newSkeletonData);
this.boys.push(this.boy);
this.addBoyBtn.on('click', () => {
@ -41,20 +44,29 @@ export default class SpineSkin extends cc.Component {
newBoy.getComponentInChildren(sp.Skeleton).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE);
newBoy.getComponentInChildren(cc.Label).string = `Spine - Cache`;
}
this.datas.push(newBoySpine.skeletonData);
this.boys.push(newBoy);
});
this.removeBoyBtn.on('click', () => {
if (this.boys.length > 1) {
this.datas[this.datas.length - 1].destroy();
this.boys[this.boys.length - 1].destroy();
this.datas.length -= 1;
this.boys.length -= 1;
}
});
this.randomChangeBtn.on('click', () => {
const boy = this.boys[this.boys.length - 1].getComponentInChildren(sp.Skeleton);
boy.setRegion('Head', 'Head', sp.SkeletonData.createRegion(this.heads[Math.floor(Math.random() * (this.heads.length))]));
boy.setRegionData('Head', 'Head', new sp.RegionData(this.heads[Math.floor(Math.random() * (this.heads.length))]));
});
}
protected onDestroy(): void {
for (const data of this.datas) {
data.destroy();
}
}
}

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "27990422-853f-43c5-a2c7-52900cb9edef",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "5149d793-c991-4dbd-84f5-dbf9b470f470",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "8939e8e9-2c8c-469a-8631-1eef214f141b",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "f48ef4d1-7483-4868-8096-115ae0431c76",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "59d30214-6082-40ab-96d5-2704f05b10b5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.0.8",
"ver": "1.1.0",
"uuid": "0f37373d-8dc4-40cb-a343-5e7761491c53",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@ -1,6 +1,7 @@
{
"ver": "1.1.2",
"ver": "1.1.3",
"uuid": "0574009e-3e43-4b85-a325-89f9dede6c68",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,

View File

@ -1,6 +1,7 @@
{
"ver": "1.2.9",
"ver": "1.3.2",
"uuid": "e267c12a-39ac-41db-9e97-de8e196c296d",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,

View File

@ -1,7 +1,7 @@
{
"engine": "cocos2d-html5",
"packages": "packages",
"version": "2.4.5",
"version": "2.4.9",
"name": "cocos-service-pack-demo",
"id": "00fac3aa-a82e-4242-8505-128adae1c6c7",
"isNew": false

View File

@ -16,8 +16,8 @@
"mainIsRemote": false,
"optimizeHotUpdate": false,
"md5Cache": true,
"nativeMd5Cache": true,
"encryptJs": true,
"nativeMd5Cache": false,
"encryptJs": false,
"xxteaKey": "24d00175-09c0-4c",
"zipCompressJs": true,
"fb-instant-games": {},
@ -51,5 +51,6 @@
"recordPath": ""
},
"appBundle": false,
"agreements": {}
"agreements": {},
"includeAnySDK": false
}

View File

@ -45,7 +45,7 @@
"width": 960,
"height": 640
},
"last-module-event-record-time": 1655460658806,
"last-module-event-record-time": 1656689574771,
"assets-sort-type": "name",
"facebook": {
"enable": false,
@ -58,5 +58,8 @@
}
},
"preview-port": 7456,
"clear-simulator-cache": true
"clear-simulator-cache": true,
"migrate-history": [
"cloud-function"
]
}

View File

@ -42,8 +42,6 @@ description: "需掌握一定的自定义引擎知识。"
如果你的项目不需要在原生平台上运行,则只定制 JavaScript 引擎即可。
如果你的项目需要在原生模拟器中预览,可能需要编译模拟器,更多详情可阅读官方的 [自定义引擎](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/engine-customization.html) 文档。
:::
### 2.安装引擎扩展
@ -60,7 +58,7 @@ description: "需掌握一定的自定义引擎知识。"
服务包需要使用名为 `sp` 的 AssetBundle 存放资源,如果你的项目有使用 AssetBundle请**确保该名称未被占用**。
没有必要将这个 Asset Bundle 设为远程包或者 Zip 压缩,里面只是一个多纹理 Effect 着色器资源。
没有必要将这个 Asset Bundle 设为远程包或者 Zip 压缩,里面只 Effect 着色器资源。
更多详情可阅读官方的 [安装扩展](https://docs.cocos.com/creator/2.4/manual/zh/extension/install-and-share.html) 文档。

View File

@ -25,10 +25,25 @@ hide_title: true
## 重要特性
- **支持多纹理渲染**(多纹理材质、多纹理合批)
![demo1](/demo-imgs/demo1.png)
- **支持高 DPI 文本渲染**Label、RichText 组件)
![demo4](/demo-imgs/demo4.png)
- **重构动态合图**(支持自动多纹理合批、优化算法、复用废弃空间等特性)
![demo2](/demo-imgs/demo2.png)
- **重构 Label 组件的 CHAR 缓存模式**(支持自动多纹理合批、多图集、复用废弃空间等特性)
![demo3](/demo-imgs/demo3.png)
- **Spine 组件支持与其它组件合批、合入动态图集与 SpriteFrame 换装**
![demo5](/demo-imgs/demo5.png)
## 功能演示
[Web Desktop 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-desktop/index.html)
[Web Mobile 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-mobile/index.html)(请将设备横屏)
:::note 提示
@ -36,12 +51,6 @@ hide_title: true
:::
## 功能演示
[Web Desktop 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html)
[Web Mobile 演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-mobile/index.html)(请将设备横屏)
## 使用方法
请阅读文档的 [安装指南](./installation-guide/installation-intro.mdx) 与 [入门教程](./start-guide/start-guide-intro.mdx)。
@ -93,4 +102,4 @@ hide_title: true
### 启动 Cocos Creator 报 Error: Can not parse this input:undefined 错误
没有找到服务包的内置资源,请记得安装配套的引擎扩展
这是你可能忘记安装配套的引擎扩展,所以没有找到服务包的内置资源导致的报错

View File

@ -31,19 +31,19 @@ cc.sp.labelRetinaScale = 2; // 渲染文本时纹理的缩放倍数,默认
官方文档中介绍了替换 attachment 对象进行换装的方法,但如果动画中有切换 attachment 的关键帧,这种方法就失效了。
还有一种方法是替换 attachment 的 region 对象来进行换装,但这种方法引擎没有直接支持,所以服务包对其进行了完善
还有一种方法是修改 attachment 的 region 对象来进行换装,但这种方法引擎没有直接支持,所以服务包对其进行了支持
只需要一句代码即可使用 cc.SpriteFrame 替换指定 attachment 的 region 对象
只需要一句代码即可使用 cc.SpriteFrame 的数据修改 attachment 的 region 对象数据
```js
this.skel.setRegion('head', 'head', sp.SkeletonData.createRegion(spriteFrame));
skeletonComponent.setRegionData('Head', 'Head', new sp.RegionData(spriteFrame));
```
![changespine](./assets/changespine.png)
> 图片中是被换头的小男孩。
这样做是直接替换了 SkeletonData 中的数据,一般情况下所有使用该数据的 Spine 组件都会受到影响,但我们提供了克隆 SkeletonData 数据的接口,可前往 [Spine](../user-guide/spine/spine-intro.mdx) 文档了解更多详情。
这样做是直接修改了 SkeletonData 的数据,所有使用该数据的 Spine 组件都会受到影响(被换头),但我们提供了克隆 SkeletonData 数据的接口,可前往 [Spine](../user-guide/spine/spine-intro.mdx) 文档了解更多详情。
:::tip 提示

View File

@ -11,7 +11,7 @@ toc_max_heading_level: 5
---
## 创建多纹理材质
你可以正常创建一个材质文件Effect 选择内置的多纹理 Effect 着色器 `multi-2d-sprite` 即可。
你可以正常创建一个材质文件Effect 选择内置的多纹理 Effect 着色器 `multi-2d-universal` 即可。
![material-settings](./assets/material-settings.png)
@ -44,8 +44,6 @@ toc_max_heading_level: 5
Spine 组件使用多纹理材质时会强制勾选 `enableBatch`,因为不开启就不能合批,那也就没必要使用多纹理材质。
并且使用多纹理材质时暂时不支持染色效果,会强制关闭 `useTint` 选项。
:::
---
@ -55,7 +53,7 @@ Spine 组件使用多纹理材质时会强制勾选 `enableBatch`,因为不开
除了直接在内置着色器的基础上修改之外,任何着色器中如果存在一个宏 `USE_MULTI_TEXTURE = true`,则会被认为是多纹理材质。
[演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html) 中有自定义材质的示范代码。
[演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-desktop/index.html) 中有自定义材质的示范代码。
:::tip 提示

View File

@ -1,8 +1,14 @@
---
sidebar_position: 2
description: "随心所欲地控制动态合图的使用。"
description: "像其它渲染组件一样在 Spine 组件上使用动态合图。"
---
# 动态合图
你可以像其它渲染组件一样在 Spine 组件上使用动态合图,如果想了解有关动态合图的更多详情,可以阅读 [动态合图](../dynamic-batcher/dynamic-batcher-intro.mdx) 文档。
:::caution 注意
由于引擎实现差异,在原生平台上 Spine 暂不支持与其它组件合批。
:::

View File

@ -12,3 +12,11 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
你可以阅读下面的文档了解详情:
<DocCardList items={useCurrentSidebarCategory().items}/>
:::caution 注意
由于引擎这部分的 C++ 实现与 JavaScript 实现在一些细节上不太一样,比如一些内部函数的执行时机。
所以当你在 Web 平台上测试得出的一些结论请不要想当然地以为在原生平台上也一样,具体实现差异请阅读 Spine 的原理文档。
:::

View File

@ -1,83 +1,91 @@
---
sidebar_position: 2
description: "随心所欲地控制动态合图的使用。"
description: "随心所欲地更换 Spine 动画的部份纹理。"
---
# SpriteFrame 换装
引擎提供了一个替换插槽的 attachment 对象进行换装的方法,可以在 [Spine 组件参考](https://docs.cocos.com/creator/2.4/manual/zh/components/spine.html) 官方文档进行了解。
但是这种方法比较绕,并且 Spine 动画中有切换 attachment 的关键帧时会导致失效
但是使用替换插槽的 attachment 对象这种方法比较绕,并且 Spine 动画中有切换 attachment 的关键帧时这种方法就没用了
而 attachment 对象都持有着一个 region 对象region 对象有点类似引擎的 SpriteFrame所以我们可以通过更换 region 对象来进行换装。
而 attachment 对象持有一个 region 对象,这个对象类似引擎的 SpriteFrame所以我们可以通过修改 region 对象的数据来进行换装。
---
## Region 与 SpriteFrame 互转
## 认识 RegionData
首先服务包提供了 Region 与 SpriteFrame 对象相互转换的接口
请勿混淆 RegionData 与 regionRegionData 主要作为 SpriteFrame 和 region 对象之间的桥梁,实现两者的相互转换
SpriteFrame 转为 Region
SpriteFrame 转为 RegionData
```js
const region = sp.SkeletonData.createRegion(spriteFrame);
const regionData = new sp.RegionData(spriteFrame);
```
Region 转为 SpriteFrame
RegionData为 SpriteFrame
```js
const spriteFrame = sp.SkeletonData.createSpriteFrame(region);
const spriteFrame = regionData.toSpriteFrame();
```
将 attachment 对象的 region 数据转换为 RegionData
```js
const regionData = new sp.RegionData(attachment);
```
将 RegionData 数据更新到 attachment 对象上:
```js
regionData.assignToAttachment(attachment);
```
:::caution 注意
Spine 的 Region 支持 `0``90``180``270` 四种旋转角度,而 Cocos Creator 的 SpriteFrame 只支持 `0``270` 两种旋转角度,所以如果是 Region 转为 SpriteFrame 则可能导致方向不同的问题,**要进行换装的话使用的是 SpriteFrame 转为 Region所以不用担心这个问题。**
Spine 的 Region 支持 `0``90``180``270` 四种旋转角度,而 Cocos Creator 的 SpriteFrame 只支持 `0``270` 两种旋转角度,所以如果是 RegionData 转为 SpriteFrame 则可能导致方向不同的问题。
**要进行换装的话使用的是 SpriteFrame 转为 RegionData所以不用担心这个问题。**
:::
---
## 替换 Region 对象
## 使用 SpriteFrame 修改 Region 数据
使用上面的接口将 SpriteFrame 转为 Region 后,就可以调用服务包提供的设置 Region 接口来进行换装了。
虽然使用上面的 RegionData 即可实现使用 SpriteFrame 换装的需求,但我们还在 Spine 组件上提供了两个更方便的接口:
这个接口在 Spine 组件上:
只使用 `regionData.assignToAttachment(attachment)` 只会修改 SkeletonData 的数据,但不会触发 Spine 组件的渲染更新。
推荐直接使用:
```js
spine.setRegion(slotName, attachmentName, region);
skeletonComponent.setRegionData('Head', 'Head', new sp.RegionData(spriteFrame));
```
还有一个获取 Region 对象的接口:
在修改的同时刷新组件的渲染实现换装,并且不会打断当前正在播放的动画。
还提供了一个通过 attachment 名称获取 RegionData 的接口:
```js
a.getRegion(slotName, attachmentName);
```
将转换与设置的代码结合,你就可以使用一行代码进行换装了。
```
spine.setRegion('head', 'head', sp.SkeletonData.createRegion(spriteFrame));
```
效果就像这样:
---
## 注意事项
### 多实例问题
替换 Region 对象实际上是在 Spine 组件所使用的 SkeletonData 上进行替换的,所以所有使用这个 SkeletonData 进行渲染的组件都会被替换
由于是直接修改 Spine 组件所使用 SkeletonData 的 attachment 数据,所以所有 Spine 组件都会受到影响。
如果你只想替换其中一个组件的显示,那么就可以让所有组件都使用不同的 SkeletonData 进行渲染。
如果你只想替换其中一个组件,那么就可以克隆这个 SkeletonData 让每个组件都使用不同的 SkeletonData 实例进行渲染。
服务包提供了一个克隆接口来实现这个需求,你可以使用
服务包提供了一个克隆数据的接口来实现这个需求:
```js
const clonedSkeletonData = skeletonData.clone();
```
克隆 SkeletonData然后再进行换装赋值给 Spine 组件
使用以上代码克隆 SkeletonData 后再进行换装,赋值给 Spine 组件,那么替换操作就只会对这个 Spine 组件生效
---
以上所有用法你可以在 [演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html) 中找到示范代码。
以上所有用法你可以在 [演示项目](https://smallmain.github.io/cocos-service-pack/demo/v1.0.0/web-desktop/index.html) 中找到示范代码。

View File

@ -36,7 +36,7 @@ cc.sp.charAtlasAutoResetBeforeSceneLoad = false;
const material = cc.Label._shareAtlas.material;
```
获取或修改该材质。
获取、修改或替换该材质。
渲染时内部会先判断当前所使用的是否为多纹理材质,是的话判断是否能在材质纹理插槽中找到字符图集纹理,如果有一个判断不满足则会将组件的材质设为内部维护的材质。

View File

@ -7,7 +7,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Cocos Service Pack',
tagline: '给 Cocos Creator 加点料',
tagline: '提供 Cocos Creator 引擎特性增强、修复与优化的开源非官方服务包',
url: 'https://smallmain.github.io',
baseUrl: '/cocos-service-pack/',
onBrokenLinks: 'throw',
@ -93,51 +93,6 @@ const config = {
},
],
},
footer: {
style: 'dark',
links: [
// {
// title: 'Docs',
// items: [
// {
// label: 'Tutorial',
// to: '/docs/intro',
// },
// ],
// },
// {
// title: 'Community',
// items: [
// {
// label: 'Stack Overflow',
// href: 'https://stackoverflow.com/questions/tagged/docusaurus',
// },
// {
// label: 'Discord',
// href: 'https://discordapp.com/invite/docusaurus',
// },
// {
// label: 'Twitter',
// href: 'https://twitter.com/docusaurus',
// },
// ],
// },
// {
// title: 'More',
// items: [
// // {
// // label: 'Blog',
// // to: '/blog',
// // },
// {
// label: 'GitHub',
// href: 'https://github.com/facebook/docusaurus',
// },
// ],
// },
],
copyright: `Copyright © ${new Date().getFullYear()} Cocos Service Pack.`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,

View File

@ -10,32 +10,34 @@ type FeatureItem = {
const FeatureList: FeatureItem[] = [
{
title: 'Easy to Use',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
title: '性能提升',
description: (
<>
Docusaurus was designed from the ground up to be easily installed and
used to get your website up and running quickly.
</>
),
},
{
title: 'Focus on What Matters',
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
title: '完全开源',
description: (
<>
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go
ahead and move your docs into the <code>docs</code> directory.
JavaScript
</>
),
},
{
title: 'Powered by React',
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
title: '原生体验',
description: (
<>
Extend or customize your website layout by reusing React. Docusaurus can
be extended while reusing the same header and footer.
使
</>
),
},
{
title: '增强特性',
description: (
<>
DPI Spine
</>
),
},
@ -43,10 +45,10 @@ const FeatureList: FeatureItem[] = [
function Feature({title, Svg, description}: FeatureItem) {
return (
<div className={clsx('col col--4')}>
<div className="text--center">
<div className={clsx('col col--3')}>
{/* <div className="text--center">
<Svg className={styles.featureSvg} role="img" />
</div>
</div> */}
<div className="text--center padding-horiz--md">
<h3>{title}</h3>
<p>{description}</p>

View File

@ -19,6 +19,6 @@
.buttons {
display: flex;
align-items: center;
margin-top: 60px;
margin-top: 70px;
/* justify-content: center; */
}

View File

@ -11,59 +11,36 @@ function HomepageHeader() {
const { siteConfig } = useDocusaurusContext();
return (
//
<header className={clsx('hero', styles.heroBanner)} style={{ height: "80vh" }}>
<header className={clsx('hero', styles.heroBanner)} style={{ height: "60vh" }}>
<div className="container">
<div className="row">
<div className="col col--8">
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline + ""}</p>
<div>
<p style={{ color: 'var(--ifm-color-primary)', marginBottom: 2 }}>
<span className="badge badge--primary" style={{ marginRight: 8 }}>2D </span>
</p>
<p style={{ color: 'var(--ifm-color-primary)', marginBottom: 2 }}>
<span className="badge badge--primary" style={{ marginRight: 8 }}>2D </span>
DPI
</p>
<p style={{ color: 'var(--ifm-color-primary)', marginBottom: 2 }}>
<span className="badge badge--primary" style={{ marginRight: 8 }}></span>
</p>
<p style={{ color: 'var(--ifm-color-primary)', marginBottom: 2 }}>
<span className="badge badge--primary" style={{ marginRight: 8 }}>Label </span>
Char
</p>
<p style={{ color: 'var(--ifm-color-primary)', marginBottom: 2 }}>
<span className="badge badge--primary" style={{ marginRight: 8 }}>Spine </span>
SpriteFrame
</p>
</div>
<div className={styles.buttons}>
<Link
className="button button--primary button--lg"
to="/docs/intro"
style={{ marginRight: 20 }}
>
使
</Link>
<Link
className="button button--outline button--primary button--lg"
href='https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html'
style={{ marginRight: 20 }}
>
</Link>
<Link
className="button button--secondary button--lg"
href='https://github.com/smallmain/cocos-service-pack'>
<svg style={{ marginRight: 8, marginBottom: -4 }} stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 496 512" className="GithubIcon_3htU" height="1.2em" width="1.2em" xmlns="http://www.w3.org/2000/svg"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg>
GitHub
</Link>
</div>
</div>
<div className="col col--4">
<Rocket width={'30rem'} height={'26rem'} className='banner-img' />
<div class="row" style={{ justifyContent: "center" }}>
<h1 className="hero__title" style={{ marginLeft: 0, fontWeight: "500", letterSpacing: 3 }}>{siteConfig.title}</h1>
</div>
<div class="row" style={{ justifyContent: "center" }}>
<p className="hero__subtitle" style={{ fontSize: "18px" }}>{siteConfig.tagline}</p>
</div>
<div class="row" style={{ justifyContent: "center" }}>
<div className={styles.buttons}>
<Link
className="button button--primary button--lg"
to="/docs/intro"
style={{ marginRight: 20 }}
>
使
</Link>
<Link
className="button button--outline button--primary button--lg"
href='https://smallmain.github.io/cocos-service-pack/demo/v1.0.0-alpha/web-desktop/index.html'
style={{ marginRight: 20 }}
>
</Link>
<Link
className="button button--secondary button--lg"
href='https://github.com/smallmain/cocos-service-pack'>
<svg style={{ marginRight: 8, marginBottom: -4 }} stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 496 512" className="GithubIcon_3htU" height="1.2em" width="1.2em" xmlns="http://www.w3.org/2000/svg"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg>
GitHub
</Link>
</div>
</div>
</div>
@ -79,7 +56,7 @@ export default function Home(): JSX.Element {
description="Description will go into a meta tag in <head />">
<HomepageHeader />
<main>
{/* <HomepageFeatures /> */}
<HomepageFeatures />
</main>
</Layout>
);

BIN
docs/static/demo-imgs/demo1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
docs/static/demo-imgs/demo2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
docs/static/demo-imgs/demo3.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

BIN
docs/static/demo-imgs/demo4.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

BIN
docs/static/demo-imgs/demo5.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,321 +0,0 @@
[
1,
0,
0,
[
[
"cc.EffectAsset",
[
"_name",
"shaders",
"techniques"
],
0
]
],
[
[
0,
0,
1,
2,
4
]
],
[
[
0,
"multi-2d-sprite",
[
{
"hash": 3894394603,
"record": null,
"name": "multi-2d-sprite|vs|fs",
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#if USE_MULTI_TEXTURE\nin float a_texId;\nout float v_texId;\n#endif\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #if USE_MULTI_TEXTURE\n v_texId = a_texId;\n #endif\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#if USE_MULTI_TEXTURE\nin float v_texId;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_MULTI_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #else\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#if USE_MULTI_TEXTURE\nattribute float a_texId;\nvarying float v_texId;\n#endif\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #if USE_MULTI_TEXTURE\n v_texId = a_texId;\n #endif\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#if USE_MULTI_TEXTURE\nvarying float v_texId;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_MULTI_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture2D(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture2D(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture2D(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture2D(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture2D(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture2D(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture2D(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture2D(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture2D(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture2D(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture2D(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture2D(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture2D(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture2D(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #else\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "USE_TEXTURE",
"type": "boolean",
"defines": []
},
{
"name": "USE_MULTI_TEXTURE",
"type": "boolean",
"defines": [
"USE_TEXTURE"
]
},
{
"name": "CC_USE_MODEL",
"type": "boolean",
"defines": []
},
{
"name": "USE_ALPHA_TEST",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_ALPHA_ATLAS_texture",
"type": "boolean",
"defines": [
"USE_TEXTURE"
]
},
{
"name": "INPUT_IS_GAMMA",
"type": "boolean",
"defines": [
"USE_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture2",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture3",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture4",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture5",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture6",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture7",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "CC_USE_ALPHA_ATLAS_texture8",
"type": "boolean",
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
}
],
"blocks": [
{
"name": "ALPHA_TEST",
"binding": 0,
"members": [
{
"name": "alphaThreshold",
"type": 13,
"count": 1
}
],
"defines": [
"USE_ALPHA_TEST"
]
}
],
"samplers": [
{
"name": "texture",
"type": 29,
"count": 1,
"binding": 30,
"defines": [
"USE_TEXTURE"
]
},
{
"name": "texture2",
"type": 29,
"count": 1,
"binding": 31,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture3",
"type": 29,
"count": 1,
"binding": 32,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture4",
"type": 29,
"count": 1,
"binding": 33,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture5",
"type": 29,
"count": 1,
"binding": 34,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture6",
"type": 29,
"count": 1,
"binding": 35,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture7",
"type": 29,
"count": 1,
"binding": 36,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
},
{
"name": "texture8",
"type": 29,
"count": 1,
"binding": 37,
"defines": [
"USE_TEXTURE",
"USE_MULTI_TEXTURE"
]
}
]
}
],
[
{
"passes": [
{
"program": "multi-2d-sprite|vs|fs",
"blendState": {
"targets": [
{
"blend": true
}
]
},
"rasterizerState": {
"cullMode": 0
},
"properties": {
"texture": {
"value": "white",
"type": 29
},
"texture2": {
"value": "white",
"type": 29
},
"texture3": {
"value": "white",
"type": 29
},
"texture4": {
"value": "white",
"type": 29
},
"texture5": {
"value": "white",
"type": 29
},
"texture6": {
"value": "white",
"type": 29
},
"texture7": {
"value": "white",
"type": 29
},
"texture8": {
"value": "white",
"type": 29
},
"alphaThreshold": {
"type": 13,
"value": [
0.5
]
}
}
}
]
}
]
]
],
0,
0,
[],
[],
[]
]

View File

@ -1 +0,0 @@
{"version":3,"sources":["assets/spine/skin/spine-skin.ts"],"names":["_a","cc","_decorator","ccclass","property","SpineSkin","_super","__extends","_this","apply","this","arguments","addBoyBtn","removeBoyBtn","randomChangeBtn","boy","heads","boys","prototype","start","boySpine","getComponentInChildren","sp","Skeleton","newSkeletonData","skeletonData","clone","animation","push","on","newBoy","instantiate","newBoySpine","parent","addChild","setPosition","length","position","x","setAnimationCacheMode","AnimationCacheMode","PRIVATE_CACHE","Label","string","destroy","setRegion","SkeletonData","createRegion","Math","floor","random","__decorate","Node","SpriteFrame","Component","exports","default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAM,IAAAA,KAAAC,GAAAC,YAAAC,UAAAH,GAAAG,SAAAC,WAAAJ,GAAAI;IAGN,IAAAC,YAAA,SAAAC;MAAuCC,UAAAF,WAAAC;MAAvC,SAAAD;QAAA,IAAAG,QAAA,SAAAF,UAAAA,OAAAG,MAAAC,MAAAC,cAAAD;QAGIF,MAAAI,YAAA;QAGAJ,MAAAK,eAAA;QAGAL,MAAAM,kBAAA;QAGAN,MAAAO,MAAA;QAGAP,MAAAQ,QAAA;QAEAR,MAAAS,OAAA;;;MAEUZ,UAAAa,UAAAC,QAAA;QAAV,IAAAX,QAAAE;QACI,IAAAU,WAAAV,KAAAK,IAAAM,uBAAAC,GAAAC;QACA,IAAAC,kBAAAJ,SAAAK,aAAAC;QACAN,SAAAK,eAAAD;QACAJ,SAAAO,YAAA;QAEAjB,KAAAO,KAAAW,KAAAlB,KAAAK;QAEAL,KAAAE,UAAAiB,GAAA,SAAA;UACI,IAAAC,SAAA7B,GAAA8B,YAAAvB,MAAAO;UACA,IAAAiB,cAAAF,OAAAT,uBAAAC,GAAAC;UACAS,YAAAP,eAAAL,SAAAK,aAAAC;UACAM,YAAAL,YAAA;UAEAnB,MAAAO,IAAAkB,OAAAC,SAAAJ;UACAA,OAAAK,YAAA3B,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAC;UACAP,OAAAQ,KAAA;UACA,IAAA9B,MAAAS,KAAAmB,SAAA,MAAA,GAAA;YACIN,OAAAT,uBAAAC,GAAAC,UAAAgB,sBAAAjB,GAAAC,SAAAiB,mBAAAC;YACAX,OAAAT,uBAAApB,GAAAyC,OAAAC,SAAA;;UAEJnC,MAAAS,KAAAW,KAAAE;;QAGJpB,KAAAG,aAAAgB,GAAA,SAAA;UACI,IAAArB,MAAAS,KAAAmB,SAAA,GAAA;YACI5B,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAQ;YACApC,MAAAS,KAAAmB,UAAA;;;QAIR1B,KAAAI,gBAAAe,GAAA,SAAA;UACI,IAAAd,MAAAP,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAf,uBAAAC,GAAAC;UACAR,IAAA8B,UAAA,QAAA,QAAAvB,GAAAwB,aAAAC,aAAAvC,MAAAQ,MAAAgC,KAAAC,MAAAD,KAAAE,WAAA1C,MAAAQ,MAAA;;;MAjDRmC,WAAA,EADC/C,SAAAH,GAAAmD,SACyB/C,UAAAa,WAAA,kBAAA;MAG1BiC,WAAA,EADC/C,SAAAH,GAAAmD,SAC4B/C,UAAAa,WAAA,qBAAA;MAG7BiC,WAAA,EADC/C,SAAAH,GAAAmD,SAC+B/C,UAAAa,WAAA,wBAAA;MAGhCiC,WAAA,EADC/C,SAAAH,GAAAmD,SACmB/C,UAAAa,WAAA,YAAA;MAGpBiC,WAAA,EADC/C,SAAA,EAAAH,GAAAoD,kBAC4BhD,UAAAa,WAAA,cAAA;MAfZb,YAAA8C,WAAA,EADpBhD,WACoBE;MAwDrB,OAAAA;KAxDA,CAAAJ,GAAAqD;IAAqBC,QAAAC,UAAAnD","sourcesContent":["const { ccclass, property } = cc._decorator;\n\n@ccclass\nexport default class SpineSkin extends cc.Component {\n\n @property(cc.Node)\n addBoyBtn: cc.Node = null;\n\n @property(cc.Node)\n removeBoyBtn: cc.Node = null;\n\n @property(cc.Node)\n randomChangeBtn: cc.Node = null;\n\n @property(cc.Node)\n boy: cc.Node = null;\n\n @property([cc.SpriteFrame])\n heads: cc.SpriteFrame[] = [];\n\n boys: cc.Node[] = [];\n\n protected start(): void {\n const boySpine = this.boy.getComponentInChildren(sp.Skeleton);\n const newSkeletonData = boySpine.skeletonData.clone();\n boySpine.skeletonData = newSkeletonData;\n boySpine.animation = 'attack';\n\n this.boys.push(this.boy);\n\n this.addBoyBtn.on('click', () => {\n const newBoy = cc.instantiate(this.boy);\n const newBoySpine = newBoy.getComponentInChildren(sp.Skeleton);\n newBoySpine.skeletonData = boySpine.skeletonData.clone();\n newBoySpine.animation = 'attack';\n\n this.boy.parent.addChild(newBoy);\n newBoy.setPosition(this.boys[this.boys.length - 1].position);\n newBoy.x += 100;\n if (this.boys.length % 2 === 1) {\n newBoy.getComponentInChildren(sp.Skeleton).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE);\n newBoy.getComponentInChildren(cc.Label).string = `Spine - Cache`;\n }\n this.boys.push(newBoy);\n });\n\n this.removeBoyBtn.on('click', () => {\n if (this.boys.length > 1) {\n this.boys[this.boys.length - 1].destroy();\n this.boys.length -= 1;\n }\n });\n\n this.randomChangeBtn.on('click', () => {\n const boy = this.boys[this.boys.length - 1].getComponentInChildren(sp.Skeleton);\n boy.setRegion('Head', 'Head', sp.SkeletonData.createRegion(this.heads[Math.floor(Math.random() * (this.heads.length))]));\n });\n }\n\n}\n"],"file":"index.js"}

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More