@woosh/meep-engine 2.119.17 → 2.119.19
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/README.md +2 -2
- package/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.d.ts +2 -6
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +7 -8
- package/src/core/binary/BitSet.d.ts.map +1 -1
- package/src/core/binary/BitSet.js +2 -3
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +8 -0
- package/src/core/cache/FrequencySketch.js +1 -1
- package/src/core/codegen/LineBuilder.d.ts +7 -1
- package/src/core/codegen/LineBuilder.d.ts.map +1 -1
- package/src/core/codegen/LineBuilder.js +10 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -0
- package/src/core/geom/3d/Ray3.d.ts +12 -0
- package/src/core/geom/3d/Ray3.d.ts.map +1 -1
- package/src/core/geom/3d/Ray3.js +32 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +17 -7
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts +2 -2
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.js +11 -11
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +2 -1
- package/src/core/geom/3d/tetrahedra/bvh/tetrahedral_mesh_to_bvh.d.ts +8 -0
- package/src/core/geom/3d/tetrahedra/bvh/tetrahedral_mesh_to_bvh.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/bvh/tetrahedral_mesh_to_bvh.js +36 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_compute_tet_aabb3.d.ts +10 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_compute_tet_aabb3.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_compute_tet_aabb3.js +49 -0
- package/src/core/geom/random/randomPointInCircle.d.ts +3 -2
- package/src/core/geom/random/randomPointInCircle.d.ts.map +1 -1
- package/src/core/geom/random/randomPointInCircle.js +6 -3
- package/src/core/geom/vec2/v2_magnitude.d.ts +3 -5
- package/src/core/geom/vec2/v2_magnitude.d.ts.map +1 -1
- package/src/core/geom/vec2/v2_magnitude.js +3 -8
- package/src/core/graph/v2/NodeContainer.d.ts.map +1 -1
- package/src/core/graph/v2/NodeContainer.js +3 -9
- package/src/core/lang/reactive/AbstractCachingParser.d.ts +8 -5
- package/src/core/lang/reactive/AbstractCachingParser.d.ts.map +1 -1
- package/src/core/lang/reactive/AbstractCachingParser.js +19 -24
- package/src/core/lang/reactive/pegjs/ReactivePegParser.d.ts +2 -1
- package/src/core/lang/reactive/pegjs/ReactivePegParser.d.ts.map +1 -1
- package/src/core/localization/Localization.js +1 -1
- package/src/engine/achievements/AchievementManager.d.ts +1 -1
- package/src/engine/achievements/AchievementManager.d.ts.map +1 -1
- package/src/engine/achievements/AchievementManager.js +11 -28
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +5 -2
- package/src/engine/ecs/EntityReference.d.ts +6 -0
- package/src/engine/ecs/EntityReference.d.ts.map +1 -1
- package/src/engine/ecs/EntityReference.js +16 -1
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.d.ts +10 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureTileLoader.js +39 -19
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +8 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +8 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +2 -1
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +17 -5
- package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/DieBehavior.js +2 -7
- package/src/engine/intelligence/behavior/ecs/SendEventBehavior.d.ts +4 -0
- package/src/engine/intelligence/behavior/ecs/SendEventBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/SendEventBehavior.js +8 -7
- package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +21 -22
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts +0 -2
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts.map +0 -1
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.js +0 -1
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts +0 -9
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts.map +0 -1
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.js +0 -31
- package/src/core/geom/2d/lt-grid/LooseTightGrid.d.ts +0 -55
- package/src/core/geom/2d/lt-grid/LooseTightGrid.d.ts.map +0 -1
- package/src/core/geom/2d/lt-grid/LooseTightGrid.js +0 -221
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { assert } from "../../../assert.js";
|
|
2
|
-
import { de_interleave_2_bits } from "../../../binary/de_interleave_2_bits.js";
|
|
3
|
-
import { split_by_2 } from "../../../binary/split_by_2.js";
|
|
4
|
-
import { UINT32_MAX } from "../../../binary/UINT32_MAX.js";
|
|
5
|
-
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
6
|
-
import { BinaryElementPool } from "../../3d/topology/struct/binary/BinaryElementPool.js";
|
|
7
|
-
|
|
8
|
-
const NULL_POINTER = UINT32_MAX;
|
|
9
|
-
|
|
10
|
-
const COLUMN_PARENT = 0;
|
|
11
|
-
const COLUMN_CHILD_1 = 1;
|
|
12
|
-
const COLUMN_CHILD_2 = 2;
|
|
13
|
-
const COLUMN_HEIGHT = 3;
|
|
14
|
-
const COLUMN_AABB_OFFSET = 4;
|
|
15
|
-
|
|
16
|
-
const COLUMN_USER_DATA = COLUMN_CHILD_2;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* NOTE: THIS CODE IS UNFINISHED, IT IS ONLY A SKETCH
|
|
21
|
-
* TODO finish implementation
|
|
22
|
-
*
|
|
23
|
-
* Inspired by Makyen's post on stackoverflow: https://stackoverflow.com/a/48384354
|
|
24
|
-
* Core idea is to have dynamically-sized bounding volumes that contain our AABBs, and then have a grid-aligned index that stores pointers to these volumes
|
|
25
|
-
* Makyren called it "Loose/Tight Double-Grid", where "loose" refers to dynamic bounding volumes and tight refers to the grid
|
|
26
|
-
*
|
|
27
|
-
* Invariants:
|
|
28
|
-
* - An element inserted into the structure will belong to exactly one "loose" cell
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
export class LooseTightGrid {
|
|
32
|
-
|
|
33
|
-
#resolution_x = 0
|
|
34
|
-
#resolution_y = 0
|
|
35
|
-
|
|
36
|
-
// amount of space covered by a single grid cell
|
|
37
|
-
#grid_scale = 1
|
|
38
|
-
|
|
39
|
-
#node_pool = new BinaryElementPool(10 * 4)
|
|
40
|
-
#grid_data = new Uint32Array(0);
|
|
41
|
-
|
|
42
|
-
constructor() {
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {number} v
|
|
48
|
-
*/
|
|
49
|
-
set grid_scale(v) {
|
|
50
|
-
assert.isNumber(v, 'v');
|
|
51
|
-
assert.greaterThan(v, 0, 'v');
|
|
52
|
-
|
|
53
|
-
if (this.#grid_scale === v) {
|
|
54
|
-
// no change
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.#grid_scale = v;
|
|
59
|
-
|
|
60
|
-
this.rebuild();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @returns {number}
|
|
66
|
-
*/
|
|
67
|
-
get grid_scale() {
|
|
68
|
-
return this.#grid_scale;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @param {number} size_x
|
|
74
|
-
* @param {number} size_y
|
|
75
|
-
*/
|
|
76
|
-
resize(size_x, size_y) {
|
|
77
|
-
assert.isNonNegativeInteger(size_x, 'size_x');
|
|
78
|
-
assert.isNonNegativeInteger(size_y, 'size_y');
|
|
79
|
-
|
|
80
|
-
if (this.#resolution_x === size_x && this.#resolution_y === size_y) {
|
|
81
|
-
// no change
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.#resolution_x = size_x;
|
|
86
|
-
this.#resolution_y = size_y;
|
|
87
|
-
|
|
88
|
-
this.rebuild();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
* @param {number} x
|
|
94
|
-
* @param {number} y
|
|
95
|
-
* @returns {number}
|
|
96
|
-
*/
|
|
97
|
-
cell_position_to_index(x, y) {
|
|
98
|
-
assert.isNonNegativeInteger(x, 'x');
|
|
99
|
-
assert.isNonNegativeInteger(y, 'y');
|
|
100
|
-
|
|
101
|
-
const _x = split_by_2(x);
|
|
102
|
-
const _y = split_by_2(y);
|
|
103
|
-
|
|
104
|
-
return _x | (_y << 1);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* @param {number[]} out
|
|
110
|
-
* @param {number} out_offset
|
|
111
|
-
* @param {number} index
|
|
112
|
-
*/
|
|
113
|
-
cell_index_to_position(out, out_offset, index) {
|
|
114
|
-
|
|
115
|
-
out[out_offset] = de_interleave_2_bits(index)
|
|
116
|
-
out[out_offset + 1] = de_interleave_2_bits(index >> 1)
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
allocate_datum() {
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
insert() {
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* @param {number} node
|
|
131
|
-
*/
|
|
132
|
-
#node_is_leaf(node) {
|
|
133
|
-
const address = this.#node_pool.element_word(node);
|
|
134
|
-
|
|
135
|
-
return this.#node_pool.data_uint32[address + COLUMN_CHILD_1] === NULL_POINTER;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Collect leaves and de-allocate all intermediate nodes
|
|
140
|
-
* @param {number[]} output
|
|
141
|
-
* @param {number} output_offset
|
|
142
|
-
* @param {number} node
|
|
143
|
-
*/
|
|
144
|
-
#erase_tree_structure(output, output_offset, node) {
|
|
145
|
-
const pool = this.#node_pool;
|
|
146
|
-
|
|
147
|
-
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
148
|
-
const top = SCRATCH_UINT32_TRAVERSAL_STACK.pointer;
|
|
149
|
-
|
|
150
|
-
stack[stack.pointer++] = node;
|
|
151
|
-
|
|
152
|
-
let result_count = 0;
|
|
153
|
-
|
|
154
|
-
while (stack.pointer > top) {
|
|
155
|
-
|
|
156
|
-
stack.pointer--;
|
|
157
|
-
|
|
158
|
-
const n = stack[stack.pointer];
|
|
159
|
-
|
|
160
|
-
const node_address = pool.element_word(n);
|
|
161
|
-
|
|
162
|
-
const child_1 = pool.data_uint32[node_address + COLUMN_CHILD_1];
|
|
163
|
-
const child_2 = pool.data_uint32[node_address + COLUMN_CHILD_2];
|
|
164
|
-
|
|
165
|
-
if (child_1 === NULL_POINTER) {
|
|
166
|
-
// leaf node
|
|
167
|
-
output[output_offset + result_count] = n;
|
|
168
|
-
result_count++;
|
|
169
|
-
} else {
|
|
170
|
-
// binary node
|
|
171
|
-
stack[stack.pointer++] = child_2;
|
|
172
|
-
stack[stack.pointer++] = child_1;
|
|
173
|
-
|
|
174
|
-
// de-allocate node
|
|
175
|
-
pool.release(n);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return result_count;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Rebuild structure from ground-up
|
|
184
|
-
* This is an expensive operation
|
|
185
|
-
* Generally you'll never want to call it explicitly, it is used internally when underlying structure changes
|
|
186
|
-
*/
|
|
187
|
-
rebuild() {
|
|
188
|
-
//TODO implement
|
|
189
|
-
|
|
190
|
-
let leaf_count = 0;
|
|
191
|
-
const leaf_nodes = [];
|
|
192
|
-
// traverse previous grid
|
|
193
|
-
for (let i = 0; i < this.#grid_data.length; i++) {
|
|
194
|
-
const node = this.#grid_data[i];
|
|
195
|
-
|
|
196
|
-
if (node === NULL_POINTER) {
|
|
197
|
-
// empty grid cell
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
leaf_count += this.#erase_tree_structure(leaf_nodes, leaf_count, node);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const resolution_y = this.#resolution_y;
|
|
206
|
-
const resolution_x = this.#resolution_x;
|
|
207
|
-
|
|
208
|
-
const grid_cell_count = resolution_x * resolution_y;
|
|
209
|
-
|
|
210
|
-
if (grid_cell_count !== this.#grid_data.length) {
|
|
211
|
-
this.#grid_data = new Uint32Array(grid_cell_count);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// drop all roots
|
|
215
|
-
this.#grid_data.fill(NULL_POINTER);
|
|
216
|
-
|
|
217
|
-
// re-insert all leaves
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
}
|