@bloopjs/toodle 0.1.1 → 0.1.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/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/textures/util.d.ts +0 -4
- package/dist/textures/util.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/textures/util.ts +0 -27
package/dist/textures/util.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { CpuTextureAtlas, TextureWithMetadata } from "./types";
|
|
2
2
|
export declare function getBitmapFromUrl(url: URL): Promise<ImageBitmap>;
|
|
3
|
-
export declare function loadZip(zipUrl: URL): Promise<{
|
|
4
|
-
path: string;
|
|
5
|
-
bitmap: ImageBitmap;
|
|
6
|
-
}[]>;
|
|
7
3
|
export declare function packBitmapsToAtlas(images: Map<string, TextureWithMetadata>, textureSize: number, device: GPUDevice): Promise<CpuTextureAtlas[]>;
|
|
8
4
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/textures/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/textures/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CASrE;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACxC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,eAAe,EAAE,CAAC,CAqH5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloopjs/toodle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"typescript": "^5.7.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"fflate": "^0.8.2",
|
|
46
45
|
"webgpu-utils": "^1.9.3",
|
|
47
46
|
"wgpu-matrix": "^3.3.0",
|
|
48
47
|
"wgsl_reflect": "^1.0.14"
|
package/src/textures/util.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unzipSync } from "fflate";
|
|
2
1
|
import type {
|
|
3
2
|
CpuTextureAtlas,
|
|
4
3
|
TextureRegion,
|
|
@@ -16,32 +15,6 @@ export async function getBitmapFromUrl(url: URL): Promise<ImageBitmap> {
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export async function loadZip(
|
|
20
|
-
zipUrl: URL,
|
|
21
|
-
): Promise<{ path: string; bitmap: ImageBitmap }[]> {
|
|
22
|
-
console.time("fetch zip");
|
|
23
|
-
const zip = await fetch(zipUrl);
|
|
24
|
-
const zipBlob = await zip.blob();
|
|
25
|
-
const zipUint8Array = await zipBlob.arrayBuffer();
|
|
26
|
-
console.timeEnd("fetch zip");
|
|
27
|
-
|
|
28
|
-
console.time("unzip");
|
|
29
|
-
const files = unzipSync(new Uint8Array(zipUint8Array));
|
|
30
|
-
console.timeEnd("unzip");
|
|
31
|
-
|
|
32
|
-
console.time("create bitmaps");
|
|
33
|
-
const validFiles = Object.entries(files).filter(
|
|
34
|
-
([path]) => !path.match("__MACOS") && path.endsWith(".png"),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return await Promise.all(
|
|
38
|
-
validFiles.map(async ([path, file]) => {
|
|
39
|
-
const bitmap = await createImageBitmap(new Blob([file]));
|
|
40
|
-
return { path, bitmap };
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
18
|
export async function packBitmapsToAtlas(
|
|
46
19
|
images: Map<string, TextureWithMetadata>,
|
|
47
20
|
textureSize: number,
|