@esengine/pathfinding 13.3.0 → 13.3.2
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/dist/{FlowController-Dc3nuLq5.d.ts → FlowController-BztOzQsW.d.ts} +36 -6
- package/dist/{chunk-NIKT3PQC.js → chunk-ZYGBA7VK.js} +29 -9
- package/dist/{chunk-NIKT3PQC.js.map → chunk-ZYGBA7VK.js.map} +1 -1
- package/dist/ecs.d.ts +27 -2
- package/dist/ecs.js +153 -2
- package/dist/ecs.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -2248,12 +2248,23 @@ interface IGridPathfinderAdapterConfig {
|
|
|
2248
2248
|
* @zh 网格单元格大小(像素),用于坐标转换
|
|
2249
2249
|
* @en Grid cell size (pixels), used for coordinate conversion
|
|
2250
2250
|
*
|
|
2251
|
-
* @zh
|
|
2252
|
-
* @en If set, input pixel coordinates are converted to grid coordinates, output grid coordinates are converted back to pixel coordinates
|
|
2251
|
+
* @zh 如果设置了此值,输入的像素坐标会自动转换为网格坐标,输出的网格坐标会转换回像素坐标
|
|
2252
|
+
* @en If set, input pixel coordinates are converted to grid coordinates, output grid coordinates are converted back to pixel coordinates
|
|
2253
2253
|
*
|
|
2254
2254
|
* @default 1 (no conversion)
|
|
2255
2255
|
*/
|
|
2256
2256
|
cellSize?: number;
|
|
2257
|
+
/**
|
|
2258
|
+
* @zh 是否将输出坐标对齐到单元格中心
|
|
2259
|
+
* @en Whether to align output coordinates to cell center
|
|
2260
|
+
*
|
|
2261
|
+
* @zh 为 true 时,输出坐标会偏移 cellSize * 0.5,指向单元格中心
|
|
2262
|
+
* @en When true, output coordinates are offset by cellSize * 0.5, pointing to cell center
|
|
2263
|
+
*
|
|
2264
|
+
* @zh 默认:当 cellSize > 1 时为 true(像素坐标场景),cellSize = 1 时为 false(网格坐标场景)
|
|
2265
|
+
* @en Default: true when cellSize > 1 (pixel coordinate scenario), false when cellSize = 1 (grid coordinate scenario)
|
|
2266
|
+
*/
|
|
2267
|
+
alignToCenter?: boolean;
|
|
2257
2268
|
}
|
|
2258
2269
|
/**
|
|
2259
2270
|
* @zh 网格寻路器适配器
|
|
@@ -2268,6 +2279,7 @@ declare class GridPathfinderAdapter implements IPathPlanner {
|
|
|
2268
2279
|
private readonly options?;
|
|
2269
2280
|
readonly type: string;
|
|
2270
2281
|
private readonly cellSize;
|
|
2282
|
+
private readonly alignToCenter;
|
|
2271
2283
|
constructor(pathfinder: IPathfinder, map: IPathfindingMap, options?: IPathfindingOptions | undefined, type?: string, config?: IGridPathfinderAdapterConfig);
|
|
2272
2284
|
/**
|
|
2273
2285
|
* @zh 像素坐标转网格坐标
|
|
@@ -2275,8 +2287,11 @@ declare class GridPathfinderAdapter implements IPathPlanner {
|
|
|
2275
2287
|
*/
|
|
2276
2288
|
private toGridCoord;
|
|
2277
2289
|
/**
|
|
2278
|
-
* @zh
|
|
2279
|
-
* @en Convert grid coordinate to pixel coordinate
|
|
2290
|
+
* @zh 网格坐标转像素坐标
|
|
2291
|
+
* @en Convert grid coordinate to pixel coordinate
|
|
2292
|
+
*
|
|
2293
|
+
* @zh 根据 alignToCenter 配置决定是否偏移到单元格中心
|
|
2294
|
+
* @en Offsets to cell center based on alignToCenter configuration
|
|
2280
2295
|
*/
|
|
2281
2296
|
private toPixelCoord;
|
|
2282
2297
|
findPath(start: IVector2, end: IVector2): IPathPlanResult;
|
|
@@ -2365,6 +2380,17 @@ interface IIncrementalGridPathPlannerConfig extends IIncrementalPathfinderConfig
|
|
|
2365
2380
|
* @default 1 (no conversion)
|
|
2366
2381
|
*/
|
|
2367
2382
|
cellSize?: number;
|
|
2383
|
+
/**
|
|
2384
|
+
* @zh 是否将输出坐标对齐到单元格中心
|
|
2385
|
+
* @en Whether to align output coordinates to cell center
|
|
2386
|
+
*
|
|
2387
|
+
* @zh 为 true 时,输出坐标会偏移 cellSize * 0.5,指向单元格中心
|
|
2388
|
+
* @en When true, output coordinates are offset by cellSize * 0.5, pointing to cell center
|
|
2389
|
+
*
|
|
2390
|
+
* @zh 默认:当 cellSize > 1 时为 true(像素坐标场景),cellSize = 1 时为 false(网格坐标场景)
|
|
2391
|
+
* @en Default: true when cellSize > 1 (pixel coordinate scenario), false when cellSize = 1 (grid coordinate scenario)
|
|
2392
|
+
*/
|
|
2393
|
+
alignToCenter?: boolean;
|
|
2368
2394
|
}
|
|
2369
2395
|
/**
|
|
2370
2396
|
* @zh 增量网格寻路器适配器
|
|
@@ -2396,6 +2422,7 @@ declare class IncrementalGridPathPlannerAdapter implements IIncrementalPathPlann
|
|
|
2396
2422
|
private readonly map;
|
|
2397
2423
|
private readonly options?;
|
|
2398
2424
|
private readonly cellSize;
|
|
2425
|
+
private readonly alignToCenter;
|
|
2399
2426
|
/**
|
|
2400
2427
|
* @zh 活跃请求 ID 集合(用于跟踪)
|
|
2401
2428
|
* @en Active request IDs set (for tracking)
|
|
@@ -2413,8 +2440,11 @@ declare class IncrementalGridPathPlannerAdapter implements IIncrementalPathPlann
|
|
|
2413
2440
|
*/
|
|
2414
2441
|
private toGridCoord;
|
|
2415
2442
|
/**
|
|
2416
|
-
* @zh
|
|
2417
|
-
* @en Convert grid coordinate to pixel coordinate
|
|
2443
|
+
* @zh 网格坐标转像素坐标
|
|
2444
|
+
* @en Convert grid coordinate to pixel coordinate
|
|
2445
|
+
*
|
|
2446
|
+
* @zh 根据 alignToCenter 配置决定是否偏移到单元格中心
|
|
2447
|
+
* @en Offsets to cell center based on alignToCenter configuration
|
|
2418
2448
|
*/
|
|
2419
2449
|
private toPixelCoord;
|
|
2420
2450
|
findPath(start: IVector2, end: IVector2, options?: IPathPlanOptions): IPathPlanResult;
|
|
@@ -2896,11 +2896,17 @@ var _GridPathfinderAdapter = class _GridPathfinderAdapter {
|
|
|
2896
2896
|
__publicField(this, "options");
|
|
2897
2897
|
__publicField(this, "type");
|
|
2898
2898
|
__publicField(this, "cellSize");
|
|
2899
|
+
__publicField(this, "alignToCenter");
|
|
2899
2900
|
this.pathfinder = pathfinder;
|
|
2900
2901
|
this.map = map;
|
|
2901
2902
|
this.options = options;
|
|
2902
2903
|
this.type = type;
|
|
2903
|
-
|
|
2904
|
+
const cellSize = config?.cellSize ?? 1;
|
|
2905
|
+
if (cellSize <= 0 || !Number.isFinite(cellSize)) {
|
|
2906
|
+
throw new Error(`cellSize must be a positive finite number, got: ${cellSize}`);
|
|
2907
|
+
}
|
|
2908
|
+
this.cellSize = cellSize;
|
|
2909
|
+
this.alignToCenter = config?.alignToCenter ?? cellSize > 1;
|
|
2904
2910
|
}
|
|
2905
2911
|
/**
|
|
2906
2912
|
* @zh 像素坐标转网格坐标
|
|
@@ -2910,11 +2916,15 @@ var _GridPathfinderAdapter = class _GridPathfinderAdapter {
|
|
|
2910
2916
|
return Math.floor(pixel / this.cellSize);
|
|
2911
2917
|
}
|
|
2912
2918
|
/**
|
|
2913
|
-
* @zh
|
|
2914
|
-
* @en Convert grid coordinate to pixel coordinate
|
|
2919
|
+
* @zh 网格坐标转像素坐标
|
|
2920
|
+
* @en Convert grid coordinate to pixel coordinate
|
|
2921
|
+
*
|
|
2922
|
+
* @zh 根据 alignToCenter 配置决定是否偏移到单元格中心
|
|
2923
|
+
* @en Offsets to cell center based on alignToCenter configuration
|
|
2915
2924
|
*/
|
|
2916
2925
|
toPixelCoord(grid) {
|
|
2917
|
-
|
|
2926
|
+
const base = grid * this.cellSize;
|
|
2927
|
+
return this.alignToCenter ? base + this.cellSize * 0.5 : base;
|
|
2918
2928
|
}
|
|
2919
2929
|
findPath(start, end) {
|
|
2920
2930
|
const startGridX = this.toGridCoord(start.x);
|
|
@@ -3011,6 +3021,7 @@ var _IncrementalGridPathPlannerAdapter = class _IncrementalGridPathPlannerAdapte
|
|
|
3011
3021
|
__publicField(this, "map");
|
|
3012
3022
|
__publicField(this, "options");
|
|
3013
3023
|
__publicField(this, "cellSize");
|
|
3024
|
+
__publicField(this, "alignToCenter");
|
|
3014
3025
|
/**
|
|
3015
3026
|
* @zh 活跃请求 ID 集合(用于跟踪)
|
|
3016
3027
|
* @en Active request IDs set (for tracking)
|
|
@@ -3023,7 +3034,12 @@ var _IncrementalGridPathPlannerAdapter = class _IncrementalGridPathPlannerAdapte
|
|
|
3023
3034
|
__publicField(this, "requestTotalNodes", /* @__PURE__ */ new Map());
|
|
3024
3035
|
this.map = map;
|
|
3025
3036
|
this.options = options;
|
|
3026
|
-
|
|
3037
|
+
const cellSize = config?.cellSize ?? 1;
|
|
3038
|
+
if (cellSize <= 0 || !Number.isFinite(cellSize)) {
|
|
3039
|
+
throw new Error(`cellSize must be a positive finite number, got: ${cellSize}`);
|
|
3040
|
+
}
|
|
3041
|
+
this.cellSize = cellSize;
|
|
3042
|
+
this.alignToCenter = config?.alignToCenter ?? cellSize > 1;
|
|
3027
3043
|
this.pathfinder = new IncrementalAStarPathfinder(map, config);
|
|
3028
3044
|
}
|
|
3029
3045
|
/**
|
|
@@ -3034,11 +3050,15 @@ var _IncrementalGridPathPlannerAdapter = class _IncrementalGridPathPlannerAdapte
|
|
|
3034
3050
|
return Math.floor(pixel / this.cellSize);
|
|
3035
3051
|
}
|
|
3036
3052
|
/**
|
|
3037
|
-
* @zh
|
|
3038
|
-
* @en Convert grid coordinate to pixel coordinate
|
|
3053
|
+
* @zh 网格坐标转像素坐标
|
|
3054
|
+
* @en Convert grid coordinate to pixel coordinate
|
|
3055
|
+
*
|
|
3056
|
+
* @zh 根据 alignToCenter 配置决定是否偏移到单元格中心
|
|
3057
|
+
* @en Offsets to cell center based on alignToCenter configuration
|
|
3039
3058
|
*/
|
|
3040
3059
|
toPixelCoord(grid) {
|
|
3041
|
-
|
|
3060
|
+
const base = grid * this.cellSize;
|
|
3061
|
+
return this.alignToCenter ? base + this.cellSize * 0.5 : base;
|
|
3042
3062
|
}
|
|
3043
3063
|
// =========================================================================
|
|
3044
3064
|
// IPathPlanner 基础接口 | IPathPlanner Base Interface
|
|
@@ -3808,4 +3828,4 @@ export {
|
|
|
3808
3828
|
FlowController,
|
|
3809
3829
|
createFlowController
|
|
3810
3830
|
};
|
|
3811
|
-
//# sourceMappingURL=chunk-
|
|
3831
|
+
//# sourceMappingURL=chunk-ZYGBA7VK.js.map
|