@woosh/meep-engine 2.90.0 → 2.91.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/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +20 -9
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +20 -9
- package/package.json +1 -1
- package/src/core/binary/de_interleave_2_bits.spec.d.ts.map +1 -0
- package/src/core/binary/de_interleave_bits_by_2.d.ts.map +1 -0
- package/src/core/binary/reinterpret_float32_as_int32.d.ts.map +1 -0
- package/src/core/binary/split_by_2.d.ts.map +1 -0
- package/src/core/binary/split_by_3.d.ts.map +1 -0
- package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +3 -4
- package/src/core/bvh2/bvh3/BVH.js +1 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/AABB2.js +2 -4
- package/src/core/geom/2d/aabb/aabb2_array_combine.d.ts +11 -0
- package/src/core/geom/2d/aabb/aabb2_array_combine.d.ts.map +1 -0
- package/src/core/geom/2d/aabb/aabb2_array_combine.js +35 -0
- package/src/core/geom/2d/aabb/aabb2_array_set.d.ts +11 -0
- package/src/core/geom/2d/aabb/aabb2_array_set.d.ts.map +1 -0
- package/src/core/geom/2d/aabb/aabb2_array_set.js +21 -0
- package/src/core/geom/2d/aabb/aabb2_compute_area.d.ts +10 -0
- package/src/core/geom/2d/aabb/aabb2_compute_area.d.ts.map +1 -0
- package/src/core/geom/2d/aabb/aabb2_compute_area.js +14 -0
- package/src/core/geom/2d/bvh/BVH2D.d.ts +296 -0
- package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/BVH2D.js +1143 -0
- package/src/core/geom/2d/bvh/BVH2D.spec.d.ts +2 -0
- package/src/core/geom/2d/bvh/BVH2D.spec.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/BVH2D.spec.js +358 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.d.ts +13 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.js +83 -0
- package/src/core/geom/2d/lt-grid/LooseTightGrid.js +2 -2
- package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
- package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts +79 -0
- package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -0
- package/src/core/geom/2d/r-tree/StaticR2Tree.js +384 -0
- package/src/core/geom/2d/r-tree/StaticR2Tree.spec.d.ts +2 -0
- package/src/core/geom/2d/r-tree/StaticR2Tree.spec.d.ts.map +1 -0
- package/src/core/geom/2d/r-tree/StaticR2Tree.spec.js +62 -0
- package/src/core/geom/3d/morton/mortonEncode_magicbits.js +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/OrderedEdge.js +1 -1
- package/src/engine/graphics/texture/virtual/tile/compose_tile_address.js +1 -1
- package/src/engine/graphics/texture/virtual/tile/tile_address_to_finger_print.js +1 -1
- package/src/core/geom/3d/morton/de_interleave_2_bits.spec.d.ts.map +0 -1
- package/src/core/geom/3d/morton/de_interleave_bits_by_2.d.ts.map +0 -1
- package/src/core/geom/3d/morton/reinterpret_float32_as_int32.d.ts.map +0 -1
- package/src/core/geom/3d/morton/split_by_2.d.ts.map +0 -1
- package/src/core/geom/3d/morton/split_by_3.d.ts.map +0 -1
- /package/src/core/{geom/3d/morton → binary}/de_interleave_2_bits.spec.d.ts +0 -0
- /package/src/core/{geom/3d/morton → binary}/de_interleave_2_bits.spec.js +0 -0
- /package/src/core/{geom/3d/morton → binary}/de_interleave_bits_by_2.d.ts +0 -0
- /package/src/core/{geom/3d/morton → binary}/de_interleave_bits_by_2.js +0 -0
- /package/src/core/{geom/3d/morton → binary}/reinterpret_float32_as_int32.d.ts +0 -0
- /package/src/core/{geom/3d/morton → binary}/reinterpret_float32_as_int32.js +0 -0
- /package/src/core/{geom/3d/morton → binary}/split_by_2.d.ts +0 -0
- /package/src/core/{geom/3d/morton → binary}/split_by_2.js +0 -0
- /package/src/core/{geom/3d/morton → binary}/split_by_3.d.ts +0 -0
- /package/src/core/{geom/3d/morton → binary}/split_by_3.js +0 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
import { ceilPowerOfTwo } from "../../../binary/operations/ceilPowerOfTwo.js";
|
|
3
|
+
import { split_by_2 } from "../../../binary/split_by_2.js";
|
|
4
|
+
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
5
|
+
import { array_swap } from "../../../collection/array/array_swap.js";
|
|
6
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
7
|
+
import { aabb2_array_combine } from "../aabb/aabb2_array_combine.js";
|
|
8
|
+
|
|
9
|
+
const BINARY_NODE_SIZE = 4;
|
|
10
|
+
const LEAF_NODE_SIZE = 5;
|
|
11
|
+
const BOX_BYTE_SIZE = 4;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Assumes data will be normalized to 0...1 value range
|
|
15
|
+
* @param {Float32Array} data
|
|
16
|
+
* @param {number} address
|
|
17
|
+
* @param {number} bounds_x0
|
|
18
|
+
* @param {number} bounds_y0
|
|
19
|
+
* @param {number} multiplier_x
|
|
20
|
+
* @param {number} multiplier_y
|
|
21
|
+
* @returns {number}
|
|
22
|
+
*/
|
|
23
|
+
function build_normalized_morton_2d(
|
|
24
|
+
data, address,
|
|
25
|
+
bounds_x0, bounds_y0,
|
|
26
|
+
multiplier_x, multiplier_y
|
|
27
|
+
) {
|
|
28
|
+
|
|
29
|
+
const x0 = data[address];
|
|
30
|
+
const y0 = data[address + 1];
|
|
31
|
+
const x1 = data[address + 3];
|
|
32
|
+
const y1 = data[address + 4];
|
|
33
|
+
|
|
34
|
+
const cx = (x0 + x1) * 0.5;
|
|
35
|
+
const cy = (y0 + y1) * 0.5;
|
|
36
|
+
|
|
37
|
+
const normalized_x = (cx - bounds_x0) * multiplier_x
|
|
38
|
+
const normalized_y = (cy - bounds_y0) * multiplier_y
|
|
39
|
+
|
|
40
|
+
return (split_by_2(normalized_y) << 1)
|
|
41
|
+
| split_by_2(normalized_x)
|
|
42
|
+
;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {Float32Array} data
|
|
48
|
+
* @param {number} destination
|
|
49
|
+
* @param {number} source
|
|
50
|
+
*/
|
|
51
|
+
function copy_box_zero_size(data, destination, source) {
|
|
52
|
+
assert.isNonNegativeInteger(destination, 'destination');
|
|
53
|
+
assert.isNonNegativeInteger(source, 'source');
|
|
54
|
+
|
|
55
|
+
const x = data[source];
|
|
56
|
+
const y = data[source + 1];
|
|
57
|
+
|
|
58
|
+
assert.notNaN(x, 'x');
|
|
59
|
+
assert.notNaN(y, 'y');
|
|
60
|
+
|
|
61
|
+
data[destination] = x;
|
|
62
|
+
data[destination + 1] = y;
|
|
63
|
+
|
|
64
|
+
data[destination + 2] = x;
|
|
65
|
+
data[destination + 3] = y;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* NOTE: code is based on BinaryUint32BVH
|
|
71
|
+
* NOTE: this code is mostly untested
|
|
72
|
+
*/
|
|
73
|
+
export class StaticR2Tree {
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @type {ArrayBuffer}
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
__data_buffer;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @readonly
|
|
83
|
+
* @private
|
|
84
|
+
* @type {Uint32Array}
|
|
85
|
+
*/
|
|
86
|
+
__data_uint32;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @type {number}
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
__node_count_binary = 0;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @type {number}
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
__node_count_leaf = 0;
|
|
101
|
+
|
|
102
|
+
constructor() {
|
|
103
|
+
this.setBuffer(new ArrayBuffer(320));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param {ArrayBuffer} buffer
|
|
110
|
+
*/
|
|
111
|
+
setBuffer(buffer) {
|
|
112
|
+
assert.defined(buffer, 'buffer');
|
|
113
|
+
|
|
114
|
+
this.__data_buffer = buffer;
|
|
115
|
+
|
|
116
|
+
this.__data_float32 = new Float32Array(this.__data_buffer);
|
|
117
|
+
this.__data_uint32 = new Uint32Array(this.__data_buffer);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
initialize_structure() {
|
|
122
|
+
// compute memory requirements
|
|
123
|
+
const word_count = this.__node_count_binary * BINARY_NODE_SIZE + this.__node_count_leaf * LEAF_NODE_SIZE;
|
|
124
|
+
const storage_size = word_count * 4;
|
|
125
|
+
|
|
126
|
+
// possibly resize the storage
|
|
127
|
+
if (this.__data_buffer.byteLength < storage_size) {
|
|
128
|
+
this.setBuffer(new ArrayBuffer(storage_size));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @param {number} count
|
|
135
|
+
*/
|
|
136
|
+
setLeafCount(count) {
|
|
137
|
+
this.__node_count_leaf = count;
|
|
138
|
+
|
|
139
|
+
const twoLeafLimit = ceilPowerOfTwo(count);
|
|
140
|
+
|
|
141
|
+
if (count <= 1) {
|
|
142
|
+
// special case
|
|
143
|
+
this.__node_count_binary = twoLeafLimit;
|
|
144
|
+
} else {
|
|
145
|
+
this.__node_count_binary = twoLeafLimit - 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param {number} index
|
|
154
|
+
* @param {number} payload
|
|
155
|
+
* @param {number} x0
|
|
156
|
+
* @param {number} y0
|
|
157
|
+
* @param {number} x1
|
|
158
|
+
* @param {number} y1
|
|
159
|
+
*/
|
|
160
|
+
setLeafData(
|
|
161
|
+
index, payload,
|
|
162
|
+
x0, y0,
|
|
163
|
+
x1, y1
|
|
164
|
+
) {
|
|
165
|
+
assert.notNaN(x0, 'x0');
|
|
166
|
+
assert.notNaN(y0, 'y0');
|
|
167
|
+
assert.notNaN(x1, 'x1');
|
|
168
|
+
assert.notNaN(y1, 'y1');
|
|
169
|
+
|
|
170
|
+
assert.isNonNegativeInteger(payload, 'payload');
|
|
171
|
+
|
|
172
|
+
const address = index * LEAF_NODE_SIZE + this.__node_count_binary * BINARY_NODE_SIZE;
|
|
173
|
+
|
|
174
|
+
const float32 = this.__data_float32;
|
|
175
|
+
|
|
176
|
+
float32[address] = x0;
|
|
177
|
+
float32[address + 1] = y0;
|
|
178
|
+
float32[address + 2] = x1;
|
|
179
|
+
float32[address + 3] = y1;
|
|
180
|
+
|
|
181
|
+
this.__data_uint32[address + 4] = payload;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
* @returns {number}
|
|
187
|
+
*/
|
|
188
|
+
getLeafBlockAddress() {
|
|
189
|
+
return this.__node_count_binary * BINARY_NODE_SIZE;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
* @param {number} leaf_index
|
|
195
|
+
* @returns {number}
|
|
196
|
+
*/
|
|
197
|
+
readLeafPayload(leaf_index) {
|
|
198
|
+
const block_address = this.getLeafBlockAddress();
|
|
199
|
+
|
|
200
|
+
const address = block_address + leaf_index * LEAF_NODE_SIZE + BOX_BYTE_SIZE;
|
|
201
|
+
|
|
202
|
+
return this.__data_uint32[address];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Sort leaf nodes according to their morton codes
|
|
208
|
+
* @param {number[]} bounds
|
|
209
|
+
*/
|
|
210
|
+
sort_morton(bounds) {
|
|
211
|
+
|
|
212
|
+
const leaf_block_address = this.__node_count_binary * BINARY_NODE_SIZE;
|
|
213
|
+
|
|
214
|
+
if (this.__node_count_leaf < 2) {
|
|
215
|
+
// no swaps available
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
220
|
+
const stack_top = stack.pointer;
|
|
221
|
+
|
|
222
|
+
let stackPointer = stack_top + 2;
|
|
223
|
+
let iL, iR;
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
stack[0] = 0; // first node
|
|
227
|
+
stack[1] = this.__node_count_leaf - 1; // last node
|
|
228
|
+
|
|
229
|
+
const data = this.__data_float32;
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
const bounds_x0 = bounds[0];
|
|
233
|
+
const bounds_y0 = bounds[1];
|
|
234
|
+
|
|
235
|
+
const bounds_span_x = bounds[2] - bounds_x0;
|
|
236
|
+
const bounds_span_y = bounds[3] - bounds_y0;
|
|
237
|
+
|
|
238
|
+
const bounds_multiplier_x = 4095 / bounds_span_x;
|
|
239
|
+
const bounds_multiplier_y = 4095 / bounds_span_y;
|
|
240
|
+
|
|
241
|
+
while (stackPointer > stack_top) {
|
|
242
|
+
stackPointer -= 2;
|
|
243
|
+
|
|
244
|
+
const right = stack[stackPointer + 1];
|
|
245
|
+
const left = stack[stackPointer];
|
|
246
|
+
|
|
247
|
+
iL = left;
|
|
248
|
+
iR = right;
|
|
249
|
+
|
|
250
|
+
const pivot_index = (left + right) >>> 1;
|
|
251
|
+
|
|
252
|
+
const pivot_address = pivot_index * LEAF_NODE_SIZE + leaf_block_address;
|
|
253
|
+
|
|
254
|
+
const pivot = build_normalized_morton_2d(data, pivot_address, bounds_x0, bounds_y0, bounds_multiplier_x, bounds_multiplier_y);
|
|
255
|
+
|
|
256
|
+
/* partition */
|
|
257
|
+
while (iL <= iR) {
|
|
258
|
+
while (build_normalized_morton_2d(data, iL * LEAF_NODE_SIZE + leaf_block_address, bounds_x0, bounds_y0, bounds_multiplier_x, bounds_multiplier_y) < pivot) {
|
|
259
|
+
iL++;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
while (build_normalized_morton_2d(data, iR * LEAF_NODE_SIZE + leaf_block_address, bounds_x0, bounds_y0, bounds_multiplier_x, bounds_multiplier_y) > pivot) {
|
|
263
|
+
iR--;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (iL <= iR) {
|
|
267
|
+
|
|
268
|
+
if (iL !== iR) {
|
|
269
|
+
//do swap
|
|
270
|
+
this.__swap_leaves(iL, iR);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
iL++;
|
|
274
|
+
iR--;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* recursion */
|
|
279
|
+
if (left < iR) {
|
|
280
|
+
stack[stackPointer++] = left;
|
|
281
|
+
stack[stackPointer++] = iR;
|
|
282
|
+
}
|
|
283
|
+
if (iL < right) {
|
|
284
|
+
stack[stackPointer++] = iL;
|
|
285
|
+
stack[stackPointer++] = right;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
*
|
|
292
|
+
* @param {number} i
|
|
293
|
+
* @param {number} j
|
|
294
|
+
* @private
|
|
295
|
+
*/
|
|
296
|
+
__swap_leaves(i, j) {
|
|
297
|
+
const leaf_block_address = this.getLeafBlockAddress();
|
|
298
|
+
const a = i * LEAF_NODE_SIZE + leaf_block_address;
|
|
299
|
+
const b = j * LEAF_NODE_SIZE + leaf_block_address;
|
|
300
|
+
|
|
301
|
+
const float32 = this.__data_float32;
|
|
302
|
+
|
|
303
|
+
array_swap(
|
|
304
|
+
float32, a,
|
|
305
|
+
float32, b,
|
|
306
|
+
LEAF_NODE_SIZE
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Assemble leaf nodes into hierarchy, set binary node bounds iteratively bottom up
|
|
312
|
+
*/
|
|
313
|
+
build() {
|
|
314
|
+
const binary_node_count = this.__node_count_binary;
|
|
315
|
+
|
|
316
|
+
const leaf_node_block_address = binary_node_count * BINARY_NODE_SIZE;
|
|
317
|
+
|
|
318
|
+
let level = Math.floor(Math.log(binary_node_count) / Math.log(2));
|
|
319
|
+
|
|
320
|
+
let i, offset, level_node_count;
|
|
321
|
+
//NOTE: building first level separately allows to avoid some switching logic needed to determine what is the type of lower level node
|
|
322
|
+
//build one level above leaf nodes
|
|
323
|
+
level_node_count = Math.pow(2, level);
|
|
324
|
+
offset = (level_node_count - 1) * BINARY_NODE_SIZE;
|
|
325
|
+
|
|
326
|
+
let parentIndex;
|
|
327
|
+
|
|
328
|
+
const node_count_leaf = this.__node_count_leaf;
|
|
329
|
+
|
|
330
|
+
const float32 = this.__data_float32;
|
|
331
|
+
|
|
332
|
+
// build bottom-most level, just above the leaves
|
|
333
|
+
for (i = 0; i < level_node_count; i++) {
|
|
334
|
+
const leaf_index_0 = i << 1;
|
|
335
|
+
const leaf_index_1 = leaf_index_0 + 1;
|
|
336
|
+
|
|
337
|
+
const leaf_offset_0 = leaf_node_block_address + leaf_index_0 * LEAF_NODE_SIZE;
|
|
338
|
+
const leaf_offset_1 = leaf_node_block_address + leaf_index_1 * LEAF_NODE_SIZE;
|
|
339
|
+
|
|
340
|
+
if (leaf_index_1 < node_count_leaf) {
|
|
341
|
+
// both children nodes are valid
|
|
342
|
+
aabb2_array_combine(
|
|
343
|
+
float32, offset,
|
|
344
|
+
float32, leaf_offset_0,
|
|
345
|
+
float32, leaf_offset_1
|
|
346
|
+
);
|
|
347
|
+
} else if (leaf_index_0 < node_count_leaf) {
|
|
348
|
+
// only left child node is valid
|
|
349
|
+
array_copy(float32, leaf_offset_0, float32, offset, 6);
|
|
350
|
+
} else {
|
|
351
|
+
//initialize to 0-size box same position as previous node
|
|
352
|
+
copy_box_zero_size(this.__data_float32, offset, (offset - BINARY_NODE_SIZE));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
offset += BINARY_NODE_SIZE;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
level--;
|
|
359
|
+
|
|
360
|
+
//build intermediate nodes
|
|
361
|
+
for (; level >= 0; level--) {
|
|
362
|
+
level_node_count = 1 << level;
|
|
363
|
+
parentIndex = (level_node_count - 1);
|
|
364
|
+
|
|
365
|
+
for (i = 0; i < level_node_count; i++) {
|
|
366
|
+
|
|
367
|
+
const childIndex0 = (parentIndex << 1) + 1;
|
|
368
|
+
|
|
369
|
+
const address_parent = parentIndex * BINARY_NODE_SIZE;
|
|
370
|
+
|
|
371
|
+
const address_child_0 = childIndex0 * BINARY_NODE_SIZE;
|
|
372
|
+
const address_child_1 = address_child_0 + BINARY_NODE_SIZE;
|
|
373
|
+
|
|
374
|
+
aabb2_array_combine(
|
|
375
|
+
float32, address_parent,
|
|
376
|
+
float32, address_child_0,
|
|
377
|
+
float32, address_child_1
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
parentIndex++;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticR2Tree.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/r-tree/StaticR2Tree.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { randomFloatBetween } from "../../../math/random/randomFloatBetween.js";
|
|
2
|
+
import { seededRandom } from "../../../math/random/seededRandom.js";
|
|
3
|
+
import { StaticR2Tree } from "./StaticR2Tree.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
test.skip("performance, insertion 1m random", () => {
|
|
7
|
+
const tree = new StaticR2Tree();
|
|
8
|
+
|
|
9
|
+
const random = seededRandom(42);
|
|
10
|
+
|
|
11
|
+
const N = 1000000;
|
|
12
|
+
|
|
13
|
+
const boxes = new Float32Array(N * 4);
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < N; i++) {
|
|
16
|
+
|
|
17
|
+
const position_x = randomFloatBetween(random, 0, 98);
|
|
18
|
+
const position_y = randomFloatBetween(random, 0, 98);
|
|
19
|
+
|
|
20
|
+
const size_x = randomFloatBetween(random, 0.1, 2);
|
|
21
|
+
const size_y = randomFloatBetween(random, 0.1, 2);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const i4 = i * 4;
|
|
25
|
+
boxes[i4] = position_x;
|
|
26
|
+
boxes[i4 + 1] = position_y;
|
|
27
|
+
boxes[i4 + 2] = position_x + size_x;
|
|
28
|
+
boxes[i4 + 3] = position_y + size_y;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
tree.setLeafCount(N);
|
|
32
|
+
tree.initialize_structure();
|
|
33
|
+
|
|
34
|
+
// perform insertion
|
|
35
|
+
const t0 = performance.now();
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < N; i++) {
|
|
38
|
+
const i4 = i * 4;
|
|
39
|
+
|
|
40
|
+
const x0 = boxes[i4];
|
|
41
|
+
const y0 = boxes[i4 + 1];
|
|
42
|
+
const x1 = boxes[i4 + 2];
|
|
43
|
+
const y1 = boxes[i4 + 3];
|
|
44
|
+
|
|
45
|
+
tree.setLeafData(i, i,
|
|
46
|
+
x0,
|
|
47
|
+
y0,
|
|
48
|
+
x1,
|
|
49
|
+
y1
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
tree.sort_morton([0,0,100,100])
|
|
54
|
+
|
|
55
|
+
tree.build();
|
|
56
|
+
|
|
57
|
+
const duration = performance.now() - t0;
|
|
58
|
+
|
|
59
|
+
const duration_seconds = duration * 1e-3;
|
|
60
|
+
|
|
61
|
+
console.log(`Duration ${duration_seconds}s, ${(N / duration_seconds).toFixed(2)} records per second`);
|
|
62
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"de_interleave_2_bits.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/de_interleave_2_bits.spec.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"de_interleave_bits_by_2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/de_interleave_bits_by_2.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACJ,MAAM,CAWlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reinterpret_float32_as_int32.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/reinterpret_float32_as_int32.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,oDAHW,MAAM,GACJ,MAAM,CAKlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/split_by_2.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAHW,MAAM,GACJ,MAAM,CAUlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_3.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/split_by_3.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAHW,MAAM,GACJ,MAAM,CASlB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|