@cult-frog/noise 0.0.0-stage → 0.1.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 (264) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +205 -2
  4. package/dist/fractal/_types/fractalOptions.d.ts +36 -0
  5. package/dist/fractal/_types/fractalOptions.d.ts.map +1 -0
  6. package/dist/fractal/_types/fractalOptions.js +2 -0
  7. package/dist/fractal/_types/fractalOptions.js.map +1 -0
  8. package/dist/fractal/_types/index.d.ts +2 -0
  9. package/dist/fractal/_types/index.d.ts.map +1 -0
  10. package/dist/fractal/_types/index.js +2 -0
  11. package/dist/fractal/_types/index.js.map +1 -0
  12. package/dist/fractal/fractal.d.ts +17 -0
  13. package/dist/fractal/fractal.d.ts.map +1 -0
  14. package/dist/fractal/fractal.js +31 -0
  15. package/dist/fractal/fractal.js.map +1 -0
  16. package/dist/fractal/index.d.ts +4 -0
  17. package/dist/fractal/index.d.ts.map +1 -0
  18. package/dist/fractal/index.js +3 -0
  19. package/dist/fractal/index.js.map +1 -0
  20. package/dist/fractal/options.d.ts +14 -0
  21. package/dist/fractal/options.d.ts.map +1 -0
  22. package/dist/fractal/options.js +57 -0
  23. package/dist/fractal/options.js.map +1 -0
  24. package/dist/gradient/cubeEdge3.d.ts +11 -0
  25. package/dist/gradient/cubeEdge3.d.ts.map +1 -0
  26. package/dist/gradient/cubeEdge3.js +39 -0
  27. package/dist/gradient/cubeEdge3.js.map +1 -0
  28. package/dist/gradient/index.d.ts +2 -0
  29. package/dist/gradient/index.d.ts.map +1 -0
  30. package/dist/gradient/index.js +2 -0
  31. package/dist/gradient/index.js.map +1 -0
  32. package/dist/hashes/hash.d.ts +16 -0
  33. package/dist/hashes/hash.d.ts.map +1 -0
  34. package/dist/hashes/hash.js +37 -0
  35. package/dist/hashes/hash.js.map +1 -0
  36. package/dist/hashes/hashes.d.ts +3 -0
  37. package/dist/hashes/hashes.d.ts.map +1 -0
  38. package/dist/hashes/hashes.js +3 -0
  39. package/dist/hashes/hashes.js.map +1 -0
  40. package/dist/hashes/index.d.ts +2 -0
  41. package/dist/hashes/index.d.ts.map +1 -0
  42. package/dist/hashes/index.js +2 -0
  43. package/dist/hashes/index.js.map +1 -0
  44. package/dist/hashes/lowbias.d.ts +12 -0
  45. package/dist/hashes/lowbias.d.ts.map +1 -0
  46. package/dist/hashes/lowbias.js +19 -0
  47. package/dist/hashes/lowbias.js.map +1 -0
  48. package/dist/index.d.ts +4 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +3 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/noiseMap/_types/index.d.ts +3 -0
  53. package/dist/noiseMap/_types/index.d.ts.map +1 -0
  54. package/dist/noiseMap/_types/index.js +2 -0
  55. package/dist/noiseMap/_types/index.js.map +1 -0
  56. package/dist/noiseMap/_types/noise2d.d.ts +21 -0
  57. package/dist/noiseMap/_types/noise2d.d.ts.map +1 -0
  58. package/dist/noiseMap/_types/noise2d.js +2 -0
  59. package/dist/noiseMap/_types/noise2d.js.map +1 -0
  60. package/dist/noiseMap/_types/noise3d.d.ts +24 -0
  61. package/dist/noiseMap/_types/noise3d.d.ts.map +1 -0
  62. package/dist/noiseMap/_types/noise3d.js +2 -0
  63. package/dist/noiseMap/_types/noise3d.js.map +1 -0
  64. package/dist/noiseMap/index.d.ts +6 -0
  65. package/dist/noiseMap/index.d.ts.map +1 -0
  66. package/dist/noiseMap/index.js +3 -0
  67. package/dist/noiseMap/index.js.map +1 -0
  68. package/dist/noiseMap/noise2d.d.ts +52 -0
  69. package/dist/noiseMap/noise2d.d.ts.map +1 -0
  70. package/dist/noiseMap/noise2d.js +105 -0
  71. package/dist/noiseMap/noise2d.js.map +1 -0
  72. package/dist/noiseMap/noise3d.d.ts +62 -0
  73. package/dist/noiseMap/noise3d.d.ts.map +1 -0
  74. package/dist/noiseMap/noise3d.js +129 -0
  75. package/dist/noiseMap/noise3d.js.map +1 -0
  76. package/dist/noiseTypes/cellular/2d.d.ts +36 -0
  77. package/dist/noiseTypes/cellular/2d.d.ts.map +1 -0
  78. package/dist/noiseTypes/cellular/2d.js +123 -0
  79. package/dist/noiseTypes/cellular/2d.js.map +1 -0
  80. package/dist/noiseTypes/cellular/3d.d.ts +32 -0
  81. package/dist/noiseTypes/cellular/3d.d.ts.map +1 -0
  82. package/dist/noiseTypes/cellular/3d.js +143 -0
  83. package/dist/noiseTypes/cellular/3d.js.map +1 -0
  84. package/dist/noiseTypes/cellular/_types/index.d.ts +2 -0
  85. package/dist/noiseTypes/cellular/_types/index.d.ts.map +1 -0
  86. package/dist/noiseTypes/cellular/_types/index.js +2 -0
  87. package/dist/noiseTypes/cellular/_types/index.js.map +1 -0
  88. package/dist/noiseTypes/cellular/_types/options.d.ts +37 -0
  89. package/dist/noiseTypes/cellular/_types/options.d.ts.map +1 -0
  90. package/dist/noiseTypes/cellular/_types/options.js +2 -0
  91. package/dist/noiseTypes/cellular/_types/options.js.map +1 -0
  92. package/dist/noiseTypes/cellular/defaultOptions.d.ts +4 -0
  93. package/dist/noiseTypes/cellular/defaultOptions.d.ts.map +1 -0
  94. package/dist/noiseTypes/cellular/defaultOptions.js +13 -0
  95. package/dist/noiseTypes/cellular/defaultOptions.js.map +1 -0
  96. package/dist/noiseTypes/cellular/floorDiv.d.ts +18 -0
  97. package/dist/noiseTypes/cellular/floorDiv.d.ts.map +1 -0
  98. package/dist/noiseTypes/cellular/floorDiv.js +28 -0
  99. package/dist/noiseTypes/cellular/floorDiv.js.map +1 -0
  100. package/dist/noiseTypes/cellular/index.d.ts +4 -0
  101. package/dist/noiseTypes/cellular/index.d.ts.map +1 -0
  102. package/dist/noiseTypes/cellular/index.js +3 -0
  103. package/dist/noiseTypes/cellular/index.js.map +1 -0
  104. package/dist/noiseTypes/cellular/options.d.ts +6 -0
  105. package/dist/noiseTypes/cellular/options.d.ts.map +1 -0
  106. package/dist/noiseTypes/cellular/options.js +20 -0
  107. package/dist/noiseTypes/cellular/options.js.map +1 -0
  108. package/dist/noiseTypes/index.d.ts +5 -0
  109. package/dist/noiseTypes/index.d.ts.map +1 -0
  110. package/dist/noiseTypes/index.js +5 -0
  111. package/dist/noiseTypes/index.js.map +1 -0
  112. package/dist/noiseTypes/perlin/2d.d.ts +23 -0
  113. package/dist/noiseTypes/perlin/2d.d.ts.map +1 -0
  114. package/dist/noiseTypes/perlin/2d.js +64 -0
  115. package/dist/noiseTypes/perlin/2d.js.map +1 -0
  116. package/dist/noiseTypes/perlin/3d.d.ts +24 -0
  117. package/dist/noiseTypes/perlin/3d.d.ts.map +1 -0
  118. package/dist/noiseTypes/perlin/3d.js +69 -0
  119. package/dist/noiseTypes/perlin/3d.js.map +1 -0
  120. package/dist/noiseTypes/perlin/_types/index.d.ts +2 -0
  121. package/dist/noiseTypes/perlin/_types/index.d.ts.map +1 -0
  122. package/dist/noiseTypes/perlin/_types/index.js +2 -0
  123. package/dist/noiseTypes/perlin/_types/index.js.map +1 -0
  124. package/dist/noiseTypes/perlin/_types/options.d.ts +22 -0
  125. package/dist/noiseTypes/perlin/_types/options.d.ts.map +1 -0
  126. package/dist/noiseTypes/perlin/_types/options.js +2 -0
  127. package/dist/noiseTypes/perlin/_types/options.js.map +1 -0
  128. package/dist/noiseTypes/perlin/defaultOptions.d.ts +4 -0
  129. package/dist/noiseTypes/perlin/defaultOptions.d.ts.map +1 -0
  130. package/dist/noiseTypes/perlin/defaultOptions.js +14 -0
  131. package/dist/noiseTypes/perlin/defaultOptions.js.map +1 -0
  132. package/dist/noiseTypes/perlin/index.d.ts +4 -0
  133. package/dist/noiseTypes/perlin/index.d.ts.map +1 -0
  134. package/dist/noiseTypes/perlin/index.js +3 -0
  135. package/dist/noiseTypes/perlin/index.js.map +1 -0
  136. package/dist/noiseTypes/perlin/options.d.ts +9 -0
  137. package/dist/noiseTypes/perlin/options.d.ts.map +1 -0
  138. package/dist/noiseTypes/perlin/options.js +17 -0
  139. package/dist/noiseTypes/perlin/options.js.map +1 -0
  140. package/dist/noiseTypes/perlin/sample2.d.ts +25 -0
  141. package/dist/noiseTypes/perlin/sample2.d.ts.map +1 -0
  142. package/dist/noiseTypes/perlin/sample2.js +58 -0
  143. package/dist/noiseTypes/perlin/sample2.js.map +1 -0
  144. package/dist/noiseTypes/perlin/sample3.d.ts +9 -0
  145. package/dist/noiseTypes/perlin/sample3.d.ts.map +1 -0
  146. package/dist/noiseTypes/perlin/sample3.js +38 -0
  147. package/dist/noiseTypes/perlin/sample3.js.map +1 -0
  148. package/dist/noiseTypes/simplex/2d.d.ts +23 -0
  149. package/dist/noiseTypes/simplex/2d.d.ts.map +1 -0
  150. package/dist/noiseTypes/simplex/2d.js +64 -0
  151. package/dist/noiseTypes/simplex/2d.js.map +1 -0
  152. package/dist/noiseTypes/simplex/3d.d.ts +25 -0
  153. package/dist/noiseTypes/simplex/3d.d.ts.map +1 -0
  154. package/dist/noiseTypes/simplex/3d.js +70 -0
  155. package/dist/noiseTypes/simplex/3d.js.map +1 -0
  156. package/dist/noiseTypes/simplex/_types/index.d.ts +2 -0
  157. package/dist/noiseTypes/simplex/_types/index.d.ts.map +1 -0
  158. package/dist/noiseTypes/simplex/_types/index.js +2 -0
  159. package/dist/noiseTypes/simplex/_types/index.js.map +1 -0
  160. package/dist/noiseTypes/simplex/_types/options.d.ts +33 -0
  161. package/dist/noiseTypes/simplex/_types/options.d.ts.map +1 -0
  162. package/dist/noiseTypes/simplex/_types/options.js +2 -0
  163. package/dist/noiseTypes/simplex/_types/options.js.map +1 -0
  164. package/dist/noiseTypes/simplex/defaultOptions.d.ts +4 -0
  165. package/dist/noiseTypes/simplex/defaultOptions.d.ts.map +1 -0
  166. package/dist/noiseTypes/simplex/defaultOptions.js +14 -0
  167. package/dist/noiseTypes/simplex/defaultOptions.js.map +1 -0
  168. package/dist/noiseTypes/simplex/index.d.ts +4 -0
  169. package/dist/noiseTypes/simplex/index.d.ts.map +1 -0
  170. package/dist/noiseTypes/simplex/index.js +3 -0
  171. package/dist/noiseTypes/simplex/index.js.map +1 -0
  172. package/dist/noiseTypes/simplex/options.d.ts +9 -0
  173. package/dist/noiseTypes/simplex/options.d.ts.map +1 -0
  174. package/dist/noiseTypes/simplex/options.js +17 -0
  175. package/dist/noiseTypes/simplex/options.js.map +1 -0
  176. package/dist/noiseTypes/simplex/sample2.d.ts +32 -0
  177. package/dist/noiseTypes/simplex/sample2.d.ts.map +1 -0
  178. package/dist/noiseTypes/simplex/sample2.js +94 -0
  179. package/dist/noiseTypes/simplex/sample2.js.map +1 -0
  180. package/dist/noiseTypes/simplex/sample3.d.ts +19 -0
  181. package/dist/noiseTypes/simplex/sample3.d.ts.map +1 -0
  182. package/dist/noiseTypes/simplex/sample3.js +110 -0
  183. package/dist/noiseTypes/simplex/sample3.js.map +1 -0
  184. package/dist/noiseTypes/white/2d.d.ts +18 -0
  185. package/dist/noiseTypes/white/2d.d.ts.map +1 -0
  186. package/dist/noiseTypes/white/2d.js +33 -0
  187. package/dist/noiseTypes/white/2d.js.map +1 -0
  188. package/dist/noiseTypes/white/3d.d.ts +17 -0
  189. package/dist/noiseTypes/white/3d.d.ts.map +1 -0
  190. package/dist/noiseTypes/white/3d.js +34 -0
  191. package/dist/noiseTypes/white/3d.js.map +1 -0
  192. package/dist/noiseTypes/white/_types/index.d.ts +2 -0
  193. package/dist/noiseTypes/white/_types/index.d.ts.map +1 -0
  194. package/dist/noiseTypes/white/_types/index.js +2 -0
  195. package/dist/noiseTypes/white/_types/index.js.map +1 -0
  196. package/dist/noiseTypes/white/_types/options.d.ts +28 -0
  197. package/dist/noiseTypes/white/_types/options.d.ts.map +1 -0
  198. package/dist/noiseTypes/white/_types/options.js +2 -0
  199. package/dist/noiseTypes/white/_types/options.js.map +1 -0
  200. package/dist/noiseTypes/white/defaultOptions.d.ts +4 -0
  201. package/dist/noiseTypes/white/defaultOptions.d.ts.map +1 -0
  202. package/dist/noiseTypes/white/defaultOptions.js +10 -0
  203. package/dist/noiseTypes/white/defaultOptions.js.map +1 -0
  204. package/dist/noiseTypes/white/index.d.ts +4 -0
  205. package/dist/noiseTypes/white/index.d.ts.map +1 -0
  206. package/dist/noiseTypes/white/index.js +3 -0
  207. package/dist/noiseTypes/white/index.js.map +1 -0
  208. package/dist/noiseTypes/white/options.d.ts +6 -0
  209. package/dist/noiseTypes/white/options.d.ts.map +1 -0
  210. package/dist/noiseTypes/white/options.js +14 -0
  211. package/dist/noiseTypes/white/options.js.map +1 -0
  212. package/package.json +74 -3
  213. package/src/fractal/_types/fractalOptions.ts +35 -0
  214. package/src/fractal/_types/index.ts +1 -0
  215. package/src/fractal/fractal.ts +41 -0
  216. package/src/fractal/index.ts +4 -0
  217. package/src/fractal/options.ts +62 -0
  218. package/src/gradient/cubeEdge3.ts +47 -0
  219. package/src/gradient/index.ts +1 -0
  220. package/src/hashes/hash.ts +41 -0
  221. package/src/hashes/hashes.ts +2 -0
  222. package/src/hashes/index.ts +1 -0
  223. package/src/hashes/lowbias.ts +18 -0
  224. package/src/index.ts +4 -0
  225. package/src/noiseMap/_types/index.ts +2 -0
  226. package/src/noiseMap/_types/noise2d.ts +21 -0
  227. package/src/noiseMap/_types/noise3d.ts +24 -0
  228. package/src/noiseMap/index.ts +7 -0
  229. package/src/noiseMap/noise2d.ts +117 -0
  230. package/src/noiseMap/noise3d.ts +146 -0
  231. package/src/noiseTypes/cellular/2d.ts +142 -0
  232. package/src/noiseTypes/cellular/3d.ts +171 -0
  233. package/src/noiseTypes/cellular/_types/index.ts +1 -0
  234. package/src/noiseTypes/cellular/_types/options.ts +37 -0
  235. package/src/noiseTypes/cellular/defaultOptions.ts +15 -0
  236. package/src/noiseTypes/cellular/floorDiv.ts +27 -0
  237. package/src/noiseTypes/cellular/index.ts +4 -0
  238. package/src/noiseTypes/cellular/options.ts +20 -0
  239. package/src/noiseTypes/index.ts +4 -0
  240. package/src/noiseTypes/perlin/2d.ts +86 -0
  241. package/src/noiseTypes/perlin/3d.ts +93 -0
  242. package/src/noiseTypes/perlin/_types/index.ts +1 -0
  243. package/src/noiseTypes/perlin/_types/options.ts +23 -0
  244. package/src/noiseTypes/perlin/defaultOptions.ts +16 -0
  245. package/src/noiseTypes/perlin/index.ts +4 -0
  246. package/src/noiseTypes/perlin/options.ts +19 -0
  247. package/src/noiseTypes/perlin/sample2.ts +62 -0
  248. package/src/noiseTypes/perlin/sample3.ts +43 -0
  249. package/src/noiseTypes/simplex/2d.ts +86 -0
  250. package/src/noiseTypes/simplex/3d.ts +94 -0
  251. package/src/noiseTypes/simplex/_types/index.ts +1 -0
  252. package/src/noiseTypes/simplex/_types/options.ts +34 -0
  253. package/src/noiseTypes/simplex/defaultOptions.ts +16 -0
  254. package/src/noiseTypes/simplex/index.ts +4 -0
  255. package/src/noiseTypes/simplex/options.ts +19 -0
  256. package/src/noiseTypes/simplex/sample2.ts +103 -0
  257. package/src/noiseTypes/simplex/sample3.ts +128 -0
  258. package/src/noiseTypes/white/2d.ts +44 -0
  259. package/src/noiseTypes/white/3d.ts +46 -0
  260. package/src/noiseTypes/white/_types/index.ts +1 -0
  261. package/src/noiseTypes/white/_types/options.ts +28 -0
  262. package/src/noiseTypes/white/defaultOptions.ts +12 -0
  263. package/src/noiseTypes/white/index.ts +4 -0
  264. package/src/noiseTypes/white/options.ts +14 -0
@@ -0,0 +1,123 @@
1
+ import { Hashes } from '../../hashes/index.js';
2
+ import { Noise2D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_CELLULAR_2D_OPTIONS } from './defaultOptions.js';
4
+ import { floorDiv, floorMod } from './floorDiv.js';
5
+ import { validateOptions2 } from './options.js';
6
+ /** Numbers stored per cell in the point grid: the point's x and y within its cell. */
7
+ const CELL_STRIDE = 2;
8
+ /**
9
+ * Extra cells stored on each side of the cells the map covers. The 3×3 search
10
+ * needs one; the second leaves room for a 5×5 search without resizing.
11
+ */
12
+ const CELL_PADDING = 2;
13
+ const CELL_PADDING_TOTAL = CELL_PADDING * 2;
14
+ /** Scales a 32-bit hash into [0, 1). Exact, since it is a power of two. */
15
+ const INV_2_POW_32 = 2 ** -32;
16
+ /**
17
+ * Creates a `width` × `height` map of cellular (Worley) noise in [0, 1]. Each
18
+ * value is the distance from its cell to the nearest feature point (F1),
19
+ * divided by the diagonal of one grid cell. The caller owns the returned map.
20
+ *
21
+ * The world is divided into `cellWidth` × `cellHeight` grid cells anchored at
22
+ * world (0, 0), and each grid cell holds one point whose position depends only
23
+ * on the cell's coordinates and the seed. Each value therefore depends only on
24
+ * its world cell (`x + offsetX`, `y + offsetY`) and the other options, never on
25
+ * the map's size, so chunks of any size created with the same options and their
26
+ * world origin as the offset agree bit for bit wherever they overlap.
27
+ *
28
+ * The mapping to [0, 1] is fixed by the cell size rather than stretched per
29
+ * map. The diagonal is the true upper bound but is almost never reached: 256²
30
+ * maps span roughly 0–0.8 and average about 0.3, so the result reads darker
31
+ * than gradient noise centred on 0.5.
32
+ *
33
+ * Distances are measured from the sample's position inside its own grid cell,
34
+ * not from absolute world coordinates, so precision does not fall off far from
35
+ * the origin. The point hash takes 32-bit cell coordinates, so the pattern
36
+ * repeats every 2^32 grid cells along each axis.
37
+ *
38
+ * Known limitation: only the 3×3 block of grid cells around each sample is
39
+ * searched, so the true nearest point is missed when it lies two cells over.
40
+ * For square cells that is rare (about one value in a 256² map), but it grows
41
+ * with the cell's aspect ratio and shows as visible seams: roughly 0.15% of
42
+ * values at 10 × 20, 3% at 5 × 20 and 8% at 3 × 17. Searching
43
+ * `ceil(diagonal / cellSize)` cells along each axis would make it exact.
44
+ *
45
+ * Throws if the size is not a positive integer or an option breaks its contract
46
+ * in {@link Cellular2dOptions}.
47
+ */
48
+ export function create(width, height, options = {}) {
49
+ const noise = Noise2D.create(width, height);
50
+ const config = { ...DEFAULT_CELLULAR_2D_OPTIONS, ...options };
51
+ validateOptions2(config);
52
+ const values = Noise2D.getValues(noise);
53
+ const { cellWidth, cellHeight, offsetX, offsetY, seed } = config;
54
+ // Grid cell holding the map's first column / row, and how far into it that
55
+ // column / row sits. Both are exact for any safe-integer offset.
56
+ const firstCellX = floorDiv(offsetX, cellWidth);
57
+ const firstCellY = floorDiv(offsetY, cellHeight);
58
+ const firstLocalX = floorMod(offsetX, cellWidth);
59
+ const firstLocalY = floorMod(offsetY, cellHeight);
60
+ const gridSizeX = Math.ceil(width / cellWidth) + CELL_PADDING_TOTAL;
61
+ const gridSizeY = Math.ceil(height / cellHeight) + CELL_PADDING_TOTAL;
62
+ /**
63
+ * Each grid cell's point, relative to the cell's own corner, interleaved
64
+ * (x, y) and stored row by row. Slot (0, 0) is world grid cell
65
+ * (`firstCellX - CELL_PADDING`, `firstCellY - CELL_PADDING`).
66
+ */
67
+ const cellPoints = new Float64Array(gridSizeX * gridSizeY * CELL_STRIDE);
68
+ let index = 0;
69
+ for (let slotY = 0; slotY < gridSizeY; slotY++) {
70
+ const cellY = firstCellY - CELL_PADDING + slotY;
71
+ for (let slotX = 0; slotX < gridSizeX; slotX++) {
72
+ const cellX = firstCellX - CELL_PADDING + slotX;
73
+ const hash = Hashes.hash2(cellX, cellY, seed);
74
+ const xHash = Hashes.lowbias32(hash);
75
+ const yHash = Hashes.lowbias32(xHash);
76
+ cellPoints[index++] = xHash * INV_2_POW_32 * cellWidth;
77
+ cellPoints[index++] = yHash * INV_2_POW_32 * cellHeight;
78
+ }
79
+ }
80
+ /**
81
+ * Distance from (`localX`, `localY`) inside grid slot (`slotX`, `slotY`) to
82
+ * the nearest point in the 3×3 block of slots around it.
83
+ */
84
+ function getNearestDistance(slotX, slotY, localX, localY) {
85
+ let minDistanceSq = Number.POSITIVE_INFINITY;
86
+ for (let dy = -1; dy <= 1; dy++) {
87
+ const rowStart = (slotY + dy) * gridSizeX + slotX;
88
+ const cellOriginY = dy * cellHeight - localY;
89
+ for (let dx = -1; dx <= 1; dx++) {
90
+ const pointIndex = (rowStart + dx) * CELL_STRIDE;
91
+ const distanceX = dx * cellWidth + cellPoints[pointIndex] - localX;
92
+ const distanceY = cellOriginY + cellPoints[pointIndex + 1];
93
+ const distanceSq = distanceX * distanceX + distanceY * distanceY;
94
+ if (distanceSq < minDistanceSq)
95
+ minDistanceSq = distanceSq;
96
+ }
97
+ }
98
+ return Math.sqrt(minDistanceSq);
99
+ }
100
+ const invMaxDistance = 1 / Math.sqrt(cellWidth * cellWidth + cellHeight * cellHeight);
101
+ // Walk the map tracking which slot each sample is in and where inside it,
102
+ // stepping into the next slot when the local position reaches the cell size.
103
+ index = 0;
104
+ let slotY = CELL_PADDING;
105
+ let localY = firstLocalY;
106
+ for (let y = 0; y < height; y++) {
107
+ let slotX = CELL_PADDING;
108
+ let localX = firstLocalX;
109
+ for (let x = 0; x < width; x++) {
110
+ values[index++] = getNearestDistance(slotX, slotY, localX, localY) * invMaxDistance;
111
+ if (++localX === cellWidth) {
112
+ localX = 0;
113
+ slotX++;
114
+ }
115
+ }
116
+ if (++localY === cellHeight) {
117
+ localY = 0;
118
+ slotY++;
119
+ }
120
+ }
121
+ return noise;
122
+ }
123
+ //# sourceMappingURL=2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,sFAAsF;AACtF,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,kBAAkB,GAAG,YAAY,GAAG,CAAC,CAAC;AAE5C,2EAA2E;AAC3E,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AAE9B;;;;;;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
2
+ import type { Cellular3dOptions } from './_types/index.js';
3
+ /**
4
+ * Creates a `width` × `height` × `depth` map of cellular (Worley) noise in
5
+ * [0, 1]. Each value is the distance from its cell to the nearest feature point
6
+ * (F1), divided by the diagonal of one grid cell. The caller owns the returned
7
+ * map.
8
+ *
9
+ * Works like the 2D version with a third axis: grid cells of `cellWidth` ×
10
+ * `cellHeight` × `cellDepth` anchored at world (0, 0, 0), one hashed point per
11
+ * grid cell, and values that depend only on the world cell (`x + offsetX`,
12
+ * `y + offsetY`, `z + offsetZ`), so chunks of any size agree bit for bit where
13
+ * they overlap. Distances are measured from inside the sample's own grid cell,
14
+ * so precision holds far from the origin, and the pattern repeats every 2^32
15
+ * grid cells along each axis.
16
+ *
17
+ * The mapping to [0, 1] is fixed by the cell size, as in 2D. The 3D diagonal is
18
+ * further from the typical nearest distance than the 2D one, so the top of the
19
+ * range is used even less: 64³ maps span roughly 0–0.65 (2D reaches about 0.8)
20
+ * and average about 0.3.
21
+ *
22
+ * Known limitation, as in 2D: only the 3×3×3 block of grid cells around each
23
+ * sample is searched (27 points per value), so the true nearest point is missed
24
+ * when it lies two cells over. Cube-shaped cells are effectively unaffected, but
25
+ * misses grow with the cell's aspect ratio and show as visible seams: roughly
26
+ * 0.05% of values at 10 × 10 × 20 and 2% at 5 × 10 × 20.
27
+ *
28
+ * Throws if the size is not a positive integer or an option breaks its contract
29
+ * in {@link Cellular3dOptions}.
30
+ */
31
+ export declare function create(width: number, height: number, depth: number, options?: Partial<Cellular3dOptions>): Noise3D;
32
+ //# sourceMappingURL=3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/3d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAc3D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM,GACvC,OAAO,CAqHT"}
@@ -0,0 +1,143 @@
1
+ import { Hashes } from '../../hashes/index.js';
2
+ import { Noise3D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_CELLULAR_3D_OPTIONS } from './defaultOptions.js';
4
+ import { floorDiv, floorMod } from './floorDiv.js';
5
+ import { validateOptions3 } from './options.js';
6
+ /** Numbers stored per cell in the point grid: the point's x, y and z within its cell. */
7
+ const CELL_STRIDE = 3;
8
+ /**
9
+ * Extra cells stored on each side of the cells the map covers. The 3×3×3
10
+ * search needs one; the second leaves room for a 5×5×5 search without resizing.
11
+ */
12
+ const CELL_PADDING = 2;
13
+ const CELL_PADDING_TOTAL = CELL_PADDING * 2;
14
+ /** Scales a 32-bit hash into [0, 1). Exact, since it is a power of two. */
15
+ const INV_2_POW_32 = 2 ** -32;
16
+ /**
17
+ * Creates a `width` × `height` × `depth` map of cellular (Worley) noise in
18
+ * [0, 1]. Each value is the distance from its cell to the nearest feature point
19
+ * (F1), divided by the diagonal of one grid cell. The caller owns the returned
20
+ * map.
21
+ *
22
+ * Works like the 2D version with a third axis: grid cells of `cellWidth` ×
23
+ * `cellHeight` × `cellDepth` anchored at world (0, 0, 0), one hashed point per
24
+ * grid cell, and values that depend only on the world cell (`x + offsetX`,
25
+ * `y + offsetY`, `z + offsetZ`), so chunks of any size agree bit for bit where
26
+ * they overlap. Distances are measured from inside the sample's own grid cell,
27
+ * so precision holds far from the origin, and the pattern repeats every 2^32
28
+ * grid cells along each axis.
29
+ *
30
+ * The mapping to [0, 1] is fixed by the cell size, as in 2D. The 3D diagonal is
31
+ * further from the typical nearest distance than the 2D one, so the top of the
32
+ * range is used even less: 64³ maps span roughly 0–0.65 (2D reaches about 0.8)
33
+ * and average about 0.3.
34
+ *
35
+ * Known limitation, as in 2D: only the 3×3×3 block of grid cells around each
36
+ * sample is searched (27 points per value), so the true nearest point is missed
37
+ * when it lies two cells over. Cube-shaped cells are effectively unaffected, but
38
+ * misses grow with the cell's aspect ratio and show as visible seams: roughly
39
+ * 0.05% of values at 10 × 10 × 20 and 2% at 5 × 10 × 20.
40
+ *
41
+ * Throws if the size is not a positive integer or an option breaks its contract
42
+ * in {@link Cellular3dOptions}.
43
+ */
44
+ export function create(width, height, depth, options = {}) {
45
+ const noise = Noise3D.create(width, height, depth);
46
+ const config = { ...DEFAULT_CELLULAR_3D_OPTIONS, ...options };
47
+ validateOptions3(config);
48
+ const values = Noise3D.getValues(noise);
49
+ const { cellWidth, cellHeight, cellDepth, offsetX, offsetY, offsetZ, seed } = config;
50
+ // Grid cell holding the map's first column / row / layer, and how far into it
51
+ // that column / row / layer sits. Exact for any safe-integer offset.
52
+ const firstCellX = floorDiv(offsetX, cellWidth);
53
+ const firstCellY = floorDiv(offsetY, cellHeight);
54
+ const firstCellZ = floorDiv(offsetZ, cellDepth);
55
+ const firstLocalX = floorMod(offsetX, cellWidth);
56
+ const firstLocalY = floorMod(offsetY, cellHeight);
57
+ const firstLocalZ = floorMod(offsetZ, cellDepth);
58
+ const gridSizeX = Math.ceil(width / cellWidth) + CELL_PADDING_TOTAL;
59
+ const gridSizeY = Math.ceil(height / cellHeight) + CELL_PADDING_TOTAL;
60
+ const gridSizeZ = Math.ceil(depth / cellDepth) + CELL_PADDING_TOTAL;
61
+ const gridLayerSize = gridSizeX * gridSizeY;
62
+ /**
63
+ * Each grid cell's point, relative to the cell's own corner, interleaved
64
+ * (x, y, z) and stored row by row, then layer by layer. Slot (0, 0, 0) is
65
+ * world grid cell (`firstCellX - CELL_PADDING`, `firstCellY - CELL_PADDING`,
66
+ * `firstCellZ - CELL_PADDING`).
67
+ */
68
+ const cellPoints = new Float64Array(gridLayerSize * gridSizeZ * CELL_STRIDE);
69
+ let index = 0;
70
+ for (let slotZ = 0; slotZ < gridSizeZ; slotZ++) {
71
+ const cellZ = firstCellZ - CELL_PADDING + slotZ;
72
+ for (let slotY = 0; slotY < gridSizeY; slotY++) {
73
+ const cellY = firstCellY - CELL_PADDING + slotY;
74
+ for (let slotX = 0; slotX < gridSizeX; slotX++) {
75
+ const cellX = firstCellX - CELL_PADDING + slotX;
76
+ const hash = Hashes.hash3(cellX, cellY, cellZ, seed);
77
+ const xHash = Hashes.lowbias32(hash);
78
+ const yHash = Hashes.lowbias32(xHash);
79
+ const zHash = Hashes.lowbias32(yHash);
80
+ cellPoints[index++] = xHash * INV_2_POW_32 * cellWidth;
81
+ cellPoints[index++] = yHash * INV_2_POW_32 * cellHeight;
82
+ cellPoints[index++] = zHash * INV_2_POW_32 * cellDepth;
83
+ }
84
+ }
85
+ }
86
+ /**
87
+ * Distance from (`localX`, `localY`, `localZ`) inside grid slot (`slotX`,
88
+ * `slotY`, `slotZ`) to the nearest point in the 3×3×3 block of slots around it.
89
+ */
90
+ function getNearestDistance(slotX, slotY, slotZ, localX, localY, localZ) {
91
+ let minDistanceSq = Number.POSITIVE_INFINITY;
92
+ for (let dz = -1; dz <= 1; dz++) {
93
+ const layerStart = (slotZ + dz) * gridLayerSize;
94
+ const cellOriginZ = dz * cellDepth - localZ;
95
+ for (let dy = -1; dy <= 1; dy++) {
96
+ const rowStart = layerStart + (slotY + dy) * gridSizeX + slotX;
97
+ const cellOriginY = dy * cellHeight - localY;
98
+ for (let dx = -1; dx <= 1; dx++) {
99
+ const pointIndex = (rowStart + dx) * CELL_STRIDE;
100
+ const distanceX = dx * cellWidth + cellPoints[pointIndex] - localX;
101
+ const distanceY = cellOriginY + cellPoints[pointIndex + 1];
102
+ const distanceZ = cellOriginZ + cellPoints[pointIndex + 2];
103
+ const distanceSq = distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ;
104
+ if (distanceSq < minDistanceSq)
105
+ minDistanceSq = distanceSq;
106
+ }
107
+ }
108
+ }
109
+ return Math.sqrt(minDistanceSq);
110
+ }
111
+ const invMaxDistance = 1 / Math.sqrt(cellWidth * cellWidth + cellHeight * cellHeight + cellDepth * cellDepth);
112
+ // Walk the map tracking which slot each sample is in and where inside it,
113
+ // stepping into the next slot when the local position reaches the cell size.
114
+ index = 0;
115
+ let slotZ = CELL_PADDING;
116
+ let localZ = firstLocalZ;
117
+ for (let z = 0; z < depth; z++) {
118
+ let slotY = CELL_PADDING;
119
+ let localY = firstLocalY;
120
+ for (let y = 0; y < height; y++) {
121
+ let slotX = CELL_PADDING;
122
+ let localX = firstLocalX;
123
+ for (let x = 0; x < width; x++) {
124
+ values[index++] =
125
+ getNearestDistance(slotX, slotY, slotZ, localX, localY, localZ) * invMaxDistance;
126
+ if (++localX === cellWidth) {
127
+ localX = 0;
128
+ slotX++;
129
+ }
130
+ }
131
+ if (++localY === cellHeight) {
132
+ localY = 0;
133
+ slotY++;
134
+ }
135
+ }
136
+ if (++localZ === cellDepth) {
137
+ localZ = 0;
138
+ slotZ++;
139
+ }
140
+ }
141
+ return noise;
142
+ }
143
+ //# sourceMappingURL=3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,yFAAyF;AACzF,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,kBAAkB,GAAG,YAAY,GAAG,CAAC,CAAC;AAE5C,2EAA2E;AAC3E,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,EAAE,CA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,GAAG,CAAC,CAAC;YACX,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { Cellular2dOptions, Cellular3dOptions } from './options.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/cellular/_types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noiseTypes/cellular/_types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Options for 2D cellular noise. A map is a pure function of its size and these
3
+ * options, so the same options reproduce it exactly on any JS engine.
4
+ */
5
+ export interface Cellular2dOptions {
6
+ /**
7
+ * Selects which point each grid cell gets. An integer; only its low 32 bits
8
+ * take part, so seeds 2^32 apart give the same map.
9
+ */
10
+ seed: number;
11
+ /**
12
+ * Width of one grid cell in map cells. Each grid cell holds one point, so this
13
+ * sets the spacing of the pattern. A positive safe integer: whole cells keep
14
+ * the grid's edges on map cells, which lets each sample's position inside its
15
+ * grid cell be tracked exactly, and the lower bound of 1 keeps the number of
16
+ * grid cells a map stores no larger than the map itself.
17
+ */
18
+ cellWidth: number;
19
+ /** Height of one grid cell. Same contract as {@link cellWidth}. */
20
+ cellHeight: number;
21
+ /**
22
+ * World x of the map's first column, in map cells. A safe integer (|v| < 2^53),
23
+ * so `x + offsetX` is exact and a chunk at offset 64 reproduces column 64 of a
24
+ * chunk at offset 0 bit for bit. Larger integers would round when added to.
25
+ */
26
+ offsetX: number;
27
+ /** World y of the map's first row. Same contract as {@link offsetX}. */
28
+ offsetY: number;
29
+ }
30
+ /** Options for 3D cellular noise: the 2D options plus a depth and a z offset. */
31
+ export interface Cellular3dOptions extends Cellular2dOptions {
32
+ /** Depth of one grid cell. Same contract as {@link Cellular2dOptions.cellWidth}. */
33
+ cellDepth: number;
34
+ /** World z of the map's first layer. Same contract as {@link Cellular2dOptions.offsetX}. */
35
+ offsetZ: number;
36
+ }
37
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/cellular/_types/options.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/noiseTypes/cellular/_types/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Cellular2dOptions, Cellular3dOptions } from './_types/index.js';
2
+ export declare const DEFAULT_CELLULAR_2D_OPTIONS: Cellular2dOptions;
3
+ export declare const DEFAULT_CELLULAR_3D_OPTIONS: Cellular3dOptions;
4
+ //# sourceMappingURL=defaultOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,eAAO,MAAM,2BAA2B,EAAE,iBAMzC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,iBAIzC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const DEFAULT_CELLULAR_2D_OPTIONS = {
2
+ seed: 0,
3
+ cellWidth: 10,
4
+ cellHeight: 10,
5
+ offsetX: 0,
6
+ offsetY: 0,
7
+ };
8
+ export const DEFAULT_CELLULAR_3D_OPTIONS = {
9
+ ...DEFAULT_CELLULAR_2D_OPTIONS,
10
+ cellDepth: 10,
11
+ offsetZ: 0,
12
+ };
13
+ //# sourceMappingURL=defaultOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/defaultOptions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,GAAG,2BAA2B;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,CAAC;CACX,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `floor(value / divisor)` for a safe-integer `value` and a positive
3
+ * safe-integer `divisor`, exact across the whole safe range.
4
+ *
5
+ * `Math.floor(value / divisor)` is not: the division rounds, so near ±2^53 the
6
+ * floor can land one off, and multiplying the quotient back by `divisor` to
7
+ * check it can leave the safe range and round again. `%` is exact, and
8
+ * `value - remainder` keeps the sign of `value` with a smaller magnitude, so it
9
+ * stays exact and divides evenly.
10
+ */
11
+ export declare function floorDiv(value: number, divisor: number): number;
12
+ /**
13
+ * `value - floorDiv(value, divisor) * divisor`, in [0, `divisor`), computed
14
+ * without that product so it stays exact across the whole safe range. Same
15
+ * argument contract as {@link floorDiv}.
16
+ */
17
+ export declare function floorMod(value: number, divisor: number): number;
18
+ //# sourceMappingURL=floorDiv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floorDiv.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/floorDiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK/D"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `floor(value / divisor)` for a safe-integer `value` and a positive
3
+ * safe-integer `divisor`, exact across the whole safe range.
4
+ *
5
+ * `Math.floor(value / divisor)` is not: the division rounds, so near ±2^53 the
6
+ * floor can land one off, and multiplying the quotient back by `divisor` to
7
+ * check it can leave the safe range and round again. `%` is exact, and
8
+ * `value - remainder` keeps the sign of `value` with a smaller magnitude, so it
9
+ * stays exact and divides evenly.
10
+ */
11
+ export function floorDiv(value, divisor) {
12
+ const remainder = value % divisor;
13
+ const quotient = (value - remainder) / divisor;
14
+ return remainder < 0 ? quotient - 1 : quotient;
15
+ }
16
+ /**
17
+ * `value - floorDiv(value, divisor) * divisor`, in [0, `divisor`), computed
18
+ * without that product so it stays exact across the whole safe range. Same
19
+ * argument contract as {@link floorDiv}.
20
+ */
21
+ export function floorMod(value, divisor) {
22
+ const remainder = value % divisor;
23
+ if (remainder < 0)
24
+ return remainder + divisor;
25
+ // `%` returns -0 for negative multiples of `divisor`; normalise it to 0.
26
+ return remainder === 0 ? 0 : remainder;
27
+ }
28
+ //# sourceMappingURL=floorDiv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floorDiv.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/floorDiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,OAAe;IACrD,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,MAAM,QAAQ,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC;IAC/C,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,OAAe;IACrD,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,SAAS,GAAG,OAAO,CAAC;IAC9C,yEAAyE;IACzE,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * as Cellular2 from './2d.js';
2
+ export * as Cellular3 from './3d.js';
3
+ export type * from './_types/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC;AAErC,mBAAmB,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * as Cellular2 from './2d.js';
2
+ export * as Cellular3 from './3d.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Cellular2dOptions, Cellular3dOptions } from './_types/index.js';
2
+ /** Throws if `options` breaks a contract in {@link Cellular2dOptions}. */
3
+ export declare function validateOptions2(options: Cellular2dOptions): void;
4
+ /** Throws if `options` breaks a contract in {@link Cellular3dOptions}. */
5
+ export declare function validateOptions3(options: Cellular3dOptions): void;
6
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAQjE;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAKjE"}
@@ -0,0 +1,20 @@
1
+ /** Throws if `options` breaks a contract in {@link Cellular2dOptions}. */
2
+ export function validateOptions2(options) {
3
+ if (!Number.isInteger(options.seed))
4
+ throw new RangeError('Invalid seed');
5
+ if (!(Number.isSafeInteger(options.cellWidth) && options.cellWidth > 0))
6
+ throw new RangeError('Invalid cellWidth');
7
+ if (!(Number.isSafeInteger(options.cellHeight) && options.cellHeight > 0))
8
+ throw new RangeError('Invalid cellHeight');
9
+ if (!(Number.isSafeInteger(options.offsetX) && Number.isSafeInteger(options.offsetY)))
10
+ throw new RangeError('Invalid offsetX or offsetY');
11
+ }
12
+ /** Throws if `options` breaks a contract in {@link Cellular3dOptions}. */
13
+ export function validateOptions3(options) {
14
+ validateOptions2(options);
15
+ if (!Number.isSafeInteger(options.offsetZ))
16
+ throw new RangeError('Invalid offsetZ');
17
+ if (!(Number.isSafeInteger(options.cellDepth) && options.cellDepth > 0))
18
+ throw new RangeError('Invalid cellDepth');
19
+ }
20
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/noiseTypes/cellular/options.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;IAC1E,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QACrE,MAAM,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC5C,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC;QACvE,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC7C,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnF,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,CAAC;AACvD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACpF,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QACrE,MAAM,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './cellular/index.js';
2
+ export * from './perlin/index.js';
3
+ export * from './simplex/index.js';
4
+ export * from './white/index.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/noiseTypes/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './cellular/index.js';
2
+ export * from './perlin/index.js';
3
+ export * from './simplex/index.js';
4
+ export * from './white/index.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/noiseTypes/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Noise2D } from '../../noiseMap/index.js';
2
+ import type { Perlin2dOptions } from './_types/options.js';
3
+ /**
4
+ * Creates a `width` × `height` map of fractal (multi-octave) Perlin noise in
5
+ * [0, 1]. The caller owns the returned map.
6
+ *
7
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`) and
8
+ * the other options, never on the map's size. Chunks of any size, created with
9
+ * the same options and their world origin as the offset, agree bit for bit
10
+ * wherever they overlap.
11
+ *
12
+ * The mapping to [0, 1] is fixed by the options, not stretched to each map's own
13
+ * minimum and maximum; that is what keeps chunks consistent. The cost is
14
+ * contrast: the fixed bound is the sum of octave amplitudes, which summed noise
15
+ * rarely approaches. With the defaults (5 octaves, persistence 0.5) a 256 × 256
16
+ * map spans roughly 0.2–0.8, while a single octave uses nearly all of [0, 1].
17
+ * Stretch the result yourself if you need contrast more than tiling.
18
+ *
19
+ * Throws if the size is not a positive integer or an option breaks its contract
20
+ * in {@link Perlin2dOptions}.
21
+ */
22
+ export declare function create(width: number, height: number, options?: Partial<Perlin2dOptions>): Noise2D;
23
+ //# sourceMappingURL=2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiC3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,CAAC,eAAe,CAAM,GACrC,OAAO,CAuBT"}