@safe-engine/pixi 8.4.1 → 8.4.2
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/app.js +1 -1
- package/dist/base/index.d.ts +8 -0
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/utils.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.d.ts +2 -1
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +6 -5
- package/dist/box2d-wasm/debugDraw.d.ts +1 -1
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
- package/dist/box2d-wasm/debugDraw.js +7 -7
- package/dist/components/NodeComp.d.ts +10 -8
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +17 -11
- package/dist/core/Vec2.d.ts +30 -0
- package/dist/core/Vec2.d.ts.map +1 -0
- package/dist/core/Vec2.js +88 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/loader.d.ts +3 -0
- package/dist/core/loader.d.ts.map +1 -0
- package/dist/core/loader.js +21 -0
- package/dist/core/math.d.ts +1 -0
- package/dist/core/math.d.ts.map +1 -1
- package/dist/core/math.js +9 -0
- package/dist/gui/GUISystem.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +4 -4
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/norender/NoRenderComponent.d.ts +2 -2
- package/dist/norender/NoRenderComponent.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.js +7 -6
- package/dist/norender/Touch.d.ts +32 -0
- package/dist/norender/Touch.d.ts.map +1 -0
- package/dist/norender/Touch.js +32 -0
- package/dist/render/RenderComponent.d.ts +3 -3
- package/dist/render/RenderComponent.d.ts.map +1 -1
- package/dist/render/RenderComponent.js +18 -28
- package/dist/render/RenderSystem.d.ts.map +1 -1
- package/dist/render/RenderSystem.js +1 -1
- package/package.json +2 -1
- package/src/app.ts +2 -2
- package/src/base/index.ts +11 -0
- package/src/base/utils.ts +4 -4
- package/src/box2d-wasm/PhysicsSystem.ts +45 -48
- package/src/box2d-wasm/debugDraw.ts +80 -88
- package/src/components/NodeComp.ts +30 -30
- package/src/core/Vec2.ts +108 -0
- package/src/core/index.ts +6 -0
- package/src/core/loader.ts +12 -0
- package/src/core/math.ts +9 -0
- package/src/gui/GUISystem.ts +15 -9
- package/src/index.ts +3 -5
- package/src/norender/NoRenderComponent.ts +2 -2
- package/src/norender/NoRenderSystem.ts +12 -11
- package/src/norender/Touch.ts +37 -0
- package/src/render/RenderComponent.ts +35 -41
- package/src/render/RenderSystem.ts +3 -7
- package/dist/helper/html-text-parser.d.ts +0 -20
- package/dist/helper/html-text-parser.d.ts.map +0 -1
- package/dist/helper/html-text-parser.js +0 -64
- package/dist/spine/lib/assets/atlasLoader.d.ts +0 -34
- package/dist/spine/lib/assets/atlasLoader.d.ts.map +0 -1
- package/dist/spine/lib/assets/atlasLoader.js +0 -122
- package/dist/spine/lib/assets/skeletonLoader.d.ts +0 -30
- package/dist/spine/lib/assets/skeletonLoader.d.ts.map +0 -1
- package/dist/spine/lib/assets/skeletonLoader.js +0 -70
- package/src/spine/lib/assets/atlasLoader.ts +0 -158
- package/src/spine/lib/assets/skeletonLoader.ts +0 -81
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/** ****************************************************************************
|
|
2
|
-
* Spine Runtimes License Agreement
|
|
3
|
-
* Last updated July 28, 2023. Replaces all prior versions.
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2013-2023, Esoteric Software LLC
|
|
6
|
-
*
|
|
7
|
-
* Integration of the Spine Runtimes into software or otherwise creating
|
|
8
|
-
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
9
|
-
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
10
|
-
* http://esotericsoftware.com/spine-editor-license
|
|
11
|
-
*
|
|
12
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software or
|
|
13
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
14
|
-
* "Products"), provided that each user of the Products must obtain their own
|
|
15
|
-
* Spine Editor license and redistribution of the Products in any form must
|
|
16
|
-
* include this license and copyright notice.
|
|
17
|
-
*
|
|
18
|
-
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
|
19
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
|
22
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
24
|
-
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
25
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
|
|
27
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*****************************************************************************/
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
checkExtension,
|
|
32
|
-
DOMAdapter,
|
|
33
|
-
extensions,
|
|
34
|
-
ExtensionType,
|
|
35
|
-
LoaderParserPriority,
|
|
36
|
-
path,
|
|
37
|
-
Resolver,
|
|
38
|
-
TextureSource
|
|
39
|
-
} from 'pixi.js';
|
|
40
|
-
import { SpineTexture } from '../SpineTexture.js';
|
|
41
|
-
import { TextureAtlas } from '@esotericsoftware/spine-core';
|
|
42
|
-
|
|
43
|
-
import type { AssetExtension, Loader, ResolvedAsset, Texture, UnresolvedAsset } from 'pixi.js';
|
|
44
|
-
|
|
45
|
-
type RawAtlas = string;
|
|
46
|
-
|
|
47
|
-
const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtlasMetadata> = {
|
|
48
|
-
extension: ExtensionType.Asset,
|
|
49
|
-
|
|
50
|
-
resolver: {
|
|
51
|
-
test: (value: string): boolean => checkExtension(value, ".atlas"),
|
|
52
|
-
parse: (value: string): UnresolvedAsset => {
|
|
53
|
-
const split = value.split('.');
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
resolution: parseFloat(Resolver.RETINA_PREFIX?.exec(value)?.[1] ?? '1'),
|
|
57
|
-
format: split[split.length - 2],
|
|
58
|
-
src: value,
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
loader: {
|
|
64
|
-
extension: {
|
|
65
|
-
type: ExtensionType.LoadParser,
|
|
66
|
-
priority: LoaderParserPriority.Normal,
|
|
67
|
-
name: 'spineTextureAtlasLoader',
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
test (url: string): boolean {
|
|
71
|
-
return checkExtension(url, '.atlas');
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
async load (url: string): Promise<RawAtlas> {
|
|
75
|
-
const response = await DOMAdapter.get().fetch(url);
|
|
76
|
-
|
|
77
|
-
const txt = await response.text();
|
|
78
|
-
|
|
79
|
-
return txt;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
|
83
|
-
const isExtensionRight = checkExtension(options.src as string, '.atlas');
|
|
84
|
-
const isString = typeof asset === 'string';
|
|
85
|
-
|
|
86
|
-
return Promise.resolve(isExtensionRight && isString);
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
unload (atlas: TextureAtlas) {
|
|
90
|
-
atlas.dispose();
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
async parse (asset: RawAtlas, options: ResolvedAsset, loader: Loader): Promise<TextureAtlas> {
|
|
94
|
-
const metadata: ISpineAtlasMetadata = options.data || {};
|
|
95
|
-
let basePath = path.dirname(options.src as string);
|
|
96
|
-
|
|
97
|
-
if (basePath && basePath.lastIndexOf('/') !== basePath.length - 1) {
|
|
98
|
-
basePath += '/';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Retval is going to be a texture atlas. However we need to wait for it's callback to resolve this promise.
|
|
102
|
-
const retval = new TextureAtlas(asset);
|
|
103
|
-
|
|
104
|
-
// If the user gave me only one texture, that one is assumed to be the "first" texture in the atlas
|
|
105
|
-
if (metadata.images instanceof TextureSource || typeof metadata.images === 'string') {
|
|
106
|
-
const pixiTexture = metadata.images;
|
|
107
|
-
|
|
108
|
-
metadata.images = {} as Record<string, TextureSource | string>;
|
|
109
|
-
metadata.images[retval.pages[0].name] = pixiTexture;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// we will wait for all promises for the textures at the same time at the end.
|
|
113
|
-
const textureLoadingPromises: Promise<any>[] = [];
|
|
114
|
-
|
|
115
|
-
// fill the pages
|
|
116
|
-
for (const page of retval.pages) {
|
|
117
|
-
const pageName = page.name;
|
|
118
|
-
const providedPage = metadata?.images ? metadata.images[pageName] : undefined;
|
|
119
|
-
|
|
120
|
-
if (providedPage instanceof TextureSource) {
|
|
121
|
-
page.setTexture(SpineTexture.from(providedPage));
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
// eslint-disable-next-line max-len
|
|
125
|
-
const url: string = providedPage ?? path.normalize([...basePath.split(path.sep), pageName].join(path.sep));
|
|
126
|
-
|
|
127
|
-
const assetsToLoadIn = {
|
|
128
|
-
src: url,
|
|
129
|
-
data: {
|
|
130
|
-
...metadata.imageMetadata,
|
|
131
|
-
alphaMode: page.pma ? 'premultiplied-alpha' : 'premultiply-alpha-on-upload'
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const pixiPromise = loader.load<Texture>(assetsToLoadIn).then((texture) => {
|
|
136
|
-
page.setTexture(SpineTexture.from(texture.source));
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
textureLoadingPromises.push(pixiPromise);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
await Promise.all(textureLoadingPromises);
|
|
144
|
-
|
|
145
|
-
return retval;
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
} as AssetExtension<RawAtlas | TextureAtlas, ISpineAtlasMetadata>;
|
|
149
|
-
|
|
150
|
-
extensions.add(spineTextureAtlasLoader);
|
|
151
|
-
|
|
152
|
-
export interface ISpineAtlasMetadata {
|
|
153
|
-
// If you are downloading an .atlas file, this metadata will go to the Texture loader
|
|
154
|
-
imageMetadata?: any;
|
|
155
|
-
// If you already have atlas pages loaded as pixi textures
|
|
156
|
-
// and want to use that to create the atlas, you can pass them here
|
|
157
|
-
images?: TextureSource | string | Record<string, TextureSource | string>;
|
|
158
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/** ****************************************************************************
|
|
2
|
-
* Spine Runtimes License Agreement
|
|
3
|
-
* Last updated July 28, 2023. Replaces all prior versions.
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2013-2023, Esoteric Software LLC
|
|
6
|
-
*
|
|
7
|
-
* Integration of the Spine Runtimes into software or otherwise creating
|
|
8
|
-
* derivative works of the Spine Runtimes is permitted under the terms and
|
|
9
|
-
* conditions of Section 2 of the Spine Editor License Agreement:
|
|
10
|
-
* http://esotericsoftware.com/spine-editor-license
|
|
11
|
-
*
|
|
12
|
-
* Otherwise, it is permitted to integrate the Spine Runtimes into software or
|
|
13
|
-
* otherwise create derivative works of the Spine Runtimes (collectively,
|
|
14
|
-
* "Products"), provided that each user of the Products must obtain their own
|
|
15
|
-
* Spine Editor license and redistribution of the Products in any form must
|
|
16
|
-
* include this license and copyright notice.
|
|
17
|
-
*
|
|
18
|
-
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
|
19
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
-
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
|
22
|
-
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
24
|
-
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
25
|
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
|
|
27
|
-
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*****************************************************************************/
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
type AssetExtension,
|
|
32
|
-
checkExtension,
|
|
33
|
-
DOMAdapter,
|
|
34
|
-
extensions,
|
|
35
|
-
ExtensionType,
|
|
36
|
-
LoaderParserPriority,
|
|
37
|
-
ResolvedAsset
|
|
38
|
-
} from 'pixi.js';
|
|
39
|
-
|
|
40
|
-
type SkeletonJsonAsset = any;
|
|
41
|
-
type SkeletonBinaryAsset = Uint8Array;
|
|
42
|
-
|
|
43
|
-
function isJson (resource: any): resource is SkeletonJsonAsset {
|
|
44
|
-
return Object.prototype.hasOwnProperty.call(resource, 'bones');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function isBuffer (resource: any): resource is SkeletonBinaryAsset {
|
|
48
|
-
return resource instanceof Uint8Array;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAsset> = {
|
|
52
|
-
extension: ExtensionType.Asset,
|
|
53
|
-
|
|
54
|
-
loader: {
|
|
55
|
-
extension: {
|
|
56
|
-
type: ExtensionType.LoadParser,
|
|
57
|
-
priority: LoaderParserPriority.Normal,
|
|
58
|
-
name: 'spineSkeletonLoader',
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
test (url) {
|
|
62
|
-
return checkExtension(url, '.skel');
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
async load (url: string): Promise<SkeletonBinaryAsset> {
|
|
66
|
-
const response = await DOMAdapter.get().fetch(url);
|
|
67
|
-
|
|
68
|
-
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
69
|
-
|
|
70
|
-
return buffer;
|
|
71
|
-
},
|
|
72
|
-
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
|
73
|
-
const isJsonSpineModel = checkExtension(options.src!, '.json') && isJson(asset);
|
|
74
|
-
const isBinarySpineModel = checkExtension(options.src!, '.skel') && isBuffer(asset);
|
|
75
|
-
|
|
76
|
-
return Promise.resolve(isJsonSpineModel || isBinarySpineModel);
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
} as AssetExtension<SkeletonJsonAsset | SkeletonBinaryAsset>;
|
|
80
|
-
|
|
81
|
-
extensions.add(spineLoaderExtension);
|