@woosh/meep-engine 2.104.0 → 2.105.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/build/meep.cjs +96 -65
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +96 -65
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +1 -1
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts +1 -0
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +3 -2
- package/src/core/cache/Cache.d.ts +2 -1
- package/src/core/cache/Cache.d.ts.map +1 -1
- package/src/core/cache/Cache.js +48 -25
- package/src/core/cache/Cache.spec.js +42 -0
- package/src/core/cache/CacheElement.d.ts +1 -0
- package/src/core/cache/CacheElement.d.ts.map +1 -1
- package/src/core/cache/CacheElement.js +4 -0
- package/src/core/codegen/LineBuilder.d.ts +1 -24
- package/src/core/codegen/LineBuilder.d.ts.map +1 -1
- package/src/core/codegen/LineBuilder.js +19 -15
- package/src/core/collection/map/HashMap.d.ts.map +1 -1
- package/src/core/collection/map/HashMap.js +32 -27
- package/src/core/model/node-graph/NodeGraph.js +2 -2
- package/src/engine/graphics/ecs/mesh/Mesh.js +1 -1
- package/src/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +1 -1
package/build/meep.cjs
CHANGED
|
@@ -60005,28 +60005,6 @@ const RESERVED_HASH_SUBSTITUTE = 0;
|
|
|
60005
60005
|
const UNDEFINED_BIN_INDEX = ~0;
|
|
60006
60006
|
|
|
60007
60007
|
|
|
60008
|
-
/**
|
|
60009
|
-
* @template K,V
|
|
60010
|
-
* @param {HashMapEntry<K,V>} record
|
|
60011
|
-
* @param {number} hash
|
|
60012
|
-
* @param {K} key
|
|
60013
|
-
* @param {function(a:K,b:K):boolean} equality_op
|
|
60014
|
-
*/
|
|
60015
|
-
function entry_equality_check(record, hash, key, equality_op) {
|
|
60016
|
-
if (record.hash !== hash) {
|
|
60017
|
-
return false;
|
|
60018
|
-
}
|
|
60019
|
-
|
|
60020
|
-
if (record.key === key) {
|
|
60021
|
-
return true;
|
|
60022
|
-
}
|
|
60023
|
-
|
|
60024
|
-
const result = equality_op(record.key, key);
|
|
60025
|
-
|
|
60026
|
-
return result;
|
|
60027
|
-
}
|
|
60028
|
-
|
|
60029
|
-
|
|
60030
60008
|
const EMPTY_BINS = new Uint32Array(0);
|
|
60031
60009
|
|
|
60032
60010
|
/**
|
|
@@ -60094,6 +60072,10 @@ class HashMap {
|
|
|
60094
60072
|
*/
|
|
60095
60073
|
#load_factor = DEFAULT_LOAD_FACTOR;
|
|
60096
60074
|
|
|
60075
|
+
/**
|
|
60076
|
+
* Used to track modifications to prevent concurrent changes during iteration
|
|
60077
|
+
* @type {number}
|
|
60078
|
+
*/
|
|
60097
60079
|
#version = 0;
|
|
60098
60080
|
|
|
60099
60081
|
/**
|
|
@@ -60206,6 +60188,25 @@ class HashMap {
|
|
|
60206
60188
|
return original === RESERVED_HASH ? RESERVED_HASH_SUBSTITUTE : original;
|
|
60207
60189
|
}
|
|
60208
60190
|
|
|
60191
|
+
/**
|
|
60192
|
+
* @param {HashMapEntry<K,V>} record
|
|
60193
|
+
* @param {number} hash
|
|
60194
|
+
* @param {K} key
|
|
60195
|
+
*/
|
|
60196
|
+
#entry_equality_check(record, hash, key) {
|
|
60197
|
+
if (record.hash !== hash) {
|
|
60198
|
+
return false;
|
|
60199
|
+
}
|
|
60200
|
+
|
|
60201
|
+
if (record.key === key) {
|
|
60202
|
+
return true;
|
|
60203
|
+
}
|
|
60204
|
+
|
|
60205
|
+
const result = this.keyEqualityFunction(record.key, key);
|
|
60206
|
+
|
|
60207
|
+
return result;
|
|
60208
|
+
}
|
|
60209
|
+
|
|
60209
60210
|
/**
|
|
60210
60211
|
*
|
|
60211
60212
|
* @param {K} k
|
|
@@ -60281,11 +60282,12 @@ class HashMap {
|
|
|
60281
60282
|
// check if it's the entry that we're looking for
|
|
60282
60283
|
const entry = this.#entries[bin - ENTRY_BASE];
|
|
60283
60284
|
|
|
60284
|
-
if (entry_equality_check(entry, raw_hash, key
|
|
60285
|
+
if (this.#entry_equality_check(entry, raw_hash, key)) {
|
|
60285
60286
|
// found the right entry
|
|
60286
60287
|
entry.value = value;
|
|
60287
60288
|
return;
|
|
60288
60289
|
}
|
|
60290
|
+
|
|
60289
60291
|
} else if (bin === BIN_RESERVED_VALUE_EMPTY) {
|
|
60290
60292
|
// bin is empty
|
|
60291
60293
|
|
|
@@ -60344,7 +60346,7 @@ class HashMap {
|
|
|
60344
60346
|
// check if the entry is what we're looking for
|
|
60345
60347
|
const entry = this.#entries[bin - ENTRY_BASE];
|
|
60346
60348
|
|
|
60347
|
-
if (entry_equality_check(entry, raw_hash, key
|
|
60349
|
+
if (this.#entry_equality_check(entry, raw_hash, key)) {
|
|
60348
60350
|
// found the right entry
|
|
60349
60351
|
return entry.value;
|
|
60350
60352
|
}
|
|
@@ -60444,7 +60446,7 @@ class HashMap {
|
|
|
60444
60446
|
const entry_index = bin - ENTRY_BASE;
|
|
60445
60447
|
const entry = entries[entry_index];
|
|
60446
60448
|
|
|
60447
|
-
if (entry_equality_check(entry, raw_hash, key
|
|
60449
|
+
if (this.#entry_equality_check(entry, raw_hash, key)) {
|
|
60448
60450
|
// found the right entry
|
|
60449
60451
|
|
|
60450
60452
|
// record entry as dead
|
|
@@ -60778,16 +60780,27 @@ class CacheElement {
|
|
|
60778
60780
|
next.previous = previous;
|
|
60779
60781
|
}
|
|
60780
60782
|
}
|
|
60783
|
+
|
|
60784
|
+
toString() {
|
|
60785
|
+
return `CacheElement{ hasNext:${this.next !== null}, hasPrevious:${this.previous !== null}, weight:${this.weight}, key:${this.key}, value:${this.value} }`;
|
|
60786
|
+
}
|
|
60781
60787
|
}
|
|
60782
60788
|
|
|
60783
|
-
// TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
|
|
60784
|
-
|
|
60785
60789
|
/**
|
|
60786
60790
|
* Hash-based cache, uses LRU (least-recently-used) eviction policy
|
|
60791
|
+
* Make sure that keys being used are truly immutable when it comes to hash and equality calculation, otherwise cache corruption is inevitable
|
|
60787
60792
|
* @template Key, Value
|
|
60788
60793
|
* @extends Map<Key,Value>
|
|
60789
60794
|
*/
|
|
60790
60795
|
class Cache {
|
|
60796
|
+
#maxWeight = Number.POSITIVE_INFINITY;
|
|
60797
|
+
/**
|
|
60798
|
+
*
|
|
60799
|
+
* @type {number}
|
|
60800
|
+
* @private
|
|
60801
|
+
*/
|
|
60802
|
+
#weight = 0;
|
|
60803
|
+
|
|
60791
60804
|
/**
|
|
60792
60805
|
* @param {number} [maxWeight=Number.POSITIVE_INFINITY]
|
|
60793
60806
|
* @param {function(key:Key):number} [keyWeigher= key=>0]
|
|
@@ -60811,14 +60824,8 @@ class Cache {
|
|
|
60811
60824
|
* @type {number}
|
|
60812
60825
|
* @private
|
|
60813
60826
|
*/
|
|
60814
|
-
this
|
|
60827
|
+
this.#maxWeight = maxWeight;
|
|
60815
60828
|
|
|
60816
|
-
/**
|
|
60817
|
-
*
|
|
60818
|
-
* @type {number}
|
|
60819
|
-
* @private
|
|
60820
|
-
*/
|
|
60821
|
-
this.weight = 0;
|
|
60822
60829
|
|
|
60823
60830
|
/**
|
|
60824
60831
|
*
|
|
@@ -60919,18 +60926,37 @@ class Cache {
|
|
|
60919
60926
|
return this.data.size;
|
|
60920
60927
|
}
|
|
60921
60928
|
|
|
60929
|
+
/**
|
|
60930
|
+
* @deprecated use {@link maxWeight} directly instead
|
|
60931
|
+
*/
|
|
60932
|
+
setMaxWeight(value) {
|
|
60933
|
+
this.maxWeight = value;
|
|
60934
|
+
}
|
|
60935
|
+
|
|
60936
|
+
/**
|
|
60937
|
+
* Total weight of all elements currently in the cache
|
|
60938
|
+
* @returns {number}
|
|
60939
|
+
*/
|
|
60940
|
+
get weight() {
|
|
60941
|
+
return this.#weight;
|
|
60942
|
+
}
|
|
60943
|
+
|
|
60922
60944
|
/**
|
|
60923
60945
|
* Will cause evictions if current weight is smaller than what we're setting
|
|
60924
60946
|
* @param {number} value
|
|
60925
60947
|
*/
|
|
60926
|
-
|
|
60948
|
+
set maxWeight(value) {
|
|
60927
60949
|
if (typeof value !== "number" || value < 0) {
|
|
60928
60950
|
throw new Error(`Weight must be a non-negative number, instead was '${value}'`);
|
|
60929
60951
|
}
|
|
60930
60952
|
|
|
60931
|
-
this
|
|
60953
|
+
this.#maxWeight = value;
|
|
60954
|
+
|
|
60955
|
+
this.evictUntilWeight(this.#maxWeight);
|
|
60956
|
+
}
|
|
60932
60957
|
|
|
60933
|
-
|
|
60958
|
+
get maxWeight() {
|
|
60959
|
+
return this.#maxWeight;
|
|
60934
60960
|
}
|
|
60935
60961
|
|
|
60936
60962
|
/**
|
|
@@ -60949,7 +60975,8 @@ class Cache {
|
|
|
60949
60975
|
result += weight;
|
|
60950
60976
|
}
|
|
60951
60977
|
|
|
60952
|
-
this
|
|
60978
|
+
this.#weight = result;
|
|
60979
|
+
this.evictUntilWeight(this.#maxWeight);
|
|
60953
60980
|
}
|
|
60954
60981
|
|
|
60955
60982
|
/**
|
|
@@ -60979,13 +61006,13 @@ class Cache {
|
|
|
60979
61006
|
|
|
60980
61007
|
const delta_weight = new_weight - old_weight;
|
|
60981
61008
|
|
|
60982
|
-
this
|
|
61009
|
+
this.#weight += delta_weight;
|
|
60983
61010
|
|
|
60984
61011
|
if (
|
|
60985
|
-
this
|
|
60986
|
-
&& new_weight <= this
|
|
61012
|
+
this.#weight > this.#maxWeight
|
|
61013
|
+
&& new_weight <= this.#maxWeight //make it less likely to drop entire cache
|
|
60987
61014
|
) {
|
|
60988
|
-
this.evictUntilWeight(this
|
|
61015
|
+
this.evictUntilWeight(this.#maxWeight);
|
|
60989
61016
|
}
|
|
60990
61017
|
|
|
60991
61018
|
return true;
|
|
@@ -61041,7 +61068,7 @@ class Cache {
|
|
|
61041
61068
|
|
|
61042
61069
|
const target = Math.max(targetWeight, 0);
|
|
61043
61070
|
|
|
61044
|
-
while (this
|
|
61071
|
+
while (this.#weight > target) {
|
|
61045
61072
|
this.evictOne();
|
|
61046
61073
|
}
|
|
61047
61074
|
}
|
|
@@ -61083,7 +61110,7 @@ class Cache {
|
|
|
61083
61110
|
* in which case entire cache will be evicted, but there still won't be enough space
|
|
61084
61111
|
* @type {number}
|
|
61085
61112
|
*/
|
|
61086
|
-
const weightTarget = this
|
|
61113
|
+
const weightTarget = this.#maxWeight - elementWeight;
|
|
61087
61114
|
|
|
61088
61115
|
if (weightTarget < 0) {
|
|
61089
61116
|
// Special case
|
|
@@ -61098,13 +61125,13 @@ class Cache {
|
|
|
61098
61125
|
this.data.set(key, element);
|
|
61099
61126
|
|
|
61100
61127
|
//update weight
|
|
61101
|
-
this
|
|
61128
|
+
this.#weight += elementWeight;
|
|
61102
61129
|
} else {
|
|
61103
61130
|
// check if value is the same
|
|
61104
61131
|
if (value === element.value) ; else {
|
|
61105
61132
|
// replace value, adjust weight
|
|
61106
|
-
this
|
|
61107
|
-
this
|
|
61133
|
+
this.#weight -= this.valueWeigher(element.value);
|
|
61134
|
+
this.#weight += this.valueWeigher(value);
|
|
61108
61135
|
|
|
61109
61136
|
element.value = value;
|
|
61110
61137
|
}
|
|
@@ -61190,7 +61217,7 @@ class Cache {
|
|
|
61190
61217
|
this.data.delete(key);
|
|
61191
61218
|
|
|
61192
61219
|
//update weight
|
|
61193
|
-
this
|
|
61220
|
+
this.#weight -= element.weight;
|
|
61194
61221
|
}
|
|
61195
61222
|
|
|
61196
61223
|
/**
|
|
@@ -61262,7 +61289,7 @@ class Cache {
|
|
|
61262
61289
|
this.__first = null;
|
|
61263
61290
|
this.__last = null;
|
|
61264
61291
|
|
|
61265
|
-
this
|
|
61292
|
+
this.#weight = 0;
|
|
61266
61293
|
}
|
|
61267
61294
|
|
|
61268
61295
|
/**
|
|
@@ -63123,12 +63150,14 @@ class LineBuilder {
|
|
|
63123
63150
|
*
|
|
63124
63151
|
* @type {Line[]}
|
|
63125
63152
|
*/
|
|
63126
|
-
lines = [];
|
|
63153
|
+
#lines = [];
|
|
63154
|
+
|
|
63127
63155
|
/**
|
|
63128
63156
|
*
|
|
63129
63157
|
* @type {number}
|
|
63130
63158
|
*/
|
|
63131
|
-
indentation = 0;
|
|
63159
|
+
#indentation = 0;
|
|
63160
|
+
|
|
63132
63161
|
/**
|
|
63133
63162
|
*
|
|
63134
63163
|
* @type {number}
|
|
@@ -63140,7 +63169,7 @@ class LineBuilder {
|
|
|
63140
63169
|
* @return {number}
|
|
63141
63170
|
*/
|
|
63142
63171
|
get count() {
|
|
63143
|
-
return this
|
|
63172
|
+
return this.#lines.length;
|
|
63144
63173
|
}
|
|
63145
63174
|
|
|
63146
63175
|
/**
|
|
@@ -63149,7 +63178,7 @@ class LineBuilder {
|
|
|
63149
63178
|
* @param {string} term
|
|
63150
63179
|
*/
|
|
63151
63180
|
containsSubstring(term) {
|
|
63152
|
-
const lines = this
|
|
63181
|
+
const lines = this.#lines;
|
|
63153
63182
|
const n = lines.length;
|
|
63154
63183
|
for (let i = 0; i < n; i++) {
|
|
63155
63184
|
const line = lines[i];
|
|
@@ -63169,7 +63198,7 @@ class LineBuilder {
|
|
|
63169
63198
|
* @returns {LineBuilder}
|
|
63170
63199
|
*/
|
|
63171
63200
|
indent() {
|
|
63172
|
-
this
|
|
63201
|
+
this.#indentation++;
|
|
63173
63202
|
return this;
|
|
63174
63203
|
}
|
|
63175
63204
|
|
|
@@ -63178,7 +63207,7 @@ class LineBuilder {
|
|
|
63178
63207
|
* @returns {LineBuilder}
|
|
63179
63208
|
*/
|
|
63180
63209
|
dedent() {
|
|
63181
|
-
this
|
|
63210
|
+
this.#indentation--;
|
|
63182
63211
|
return this;
|
|
63183
63212
|
}
|
|
63184
63213
|
|
|
@@ -63189,9 +63218,9 @@ class LineBuilder {
|
|
|
63189
63218
|
*/
|
|
63190
63219
|
add(line_text) {
|
|
63191
63220
|
|
|
63192
|
-
const line = new Line(line_text, this
|
|
63221
|
+
const line = new Line(line_text, this.#indentation);
|
|
63193
63222
|
|
|
63194
|
-
this
|
|
63223
|
+
this.#lines.push(line);
|
|
63195
63224
|
|
|
63196
63225
|
return this;
|
|
63197
63226
|
}
|
|
@@ -63202,23 +63231,23 @@ class LineBuilder {
|
|
|
63202
63231
|
*/
|
|
63203
63232
|
addLines(lines) {
|
|
63204
63233
|
|
|
63205
|
-
const other_lines = lines
|
|
63234
|
+
const other_lines = lines.#lines;
|
|
63206
63235
|
|
|
63207
63236
|
const other_line_count = other_lines.length;
|
|
63208
63237
|
|
|
63209
63238
|
for (let i = 0; i < other_line_count; i++) {
|
|
63210
63239
|
const otherLine = other_lines[i];
|
|
63211
63240
|
|
|
63212
|
-
const line = new Line(otherLine.text, otherLine.indentation + this
|
|
63241
|
+
const line = new Line(otherLine.text, otherLine.indentation + this.#indentation);
|
|
63213
63242
|
|
|
63214
|
-
this
|
|
63243
|
+
this.#lines.push(line);
|
|
63215
63244
|
}
|
|
63216
63245
|
|
|
63217
63246
|
}
|
|
63218
63247
|
|
|
63219
63248
|
clear() {
|
|
63220
|
-
this
|
|
63221
|
-
this
|
|
63249
|
+
this.#lines = [];
|
|
63250
|
+
this.#indentation = 0;
|
|
63222
63251
|
}
|
|
63223
63252
|
|
|
63224
63253
|
/**
|
|
@@ -63230,7 +63259,7 @@ class LineBuilder {
|
|
|
63230
63259
|
|
|
63231
63260
|
let i, j, l;
|
|
63232
63261
|
|
|
63233
|
-
const lines = this
|
|
63262
|
+
const lines = this.#lines;
|
|
63234
63263
|
|
|
63235
63264
|
for (i = 0, l = lines.length; i < l; i++) {
|
|
63236
63265
|
const line = lines[i];
|
|
@@ -63263,7 +63292,9 @@ class LineBuilder {
|
|
|
63263
63292
|
|
|
63264
63293
|
for (let i = 0; i < n; i++) {
|
|
63265
63294
|
|
|
63266
|
-
|
|
63295
|
+
const line_text = lines[i];
|
|
63296
|
+
|
|
63297
|
+
r.add(line_text);
|
|
63267
63298
|
|
|
63268
63299
|
}
|
|
63269
63300
|
|
|
@@ -66277,7 +66308,7 @@ class GeometrySpatialQueryAccelerator {
|
|
|
66277
66308
|
* @param {number} value in bytes
|
|
66278
66309
|
*/
|
|
66279
66310
|
set cache_size(value) {
|
|
66280
|
-
this.cache.
|
|
66311
|
+
this.cache.maxWeight = value;
|
|
66281
66312
|
}
|
|
66282
66313
|
|
|
66283
66314
|
/**
|