@safe-engine/cocos 2.3.4 → 2.3.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.
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +3 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSprite.js +2 -1
- package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +20 -16
- package/dist/box2d-wasm/debugDraw.d.ts +0 -15
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
- package/dist/box2d-wasm/debugDraw.js +8 -20
- package/dist/box2d-wasm/index.d.ts +19 -1
- package/dist/box2d-wasm/index.d.ts.map +1 -1
- package/dist/box2d-wasm/index.js +2 -2
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +5 -0
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts +19 -0
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -0
- package/dist/dragonbones/PixiDragonBonesSprite.js +75 -0
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts +2 -3
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/CocosFactory.js +4 -8
- package/dist/dragonbones/db-cocos/CocosSlot.d.ts +4 -1
- package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/CocosSlot.js +35 -38
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +1 -1
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +6 -6
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +36 -0
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -0
- package/dist/dragonbones/db-cocos/SimpleMeshNode.js +354 -0
- package/dist/gworld/EnhancedComponent.d.ts +22 -0
- package/dist/gworld/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/EnhancedComponent.js +44 -0
- package/dist/gworld/NodeComp.d.ts +153 -0
- package/dist/gworld/NodeComp.d.ts.map +1 -0
- package/dist/gworld/NodeComp.js +337 -0
- package/dist/gworld/NodePool.d.ts +9 -0
- package/dist/gworld/NodePool.d.ts.map +1 -0
- package/dist/gworld/NodePool.js +23 -0
- package/dist/gworld/Scene.d.ts +5 -0
- package/dist/gworld/Scene.d.ts.map +1 -0
- package/dist/gworld/Scene.js +14 -0
- package/dist/gworld/decorator.d.ts +8 -0
- package/dist/gworld/decorator.d.ts.map +1 -0
- package/dist/gworld/decorator.js +12 -0
- package/dist/gworld/index.d.ts +8 -0
- package/dist/gworld/index.d.ts.map +1 -0
- package/dist/gworld/index.js +14 -0
- package/dist/render/TiledSprite.d.ts +13 -0
- package/dist/render/TiledSprite.d.ts.map +1 -0
- package/dist/render/TiledSprite.js +69 -0
- package/dist/safex.d.ts +10 -0
- package/dist/safex.d.ts.map +1 -0
- package/dist/safex.js +1 -0
- package/dist/spine/CCSkeleton.d.ts +189 -0
- package/dist/spine/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/CCSkeleton.js +320 -0
- package/dist/spine/CCSkeletonAnimation.d.ts +146 -0
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/CCSkeletonAnimation.js +311 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +228 -0
- package/dist/spine/CCSkeletonTexture.d.ts +25 -0
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/CCSkeletonTexture.js +60 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +28 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +277 -0
- package/dist/spine/PixiSpineSprite.d.ts +19 -0
- package/dist/spine/PixiSpineSprite.d.ts.map +1 -0
- package/dist/spine/PixiSpineSprite.js +72 -0
- package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +2 -1
- package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -1
- package/dist/spine/spine-cocos/CCSkeletonAnimation.js +1 -1
- package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts +12 -1
- package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -1
- package/dist/spine/spine-cocos/CCSkeletonTexture.js +18 -19
- package/package.json +3 -3
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Spine } from '@esotericsoftware/spine-pixi-v8';
|
|
2
|
+
import { Application, Assets } from 'pixi.js';
|
|
3
|
+
export function loadSpineAssets({ skeleton, atlas, texture }) {
|
|
4
|
+
return Assets.load([skeleton, atlas, texture]);
|
|
5
|
+
}
|
|
6
|
+
export class PixiSpineSprite extends cc.Sprite {
|
|
7
|
+
_canvas;
|
|
8
|
+
_pixiApp;
|
|
9
|
+
_texture;
|
|
10
|
+
_config;
|
|
11
|
+
_armatureDisplay;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super();
|
|
14
|
+
super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
15
|
+
this._canvas = document.createElement('canvas');
|
|
16
|
+
this._canvas.width = config.width || 1024;
|
|
17
|
+
this._canvas.height = config.height || 1024;
|
|
18
|
+
this._pixiApp = new Application();
|
|
19
|
+
this._pixiApp.init({
|
|
20
|
+
view: this._canvas,
|
|
21
|
+
width: this._canvas.width,
|
|
22
|
+
height: this._canvas.height,
|
|
23
|
+
backgroundAlpha: 0, // nền trong suốt
|
|
24
|
+
// transparent: true, // bắt buộc để alpha hoạt động
|
|
25
|
+
clearBeforeRender: true, // xoá trước khi vẽ frame mới
|
|
26
|
+
preserveDrawingBuffer: true, // giúp lấy ảnh từ canvas
|
|
27
|
+
antialias: true,
|
|
28
|
+
});
|
|
29
|
+
this._texture = new cc.Texture2D();
|
|
30
|
+
this._texture.initWithElement(this._canvas);
|
|
31
|
+
this._texture.handleLoadedTexture();
|
|
32
|
+
this.initWithTexture(this._texture);
|
|
33
|
+
this._config = config;
|
|
34
|
+
this._setupSpine();
|
|
35
|
+
}
|
|
36
|
+
_setupSpine() {
|
|
37
|
+
const { skeleton, atlas, loop, skin, timeScale, animationName } = this._config;
|
|
38
|
+
// console.log('_setupSpine', this._config, Assets.get(this._config.texture))
|
|
39
|
+
const display = Spine.from({ skeleton, atlas, scale: timeScale });
|
|
40
|
+
if (!display) {
|
|
41
|
+
console.error('Cannot build spine:', skeleton);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (skin) {
|
|
45
|
+
const skeletonData = display.skeleton.data;
|
|
46
|
+
const newSkin = skeletonData.findSkin(skin);
|
|
47
|
+
display.skeleton.setSkin(newSkin);
|
|
48
|
+
display.skeleton.setSlotsToSetupPose();
|
|
49
|
+
}
|
|
50
|
+
if (animationName)
|
|
51
|
+
display.state.setAnimation(0, animationName, loop);
|
|
52
|
+
display.x = this._canvas.width / 2;
|
|
53
|
+
display.y = this._canvas.height;
|
|
54
|
+
this._pixiApp.stage.addChild(display);
|
|
55
|
+
this._armatureDisplay = display;
|
|
56
|
+
}
|
|
57
|
+
updateTexture() {
|
|
58
|
+
if (this._armatureDisplay && this._pixiApp.renderer && this._texture) {
|
|
59
|
+
this._pixiApp.renderer.render(this._pixiApp.stage);
|
|
60
|
+
this._texture.initWithElement(this._canvas);
|
|
61
|
+
this._texture.handleLoadedTexture();
|
|
62
|
+
// console.log('updateTexture', this._texture.getPixelsHigh(), this._texture.getPixelsWide())
|
|
63
|
+
this.setTexture(this._texture);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
onExit() {
|
|
67
|
+
// console.log('onExit')
|
|
68
|
+
this._pixiApp.destroy(true, { children: true });
|
|
69
|
+
this._canvas.remove();
|
|
70
|
+
super.onExit();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Animation, AnimationState, AnimationStateData } from '@esotericsoftware/spine-core';
|
|
2
2
|
import { CCSkeleton } from './CCSkeleton';
|
|
3
|
+
import { SkeletonTexture } from './CCSkeletonTexture';
|
|
3
4
|
/****************************************************************************
|
|
4
5
|
Copyright (c) 2011-2012 cocos2d-x.org
|
|
5
6
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
@@ -28,7 +29,7 @@ import { CCSkeleton } from './CCSkeleton';
|
|
|
28
29
|
export declare const _atlasLoader: {
|
|
29
30
|
spAtlasFile: any;
|
|
30
31
|
setAtlasFile: (spAtlasFile: any) => void;
|
|
31
|
-
load: (line: any) =>
|
|
32
|
+
load: (line: any) => SkeletonTexture;
|
|
32
33
|
unload: () => void;
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CCSkeletonAnimation.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAKnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"CCSkeletonAnimation.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAKnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;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AAQ,EAAE,QAAQ;IAIlD,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAItD,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIvD,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIpD,QAAQ;IAIR,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;IAI5E,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;CAc/E"}
|
|
@@ -35,7 +35,7 @@ export const _atlasLoader = {
|
|
|
35
35
|
load: function (line) {
|
|
36
36
|
const texturePath = cc.path.join(cc.path.dirname(this.spAtlasFile), line);
|
|
37
37
|
const texture = cc.textureCache.addImage(texturePath);
|
|
38
|
-
const tex = new SkeletonTexture();
|
|
38
|
+
const tex = new SkeletonTexture({ width: texture.getPixelsWide(), height: texture.getPixelsHigh() });
|
|
39
39
|
tex.setRealTexture(texture);
|
|
40
40
|
return tex;
|
|
41
41
|
},
|
|
@@ -21,5 +21,16 @@
|
|
|
21
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
22
|
THE SOFTWARE.
|
|
23
23
|
****************************************************************************/
|
|
24
|
-
|
|
24
|
+
import { Texture } from '@esotericsoftware/spine-core';
|
|
25
|
+
export declare class SkeletonTexture extends Texture {
|
|
26
|
+
constructor(image: any);
|
|
27
|
+
name: string;
|
|
28
|
+
_texture: any;
|
|
29
|
+
setRealTexture(tex: any): void;
|
|
30
|
+
getRealTexture(): any;
|
|
31
|
+
setFilters(minFilter: any, magFilter: any): void;
|
|
32
|
+
setWraps(uWrap: any, vWrap: any): void;
|
|
33
|
+
dispose(): void;
|
|
34
|
+
bind(): void;
|
|
35
|
+
}
|
|
25
36
|
//# sourceMappingURL=CCSkeletonTexture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;
|
|
1
|
+
{"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,qBAAa,eAAgB,SAAQ,OAAO;gBAC9B,KAAK,KAAA;IAGjB,IAAI,SAAoB;IACxB,QAAQ,MAAO;IAEf,cAAc,CAAC,GAAG,KAAA;IAIlB,cAAc;IAId,UAAU,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA;IAS/B,QAAQ,CAAC,KAAK,KAAA,EAAE,KAAK,KAAA;IASrB,OAAO;IAEP,IAAI;CAKL"}
|
|
@@ -22,39 +22,38 @@
|
|
|
22
22
|
THE SOFTWARE.
|
|
23
23
|
****************************************************************************/
|
|
24
24
|
import { Texture } from '@esotericsoftware/spine-core';
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setRealTexture: function (tex) {
|
|
25
|
+
export class SkeletonTexture extends Texture {
|
|
26
|
+
constructor(image) {
|
|
27
|
+
super(image);
|
|
28
|
+
}
|
|
29
|
+
name = 'SkeletonTexture';
|
|
30
|
+
_texture = null;
|
|
31
|
+
setRealTexture(tex) {
|
|
33
32
|
this._texture = tex;
|
|
34
|
-
}
|
|
35
|
-
getRealTexture
|
|
33
|
+
}
|
|
34
|
+
getRealTexture() {
|
|
36
35
|
return this._texture;
|
|
37
|
-
}
|
|
38
|
-
setFilters
|
|
36
|
+
}
|
|
37
|
+
setFilters(minFilter, magFilter) {
|
|
39
38
|
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
40
39
|
const gl = cc._renderContext;
|
|
41
40
|
this.bind();
|
|
42
41
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
43
42
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
44
43
|
}
|
|
45
|
-
}
|
|
46
|
-
setWraps
|
|
44
|
+
}
|
|
45
|
+
setWraps(uWrap, vWrap) {
|
|
47
46
|
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
48
47
|
const gl = cc._renderContext;
|
|
49
48
|
this.bind();
|
|
50
49
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
|
|
51
50
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
|
|
52
51
|
}
|
|
53
|
-
}
|
|
54
|
-
dispose
|
|
55
|
-
bind
|
|
52
|
+
}
|
|
53
|
+
dispose() { }
|
|
54
|
+
bind() {
|
|
56
55
|
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
|
|
57
56
|
cc.glBindTexture2D(this._texture);
|
|
58
57
|
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
58
|
+
}
|
|
59
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/cocos",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"description": "safe-engine with cocos renderer support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"build": "tsc"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"typescript": "^5.9.
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@cocos/dragonbones-js": "^1.0.2",
|
|
25
25
|
"@esotericsoftware/spine-core": "^4.2.93",
|
|
26
26
|
"box2d-wasm": "^7.0.0",
|
|
27
|
-
"cocos-html5-ts": "^
|
|
27
|
+
"cocos-html5-ts": "^2.0.1",
|
|
28
28
|
"entityx-ts": "^2.3.1"
|
|
29
29
|
},
|
|
30
30
|
"author": "",
|