@aethervtt/shard-sprite 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/atlas.d.ts +112 -0
- package/dist/atlas.js +511 -0
- package/dist/clip.d.ts +73 -0
- package/dist/clip.js +278 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +186 -0
- package/dist/lighting-shaders.d.ts +5 -0
- package/dist/lighting-shaders.js +267 -0
- package/dist/lighting.d.ts +44 -0
- package/dist/lighting.js +149 -0
- package/dist/lights2d.d.ts +203 -0
- package/dist/lights2d.js +1093 -0
- package/dist/occluders.d.ts +64 -0
- package/dist/occluders.js +241 -0
- package/dist/outline.d.ts +24 -0
- package/dist/outline.js +183 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +67 -0
- package/dist/preview.d.ts +9 -0
- package/dist/preview.js +71 -0
- package/dist/render.d.ts +202 -0
- package/dist/render.js +1216 -0
- package/dist/shaders.d.ts +2 -0
- package/dist/shaders.js +263 -0
- package/dist/sprite.d.ts +26 -0
- package/dist/sprite.js +67 -0
- package/dist/tilemap.d.ts +94 -0
- package/dist/tilemap.js +267 -0
- package/package.json +39 -0
package/dist/clip.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AssetStore } from '@aethervtt/shard-assets';
|
|
2
|
+
import { type AssetRef, type Entity } from '@aethervtt/shard-core';
|
|
3
|
+
export declare const CLIP_LOOPS: readonly ['loop', 'once', 'ping-pong'];
|
|
4
|
+
export declare const SpriteClipSchema: import("@aethervtt/shard-core").ComponentDef<{
|
|
5
|
+
readonly atlas: import("@aethervtt/shard-core").FieldType<AssetRef<"TextureAtlas"> | null, "object">;
|
|
6
|
+
readonly frames: import("@aethervtt/shard-core").FieldType<import("@aethervtt/shard-core").InferFields<{
|
|
7
|
+
region: import("@aethervtt/shard-core").FieldType<string, "object">;
|
|
8
|
+
duration: import("@aethervtt/shard-core").FieldType<number, "f32">;
|
|
9
|
+
}>[], "object">;
|
|
10
|
+
readonly loop: import("@aethervtt/shard-core").FieldType<"loop" | "once" | "ping-pong", "u8">;
|
|
11
|
+
readonly events: import("@aethervtt/shard-core").FieldType<import("@aethervtt/shard-core").InferFields<{
|
|
12
|
+
frame: import("@aethervtt/shard-core").FieldType<number, "u32">;
|
|
13
|
+
name: import("@aethervtt/shard-core").FieldType<string, "object">;
|
|
14
|
+
}>[], "object">;
|
|
15
|
+
}>;
|
|
16
|
+
/** A frame animation over an atlas: regions, durations, loop mode, and named events. */
|
|
17
|
+
export declare class SpriteClip {
|
|
18
|
+
atlas: AssetRef<'TextureAtlas'> | null;
|
|
19
|
+
regions: string[];
|
|
20
|
+
/** Frame start times (s), plus the total at the end. */
|
|
21
|
+
starts: Float64Array;
|
|
22
|
+
loop: (typeof CLIP_LOOPS)[number];
|
|
23
|
+
/** Event names by frame. */
|
|
24
|
+
events: Map<number, string[]>;
|
|
25
|
+
constructor(atlas: AssetRef<'TextureAtlas'> | null, frames: {
|
|
26
|
+
region: string;
|
|
27
|
+
duration: number;
|
|
28
|
+
}[], loop?: (typeof CLIP_LOOPS)[number], events?: {
|
|
29
|
+
frame: number;
|
|
30
|
+
name: string;
|
|
31
|
+
}[]);
|
|
32
|
+
get duration(): number;
|
|
33
|
+
/**
|
|
34
|
+
* The frame showing at `time` (seconds from the start). Ping-pong runs the frames forward, then
|
|
35
|
+
* back over the inner ones, so the ends don't show twice.
|
|
36
|
+
*/
|
|
37
|
+
frameAt(time: number): number;
|
|
38
|
+
/** Whether a `once` clip has played to its end at `time`. */
|
|
39
|
+
ended(time: number): boolean;
|
|
40
|
+
private search;
|
|
41
|
+
copyFrom(other: SpriteClip): void;
|
|
42
|
+
}
|
|
43
|
+
export declare class SpriteClipStore extends AssetStore<SpriteClip, 'SpriteClip'> {
|
|
44
|
+
constructor();
|
|
45
|
+
}
|
|
46
|
+
export declare const SpriteClips: import("@aethervtt/shard-core").ResourceDef<SpriteClipStore>;
|
|
47
|
+
export declare const SpriteClipAssetType: import("@aethervtt/shard-assets").AssetTypeDef<SpriteClip>;
|
|
48
|
+
/** `*.clip.json`: a frame animation over an atlas's regions. */
|
|
49
|
+
export declare const SpriteClipImporter: import("@aethervtt/shard-assets").ImporterDef;
|
|
50
|
+
export declare const SpriteAnimation: import("@aethervtt/shard-core").ComponentDef<{
|
|
51
|
+
readonly clip: import("@aethervtt/shard-core").FieldType<AssetRef<"SpriteClip"> | null, "object">;
|
|
52
|
+
readonly playing: import("@aethervtt/shard-core").FieldType<boolean, "u8">;
|
|
53
|
+
readonly speed: import("@aethervtt/shard-core").FieldType<number, "f32">;
|
|
54
|
+
readonly time: import("@aethervtt/shard-core").FieldType<number, "f32">;
|
|
55
|
+
}>;
|
|
56
|
+
export interface SpriteAnimationEventValue {
|
|
57
|
+
entity: Entity;
|
|
58
|
+
/** The event's name from the clip. */
|
|
59
|
+
name: string;
|
|
60
|
+
frame: number;
|
|
61
|
+
}
|
|
62
|
+
export declare const SpriteAnimationEvent: import("@aethervtt/shard-core").EventDef<SpriteAnimationEventValue>;
|
|
63
|
+
/**
|
|
64
|
+
* Advances every SpriteAnimation, points its Sprite at the current frame's region, and sends the
|
|
65
|
+
* events of frames it passes (all of them, even when a long step skips frames).
|
|
66
|
+
*/
|
|
67
|
+
export declare const animateSprites: import("@aethervtt/shard-core").SystemDef<{
|
|
68
|
+
q: import("@aethervtt/shard-core").Query;
|
|
69
|
+
warned: Set<string>;
|
|
70
|
+
lastFrames: Map<number, number>;
|
|
71
|
+
}>;
|
|
72
|
+
/** A clip's frames side by side, in order, each labeled with its index. */
|
|
73
|
+
export declare const spriteClipPreview: import("@aethervtt/shard-assets").AssetPreview;
|
package/dist/clip.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssetStore,
|
|
3
|
+
assetServer,
|
|
4
|
+
defineAssetPreview,
|
|
5
|
+
defineAssetType,
|
|
6
|
+
defineDataAsset
|
|
7
|
+
} from "@aethervtt/shard-assets";
|
|
8
|
+
import {
|
|
9
|
+
defineComponent,
|
|
10
|
+
defineEvent,
|
|
11
|
+
defineResource,
|
|
12
|
+
defineSchema,
|
|
13
|
+
defineSystem,
|
|
14
|
+
ShardError,
|
|
15
|
+
t
|
|
16
|
+
} from "@aethervtt/shard-core";
|
|
17
|
+
import { LogResource, Time } from "@aethervtt/shard-runtime";
|
|
18
|
+
import { readKtx2 } from "@aethervtt/shard-texture";
|
|
19
|
+
import { TextureAtlas, TextureAtlases } from "./atlas.js";
|
|
20
|
+
import { drawLabel, fitImage } from "./preview.js";
|
|
21
|
+
import { Sprite } from "./sprite.js";
|
|
22
|
+
const CLIP_LOOPS = ["loop", "once", "ping-pong"];
|
|
23
|
+
const SpriteClipSchema = defineSchema(
|
|
24
|
+
"sprite/SpriteClip",
|
|
25
|
+
{
|
|
26
|
+
atlas: t.handle("TextureAtlas", { description: "The atlas the frames come from." }),
|
|
27
|
+
frames: t.list(
|
|
28
|
+
t.struct({
|
|
29
|
+
region: t.string({ description: "Atlas region name." }),
|
|
30
|
+
duration: t.f32({ default: 0.1, min: 1e-3, unit: "s", description: "How long it shows." })
|
|
31
|
+
}),
|
|
32
|
+
{ description: "Frames in order." }
|
|
33
|
+
),
|
|
34
|
+
loop: t.enum(CLIP_LOOPS, {
|
|
35
|
+
description: "loop: from the start again; once: stop on the last frame; ping-pong: back and forth."
|
|
36
|
+
}),
|
|
37
|
+
events: t.list(
|
|
38
|
+
t.struct({
|
|
39
|
+
frame: t.u32({ description: "Frame index that sends it, when it starts showing." }),
|
|
40
|
+
name: t.string({ description: 'Event name, e.g. "footstep".' })
|
|
41
|
+
}),
|
|
42
|
+
{ description: "Named events sent as SpriteAnimationEvent." }
|
|
43
|
+
)
|
|
44
|
+
},
|
|
45
|
+
{ description: "A frame animation: atlas regions with durations, a loop mode, and events." }
|
|
46
|
+
);
|
|
47
|
+
class SpriteClip {
|
|
48
|
+
atlas;
|
|
49
|
+
regions;
|
|
50
|
+
/** Frame start times (s), plus the total at the end. */
|
|
51
|
+
starts;
|
|
52
|
+
loop;
|
|
53
|
+
/** Event names by frame. */
|
|
54
|
+
events;
|
|
55
|
+
constructor(atlas, frames, loop = "loop", events = []) {
|
|
56
|
+
this.atlas = atlas;
|
|
57
|
+
this.regions = frames.map((f) => f.region);
|
|
58
|
+
this.starts = new Float64Array(frames.length + 1);
|
|
59
|
+
for (let i = 0; i < frames.length; i++)
|
|
60
|
+
this.starts[i + 1] = this.starts[i] + frames[i].duration;
|
|
61
|
+
this.loop = loop;
|
|
62
|
+
this.events = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const e of events) {
|
|
64
|
+
const list = this.events.get(e.frame) ?? [];
|
|
65
|
+
list.push(e.name);
|
|
66
|
+
this.events.set(e.frame, list);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
get duration() {
|
|
70
|
+
return this.starts[this.regions.length];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The frame showing at `time` (seconds from the start). Ping-pong runs the frames forward, then
|
|
74
|
+
* back over the inner ones, so the ends don't show twice.
|
|
75
|
+
*/
|
|
76
|
+
frameAt(time) {
|
|
77
|
+
const n = this.regions.length;
|
|
78
|
+
if (n === 0) return -1;
|
|
79
|
+
const total = this.duration;
|
|
80
|
+
if (this.loop === "once") return time >= total ? n - 1 : this.search(Math.max(0, time));
|
|
81
|
+
if (this.loop === "loop" || n < 3) return this.search(mod(time, total));
|
|
82
|
+
const back = this.starts[n - 1] - this.starts[1];
|
|
83
|
+
const t2 = mod(time, total + back);
|
|
84
|
+
if (t2 < total) return this.search(t2);
|
|
85
|
+
let r = t2 - total;
|
|
86
|
+
for (let f = n - 2; f >= 1; f--) {
|
|
87
|
+
const d = this.starts[f + 1] - this.starts[f];
|
|
88
|
+
if (r < d) return f;
|
|
89
|
+
r -= d;
|
|
90
|
+
}
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
/** Whether a `once` clip has played to its end at `time`. */
|
|
94
|
+
ended(time) {
|
|
95
|
+
return this.loop === "once" && time >= this.duration;
|
|
96
|
+
}
|
|
97
|
+
search(t2) {
|
|
98
|
+
const n = this.regions.length;
|
|
99
|
+
let lo = 0;
|
|
100
|
+
let hi = n - 1;
|
|
101
|
+
while (lo < hi) {
|
|
102
|
+
const mid = lo + hi + 1 >> 1;
|
|
103
|
+
if (this.starts[mid] <= t2) lo = mid;
|
|
104
|
+
else hi = mid - 1;
|
|
105
|
+
}
|
|
106
|
+
return lo;
|
|
107
|
+
}
|
|
108
|
+
copyFrom(other) {
|
|
109
|
+
this.atlas = other.atlas;
|
|
110
|
+
this.regions = other.regions;
|
|
111
|
+
this.starts = other.starts;
|
|
112
|
+
this.loop = other.loop;
|
|
113
|
+
this.events = other.events;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const mod = (a, b) => b > 0 ? (a % b + b) % b : 0;
|
|
117
|
+
class SpriteClipStore extends AssetStore {
|
|
118
|
+
constructor() {
|
|
119
|
+
super("SpriteClip");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const SpriteClips = defineResource("sprite/SpriteClips", {
|
|
123
|
+
description: "Loaded sprite animation clips by guid.",
|
|
124
|
+
init: () => new SpriteClipStore()
|
|
125
|
+
});
|
|
126
|
+
const SpriteClipAssetType = defineAssetType("SpriteClip", {
|
|
127
|
+
store: SpriteClips,
|
|
128
|
+
load: (artifact, ctx) => {
|
|
129
|
+
const v = SpriteClipSchema.deserialize(artifact.json);
|
|
130
|
+
const atlas = v.atlas?.path ? ctx.resolve(v.atlas.path) ?? v.atlas : v.atlas;
|
|
131
|
+
return new SpriteClip(atlas ?? null, v.frames, v.loop, v.events);
|
|
132
|
+
},
|
|
133
|
+
update: (existing, next) => existing.copyFrom(next)
|
|
134
|
+
});
|
|
135
|
+
const SpriteClipImporter = defineDataAsset("SpriteClip", SpriteClipSchema, {
|
|
136
|
+
extension: "clip"
|
|
137
|
+
});
|
|
138
|
+
const SpriteAnimation = defineComponent(
|
|
139
|
+
"sprite/SpriteAnimation",
|
|
140
|
+
{
|
|
141
|
+
clip: t.handle("SpriteClip", { description: "The frame animation to play." }),
|
|
142
|
+
playing: t.bool({
|
|
143
|
+
default: true,
|
|
144
|
+
description: "Advances each frame. A once clip clears it at its end."
|
|
145
|
+
}),
|
|
146
|
+
speed: t.f32({
|
|
147
|
+
default: 1,
|
|
148
|
+
description: "Playback rate: 2 is twice as fast, negative plays backward."
|
|
149
|
+
}),
|
|
150
|
+
time: t.f32({ unit: "s", description: "Position in the clip." })
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
description: "Plays a SpriteClip on this entity's Sprite: sets its atlas and region each frame.",
|
|
154
|
+
requires: [Sprite]
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
const SpriteAnimationEvent = defineEvent(
|
|
158
|
+
"sprite/SpriteAnimationEvent",
|
|
159
|
+
{ description: "A clip frame with an event started showing: { entity, name, frame }." }
|
|
160
|
+
);
|
|
161
|
+
const animateSprites = defineSystem({
|
|
162
|
+
name: "sprite/animate",
|
|
163
|
+
description: "Plays sprite animation clips: time, frame, Sprite region, events.",
|
|
164
|
+
setup: (world) => ({
|
|
165
|
+
q: world.query({ with: [SpriteAnimation, Sprite] }),
|
|
166
|
+
warned: /* @__PURE__ */ new Set(),
|
|
167
|
+
// The last frame shown per entity, so events fire once per frame change.
|
|
168
|
+
lastFrames: /* @__PURE__ */ new Map()
|
|
169
|
+
}),
|
|
170
|
+
run: ({ q, warned, lastFrames }, world) => {
|
|
171
|
+
const clips = world.resource(SpriteClips);
|
|
172
|
+
const atlases = world.resource(TextureAtlases);
|
|
173
|
+
const dt = world.resource(Time).delta;
|
|
174
|
+
for (const table of q.tables) {
|
|
175
|
+
const clipRefs = table.column(SpriteAnimation, "clip");
|
|
176
|
+
const playing = table.column(SpriteAnimation, "playing");
|
|
177
|
+
const speed = table.column(SpriteAnimation, "speed");
|
|
178
|
+
const time = table.column(SpriteAnimation, "time");
|
|
179
|
+
const atlas = table.column(Sprite, "atlas");
|
|
180
|
+
const region = table.column(Sprite, "region");
|
|
181
|
+
for (let i = 0; i < table.count; i++) {
|
|
182
|
+
const clip = clips.get(clipRefs[i]);
|
|
183
|
+
if (!clip || clip.regions.length === 0) continue;
|
|
184
|
+
const entity = table.entities[i];
|
|
185
|
+
const before = time[i];
|
|
186
|
+
if (playing[i]) {
|
|
187
|
+
time[i] = before + dt * speed[i];
|
|
188
|
+
table.markChanged(SpriteAnimation, i);
|
|
189
|
+
}
|
|
190
|
+
const frame = clip.frameAt(time[i]);
|
|
191
|
+
if (playing[i] && clip.ended(time[i])) playing[i] = 0;
|
|
192
|
+
const previous = lastFrames.get(entity);
|
|
193
|
+
if (previous !== frame) {
|
|
194
|
+
if (clip.events.size > 0)
|
|
195
|
+
sendPassed(world, clip, entity, previous, before, time[i], frame);
|
|
196
|
+
lastFrames.set(entity, frame);
|
|
197
|
+
const name = clip.regions[frame];
|
|
198
|
+
if (region[i] !== name || clip.atlas && atlas[i]?.guid !== clip.atlas.guid) {
|
|
199
|
+
region[i] = name;
|
|
200
|
+
if (clip.atlas) atlas[i] = clip.atlas;
|
|
201
|
+
table.markChanged(Sprite, i);
|
|
202
|
+
}
|
|
203
|
+
const a = atlases.get(clip.atlas);
|
|
204
|
+
if (a && a.region(name) < 0 && !warned.has(name)) {
|
|
205
|
+
warned.add(name);
|
|
206
|
+
world.tryResource(LogResource)?.warn(`Sprite clip frame "${name}" isn't a region of its atlas`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
function sendPassed(world, clip, entity, previous, from, to, frame) {
|
|
214
|
+
const n = clip.regions.length;
|
|
215
|
+
if (previous === void 0 || clip.loop === "ping-pong" || n === 1) {
|
|
216
|
+
for (const name of clip.events.get(frame) ?? []) {
|
|
217
|
+
world.send(SpriteAnimationEvent, { entity, name, frame });
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const step = to >= from ? 1 : -1;
|
|
222
|
+
let f = previous;
|
|
223
|
+
for (let guard = 0; guard < n * 4 && f !== frame; guard++) {
|
|
224
|
+
f = ((f + step) % n + n) % n;
|
|
225
|
+
for (const name of clip.events.get(f) ?? []) {
|
|
226
|
+
world.send(SpriteAnimationEvent, { entity, name, frame: f });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const spriteClipPreview = defineAssetPreview(
|
|
231
|
+
"SpriteClip",
|
|
232
|
+
async (world, path, width, height) => {
|
|
233
|
+
const server = assetServer(world);
|
|
234
|
+
const clip = SpriteClipSchema.deserialize((await server.artifact(path)).json);
|
|
235
|
+
const atlasPath = clip.atlas?.path;
|
|
236
|
+
if (!atlasPath)
|
|
237
|
+
throw new ShardError("sprite/no-atlas", `${path} has no atlas`, { path: "/atlas" });
|
|
238
|
+
const atlas = TextureAtlas.fromJson((await server.artifact(atlasPath)).json);
|
|
239
|
+
const texturePath = atlas.texture?.path?.startsWith("#") ? `${atlasPath.split("#")[0]}${atlas.texture.path}` : atlas.texture?.path;
|
|
240
|
+
if (!texturePath) throw new ShardError("sprite/no-texture", `${atlasPath} has no texture`);
|
|
241
|
+
const ktx = readKtx2((await server.artifact(texturePath)).bytes);
|
|
242
|
+
const src = ktx.levels[0];
|
|
243
|
+
const rects = clip.frames.map((f) => {
|
|
244
|
+
const r = atlas.region(f.region);
|
|
245
|
+
return r < 0 ? [0, 0, 1, 1] : [...atlas.rects.subarray(r * 4, r * 4 + 4)];
|
|
246
|
+
});
|
|
247
|
+
const cw = Math.max(1, ...rects.map((r) => r[2]));
|
|
248
|
+
const ch = Math.max(1, ...rects.map((r) => r[3]));
|
|
249
|
+
const sheetW = cw * rects.length;
|
|
250
|
+
const sheet = new Uint8Array(sheetW * ch * 4);
|
|
251
|
+
rects.forEach(([x, y, w, h], k) => {
|
|
252
|
+
for (let j = 0; j < h; j++) {
|
|
253
|
+
for (let i = 0; i < w; i++) {
|
|
254
|
+
const s = ((y + j) * ktx.width + x + i) * 4;
|
|
255
|
+
sheet.set(src.subarray(s, s + 4), (j * sheetW + k * cw + i) * 4);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
const image = fitImage(sheet, sheetW, ch, width, height);
|
|
260
|
+
const scale = image.width / sheetW;
|
|
261
|
+
for (let k = 0; k < rects.length; k++)
|
|
262
|
+
drawLabel(image, String(k), Math.round(k * cw * scale) + 1, 1);
|
|
263
|
+
return image;
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
export {
|
|
267
|
+
CLIP_LOOPS,
|
|
268
|
+
SpriteAnimation,
|
|
269
|
+
SpriteAnimationEvent,
|
|
270
|
+
SpriteClip,
|
|
271
|
+
SpriteClipAssetType,
|
|
272
|
+
SpriteClipImporter,
|
|
273
|
+
SpriteClipSchema,
|
|
274
|
+
SpriteClipStore,
|
|
275
|
+
SpriteClips,
|
|
276
|
+
animateSprites,
|
|
277
|
+
spriteClipPreview
|
|
278
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { AtlasPackImporter, AtlasPackSchema, packImages, packNormals, regionOutline, TextureAtlas, TextureAtlasAssetType, TextureAtlases, TextureAtlasImporter, TextureAtlasSchema, TextureAtlasStore, } from './atlas.js';
|
|
2
|
+
export { animateSprites, CLIP_LOOPS, SpriteAnimation, SpriteAnimationEvent, type SpriteAnimationEventValue, SpriteClip, SpriteClipAssetType, SpriteClipImporter, SpriteClipSchema, SpriteClipStore, SpriteClips, } from './clip.js';
|
|
3
|
+
export { Lighting2d, LightOccluder2d, layerBit, OCCLUDER_SHAPES, type OccluderShape, PointLight2d, SpotLight2d, SpriteLighting, } from './lighting.js';
|
|
4
|
+
export { binLightsCpu, describeLights2d, LIGHT2D_FLOATS, Lights2d, Lights2dStore, LightView2d, lightCircle, MAX_SHADOWED, OccluderStore, prepareLights2d, SEGMENT_FLOATS, SHADOW_RES, shadowFactorCpu, shadowRowCpu, TILE_MAX, TILE_PIXELS, TILE_STRIDE, } from './lights2d.js';
|
|
5
|
+
export { boxPolygon, capsulePolygon, circlePolygon, convexHull, occluderSegments, polygonProblem, polygonSegments, spriteOutline, tileChunkEdges, transformSegments, } from './occluders.js';
|
|
6
|
+
export { alphaOutline, distanceToLoop, loopArea, simplifyLoop, traceAlpha } from './outline.js';
|
|
7
|
+
export { spritePlugin } from './plugin.js';
|
|
8
|
+
export { describeSprites, prepareSprites, SPRITE_FLOATS, type SpriteBatch, SpriteStore, Sprites, TilemapStore, Tilemaps, } from './render.js';
|
|
9
|
+
export { SPRITE_SHADERS } from './shaders.js';
|
|
10
|
+
export { SPRITE_BLENDS, SPRITE_SORTS, SPRITE_SPACES, Sprite, Sprite2dSettings, type Sprite2dSettingsValue, SpriteSlot, } from './sprite.js';
|
|
11
|
+
export { setTile, TileFlags, TileLayer, Tilemap, TilemapData, TilemapDataAssetType, TilemapDataImporter, TilemapDataSchema, TilemapDataStore, TilemapDatas, tileAt, } from './tilemap.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AtlasPackImporter,
|
|
3
|
+
AtlasPackSchema,
|
|
4
|
+
packImages,
|
|
5
|
+
packNormals,
|
|
6
|
+
regionOutline,
|
|
7
|
+
TextureAtlas,
|
|
8
|
+
TextureAtlasAssetType,
|
|
9
|
+
TextureAtlases,
|
|
10
|
+
TextureAtlasImporter,
|
|
11
|
+
TextureAtlasSchema,
|
|
12
|
+
TextureAtlasStore
|
|
13
|
+
} from "./atlas.js";
|
|
14
|
+
import {
|
|
15
|
+
animateSprites,
|
|
16
|
+
CLIP_LOOPS,
|
|
17
|
+
SpriteAnimation,
|
|
18
|
+
SpriteAnimationEvent,
|
|
19
|
+
SpriteClip,
|
|
20
|
+
SpriteClipAssetType,
|
|
21
|
+
SpriteClipImporter,
|
|
22
|
+
SpriteClipSchema,
|
|
23
|
+
SpriteClipStore,
|
|
24
|
+
SpriteClips
|
|
25
|
+
} from "./clip.js";
|
|
26
|
+
import {
|
|
27
|
+
Lighting2d,
|
|
28
|
+
LightOccluder2d,
|
|
29
|
+
layerBit,
|
|
30
|
+
OCCLUDER_SHAPES,
|
|
31
|
+
PointLight2d,
|
|
32
|
+
SpotLight2d,
|
|
33
|
+
SpriteLighting
|
|
34
|
+
} from "./lighting.js";
|
|
35
|
+
import {
|
|
36
|
+
binLightsCpu,
|
|
37
|
+
describeLights2d,
|
|
38
|
+
LIGHT2D_FLOATS,
|
|
39
|
+
Lights2d,
|
|
40
|
+
Lights2dStore,
|
|
41
|
+
LightView2d,
|
|
42
|
+
lightCircle,
|
|
43
|
+
MAX_SHADOWED,
|
|
44
|
+
OccluderStore,
|
|
45
|
+
prepareLights2d,
|
|
46
|
+
SEGMENT_FLOATS,
|
|
47
|
+
SHADOW_RES,
|
|
48
|
+
shadowFactorCpu,
|
|
49
|
+
shadowRowCpu,
|
|
50
|
+
TILE_MAX,
|
|
51
|
+
TILE_PIXELS,
|
|
52
|
+
TILE_STRIDE
|
|
53
|
+
} from "./lights2d.js";
|
|
54
|
+
import {
|
|
55
|
+
boxPolygon,
|
|
56
|
+
capsulePolygon,
|
|
57
|
+
circlePolygon,
|
|
58
|
+
convexHull,
|
|
59
|
+
occluderSegments,
|
|
60
|
+
polygonProblem,
|
|
61
|
+
polygonSegments,
|
|
62
|
+
spriteOutline,
|
|
63
|
+
tileChunkEdges,
|
|
64
|
+
transformSegments
|
|
65
|
+
} from "./occluders.js";
|
|
66
|
+
import { alphaOutline, distanceToLoop, loopArea, simplifyLoop, traceAlpha } from "./outline.js";
|
|
67
|
+
import { spritePlugin } from "./plugin.js";
|
|
68
|
+
import {
|
|
69
|
+
describeSprites,
|
|
70
|
+
prepareSprites,
|
|
71
|
+
SPRITE_FLOATS,
|
|
72
|
+
SpriteStore,
|
|
73
|
+
Sprites,
|
|
74
|
+
TilemapStore,
|
|
75
|
+
Tilemaps
|
|
76
|
+
} from "./render.js";
|
|
77
|
+
import { SPRITE_SHADERS } from "./shaders.js";
|
|
78
|
+
import {
|
|
79
|
+
SPRITE_BLENDS,
|
|
80
|
+
SPRITE_SORTS,
|
|
81
|
+
SPRITE_SPACES,
|
|
82
|
+
Sprite,
|
|
83
|
+
Sprite2dSettings,
|
|
84
|
+
SpriteSlot
|
|
85
|
+
} from "./sprite.js";
|
|
86
|
+
import {
|
|
87
|
+
setTile,
|
|
88
|
+
TileFlags,
|
|
89
|
+
TileLayer,
|
|
90
|
+
Tilemap,
|
|
91
|
+
TilemapData,
|
|
92
|
+
TilemapDataAssetType,
|
|
93
|
+
TilemapDataImporter,
|
|
94
|
+
TilemapDataSchema,
|
|
95
|
+
TilemapDataStore,
|
|
96
|
+
TilemapDatas,
|
|
97
|
+
tileAt
|
|
98
|
+
} from "./tilemap.js";
|
|
99
|
+
export {
|
|
100
|
+
AtlasPackImporter,
|
|
101
|
+
AtlasPackSchema,
|
|
102
|
+
CLIP_LOOPS,
|
|
103
|
+
LIGHT2D_FLOATS,
|
|
104
|
+
LightOccluder2d,
|
|
105
|
+
LightView2d,
|
|
106
|
+
Lighting2d,
|
|
107
|
+
Lights2d,
|
|
108
|
+
Lights2dStore,
|
|
109
|
+
MAX_SHADOWED,
|
|
110
|
+
OCCLUDER_SHAPES,
|
|
111
|
+
OccluderStore,
|
|
112
|
+
PointLight2d,
|
|
113
|
+
SEGMENT_FLOATS,
|
|
114
|
+
SHADOW_RES,
|
|
115
|
+
SPRITE_BLENDS,
|
|
116
|
+
SPRITE_FLOATS,
|
|
117
|
+
SPRITE_SHADERS,
|
|
118
|
+
SPRITE_SORTS,
|
|
119
|
+
SPRITE_SPACES,
|
|
120
|
+
SpotLight2d,
|
|
121
|
+
Sprite,
|
|
122
|
+
Sprite2dSettings,
|
|
123
|
+
SpriteAnimation,
|
|
124
|
+
SpriteAnimationEvent,
|
|
125
|
+
SpriteClip,
|
|
126
|
+
SpriteClipAssetType,
|
|
127
|
+
SpriteClipImporter,
|
|
128
|
+
SpriteClipSchema,
|
|
129
|
+
SpriteClipStore,
|
|
130
|
+
SpriteClips,
|
|
131
|
+
SpriteLighting,
|
|
132
|
+
SpriteSlot,
|
|
133
|
+
SpriteStore,
|
|
134
|
+
Sprites,
|
|
135
|
+
TILE_MAX,
|
|
136
|
+
TILE_PIXELS,
|
|
137
|
+
TILE_STRIDE,
|
|
138
|
+
TextureAtlas,
|
|
139
|
+
TextureAtlasAssetType,
|
|
140
|
+
TextureAtlasImporter,
|
|
141
|
+
TextureAtlasSchema,
|
|
142
|
+
TextureAtlasStore,
|
|
143
|
+
TextureAtlases,
|
|
144
|
+
TileFlags,
|
|
145
|
+
TileLayer,
|
|
146
|
+
Tilemap,
|
|
147
|
+
TilemapData,
|
|
148
|
+
TilemapDataAssetType,
|
|
149
|
+
TilemapDataImporter,
|
|
150
|
+
TilemapDataSchema,
|
|
151
|
+
TilemapDataStore,
|
|
152
|
+
TilemapDatas,
|
|
153
|
+
TilemapStore,
|
|
154
|
+
Tilemaps,
|
|
155
|
+
alphaOutline,
|
|
156
|
+
animateSprites,
|
|
157
|
+
binLightsCpu,
|
|
158
|
+
boxPolygon,
|
|
159
|
+
capsulePolygon,
|
|
160
|
+
circlePolygon,
|
|
161
|
+
convexHull,
|
|
162
|
+
describeLights2d,
|
|
163
|
+
describeSprites,
|
|
164
|
+
distanceToLoop,
|
|
165
|
+
layerBit,
|
|
166
|
+
lightCircle,
|
|
167
|
+
loopArea,
|
|
168
|
+
occluderSegments,
|
|
169
|
+
packImages,
|
|
170
|
+
packNormals,
|
|
171
|
+
polygonProblem,
|
|
172
|
+
polygonSegments,
|
|
173
|
+
prepareLights2d,
|
|
174
|
+
prepareSprites,
|
|
175
|
+
regionOutline,
|
|
176
|
+
setTile,
|
|
177
|
+
shadowFactorCpu,
|
|
178
|
+
shadowRowCpu,
|
|
179
|
+
simplifyLoop,
|
|
180
|
+
spriteOutline,
|
|
181
|
+
spritePlugin,
|
|
182
|
+
tileAt,
|
|
183
|
+
tileChunkEdges,
|
|
184
|
+
traceAlpha,
|
|
185
|
+
transformSegments
|
|
186
|
+
};
|