@esengine/procgen 1.0.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 +21 -0
- package/dist/index.d.ts +619 -0
- package/dist/index.js +1792 -0
- package/dist/index.js.map +1 -0
- package/module.json +24 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ESEngine Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { BlueprintNodeTemplate, INodeExecutor, BlueprintNode, ExecutionResult } from '@esengine/blueprint';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @zh Perlin 噪声实现
|
|
5
|
+
* @en Perlin Noise Implementation
|
|
6
|
+
*
|
|
7
|
+
* @zh 基于 Ken Perlin 的改进版噪声算法
|
|
8
|
+
* @en Based on Ken Perlin's improved noise algorithm
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @zh Perlin 噪声生成器
|
|
12
|
+
* @en Perlin noise generator
|
|
13
|
+
*/
|
|
14
|
+
declare class PerlinNoise {
|
|
15
|
+
private readonly _perm;
|
|
16
|
+
private readonly _gradP;
|
|
17
|
+
/**
|
|
18
|
+
* @zh 创建 Perlin 噪声生成器
|
|
19
|
+
* @en Create Perlin noise generator
|
|
20
|
+
*
|
|
21
|
+
* @param seed - @zh 随机种子 @en Random seed
|
|
22
|
+
*/
|
|
23
|
+
constructor(seed?: number);
|
|
24
|
+
private _seed;
|
|
25
|
+
private _fade;
|
|
26
|
+
private _lerp;
|
|
27
|
+
private _dot2;
|
|
28
|
+
private _dot3;
|
|
29
|
+
/**
|
|
30
|
+
* @zh 2D Perlin 噪声
|
|
31
|
+
* @en 2D Perlin noise
|
|
32
|
+
*
|
|
33
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
34
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
35
|
+
* @returns @zh 噪声值 [-1, 1] @en Noise value [-1, 1]
|
|
36
|
+
*/
|
|
37
|
+
noise2D(x: number, y: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* @zh 3D Perlin 噪声
|
|
40
|
+
* @en 3D Perlin noise
|
|
41
|
+
*
|
|
42
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
43
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
44
|
+
* @param z - @zh Z 坐标 @en Z coordinate
|
|
45
|
+
* @returns @zh 噪声值 [-1, 1] @en Noise value [-1, 1]
|
|
46
|
+
*/
|
|
47
|
+
noise3D(x: number, y: number, z: number): number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @zh 创建 Perlin 噪声生成器
|
|
51
|
+
* @en Create Perlin noise generator
|
|
52
|
+
*/
|
|
53
|
+
declare function createPerlinNoise(seed?: number): PerlinNoise;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @zh Simplex 噪声实现
|
|
57
|
+
* @en Simplex Noise Implementation
|
|
58
|
+
*
|
|
59
|
+
* @zh 比 Perlin 噪声更快且没有方向性伪影
|
|
60
|
+
* @en Faster than Perlin noise with no directional artifacts
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* @zh Simplex 噪声生成器
|
|
64
|
+
* @en Simplex noise generator
|
|
65
|
+
*/
|
|
66
|
+
declare class SimplexNoise {
|
|
67
|
+
private readonly _perm;
|
|
68
|
+
private readonly _permMod12;
|
|
69
|
+
private static readonly _grad3;
|
|
70
|
+
/**
|
|
71
|
+
* @zh 创建 Simplex 噪声生成器
|
|
72
|
+
* @en Create Simplex noise generator
|
|
73
|
+
*
|
|
74
|
+
* @param seed - @zh 随机种子 @en Random seed
|
|
75
|
+
*/
|
|
76
|
+
constructor(seed?: number);
|
|
77
|
+
private _seed;
|
|
78
|
+
/**
|
|
79
|
+
* @zh 2D Simplex 噪声
|
|
80
|
+
* @en 2D Simplex noise
|
|
81
|
+
*
|
|
82
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
83
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
84
|
+
* @returns @zh 噪声值 [-1, 1] @en Noise value [-1, 1]
|
|
85
|
+
*/
|
|
86
|
+
noise2D(x: number, y: number): number;
|
|
87
|
+
/**
|
|
88
|
+
* @zh 3D Simplex 噪声
|
|
89
|
+
* @en 3D Simplex noise
|
|
90
|
+
*
|
|
91
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
92
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
93
|
+
* @param z - @zh Z 坐标 @en Z coordinate
|
|
94
|
+
* @returns @zh 噪声值 [-1, 1] @en Noise value [-1, 1]
|
|
95
|
+
*/
|
|
96
|
+
noise3D(x: number, y: number, z: number): number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @zh 创建 Simplex 噪声生成器
|
|
100
|
+
* @en Create Simplex noise generator
|
|
101
|
+
*/
|
|
102
|
+
declare function createSimplexNoise(seed?: number): SimplexNoise;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @zh Worley (Cellular) 噪声实现
|
|
106
|
+
* @en Worley (Cellular) Noise Implementation
|
|
107
|
+
*
|
|
108
|
+
* @zh 基于 Voronoi 图的噪声,适合生成细胞、石头纹理
|
|
109
|
+
* @en Voronoi-based noise, suitable for cellular and stone textures
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* @zh 距离函数类型
|
|
113
|
+
* @en Distance function type
|
|
114
|
+
*/
|
|
115
|
+
type DistanceFunction = 'euclidean' | 'manhattan' | 'chebyshev';
|
|
116
|
+
/**
|
|
117
|
+
* @zh Worley 噪声生成器
|
|
118
|
+
* @en Worley noise generator
|
|
119
|
+
*/
|
|
120
|
+
declare class WorleyNoise {
|
|
121
|
+
private readonly _seed;
|
|
122
|
+
private readonly _distanceFunc;
|
|
123
|
+
/**
|
|
124
|
+
* @zh 创建 Worley 噪声生成器
|
|
125
|
+
* @en Create Worley noise generator
|
|
126
|
+
*
|
|
127
|
+
* @param seed - @zh 随机种子 @en Random seed
|
|
128
|
+
* @param distanceFunc - @zh 距离函数 @en Distance function
|
|
129
|
+
*/
|
|
130
|
+
constructor(seed?: number, distanceFunc?: DistanceFunction);
|
|
131
|
+
private _hash;
|
|
132
|
+
private _randomPoint;
|
|
133
|
+
private _randomPoint3D;
|
|
134
|
+
private _distance2D;
|
|
135
|
+
private _distance3D;
|
|
136
|
+
/**
|
|
137
|
+
* @zh 2D Worley 噪声
|
|
138
|
+
* @en 2D Worley noise
|
|
139
|
+
*
|
|
140
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
141
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
142
|
+
* @param pointsPerCell - @zh 每个单元格的点数 @en Points per cell
|
|
143
|
+
* @returns @zh 到最近点的距离 [0, ~1.4] @en Distance to nearest point [0, ~1.4]
|
|
144
|
+
*/
|
|
145
|
+
noise2D(x: number, y: number, pointsPerCell?: number): number;
|
|
146
|
+
/**
|
|
147
|
+
* @zh 3D Worley 噪声
|
|
148
|
+
* @en 3D Worley noise
|
|
149
|
+
*
|
|
150
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
151
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
152
|
+
* @param z - @zh Z 坐标 @en Z coordinate
|
|
153
|
+
* @param pointsPerCell - @zh 每个单元格的点数 @en Points per cell
|
|
154
|
+
* @returns @zh 到最近点的距离 @en Distance to nearest point
|
|
155
|
+
*/
|
|
156
|
+
noise3D(x: number, y: number, z: number, pointsPerCell?: number): number;
|
|
157
|
+
/**
|
|
158
|
+
* @zh 获取到第 N 近点的距离(用于更复杂的纹理)
|
|
159
|
+
* @en Get distance to Nth nearest point (for more complex textures)
|
|
160
|
+
*
|
|
161
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
162
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
163
|
+
* @param n - @zh 第 N 近 (1 = 最近) @en Nth nearest (1 = nearest)
|
|
164
|
+
* @returns @zh 距离值 @en Distance value
|
|
165
|
+
*/
|
|
166
|
+
nthNearest2D(x: number, y: number, n?: number): number;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @zh 创建 Worley 噪声生成器
|
|
170
|
+
* @en Create Worley noise generator
|
|
171
|
+
*/
|
|
172
|
+
declare function createWorleyNoise(seed?: number, distanceFunc?: DistanceFunction): WorleyNoise;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @zh 分形布朗运动 (FBM)
|
|
176
|
+
* @en Fractal Brownian Motion (FBM)
|
|
177
|
+
*
|
|
178
|
+
* @zh 通过叠加多层噪声创建更自然的效果
|
|
179
|
+
* @en Creates more natural effects by layering multiple noise octaves
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* @zh 噪声函数接口
|
|
183
|
+
* @en Noise function interface
|
|
184
|
+
*/
|
|
185
|
+
interface INoise2D {
|
|
186
|
+
noise2D(x: number, y: number): number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @zh 噪声函数接口 (3D)
|
|
190
|
+
* @en Noise function interface (3D)
|
|
191
|
+
*/
|
|
192
|
+
interface INoise3D {
|
|
193
|
+
noise3D(x: number, y: number, z: number): number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @zh FBM 配置
|
|
197
|
+
* @en FBM configuration
|
|
198
|
+
*/
|
|
199
|
+
interface FBMConfig {
|
|
200
|
+
/**
|
|
201
|
+
* @zh 八度数(层数)
|
|
202
|
+
* @en Number of octaves (layers)
|
|
203
|
+
*/
|
|
204
|
+
octaves: number;
|
|
205
|
+
/**
|
|
206
|
+
* @zh 频率倍增因子
|
|
207
|
+
* @en Frequency multiplier per octave
|
|
208
|
+
*/
|
|
209
|
+
lacunarity: number;
|
|
210
|
+
/**
|
|
211
|
+
* @zh 振幅衰减因子
|
|
212
|
+
* @en Amplitude decay per octave
|
|
213
|
+
*/
|
|
214
|
+
persistence: number;
|
|
215
|
+
/**
|
|
216
|
+
* @zh 初始频率
|
|
217
|
+
* @en Initial frequency
|
|
218
|
+
*/
|
|
219
|
+
frequency: number;
|
|
220
|
+
/**
|
|
221
|
+
* @zh 初始振幅
|
|
222
|
+
* @en Initial amplitude
|
|
223
|
+
*/
|
|
224
|
+
amplitude: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @zh FBM 噪声生成器
|
|
228
|
+
* @en FBM noise generator
|
|
229
|
+
*/
|
|
230
|
+
declare class FBM {
|
|
231
|
+
private readonly _noise;
|
|
232
|
+
private readonly _config;
|
|
233
|
+
/**
|
|
234
|
+
* @zh 创建 FBM 噪声生成器
|
|
235
|
+
* @en Create FBM noise generator
|
|
236
|
+
*
|
|
237
|
+
* @param noise - @zh 基础噪声函数 @en Base noise function
|
|
238
|
+
* @param config - @zh 配置 @en Configuration
|
|
239
|
+
*/
|
|
240
|
+
constructor(noise: INoise2D & Partial<INoise3D>, config?: Partial<FBMConfig>);
|
|
241
|
+
/**
|
|
242
|
+
* @zh 2D FBM 噪声
|
|
243
|
+
* @en 2D FBM noise
|
|
244
|
+
*
|
|
245
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
246
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
247
|
+
* @returns @zh 噪声值 @en Noise value
|
|
248
|
+
*/
|
|
249
|
+
noise2D(x: number, y: number): number;
|
|
250
|
+
/**
|
|
251
|
+
* @zh 3D FBM 噪声
|
|
252
|
+
* @en 3D FBM noise
|
|
253
|
+
*
|
|
254
|
+
* @param x - @zh X 坐标 @en X coordinate
|
|
255
|
+
* @param y - @zh Y 坐标 @en Y coordinate
|
|
256
|
+
* @param z - @zh Z 坐标 @en Z coordinate
|
|
257
|
+
* @returns @zh 噪声值 @en Noise value
|
|
258
|
+
*/
|
|
259
|
+
noise3D(x: number, y: number, z: number): number;
|
|
260
|
+
/**
|
|
261
|
+
* @zh Ridged FBM(脊状,适合山脉)
|
|
262
|
+
* @en Ridged FBM (suitable for mountains)
|
|
263
|
+
*/
|
|
264
|
+
ridged2D(x: number, y: number): number;
|
|
265
|
+
/**
|
|
266
|
+
* @zh Turbulence(湍流,使用绝对值)
|
|
267
|
+
* @en Turbulence (using absolute value)
|
|
268
|
+
*/
|
|
269
|
+
turbulence2D(x: number, y: number): number;
|
|
270
|
+
/**
|
|
271
|
+
* @zh Billowed(膨胀,适合云朵)
|
|
272
|
+
* @en Billowed (suitable for clouds)
|
|
273
|
+
*/
|
|
274
|
+
billowed2D(x: number, y: number): number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @zh 创建 FBM 噪声生成器
|
|
278
|
+
* @en Create FBM noise generator
|
|
279
|
+
*/
|
|
280
|
+
declare function createFBM(noise: INoise2D & Partial<INoise3D>, config?: Partial<FBMConfig>): FBM;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @zh 种子随机数生成器
|
|
284
|
+
* @en Seeded Random Number Generator
|
|
285
|
+
*
|
|
286
|
+
* @zh 基于 xorshift128+ 算法的确定性伪随机数生成器
|
|
287
|
+
* @en Deterministic PRNG based on xorshift128+ algorithm
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* @zh 种子随机数生成器
|
|
291
|
+
* @en Seeded random number generator
|
|
292
|
+
*/
|
|
293
|
+
declare class SeededRandom {
|
|
294
|
+
private _s0;
|
|
295
|
+
private _s1;
|
|
296
|
+
private readonly _initialS0;
|
|
297
|
+
private readonly _initialS1;
|
|
298
|
+
/**
|
|
299
|
+
* @zh 创建种子随机数生成器
|
|
300
|
+
* @en Create seeded random number generator
|
|
301
|
+
*
|
|
302
|
+
* @param seed - @zh 随机种子 @en Random seed
|
|
303
|
+
*/
|
|
304
|
+
constructor(seed?: number);
|
|
305
|
+
/**
|
|
306
|
+
* @zh 重置到初始状态
|
|
307
|
+
* @en Reset to initial state
|
|
308
|
+
*/
|
|
309
|
+
reset(): void;
|
|
310
|
+
/**
|
|
311
|
+
* @zh 生成下一个随机数 [0, 1)
|
|
312
|
+
* @en Generate next random number [0, 1)
|
|
313
|
+
*/
|
|
314
|
+
next(): number;
|
|
315
|
+
/**
|
|
316
|
+
* @zh 生成整数 [min, max]
|
|
317
|
+
* @en Generate integer [min, max]
|
|
318
|
+
*/
|
|
319
|
+
nextInt(min: number, max: number): number;
|
|
320
|
+
/**
|
|
321
|
+
* @zh 生成浮点数 [min, max)
|
|
322
|
+
* @en Generate float [min, max)
|
|
323
|
+
*/
|
|
324
|
+
nextFloat(min: number, max: number): number;
|
|
325
|
+
/**
|
|
326
|
+
* @zh 生成布尔值
|
|
327
|
+
* @en Generate boolean
|
|
328
|
+
*
|
|
329
|
+
* @param probability - @zh 为 true 的概率 [0, 1] @en Probability of true [0, 1]
|
|
330
|
+
*/
|
|
331
|
+
nextBool(probability?: number): boolean;
|
|
332
|
+
/**
|
|
333
|
+
* @zh 生成正态分布随机数 (Box-Muller 变换)
|
|
334
|
+
* @en Generate normally distributed random number (Box-Muller transform)
|
|
335
|
+
*
|
|
336
|
+
* @param mean - @zh 均值 @en Mean
|
|
337
|
+
* @param stdDev - @zh 标准差 @en Standard deviation
|
|
338
|
+
*/
|
|
339
|
+
nextGaussian(mean?: number, stdDev?: number): number;
|
|
340
|
+
/**
|
|
341
|
+
* @zh 生成指数分布随机数
|
|
342
|
+
* @en Generate exponentially distributed random number
|
|
343
|
+
*
|
|
344
|
+
* @param lambda - @zh 率参数 @en Rate parameter
|
|
345
|
+
*/
|
|
346
|
+
nextExponential(lambda?: number): number;
|
|
347
|
+
/**
|
|
348
|
+
* @zh 在圆内生成均匀分布的随机点
|
|
349
|
+
* @en Generate uniformly distributed random point in circle
|
|
350
|
+
*
|
|
351
|
+
* @param radius - @zh 半径 @en Radius
|
|
352
|
+
*/
|
|
353
|
+
nextPointInCircle(radius?: number): {
|
|
354
|
+
x: number;
|
|
355
|
+
y: number;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* @zh 在圆环上生成随机点
|
|
359
|
+
* @en Generate random point on circle
|
|
360
|
+
*
|
|
361
|
+
* @param radius - @zh 半径 @en Radius
|
|
362
|
+
*/
|
|
363
|
+
nextPointOnCircle(radius?: number): {
|
|
364
|
+
x: number;
|
|
365
|
+
y: number;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* @zh 在球内生成均匀分布的随机点
|
|
369
|
+
* @en Generate uniformly distributed random point in sphere
|
|
370
|
+
*
|
|
371
|
+
* @param radius - @zh 半径 @en Radius
|
|
372
|
+
*/
|
|
373
|
+
nextPointInSphere(radius?: number): {
|
|
374
|
+
x: number;
|
|
375
|
+
y: number;
|
|
376
|
+
z: number;
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* @zh 生成随机方向向量
|
|
380
|
+
* @en Generate random direction vector
|
|
381
|
+
*/
|
|
382
|
+
nextDirection2D(): {
|
|
383
|
+
x: number;
|
|
384
|
+
y: number;
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* @zh 创建种子随机数生成器
|
|
389
|
+
* @en Create seeded random number generator
|
|
390
|
+
*/
|
|
391
|
+
declare function createSeededRandom(seed?: number): SeededRandom;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @zh 加权随机工具
|
|
395
|
+
* @en Weighted Random Utilities
|
|
396
|
+
*/
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @zh 加权项
|
|
400
|
+
* @en Weighted item
|
|
401
|
+
*/
|
|
402
|
+
interface WeightedItem<T> {
|
|
403
|
+
/**
|
|
404
|
+
* @zh 项目值
|
|
405
|
+
* @en Item value
|
|
406
|
+
*/
|
|
407
|
+
value: T;
|
|
408
|
+
/**
|
|
409
|
+
* @zh 权重(> 0)
|
|
410
|
+
* @en Weight (> 0)
|
|
411
|
+
*/
|
|
412
|
+
weight: number;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* @zh 加权随机选择器
|
|
416
|
+
* @en Weighted random selector
|
|
417
|
+
*/
|
|
418
|
+
declare class WeightedRandom<T> {
|
|
419
|
+
private readonly _items;
|
|
420
|
+
private readonly _cumulativeWeights;
|
|
421
|
+
private readonly _totalWeight;
|
|
422
|
+
/**
|
|
423
|
+
* @zh 创建加权随机选择器
|
|
424
|
+
* @en Create weighted random selector
|
|
425
|
+
*
|
|
426
|
+
* @param items - @zh 加权项数组 @en Array of weighted items
|
|
427
|
+
*/
|
|
428
|
+
constructor(items: WeightedItem<T>[]);
|
|
429
|
+
/**
|
|
430
|
+
* @zh 随机选择一个项目
|
|
431
|
+
* @en Randomly select an item
|
|
432
|
+
*
|
|
433
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
434
|
+
*/
|
|
435
|
+
pick(rng: SeededRandom | {
|
|
436
|
+
next(): number;
|
|
437
|
+
}): T;
|
|
438
|
+
/**
|
|
439
|
+
* @zh 使用 Math.random 选择
|
|
440
|
+
* @en Pick using Math.random
|
|
441
|
+
*/
|
|
442
|
+
pickRandom(): T;
|
|
443
|
+
/**
|
|
444
|
+
* @zh 获取项目的选中概率
|
|
445
|
+
* @en Get selection probability of an item
|
|
446
|
+
*/
|
|
447
|
+
getProbability(index: number): number;
|
|
448
|
+
/**
|
|
449
|
+
* @zh 获取所有项目数量
|
|
450
|
+
* @en Get total item count
|
|
451
|
+
*/
|
|
452
|
+
get size(): number;
|
|
453
|
+
/**
|
|
454
|
+
* @zh 获取总权重
|
|
455
|
+
* @en Get total weight
|
|
456
|
+
*/
|
|
457
|
+
get totalWeight(): number;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* @zh 从加权数组中随机选择
|
|
461
|
+
* @en Pick from weighted array
|
|
462
|
+
*
|
|
463
|
+
* @param items - @zh 加权项数组 @en Array of weighted items
|
|
464
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
465
|
+
*/
|
|
466
|
+
declare function weightedPick<T>(items: WeightedItem<T>[], rng: SeededRandom | {
|
|
467
|
+
next(): number;
|
|
468
|
+
}): T;
|
|
469
|
+
/**
|
|
470
|
+
* @zh 从权重映射中随机选择
|
|
471
|
+
* @en Pick from weight map
|
|
472
|
+
*
|
|
473
|
+
* @param weights - @zh 值到权重的映射 @en Map of values to weights
|
|
474
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
475
|
+
*/
|
|
476
|
+
declare function weightedPickFromMap<T extends string | number>(weights: Record<T, number>, rng: SeededRandom | {
|
|
477
|
+
next(): number;
|
|
478
|
+
}): T;
|
|
479
|
+
/**
|
|
480
|
+
* @zh 创建加权随机选择器
|
|
481
|
+
* @en Create weighted random selector
|
|
482
|
+
*/
|
|
483
|
+
declare function createWeightedRandom<T>(items: WeightedItem<T>[]): WeightedRandom<T>;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @zh 洗牌和采样工具
|
|
487
|
+
* @en Shuffle and Sampling Utilities
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @zh Fisher-Yates 洗牌算法(原地修改)
|
|
492
|
+
* @en Fisher-Yates shuffle algorithm (in-place)
|
|
493
|
+
*
|
|
494
|
+
* @param array - @zh 要洗牌的数组 @en Array to shuffle
|
|
495
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
496
|
+
* @returns @zh 洗牌后的数组(同一数组)@en Shuffled array (same array)
|
|
497
|
+
*/
|
|
498
|
+
declare function shuffle<T>(array: T[], rng: SeededRandom | {
|
|
499
|
+
next(): number;
|
|
500
|
+
}): T[];
|
|
501
|
+
/**
|
|
502
|
+
* @zh 创建洗牌后的副本(不修改原数组)
|
|
503
|
+
* @en Create shuffled copy (does not modify original)
|
|
504
|
+
*
|
|
505
|
+
* @param array - @zh 原数组 @en Original array
|
|
506
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
507
|
+
* @returns @zh 洗牌后的新数组 @en New shuffled array
|
|
508
|
+
*/
|
|
509
|
+
declare function shuffleCopy<T>(array: readonly T[], rng: SeededRandom | {
|
|
510
|
+
next(): number;
|
|
511
|
+
}): T[];
|
|
512
|
+
/**
|
|
513
|
+
* @zh 从数组中随机选择一个元素
|
|
514
|
+
* @en Pick a random element from array
|
|
515
|
+
*
|
|
516
|
+
* @param array - @zh 数组 @en Array
|
|
517
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
518
|
+
* @returns @zh 随机元素 @en Random element
|
|
519
|
+
*/
|
|
520
|
+
declare function pickOne<T>(array: readonly T[], rng: SeededRandom | {
|
|
521
|
+
next(): number;
|
|
522
|
+
}): T;
|
|
523
|
+
/**
|
|
524
|
+
* @zh 从数组中随机采样 N 个不重复元素
|
|
525
|
+
* @en Sample N unique elements from array
|
|
526
|
+
*
|
|
527
|
+
* @param array - @zh 数组 @en Array
|
|
528
|
+
* @param count - @zh 采样数量 @en Sample count
|
|
529
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
530
|
+
* @returns @zh 采样结果 @en Sample result
|
|
531
|
+
*/
|
|
532
|
+
declare function sample<T>(array: readonly T[], count: number, rng: SeededRandom | {
|
|
533
|
+
next(): number;
|
|
534
|
+
}): T[];
|
|
535
|
+
/**
|
|
536
|
+
* @zh 从数组中随机采样 N 个元素(可重复)
|
|
537
|
+
* @en Sample N elements from array (with replacement)
|
|
538
|
+
*
|
|
539
|
+
* @param array - @zh 数组 @en Array
|
|
540
|
+
* @param count - @zh 采样数量 @en Sample count
|
|
541
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
542
|
+
* @returns @zh 采样结果 @en Sample result
|
|
543
|
+
*/
|
|
544
|
+
declare function sampleWithReplacement<T>(array: readonly T[], count: number, rng: SeededRandom | {
|
|
545
|
+
next(): number;
|
|
546
|
+
}): T[];
|
|
547
|
+
/**
|
|
548
|
+
* @zh 生成范围内的随机整数数组(不重复)
|
|
549
|
+
* @en Generate array of random unique integers in range
|
|
550
|
+
*
|
|
551
|
+
* @param min - @zh 最小值(包含)@en Minimum (inclusive)
|
|
552
|
+
* @param max - @zh 最大值(包含)@en Maximum (inclusive)
|
|
553
|
+
* @param count - @zh 数量 @en Count
|
|
554
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
555
|
+
* @returns @zh 随机整数数组 @en Array of random integers
|
|
556
|
+
*/
|
|
557
|
+
declare function randomIntegers(min: number, max: number, count: number, rng: SeededRandom | {
|
|
558
|
+
next(): number;
|
|
559
|
+
}): number[];
|
|
560
|
+
/**
|
|
561
|
+
* @zh 按权重从数组中采样(不重复)
|
|
562
|
+
* @en Sample from array by weight (without replacement)
|
|
563
|
+
*
|
|
564
|
+
* @param items - @zh 项目数组 @en Item array
|
|
565
|
+
* @param weights - @zh 权重数组 @en Weight array
|
|
566
|
+
* @param count - @zh 采样数量 @en Sample count
|
|
567
|
+
* @param rng - @zh 随机数生成器 @en Random number generator
|
|
568
|
+
*/
|
|
569
|
+
declare function weightedSample<T>(items: readonly T[], weights: readonly number[], count: number, rng: SeededRandom | {
|
|
570
|
+
next(): number;
|
|
571
|
+
}): T[];
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @zh 程序化生成蓝图节点
|
|
575
|
+
* @en Procedural Generation Blueprint Nodes
|
|
576
|
+
*/
|
|
577
|
+
|
|
578
|
+
declare const SampleNoise2DTemplate: BlueprintNodeTemplate;
|
|
579
|
+
declare class SampleNoise2DExecutor implements INodeExecutor {
|
|
580
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
581
|
+
}
|
|
582
|
+
declare const SampleFBMTemplate: BlueprintNodeTemplate;
|
|
583
|
+
declare class SampleFBMExecutor implements INodeExecutor {
|
|
584
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
585
|
+
}
|
|
586
|
+
declare const SeededRandomTemplate: BlueprintNodeTemplate;
|
|
587
|
+
declare class SeededRandomExecutor implements INodeExecutor {
|
|
588
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
589
|
+
}
|
|
590
|
+
declare const SeededRandomIntTemplate: BlueprintNodeTemplate;
|
|
591
|
+
declare class SeededRandomIntExecutor implements INodeExecutor {
|
|
592
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
593
|
+
}
|
|
594
|
+
declare const WeightedPickTemplate: BlueprintNodeTemplate;
|
|
595
|
+
declare class WeightedPickExecutor implements INodeExecutor {
|
|
596
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
597
|
+
}
|
|
598
|
+
declare const ShuffleArrayTemplate: BlueprintNodeTemplate;
|
|
599
|
+
declare class ShuffleArrayExecutor implements INodeExecutor {
|
|
600
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
601
|
+
}
|
|
602
|
+
declare const PickRandomTemplate: BlueprintNodeTemplate;
|
|
603
|
+
declare class PickRandomExecutor implements INodeExecutor {
|
|
604
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
605
|
+
}
|
|
606
|
+
declare const SampleArrayTemplate: BlueprintNodeTemplate;
|
|
607
|
+
declare class SampleArrayExecutor implements INodeExecutor {
|
|
608
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
609
|
+
}
|
|
610
|
+
declare const RandomPointInCircleTemplate: BlueprintNodeTemplate;
|
|
611
|
+
declare class RandomPointInCircleExecutor implements INodeExecutor {
|
|
612
|
+
execute(node: BlueprintNode, context: unknown): ExecutionResult;
|
|
613
|
+
}
|
|
614
|
+
declare const ProcGenNodeDefinitions: {
|
|
615
|
+
templates: BlueprintNodeTemplate[];
|
|
616
|
+
executors: Map<string, INodeExecutor>;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
export { type DistanceFunction, FBM, type FBMConfig, type INoise2D, type INoise3D, PerlinNoise, PickRandomExecutor, PickRandomTemplate, ProcGenNodeDefinitions, RandomPointInCircleExecutor, RandomPointInCircleTemplate, SampleArrayExecutor, SampleArrayTemplate, SampleFBMExecutor, SampleFBMTemplate, SampleNoise2DExecutor, SampleNoise2DTemplate, SeededRandom, SeededRandomExecutor, SeededRandomIntExecutor, SeededRandomIntTemplate, SeededRandomTemplate, ShuffleArrayExecutor, ShuffleArrayTemplate, SimplexNoise, type WeightedItem, WeightedPickExecutor, WeightedPickTemplate, WeightedRandom, WorleyNoise, createFBM, createPerlinNoise, createSeededRandom, createSimplexNoise, createWeightedRandom, createWorleyNoise, pickOne, randomIntegers, sample, sampleWithReplacement, shuffle, shuffleCopy, weightedPick, weightedPickFromMap, weightedSample };
|