voxljs 0.1.0 → 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.
- package/dist/audio/SpatialAudioEngine.d.ts +10 -0
- package/dist/audio/SpatialAudioEngine.js +80 -0
- package/dist/audio/SpatialAudioEngine.js.map +1 -1
- package/dist/core/VoxelEngine.d.ts +99 -0
- package/dist/core/VoxelEngine.js +181 -0
- package/dist/core/VoxelEngine.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/input/InputManager.d.ts +45 -6
- package/dist/input/InputManager.js +178 -31
- package/dist/input/InputManager.js.map +1 -1
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/input/index.js.map +1 -1
- package/dist/materials/Material.d.ts +6 -0
- package/dist/materials/Material.js +12 -0
- package/dist/materials/Material.js.map +1 -1
- package/dist/perf/EntityTickScheduler.d.ts +71 -0
- package/dist/perf/EntityTickScheduler.js +202 -0
- package/dist/perf/EntityTickScheduler.js.map +1 -0
- package/dist/perf/SpatialEntityGrid.d.ts +47 -0
- package/dist/perf/SpatialEntityGrid.js +200 -0
- package/dist/perf/SpatialEntityGrid.js.map +1 -0
- package/dist/perf/index.d.ts +2 -0
- package/dist/perf/index.js +2 -0
- package/dist/perf/index.js.map +1 -1
- package/dist/physics/VoxelPhysicsWorld.d.ts +308 -0
- package/dist/physics/VoxelPhysicsWorld.js +1020 -0
- package/dist/physics/VoxelPhysicsWorld.js.map +1 -0
- package/dist/physics/index.d.ts +1 -0
- package/dist/physics/index.js +1 -0
- package/dist/physics/index.js.map +1 -1
- package/dist/renderers/WebGLRenderer.js +1 -0
- package/dist/renderers/WebGLRenderer.js.map +1 -1
- package/dist/renderers/webgl/WebGLProgram.js +18 -19
- package/dist/renderers/webgl/WebGLProgram.js.map +1 -1
- package/dist/renderers/webgl/WebGLState.d.ts +17 -0
- package/dist/renderers/webgl/WebGLState.js +115 -1
- package/dist/renderers/webgl/WebGLState.js.map +1 -1
- package/dist/voxel/GrassFieldSystem.d.ts +186 -0
- package/dist/voxel/GrassFieldSystem.js +723 -0
- package/dist/voxel/GrassFieldSystem.js.map +1 -0
- package/dist/voxel/SilhouetteLightVolumes.d.ts +13 -2
- package/dist/voxel/SilhouetteLightVolumes.js +384 -78
- package/dist/voxel/SilhouetteLightVolumes.js.map +1 -1
- package/dist/voxel/VoxImporter.d.ts +32 -0
- package/dist/voxel/VoxImporter.js +228 -0
- package/dist/voxel/VoxImporter.js.map +1 -1
- package/dist/voxel/VoxelBrushes.d.ts +110 -0
- package/dist/voxel/VoxelBrushes.js +248 -0
- package/dist/voxel/VoxelBrushes.js.map +1 -0
- package/dist/voxel/VoxelPotatoShader.d.ts +8 -2
- package/dist/voxel/VoxelPotatoShader.js +68 -4
- package/dist/voxel/VoxelPotatoShader.js.map +1 -1
- package/dist/voxel/VoxelSilhouetteShadows.d.ts +69 -11
- package/dist/voxel/VoxelSilhouetteShadows.js +653 -32
- package/dist/voxel/VoxelSilhouetteShadows.js.map +1 -1
- package/dist/voxel/index.d.ts +4 -2
- package/dist/voxel/index.js +4 -2
- package/dist/voxel/index.js.map +1 -1
- package/dist/world/VoxelMobAISystem.d.ts +183 -0
- package/dist/world/VoxelMobAISystem.js +492 -0
- package/dist/world/VoxelMobAISystem.js.map +1 -0
- package/dist/world/index.d.ts +1 -0
- package/dist/world/index.js +1 -0
- package/dist/world/index.js.map +1 -1
- package/llms.txt +301 -0
- package/package.json +2 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Spatial & Budget-Guarded Entity/AI Tick Scheduler for `voxljs`.
|
|
3
|
+
*
|
|
4
|
+
* Automatically throttles callbacks by cadence (`interval`), puts distant entities to sleep
|
|
5
|
+
* beyond `sleepDistance`, and enforces per-frame execution count & millisecond budgets so
|
|
6
|
+
* runaway game scripts never stall the main render loop.
|
|
7
|
+
*/
|
|
8
|
+
export class EntityTickScheduler {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this._entries = new Map();
|
|
11
|
+
this._ordered = [];
|
|
12
|
+
this._orderDirty = false;
|
|
13
|
+
this._nextId = 1;
|
|
14
|
+
this._roundRobinCursor = 0;
|
|
15
|
+
this._elapsed = 0;
|
|
16
|
+
this._runCounter = 0;
|
|
17
|
+
this.lastStats = {
|
|
18
|
+
totalRegistered: 0,
|
|
19
|
+
executed: 0,
|
|
20
|
+
sleeping: 0,
|
|
21
|
+
throttledByInterval: 0,
|
|
22
|
+
deferredByBudget: 0,
|
|
23
|
+
elapsedMs: 0,
|
|
24
|
+
};
|
|
25
|
+
this.maxTicksPerFrame = Math.max(1, options.maxTicksPerFrame ?? 256);
|
|
26
|
+
this.maxBudgetMs = Math.max(0, options.maxBudgetMs ?? 4.0);
|
|
27
|
+
this._nowMs =
|
|
28
|
+
options.nowMs ??
|
|
29
|
+
(() => (typeof performance !== 'undefined' ? performance.now() : Date.now()));
|
|
30
|
+
}
|
|
31
|
+
get size() {
|
|
32
|
+
return this._entries.size;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Registers a managed entity/AI tick callback and returns an idempotent unregister handle.
|
|
36
|
+
*/
|
|
37
|
+
registerTick(fn, options = {}) {
|
|
38
|
+
const id = options.id ?? `tick_${this._nextId++}`;
|
|
39
|
+
const sleepDist = Math.max(0, options.sleepDistance ?? 0);
|
|
40
|
+
const hysteresis = options.wakeHysteresis ?? sleepDist * 0.1;
|
|
41
|
+
const wakeDist = Math.max(0, sleepDist - hysteresis);
|
|
42
|
+
const entry = {
|
|
43
|
+
id,
|
|
44
|
+
fn,
|
|
45
|
+
interval: Math.max(0, options.interval ?? 0),
|
|
46
|
+
sleepDistance: sleepDist,
|
|
47
|
+
sleepDistanceSq: sleepDist * sleepDist,
|
|
48
|
+
wakeDistanceSq: wakeDist * wakeDist,
|
|
49
|
+
getPosition: options.getPosition ?? null,
|
|
50
|
+
priority: options.priority ?? 0,
|
|
51
|
+
enabled: options.enabled !== false,
|
|
52
|
+
accumulatedDt: 0,
|
|
53
|
+
sleeping: false,
|
|
54
|
+
lastRunOrder: 0,
|
|
55
|
+
};
|
|
56
|
+
this._entries.set(id, entry);
|
|
57
|
+
this._orderDirty = true;
|
|
58
|
+
return () => {
|
|
59
|
+
this.unregisterTick(id);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
unregisterTick(id) {
|
|
63
|
+
const removed = this._entries.delete(id);
|
|
64
|
+
if (removed) {
|
|
65
|
+
this._orderDirty = true;
|
|
66
|
+
}
|
|
67
|
+
return removed;
|
|
68
|
+
}
|
|
69
|
+
setTickEnabled(id, enabled) {
|
|
70
|
+
const entry = this._entries.get(id);
|
|
71
|
+
if (!entry)
|
|
72
|
+
return false;
|
|
73
|
+
entry.enabled = enabled;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
isSleeping(id) {
|
|
77
|
+
return this._entries.get(id)?.sleeping ?? false;
|
|
78
|
+
}
|
|
79
|
+
clear() {
|
|
80
|
+
this._entries.clear();
|
|
81
|
+
this._ordered.length = 0;
|
|
82
|
+
this._orderDirty = false;
|
|
83
|
+
this._roundRobinCursor = 0;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Steps scheduled entity callbacks with spatial sleep culling and frame-budget guards.
|
|
87
|
+
*
|
|
88
|
+
* @param dt Clamped frame delta in seconds
|
|
89
|
+
* @param referencePos Optional camera/player world position used for `sleepDistance` checks
|
|
90
|
+
*/
|
|
91
|
+
update(dt, referencePos) {
|
|
92
|
+
if (!Number.isFinite(dt) || dt <= 0) {
|
|
93
|
+
this.lastStats.totalRegistered = this._entries.size;
|
|
94
|
+
this.lastStats.executed = 0;
|
|
95
|
+
this.lastStats.sleeping = 0;
|
|
96
|
+
this.lastStats.throttledByInterval = 0;
|
|
97
|
+
this.lastStats.deferredByBudget = 0;
|
|
98
|
+
this.lastStats.elapsedMs = 0;
|
|
99
|
+
return this.lastStats;
|
|
100
|
+
}
|
|
101
|
+
this._elapsed += dt;
|
|
102
|
+
if (this._orderDirty) {
|
|
103
|
+
this._ordered.length = 0;
|
|
104
|
+
for (const entry of this._entries.values()) {
|
|
105
|
+
this._ordered.push(entry);
|
|
106
|
+
}
|
|
107
|
+
this._ordered.sort((a, b) => b.priority - a.priority);
|
|
108
|
+
this._orderDirty = false;
|
|
109
|
+
}
|
|
110
|
+
const total = this._ordered.length;
|
|
111
|
+
const startMs = this._nowMs();
|
|
112
|
+
const hasRef = referencePos !== null && referencePos !== undefined;
|
|
113
|
+
const rx = hasRef ? referencePos.x : 0;
|
|
114
|
+
const ry = hasRef ? referencePos.y : 0;
|
|
115
|
+
const rz = hasRef ? referencePos.z : 0;
|
|
116
|
+
let executed = 0;
|
|
117
|
+
let sleeping = 0;
|
|
118
|
+
let throttledByInterval = 0;
|
|
119
|
+
let deferredByBudget = 0;
|
|
120
|
+
// Accumulate dt for all enabled active entries first, and update spatial sleep state
|
|
121
|
+
for (let i = 0; i < total; i++) {
|
|
122
|
+
const e = this._ordered[i];
|
|
123
|
+
if (!e.enabled)
|
|
124
|
+
continue;
|
|
125
|
+
if (hasRef && e.sleepDistance > 0 && e.getPosition) {
|
|
126
|
+
const pos = e.getPosition();
|
|
127
|
+
if (pos) {
|
|
128
|
+
const dx = pos.x - rx;
|
|
129
|
+
const dy = pos.y - ry;
|
|
130
|
+
const dz = pos.z - rz;
|
|
131
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
132
|
+
if (e.sleeping) {
|
|
133
|
+
if (d2 <= e.wakeDistanceSq) {
|
|
134
|
+
e.sleeping = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (d2 > e.sleepDistanceSq) {
|
|
138
|
+
e.sleeping = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
e.sleeping = false;
|
|
144
|
+
}
|
|
145
|
+
if (e.sleeping) {
|
|
146
|
+
sleeping++;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
e.accumulatedDt += dt;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Partition high-priority prefix (priority > 0) from normal/low-priority round-robin suffix
|
|
153
|
+
let normalStart = 0;
|
|
154
|
+
while (normalStart < total && this._ordered[normalStart].priority > 0) {
|
|
155
|
+
normalStart++;
|
|
156
|
+
}
|
|
157
|
+
const normalCount = total - normalStart;
|
|
158
|
+
const normalOffset = normalCount > 0 ? this._roundRobinCursor % normalCount : 0;
|
|
159
|
+
let budgetExceeded = false;
|
|
160
|
+
let normalExecuted = 0;
|
|
161
|
+
for (let pass = 0; pass < total; pass++) {
|
|
162
|
+
const idx = pass < normalStart
|
|
163
|
+
? pass
|
|
164
|
+
: normalStart + ((normalOffset + (pass - normalStart)) % normalCount);
|
|
165
|
+
const e = this._ordered[idx];
|
|
166
|
+
if (!e.enabled || e.sleeping)
|
|
167
|
+
continue;
|
|
168
|
+
if (e.lastRunOrder === this._runCounter + 1)
|
|
169
|
+
continue;
|
|
170
|
+
if (e.interval > 0 && e.accumulatedDt + 1e-9 < e.interval) {
|
|
171
|
+
throttledByInterval++;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (budgetExceeded ||
|
|
175
|
+
executed >= this.maxTicksPerFrame ||
|
|
176
|
+
(this.maxBudgetMs > 0 && executed > 0 && this._nowMs() - startMs >= this.maxBudgetMs)) {
|
|
177
|
+
budgetExceeded = true;
|
|
178
|
+
deferredByBudget++;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const stepDt = e.accumulatedDt;
|
|
182
|
+
e.accumulatedDt = 0;
|
|
183
|
+
e.lastRunOrder = this._runCounter + 1;
|
|
184
|
+
e.fn(stepDt, this._elapsed);
|
|
185
|
+
executed++;
|
|
186
|
+
if (pass >= normalStart)
|
|
187
|
+
normalExecuted++;
|
|
188
|
+
}
|
|
189
|
+
this._runCounter++;
|
|
190
|
+
if (normalCount > 0) {
|
|
191
|
+
this._roundRobinCursor = (normalOffset + Math.max(1, normalExecuted)) % normalCount;
|
|
192
|
+
}
|
|
193
|
+
this.lastStats.totalRegistered = total;
|
|
194
|
+
this.lastStats.executed = executed;
|
|
195
|
+
this.lastStats.sleeping = sleeping;
|
|
196
|
+
this.lastStats.throttledByInterval = throttledByInterval;
|
|
197
|
+
this.lastStats.deferredByBudget = deferredByBudget;
|
|
198
|
+
this.lastStats.elapsedMs = Math.max(0, this._nowMs() - startMs);
|
|
199
|
+
return this.lastStats;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=EntityTickScheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityTickScheduler.js","sourceRoot":"","sources":["../../src/engine/perf/EntityTickScheduler.ts"],"names":[],"mappings":"AAsDA;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAsB9B,YAAY,OAAO,GAA+B,EAAE;QAlBnC,aAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;QACxC,aAAQ,GAAgB,EAAE,CAAC;QACpC,gBAAW,GAAG,KAAK,CAAC;QACpB,YAAO,GAAG,CAAC,CAAC;QACZ,sBAAiB,GAAG,CAAC,CAAC;QACtB,aAAQ,GAAG,CAAC,CAAC;QACb,gBAAW,GAAG,CAAC,CAAC;QAGR,cAAS,GAAoB;YAC3C,eAAe,EAAE,CAAC;YAClB,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,CAAC;YACX,mBAAmB,EAAE,CAAC;YACtB,gBAAgB,EAAE,CAAC;YACnB,SAAS,EAAE,CAAC;SACb,CAAC;QAGA,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,IAAI,GAAG,CAAC,CAAC;QACrE,IAAI,CAAC,WAAW,GA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,GAAG,gBAAgB,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Vector3Like } from '../math/index.js';
|
|
2
|
+
export interface SpatialEntityRecord<T = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
data: T;
|
|
8
|
+
}
|
|
9
|
+
export interface SpatialEntityGridOptions {
|
|
10
|
+
/** Uniform 3D hash cell size in world meters (default: 8). */
|
|
11
|
+
cellSize?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* O(1) Uniform 3D Spatial Hash Grid for fast broadphase entity, enemy, trigger, and pickup queries.
|
|
15
|
+
* Supports zero-allocation radius/box queries when callers pass a reusable output array.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SpatialEntityGrid<T = unknown> {
|
|
18
|
+
readonly cellSize: number;
|
|
19
|
+
private readonly _invCellSize;
|
|
20
|
+
private readonly _cells;
|
|
21
|
+
private readonly _records;
|
|
22
|
+
private readonly _recordCellKey;
|
|
23
|
+
constructor(options?: SpatialEntityGridOptions);
|
|
24
|
+
get size(): number;
|
|
25
|
+
private _cellKey;
|
|
26
|
+
/**
|
|
27
|
+
* Inserts or updates an entity's world position in O(1) time.
|
|
28
|
+
*/
|
|
29
|
+
upsert(id: string, x: number, y: number, z: number, data: T): SpatialEntityRecord<T>;
|
|
30
|
+
upsertAt(id: string, pos: Vector3Like, data: T): SpatialEntityRecord<T>;
|
|
31
|
+
get(id: string): SpatialEntityRecord<T> | undefined;
|
|
32
|
+
has(id: string): boolean;
|
|
33
|
+
remove(id: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns all entities within Euclidean `radius` of `(x, y, z)`.
|
|
36
|
+
*/
|
|
37
|
+
queryRadius(x: number, y: number, z: number, radius: number, out?: SpatialEntityRecord<T>[]): SpatialEntityRecord<T>[];
|
|
38
|
+
/**
|
|
39
|
+
* Returns all entities inside the axis-aligned box `[minX..maxX] x [minY..maxY] x [minZ..maxZ]`.
|
|
40
|
+
*/
|
|
41
|
+
queryBox(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number, out?: SpatialEntityRecord<T>[]): SpatialEntityRecord<T>[];
|
|
42
|
+
/**
|
|
43
|
+
* Finds the single nearest entity within `maxRadius`, optionally excluding an ID (e.g. self).
|
|
44
|
+
*/
|
|
45
|
+
nearest(x: number, y: number, z: number, maxRadius: number, excludeId?: string): SpatialEntityRecord<T> | null;
|
|
46
|
+
clear(): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* O(1) Uniform 3D Spatial Hash Grid for fast broadphase entity, enemy, trigger, and pickup queries.
|
|
3
|
+
* Supports zero-allocation radius/box queries when callers pass a reusable output array.
|
|
4
|
+
*/
|
|
5
|
+
export class SpatialEntityGrid {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this._cells = new Map();
|
|
8
|
+
this._records = new Map();
|
|
9
|
+
this._recordCellKey = new Map();
|
|
10
|
+
this.cellSize = Math.max(0.25, options.cellSize ?? 8);
|
|
11
|
+
this._invCellSize = 1 / this.cellSize;
|
|
12
|
+
}
|
|
13
|
+
get size() {
|
|
14
|
+
return this._records.size;
|
|
15
|
+
}
|
|
16
|
+
_cellKey(cx, cy, cz) {
|
|
17
|
+
return `${cx},${cy},${cz}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inserts or updates an entity's world position in O(1) time.
|
|
21
|
+
*/
|
|
22
|
+
upsert(id, x, y, z, data) {
|
|
23
|
+
const cx = Math.floor(x * this._invCellSize);
|
|
24
|
+
const cy = Math.floor(y * this._invCellSize);
|
|
25
|
+
const cz = Math.floor(z * this._invCellSize);
|
|
26
|
+
const nextKey = this._cellKey(cx, cy, cz);
|
|
27
|
+
let record = this._records.get(id);
|
|
28
|
+
if (record) {
|
|
29
|
+
const prevKey = this._recordCellKey.get(id);
|
|
30
|
+
record.x = x;
|
|
31
|
+
record.y = y;
|
|
32
|
+
record.z = z;
|
|
33
|
+
record.data = data;
|
|
34
|
+
if (prevKey !== nextKey) {
|
|
35
|
+
if (prevKey !== undefined) {
|
|
36
|
+
const prevBucket = this._cells.get(prevKey);
|
|
37
|
+
if (prevBucket) {
|
|
38
|
+
prevBucket.delete(record);
|
|
39
|
+
if (prevBucket.size === 0)
|
|
40
|
+
this._cells.delete(prevKey);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let nextBucket = this._cells.get(nextKey);
|
|
44
|
+
if (!nextBucket) {
|
|
45
|
+
nextBucket = new Set();
|
|
46
|
+
this._cells.set(nextKey, nextBucket);
|
|
47
|
+
}
|
|
48
|
+
nextBucket.add(record);
|
|
49
|
+
this._recordCellKey.set(id, nextKey);
|
|
50
|
+
}
|
|
51
|
+
return record;
|
|
52
|
+
}
|
|
53
|
+
record = { id, x, y, z, data };
|
|
54
|
+
this._records.set(id, record);
|
|
55
|
+
let bucket = this._cells.get(nextKey);
|
|
56
|
+
if (!bucket) {
|
|
57
|
+
bucket = new Set();
|
|
58
|
+
this._cells.set(nextKey, bucket);
|
|
59
|
+
}
|
|
60
|
+
bucket.add(record);
|
|
61
|
+
this._recordCellKey.set(id, nextKey);
|
|
62
|
+
return record;
|
|
63
|
+
}
|
|
64
|
+
upsertAt(id, pos, data) {
|
|
65
|
+
return this.upsert(id, pos.x, pos.y, pos.z, data);
|
|
66
|
+
}
|
|
67
|
+
get(id) {
|
|
68
|
+
return this._records.get(id);
|
|
69
|
+
}
|
|
70
|
+
has(id) {
|
|
71
|
+
return this._records.has(id);
|
|
72
|
+
}
|
|
73
|
+
remove(id) {
|
|
74
|
+
const record = this._records.get(id);
|
|
75
|
+
if (!record)
|
|
76
|
+
return false;
|
|
77
|
+
const key = this._recordCellKey.get(id);
|
|
78
|
+
if (key !== undefined) {
|
|
79
|
+
const bucket = this._cells.get(key);
|
|
80
|
+
if (bucket) {
|
|
81
|
+
bucket.delete(record);
|
|
82
|
+
if (bucket.size === 0)
|
|
83
|
+
this._cells.delete(key);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
this._records.delete(id);
|
|
87
|
+
this._recordCellKey.delete(id);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns all entities within Euclidean `radius` of `(x, y, z)`.
|
|
92
|
+
*/
|
|
93
|
+
queryRadius(x, y, z, radius, out = []) {
|
|
94
|
+
out.length = 0;
|
|
95
|
+
if (radius < 0 || this._records.size === 0)
|
|
96
|
+
return out;
|
|
97
|
+
const r2 = radius * radius;
|
|
98
|
+
const minCx = Math.floor((x - radius) * this._invCellSize);
|
|
99
|
+
const maxCx = Math.floor((x + radius) * this._invCellSize);
|
|
100
|
+
const minCy = Math.floor((y - radius) * this._invCellSize);
|
|
101
|
+
const maxCy = Math.floor((y + radius) * this._invCellSize);
|
|
102
|
+
const minCz = Math.floor((z - radius) * this._invCellSize);
|
|
103
|
+
const maxCz = Math.floor((z + radius) * this._invCellSize);
|
|
104
|
+
for (let cy = minCy; cy <= maxCy; cy++) {
|
|
105
|
+
for (let cz = minCz; cz <= maxCz; cz++) {
|
|
106
|
+
for (let cx = minCx; cx <= maxCx; cx++) {
|
|
107
|
+
const bucket = this._cells.get(this._cellKey(cx, cy, cz));
|
|
108
|
+
if (!bucket)
|
|
109
|
+
continue;
|
|
110
|
+
for (const rec of bucket) {
|
|
111
|
+
const dx = rec.x - x;
|
|
112
|
+
const dy = rec.y - y;
|
|
113
|
+
const dz = rec.z - z;
|
|
114
|
+
if (dx * dx + dy * dy + dz * dz <= r2) {
|
|
115
|
+
out.push(rec);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Returns all entities inside the axis-aligned box `[minX..maxX] x [minY..maxY] x [minZ..maxZ]`.
|
|
125
|
+
*/
|
|
126
|
+
queryBox(minX, minY, minZ, maxX, maxY, maxZ, out = []) {
|
|
127
|
+
out.length = 0;
|
|
128
|
+
if (this._records.size === 0)
|
|
129
|
+
return out;
|
|
130
|
+
const minCx = Math.floor(minX * this._invCellSize);
|
|
131
|
+
const maxCx = Math.floor(maxX * this._invCellSize);
|
|
132
|
+
const minCy = Math.floor(minY * this._invCellSize);
|
|
133
|
+
const maxCy = Math.floor(maxY * this._invCellSize);
|
|
134
|
+
const minCz = Math.floor(minZ * this._invCellSize);
|
|
135
|
+
const maxCz = Math.floor(maxZ * this._invCellSize);
|
|
136
|
+
for (let cy = minCy; cy <= maxCy; cy++) {
|
|
137
|
+
for (let cz = minCz; cz <= maxCz; cz++) {
|
|
138
|
+
for (let cx = minCx; cx <= maxCx; cx++) {
|
|
139
|
+
const bucket = this._cells.get(this._cellKey(cx, cy, cz));
|
|
140
|
+
if (!bucket)
|
|
141
|
+
continue;
|
|
142
|
+
for (const rec of bucket) {
|
|
143
|
+
if (rec.x >= minX &&
|
|
144
|
+
rec.x <= maxX &&
|
|
145
|
+
rec.y >= minY &&
|
|
146
|
+
rec.y <= maxY &&
|
|
147
|
+
rec.z >= minZ &&
|
|
148
|
+
rec.z <= maxZ) {
|
|
149
|
+
out.push(rec);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Finds the single nearest entity within `maxRadius`, optionally excluding an ID (e.g. self).
|
|
159
|
+
*/
|
|
160
|
+
nearest(x, y, z, maxRadius, excludeId) {
|
|
161
|
+
if (maxRadius < 0 || this._records.size === 0)
|
|
162
|
+
return null;
|
|
163
|
+
let best = null;
|
|
164
|
+
let bestD2 = maxRadius * maxRadius;
|
|
165
|
+
const minCx = Math.floor((x - maxRadius) * this._invCellSize);
|
|
166
|
+
const maxCx = Math.floor((x + maxRadius) * this._invCellSize);
|
|
167
|
+
const minCy = Math.floor((y - maxRadius) * this._invCellSize);
|
|
168
|
+
const maxCy = Math.floor((y + maxRadius) * this._invCellSize);
|
|
169
|
+
const minCz = Math.floor((z - maxRadius) * this._invCellSize);
|
|
170
|
+
const maxCz = Math.floor((z + maxRadius) * this._invCellSize);
|
|
171
|
+
for (let cy = minCy; cy <= maxCy; cy++) {
|
|
172
|
+
for (let cz = minCz; cz <= maxCz; cz++) {
|
|
173
|
+
for (let cx = minCx; cx <= maxCx; cx++) {
|
|
174
|
+
const bucket = this._cells.get(this._cellKey(cx, cy, cz));
|
|
175
|
+
if (!bucket)
|
|
176
|
+
continue;
|
|
177
|
+
for (const rec of bucket) {
|
|
178
|
+
if (excludeId !== undefined && rec.id === excludeId)
|
|
179
|
+
continue;
|
|
180
|
+
const dx = rec.x - x;
|
|
181
|
+
const dy = rec.y - y;
|
|
182
|
+
const dz = rec.z - z;
|
|
183
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
184
|
+
if (d2 <= bestD2) {
|
|
185
|
+
bestD2 = d2;
|
|
186
|
+
best = rec;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return best;
|
|
193
|
+
}
|
|
194
|
+
clear() {
|
|
195
|
+
this._cells.clear();
|
|
196
|
+
this._records.clear();
|
|
197
|
+
this._recordCellKey.clear();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=SpatialEntityGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpatialEntityGrid.js","sourceRoot":"","sources":["../../src/engine/perf/SpatialEntityGrid.ts"],"names":[],"mappings":"A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AE,EAAE,IAAI,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC;oBACvC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;oBAC1D,IAAI,CAAC,MAAM;wBAAE,SAAS;oBACtB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;wBACzB,IAAI,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS;4BAAE,SAAS;wBAC9D,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;wBACrB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;wBACrB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;wBACrB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;wBACvC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;4BACjB,MAAM,GAAG,EAAE,CAAC;4BACZ,IAAI,GAAG,GAAG,CAAC;wBACb,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/perf/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { PerfProfiler, perfProfiler, type PerfSnapshot } from './PerfProfiler.js';
|
|
2
2
|
export { DynamicResolutionScaler, type DynamicResolutionScalerOptions, type DynamicResolutionUpdateResult, } from './DynamicResolutionScaler.js';
|
|
3
|
+
export { EntityTickScheduler, type EntityTickCallback, type EntityTickSchedulerOptions, type EntityTickStats, type RegisterTickOptions, } from './EntityTickScheduler.js';
|
|
4
|
+
export { SpatialEntityGrid, type SpatialEntityGridOptions, type SpatialEntityRecord, } from './SpatialEntityGrid.js';
|
package/dist/perf/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { PerfProfiler, perfProfiler } from './PerfProfiler.js';
|
|
2
2
|
export { DynamicResolutionScaler, } from './DynamicResolutionScaler.js';
|
|
3
|
+
export { EntityTickScheduler, } from './EntityTickScheduler.js';
|
|
4
|
+
export { SpatialEntityGrid, } from './SpatialEntityGrid.js';
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
package/dist/perf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/perf/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AAClF,OAAO,EACL,uBAAuB,GAGxB,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/perf/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AAClF,OAAO,EACL,uBAAuB,GAGxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,mBAAmB,GAKpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,GAGlB,MAAM,wBAAwB,CAAC"}
|