@nodecraft/rendermite 1.1.3 → 1.2.0

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 (127) hide show
  1. package/README.md +27 -2
  2. package/assets/builtin/renderchest/models/block/banner_standing.json +225 -0
  3. package/assets/builtin/renderchest/models/block/banner_wall.json +155 -0
  4. package/assets/builtin/renderchest/models/block/bed_foot.json +44 -0
  5. package/assets/builtin/renderchest/models/block/bed_head.json +44 -0
  6. package/assets/builtin/renderchest/models/block/chest_left.json +182 -0
  7. package/assets/builtin/renderchest/models/block/chest_right.json +182 -0
  8. package/assets/builtin/renderchest/models/block/copper_golem_statue.json +709 -0
  9. package/assets/builtin/renderchest/models/block/fluid.json +83 -0
  10. package/assets/builtin/renderchest/models/block/fluid_tinted.json +89 -0
  11. package/assets/builtin/renderchest/models/block/hanging_sign.json +54 -0
  12. package/assets/builtin/renderchest/models/block/standing_sign.json +32 -0
  13. package/assets/builtin/renderchest/models/block/wall_sign.json +19 -0
  14. package/dist/atlas/registry.js +1 -1
  15. package/dist/atlas/sources.js +1 -1
  16. package/dist/atlas-pack-CoOih7By.js +130 -0
  17. package/dist/atlas-pack-DRTrWcSU.d.ts +41 -0
  18. package/dist/block-entities-BbS1kv0m.js +481 -0
  19. package/dist/blocks/atlas-pack.d.ts +2 -0
  20. package/dist/blocks/atlas-pack.js +2 -0
  21. package/dist/blocks/block-entities.d.ts +93 -0
  22. package/dist/blocks/block-entities.js +2 -0
  23. package/dist/blocks/blockstate-eval.d.ts +2 -0
  24. package/dist/blocks/blockstate-eval.js +2 -0
  25. package/dist/blocks/cli.d.ts +9 -0
  26. package/dist/blocks/cli.js +2 -0
  27. package/dist/blocks/export.d.ts +2 -0
  28. package/dist/blocks/export.js +2 -0
  29. package/dist/blocks/obj-mesh.d.ts +2 -0
  30. package/dist/blocks/obj-mesh.js +2 -0
  31. package/dist/blocks/tints.d.ts +2 -0
  32. package/dist/blocks/tints.js +2 -0
  33. package/dist/{blockstate-CdstnW2-.js → blockstate-DVb8Mhxc.js} +1 -1
  34. package/dist/blockstate-eval-Ckjlyxn4.js +231 -0
  35. package/dist/blockstate-eval-DDArZs1P.d.ts +107 -0
  36. package/dist/cli-D7_oUuPT.js +161 -0
  37. package/dist/cli.js +9 -7
  38. package/dist/{descriptor-DWebtkI1.js → descriptor-BVIoEpPO.js} +3 -3
  39. package/dist/{discovery-B9aqV_Rz.js → discovery-CsZu08re.js} +1 -1
  40. package/dist/dynamic/generators.js +1 -1
  41. package/dist/{entity-fallback-Cu22uEIK.js → entity-fallback-DNO0Ta9C.js} +3 -155
  42. package/dist/entity-textures-DFRIVdF1.js +209 -0
  43. package/dist/export-BIpqNU3H.d.ts +44 -0
  44. package/dist/export-DxREy3qA.js +701 -0
  45. package/dist/{face-cQ-pVHoe.d.ts → face-BKwkeTps.d.ts} +1 -1
  46. package/dist/{fluid-bucket-BzoLofB_.js → fluid-bucket-B-I4ZYHl.js} +1 -1
  47. package/dist/{generators-BlG4KmtP.js → generators-BCZVlWig.js} +1 -1
  48. package/dist/{geo-w9HHIrb5.js → geo-BguldlU-.js} +5 -5
  49. package/dist/{geometry-w0yQbzDZ.d.ts → geometry-Bkur58Vi.d.ts} +1 -1
  50. package/dist/index.d.ts +10 -5
  51. package/dist/index.js +21 -16
  52. package/dist/{item-styles-upgEO1yP.js → item-styles-DjYRdyHi.js} +1 -1
  53. package/dist/items/blockstate.js +1 -1
  54. package/dist/items/discovery.js +1 -1
  55. package/dist/{jar-D9z-X7tA.js → jar-5aLDI0nT.js} +2 -2
  56. package/dist/{legacy-reshape-C05SfAPR.js → legacy-reshape-CcdstKyI.js} +2 -2
  57. package/dist/{legacy-tints-B09J0Rxh.js → legacy-tints-l-541wgI.js} +1 -1
  58. package/dist/{loader-CWsTZgrk.js → loader-BvLcevlN.js} +100 -9
  59. package/dist/{loader-Lb0ZeILz.js → loader-C18GpurU.js} +1 -1
  60. package/dist/{loader-DD83d80u.d.ts → loader-C_1_amsq.d.ts} +18 -1
  61. package/dist/{locator-ycZzh_6z.js → locator-COMEtEn9.js} +23 -1
  62. package/dist/{manager-CkletR5K.js → manager-CYbAkWuT.js} +2 -2
  63. package/dist/models/loader.d.ts +1 -1
  64. package/dist/models/loader.js +1 -1
  65. package/dist/models/types.d.ts +1 -1
  66. package/dist/{models-BKxGkPS7.js → models-CQwcTZcg.js} +1 -1
  67. package/dist/mods/models.js +1 -1
  68. package/dist/mods/prepare.js +1 -1
  69. package/dist/mods/synthesize.js +1 -1
  70. package/dist/mods/tints.js +1 -1
  71. package/dist/{renderer-DB1Oe7xs.js → obj-BEjq3_Ao.js} +234 -234
  72. package/dist/obj-mesh-C6Sp4Ysc.d.ts +41 -0
  73. package/dist/obj-mesh-CiHiqrlm.js +97 -0
  74. package/dist/output/item-styles.js +1 -1
  75. package/dist/{pipeline-Bp6amYz_.d.ts → pipeline-BDvXcw20.d.ts} +1 -1
  76. package/dist/{pipeline-CgJaVpoL.js → pipeline-DRMsBiod.js} +14 -14
  77. package/dist/{prepare-D56Z-9cg.js → prepare-B8oPdGYz.js} +5 -5
  78. package/dist/{prepare-Cc8QZ3j0.js → prepare-C95vjt_o.js} +5 -5
  79. package/dist/{registry-DS5PZ57l.js → registry-DlduyjtM.js} +2 -2
  80. package/dist/render/entity-fallback.d.ts +3 -3
  81. package/dist/render/entity-fallback.js +1 -1
  82. package/dist/render/face.d.ts +1 -1
  83. package/dist/render/face.js +1 -1
  84. package/dist/render/fluid-bucket.js +1 -1
  85. package/dist/render/geo.d.ts +2 -2
  86. package/dist/render/geo.js +1 -1
  87. package/dist/render/geometry.d.ts +1 -1
  88. package/dist/render/legacy-tints.d.ts +1 -1
  89. package/dist/render/legacy-tints.js +1 -1
  90. package/dist/render/obj.d.ts +10 -3
  91. package/dist/render/obj.js +2 -2
  92. package/dist/render/pipeline.d.ts +1 -1
  93. package/dist/render/pipeline.js +1 -1
  94. package/dist/render/renderer.d.ts +1 -1
  95. package/dist/render/renderer.js +1 -1
  96. package/dist/render/tints.d.ts +1 -1
  97. package/dist/render/tints.js +1 -1
  98. package/dist/{renderer-C79EQDSn.d.ts → renderer-U20hnhbi.d.ts} +2 -2
  99. package/dist/resources/descriptor.js +1 -1
  100. package/dist/resources/entity-textures.d.ts +51 -0
  101. package/dist/resources/entity-textures.js +2 -0
  102. package/dist/resources/jar.js +1 -1
  103. package/dist/resources/locator.js +1 -1
  104. package/dist/resources/manager.js +1 -1
  105. package/dist/resources/synthetic.js +1 -1
  106. package/dist/{run-uq8_hUx9.d.ts → run-CvIqiZ6T.d.ts} +1 -1
  107. package/dist/{run-BPfpBZyZ.js → run-D2S_W5As.js} +10 -7
  108. package/dist/run.d.ts +1 -1
  109. package/dist/run.js +1 -1
  110. package/dist/{sources-Bxk-WOzH.js → sources-BlUriDCs.js} +1 -1
  111. package/dist/{synthesize-3Q0aaOnK.js → synthesize-jTjVjPAt.js} +2 -2
  112. package/dist/{synthetic-ZAUjXT7E.js → synthetic-rc9BPT4P.js} +0 -0
  113. package/dist/textures/loader.js +1 -1
  114. package/dist/tints-2k3ZhkY3.d.ts +41 -0
  115. package/dist/{tints-3VI_2SNy.js → tints-B3WQcPtx.js} +1 -1
  116. package/dist/{tints-Do9Sh3dg.d.ts → tints-DqhgFi8a.d.ts} +1 -1
  117. package/dist/tints-a9FWZLma.js +176 -0
  118. package/dist/{tints-CebmvjmP.js → tints-nxtGrqv5.js} +3 -3
  119. package/dist/{types-DpRSF9Vj.d.ts → types-qlp3I8_-.d.ts} +11 -0
  120. package/dist/versions/download.js +1 -1
  121. package/dist/versions/legacy-reshape.js +1 -1
  122. package/dist/versions/prepare.js +1 -1
  123. package/dist/workers/render-worker.d.ts +1 -1
  124. package/dist/workers/render-worker.js +2 -2
  125. package/package.json +1 -1
  126. package/dist/{download-D9aARBFp.js → download-1wAfrGKx.js} +1 -1
  127. package/dist/{face-CMJ3b3Ae.js → face-CKHboPfh.js} +1 -1
@@ -0,0 +1,83 @@
1
+ {
2
+ "texture_size": [
3
+ 16,
4
+ 16
5
+ ],
6
+ "elements": [
7
+ {
8
+ "name": "fluid",
9
+ "from": [
10
+ 0,
11
+ 0,
12
+ 0
13
+ ],
14
+ "to": [
15
+ 16,
16
+ 16,
17
+ 16
18
+ ],
19
+ "faces": {
20
+ "north": {
21
+ "uv": [
22
+ 0,
23
+ 0,
24
+ 8,
25
+ 8
26
+ ],
27
+ "texture": "#flow",
28
+ "cullface": "north"
29
+ },
30
+ "east": {
31
+ "uv": [
32
+ 0,
33
+ 0,
34
+ 8,
35
+ 8
36
+ ],
37
+ "texture": "#flow",
38
+ "cullface": "east"
39
+ },
40
+ "south": {
41
+ "uv": [
42
+ 0,
43
+ 0,
44
+ 8,
45
+ 8
46
+ ],
47
+ "texture": "#flow",
48
+ "cullface": "south"
49
+ },
50
+ "west": {
51
+ "uv": [
52
+ 0,
53
+ 0,
54
+ 8,
55
+ 8
56
+ ],
57
+ "texture": "#flow",
58
+ "cullface": "west"
59
+ },
60
+ "up": {
61
+ "uv": [
62
+ 0,
63
+ 0,
64
+ 16,
65
+ 16
66
+ ],
67
+ "texture": "#still",
68
+ "cullface": "up"
69
+ },
70
+ "down": {
71
+ "uv": [
72
+ 0,
73
+ 0,
74
+ 16,
75
+ 16
76
+ ],
77
+ "texture": "#still",
78
+ "cullface": "down"
79
+ }
80
+ }
81
+ }
82
+ ]
83
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "texture_size": [
3
+ 16,
4
+ 16
5
+ ],
6
+ "elements": [
7
+ {
8
+ "name": "fluid",
9
+ "from": [
10
+ 0,
11
+ 0,
12
+ 0
13
+ ],
14
+ "to": [
15
+ 16,
16
+ 16,
17
+ 16
18
+ ],
19
+ "faces": {
20
+ "north": {
21
+ "uv": [
22
+ 0,
23
+ 0,
24
+ 8,
25
+ 8
26
+ ],
27
+ "texture": "#flow",
28
+ "cullface": "north",
29
+ "tintindex": 0
30
+ },
31
+ "east": {
32
+ "uv": [
33
+ 0,
34
+ 0,
35
+ 8,
36
+ 8
37
+ ],
38
+ "texture": "#flow",
39
+ "cullface": "east",
40
+ "tintindex": 0
41
+ },
42
+ "south": {
43
+ "uv": [
44
+ 0,
45
+ 0,
46
+ 8,
47
+ 8
48
+ ],
49
+ "texture": "#flow",
50
+ "cullface": "south",
51
+ "tintindex": 0
52
+ },
53
+ "west": {
54
+ "uv": [
55
+ 0,
56
+ 0,
57
+ 8,
58
+ 8
59
+ ],
60
+ "texture": "#flow",
61
+ "cullface": "west",
62
+ "tintindex": 0
63
+ },
64
+ "up": {
65
+ "uv": [
66
+ 0,
67
+ 0,
68
+ 16,
69
+ 16
70
+ ],
71
+ "texture": "#still",
72
+ "cullface": "up",
73
+ "tintindex": 0
74
+ },
75
+ "down": {
76
+ "uv": [
77
+ 0,
78
+ 0,
79
+ 16,
80
+ 16
81
+ ],
82
+ "texture": "#still",
83
+ "cullface": "down",
84
+ "tintindex": 0
85
+ }
86
+ }
87
+ }
88
+ ]
89
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "__comment": "Hanging sign, for the block pack. A 16x2x4 bar at the ceiling, a 14x10x2 board below it, and two short chains between — the chains are boxes cut from the sheet's chain art rather than the crossed planes the entity model uses, which reads the same at world scale. UVs follow the 64x32 hanging sheet's box unwrap.",
3
+ "texture_size": [64, 32],
4
+ "elements": [
5
+ {
6
+ "name": "bar",
7
+ "from": [0, 14, 6],
8
+ "to": [16, 16, 10],
9
+ "faces": {
10
+ "north": { "uv": [1, 2, 5, 3], "texture": "#texture" },
11
+ "east": { "uv": [5, 2, 6, 3], "texture": "#texture" },
12
+ "south": { "uv": [6, 2, 10, 3], "texture": "#texture" },
13
+ "west": { "uv": [0, 2, 1, 3], "texture": "#texture" },
14
+ "up": { "uv": [5, 0, 9, 2], "texture": "#texture" },
15
+ "down": { "uv": [1, 0, 5, 2], "texture": "#texture" }
16
+ }
17
+ },
18
+ {
19
+ "name": "chain_left",
20
+ "from": [3, 10, 7.5],
21
+ "to": [5, 14, 8.5],
22
+ "faces": {
23
+ "north": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
24
+ "east": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
25
+ "south": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
26
+ "west": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" }
27
+ }
28
+ },
29
+ {
30
+ "name": "chain_right",
31
+ "from": [11, 10, 7.5],
32
+ "to": [13, 14, 8.5],
33
+ "faces": {
34
+ "north": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
35
+ "east": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
36
+ "south": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" },
37
+ "west": { "uv": [0, 3, 0.5, 5.5], "texture": "#texture" }
38
+ }
39
+ },
40
+ {
41
+ "name": "board",
42
+ "from": [1, 0, 7],
43
+ "to": [15, 10, 9],
44
+ "faces": {
45
+ "north": { "uv": [0.5, 7, 4, 12], "texture": "#texture" },
46
+ "east": { "uv": [4, 7, 4.5, 12], "texture": "#texture" },
47
+ "south": { "uv": [4.5, 7, 8, 12], "texture": "#texture" },
48
+ "west": { "uv": [0, 7, 0.5, 12], "texture": "#texture" },
49
+ "up": { "uv": [4, 6, 7.5, 7], "texture": "#texture" },
50
+ "down": { "uv": [0.5, 6, 4, 7], "texture": "#texture" }
51
+ }
52
+ }
53
+ ]
54
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "__comment": "Standing sign, for the block pack. Vanilla ships no model for one: SignRenderer draws it from an entity model, so a world viewer reading only the assets sees nothing. Proportions follow that model (a 24x12x2 board on a 2x14x2 post, at the renderer's 2/3 scale) and the UVs follow the 64x32 entity sheet's own box unwrap, both verified by rendering.",
3
+ "texture_size": [64, 32],
4
+ "elements": [
5
+ {
6
+ "name": "post",
7
+ "from": [7.25, 0, 7.25],
8
+ "to": [8.75, 9, 8.75],
9
+ "faces": {
10
+ "north": { "uv": [0.5, 8, 1, 15], "texture": "#texture" },
11
+ "east": { "uv": [1, 8, 1.5, 15], "texture": "#texture" },
12
+ "south": { "uv": [1.5, 8, 2, 15], "texture": "#texture" },
13
+ "west": { "uv": [0, 8, 0.5, 15], "texture": "#texture" },
14
+ "up": { "uv": [1, 7, 1.5, 8], "texture": "#texture" },
15
+ "down": { "uv": [0.5, 7, 1, 8], "texture": "#texture" }
16
+ }
17
+ },
18
+ {
19
+ "name": "board",
20
+ "from": [0, 9, 7.25],
21
+ "to": [16, 17, 8.75],
22
+ "faces": {
23
+ "north": { "uv": [0.5, 1, 6.5, 7], "texture": "#texture" },
24
+ "east": { "uv": [6.5, 1, 7, 7], "texture": "#texture" },
25
+ "south": { "uv": [7, 1, 13, 7], "texture": "#texture" },
26
+ "west": { "uv": [0, 1, 0.5, 7], "texture": "#texture" },
27
+ "up": { "uv": [6.5, 0, 12.5, 1], "texture": "#texture" },
28
+ "down": { "uv": [0.5, 0, 6.5, 1], "texture": "#texture" }
29
+ }
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "__comment": "Wall sign: the same board as the standing sign with no post, sitting against the block behind it. Authored facing north, so the blockstate's facing rotates it from there.",
3
+ "texture_size": [64, 32],
4
+ "elements": [
5
+ {
6
+ "name": "board",
7
+ "from": [0, 4.5, 0],
8
+ "to": [16, 12.5, 1.5],
9
+ "faces": {
10
+ "north": { "uv": [0.5, 1, 6.5, 7], "texture": "#texture" },
11
+ "east": { "uv": [6.5, 1, 7, 7], "texture": "#texture" },
12
+ "south": { "uv": [7, 1, 13, 7], "texture": "#texture" },
13
+ "west": { "uv": [0, 1, 0.5, 7], "texture": "#texture" },
14
+ "up": { "uv": [6.5, 0, 12.5, 1], "texture": "#texture" },
15
+ "down": { "uv": [0.5, 0, 6.5, 1], "texture": "#texture" }
16
+ }
17
+ }
18
+ ]
19
+ }
@@ -1,2 +1,2 @@
1
- import { t as loadAtlasResolver } from "../registry-DS5PZ57l.js";
1
+ import { t as loadAtlasResolver } from "../registry-DlduyjtM.js";
2
2
  export { loadAtlasResolver };
@@ -1,2 +1,2 @@
1
- import { a as UnstitchAtlasSource, i as SingleAtlasSource, n as DirectoryAtlasSource, o as createAtlasResolver, r as PalettedPermutationsSource, s as parseAtlasSources, t as AtlasSourceError } from "../sources-Bxk-WOzH.js";
1
+ import { a as UnstitchAtlasSource, i as SingleAtlasSource, n as DirectoryAtlasSource, o as createAtlasResolver, r as PalettedPermutationsSource, s as parseAtlasSources, t as AtlasSourceError } from "../sources-BlUriDCs.js";
2
2
  export { AtlasSourceError, DirectoryAtlasSource, PalettedPermutationsSource, SingleAtlasSource, UnstitchAtlasSource, createAtlasResolver, parseAtlasSources };
@@ -0,0 +1,130 @@
1
+ //#region src/blocks/atlas-pack.ts
2
+ const DEFAULT_PADDING = 4;
3
+ const DEFAULT_MAX_PAGE_SIZE = 4096;
4
+ function nextPowerOfTwo(value) {
5
+ let size = 1;
6
+ while (size < value) size *= 2;
7
+ return size;
8
+ }
9
+ /**
10
+ * A NaN or negative option would otherwise classify every sprite oversized and
11
+ * write an empty atlas that looks like a successful export.
12
+ */
13
+ function requireSize(value, name, minimum) {
14
+ if (!Number.isSafeInteger(value) || value < minimum) throw new RangeError(`${name} must be an integer of at least ${minimum}, got ${value}`);
15
+ return value;
16
+ }
17
+ /** Largest power of two that still fits under `value`, floored at 1. */
18
+ function previousPowerOfTwo(value) {
19
+ let size = 1;
20
+ while (size * 2 <= value) size *= 2;
21
+ return size;
22
+ }
23
+ /**
24
+ * Lay entries out at a fixed page width, opening a new page when the current
25
+ * one runs out of shelf room. Returns the placements plus the used height of
26
+ * every page, so the caller can trim the last one.
27
+ */
28
+ function shelvePlacements(entries, pageSize, padding) {
29
+ const placements = [];
30
+ const usedHeights = [0];
31
+ let shelves = [];
32
+ let page = 0;
33
+ for (const entry of entries) {
34
+ const width = entry.texture.width + padding * 2;
35
+ const height = entry.texture.height + padding * 2;
36
+ let shelf = shelves.find((candidate) => candidate.height >= height && candidate.cursor + width <= pageSize);
37
+ if (!shelf) {
38
+ if (usedHeights[page] + height > pageSize) {
39
+ page++;
40
+ shelves = [];
41
+ usedHeights[page] = 0;
42
+ }
43
+ shelf = {
44
+ y: usedHeights[page],
45
+ height,
46
+ cursor: 0
47
+ };
48
+ shelves.push(shelf);
49
+ usedHeights[page] += height;
50
+ }
51
+ placements.push({
52
+ entry,
53
+ page,
54
+ x: shelf.cursor + padding,
55
+ y: shelf.y + padding
56
+ });
57
+ shelf.cursor += width;
58
+ }
59
+ return {
60
+ placements,
61
+ usedHeights
62
+ };
63
+ }
64
+ /**
65
+ * Copy a sprite into a page, extending its edge pixels outward across the
66
+ * padding by clamping the sample coordinates.
67
+ */
68
+ function blit(page, texture, left, top, padding) {
69
+ for (let y = -padding; y < texture.height + padding; y++) {
70
+ const sourceY = Math.min(texture.height - 1, Math.max(0, y));
71
+ for (let x = -padding; x < texture.width + padding; x++) {
72
+ const sourceX = Math.min(texture.width - 1, Math.max(0, x));
73
+ const source = (sourceY * texture.width + sourceX) * 4;
74
+ const target = ((top + y) * page.width + (left + x)) * 4;
75
+ page.data[target] = texture.data[source];
76
+ page.data[target + 1] = texture.data[source + 1];
77
+ page.data[target + 2] = texture.data[source + 2];
78
+ page.data[target + 3] = texture.data[source + 3];
79
+ }
80
+ }
81
+ }
82
+ function packAtlas(entries, options = {}) {
83
+ const padding = requireSize(options.padding ?? DEFAULT_PADDING, "padding", 0);
84
+ const pageCeiling = previousPowerOfTwo(requireSize(options.maxPageSize ?? DEFAULT_MAX_PAGE_SIZE, "maxPageSize", 1));
85
+ const oversized = [];
86
+ const packable = [];
87
+ for (const entry of entries) if (entry.texture.width + padding * 2 <= pageCeiling && entry.texture.height + padding * 2 <= pageCeiling) packable.push(entry);
88
+ else oversized.push(entry.key);
89
+ packable.sort((left, right) => right.texture.height - left.texture.height || right.texture.width - left.texture.width || left.key.localeCompare(right.key));
90
+ let area = 0;
91
+ let widest = 1;
92
+ for (const entry of packable) {
93
+ area += (entry.texture.width + padding * 2) * (entry.texture.height + padding * 2);
94
+ widest = Math.max(widest, entry.texture.width + padding * 2);
95
+ }
96
+ let pageSize = Math.min(pageCeiling, Math.max(nextPowerOfTwo(widest), nextPowerOfTwo(Math.ceil(Math.sqrt(area)))));
97
+ let layout = shelvePlacements(packable, pageSize, padding);
98
+ while (layout.usedHeights.length > 1 && pageSize < pageCeiling) {
99
+ pageSize *= 2;
100
+ layout = shelvePlacements(packable, pageSize, padding);
101
+ }
102
+ const pages = layout.usedHeights.map((used) => {
103
+ const height = Math.max(1, nextPowerOfTwo(used));
104
+ return {
105
+ width: pageSize,
106
+ height,
107
+ data: new Uint8ClampedArray(pageSize * height * 4)
108
+ };
109
+ });
110
+ const rects = [];
111
+ for (const placement of layout.placements) {
112
+ blit(pages[placement.page], placement.entry.texture, placement.x, placement.y, padding);
113
+ rects.push({
114
+ key: placement.entry.key,
115
+ page: placement.page,
116
+ x: placement.x,
117
+ y: placement.y,
118
+ width: placement.entry.texture.width,
119
+ height: placement.entry.texture.height
120
+ });
121
+ }
122
+ return {
123
+ pages,
124
+ rects,
125
+ oversized,
126
+ padding
127
+ };
128
+ }
129
+ //#endregion
130
+ export { packAtlas as t };
@@ -0,0 +1,41 @@
1
+ import { r as Texture } from "./loader-Myy22TDL.js";
2
+ //#region src/blocks/atlas-pack.d.ts
3
+ interface PackEntry {
4
+ /** Caller's identifier; carried through to the emitted rect. */
5
+ key: string;
6
+ texture: Texture;
7
+ }
8
+ interface PackedRect {
9
+ key: string;
10
+ page: number;
11
+ /** Position of the sprite itself, inside its padding. */
12
+ x: number;
13
+ y: number;
14
+ width: number;
15
+ height: number;
16
+ }
17
+ interface PackedPage {
18
+ width: number;
19
+ height: number;
20
+ /** RGBA, row-major. */
21
+ data: Uint8ClampedArray;
22
+ }
23
+ interface PackedAtlas {
24
+ pages: PackedPage[];
25
+ rects: PackedRect[];
26
+ /** Entries too large for a single page — reported, never dropped silently. */
27
+ oversized: string[];
28
+ padding: number;
29
+ }
30
+ interface PackOptions {
31
+ /** Edge-extended border per side, in pixels. */
32
+ padding?: number;
33
+ /**
34
+ * Hard ceiling on a page's dimensions; GPUs and browsers both cap this.
35
+ * Pages stay power-of-two, so a ceiling that is not one is rounded down.
36
+ */
37
+ maxPageSize?: number;
38
+ }
39
+ declare function packAtlas(entries: PackEntry[], options?: PackOptions): PackedAtlas;
40
+ //#endregion
41
+ export { PackedRect as a, PackedPage as i, PackOptions as n, packAtlas as o, PackedAtlas as r, PackEntry as t };