@woosh/meep-engine 2.95.1 → 2.97.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.
Files changed (42) hide show
  1. package/build/meep.cjs +214 -142
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +214 -142
  4. package/package.json +1 -2
  5. package/src/core/binary/BitSet.d.ts +2 -2
  6. package/src/core/binary/BitSet.d.ts.map +1 -1
  7. package/src/core/binary/BitSet.js +8 -5
  8. package/src/core/geom/Quaternion.d.ts.map +1 -1
  9. package/src/core/geom/Quaternion.js +14 -8
  10. package/src/core/graph/v2/Graph.d.ts.map +1 -1
  11. package/src/core/graph/v2/Graph.js +9 -0
  12. package/src/core/localization/Localization.d.ts.map +1 -1
  13. package/src/core/localization/Localization.js +11 -11
  14. package/src/core/math/epsilonEquals.d.ts.map +1 -1
  15. package/src/core/math/epsilonEquals.js +1 -0
  16. package/src/core/math/epsilonEquals.spec.d.ts +2 -0
  17. package/src/core/math/epsilonEquals.spec.d.ts.map +1 -0
  18. package/src/core/math/epsilonEquals.spec.js +17 -0
  19. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts +16 -0
  20. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts.map +1 -0
  21. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js +90 -0
  22. package/src/core/primitives/strings/string_compute_similarity.d.ts +6 -0
  23. package/src/core/primitives/strings/string_compute_similarity.d.ts.map +1 -0
  24. package/src/core/primitives/strings/string_compute_similarity.js +7 -0
  25. package/src/core/primitives/strings/string_jaro_distance.d.ts +10 -0
  26. package/src/core/primitives/strings/string_jaro_distance.d.ts.map +1 -0
  27. package/src/core/primitives/strings/string_jaro_distance.js +127 -0
  28. package/src/core/primitives/strings/string_jaro_winkler.d.ts +8 -0
  29. package/src/core/primitives/strings/string_jaro_winkler.d.ts.map +1 -0
  30. package/src/core/primitives/strings/string_jaro_winkler.js +53 -0
  31. package/src/core/primitives/strings/string_jaro_winkler.spec.d.ts +2 -0
  32. package/src/core/primitives/strings/string_jaro_winkler.spec.d.ts.map +1 -0
  33. package/src/core/primitives/strings/string_jaro_winkler.spec.js +39 -0
  34. package/src/engine/graphics/ecs/mesh/SkeletonUtils.d.ts.map +1 -1
  35. package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +5 -14
  36. package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +3 -3
  37. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +142 -10
  38. package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.d.ts.map +1 -1
  39. package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +9 -9
  40. package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.d.ts.map +1 -1
  41. package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +173 -23
  42. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +16 -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 {Number} [x=0]
3175
- * @param {Number} [y=0]
3176
- * @param {Number} [z=0]
3177
- * @param {Number} [w=1]
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 {Number}
3184
+ * @type {number}
3185
3185
  */
3186
3186
  this.x = x;
3187
3187
  /**
3188
3188
  *
3189
- * @type {Number}
3189
+ * @type {number}
3190
3190
  */
3191
3191
  this.y = y;
3192
3192
  /**
3193
3193
  *
3194
- * @type {Number}
3194
+ * @type {number}
3195
3195
  */
3196
3196
  this.z = z;
3197
3197
  /**
3198
3198
  *
3199
- * @type {Number}
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() {
@@ -69968,13 +69974,15 @@ BitSet.prototype.setShrinkFactor = function (x) {
69968
69974
 
69969
69975
  /**
69970
69976
  *
69971
- * @param {number} numBits
69977
+ * @param {number} bit_count
69972
69978
  */
69973
- BitSet.prototype.setCapacity = function (numBits) {
69974
- if (this.__length > numBits) {
69975
- throw new Error(`Current length is greater than requested size`);
69979
+ BitSet.prototype.setCapacity = function (bit_count) {
69980
+
69981
+ if (this.__length > bit_count) {
69982
+ throw new Error(`Current length(=${this.__length}) is greater than requested size(=${bit_count})`);
69976
69983
  }
69977
- this.__resize(numBits);
69984
+
69985
+ this.__resize(bit_count);
69978
69986
  };
69979
69987
 
69980
69988
  /**
@@ -71486,8 +71494,17 @@ class Graph {
71486
71494
  */
71487
71495
  findPath(start, goal) {
71488
71496
  const start_node_container = this.__nodes.get(start);
71497
+
71498
+ if (start_node_container === undefined) {
71499
+ throw new Error(`Start node not found in the graph '${start}'`);
71500
+ }
71501
+
71489
71502
  const goal_node_container = this.__nodes.get(goal);
71490
71503
 
71504
+ if (goal_node_container === undefined) {
71505
+ throw new Error(`Goal node not found in the graph '${goal}'`);
71506
+ }
71507
+
71491
71508
  const open = new Set();
71492
71509
  open.add(start_node_container);
71493
71510
 
@@ -81288,132 +81305,6 @@ class Tag {
81288
81305
 
81289
81306
  Tag.typeName = "Tag";
81290
81307
 
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
81308
  class Token {
81418
81309
  /**
81419
81310
  * @template V,T
@@ -82324,6 +82215,187 @@ function seedVariablesIntoTemplateString(template, seed) {
82324
82215
  return result;
82325
82216
  }
82326
82217
 
82218
+ /**
82219
+ * Calculate Jaro distance between two strings, this is a measure of string similarity. Higher value means more similarity.
82220
+ * @param {string} first
82221
+ * @param {string} second
82222
+ * @param {number} first_length
82223
+ * @param {number} second_length
82224
+ * @return {number}
82225
+ */
82226
+ function string_jaro_distance(
82227
+ first, second,
82228
+ first_length, second_length
82229
+ ) {
82230
+
82231
+ const matches1 = BitSet.fixedSize(first_length);
82232
+ const matches2 = BitSet.fixedSize(second_length);
82233
+
82234
+ const matches = getMatching(first, second, matches1, matches2);
82235
+
82236
+ if (matches <= 0) {
82237
+ return 0;
82238
+ }
82239
+
82240
+ const transpositions = getTranspositions(first, second, matches1, matches2);
82241
+ return (matches / first_length + matches / second_length + (matches - transpositions) / matches) / 3;
82242
+
82243
+ }
82244
+
82245
+ /**
82246
+ * Find matching characters in both strings according to Jaro algorithm
82247
+ * @param {string} a1
82248
+ * @param {string} a2
82249
+ * @param {BitSet} matches1
82250
+ * @param {BitSet} matches2
82251
+ * @return {number}
82252
+ */
82253
+ function getMatching(a1, a2, matches1, matches2) {
82254
+ const a1_length = a1.length;
82255
+ const a2_length = a2.length;
82256
+
82257
+ // Window is modified to work with string of length 1
82258
+ const matchWindow = max2(
82259
+ 0,
82260
+ Math.floor(max2(a1_length, a2_length) * 0.5) - 1
82261
+ );
82262
+
82263
+ let matches = 0;
82264
+
82265
+ // Loop to find matched characters:
82266
+ for (let index1 = 0; index1 < a1_length; index1++) {
82267
+
82268
+ // Use the highest of the window diff and the min of the window and string 2 length:
82269
+ const start = max2(0, index1 - matchWindow);
82270
+ const end = min2(index1 + matchWindow + 1, a2_length);
82271
+
82272
+ // Iterate second string index:
82273
+ for (let index2 = start; index2 < end; index2++) {
82274
+
82275
+ // If second string character already matched, skip:
82276
+ if (matches2.get(index2)) {
82277
+ continue;
82278
+ }
82279
+
82280
+ // If the characters don't match, skip:
82281
+ if (a1.charAt(index1) !== a2.charAt(index2)) {
82282
+ continue;
82283
+ }
82284
+
82285
+ // Assume match if the above 2 checks don't continue:
82286
+ matches1.set(index1, true);
82287
+ matches2.set(index2, true);
82288
+
82289
+ // Add matches by 1, break inner loop:
82290
+ ++matches;
82291
+ break;
82292
+ }
82293
+ }
82294
+
82295
+ return matches;
82296
+ }
82297
+
82298
+ /**
82299
+ * Calculate the number of transpositions between the two words
82300
+ * @param {string} a1 The first string to compare
82301
+ * @param {string} a2 The second string to compare
82302
+ * @param {BitSet} matches1
82303
+ * @param {BitSet} matches2
82304
+ * @returns {number}
82305
+ */
82306
+ function getTranspositions(
82307
+ a1, a2,
82308
+ matches1, matches2
82309
+ ) {
82310
+ let transpositions = 0;
82311
+
82312
+ // Loop to find transpositions:
82313
+ const a1_length = a1.length;
82314
+ const a2_length = a2.length;
82315
+
82316
+ for (let i1 = 0, i2 = 0; i1 < a1_length; i1++) {
82317
+ // If a non-matching character was found, skip:
82318
+ if (matches1.get(i1) === false) {
82319
+ continue;
82320
+ }
82321
+
82322
+ // Move i2 index to the next match:
82323
+ while (
82324
+ i2 < a2_length
82325
+ && matches2.get(i2) === false
82326
+ ) {
82327
+ i2++;
82328
+ }
82329
+
82330
+ // If the characters don't match, increase transposition:
82331
+ if (a1.charAt(i1) !== a2.charAt(i2)) {
82332
+ transpositions++;
82333
+ }
82334
+
82335
+ // Iterate i2 index normally:
82336
+ i2++;
82337
+ }
82338
+
82339
+ return Math.floor(transpositions * 0.5);
82340
+ }
82341
+
82342
+ /**
82343
+ * Calculate the Jaro-Winkler distance between two strings
82344
+ * @param {string} first The string to compare
82345
+ * @param {string} second The string to compare with
82346
+ * @returns {number} similarity score, higher value means strings are more similar
82347
+ */
82348
+ function string_jaro_winkler(first, second) {
82349
+ const l1 = first.length;
82350
+ const l2 = second.length;
82351
+
82352
+ if (l1 === 0 && l2 === 0) {
82353
+ // special case for empty string
82354
+ return 1;
82355
+ }
82356
+
82357
+ // Calculate the Jaro distance:
82358
+ const similarity = string_jaro_distance(first, second, l1, l2);
82359
+
82360
+ if (similarity === 0) {
82361
+ // no similarity at all
82362
+ return 0;
82363
+ }
82364
+
82365
+ // Transform to Jaro-Winkler:
82366
+ // Prefix scale gives more favorable ratings to strings that share common prefixes:
82367
+ const prefix_scale = 0.1;
82368
+ const prefix = getPrefix(first, second, min3(l1, l2, 4));
82369
+ return similarity + prefix * prefix_scale * (1 - similarity);
82370
+ }
82371
+
82372
+ /**
82373
+ * Counts the number of common characters at the beginning
82374
+ * of each word up to a maximum of 4
82375
+ * @param {string} a1 The first string to compare
82376
+ * @param {string} a2 The second string to compare
82377
+ * @param {number} character_limit
82378
+ * @returns {number}
82379
+ */
82380
+ function getPrefix(a1, a2, character_limit) {
82381
+
82382
+ let p = 0;
82383
+
82384
+ for (; p < character_limit; p++) {
82385
+ if (a1.charAt(p) !== a2.charAt(p)) {
82386
+ return p;
82387
+ }
82388
+ }
82389
+
82390
+ return ++p;
82391
+ }
82392
+
82393
+ /**
82394
+ * Higher value means string are more similar
82395
+ * @type {(function(string, string): number)}
82396
+ */
82397
+ const string_compute_similarity = string_jaro_winkler;
82398
+
82327
82399
  /**
82328
82400
  * Represents information about a language
82329
82401
  */
@@ -82529,7 +82601,7 @@ class Localization {
82529
82601
  * @param {number} value
82530
82602
  */
82531
82603
  formatIntegerByThousands(value) {
82532
- const formatter = new Intl.NumberFormat(this.locale.getValue(), {useGrouping: true});
82604
+ const formatter = new Intl.NumberFormat(this.locale.getValue(), { useGrouping: true });
82533
82605
 
82534
82606
  return formatter.format(value);
82535
82607
  }
@@ -82549,10 +82621,10 @@ class Localization {
82549
82621
 
82550
82622
  //try to find similar keys
82551
82623
  const similarities = Object.keys(this.json).map(function (key) {
82552
- const distance$1 = distance(key, id);
82624
+ const distance = string_compute_similarity(key, id);
82553
82625
  return {
82554
82626
  key,
82555
- distance: distance$1
82627
+ distance
82556
82628
  };
82557
82629
  });
82558
82630