@woosh/meep-engine 2.95.0 → 2.96.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 +175 -140
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +175 -140
- package/package.json +1 -2
- package/src/core/collection/array/arrayPickBestElement.d.ts.map +1 -1
- package/src/core/collection/array/arrayPickBestElement.js +3 -3
- package/src/core/collection/array/arrayPickBestElements.d.ts +2 -2
- package/src/core/collection/array/arrayPickBestElements.d.ts.map +1 -1
- package/src/core/collection/array/arrayPickBestElements.js +3 -3
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.spec.js +1 -1
- package/src/core/geom/2d/hash-grid/shg_query_elements_circle.spec.js +1 -1
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +14 -8
- package/src/core/localization/Localization.d.ts.map +1 -1
- package/src/core/localization/Localization.js +11 -11
- package/src/core/math/epsilonEquals.d.ts.map +1 -1
- package/src/core/math/epsilonEquals.js +1 -0
- package/src/core/math/epsilonEquals.spec.d.ts +2 -0
- package/src/core/math/epsilonEquals.spec.d.ts.map +1 -0
- package/src/core/math/epsilonEquals.spec.js +17 -0
- package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstance.js +8 -2
- package/src/core/primitives/strings/string_compute_similarity.d.ts +6 -0
- package/src/core/primitives/strings/string_compute_similarity.d.ts.map +1 -0
- package/src/core/primitives/strings/string_compute_similarity.js +7 -0
- package/src/core/primitives/strings/string_jaro_winkler.d.ts +8 -0
- package/src/core/primitives/strings/string_jaro_winkler.d.ts.map +1 -0
- package/src/core/primitives/strings/string_jaro_winkler.js +153 -0
- package/src/core/primitives/strings/string_jaro_winkler.spec.d.ts +2 -0
- package/src/core/primitives/strings/string_jaro_winkler.spec.d.ts.map +1 -0
- package/src/core/primitives/strings/string_jaro_winkler.spec.js +39 -0
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.d.ts.map +1 -1
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +5 -14
- package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +3 -3
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +2 -2
package/build/meep.cjs
CHANGED
|
@@ -3171,35 +3171,39 @@ const cos$1 = Math.cos;
|
|
|
3171
3171
|
let Quaternion$1 = class Quaternion {
|
|
3172
3172
|
/**
|
|
3173
3173
|
*
|
|
3174
|
-
* @param {
|
|
3175
|
-
* @param {
|
|
3176
|
-
* @param {
|
|
3177
|
-
* @param {
|
|
3174
|
+
* @param {number} [x=0]
|
|
3175
|
+
* @param {number} [y=0]
|
|
3176
|
+
* @param {number} [z=0]
|
|
3177
|
+
* @param {number} [w=1]
|
|
3178
3178
|
* @constructor
|
|
3179
3179
|
*/
|
|
3180
3180
|
constructor(x = 0, y = 0, z = 0, w = 1) {
|
|
3181
3181
|
|
|
3182
3182
|
/**
|
|
3183
3183
|
*
|
|
3184
|
-
* @type {
|
|
3184
|
+
* @type {number}
|
|
3185
3185
|
*/
|
|
3186
3186
|
this.x = x;
|
|
3187
3187
|
/**
|
|
3188
3188
|
*
|
|
3189
|
-
* @type {
|
|
3189
|
+
* @type {number}
|
|
3190
3190
|
*/
|
|
3191
3191
|
this.y = y;
|
|
3192
3192
|
/**
|
|
3193
3193
|
*
|
|
3194
|
-
* @type {
|
|
3194
|
+
* @type {number}
|
|
3195
3195
|
*/
|
|
3196
3196
|
this.z = z;
|
|
3197
3197
|
/**
|
|
3198
3198
|
*
|
|
3199
|
-
* @type {
|
|
3199
|
+
* @type {number}
|
|
3200
3200
|
*/
|
|
3201
3201
|
this.w = w;
|
|
3202
3202
|
|
|
3203
|
+
/**
|
|
3204
|
+
* @readonly
|
|
3205
|
+
* @type {Signal<number, number, number, number, number, number, number, number>}
|
|
3206
|
+
*/
|
|
3203
3207
|
this.onChanged = new Signal();
|
|
3204
3208
|
}
|
|
3205
3209
|
|
|
@@ -4481,6 +4485,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4481
4485
|
|
|
4482
4486
|
/**
|
|
4483
4487
|
* Based on GDC talk from Bungie on destiny, compressing quaternions for animation
|
|
4488
|
+
* @deprecated use `quat_decode_from_uint32` instead
|
|
4484
4489
|
* @param {number} value
|
|
4485
4490
|
*/
|
|
4486
4491
|
decodeFromUint32(value) {
|
|
@@ -4489,6 +4494,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4489
4494
|
|
|
4490
4495
|
/**
|
|
4491
4496
|
* Based on GDC talk from Bungie on destiny, compressing quaternions for animation
|
|
4497
|
+
* @deprecated use `quat_encode_to_uint32` instead
|
|
4492
4498
|
* @returns {number}
|
|
4493
4499
|
*/
|
|
4494
4500
|
encodeToUint32() {
|
|
@@ -81288,132 +81294,6 @@ class Tag {
|
|
|
81288
81294
|
|
|
81289
81295
|
Tag.typeName = "Tag";
|
|
81290
81296
|
|
|
81291
|
-
const peq = new Uint32Array(0x10000);
|
|
81292
|
-
const myers_32 = (a, b) => {
|
|
81293
|
-
const n = a.length;
|
|
81294
|
-
const m = b.length;
|
|
81295
|
-
const lst = 1 << (n - 1);
|
|
81296
|
-
let pv = -1;
|
|
81297
|
-
let mv = 0;
|
|
81298
|
-
let sc = n;
|
|
81299
|
-
let i = n;
|
|
81300
|
-
while (i--) {
|
|
81301
|
-
peq[a.charCodeAt(i)] |= 1 << i;
|
|
81302
|
-
}
|
|
81303
|
-
for (i = 0; i < m; i++) {
|
|
81304
|
-
let eq = peq[b.charCodeAt(i)];
|
|
81305
|
-
const xv = eq | mv;
|
|
81306
|
-
eq |= ((eq & pv) + pv) ^ pv;
|
|
81307
|
-
mv |= ~(eq | pv);
|
|
81308
|
-
pv &= eq;
|
|
81309
|
-
if (mv & lst) {
|
|
81310
|
-
sc++;
|
|
81311
|
-
}
|
|
81312
|
-
if (pv & lst) {
|
|
81313
|
-
sc--;
|
|
81314
|
-
}
|
|
81315
|
-
mv = (mv << 1) | 1;
|
|
81316
|
-
pv = (pv << 1) | ~(xv | mv);
|
|
81317
|
-
mv &= xv;
|
|
81318
|
-
}
|
|
81319
|
-
i = n;
|
|
81320
|
-
while (i--) {
|
|
81321
|
-
peq[a.charCodeAt(i)] = 0;
|
|
81322
|
-
}
|
|
81323
|
-
return sc;
|
|
81324
|
-
};
|
|
81325
|
-
const myers_x = (b, a) => {
|
|
81326
|
-
const n = a.length;
|
|
81327
|
-
const m = b.length;
|
|
81328
|
-
const mhc = [];
|
|
81329
|
-
const phc = [];
|
|
81330
|
-
const hsize = Math.ceil(n / 32);
|
|
81331
|
-
const vsize = Math.ceil(m / 32);
|
|
81332
|
-
for (let i = 0; i < hsize; i++) {
|
|
81333
|
-
phc[i] = -1;
|
|
81334
|
-
mhc[i] = 0;
|
|
81335
|
-
}
|
|
81336
|
-
let j = 0;
|
|
81337
|
-
for (; j < vsize - 1; j++) {
|
|
81338
|
-
let mv = 0;
|
|
81339
|
-
let pv = -1;
|
|
81340
|
-
const start = j * 32;
|
|
81341
|
-
const vlen = Math.min(32, m) + start;
|
|
81342
|
-
for (let k = start; k < vlen; k++) {
|
|
81343
|
-
peq[b.charCodeAt(k)] |= 1 << k;
|
|
81344
|
-
}
|
|
81345
|
-
for (let i = 0; i < n; i++) {
|
|
81346
|
-
const eq = peq[a.charCodeAt(i)];
|
|
81347
|
-
const pb = (phc[(i / 32) | 0] >>> i) & 1;
|
|
81348
|
-
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
|
|
81349
|
-
const xv = eq | mv;
|
|
81350
|
-
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
|
|
81351
|
-
let ph = mv | ~(xh | pv);
|
|
81352
|
-
let mh = pv & xh;
|
|
81353
|
-
if ((ph >>> 31) ^ pb) {
|
|
81354
|
-
phc[(i / 32) | 0] ^= 1 << i;
|
|
81355
|
-
}
|
|
81356
|
-
if ((mh >>> 31) ^ mb) {
|
|
81357
|
-
mhc[(i / 32) | 0] ^= 1 << i;
|
|
81358
|
-
}
|
|
81359
|
-
ph = (ph << 1) | pb;
|
|
81360
|
-
mh = (mh << 1) | mb;
|
|
81361
|
-
pv = mh | ~(xv | ph);
|
|
81362
|
-
mv = ph & xv;
|
|
81363
|
-
}
|
|
81364
|
-
for (let k = start; k < vlen; k++) {
|
|
81365
|
-
peq[b.charCodeAt(k)] = 0;
|
|
81366
|
-
}
|
|
81367
|
-
}
|
|
81368
|
-
let mv = 0;
|
|
81369
|
-
let pv = -1;
|
|
81370
|
-
const start = j * 32;
|
|
81371
|
-
const vlen = Math.min(32, m - start) + start;
|
|
81372
|
-
for (let k = start; k < vlen; k++) {
|
|
81373
|
-
peq[b.charCodeAt(k)] |= 1 << k;
|
|
81374
|
-
}
|
|
81375
|
-
let score = m;
|
|
81376
|
-
for (let i = 0; i < n; i++) {
|
|
81377
|
-
const eq = peq[a.charCodeAt(i)];
|
|
81378
|
-
const pb = (phc[(i / 32) | 0] >>> i) & 1;
|
|
81379
|
-
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
|
|
81380
|
-
const xv = eq | mv;
|
|
81381
|
-
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
|
|
81382
|
-
let ph = mv | ~(xh | pv);
|
|
81383
|
-
let mh = pv & xh;
|
|
81384
|
-
score += (ph >>> (m - 1)) & 1;
|
|
81385
|
-
score -= (mh >>> (m - 1)) & 1;
|
|
81386
|
-
if ((ph >>> 31) ^ pb) {
|
|
81387
|
-
phc[(i / 32) | 0] ^= 1 << i;
|
|
81388
|
-
}
|
|
81389
|
-
if ((mh >>> 31) ^ mb) {
|
|
81390
|
-
mhc[(i / 32) | 0] ^= 1 << i;
|
|
81391
|
-
}
|
|
81392
|
-
ph = (ph << 1) | pb;
|
|
81393
|
-
mh = (mh << 1) | mb;
|
|
81394
|
-
pv = mh | ~(xv | ph);
|
|
81395
|
-
mv = ph & xv;
|
|
81396
|
-
}
|
|
81397
|
-
for (let k = start; k < vlen; k++) {
|
|
81398
|
-
peq[b.charCodeAt(k)] = 0;
|
|
81399
|
-
}
|
|
81400
|
-
return score;
|
|
81401
|
-
};
|
|
81402
|
-
const distance = (a, b) => {
|
|
81403
|
-
if (a.length < b.length) {
|
|
81404
|
-
const tmp = b;
|
|
81405
|
-
b = a;
|
|
81406
|
-
a = tmp;
|
|
81407
|
-
}
|
|
81408
|
-
if (b.length === 0) {
|
|
81409
|
-
return a.length;
|
|
81410
|
-
}
|
|
81411
|
-
if (a.length <= 32) {
|
|
81412
|
-
return myers_32(a, b);
|
|
81413
|
-
}
|
|
81414
|
-
return myers_x(a, b);
|
|
81415
|
-
};
|
|
81416
|
-
|
|
81417
81297
|
class Token {
|
|
81418
81298
|
/**
|
|
81419
81299
|
* @template V,T
|
|
@@ -82324,6 +82204,161 @@ function seedVariablesIntoTemplateString(template, seed) {
|
|
|
82324
82204
|
return result;
|
|
82325
82205
|
}
|
|
82326
82206
|
|
|
82207
|
+
/**
|
|
82208
|
+
* Calculate the Jaro-Winkler distance between two strings
|
|
82209
|
+
* @param {string} first The string to compare
|
|
82210
|
+
* @param {string} second The string to compare with
|
|
82211
|
+
* @returns {number} similarity score, higher value means strings are more similar
|
|
82212
|
+
*/
|
|
82213
|
+
function string_jaro_winkler(first, second) {
|
|
82214
|
+
const l1 = first.length;
|
|
82215
|
+
const l2 = second.length;
|
|
82216
|
+
|
|
82217
|
+
if (l1 === 0 && l2 === 0) {
|
|
82218
|
+
// special case for empty string
|
|
82219
|
+
return 1;
|
|
82220
|
+
}
|
|
82221
|
+
|
|
82222
|
+
const matches1 = BitSet.fixedSize(l1);
|
|
82223
|
+
const matches2 = BitSet.fixedSize(l2);
|
|
82224
|
+
|
|
82225
|
+
const matches = getMatching(first, second, matches1, matches2);
|
|
82226
|
+
|
|
82227
|
+
if (matches <= 0) {
|
|
82228
|
+
return 0;
|
|
82229
|
+
}
|
|
82230
|
+
|
|
82231
|
+
// Calculate the Jaro distance:
|
|
82232
|
+
const transpositions = getTranspositions(first, second, matches1, matches2);
|
|
82233
|
+
const similarity = (matches / l1 + matches / l2 + (matches - transpositions) / matches) / 3;
|
|
82234
|
+
|
|
82235
|
+
// Transform to Jaro-Winkler:
|
|
82236
|
+
// Prefix scale gives more favorable ratings to strings that share common prefixes:
|
|
82237
|
+
const prefix_scale = 0.1;
|
|
82238
|
+
const prefix = getPrefix(first, second, min3(l1, l2, 4));
|
|
82239
|
+
return similarity + prefix * prefix_scale * (1 - similarity);
|
|
82240
|
+
}
|
|
82241
|
+
|
|
82242
|
+
/**
|
|
82243
|
+
* Find matching characters in both strings according to Jaro algorithm
|
|
82244
|
+
* @param {string} a1
|
|
82245
|
+
* @param {string} a2
|
|
82246
|
+
* @param {BitSet} matches1
|
|
82247
|
+
* @param {BitSet} matches2
|
|
82248
|
+
* @return {number}
|
|
82249
|
+
*/
|
|
82250
|
+
function getMatching(a1, a2, matches1, matches2) {
|
|
82251
|
+
const a1_length = a1.length;
|
|
82252
|
+
const a2_length = a2.length;
|
|
82253
|
+
|
|
82254
|
+
// Window is modified to work with string of length 1
|
|
82255
|
+
const matchWindow = max2(
|
|
82256
|
+
0,
|
|
82257
|
+
Math.floor(max2(a1_length, a2_length) * 0.5) - 1
|
|
82258
|
+
);
|
|
82259
|
+
|
|
82260
|
+
let matches = 0;
|
|
82261
|
+
|
|
82262
|
+
// Loop to find matched characters:
|
|
82263
|
+
for (let index1 = 0; index1 < a1_length; index1++) {
|
|
82264
|
+
|
|
82265
|
+
// Use the highest of the window diff and the min of the window and string 2 length:
|
|
82266
|
+
const start = max2(0, index1 - matchWindow);
|
|
82267
|
+
const end = min2(index1 + matchWindow + 1, a2_length);
|
|
82268
|
+
|
|
82269
|
+
// Iterate second string index:
|
|
82270
|
+
for (let index2 = start; index2 < end; index2++) {
|
|
82271
|
+
|
|
82272
|
+
// If second string character already matched, skip:
|
|
82273
|
+
if (matches2.get(index2)) {
|
|
82274
|
+
continue;
|
|
82275
|
+
}
|
|
82276
|
+
|
|
82277
|
+
// If the characters don't match, skip:
|
|
82278
|
+
if (a1.charAt(index1) !== a2.charAt(index2)) {
|
|
82279
|
+
continue;
|
|
82280
|
+
}
|
|
82281
|
+
|
|
82282
|
+
// Assume match if the above 2 checks don't continue:
|
|
82283
|
+
matches1.set(index1, true);
|
|
82284
|
+
matches2.set(index2, true);
|
|
82285
|
+
|
|
82286
|
+
// Add matches by 1, break inner loop:
|
|
82287
|
+
++matches;
|
|
82288
|
+
break;
|
|
82289
|
+
}
|
|
82290
|
+
}
|
|
82291
|
+
|
|
82292
|
+
return matches;
|
|
82293
|
+
}
|
|
82294
|
+
|
|
82295
|
+
/**
|
|
82296
|
+
* Calculate the number of transpositions between the two words
|
|
82297
|
+
* @param {string} a1 The first string to compare
|
|
82298
|
+
* @param {string} a2 The second string to compare
|
|
82299
|
+
* @param {BitSet} matches1
|
|
82300
|
+
* @param {BitSet} matches2
|
|
82301
|
+
*/
|
|
82302
|
+
function getTranspositions(a1, a2, matches1, matches2) {
|
|
82303
|
+
let transpositions = 0;
|
|
82304
|
+
|
|
82305
|
+
// Loop to find transpositions:
|
|
82306
|
+
const a1_length = a1.length;
|
|
82307
|
+
const a2_length = a2.length;
|
|
82308
|
+
|
|
82309
|
+
for (let i1 = 0, i2 = 0; i1 < a1_length; i1++) {
|
|
82310
|
+
// If a non-matching character was found, skip:
|
|
82311
|
+
if (matches1.get(i1) === false) {
|
|
82312
|
+
continue;
|
|
82313
|
+
}
|
|
82314
|
+
|
|
82315
|
+
// Move i2 index to the next match:
|
|
82316
|
+
while (
|
|
82317
|
+
i2 < a2_length
|
|
82318
|
+
&& matches2.get(i2) === false
|
|
82319
|
+
) {
|
|
82320
|
+
i2++;
|
|
82321
|
+
}
|
|
82322
|
+
|
|
82323
|
+
// If the characters don't match, increase transposition:
|
|
82324
|
+
if (a1.charAt(i1) !== a2.charAt(i2)) {
|
|
82325
|
+
transpositions++;
|
|
82326
|
+
}
|
|
82327
|
+
|
|
82328
|
+
// Iterate i2 index normally:
|
|
82329
|
+
i2++;
|
|
82330
|
+
}
|
|
82331
|
+
|
|
82332
|
+
return Math.floor(transpositions * 0.5);
|
|
82333
|
+
}
|
|
82334
|
+
|
|
82335
|
+
/**
|
|
82336
|
+
* Counts the number of common characters at the beginning
|
|
82337
|
+
* of each word up to a maximum of 4
|
|
82338
|
+
* @param {string} a1 The first string to compare
|
|
82339
|
+
* @param {string} a2 The second string to compare
|
|
82340
|
+
* @param {number} character_limit
|
|
82341
|
+
* @returns {number}
|
|
82342
|
+
*/
|
|
82343
|
+
function getPrefix(a1, a2, character_limit) {
|
|
82344
|
+
|
|
82345
|
+
let p = 0;
|
|
82346
|
+
|
|
82347
|
+
for (; p < character_limit; p++) {
|
|
82348
|
+
if (a1.charAt(p) !== a2.charAt(p)) {
|
|
82349
|
+
return p;
|
|
82350
|
+
}
|
|
82351
|
+
}
|
|
82352
|
+
|
|
82353
|
+
return ++p;
|
|
82354
|
+
}
|
|
82355
|
+
|
|
82356
|
+
/**
|
|
82357
|
+
* Higher value means string are more similar
|
|
82358
|
+
* @type {(function(string, string): number)}
|
|
82359
|
+
*/
|
|
82360
|
+
const string_compute_similarity = string_jaro_winkler;
|
|
82361
|
+
|
|
82327
82362
|
/**
|
|
82328
82363
|
* Represents information about a language
|
|
82329
82364
|
*/
|
|
@@ -82529,7 +82564,7 @@ class Localization {
|
|
|
82529
82564
|
* @param {number} value
|
|
82530
82565
|
*/
|
|
82531
82566
|
formatIntegerByThousands(value) {
|
|
82532
|
-
const formatter = new Intl.NumberFormat(this.locale.getValue(), {useGrouping: true});
|
|
82567
|
+
const formatter = new Intl.NumberFormat(this.locale.getValue(), { useGrouping: true });
|
|
82533
82568
|
|
|
82534
82569
|
return formatter.format(value);
|
|
82535
82570
|
}
|
|
@@ -82549,10 +82584,10 @@ class Localization {
|
|
|
82549
82584
|
|
|
82550
82585
|
//try to find similar keys
|
|
82551
82586
|
const similarities = Object.keys(this.json).map(function (key) {
|
|
82552
|
-
const distance
|
|
82587
|
+
const distance = string_compute_similarity(key, id);
|
|
82553
82588
|
return {
|
|
82554
82589
|
key,
|
|
82555
|
-
distance
|
|
82590
|
+
distance
|
|
82556
82591
|
};
|
|
82557
82592
|
});
|
|
82558
82593
|
|
|
@@ -114510,7 +114545,7 @@ class StorageAchievementGateway extends AchievementGateway {
|
|
|
114510
114545
|
* If multiple elements with the same highest score exist, the result will be first such encountered element
|
|
114511
114546
|
* @template T
|
|
114512
114547
|
* @param {T[]} array
|
|
114513
|
-
* @param {function(T):number} scoreFunction
|
|
114548
|
+
* @param {function(el:T, index:number):number} scoreFunction
|
|
114514
114549
|
* @returns {T|undefined}
|
|
114515
114550
|
*/
|
|
114516
114551
|
function arrayPickBestElement(array, scoreFunction) {
|
|
@@ -114526,13 +114561,13 @@ function arrayPickBestElement(array, scoreFunction) {
|
|
|
114526
114561
|
|
|
114527
114562
|
bestElement = array[0];
|
|
114528
114563
|
|
|
114529
|
-
bestScore = scoreFunction(bestElement);
|
|
114564
|
+
bestScore = scoreFunction(bestElement, 0);
|
|
114530
114565
|
|
|
114531
114566
|
for (let i = 1; i < size; i++) {
|
|
114532
114567
|
const el = array[i];
|
|
114533
114568
|
|
|
114534
114569
|
// compute score
|
|
114535
|
-
const score = scoreFunction(el);
|
|
114570
|
+
const score = scoreFunction(el, i);
|
|
114536
114571
|
|
|
114537
114572
|
if (score > bestScore) {
|
|
114538
114573
|
bestScore = score;
|