@safe-engine/pixi 8.4.6 → 8.5.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.
Files changed (98) hide show
  1. package/README.md +14 -23
  2. package/dist/box2d-wasm/ContactListener.d.ts +1 -1
  3. package/dist/box2d-wasm/ContactListener.d.ts.map +1 -1
  4. package/dist/box2d-wasm/ContactListener.js +50 -18
  5. package/dist/box2d-wasm/PhysicsComponent.d.ts +27 -30
  6. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  7. package/dist/box2d-wasm/PhysicsComponent.js +44 -11
  8. package/dist/box2d-wasm/PhysicsSprite.d.ts +3 -0
  9. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  10. package/dist/box2d-wasm/PhysicsSprite.js +24 -3
  11. package/dist/box2d-wasm/PhysicsSystem.d.ts +4 -2
  12. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  13. package/dist/box2d-wasm/PhysicsSystem.js +134 -44
  14. package/dist/collider/CollideComponent.d.ts +27 -10
  15. package/dist/collider/CollideComponent.d.ts.map +1 -1
  16. package/dist/collider/CollideComponent.js +10 -12
  17. package/dist/collider/helper/Intersection.d.ts +6 -6
  18. package/dist/collider/helper/Intersection.d.ts.map +1 -1
  19. package/dist/collider/helper/Intersection.js +4 -4
  20. package/dist/components/NodeComp.js +1 -1
  21. package/dist/helper/utils.d.ts +0 -6
  22. package/dist/helper/utils.d.ts.map +1 -1
  23. package/dist/helper/utils.js +0 -12
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -0
  27. package/{src/spine/lib/require-shim.ts → dist/spine/lib/assets/atlasLoader.d.ts} +5 -14
  28. package/dist/spine/lib/assets/atlasLoader.d.ts.map +1 -0
  29. package/dist/spine/lib/assets/atlasLoader.js +122 -0
  30. package/{src/spine/lib/darktint/DarkTintShader.ts → dist/spine/lib/assets/skeletonLoader.d.ts} +3 -47
  31. package/dist/spine/lib/assets/skeletonLoader.d.ts.map +1 -0
  32. package/dist/spine/lib/assets/skeletonLoader.js +70 -0
  33. package/package.json +6 -2
  34. package/.github/workflows/npm-publish.yml +0 -35
  35. package/dist/@types/safex.d.ts +0 -15
  36. package/src/@types/index.d.ts +0 -2
  37. package/src/app.ts +0 -91
  38. package/src/base/EnhancedComponent.ts +0 -38
  39. package/src/base/gworld.ts +0 -20
  40. package/src/base/index.ts +0 -14
  41. package/src/base/utils.ts +0 -23
  42. package/src/box2d-wasm/ContactListener.ts +0 -66
  43. package/src/box2d-wasm/PhysicsComponent.ts +0 -83
  44. package/src/box2d-wasm/PhysicsSprite.ts +0 -42
  45. package/src/box2d-wasm/PhysicsSystem.ts +0 -142
  46. package/src/box2d-wasm/debugDraw.ts +0 -249
  47. package/src/box2d-wasm/index.ts +0 -19
  48. package/src/collider/CollideComponent.ts +0 -257
  49. package/src/collider/CollideSystem.ts +0 -166
  50. package/src/collider/helper/Intersection.ts +0 -139
  51. package/src/collider/helper/utils.ts +0 -37
  52. package/src/collider/index.ts +0 -16
  53. package/src/components/BaseComponent.ts +0 -17
  54. package/src/components/NodeComp.ts +0 -442
  55. package/src/components/Scene.ts +0 -17
  56. package/src/core/Color.ts +0 -7
  57. package/src/core/LoadingBar.ts +0 -63
  58. package/src/core/NodePool.ts +0 -28
  59. package/src/core/Size.ts +0 -21
  60. package/src/core/Vec2.ts +0 -108
  61. package/src/core/director.ts +0 -11
  62. package/src/core/index.ts +0 -7
  63. package/src/core/loader.ts +0 -14
  64. package/src/core/math.ts +0 -22
  65. package/src/dragonbones/DragonBonesComponent.ts +0 -32
  66. package/src/dragonbones/DragonBonesSystem.ts +0 -35
  67. package/src/dragonbones/index.ts +0 -11
  68. package/src/gui/GUIComponent.ts +0 -155
  69. package/src/gui/GUISystem.ts +0 -125
  70. package/src/helper/utils.ts +0 -50
  71. package/src/index.ts +0 -19
  72. package/src/norender/NoRenderComponent.ts +0 -60
  73. package/src/norender/NoRenderSystem.ts +0 -67
  74. package/src/norender/Touch.ts +0 -37
  75. package/src/planck/PhysicsComponent.ts +0 -83
  76. package/src/planck/PhysicsSprite.ts +0 -43
  77. package/src/planck/PhysicsSystem.ts +0 -201
  78. package/src/planck/index.ts +0 -3
  79. package/src/render/RenderComponent.ts +0 -132
  80. package/src/render/RenderSystem.ts +0 -64
  81. package/src/richtext/RichTextComp.ts +0 -50
  82. package/src/richtext/RichTextSystem.ts +0 -26
  83. package/src/richtext/html-text-parser.ts +0 -87
  84. package/src/richtext/index.ts +0 -8
  85. package/src/spine/SpineComponent.ts +0 -18
  86. package/src/spine/SpineSystem.ts +0 -30
  87. package/src/spine/index.ts +0 -11
  88. package/src/spine/lib/BatchableSpineSlot.ts +0 -138
  89. package/src/spine/lib/Spine.ts +0 -894
  90. package/src/spine/lib/SpineDebugRenderer.ts +0 -615
  91. package/src/spine/lib/SpinePipe.ts +0 -203
  92. package/src/spine/lib/SpineTexture.ts +0 -143
  93. package/src/spine/lib/darktint/DarkTintBatchGeometry.ts +0 -92
  94. package/src/spine/lib/darktint/DarkTintBatcher.ts +0 -186
  95. package/src/spine/lib/darktint/darkTintBit.ts +0 -77
  96. package/src/spine/lib/index.ts +0 -43
  97. package/tsconfig.json +0 -18
  98. /package/{dist/@types → @types}/index.d.ts +0 -0
@@ -1,203 +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
- collectAllRenderables,
32
- extensions, ExtensionType,
33
- InstructionSet,
34
- type BLEND_MODES,
35
- type Container,
36
- type Renderer,
37
- type RenderPipe,
38
- } from 'pixi.js';
39
- import { BatchableSpineSlot } from './BatchableSpineSlot.js';
40
- import { Spine } from './Spine.js';
41
- import { MeshAttachment, RegionAttachment } from '@esotericsoftware/spine-core';
42
-
43
- const spineBlendModeMap: Record<number, BLEND_MODES> = {
44
- 0: 'normal',
45
- 1: 'add',
46
- 2: 'multiply',
47
- 3: 'screen'
48
- };
49
-
50
- type GpuSpineDataElement = { slotBatches: Record<string, BatchableSpineSlot> };
51
-
52
- // eslint-disable-next-line max-len
53
- export class SpinePipe implements RenderPipe<Spine> {
54
- /** @ignore */
55
- static extension = {
56
- type: [
57
- ExtensionType.WebGLPipes,
58
- ExtensionType.WebGPUPipes,
59
- ExtensionType.CanvasPipes,
60
- ],
61
- name: 'spine',
62
- } as const;
63
-
64
- renderer: Renderer;
65
-
66
- private gpuSpineData: Record<string, GpuSpineDataElement> = {};
67
- private readonly _destroyRenderableBound = this.destroyRenderable.bind(this) as (renderable: Container) => void;
68
-
69
- constructor (renderer: Renderer) {
70
- this.renderer = renderer;
71
- }
72
-
73
- validateRenderable (spine: Spine): boolean {
74
- spine._validateAndTransformAttachments();
75
-
76
- // if spine attachments have changed or destroyed, we need to rebuild the batch!
77
- if (spine.spineAttachmentsDirty) {
78
- return true;
79
- }
80
-
81
- // if the textures have changed, we need to rebuild the batch, but only if the texture is not already in the batch
82
- else if (spine.spineTexturesDirty) {
83
- // loop through and see if the textures have changed..
84
- const drawOrder = spine.skeleton.drawOrder;
85
- const gpuSpine = this.gpuSpineData[spine.uid];
86
-
87
- for (let i = 0, n = drawOrder.length; i < n; i++) {
88
- const slot = drawOrder[i];
89
- const attachment = slot.getAttachment();
90
-
91
- if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
92
- const cacheData = spine._getCachedData(slot, attachment);
93
- const batchableSpineSlot = gpuSpine.slotBatches[cacheData.id];
94
-
95
- const texture = cacheData.texture;
96
-
97
- if (texture !== batchableSpineSlot.texture) {
98
- if (!batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot, texture)) {
99
- return true;
100
- }
101
- }
102
- }
103
- }
104
- }
105
-
106
- return false;
107
- }
108
-
109
- addRenderable (spine: Spine, instructionSet: InstructionSet) {
110
- const gpuSpine = this._getSpineData(spine);
111
-
112
- const batcher = this.renderer.renderPipes.batch;
113
-
114
- const drawOrder = spine.skeleton.drawOrder;
115
-
116
- const roundPixels = (this.renderer._roundPixels | spine._roundPixels) as 0 | 1;
117
-
118
- spine._validateAndTransformAttachments();
119
-
120
- spine.spineAttachmentsDirty = false;
121
- spine.spineTexturesDirty = false;
122
-
123
- for (let i = 0, n = drawOrder.length; i < n; i++) {
124
- const slot = drawOrder[i];
125
- const attachment = slot.getAttachment();
126
- const blendMode = spineBlendModeMap[slot.data.blendMode];
127
-
128
- if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
129
- const cacheData = spine._getCachedData(slot, attachment);
130
- const batchableSpineSlot = gpuSpine.slotBatches[cacheData.id] ||= new BatchableSpineSlot();
131
-
132
- batchableSpineSlot.setData(
133
- spine,
134
- cacheData,
135
- blendMode,
136
- roundPixels
137
- );
138
-
139
- if (!cacheData.skipRender) {
140
- batcher.addToBatch(batchableSpineSlot, instructionSet);
141
- }
142
- }
143
-
144
- const containerAttachment = spine._slotsObject[slot.data.name];
145
-
146
- if (containerAttachment) {
147
- const container = containerAttachment.container;
148
-
149
- container.includeInBuild = true;
150
- collectAllRenderables(container, instructionSet, this.renderer);
151
- container.includeInBuild = false;
152
- }
153
- }
154
- }
155
-
156
- updateRenderable (spine: Spine) {
157
- const gpuSpine = this.gpuSpineData[spine.uid];
158
-
159
- spine._validateAndTransformAttachments();
160
-
161
- spine.spineAttachmentsDirty = false;
162
- spine.spineTexturesDirty = false;
163
-
164
- const drawOrder = spine.skeleton.drawOrder;
165
-
166
- for (let i = 0, n = drawOrder.length; i < n; i++) {
167
- const slot = drawOrder[i];
168
- const attachment = slot.getAttachment();
169
-
170
- if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
171
- const cacheData = spine._getCachedData(slot, attachment);
172
-
173
- if (!cacheData.skipRender) {
174
- const batchableSpineSlot = gpuSpine.slotBatches[spine._getCachedData(slot, attachment).id];
175
-
176
- batchableSpineSlot._batcher?.updateElement(batchableSpineSlot);
177
- }
178
- }
179
- }
180
- }
181
-
182
- destroyRenderable (spine: Spine) {
183
- this.gpuSpineData[spine.uid] = null as any;
184
- spine.off('destroyed', this._destroyRenderableBound);
185
- }
186
-
187
- destroy () {
188
- this.gpuSpineData = null as any;
189
- this.renderer = null as any;
190
- }
191
-
192
- private _getSpineData (spine: Spine): GpuSpineDataElement {
193
- return this.gpuSpineData[spine.uid] || this._initMeshData(spine);
194
- }
195
-
196
- private _initMeshData (spine: Spine): GpuSpineDataElement {
197
- this.gpuSpineData[spine.uid] = { slotBatches: {} };
198
- spine.on('destroyed', this._destroyRenderableBound);
199
- return this.gpuSpineData[spine.uid];
200
- }
201
- }
202
-
203
- extensions.add(SpinePipe);
@@ -1,143 +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 { Texture as PixiTexture } from 'pixi.js';
31
- import { BlendMode, Texture, TextureFilter, TextureWrap } from '@esotericsoftware/spine-core';
32
-
33
- import type { BLEND_MODES, SCALE_MODE, TextureSource, WRAP_MODE } from 'pixi.js';
34
-
35
- export class SpineTexture extends Texture {
36
- private static readonly textureMap: Map<TextureSource, SpineTexture> = new Map<TextureSource, SpineTexture>();
37
-
38
- public static from (texture: TextureSource): SpineTexture {
39
- if (SpineTexture.textureMap.has(texture)) {
40
- return SpineTexture.textureMap.get(texture) as SpineTexture;
41
- }
42
-
43
- return new SpineTexture(texture);
44
- }
45
-
46
- public readonly texture: PixiTexture;
47
-
48
- private constructor (image: TextureSource) {
49
- // Todo: maybe add error handling if you feed a video texture to spine?
50
- super(image.resource);
51
- this.texture = PixiTexture.from(image);
52
- }
53
-
54
- public setFilters (minFilter: TextureFilter, magFilter: TextureFilter): void {
55
- const style = this.texture.source.style;
56
-
57
- style.minFilter = SpineTexture.toPixiTextureFilter(minFilter);
58
- style.magFilter = SpineTexture.toPixiTextureFilter(magFilter);
59
- this.texture.source.autoGenerateMipmaps = SpineTexture.toPixiMipMap(minFilter);
60
- this.texture.source.updateMipmaps();
61
- }
62
-
63
- public setWraps (uWrap: TextureWrap, vWrap: TextureWrap): void {
64
- const style = this.texture.source.style;
65
-
66
- style.addressModeU = SpineTexture.toPixiTextureWrap(uWrap);
67
- style.addressModeV = SpineTexture.toPixiTextureWrap(vWrap);
68
- }
69
-
70
- public dispose (): void {
71
- // I am not entirely sure about this...
72
- this.texture.destroy();
73
- }
74
-
75
- private static toPixiMipMap (filter: TextureFilter): boolean {
76
- switch (filter) {
77
- case TextureFilter.Nearest:
78
- case TextureFilter.Linear:
79
- return false;
80
-
81
- case TextureFilter.MipMapNearestLinear:
82
- case TextureFilter.MipMapNearestNearest:
83
- case TextureFilter.MipMapLinearLinear: // TextureFilter.MipMapLinearLinear == TextureFilter.MipMap
84
- case TextureFilter.MipMapLinearNearest:
85
- return true;
86
-
87
- default:
88
- throw new Error(`Unknown texture filter: ${String(filter)}`);
89
- }
90
- }
91
-
92
- private static toPixiTextureFilter (filter: TextureFilter): SCALE_MODE {
93
- switch (filter) {
94
- case TextureFilter.Nearest:
95
- case TextureFilter.MipMapNearestLinear:
96
- case TextureFilter.MipMapNearestNearest:
97
- return 'nearest';
98
-
99
- case TextureFilter.Linear:
100
- case TextureFilter.MipMapLinearLinear: // TextureFilter.MipMapLinearLinear == TextureFilter.MipMap
101
- case TextureFilter.MipMapLinearNearest:
102
- return 'linear';
103
-
104
- default:
105
- throw new Error(`Unknown texture filter: ${String(filter)}`);
106
- }
107
- }
108
-
109
- private static toPixiTextureWrap (wrap: TextureWrap): WRAP_MODE {
110
- switch (wrap) {
111
- case TextureWrap.ClampToEdge:
112
- return 'clamp-to-edge';
113
-
114
- case TextureWrap.MirroredRepeat:
115
- return 'mirror-repeat';
116
-
117
- case TextureWrap.Repeat:
118
- return 'repeat';
119
-
120
- default:
121
- throw new Error(`Unknown texture wrap: ${String(wrap)}`);
122
- }
123
- }
124
-
125
- public static toPixiBlending (blend: BlendMode): BLEND_MODES {
126
- switch (blend) {
127
- case BlendMode.Normal:
128
- return 'normal';
129
-
130
- case BlendMode.Additive:
131
- return 'add';
132
-
133
- case BlendMode.Multiply:
134
- return 'multiply';
135
-
136
- case BlendMode.Screen:
137
- return 'screen';
138
-
139
- default:
140
- throw new Error(`Unknown blendMode: ${String(blend)}`);
141
- }
142
- }
143
- }
@@ -1,92 +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 { Buffer, BufferUsage, Geometry } from 'pixi.js';
31
-
32
- const placeHolderBufferData = new Float32Array(1);
33
- const placeHolderIndexData = new Uint32Array(1);
34
-
35
- export class DarkTintBatchGeometry extends Geometry {
36
- constructor () {
37
- const vertexSize = 7;
38
-
39
- const attributeBuffer = new Buffer({
40
- data: placeHolderBufferData,
41
- label: 'attribute-batch-buffer',
42
- usage: BufferUsage.VERTEX | BufferUsage.COPY_DST,
43
- shrinkToFit: false,
44
- });
45
-
46
- const indexBuffer = new Buffer({
47
- data: placeHolderIndexData,
48
- label: 'index-batch-buffer',
49
- usage: BufferUsage.INDEX | BufferUsage.COPY_DST, // | BufferUsage.STATIC,
50
- shrinkToFit: false,
51
- });
52
-
53
- const stride = vertexSize * 4;
54
-
55
- super({
56
- attributes: {
57
- aPosition: {
58
- buffer: attributeBuffer,
59
- format: 'float32x2',
60
- stride,
61
- offset: 0,
62
- },
63
- aUV: {
64
- buffer: attributeBuffer,
65
- format: 'float32x2',
66
- stride,
67
- offset: 2 * 4,
68
- },
69
- aColor: {
70
- buffer: attributeBuffer,
71
- format: 'unorm8x4',
72
- stride,
73
- offset: 4 * 4,
74
- },
75
- aDarkColor: {
76
- buffer: attributeBuffer,
77
- format: 'unorm8x4',
78
- stride,
79
- offset: 5 * 4,
80
- },
81
- aTextureIdAndRound: {
82
- buffer: attributeBuffer,
83
- format: 'uint16x2',
84
- stride,
85
- offset: 6 * 4,
86
- },
87
- },
88
- indexBuffer
89
- });
90
- }
91
- }
92
-
@@ -1,186 +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
- Batcher,
32
- Color,
33
- DefaultBatchableMeshElement,
34
- DefaultBatchableQuadElement,
35
- extensions,
36
- ExtensionType,
37
- Shader
38
- } from 'pixi.js';
39
- import { DarkTintBatchGeometry } from './DarkTintBatchGeometry.js';
40
- import { DarkTintShader } from './DarkTintShader.js';
41
-
42
- let defaultShader: Shader | null = null;
43
-
44
- /** The default batcher is used to batch quads and meshes. */
45
- export class DarkTintBatcher extends Batcher {
46
- /** @ignore */
47
- public static extension = {
48
- type: [
49
- ExtensionType.Batcher,
50
- ],
51
- name: 'darkTint',
52
- } as const;
53
-
54
- public geometry = new DarkTintBatchGeometry();
55
- public shader = defaultShader || (defaultShader = new DarkTintShader(this.maxTextures));
56
- public name = DarkTintBatcher.extension.name;
57
-
58
- /** The size of one attribute. 1 = 32 bit. x, y, u, v, color, darkColor, textureIdAndRound -> total = 7 */
59
- public vertexSize = 7;
60
-
61
- public packAttributes (
62
- element: DefaultBatchableMeshElement & { darkColor: number },
63
- float32View: Float32Array,
64
- uint32View: Uint32Array,
65
- index: number,
66
- textureId: number
67
- ) {
68
- const textureIdAndRound = (textureId << 16) | (element.roundPixels & 0xFFFF);
69
-
70
- const wt = element.transform;
71
-
72
- const a = wt.a;
73
- const b = wt.b;
74
- const c = wt.c;
75
- const d = wt.d;
76
- const tx = wt.tx;
77
- const ty = wt.ty;
78
-
79
- const { positions, uvs } = element;
80
-
81
- const argb = element.color;
82
- const worldAlpha = ((argb >> 24) & 0xFF) / 255;
83
- const darkColor = Color.shared.setValue(element.darkColor).premultiply(worldAlpha, true).toPremultiplied(1, false);
84
-
85
- const offset = element.attributeOffset;
86
- const end = offset + element.attributeSize;
87
-
88
- for (let i = offset; i < end; i++) {
89
- const i2 = i * 2;
90
-
91
- const x = positions[i2];
92
- const y = positions[(i2) + 1];
93
-
94
- float32View[index++] = (a * x) + (c * y) + tx;
95
- float32View[index++] = (d * y) + (b * x) + ty;
96
-
97
- float32View[index++] = uvs[i2];
98
- float32View[index++] = uvs[(i2) + 1];
99
-
100
- uint32View[index++] = argb;
101
- uint32View[index++] = darkColor;
102
-
103
- uint32View[index++] = textureIdAndRound;
104
- }
105
- }
106
-
107
- public packQuadAttributes (
108
- element: DefaultBatchableQuadElement & { darkColor: number },
109
- float32View: Float32Array,
110
- uint32View: Uint32Array,
111
- index: number,
112
- textureId: number
113
- ) {
114
- const texture = element.texture;
115
-
116
- const wt = element.transform;
117
-
118
- const a = wt.a;
119
- const b = wt.b;
120
- const c = wt.c;
121
- const d = wt.d;
122
- const tx = wt.tx;
123
- const ty = wt.ty;
124
-
125
- const bounds = element.bounds;
126
-
127
- const w0 = bounds.maxX;
128
- const w1 = bounds.minX;
129
- const h0 = bounds.maxY;
130
- const h1 = bounds.minY;
131
-
132
- const uvs = texture.uvs;
133
-
134
- // _ _ _ _
135
- // a b g r
136
- const argb = element.color;
137
- const darkColor = element.darkColor;
138
-
139
- const textureIdAndRound = (textureId << 16) | (element.roundPixels & 0xFFFF);
140
-
141
- float32View[index + 0] = (a * w1) + (c * h1) + tx;
142
- float32View[index + 1] = (d * h1) + (b * w1) + ty;
143
-
144
- float32View[index + 2] = uvs.x0;
145
- float32View[index + 3] = uvs.y0;
146
-
147
- uint32View[index + 4] = argb;
148
- uint32View[index + 5] = darkColor;
149
- uint32View[index + 6] = textureIdAndRound;
150
-
151
- // xy
152
- float32View[index + 7] = (a * w0) + (c * h1) + tx;
153
- float32View[index + 8] = (d * h1) + (b * w0) + ty;
154
-
155
- float32View[index + 9] = uvs.x1;
156
- float32View[index + 10] = uvs.y1;
157
-
158
- uint32View[index + 11] = argb;
159
- uint32View[index + 12] = darkColor;
160
- uint32View[index + 13] = textureIdAndRound;
161
-
162
- // xy
163
- float32View[index + 14] = (a * w0) + (c * h0) + tx;
164
- float32View[index + 15] = (d * h0) + (b * w0) + ty;
165
-
166
- float32View[index + 16] = uvs.x2;
167
- float32View[index + 17] = uvs.y2;
168
-
169
- uint32View[index + 18] = argb;
170
- uint32View[index + 19] = darkColor;
171
- uint32View[index + 20] = textureIdAndRound;
172
-
173
- // xy
174
- float32View[index + 21] = (a * w1) + (c * h0) + tx;
175
- float32View[index + 22] = (d * h0) + (b * w1) + ty;
176
-
177
- float32View[index + 23] = uvs.x3;
178
- float32View[index + 24] = uvs.y3;
179
-
180
- uint32View[index + 25] = argb;
181
- uint32View[index + 26] = darkColor;
182
- uint32View[index + 27] = textureIdAndRound;
183
- }
184
- }
185
-
186
- extensions.add(DarkTintBatcher);
@@ -1,77 +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
- export const darkTintBit = {
31
- name: 'color-bit',
32
- vertex: {
33
- header: /* wgsl */`
34
- @in aDarkColor: vec4<f32>;
35
- @out vDarkColor: vec4<f32>;
36
- `,
37
- main: /* wgsl */`
38
- vDarkColor = aDarkColor;
39
- `
40
- },
41
- fragment: {
42
- header: /* wgsl */`
43
- @in vDarkColor: vec4<f32>;
44
- `,
45
- end: /* wgsl */`
46
-
47
- let alpha = outColor.a * vColor.a;
48
- let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;
49
-
50
- finalColor = vec4<f32>(rgb, alpha);
51
-
52
- `
53
- }
54
- };
55
-
56
- export const darkTintBitGl = {
57
- name: 'color-bit',
58
- vertex: {
59
- header: /* glsl */`
60
- in vec4 aDarkColor;
61
- out vec4 vDarkColor;
62
- `,
63
- main: /* glsl */`
64
- vDarkColor = aDarkColor;
65
- `
66
- },
67
- fragment: {
68
- header: /* glsl */`
69
- in vec4 vDarkColor;
70
- `,
71
- end: /* glsl */`
72
-
73
- finalColor.a = outColor.a * vColor.a;
74
- finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;
75
- `
76
- }
77
- };