@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,70 @@
1
+ import { getOctaveConfig } from '../../fractal/index.js';
2
+ import { Noise3D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_SIMPLEX_3D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions3 } from './options.js';
5
+ import { sample3 } from './sample3.js';
6
+ /**
7
+ * Creates a `width` × `height` × `depth` map of fractal (multi-octave) simplex
8
+ * noise in [0, 1]. The caller owns the returned map.
9
+ *
10
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`,
11
+ * `z + offsetZ`) and the other options, never on the map's size. Chunks of any
12
+ * size, created with the same options and their world origin as the offset,
13
+ * agree bit for bit wherever they overlap.
14
+ *
15
+ * As in 2D, the mapping to [0, 1] is fixed by the options rather than stretched
16
+ * per map, and simplex fills more of it than Perlin: with the defaults a 48³ map
17
+ * spans roughly 0.07–0.93 (Perlin roughly 0.25–0.75), and a single octave
18
+ * reaches almost exactly 0 and 1.
19
+ *
20
+ * Each cell costs `octaves` calls to `sample3`, which sums four corners against
21
+ * eight for 3D Perlin, so a map costs about half as much as the same 3D Perlin
22
+ * map. The total still grows with the volume.
23
+ *
24
+ * Throws if the size is not a positive integer or an option breaks its contract
25
+ * in {@link Simplex3dOptions}.
26
+ */
27
+ export function create(width, height, depth, options = {}) {
28
+ const noise = Noise3D.create(width, height, depth);
29
+ const config = { ...DEFAULT_SIMPLEX_3D_OPTIONS, ...options };
30
+ validateOptions3(config);
31
+ const values = Noise3D.getValues(noise);
32
+ const invScale = 1 / config.scale;
33
+ const [octaveOffsets, maxPossibleHeight] = getOctaveConfig(config, 3);
34
+ const invRange = 0.5 / maxPossibleHeight;
35
+ let index = 0;
36
+ for (let z = 0; z < depth; z++) {
37
+ const worldZ = z + config.offsetZ;
38
+ for (let y = 0; y < height; y++) {
39
+ const worldY = y + config.offsetY;
40
+ for (let x = 0; x < width; x++) {
41
+ const worldX = x + config.offsetX;
42
+ const value = samplePoint(worldX, worldY, worldZ, config, octaveOffsets, invScale);
43
+ values[index++] = value * invRange + 0.5;
44
+ }
45
+ }
46
+ }
47
+ return noise;
48
+ }
49
+ /**
50
+ * Summed octaves at an integer world cell, in ±`maxPossibleHeight`. Assumes
51
+ * `config` is validated: `octaveOffsets` then holds exactly `config.octaves`
52
+ * triples, so the indexed reads below are always in bounds.
53
+ */
54
+ function samplePoint(worldX, worldY, worldZ, config, octaveOffsets, invScale) {
55
+ let amplitude = 1;
56
+ let frequency = 1;
57
+ let noiseHeight = 0;
58
+ for (let i = 0; i < config.octaves; i++) {
59
+ const index = i * 3;
60
+ const scaledFrequency = invScale * frequency;
61
+ const sampleX = (worldX + octaveOffsets[index]) * scaledFrequency;
62
+ const sampleY = (worldY + octaveOffsets[index + 1]) * scaledFrequency;
63
+ const sampleZ = (worldZ + octaveOffsets[index + 2]) * scaledFrequency;
64
+ noiseHeight += sample3(sampleX, sampleY, sampleZ, config.seed) * amplitude;
65
+ amplitude *= config.persistence;
66
+ frequency *= config.lacunarity;
67
+ }
68
+ return noiseHeight;
69
+ }
70
+ //# sourceMappingURL=3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,MAAc,EACd,KAAa,EACb,OAAO,GAA8B,EAAE;IAEvC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,EAAE,GAAG,0BAA0B,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7D,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAElC,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,GAAG,GAAG,iBAAiB,CAAC;IAEzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAA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AAG,CAAC,MAAM,GAAI,aAAa,CAAC,KAAK,GAAG,CAAC,CAAY,CAAC,GAAG,eAAe,CAAC;QAClF,MAAM,OAAO,GAAG,CAAC,MAAM,GAAI,aAAa,CAAC,KAAK,GAAG,CAAC,CAAY,CAAC,GAAG,eAAe,CAAC;QAElF,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAE3E,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC;QAChC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { Simplex2dOptions, Simplex3dOptions } from './options.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/simplex/_types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,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/simplex/_types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { FractalOptions } from '../../../fractal/index.js';
2
+ /**
3
+ * Options for 2D simplex noise: the shared {@link FractalOptions} plus the map's
4
+ * world offset. A map is a pure function of its size and these options, so the
5
+ * same options reproduce it exactly on any JS engine.
6
+ */
7
+ export interface Simplex2dOptions extends FractalOptions {
8
+ /**
9
+ * Size of one lattice cell of the first octave, in map cells. Larger values
10
+ * zoom in. Finite and greater than 0.
11
+ *
12
+ * The lattice is skewed into triangles whose edges are about 0.82 × `scale`
13
+ * long, so features come out slightly smaller than Perlin's at the same scale.
14
+ */
15
+ scale: number;
16
+ /**
17
+ * World x of the map's first column, in map cells. A safe integer (|v| < 2^53),
18
+ * so `x + offsetX` is exact and a chunk at offset 64 reproduces column 64 of a
19
+ * chunk at offset 0 bit for bit. Larger integers would round when added to.
20
+ */
21
+ offsetX: number;
22
+ /** World y of the map's first row. Same contract as {@link offsetX}. */
23
+ offsetY: number;
24
+ }
25
+ /**
26
+ * Options for 3D simplex noise: the 2D options plus a z offset. In 3D the
27
+ * tetrahedra's edges are 0.87–1 × `scale` long.
28
+ */
29
+ export interface Simplex3dOptions extends Simplex2dOptions {
30
+ /** World z of the map's first layer. Same contract as {@link Simplex2dOptions.offsetX}. */
31
+ offsetZ: number;
32
+ }
33
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/simplex/_types/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,2FAA2F;IAC3F,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/simplex/_types/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Simplex2dOptions, Simplex3dOptions } from './_types/options.js';
2
+ export declare const DEFAULT_SIMPLEX_2D_OPTIONS: Simplex2dOptions;
3
+ export declare const DEFAULT_SIMPLEX_3D_OPTIONS: Simplex3dOptions;
4
+ //# sourceMappingURL=defaultOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,eAAO,MAAM,0BAA0B,EAAE,gBAQxC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,gBAGxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const DEFAULT_SIMPLEX_2D_OPTIONS = {
2
+ seed: 0,
3
+ offsetX: 0,
4
+ offsetY: 0,
5
+ scale: 20,
6
+ lacunarity: 2,
7
+ persistence: 0.5,
8
+ octaves: 5,
9
+ };
10
+ export const DEFAULT_SIMPLEX_3D_OPTIONS = {
11
+ ...DEFAULT_SIMPLEX_2D_OPTIONS,
12
+ offsetZ: 0,
13
+ };
14
+ //# sourceMappingURL=defaultOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/defaultOptions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC1D,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,GAAG;IAChB,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC1D,GAAG,0BAA0B;IAC7B,OAAO,EAAE,CAAC;CACX,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * as Simplex2 from './2d.js';
2
+ export * as Simplex3 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/simplex/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AAEpC,mBAAmB,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * as Simplex2 from './2d.js';
2
+ export * as Simplex3 from './3d.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Simplex2dOptions, Simplex3dOptions } from './_types/options.js';
2
+ /**
3
+ * Throws if `options` breaks a contract in {@link Simplex2dOptions}. The fractal
4
+ * options are checked first, by the shared fractal validation.
5
+ */
6
+ export declare function validateOptions2(options: Simplex2dOptions): void;
7
+ /** Throws if `options` breaks a contract in {@link Simplex3dOptions}. */
8
+ export declare function validateOptions3(options: Simplex3dOptions): void;
9
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAIhE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAGhE"}
@@ -0,0 +1,17 @@
1
+ import { validateFractalOptions } from '../../fractal/index.js';
2
+ /**
3
+ * Throws if `options` breaks a contract in {@link Simplex2dOptions}. The fractal
4
+ * options are checked first, by the shared fractal validation.
5
+ */
6
+ export function validateOptions2(options) {
7
+ validateFractalOptions(options);
8
+ if (!(Number.isSafeInteger(options.offsetX) && Number.isSafeInteger(options.offsetY)))
9
+ throw new RangeError('Invalid offsetX or offsetY');
10
+ }
11
+ /** Throws if `options` breaks a contract in {@link Simplex3dOptions}. */
12
+ export function validateOptions3(options) {
13
+ validateOptions2(options);
14
+ if (!Number.isSafeInteger(options.offsetZ))
15
+ throw new RangeError('Invalid offsetZ');
16
+ }
17
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACxD,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAChC,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,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACxD,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Dot product of the gradient hashed for lattice corner (`ci`, `cj`) with the
3
+ * offset (`dx`, `dy`) from that corner, in input space.
4
+ *
5
+ * The twelve gradients are unit vectors 30° apart. Simplex sums radial kernels,
6
+ * so unequal gradient lengths (Perlin's diagonals are √2) would show up as
7
+ * brighter blobs along those directions; equal lengths keep it isotropic. The
8
+ * √3/2 components are fixed constants, so each dot product is still exact
9
+ * arithmetic and matches across engines. `% 12` relies on the hash being
10
+ * unsigned.
11
+ */
12
+ export declare function corner2(ci: number, cj: number, dx: number, dy: number, seed: number): number;
13
+ /**
14
+ * One octave of 2D simplex noise at (`x`, `y`), in [-1, 1].
15
+ *
16
+ * Space is split into equilateral triangles and each sample sums kernels from
17
+ * its triangle's three corners, against four corners for 2D Perlin. The kernel
18
+ * radius √0.5 equals the triangle's height, so no corner outside the triangle
19
+ * can reach the sample and the result is continuous with a continuous gradient.
20
+ * Features sit on a triangle lattice with no axis alignment, so the output
21
+ * avoids Perlin's grid-aligned look.
22
+ *
23
+ * Unlike Perlin, the value is not 0 at integer points; it is 0 at the lattice
24
+ * corners, which lie at `(i − (i + j)·G2, j − (i + j)·G2)`. Most values sit well
25
+ * inside ±1, which is only reached with every gradient lined up. Corner indices
26
+ * are truncated to int32 by the hash, so the pattern repeats beyond ±2^31 cells.
27
+ *
28
+ * Seeded output must match across engines, so this may only use exact
29
+ * operations: + − × ÷, floor, sqrt, integer and bitwise ops.
30
+ */
31
+ export declare function sample2(x: number, y: number, seed: number): number;
32
+ //# sourceMappingURL=sample2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample2.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/sample2.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2B5F;AAUD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBlE"}
@@ -0,0 +1,94 @@
1
+ import { Hashes } from '../../hashes/index.js';
2
+ /** Skews (x, y) onto the triangle lattice: cell (i, j) is `floor(x + (x + y) * F2)`. */
3
+ const F2 = 0.5 * (Math.sqrt(3) - 1);
4
+ /** Unskews lattice point (i, j) back to input space: `i - (i + j) * G2`. */
5
+ const G2 = (3 - Math.sqrt(3)) / 6;
6
+ /** cos 30° and sin 60°, for the gradient directions at 30° steps. */
7
+ const S = Math.sqrt(3) / 2;
8
+ /**
9
+ * Brings the sum inside [-1, 1]. The worst case, with every corner's gradient
10
+ * pointing at the sample, is about 1 / 101.6557 of the raw sum. 101.65 is that
11
+ * reciprocal rounded down, so the result stays within ±1.
12
+ */
13
+ const SAMPLE2_SCALE = 101.65;
14
+ /**
15
+ * Dot product of the gradient hashed for lattice corner (`ci`, `cj`) with the
16
+ * offset (`dx`, `dy`) from that corner, in input space.
17
+ *
18
+ * The twelve gradients are unit vectors 30° apart. Simplex sums radial kernels,
19
+ * so unequal gradient lengths (Perlin's diagonals are √2) would show up as
20
+ * brighter blobs along those directions; equal lengths keep it isotropic. The
21
+ * √3/2 components are fixed constants, so each dot product is still exact
22
+ * arithmetic and matches across engines. `% 12` relies on the hash being
23
+ * unsigned.
24
+ */
25
+ export function corner2(ci, cj, dx, dy, seed) {
26
+ switch (Hashes.hash2(ci, cj, seed) % 12) {
27
+ case 0:
28
+ return dx;
29
+ case 1:
30
+ return S * dx + 0.5 * dy;
31
+ case 2:
32
+ return 0.5 * dx + S * dy;
33
+ case 3:
34
+ return dy;
35
+ case 4:
36
+ return -0.5 * dx + S * dy;
37
+ case 5:
38
+ return -S * dx + 0.5 * dy;
39
+ case 6:
40
+ return -dx;
41
+ case 7:
42
+ return -S * dx - 0.5 * dy;
43
+ case 8:
44
+ return -0.5 * dx - S * dy;
45
+ case 9:
46
+ return -dy;
47
+ case 10:
48
+ return 0.5 * dx - S * dy;
49
+ default:
50
+ return S * dx - 0.5 * dy;
51
+ }
52
+ }
53
+ /** One corner's kernel-weighted contribution: (0.5 − d²)⁴ · (g · d), or 0 outside radius √0.5. */
54
+ function contribution(ci, cj, dx, dy, seed) {
55
+ const t = 0.5 - dx * dx - dy * dy;
56
+ if (t <= 0)
57
+ return 0;
58
+ const t2 = t * t;
59
+ return t2 * t2 * corner2(ci, cj, dx, dy, seed);
60
+ }
61
+ /**
62
+ * One octave of 2D simplex noise at (`x`, `y`), in [-1, 1].
63
+ *
64
+ * Space is split into equilateral triangles and each sample sums kernels from
65
+ * its triangle's three corners, against four corners for 2D Perlin. The kernel
66
+ * radius √0.5 equals the triangle's height, so no corner outside the triangle
67
+ * can reach the sample and the result is continuous with a continuous gradient.
68
+ * Features sit on a triangle lattice with no axis alignment, so the output
69
+ * avoids Perlin's grid-aligned look.
70
+ *
71
+ * Unlike Perlin, the value is not 0 at integer points; it is 0 at the lattice
72
+ * corners, which lie at `(i − (i + j)·G2, j − (i + j)·G2)`. Most values sit well
73
+ * inside ±1, which is only reached with every gradient lined up. Corner indices
74
+ * are truncated to int32 by the hash, so the pattern repeats beyond ±2^31 cells.
75
+ *
76
+ * Seeded output must match across engines, so this may only use exact
77
+ * operations: + − × ÷, floor, sqrt, integer and bitwise ops.
78
+ */
79
+ export function sample2(x, y, seed) {
80
+ const skew = (x + y) * F2;
81
+ const i = Math.floor(x + skew);
82
+ const j = Math.floor(y + skew);
83
+ const unskew = (i + j) * G2;
84
+ const x0 = x - (i - unskew);
85
+ const y0 = y - (j - unskew);
86
+ // Below the diagonal the middle corner is (i + 1, j), above it (i, j + 1).
87
+ const i1 = x0 > y0 ? 1 : 0;
88
+ const j1 = 1 - i1;
89
+ const n0 = contribution(i, j, x0, y0, seed);
90
+ const n1 = contribution(i + i1, j + j1, x0 - i1 + G2, y0 - j1 + G2, seed);
91
+ const n2 = contribution(i + 1, j + 1, x0 - 1 + 2 * G2, y0 - 1 + 2 * G2, seed);
92
+ return (n0 + n1 + n2) * SAMPLE2_SCALE;
93
+ }
94
+ //# sourceMappingURL=sample2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample2.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/sample2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IAElB,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5C,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1E,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAE9E,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC;AACxC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * One octave of 3D simplex noise at (`x`, `y`, `z`), in [-1, 1].
3
+ *
4
+ * Space is split into tetrahedra and each sample sums kernels from its
5
+ * tetrahedron's four corners, against eight for 3D Perlin, so it costs roughly
6
+ * half as much per octave.
7
+ *
8
+ * The kernel radius is √0.5. The commonly published 0.6 lets corners outside the
9
+ * tetrahedron reach the sample, and since those are never summed the output
10
+ * jumps at tetrahedron faces. At 0.5 no outside corner can reach, so the result
11
+ * is continuous with a continuous gradient.
12
+ *
13
+ * Gradients are the same twelve cube edges as 3D Perlin, all of length √2. The
14
+ * value is 0 at the lattice corners, not at integer points. Corner indices are
15
+ * truncated to int32 by the hash, so the pattern repeats beyond ±2^31 cells.
16
+ * Like `sample2`, this may only use exact operations.
17
+ */
18
+ export declare function sample3(x: number, y: number, z: number, seed: number): number;
19
+ //# sourceMappingURL=sample3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample3.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/sample3.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA+E7E"}
@@ -0,0 +1,110 @@
1
+ import { cubeEdge3 } from '../../gradient/index.js';
2
+ /** Skews (x, y, z) onto the tetrahedral lattice: cell (i, j, k) is `floor(x + (x + y + z) * F3)`. */
3
+ const F3 = 1 / 3;
4
+ /** Unskews lattice point (i, j, k) back to input space: `i - (i + j + k) * G3`. */
5
+ const G3 = 1 / 6;
6
+ /**
7
+ * Brings the sum inside [-1, 1]. The worst case, with every corner's gradient
8
+ * pointing at the sample, is about 1 / 76.8808 of the raw sum. 76.88 is that
9
+ * reciprocal rounded down, so the result stays within ±1.
10
+ */
11
+ const SAMPLE3_SCALE = 76.88;
12
+ /** One corner's kernel-weighted contribution: (0.5 − d²)⁴ · (g · d), or 0 outside radius √0.5. */
13
+ function contribution(ci, cj, ck, dx, dy, dz, seed) {
14
+ const t = 0.5 - dx * dx - dy * dy - dz * dz;
15
+ if (t <= 0)
16
+ return 0;
17
+ const t2 = t * t;
18
+ return t2 * t2 * cubeEdge3(ci, cj, ck, dx, dy, dz, seed);
19
+ }
20
+ /**
21
+ * One octave of 3D simplex noise at (`x`, `y`, `z`), in [-1, 1].
22
+ *
23
+ * Space is split into tetrahedra and each sample sums kernels from its
24
+ * tetrahedron's four corners, against eight for 3D Perlin, so it costs roughly
25
+ * half as much per octave.
26
+ *
27
+ * The kernel radius is √0.5. The commonly published 0.6 lets corners outside the
28
+ * tetrahedron reach the sample, and since those are never summed the output
29
+ * jumps at tetrahedron faces. At 0.5 no outside corner can reach, so the result
30
+ * is continuous with a continuous gradient.
31
+ *
32
+ * Gradients are the same twelve cube edges as 3D Perlin, all of length √2. The
33
+ * value is 0 at the lattice corners, not at integer points. Corner indices are
34
+ * truncated to int32 by the hash, so the pattern repeats beyond ±2^31 cells.
35
+ * Like `sample2`, this may only use exact operations.
36
+ */
37
+ export function sample3(x, y, z, seed) {
38
+ const skew = (x + y + z) * F3;
39
+ const i = Math.floor(x + skew);
40
+ const j = Math.floor(y + skew);
41
+ const k = Math.floor(z + skew);
42
+ const unskew = (i + j + k) * G3;
43
+ const x0 = x - (i - unskew);
44
+ const y0 = y - (j - unskew);
45
+ const z0 = z - (k - unskew);
46
+ // The tetrahedron is picked by ranking x0, y0, z0: the walk from (i, j, k) to
47
+ // (i + 1, j + 1, k + 1) steps along the largest offset first, then the next.
48
+ let i1;
49
+ let j1;
50
+ let k1;
51
+ let i2;
52
+ let j2;
53
+ let k2;
54
+ if (x0 >= y0) {
55
+ if (y0 >= z0) {
56
+ i1 = 1;
57
+ j1 = 0;
58
+ k1 = 0;
59
+ i2 = 1;
60
+ j2 = 1;
61
+ k2 = 0;
62
+ }
63
+ else if (x0 >= z0) {
64
+ i1 = 1;
65
+ j1 = 0;
66
+ k1 = 0;
67
+ i2 = 1;
68
+ j2 = 0;
69
+ k2 = 1;
70
+ }
71
+ else {
72
+ i1 = 0;
73
+ j1 = 0;
74
+ k1 = 1;
75
+ i2 = 1;
76
+ j2 = 0;
77
+ k2 = 1;
78
+ }
79
+ }
80
+ else if (y0 < z0) {
81
+ i1 = 0;
82
+ j1 = 0;
83
+ k1 = 1;
84
+ i2 = 0;
85
+ j2 = 1;
86
+ k2 = 1;
87
+ }
88
+ else if (x0 < z0) {
89
+ i1 = 0;
90
+ j1 = 1;
91
+ k1 = 0;
92
+ i2 = 0;
93
+ j2 = 1;
94
+ k2 = 1;
95
+ }
96
+ else {
97
+ i1 = 0;
98
+ j1 = 1;
99
+ k1 = 0;
100
+ i2 = 1;
101
+ j2 = 1;
102
+ k2 = 0;
103
+ }
104
+ const n0 = contribution(i, j, k, x0, y0, z0, seed);
105
+ const n1 = contribution(i + i1, j + j1, k + k1, x0 - i1 + G3, y0 - j1 + G3, z0 - k1 + G3, seed);
106
+ const n2 = contribution(i + i2, j + j2, k + k2, x0 - i2 + 2 * G3, y0 - j2 + 2 * G3, z0 - k2 + 2 * G3, seed);
107
+ const n3 = contribution(i + 1, j + 1, k + 1, x0 - 0.5, y0 - 0.5, z0 - 0.5, seed);
108
+ return (n0 + n1 + n2 + n3) * SAMPLE3_SCALE;
109
+ }
110
+ //# sourceMappingURL=sample3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample3.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/sample3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,qGAAqG;AACrG,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB,mFAAmF;AACnF,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjB;;;;GAIG;AACH,MAAM,aAAa,GAAG,KAAK,CAAC;AAE5B,kGAAkG;AAClG,SAAS,YAAY,CACnB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,IAAY;IAEZ,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,IAAY;IACnE,MA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GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAChG,MAAM,EAAE,GAAG,YAAY,CACrB,CAAC,GAAG,EAAE,EACN,CAAC,GAAG,EAAE,EACN,CAAC,GAAG,EAAE,EACN,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,EAChB,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,EAChB,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,EAChB,IAAI,CACL,CAAC;IACF,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;IAEjF,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Noise2D } from '../../noiseMap/index.js';
2
+ import type { White2dOptions } from './_types/options.js';
3
+ /**
4
+ * Creates a `width` × `height` map of white noise in [0, 1): every cell gets an
5
+ * independent, uniformly distributed value with no relation to its neighbours.
6
+ * The caller owns the returned map.
7
+ *
8
+ * Each value is the top 24 bits of the hash of its world cell (`x + offsetX`,
9
+ * `y + offsetY`) and the seed, divided by 2^24. 24 bits is all a Float32 can
10
+ * hold exactly, so values are spaced 2^-24 apart and never reach 1. Values
11
+ * depend only on the world cell and the seed, so chunks of any size agree bit
12
+ * for bit where they overlap.
13
+ *
14
+ * Throws if the size is not a positive integer or an option breaks its contract
15
+ * in {@link White2dOptions}.
16
+ */
17
+ export declare function create(width: number, height: number, options?: Partial<White2dOptions>): Noise2D;
18
+ //# sourceMappingURL=2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/white/2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,GACpC,OAAO,CAkBT"}
@@ -0,0 +1,33 @@
1
+ import { Hashes } from '../../hashes/index.js';
2
+ import { Noise2D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_WHITE_2D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions2 } from './options.js';
5
+ /**
6
+ * Creates a `width` × `height` map of white noise in [0, 1): every cell gets an
7
+ * independent, uniformly distributed value with no relation to its neighbours.
8
+ * The caller owns the returned map.
9
+ *
10
+ * Each value is the top 24 bits of the hash of its world cell (`x + offsetX`,
11
+ * `y + offsetY`) and the seed, divided by 2^24. 24 bits is all a Float32 can
12
+ * hold exactly, so values are spaced 2^-24 apart and never reach 1. Values
13
+ * depend only on the world cell and the seed, so chunks of any size agree bit
14
+ * for bit where they overlap.
15
+ *
16
+ * Throws if the size is not a positive integer or an option breaks its contract
17
+ * in {@link White2dOptions}.
18
+ */
19
+ export function create(width, height, options = {}) {
20
+ const noise = Noise2D.create(width, height);
21
+ const config = { ...DEFAULT_WHITE_2D_OPTIONS, ...options };
22
+ validateOptions2(config);
23
+ const seed = config.seed;
24
+ for (let y = 0; y < height; y++) {
25
+ for (let x = 0; x < width; x++) {
26
+ const hash = Hashes.hash2(x + config.offsetX, y + config.offsetY, seed);
27
+ const value = (hash >>> 8) / 16777216;
28
+ Noise2D.set(noise, x, y, value);
29
+ }
30
+ }
31
+ return noise;
32
+ }
33
+ //# sourceMappingURL=2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.js","sourceRoot":"","sources":["../../../src/noiseTypes/white/2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,MAAc,EACd,OAAO,GAA4B,EAAE;IAErC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3D,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACxE,MAAM,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Noise3D } from '../../noiseMap/index.js';
2
+ import type { White3dOptions } from './_types/options.js';
3
+ /**
4
+ * Creates a `width` × `height` × `depth` map of white noise in [0, 1): every
5
+ * cell gets an independent, uniformly distributed value. The caller owns the
6
+ * returned map.
7
+ *
8
+ * Works like the 2D version with a third axis: each value is the top 24 bits of
9
+ * the hash of its world cell (`x + offsetX`, `y + offsetY`, `z + offsetZ`) and
10
+ * the seed, divided by 2^24, so chunks of any size agree bit for bit where they
11
+ * overlap.
12
+ *
13
+ * Throws if the size is not a positive integer or an option breaks its contract
14
+ * in {@link White3dOptions}.
15
+ */
16
+ export declare function create(width: number, height: number, depth: number, options?: Partial<White3dOptions>): Noise3D;
17
+ //# sourceMappingURL=3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/white/3d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM,GACpC,OAAO,CAoBT"}
@@ -0,0 +1,34 @@
1
+ import { Hashes } from '../../hashes/index.js';
2
+ import { Noise3D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_WHITE_3D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions3 } from './options.js';
5
+ /**
6
+ * Creates a `width` × `height` × `depth` map of white noise in [0, 1): every
7
+ * cell gets an independent, uniformly distributed value. The caller owns the
8
+ * returned map.
9
+ *
10
+ * Works like the 2D version with a third axis: each value is the top 24 bits of
11
+ * the hash of its world cell (`x + offsetX`, `y + offsetY`, `z + offsetZ`) and
12
+ * the seed, divided by 2^24, so chunks of any size agree bit for bit where they
13
+ * overlap.
14
+ *
15
+ * Throws if the size is not a positive integer or an option breaks its contract
16
+ * in {@link White3dOptions}.
17
+ */
18
+ export function create(width, height, depth, options = {}) {
19
+ const noise = Noise3D.create(width, height, depth);
20
+ const config = { ...DEFAULT_WHITE_3D_OPTIONS, ...options };
21
+ validateOptions3(config);
22
+ const seed = config.seed;
23
+ for (let y = 0; y < height; y++) {
24
+ for (let x = 0; x < width; x++) {
25
+ for (let z = 0; z < depth; z++) {
26
+ const hash = Hashes.hash3(x + config.offsetX, y + config.offsetY, z + config.offsetZ, seed);
27
+ const value = (hash >>> 8) / 16777216;
28
+ Noise3D.set(noise, x, y, z, value);
29
+ }
30
+ }
31
+ }
32
+ return noise;
33
+ }
34
+ //# sourceMappingURL=3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.js","sourceRoot":"","sources":["../../../src/noiseTypes/white/3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,MAAc,EACd,KAAa,EACb,OAAO,GAA4B,EAAE;IAErC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3D,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KA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