fastnoiselite-builder 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.
- package/LICENSE +23 -0
- package/README.md +283 -0
- package/dist/builder/ANoiseBuilder.d.ts +100 -0
- package/dist/builder/NoiseBuilder2D.d.ts +14 -0
- package/dist/builder/NoiseBuilder3D.d.ts +18 -0
- package/dist/builder/index.d.ts +3 -0
- package/dist/core/gradients.d.ts +27 -0
- package/dist/core/hash.d.ts +10 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/math.d.ts +25 -0
- package/dist/core/primes.d.ts +6 -0
- package/dist/fractal/fbm.d.ts +9 -0
- package/dist/fractal/index.d.ts +3 -0
- package/dist/fractal/pingpong.d.ts +13 -0
- package/dist/fractal/ridged.d.ts +9 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3631 -0
- package/dist/noise/cellular/cellular.d.ts +28 -0
- package/dist/noise/cellular/distance.d.ts +43 -0
- package/dist/noise/cellular/index.d.ts +3 -0
- package/dist/noise/cellular/return-type.d.ts +48 -0
- package/dist/noise/index.d.ts +6 -0
- package/dist/noise/opensimplex2.d.ts +9 -0
- package/dist/noise/opensimplex2s.d.ts +9 -0
- package/dist/noise/perlin.d.ts +9 -0
- package/dist/noise/value-cubic.d.ts +9 -0
- package/dist/noise/value.d.ts +9 -0
- package/dist/transform/transform3dFunc.d.ts +2 -0
- package/dist/types/common.d.ts +56 -0
- package/dist/types/config.d.ts +28 -0
- package/dist/types/enums.d.ts +67 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/warp/basic-grid.d.ts +23 -0
- package/dist/warp/index.d.ts +3 -0
- package/dist/warp/opensimplex2.d.ts +25 -0
- package/dist/warp/types.d.ts +27 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright(c) 2020 Jordan Peck (jordan.me2@gmail.com)
|
|
4
|
+
Copyright(c) 2020 Contributors
|
|
5
|
+
Copyright(c) 2026 Sébastien Vincent (metabast@gmail.com)
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# fastnoiselite-builder
|
|
2
|
+
|
|
3
|
+
A TypeScript implementation of FastNoiseLite with zero runtime dispatch overhead.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- **Zero runtime switch statements**: Function composition happens at build-time via the Builder pattern
|
|
8
|
+
- **Fully typed**: Complete TypeScript type definitions
|
|
9
|
+
- **Modular architecture**: Clean separation of concerns
|
|
10
|
+
- **Implementation details**: Uses `Float64Array` for gradient tables, pre-computed constants, and closures to capture context
|
|
11
|
+
- **Multiple noise algorithms**:
|
|
12
|
+
- OpenSimplex2 (2D & 3D)
|
|
13
|
+
- OpenSimplex2S (2D & 3D with skew)
|
|
14
|
+
- Cellular/Voronoi (2D & 3D) with 4 distance functions and 7 return types
|
|
15
|
+
- Perlin (2D & 3D)
|
|
16
|
+
- Value (2D & 3D)
|
|
17
|
+
- ValueCubic (2D & 3D)
|
|
18
|
+
- **Fractal modifiers**:
|
|
19
|
+
- FBm (Fractional Brownian Motion)
|
|
20
|
+
- Ridged
|
|
21
|
+
- PingPong
|
|
22
|
+
- **Domain Warp**:
|
|
23
|
+
- BasicGrid warp (smooth grid-based deformation)
|
|
24
|
+
- OpenSimplex2 warp (organic gradient-based deformation)
|
|
25
|
+
- OpenSimplex2Reduced warp (faster simplified version)
|
|
26
|
+
- Progressive fractal warp (multi-octave deformation)
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install fastnoiselite-builder
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Basic 2D Noise
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { NoiseBuilder2D, NoiseType } from 'fastnoiselite-builder';
|
|
40
|
+
|
|
41
|
+
const noise = new NoiseBuilder2D()
|
|
42
|
+
.seed(1337)
|
|
43
|
+
.frequency(0.01)
|
|
44
|
+
.noiseType(NoiseType.Perlin)
|
|
45
|
+
.build2D();
|
|
46
|
+
|
|
47
|
+
const value = noise(x, y); // Returns noise value in range [-1, 1]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Fractal Noise
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { NoiseBuilder2D, NoiseType, FractalType } from 'fastnoiselite-builder';
|
|
54
|
+
|
|
55
|
+
const noise = new NoiseBuilder2D()
|
|
56
|
+
.seed(1337)
|
|
57
|
+
.frequency(0.01)
|
|
58
|
+
.noiseType(NoiseType.Perlin)
|
|
59
|
+
.fractalType(FractalType.FBm)
|
|
60
|
+
.fractalOctaves(4)
|
|
61
|
+
.fractalLacunarity(2.0)
|
|
62
|
+
.fractalGain(0.5)
|
|
63
|
+
.build2D();
|
|
64
|
+
|
|
65
|
+
const value = noise(x, y);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3D Noise
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { NoiseBuilder3D, NoiseType } from 'fastnoiselite-builder';
|
|
72
|
+
|
|
73
|
+
const noise = new NoiseBuilder3D()
|
|
74
|
+
.seed(1337)
|
|
75
|
+
.frequency(0.01)
|
|
76
|
+
.noiseType(NoiseType.OpenSimplex2)
|
|
77
|
+
.build3D();
|
|
78
|
+
|
|
79
|
+
const value = noise(x, y, z);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Ridged Terrain
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { NoiseBuilder2D, NoiseType, FractalType } from 'fastnoiselite-builder';
|
|
86
|
+
|
|
87
|
+
const noise = new NoiseBuilder2D()
|
|
88
|
+
.seed(42)
|
|
89
|
+
.frequency(0.005)
|
|
90
|
+
.noiseType(NoiseType.Perlin)
|
|
91
|
+
.fractalType(FractalType.Ridged)
|
|
92
|
+
.fractalOctaves(6)
|
|
93
|
+
.fractalWeightedStrength(0.8)
|
|
94
|
+
.build2D();
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Cellular/Voronoi Noise
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { NoiseBuilder2D, NoiseType, CellularDistanceFunction, CellularReturnType } from 'fastnoiselite-builder';
|
|
101
|
+
|
|
102
|
+
// Basic voronoi pattern
|
|
103
|
+
const noise = new NoiseBuilder2D()
|
|
104
|
+
.seed(1337)
|
|
105
|
+
.frequency(0.01)
|
|
106
|
+
.noiseType(NoiseType.Cellular)
|
|
107
|
+
.cellularDistanceFunction(CellularDistanceFunction.Euclidean)
|
|
108
|
+
.cellularReturnType(CellularReturnType.Distance)
|
|
109
|
+
.build2D();
|
|
110
|
+
|
|
111
|
+
// Voronoi edges (great for cell boundaries)
|
|
112
|
+
const edges = new NoiseBuilder2D()
|
|
113
|
+
.seed(1337)
|
|
114
|
+
.frequency(0.01)
|
|
115
|
+
.noiseType(NoiseType.Cellular)
|
|
116
|
+
.cellularReturnType(CellularReturnType.Distance2Sub)
|
|
117
|
+
.build2D();
|
|
118
|
+
|
|
119
|
+
// Cell value (flat regions with hard edges)
|
|
120
|
+
const cells = new NoiseBuilder2D()
|
|
121
|
+
.seed(1337)
|
|
122
|
+
.frequency(0.01)
|
|
123
|
+
.noiseType(NoiseType.Cellular)
|
|
124
|
+
.cellularReturnType(CellularReturnType.CellValue)
|
|
125
|
+
.cellularJitter(1.0) // Control randomness (0-1)
|
|
126
|
+
.build2D();
|
|
127
|
+
|
|
128
|
+
// Manhattan distance (diamond-shaped cells)
|
|
129
|
+
const manhattan = new NoiseBuilder2D()
|
|
130
|
+
.seed(1337)
|
|
131
|
+
.frequency(0.01)
|
|
132
|
+
.noiseType(NoiseType.Cellular)
|
|
133
|
+
.cellularDistanceFunction(CellularDistanceFunction.Manhattan)
|
|
134
|
+
.cellularReturnType(CellularReturnType.Distance)
|
|
135
|
+
.build2D();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Domain Warp
|
|
139
|
+
|
|
140
|
+
Domain Warp deforms the coordinate space before sampling noise, creating organic flowing patterns.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { NoiseBuilder2D, NoiseType, DomainWarpType, DomainWarpFractalType } from 'fastnoiselite-builder';
|
|
144
|
+
|
|
145
|
+
// Simple domain warp
|
|
146
|
+
const noise = new NoiseBuilder2D()
|
|
147
|
+
.seed(42)
|
|
148
|
+
.frequency(0.01)
|
|
149
|
+
.noiseType(NoiseType.Perlin)
|
|
150
|
+
.domainWarpType(DomainWarpType.BasicGrid)
|
|
151
|
+
.domainWarpAmplitude(30.0)
|
|
152
|
+
.domainWarpFrequency(0.005)
|
|
153
|
+
.build2D();
|
|
154
|
+
|
|
155
|
+
// Fractal domain warp (progressive)
|
|
156
|
+
const fractalWarpNoise = new NoiseBuilder2D()
|
|
157
|
+
.seed(42)
|
|
158
|
+
.frequency(0.01)
|
|
159
|
+
.noiseType(NoiseType.OpenSimplex2)
|
|
160
|
+
.domainWarpType(DomainWarpType.OpenSimplex2)
|
|
161
|
+
.domainWarpAmplitude(50.0)
|
|
162
|
+
.domainWarpFrequency(0.005)
|
|
163
|
+
.domainWarpFractalType(DomainWarpFractalType.Progressive)
|
|
164
|
+
.domainWarpFractalOctaves(3)
|
|
165
|
+
.domainWarpFractalLacunarity(2.0)
|
|
166
|
+
.domainWarpFractalGain(0.5)
|
|
167
|
+
.build2D();
|
|
168
|
+
|
|
169
|
+
const value = noise(x, y);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Use Cases for Domain Warp:**
|
|
173
|
+
- **Terrain generation** - Natural-looking height maps with flowing features
|
|
174
|
+
- **Cloud patterns** - Organic, swirling cloud formations
|
|
175
|
+
- **Marble textures** - Flowing veined patterns
|
|
176
|
+
- **Water caustics** - Complex light refraction patterns
|
|
177
|
+
- **Organic shapes** - Any pattern that needs natural, flowing deformation
|
|
178
|
+
|
|
179
|
+
## Architecture
|
|
180
|
+
|
|
181
|
+
The library uses a **composition over inheritance** approach with the Builder pattern:
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
185
|
+
│ NoiseBuilder2D / NoiseBuilder3D │
|
|
186
|
+
│ • Fluent API for configuration │
|
|
187
|
+
│ • Composes functions at build-time │
|
|
188
|
+
│ • Returns composed noise function │
|
|
189
|
+
└─────────────────────────────────────────────────────────────┘
|
|
190
|
+
│
|
|
191
|
+
┌──────────┴──────────┐
|
|
192
|
+
▼ ▼
|
|
193
|
+
┌──────────────┐ ┌──────────────┐
|
|
194
|
+
│ Base Noise │ │ Fractals │
|
|
195
|
+
│ Generators │ │ Modifiers │
|
|
196
|
+
└──────────────┘ └──────────────┘
|
|
197
|
+
│ │
|
|
198
|
+
┌───────────┼───────────┐ │
|
|
199
|
+
▼ ▼ ▼ ▼
|
|
200
|
+
OpenSimplex Perlin Value FBm
|
|
201
|
+
Value ValueCubic Ridged
|
|
202
|
+
PingPong
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Project Structure
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
lib/
|
|
209
|
+
├── types/ # TypeScript type definitions
|
|
210
|
+
├── core/ # Math utilities, hash functions, constants
|
|
211
|
+
├── noise/ # Noise generators (OpenSimplex, Perlin, Value, etc.)
|
|
212
|
+
├── fractal/ # Fractal modifiers (FBm, Ridged, PingPong)
|
|
213
|
+
├── builder/ # NoiseBuilder2D / NoiseBuilder3D fluent API
|
|
214
|
+
└── __tests__/ # Test suite
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Build the library (generates dist/)
|
|
221
|
+
npm run build:lib
|
|
222
|
+
|
|
223
|
+
# Run tests
|
|
224
|
+
npm test
|
|
225
|
+
|
|
226
|
+
# Run tests with UI
|
|
227
|
+
npm run test:ui
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## API Reference
|
|
231
|
+
|
|
232
|
+
### NoiseBuilder2D / NoiseBuilder3D Methods
|
|
233
|
+
|
|
234
|
+
| Method | Description | Default |
|
|
235
|
+
|--------|-------------|---------|
|
|
236
|
+
| `seed(n)` | Set random seed | 1337 |
|
|
237
|
+
| `frequency(f)` | Set sampling frequency | 0.01 |
|
|
238
|
+
| `noiseType(type)` | Set noise algorithm | `NoiseType.OpenSimplex2` |
|
|
239
|
+
| `fractalType(type)` | Set fractal type | `FractalType.None` |
|
|
240
|
+
| `fractalOctaves(n)` | Set number of octaves | 3 |
|
|
241
|
+
| `fractalLacunarity(f)` | Set lacunarity | 2.0 |
|
|
242
|
+
| `fractalGain(f)` | Set gain | 0.5 |
|
|
243
|
+
| `fractalWeightedStrength(f)` | Set weighted strength | 0.0 |
|
|
244
|
+
| `fractalPingPongStrength(f)` | Set ping-pong strength | 2.0 |
|
|
245
|
+
| `cellularDistanceFunction(type)` | Distance metric for cellular noise | `CellularDistanceFunction.EuclideanSq` |
|
|
246
|
+
| `cellularReturnType(type)` | Return type for cellular noise | `CellularReturnType.Distance` |
|
|
247
|
+
| `cellularJitter(f)` | Cell position randomness (0-1) | 1.0 |
|
|
248
|
+
| `domainWarpType(type)` | Set domain warp algorithm | `DomainWarpType.None` |
|
|
249
|
+
| `domainWarpAmplitude(f)` | Set warp strength | 30.0 |
|
|
250
|
+
| `domainWarpFrequency(f)` | Set warp sampling frequency | 0.005 |
|
|
251
|
+
| `domainWarpFractalType(type)` | Set fractal warp mode | `DomainWarpFractalType.None` |
|
|
252
|
+
| `domainWarpFractalOctaves(n)` | Set warp fractal octaves | 3 |
|
|
253
|
+
| `domainWarpFractalLacunarity(f)` | Set warp fractal lacunarity | 2.0 |
|
|
254
|
+
| `domainWarpFractalGain(f)` | Set warp fractal gain | 0.5 |
|
|
255
|
+
| `build2D()` | Build 2D noise function *(NoiseBuilder2D only)* | - |
|
|
256
|
+
| `build3D()` | Build 3D noise function *(NoiseBuilder3D only)* | - |
|
|
257
|
+
|
|
258
|
+
### Cellular Options
|
|
259
|
+
|
|
260
|
+
**Distance Functions:**
|
|
261
|
+
- `CellularDistanceFunction.Euclidean` - True distance (with sqrt)
|
|
262
|
+
- `CellularDistanceFunction.EuclideanSq` - Squared distance (faster)
|
|
263
|
+
- `CellularDistanceFunction.Manhattan` - Sum of absolute differences (diamond-shaped cells)
|
|
264
|
+
- `CellularDistanceFunction.Hybrid` - Combination of Manhattan and Euclidean
|
|
265
|
+
|
|
266
|
+
**Return Types:**
|
|
267
|
+
- `CellularReturnType.CellValue` - Value based on closest cell (flat regions)
|
|
268
|
+
- `CellularReturnType.Distance` - Distance to closest point (voronoi)
|
|
269
|
+
- `CellularReturnType.Distance2` - Distance to second closest point
|
|
270
|
+
- `CellularReturnType.Distance2Add` - Average of both distances
|
|
271
|
+
- `CellularReturnType.Distance2Sub` - Difference between distances (cell edges)
|
|
272
|
+
- `CellularReturnType.Distance2Mul` - Product of both distances
|
|
273
|
+
- `CellularReturnType.Distance2Div` - Ratio of distances
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
MIT License - Based on FastNoiseLite by Jordan Peck
|
|
278
|
+
|
|
279
|
+
## Credits
|
|
280
|
+
|
|
281
|
+
- Original FastNoiseLite: [Auburn/FastNoiseLite](https://github.com/Auburn/FastNoiseLite)
|
|
282
|
+
- JavaScript port: snowfoxsh
|
|
283
|
+
- TypeScript implementation: Sébastien Vincent
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type NoiseConfig, NoiseType, CellularDistanceFunction, CellularReturnType, FractalType, DomainWarpType, DomainWarpFractalType, TransformType3D, RotationType3D } from '../types';
|
|
2
|
+
export declare abstract class ANoiseBuilder {
|
|
3
|
+
protected config: Required<NoiseConfig>;
|
|
4
|
+
/**
|
|
5
|
+
* Set the seed for noise generation
|
|
6
|
+
*/
|
|
7
|
+
seed(value: number): this;
|
|
8
|
+
/**
|
|
9
|
+
* Set the frequency for noise generation
|
|
10
|
+
*/
|
|
11
|
+
frequency(value: number): this;
|
|
12
|
+
/**
|
|
13
|
+
* Set the noise algorithm type
|
|
14
|
+
*/
|
|
15
|
+
noiseType(value: NoiseType): this;
|
|
16
|
+
/**
|
|
17
|
+
* Set the rotation type for 3D noise
|
|
18
|
+
*/
|
|
19
|
+
rotationType3D(value: RotationType3D): this;
|
|
20
|
+
/**
|
|
21
|
+
* Set the fractal type
|
|
22
|
+
*/
|
|
23
|
+
fractalType(value: FractalType): this;
|
|
24
|
+
/**
|
|
25
|
+
* Set the number of octaves for fractal noise
|
|
26
|
+
*/
|
|
27
|
+
fractalOctaves(value: number): this;
|
|
28
|
+
/**
|
|
29
|
+
* Set the lacunarity for fractal noise
|
|
30
|
+
*/
|
|
31
|
+
fractalLacunarity(value: number): this;
|
|
32
|
+
/**
|
|
33
|
+
* Set the gain for fractal noise
|
|
34
|
+
*/
|
|
35
|
+
fractalGain(value: number): this;
|
|
36
|
+
/**
|
|
37
|
+
* Set the weighted strength for fractal noise
|
|
38
|
+
*/
|
|
39
|
+
fractalWeightedStrength(value: number): this;
|
|
40
|
+
/**
|
|
41
|
+
* Set the ping pong strength for ping pong fractal
|
|
42
|
+
*/
|
|
43
|
+
fractalPingPongStrength(value: number): this;
|
|
44
|
+
/**
|
|
45
|
+
* Set the transform type for 3D noise
|
|
46
|
+
*/
|
|
47
|
+
transformType3D(value: TransformType3D): this;
|
|
48
|
+
/**
|
|
49
|
+
* Set the distance function for cellular noise
|
|
50
|
+
*/
|
|
51
|
+
cellularDistanceFunction(value: CellularDistanceFunction): this;
|
|
52
|
+
/**
|
|
53
|
+
* Set the return type for cellular noise
|
|
54
|
+
*/
|
|
55
|
+
cellularReturnType(value: CellularReturnType): this;
|
|
56
|
+
/**
|
|
57
|
+
* Set the jitter modifier for cellular noise (0-1)
|
|
58
|
+
*/
|
|
59
|
+
cellularJitter(value: number): this;
|
|
60
|
+
/**
|
|
61
|
+
* Set the domain warp type
|
|
62
|
+
*/
|
|
63
|
+
domainWarpType(value: DomainWarpType): this;
|
|
64
|
+
/**
|
|
65
|
+
* Set the domain warp amplitude
|
|
66
|
+
*/
|
|
67
|
+
domainWarpAmplitude(value: number): this;
|
|
68
|
+
/**
|
|
69
|
+
* Set the domain warp frequency
|
|
70
|
+
*/
|
|
71
|
+
domainWarpFrequency(value: number): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set the domain warp fractal type (Progressive or Independent)
|
|
74
|
+
*/
|
|
75
|
+
domainWarpFractalType(value: DomainWarpFractalType): this;
|
|
76
|
+
/**
|
|
77
|
+
* Set the number of octaves for domain warp fractal
|
|
78
|
+
*/
|
|
79
|
+
domainWarpFractalOctaves(value: number): this;
|
|
80
|
+
/**
|
|
81
|
+
* Set the lacunarity for domain warp fractal
|
|
82
|
+
*/
|
|
83
|
+
domainWarpFractalLacunarity(value: number): this;
|
|
84
|
+
/**
|
|
85
|
+
* Set the gain for domain warp fractal
|
|
86
|
+
*/
|
|
87
|
+
domainWarpFractalGain(value: number): this;
|
|
88
|
+
/**
|
|
89
|
+
* Calculate fractal bounding value
|
|
90
|
+
*/
|
|
91
|
+
protected calculateFractalBounding(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Calculate fractal bounding for domain warp amplitude scaling
|
|
94
|
+
*/
|
|
95
|
+
protected calculateWarpFractalBounding(): number;
|
|
96
|
+
/**
|
|
97
|
+
* Get type-specific amplitude multiplier for domain warp
|
|
98
|
+
*/
|
|
99
|
+
protected getWarpAmplitudeMultiplier(): number;
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type NoiseFunction2D } from '../types';
|
|
2
|
+
import { ANoiseBuilder } from './ANoiseBuilder';
|
|
3
|
+
export declare class NoiseBuilder2D extends ANoiseBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* Build a 2D noise function
|
|
6
|
+
* Returns an optimized function with zero runtime dispatch overhead
|
|
7
|
+
*/
|
|
8
|
+
build2D(): NoiseFunction2D;
|
|
9
|
+
/**
|
|
10
|
+
* Build domain warp function for 2D (if enabled)
|
|
11
|
+
* Returns null if domain warp is disabled
|
|
12
|
+
*/
|
|
13
|
+
private buildDomainWarp2D;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type NoiseFunction3D } from '../types';
|
|
2
|
+
import { ANoiseBuilder } from './ANoiseBuilder';
|
|
3
|
+
export declare class NoiseBuilder3D extends ANoiseBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* Build a 3D noise function
|
|
6
|
+
* Returns an optimized function with zero runtime dispatch overhead
|
|
7
|
+
*/
|
|
8
|
+
build3D(): NoiseFunction3D;
|
|
9
|
+
/**
|
|
10
|
+
* Build domain warp function for 3D (if enabled)
|
|
11
|
+
* Returns null if domain warp is disabled
|
|
12
|
+
*/
|
|
13
|
+
private buildDomainWarp3D;
|
|
14
|
+
/**
|
|
15
|
+
* Get type-specific amplitude multiplier for domain warp
|
|
16
|
+
*/
|
|
17
|
+
private getWarpAmplitudeMultiplier3D;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gradient coordinate helper for 2D noise (Perlin, OpenSimplex2, OpenSimplex2S)
|
|
3
|
+
*/
|
|
4
|
+
export declare function gradCoordR2(seed: number, xPrimed: number, yPrimed: number, xd: number, yd: number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Gradient coordinate helper for 3D noise (Perlin, OpenSimplex2, OpenSimplex2S)
|
|
7
|
+
*/
|
|
8
|
+
export declare function gradCoordR3(seed: number, xPrimed: number, yPrimed: number, zPrimed: number, xd: number, yd: number, zd: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* 2D gradient vectors for OpenSimplex2 and Perlin noise
|
|
11
|
+
*/
|
|
12
|
+
export declare const GRADIENTS_2D: Float64Array<ArrayBuffer>;
|
|
13
|
+
/**
|
|
14
|
+
* 2D random vectors
|
|
15
|
+
* Used for domain warp and cellular noise
|
|
16
|
+
*/
|
|
17
|
+
export declare const RAND_VECS_2D: Float64Array<ArrayBuffer>;
|
|
18
|
+
/**
|
|
19
|
+
* 3D gradient vectors
|
|
20
|
+
* Used for Perlin noise and domain warp
|
|
21
|
+
* 256 elements (64 gradients * 4 components)
|
|
22
|
+
*/
|
|
23
|
+
export declare const GRADIENTS_3D: Float64Array<ArrayBuffer>;
|
|
24
|
+
/**
|
|
25
|
+
* 3D random vectors for domain warp
|
|
26
|
+
*/
|
|
27
|
+
export declare const RAND_VECS_3D: Float64Array<ArrayBuffer>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash function for 2D coordinates (R2)
|
|
3
|
+
* Returns a hash value for seeded 2D coordinates
|
|
4
|
+
*/
|
|
5
|
+
export declare function hashR2(seed: number, xPrimed: number, yPrimed: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Hash function for 3D coordinates (R3)
|
|
8
|
+
* Returns a hash value for seeded 3D coordinates
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashR3(seed: number, xPrimed: number, yPrimed: number, zPrimed: number): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fast floor using bitwise operation
|
|
3
|
+
* Equivalent to Math.floor for positive numbers, slightly faster
|
|
4
|
+
*/
|
|
5
|
+
export declare function fastFloor(f: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Linear interpolation
|
|
8
|
+
*/
|
|
9
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Hermite interpolation (smoothstep)
|
|
12
|
+
*/
|
|
13
|
+
export declare function interpHermite(t: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* Quintic interpolation (smootherstep)
|
|
16
|
+
*/
|
|
17
|
+
export declare function interpQuintic(t: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Cubic interpolation
|
|
20
|
+
*/
|
|
21
|
+
export declare function cubicLerp(a: number, b: number, c: number, d: number, t: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Ping pong function for fractal noise
|
|
24
|
+
*/
|
|
25
|
+
export declare function pingPong(t: number): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NoiseFunction2D, NoiseFunction3D, FractalContext, TransformFunction3D } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Fractional Brownian Motion (FBm) 2D modifier
|
|
4
|
+
*/
|
|
5
|
+
export declare function createFBm2D(createBaseNoise: (seed: number) => NoiseFunction2D, ctx: FractalContext): NoiseFunction2D;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Fractional Brownian Motion (FBm) 3D modifier
|
|
8
|
+
*/
|
|
9
|
+
export declare function createFBm3D(createBaseNoise: (seed: number) => NoiseFunction3D, transformFunction3d: TransformFunction3D, ctx: FractalContext): NoiseFunction3D;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NoiseFunction2D, NoiseFunction3D, PingPongContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a PingPong fractal 2D modifier
|
|
4
|
+
*/
|
|
5
|
+
export declare function createPingPong2D(createBaseNoise: (seed: number) => NoiseFunction2D, ctx: PingPongContext): NoiseFunction2D;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a PingPong fractal 3D modifier
|
|
8
|
+
*/
|
|
9
|
+
export declare function createPingPong3D(createBaseNoise: (seed: number) => NoiseFunction3D, transformFunction3d: (x: number, y: number, z: number) => {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
}, ctx: PingPongContext): NoiseFunction3D;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NoiseFunction2D, NoiseFunction3D, FractalContext, TransformFunction3D } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Ridged fractal 2D modifier
|
|
4
|
+
*/
|
|
5
|
+
export declare function createRidged2D(createBaseNoise: (seed: number) => NoiseFunction2D, ctx: FractalContext): NoiseFunction2D;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Ridged fractal 3D modifier
|
|
8
|
+
*/
|
|
9
|
+
export declare function createRidged3D(createBaseNoise: (seed: number) => NoiseFunction3D, transformFunction3d: TransformFunction3D, ctx: FractalContext): NoiseFunction3D;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NoiseBuilder2D, NoiseBuilder3D } from './builder';
|
|
2
|
+
export { NoiseType, FractalType, CellularDistanceFunction, CellularReturnType, DomainWarpType, DomainWarpFractalType, RotationType3D, TransformType3D, } from './types/enums';
|
|
3
|
+
export type { NoiseFunction2D, NoiseFunction3D } from './types/common';
|