@cult-frog/noise 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +29 -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 +78 -4
  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,64 @@
1
+ import { getOctaveConfig } from '../../fractal/index.js';
2
+ import { Noise2D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_PERLIN_2D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions2 } from './options.js';
5
+ import { sample2 } from './sample2.js';
6
+ /**
7
+ * Summed octaves at an integer world cell, in ±`maxPossibleHeight`. Assumes
8
+ * `config` is validated: `octaveOffsets` then holds exactly `config.octaves`
9
+ * pairs, so the indexed reads below are always in bounds.
10
+ */
11
+ function samplePoint(worldX, worldY, config, octaveOffsets, invScale) {
12
+ let amplitude = 1;
13
+ let frequency = 1;
14
+ let noiseHeight = 0;
15
+ for (let i = 0; i < config.octaves; i++) {
16
+ const index = i * 2;
17
+ const scaledFrequency = invScale * frequency;
18
+ const sampleX = (worldX + octaveOffsets[index]) * scaledFrequency;
19
+ const sampleY = (worldY + octaveOffsets[index + 1]) * scaledFrequency;
20
+ noiseHeight += sample2(sampleX, sampleY, config.seed) * amplitude;
21
+ amplitude *= config.persistence;
22
+ frequency *= config.lacunarity;
23
+ }
24
+ return noiseHeight;
25
+ }
26
+ /**
27
+ * Creates a `width` × `height` map of fractal (multi-octave) Perlin noise in
28
+ * [0, 1]. The caller owns the returned map.
29
+ *
30
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`) and
31
+ * the other options, never on the map's size. Chunks of any size, created with
32
+ * the same options and their world origin as the offset, agree bit for bit
33
+ * wherever they overlap.
34
+ *
35
+ * The mapping to [0, 1] is fixed by the options, not stretched to each map's own
36
+ * minimum and maximum; that is what keeps chunks consistent. The cost is
37
+ * contrast: the fixed bound is the sum of octave amplitudes, which summed noise
38
+ * rarely approaches. With the defaults (5 octaves, persistence 0.5) a 256 × 256
39
+ * map spans roughly 0.2–0.8, while a single octave uses nearly all of [0, 1].
40
+ * Stretch the result yourself if you need contrast more than tiling.
41
+ *
42
+ * Throws if the size is not a positive integer or an option breaks its contract
43
+ * in {@link Perlin2dOptions}.
44
+ */
45
+ export function create(width, height, options = {}) {
46
+ const noise = Noise2D.create(width, height);
47
+ const config = { ...DEFAULT_PERLIN_2D_OPTIONS, ...options };
48
+ validateOptions2(config);
49
+ const values = Noise2D.getValues(noise);
50
+ const invScale = 1 / config.scale;
51
+ const [octaveOffsets, maxPossibleHeight] = getOctaveConfig(config, 2);
52
+ const invRange = 0.5 / maxPossibleHeight;
53
+ let index = 0;
54
+ for (let y = 0; y < height; y++) {
55
+ const worldY = y + config.offsetY;
56
+ for (let x = 0; x < width; x++) {
57
+ const worldX = x + config.offsetX;
58
+ const value = samplePoint(worldX, worldY, config, octaveOffsets, invScale);
59
+ values[index++] = value * invRange + 0.5;
60
+ }
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';
3
+ /**
4
+ * Creates a `width` × `height` × `depth` map of fractal (multi-octave) Perlin
5
+ * noise in [0, 1]. The caller owns the returned map.
6
+ *
7
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`,
8
+ * `z + offsetZ`) and the other options, never on the map's size. Chunks of any
9
+ * size, created with the same options and their world origin as the offset,
10
+ * agree bit for bit wherever they overlap.
11
+ *
12
+ * As in 2D, the mapping to [0, 1] is fixed by the options rather than stretched
13
+ * per map, which keeps chunks consistent at the cost of contrast. 3D noise
14
+ * spreads less than 2D: with the defaults a 48³ map spans roughly 0.23–0.78, and
15
+ * a single octave roughly 0.15–0.88.
16
+ *
17
+ * Each cell costs `octaves` calls to `sample3`, which blends eight corners, so a
18
+ * cell costs about twice a 2D one and the total grows with the volume.
19
+ *
20
+ * Throws if the size is not a positive integer or an option breaks its contract
21
+ * in {@link Perlin3dOptions}.
22
+ */
23
+ export declare function create(width: number, height: number, depth: number, options?: Partial<Perlin3dOptions>): Noise3D;
24
+ //# sourceMappingURL=3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/3d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAmC3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,OAAO,CAAC,eAAe,CAAM,GACrC,OAAO,CA0BT"}
@@ -0,0 +1,69 @@
1
+ import { getOctaveConfig } from '../../fractal/index.js';
2
+ import { Noise3D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_PERLIN_3D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions3 } from './options.js';
5
+ import { sample3 } from './sample3.js';
6
+ /**
7
+ * Summed octaves at an integer world cell, in ±`maxPossibleHeight`. Assumes
8
+ * `config` is validated: `octaveOffsets` then holds exactly `config.octaves`
9
+ * triples, so the indexed reads below are always in bounds.
10
+ */
11
+ function samplePoint(worldX, worldY, worldZ, config, octaveOffsets, invScale) {
12
+ let amplitude = 1;
13
+ let frequency = 1;
14
+ let noiseHeight = 0;
15
+ for (let i = 0; i < config.octaves; i++) {
16
+ const index = i * 3;
17
+ const scaledFrequency = invScale * frequency;
18
+ const sampleX = (worldX + octaveOffsets[index]) * scaledFrequency;
19
+ const sampleY = (worldY + octaveOffsets[index + 1]) * scaledFrequency;
20
+ const sampleZ = (worldZ + octaveOffsets[index + 2]) * scaledFrequency;
21
+ noiseHeight += sample3(sampleX, sampleY, sampleZ, config.seed) * amplitude;
22
+ amplitude *= config.persistence;
23
+ frequency *= config.lacunarity;
24
+ }
25
+ return noiseHeight;
26
+ }
27
+ /**
28
+ * Creates a `width` × `height` × `depth` map of fractal (multi-octave) Perlin
29
+ * noise in [0, 1]. The caller owns the returned map.
30
+ *
31
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`,
32
+ * `z + offsetZ`) and the other options, never on the map's size. Chunks of any
33
+ * size, created with the same options and their world origin as the offset,
34
+ * agree bit for bit wherever they overlap.
35
+ *
36
+ * As in 2D, the mapping to [0, 1] is fixed by the options rather than stretched
37
+ * per map, which keeps chunks consistent at the cost of contrast. 3D noise
38
+ * spreads less than 2D: with the defaults a 48³ map spans roughly 0.23–0.78, and
39
+ * a single octave roughly 0.15–0.88.
40
+ *
41
+ * Each cell costs `octaves` calls to `sample3`, which blends eight corners, so a
42
+ * cell costs about twice a 2D one and the total grows with the volume.
43
+ *
44
+ * Throws if the size is not a positive integer or an option breaks its contract
45
+ * in {@link Perlin3dOptions}.
46
+ */
47
+ export function create(width, height, depth, options = {}) {
48
+ const noise = Noise3D.create(width, height, depth);
49
+ const config = { ...DEFAULT_PERLIN_3D_OPTIONS, ...options };
50
+ validateOptions3(config);
51
+ const values = Noise3D.getValues(noise);
52
+ const invScale = 1 / config.scale;
53
+ const [octaveOffsets, maxPossibleHeight] = getOctaveConfig(config, 3);
54
+ const invRange = 0.5 / maxPossibleHeight;
55
+ let index = 0;
56
+ for (let z = 0; z < depth; z++) {
57
+ const worldZ = z + config.offsetZ;
58
+ for (let y = 0; y < height; y++) {
59
+ const worldY = y + config.offsetY;
60
+ for (let x = 0; x < width; x++) {
61
+ const worldX = x + config.offsetX;
62
+ const value = samplePoint(worldX, worldY, worldZ, config, octaveOffsets, invScale);
63
+ values[index++] = value * invRange + 0.5;
64
+ }
65
+ }
66
+ }
67
+ return noise;
68
+ }
69
+ //# sourceMappingURL=3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.js","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC;;;;GAIG;AACH,SAAS,WAAW,CAClB,MAAc,EACd,MAAc,EACd,MAAc,EACd,MAAuB,EACvB,aAA2B,EAC3B,QAAgB;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;QAC7C,MAAM,OAAO,GAAG,CAAC,MAA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AAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;YAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;gBAClC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;gBACnF,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,QAAQ,GAAG,GAAG,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { Perlin2dOptions, Perlin3dOptions } from './options.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/perlin/_types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,eAAe,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/perlin/_types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import type { FractalOptions } from '../../../fractal/index.js';
2
+ /**
3
+ * Options for 2D Perlin 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 Perlin2dOptions extends FractalOptions {
8
+ /**
9
+ * World x of the map's first column, in map cells. A safe integer (|v| < 2^53),
10
+ * so `x + offsetX` is exact and a chunk at offset 64 reproduces column 64 of a
11
+ * chunk at offset 0 bit for bit. Larger integers would round when added to.
12
+ */
13
+ offsetX: number;
14
+ /** World y of the map's first row. Same contract as {@link offsetX}. */
15
+ offsetY: number;
16
+ }
17
+ /** Options for 3D Perlin noise: the 2D options plus a z offset. */
18
+ export interface Perlin3dOptions extends Perlin2dOptions {
19
+ /** World z of the map's first layer. Same contract as {@link Perlin2dOptions.offsetX}. */
20
+ offsetZ: number;
21
+ }
22
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/noiseTypes/perlin/_types/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,0FAA0F;IAC1F,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/perlin/_types/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Perlin2dOptions, Perlin3dOptions } from './_types/options.js';
2
+ export declare const DEFAULT_PERLIN_2D_OPTIONS: Perlin2dOptions;
3
+ export declare const DEFAULT_PERLIN_3D_OPTIONS: Perlin3dOptions;
4
+ //# sourceMappingURL=defaultOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE5E,eAAO,MAAM,yBAAyB,EAAE,eAQvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,eAGvC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const DEFAULT_PERLIN_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_PERLIN_3D_OPTIONS = {
11
+ ...DEFAULT_PERLIN_2D_OPTIONS,
12
+ offsetZ: 0,
13
+ };
14
+ //# sourceMappingURL=defaultOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.js","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/defaultOptions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,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,yBAAyB,GAAoB;IACxD,GAAG,yBAAyB;IAC5B,OAAO,EAAE,CAAC;CACX,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * as Perlin2 from './2d.js';
2
+ export * as Perlin3 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/perlin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,mBAAmB,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * as Perlin2 from './2d.js';
2
+ export * as Perlin3 from './3d.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Perlin2dOptions, Perlin3dOptions } from './_types/options.js';
2
+ /**
3
+ * Throws if `options` breaks a contract in {@link Perlin2dOptions}. The fractal
4
+ * options are checked first, by the shared fractal validation.
5
+ */
6
+ export declare function validateOptions2(options: Perlin2dOptions): void;
7
+ /** Throws if `options` breaks a contract in {@link Perlin3dOptions}. */
8
+ export declare function validateOptions3(options: Perlin3dOptions): void;
9
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAI/D;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAG/D"}
@@ -0,0 +1,17 @@
1
+ import { validateFractalOptions } from '../../fractal/index.js';
2
+ /**
3
+ * Throws if `options` breaks a contract in {@link Perlin2dOptions}. 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 Perlin3dOptions}. */
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/perlin/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAwB;IACvD,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,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAAC,OAAwB;IACvD,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,25 @@
1
+ /**
2
+ * Dot product of the gradient hashed for lattice corner (`cx`, `cy`) with the
3
+ * offset (`dx`, `dy`) from that corner to the sample point.
4
+ *
5
+ * The eight gradients are (±1, 0), (0, ±1) and (±1, ±1), picked by integer hash
6
+ * and a switch instead of an angle. ECMAScript lets engines approximate trig
7
+ * functions differently, so angle-based gradients would make the same seed give
8
+ * different noise in different engines; this uses only exact operations.
9
+ */
10
+ export declare function corner2(cx: number, cy: number, dx: number, dy: number, seed: number): number;
11
+ /**
12
+ * One octave of 2D Perlin noise at (`x`, `y`) in lattice units, in [-1, 1].
13
+ *
14
+ * Exactly 0 at every integer point. The ±1 bound is only reached near cell
15
+ * centres where diagonal gradients line up, so most values sit well inside it.
16
+ * The smootherstep fade keeps the first and second derivatives continuous across
17
+ * cell borders. Corner coordinates are truncated to int32 by the hash, so the
18
+ * pattern repeats beyond ±2^31.
19
+ *
20
+ * Seeded output must match across engines, so this may only use exact
21
+ * operations: + − × ÷, floor, sqrt, integer and bitwise ops. Engine-approximated
22
+ * functions such as sin, cos, exp and pow break that.
23
+ */
24
+ export declare function sample2(x: number, y: number, seed: number): number;
25
+ //# sourceMappingURL=sample2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample2.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/sample2.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAmBnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAczD"}
@@ -0,0 +1,58 @@
1
+ import { Easing, lerp } from '@cult-frog/math';
2
+ import { Hashes } from '../../hashes/index.js';
3
+ /**
4
+ * Dot product of the gradient hashed for lattice corner (`cx`, `cy`) with the
5
+ * offset (`dx`, `dy`) from that corner to the sample point.
6
+ *
7
+ * The eight gradients are (±1, 0), (0, ±1) and (±1, ±1), picked by integer hash
8
+ * and a switch instead of an angle. ECMAScript lets engines approximate trig
9
+ * functions differently, so angle-based gradients would make the same seed give
10
+ * different noise in different engines; this uses only exact operations.
11
+ */
12
+ export function corner2(cx, cy, dx, dy, seed) {
13
+ switch (Hashes.hash2(cx, cy, seed) & 7) {
14
+ case 0:
15
+ return dx;
16
+ case 1:
17
+ return -dx;
18
+ case 2:
19
+ return dy;
20
+ case 3:
21
+ return -dy;
22
+ case 4:
23
+ return dx + dy;
24
+ case 5:
25
+ return dx - dy;
26
+ case 6:
27
+ return -dx + dy;
28
+ default:
29
+ return -dx - dy;
30
+ }
31
+ }
32
+ /**
33
+ * One octave of 2D Perlin noise at (`x`, `y`) in lattice units, in [-1, 1].
34
+ *
35
+ * Exactly 0 at every integer point. The ±1 bound is only reached near cell
36
+ * centres where diagonal gradients line up, so most values sit well inside it.
37
+ * The smootherstep fade keeps the first and second derivatives continuous across
38
+ * cell borders. Corner coordinates are truncated to int32 by the hash, so the
39
+ * pattern repeats beyond ±2^31.
40
+ *
41
+ * Seeded output must match across engines, so this may only use exact
42
+ * operations: + − × ÷, floor, sqrt, integer and bitwise ops. Engine-approximated
43
+ * functions such as sin, cos, exp and pow break that.
44
+ */
45
+ export function sample2(x, y, seed) {
46
+ const x0 = Math.floor(x);
47
+ const y0 = Math.floor(y);
48
+ const dx = x - x0;
49
+ const dy = y - y0;
50
+ const n00 = corner2(x0, y0, dx, dy, seed);
51
+ const n10 = corner2(x0 + 1, y0, dx - 1, dy, seed);
52
+ const n01 = corner2(x0, y0 + 1, dx, dy - 1, seed);
53
+ const n11 = corner2(x0 + 1, y0 + 1, dx - 1, dy - 1, seed);
54
+ const u = Easing.Smooth.smootherstep(dx);
55
+ const v = Easing.Smooth.smootherstep(dy);
56
+ return lerp(lerp(n00, n10, u), lerp(n01, n11, u), v);
57
+ }
58
+ //# sourceMappingURL=sample2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample2.js","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/sample2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,IAAY;IAClF,QAAQ,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAA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AAE,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IAE1D,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * One octave of 3D Perlin noise at (`x`, `y`, `z`) in lattice units, in [-1, 1].
3
+ *
4
+ * Exactly 0 at every integer point. Corner coordinates are truncated to int32 by
5
+ * the hash, so the pattern repeats beyond ±2^31. Like `sample2`, this may only use
6
+ * exact operations, so seeded output matches across engines.
7
+ */
8
+ export declare function sample3(x: number, y: number, z: number, seed: number): number;
9
+ //# sourceMappingURL=sample3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample3.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/sample3.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAwBpE"}
@@ -0,0 +1,38 @@
1
+ import { Easing, lerp } from '@cult-frog/math';
2
+ import { cubeEdge3 } from '../../gradient/index.js';
3
+ /**
4
+ * Brings the 3D sum inside [-1, 1]. With these gradients, eight corners can
5
+ * reach about 1.0364 off-centre (near (0.48, 0.36, 0.5) in a cell), unlike 2D,
6
+ * whose bound is exactly 1 at the centre. 1 / 1.03635 ≈ 0.96492, rounded down.
7
+ */
8
+ const SAMPLE3_SCALE = 0.9649;
9
+ /**
10
+ * One octave of 3D Perlin noise at (`x`, `y`, `z`) in lattice units, in [-1, 1].
11
+ *
12
+ * Exactly 0 at every integer point. Corner coordinates are truncated to int32 by
13
+ * the hash, so the pattern repeats beyond ±2^31. Like `sample2`, this may only use
14
+ * exact operations, so seeded output matches across engines.
15
+ */
16
+ export function sample3(x, y, z, seed) {
17
+ const x0 = Math.floor(x);
18
+ const y0 = Math.floor(y);
19
+ const z0 = Math.floor(z);
20
+ const dx = x - x0;
21
+ const dy = y - y0;
22
+ const dz = z - z0;
23
+ const n000 = cubeEdge3(x0, y0, z0, dx, dy, dz, seed);
24
+ const n100 = cubeEdge3(x0 + 1, y0, z0, dx - 1, dy, dz, seed);
25
+ const n010 = cubeEdge3(x0, y0 + 1, z0, dx, dy - 1, dz, seed);
26
+ const n110 = cubeEdge3(x0 + 1, y0 + 1, z0, dx - 1, dy - 1, dz, seed);
27
+ const n001 = cubeEdge3(x0, y0, z0 + 1, dx, dy, dz - 1, seed);
28
+ const n101 = cubeEdge3(x0 + 1, y0, z0 + 1, dx - 1, dy, dz - 1, seed);
29
+ const n011 = cubeEdge3(x0, y0 + 1, z0 + 1, dx, dy - 1, dz - 1, seed);
30
+ const n111 = cubeEdge3(x0 + 1, y0 + 1, z0 + 1, dx - 1, dy - 1, dz - 1, seed);
31
+ const u = Easing.Smooth.smootherstep(dx);
32
+ const v = Easing.Smooth.smootherstep(dy);
33
+ const w = Easing.Smooth.smootherstep(dz);
34
+ const near = lerp(lerp(n000, n100, u), lerp(n010, n110, u), v);
35
+ const far = lerp(lerp(n001, n101, u), lerp(n011, n111, u), v);
36
+ return lerp(near, far, w) * SAMPLE3_SCALE;
37
+ }
38
+ //# sourceMappingURL=sample3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample3.js","sourceRoot":"","sources":["../../../src/noiseTypes/perlin/sample3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,C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23 @@
1
+ import { Noise2D } from '../../noiseMap/index.js';
2
+ import type { Simplex2dOptions } from './_types/index.js';
3
+ /**
4
+ * Creates a `width` × `height` map of fractal (multi-octave) simplex 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, which keeps chunks consistent. Simplex fills that range
14
+ * far more than Perlin does: with the defaults a 256 × 256 map spans roughly
15
+ * 0.05–0.96 (Perlin roughly 0.2–0.8), and a single octave reaches almost exactly
16
+ * 0 and 1. A threshold tuned for one, such as a sea level, covers a different
17
+ * share of the map with the other at the same options.
18
+ *
19
+ * Throws if the size is not a positive integer or an option breaks its contract
20
+ * in {@link Simplex2dOptions}.
21
+ */
22
+ export declare function create(width: number, height: number, options?: Partial<Simplex2dOptions>): Noise2D;
23
+ //# sourceMappingURL=2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,GACtC,OAAO,CAuBT"}
@@ -0,0 +1,64 @@
1
+ import { getOctaveConfig } from '../../fractal/index.js';
2
+ import { Noise2D } from '../../noiseMap/index.js';
3
+ import { DEFAULT_SIMPLEX_2D_OPTIONS } from './defaultOptions.js';
4
+ import { validateOptions2 } from './options.js';
5
+ import { sample2 } from './sample2.js';
6
+ /**
7
+ * Creates a `width` × `height` map of fractal (multi-octave) simplex noise in
8
+ * [0, 1]. The caller owns the returned map.
9
+ *
10
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`) and
11
+ * the other options, never on the map's size. Chunks of any size, created with
12
+ * the same options and their world origin as the offset, agree bit for bit
13
+ * wherever they overlap.
14
+ *
15
+ * The mapping to [0, 1] is fixed by the options, not stretched to each map's own
16
+ * minimum and maximum, which keeps chunks consistent. Simplex fills that range
17
+ * far more than Perlin does: with the defaults a 256 × 256 map spans roughly
18
+ * 0.05–0.96 (Perlin roughly 0.2–0.8), and a single octave reaches almost exactly
19
+ * 0 and 1. A threshold tuned for one, such as a sea level, covers a different
20
+ * share of the map with the other at the same options.
21
+ *
22
+ * Throws if the size is not a positive integer or an option breaks its contract
23
+ * in {@link Simplex2dOptions}.
24
+ */
25
+ export function create(width, height, options = {}) {
26
+ const noise = Noise2D.create(width, height);
27
+ const config = { ...DEFAULT_SIMPLEX_2D_OPTIONS, ...options };
28
+ validateOptions2(config);
29
+ const values = Noise2D.getValues(noise);
30
+ const invScale = 1 / config.scale;
31
+ const [octaveOffsets, maxPossibleHeight] = getOctaveConfig(config, 2);
32
+ const invRange = 0.5 / maxPossibleHeight;
33
+ let index = 0;
34
+ for (let y = 0; y < height; y++) {
35
+ const worldY = y + config.offsetY;
36
+ for (let x = 0; x < width; x++) {
37
+ const worldX = x + config.offsetX;
38
+ const value = samplePoint(worldX, worldY, config, octaveOffsets, invScale);
39
+ values[index++] = value * invRange + 0.5;
40
+ }
41
+ }
42
+ return noise;
43
+ }
44
+ /**
45
+ * Summed octaves at an integer world cell, in ±`maxPossibleHeight`. Assumes
46
+ * `config` is validated: `octaveOffsets` then holds exactly `config.octaves`
47
+ * pairs, so the indexed reads below are always in bounds.
48
+ */
49
+ function samplePoint(worldX, worldY, config, octaveOffsets, invScale) {
50
+ let amplitude = 1;
51
+ let frequency = 1;
52
+ let noiseHeight = 0;
53
+ for (let i = 0; i < config.octaves; i++) {
54
+ const index = i * 2;
55
+ const scaledFrequency = invScale * frequency;
56
+ const sampleX = (worldX + octaveOffsets[index]) * scaledFrequency;
57
+ const sampleY = (worldY + octaveOffsets[index + 1]) * scaledFrequency;
58
+ noiseHeight += sample2(sampleX, sampleY, config.seed) * amplitude;
59
+ amplitude *= config.persistence;
60
+ frequency *= config.lacunarity;
61
+ }
62
+ return noiseHeight;
63
+ }
64
+ //# sourceMappingURL=2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2d.js","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/2d.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;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,MAAc,EACd,OAAO,GAA8B,EAAE;IAEvC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE5C,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,K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AAI,CAAC,GAAG,SAAS,CAAC;QAElE,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC;QAChC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Noise3D } from '../../noiseMap/index.js';
2
+ import type { Simplex3dOptions } from './_types/index.js';
3
+ /**
4
+ * Creates a `width` × `height` × `depth` map of fractal (multi-octave) simplex
5
+ * noise in [0, 1]. The caller owns the returned map.
6
+ *
7
+ * Each value depends only on its world cell (`x + offsetX`, `y + offsetY`,
8
+ * `z + offsetZ`) and the other options, never on the map's size. Chunks of any
9
+ * size, created with the same options and their world origin as the offset,
10
+ * agree bit for bit wherever they overlap.
11
+ *
12
+ * As in 2D, the mapping to [0, 1] is fixed by the options rather than stretched
13
+ * per map, and simplex fills more of it than Perlin: with the defaults a 48³ map
14
+ * spans roughly 0.07–0.93 (Perlin roughly 0.25–0.75), and a single octave
15
+ * reaches almost exactly 0 and 1.
16
+ *
17
+ * Each cell costs `octaves` calls to `sample3`, which sums four corners against
18
+ * eight for 3D Perlin, so a map costs about half as much as the same 3D Perlin
19
+ * map. The total still grows with the volume.
20
+ *
21
+ * Throws if the size is not a positive integer or an option breaks its contract
22
+ * in {@link Simplex3dOptions}.
23
+ */
24
+ export declare function create(width: number, height: number, depth: number, options?: Partial<Simplex3dOptions>): Noise3D;
25
+ //# sourceMappingURL=3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d.d.ts","sourceRoot":"","sources":["../../../src/noiseTypes/simplex/3d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,GACtC,OAAO,CA0BT"}