@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.
- package/build/meep.cjs +214 -142
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +214 -142
- package/package.json +1 -2
- package/src/core/binary/BitSet.d.ts +2 -2
- package/src/core/binary/BitSet.d.ts.map +1 -1
- package/src/core/binary/BitSet.js +8 -5
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +14 -8
- package/src/core/graph/v2/Graph.d.ts.map +1 -1
- package/src/core/graph/v2/Graph.js +9 -0
- 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/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts +16 -0
- package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts.map +1 -0
- package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js +90 -0
- 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_distance.d.ts +10 -0
- package/src/core/primitives/strings/string_jaro_distance.d.ts.map +1 -0
- package/src/core/primitives/strings/string_jaro_distance.js +127 -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 +53 -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/ecs/path/testPathDisplaySystem.js +142 -10
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +9 -9
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +173 -23
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +16 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epsilonEquals.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/math/epsilonEquals.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { epsilonEquals } from "./epsilonEquals.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
|
|
5
|
+
expect(epsilonEquals(0, 0, 0)).toBe(true);
|
|
6
|
+
expect(epsilonEquals(0, 1, 0)).toBe(false);
|
|
7
|
+
expect(epsilonEquals(1, 0, 0)).toBe(false);
|
|
8
|
+
expect(epsilonEquals(-1, 0, 0)).toBe(false);
|
|
9
|
+
expect(epsilonEquals(-1, 1, 0)).toBe(false);
|
|
10
|
+
expect(epsilonEquals(1, -1, 0)).toBe(false);
|
|
11
|
+
|
|
12
|
+
expect(epsilonEquals(1, 1.1, 0)).toBe(false);
|
|
13
|
+
expect(epsilonEquals(1, 1, 0.1)).toBe(true);
|
|
14
|
+
expect(epsilonEquals(1, 1.09, 0.1)).toBe(true);
|
|
15
|
+
expect(epsilonEquals(1, 1.11, 0.1)).toBe(false);
|
|
16
|
+
|
|
17
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes derivative of Catmull Rom spline
|
|
3
|
+
* @param {number[]} result_value
|
|
4
|
+
* @param {number} result_value_offset
|
|
5
|
+
* @param {number[]} result_derivative
|
|
6
|
+
* @param {number} result_derivative_offset
|
|
7
|
+
* @param {number[]} p0 spline point 0
|
|
8
|
+
* @param {number[]} p1 spline point 1
|
|
9
|
+
* @param {number[]} p2 spline point 2
|
|
10
|
+
* @param {number[]} p3 spline point 3
|
|
11
|
+
* @param {number} dimensions number of dimensions in the input and output vectors
|
|
12
|
+
* @param {number} f between 0..1
|
|
13
|
+
* @param {number} alpha between 0..1
|
|
14
|
+
*/
|
|
15
|
+
export function computeNonuniformCaltmullRomSplineDerivative(result_value: number[], result_value_offset: number, result_derivative: number[], result_derivative_offset: number, p0: number[], p1: number[], p2: number[], p3: number[], dimensions: number, f: number, alpha: number): void;
|
|
16
|
+
//# sourceMappingURL=computeNonuniformCaltmullRomSplineDerivative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeNonuniformCaltmullRomSplineDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,2EAZW,MAAM,EAAE,uBACR,MAAM,qBACN,MAAM,EAAE,4BACR,MAAM,MACN,MAAM,EAAE,MACR,MAAM,EAAE,MACR,MAAM,EAAE,MACR,MAAM,EAAE,cACR,MAAM,KACN,MAAM,SACN,MAAM,QA2EhB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { catmull_rom_compute_T } from "./catmull_rom_compute_T.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Computes derivative of Catmull Rom spline
|
|
5
|
+
* @param {number[]} result_value
|
|
6
|
+
* @param {number} result_value_offset
|
|
7
|
+
* @param {number[]} result_derivative
|
|
8
|
+
* @param {number} result_derivative_offset
|
|
9
|
+
* @param {number[]} p0 spline point 0
|
|
10
|
+
* @param {number[]} p1 spline point 1
|
|
11
|
+
* @param {number[]} p2 spline point 2
|
|
12
|
+
* @param {number[]} p3 spline point 3
|
|
13
|
+
* @param {number} dimensions number of dimensions in the input and output vectors
|
|
14
|
+
* @param {number} f between 0..1
|
|
15
|
+
* @param {number} alpha between 0..1
|
|
16
|
+
*/
|
|
17
|
+
export function computeNonuniformCaltmullRomSplineDerivative(
|
|
18
|
+
result_value, result_value_offset,
|
|
19
|
+
result_derivative, result_derivative_offset,
|
|
20
|
+
p0, p1, p2, p3,
|
|
21
|
+
dimensions, f, alpha
|
|
22
|
+
) {
|
|
23
|
+
/*
|
|
24
|
+
@see https://math.stackexchange.com/questions/843595/how-can-i-calculate-the-derivative-of-a-catmull-rom-spline-with-nonuniform-param
|
|
25
|
+
@see http://denkovacs.com/2016/02/catmull-rom-spline-derivatives/
|
|
26
|
+
@see https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const half_alpha = alpha * 0.5;
|
|
30
|
+
|
|
31
|
+
// calculate T
|
|
32
|
+
const t0 = 0;
|
|
33
|
+
let t_01 = catmull_rom_compute_T(p0, p1, dimensions, half_alpha);
|
|
34
|
+
let t_02 = catmull_rom_compute_T(p1, p2, dimensions, half_alpha);
|
|
35
|
+
let t_03 = catmull_rom_compute_T(p2, p3, dimensions, half_alpha);
|
|
36
|
+
|
|
37
|
+
// safety check for repeated points, to prevent division by 0
|
|
38
|
+
if (t_01 < 1e-4) {
|
|
39
|
+
t_01 = 1;
|
|
40
|
+
}
|
|
41
|
+
if (t_02 < 1e-4) {
|
|
42
|
+
t_02 = t_01;
|
|
43
|
+
}
|
|
44
|
+
if (t_03 < 1e-4) {
|
|
45
|
+
t_03 = t_02;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const t1 = t_01 + t0;
|
|
49
|
+
const t2 = t_02 + t1;
|
|
50
|
+
const t3 = t_03 + t2;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Interpolation between points 1 and 2
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
const t = t1 * (1 - f) + t2 * f;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < dimensions; i++) {
|
|
59
|
+
// read vector values for the dimension
|
|
60
|
+
const v0 = p0[i];
|
|
61
|
+
const v1 = p1[i];
|
|
62
|
+
const v2 = p2[i];
|
|
63
|
+
const v3 = p3[i];
|
|
64
|
+
|
|
65
|
+
const A1 = (t1 - t) / (t1 - t0) * v0 + (t - t0) / (t1 - t0) * v1;
|
|
66
|
+
const A2 = (t2 - t) / (t2 - t1) * v1 + (t - t1) / (t2 - t1) * v2;
|
|
67
|
+
const A3 = (t3 - t) / (t3 - t2) * v2 + (t - t2) / (t3 - t2) * v3;
|
|
68
|
+
|
|
69
|
+
const B1 = (t2 - t) / (t2 - t0) * A1 + (t - t0) / (t2 - t0) * A2;
|
|
70
|
+
const B2 = (t3 - t) / (t3 - t1) * A2 + (t - t1) / (t3 - t1) * A3;
|
|
71
|
+
|
|
72
|
+
const C = (t2 - t) / (t2 - t1) * B1 + (t - t1) / (t2 - t1) * B2;
|
|
73
|
+
|
|
74
|
+
result_value[result_value_offset + i] = C;
|
|
75
|
+
|
|
76
|
+
// derivatives
|
|
77
|
+
|
|
78
|
+
const dA1 = (v1 - v0) / (t1 - t0)
|
|
79
|
+
const dA2 = (v2 - v1) / (t2 - t1);
|
|
80
|
+
const dA3 = (v3 - v2) / (t3 - t2);
|
|
81
|
+
|
|
82
|
+
const dB1 = (A2 - A1) / (t2 - t0) + dA1 * (t2 - t) / (t2 - t0) + dA2 * (t - t0) / (t2 - t0);
|
|
83
|
+
const dB2 = (A3 - A2) / (t3 - t1) + dA2 * (t3 - t) / (t3 - t1) + dA3 * (t - t1) / (t3 - t1);
|
|
84
|
+
|
|
85
|
+
const dC = (B2 - B1) / (t2 - t1) + dB1 * (t2 - t) / (t2 - t1) + dB2 * (t - t1) / (t2 - t1);
|
|
86
|
+
|
|
87
|
+
result_derivative[result_derivative_offset + i] = dC;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_compute_similarity.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/strings/string_compute_similarity.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wCAFU,QAAU,MAAM,QAAE,MAAM,KAAG,MAAM,CAAC,CAEiB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate Jaro distance between two strings, this is a measure of string similarity. Higher value means more similarity.
|
|
3
|
+
* @param {string} first
|
|
4
|
+
* @param {string} second
|
|
5
|
+
* @param {number} first_length
|
|
6
|
+
* @param {number} second_length
|
|
7
|
+
* @return {number}
|
|
8
|
+
*/
|
|
9
|
+
export function string_jaro_distance(first: string, second: string, first_length: number, second_length: number): number;
|
|
10
|
+
//# sourceMappingURL=string_jaro_distance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_jaro_distance.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/strings/string_jaro_distance.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,4CANW,MAAM,UACN,MAAM,gBACN,MAAM,iBACN,MAAM,GACL,MAAM,CAmBjB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BitSet } from "../../binary/BitSet.js";
|
|
2
|
+
import { max2 } from "../../math/max2.js";
|
|
3
|
+
import { min2 } from "../../math/min2.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calculate Jaro distance between two strings, this is a measure of string similarity. Higher value means more similarity.
|
|
7
|
+
* @param {string} first
|
|
8
|
+
* @param {string} second
|
|
9
|
+
* @param {number} first_length
|
|
10
|
+
* @param {number} second_length
|
|
11
|
+
* @return {number}
|
|
12
|
+
*/
|
|
13
|
+
export function string_jaro_distance(
|
|
14
|
+
first, second,
|
|
15
|
+
first_length, second_length
|
|
16
|
+
) {
|
|
17
|
+
|
|
18
|
+
const matches1 = BitSet.fixedSize(first_length);
|
|
19
|
+
const matches2 = BitSet.fixedSize(second_length);
|
|
20
|
+
|
|
21
|
+
const matches = getMatching(first, second, matches1, matches2);
|
|
22
|
+
|
|
23
|
+
if (matches <= 0) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const transpositions = getTranspositions(first, second, matches1, matches2);
|
|
28
|
+
return (matches / first_length + matches / second_length + (matches - transpositions) / matches) / 3;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Find matching characters in both strings according to Jaro algorithm
|
|
34
|
+
* @param {string} a1
|
|
35
|
+
* @param {string} a2
|
|
36
|
+
* @param {BitSet} matches1
|
|
37
|
+
* @param {BitSet} matches2
|
|
38
|
+
* @return {number}
|
|
39
|
+
*/
|
|
40
|
+
function getMatching(a1, a2, matches1, matches2) {
|
|
41
|
+
const a1_length = a1.length;
|
|
42
|
+
const a2_length = a2.length;
|
|
43
|
+
|
|
44
|
+
// Window is modified to work with string of length 1
|
|
45
|
+
const matchWindow = max2(
|
|
46
|
+
0,
|
|
47
|
+
Math.floor(max2(a1_length, a2_length) * 0.5) - 1
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let matches = 0;
|
|
51
|
+
|
|
52
|
+
// Loop to find matched characters:
|
|
53
|
+
for (let index1 = 0; index1 < a1_length; index1++) {
|
|
54
|
+
|
|
55
|
+
// Use the highest of the window diff and the min of the window and string 2 length:
|
|
56
|
+
const start = max2(0, index1 - matchWindow);
|
|
57
|
+
const end = min2(index1 + matchWindow + 1, a2_length);
|
|
58
|
+
|
|
59
|
+
// Iterate second string index:
|
|
60
|
+
for (let index2 = start; index2 < end; index2++) {
|
|
61
|
+
|
|
62
|
+
// If second string character already matched, skip:
|
|
63
|
+
if (matches2.get(index2)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If the characters don't match, skip:
|
|
68
|
+
if (a1.charAt(index1) !== a2.charAt(index2)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Assume match if the above 2 checks don't continue:
|
|
73
|
+
matches1.set(index1, true);
|
|
74
|
+
matches2.set(index2, true);
|
|
75
|
+
|
|
76
|
+
// Add matches by 1, break inner loop:
|
|
77
|
+
++matches;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return matches;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Calculate the number of transpositions between the two words
|
|
87
|
+
* @param {string} a1 The first string to compare
|
|
88
|
+
* @param {string} a2 The second string to compare
|
|
89
|
+
* @param {BitSet} matches1
|
|
90
|
+
* @param {BitSet} matches2
|
|
91
|
+
* @returns {number}
|
|
92
|
+
*/
|
|
93
|
+
function getTranspositions(
|
|
94
|
+
a1, a2,
|
|
95
|
+
matches1, matches2
|
|
96
|
+
) {
|
|
97
|
+
let transpositions = 0;
|
|
98
|
+
|
|
99
|
+
// Loop to find transpositions:
|
|
100
|
+
const a1_length = a1.length;
|
|
101
|
+
const a2_length = a2.length;
|
|
102
|
+
|
|
103
|
+
for (let i1 = 0, i2 = 0; i1 < a1_length; i1++) {
|
|
104
|
+
// If a non-matching character was found, skip:
|
|
105
|
+
if (matches1.get(i1) === false) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Move i2 index to the next match:
|
|
110
|
+
while (
|
|
111
|
+
i2 < a2_length
|
|
112
|
+
&& matches2.get(i2) === false
|
|
113
|
+
) {
|
|
114
|
+
i2++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// If the characters don't match, increase transposition:
|
|
118
|
+
if (a1.charAt(i1) !== a2.charAt(i2)) {
|
|
119
|
+
transpositions++;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Iterate i2 index normally:
|
|
123
|
+
i2++;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return Math.floor(transpositions * 0.5);
|
|
127
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the Jaro-Winkler distance between two strings
|
|
3
|
+
* @param {string} first The string to compare
|
|
4
|
+
* @param {string} second The string to compare with
|
|
5
|
+
* @returns {number} similarity score, higher value means strings are more similar
|
|
6
|
+
*/
|
|
7
|
+
export function string_jaro_winkler(first: string, second: string): number;
|
|
8
|
+
//# sourceMappingURL=string_jaro_winkler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_jaro_winkler.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/strings/string_jaro_winkler.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,2CAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAwBlB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { min3 } from "../../math/min3.js";
|
|
2
|
+
import { string_jaro_distance } from "./string_jaro_distance.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Calculate the Jaro-Winkler distance between two strings
|
|
6
|
+
* @param {string} first The string to compare
|
|
7
|
+
* @param {string} second The string to compare with
|
|
8
|
+
* @returns {number} similarity score, higher value means strings are more similar
|
|
9
|
+
*/
|
|
10
|
+
export function string_jaro_winkler(first, second) {
|
|
11
|
+
const l1 = first.length;
|
|
12
|
+
const l2 = second.length;
|
|
13
|
+
|
|
14
|
+
if (l1 === 0 && l2 === 0) {
|
|
15
|
+
// special case for empty string
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Calculate the Jaro distance:
|
|
20
|
+
const similarity = string_jaro_distance(first, second, l1, l2);
|
|
21
|
+
|
|
22
|
+
if (similarity === 0) {
|
|
23
|
+
// no similarity at all
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Transform to Jaro-Winkler:
|
|
28
|
+
// Prefix scale gives more favorable ratings to strings that share common prefixes:
|
|
29
|
+
const prefix_scale = 0.1;
|
|
30
|
+
const prefix = getPrefix(first, second, min3(l1, l2, 4));
|
|
31
|
+
return similarity + prefix * prefix_scale * (1 - similarity);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Counts the number of common characters at the beginning
|
|
36
|
+
* of each word up to a maximum of 4
|
|
37
|
+
* @param {string} a1 The first string to compare
|
|
38
|
+
* @param {string} a2 The second string to compare
|
|
39
|
+
* @param {number} character_limit
|
|
40
|
+
* @returns {number}
|
|
41
|
+
*/
|
|
42
|
+
function getPrefix(a1, a2, character_limit) {
|
|
43
|
+
|
|
44
|
+
let p = 0;
|
|
45
|
+
|
|
46
|
+
for (; p < character_limit; p++) {
|
|
47
|
+
if (a1.charAt(p) !== a2.charAt(p)) {
|
|
48
|
+
return p;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return ++p;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_jaro_winkler.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/strings/string_jaro_winkler.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { string_jaro_winkler } from "./string_jaro_winkler.js";
|
|
2
|
+
|
|
3
|
+
test("empty strings", () => {
|
|
4
|
+
|
|
5
|
+
expect(string_jaro_winkler("", "")).toBe(1)
|
|
6
|
+
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("whitespace", () => {
|
|
10
|
+
expect(string_jaro_winkler(" ", " ")).toBe(1);
|
|
11
|
+
|
|
12
|
+
expect(string_jaro_winkler("\n", "\n")).toBe(1);
|
|
13
|
+
expect(string_jaro_winkler("\t", "\t")).toBe(1);
|
|
14
|
+
|
|
15
|
+
expect(string_jaro_winkler(" ", " ")).toBeGreaterThan(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("negative cases", () => {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
expect(string_jaro_winkler("a", "")).toBe(0);
|
|
22
|
+
expect(string_jaro_winkler("", "a")).toBe(0);
|
|
23
|
+
|
|
24
|
+
expect(string_jaro_winkler("a", "b")).toBe(0);
|
|
25
|
+
expect(string_jaro_winkler("b", "a")).toBe(0);
|
|
26
|
+
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("known cases", () => {
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
expect(string_jaro_winkler("a", "a")).toBeCloseTo(1);
|
|
33
|
+
expect(string_jaro_winkler("aa", "aa")).toBeCloseTo(1);
|
|
34
|
+
expect(string_jaro_winkler("abc", "abc")).toBeCloseTo(1);
|
|
35
|
+
|
|
36
|
+
expect(string_jaro_winkler("DwAyNE", "DuANE")).toBeCloseTo(0.84);
|
|
37
|
+
expect(string_jaro_winkler("TRATE", "TRACE")).toBeCloseTo(0.906667);
|
|
38
|
+
|
|
39
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkeletonUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/mesh/SkeletonUtils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SkeletonUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/mesh/SkeletonUtils.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,2DAHW,MAAM,GACJ,UAAU,GAAG,IAAI,CAuC7B;AAiCD;;;;GAIG;AACH,mEAFa,WAAS,SAAS,CAgB9B;AAED;;;;;GAKG;AACH,qEAHW,yBAAuB,GACtB,IAAI,GAAC,IAAI,CAkCpB;AAED;;;;;GAKG;AACH,iEAHW,yBAAuB,GACrB,IAAI,GAAG,IAAI,CAUvB;AAGD;;;;;GAKG;AACH,0EAFa,IAAI,GAAG,IAAI,CA+BvB;AAID;;;;;GAKG;AACH,sEAFa,IAAI,GAAG,IAAI,CA8BvB;qBA1OoB,OAAO"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { distance as levenshtein_distance } from "fastest-levenshtein";
|
|
2
1
|
import { Bone } from "three";
|
|
3
|
-
import {
|
|
2
|
+
import { arrayPickBestElement } from "../../../../core/collection/array/arrayPickBestElement.js";
|
|
3
|
+
import { string_compute_similarity } from "../../../../core/primitives/strings/string_compute_similarity.js";
|
|
4
4
|
import { extractName } from "../../../../extractName.js";
|
|
5
|
+
import { BoneMapping } from "./skeleton/BoneMapping.js";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -42,20 +43,10 @@ export function getSkeletonBone(component, boneName) {
|
|
|
42
43
|
//bone not found
|
|
43
44
|
|
|
44
45
|
//try to find similar bones
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
bone: bone,
|
|
49
|
-
distance: distance
|
|
50
|
-
};
|
|
46
|
+
const bestMatch = arrayPickBestElement(bones, function (bone) {
|
|
47
|
+
return string_compute_similarity(bone.name, boneName);
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
similarities.sort(function (a, b) {
|
|
54
|
-
return a.distance - b.distance;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const bestMatch = similarities[0].bone;
|
|
58
|
-
|
|
59
50
|
throw new Error("Bone '" + boneName + "' not found, did you mean '" + bestMatch.name + "'");
|
|
60
51
|
}
|
|
61
52
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HumanoidBoneType } from "./HumanoidBoneType.js";
|
|
2
|
-
import { distance as levenshtein_distance } from "fastest-levenshtein";
|
|
3
1
|
import { assert } from "../../../../../core/assert.js";
|
|
4
2
|
import { string_compute_common_prefix } from "../../../../../core/primitives/strings/string_compute_common_prefix.js";
|
|
3
|
+
import { string_compute_similarity } from "../../../../../core/primitives/strings/string_compute_similarity.js";
|
|
4
|
+
import { HumanoidBoneType } from "./HumanoidBoneType.js";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -40,7 +40,7 @@ export class BoneMapping {
|
|
|
40
40
|
boneValues.forEach(function (boneName, boneIndex) {
|
|
41
41
|
|
|
42
42
|
conditionedNames.forEach(function (name, inputIndex) {
|
|
43
|
-
const distance =
|
|
43
|
+
const distance = string_compute_similarity(name, boneName);
|
|
44
44
|
const match = {
|
|
45
45
|
boneIndex,
|
|
46
46
|
inputIndex,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MeshStandardMaterial, OctahedronBufferGeometry } from "three";
|
|
1
2
|
import '../../../../../../../../css/game.scss';
|
|
2
3
|
import FacingDirectionSystem from "../../../../../../model/game/ecs/system/FacingDirectionSystem.js";
|
|
3
4
|
import { makeEngineOptionsModel } from "../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
@@ -47,6 +48,7 @@ import Highlight from "../highlight/Highlight.js";
|
|
|
47
48
|
import MeshHighlightSystem from "../highlight/system/MeshHighlightSystem.js";
|
|
48
49
|
import { ShadedGeometryHighlightSystem } from "../highlight/system/ShadedGeometryHighlightSystem.js";
|
|
49
50
|
import LightSystem from "../light/LightSystem.js";
|
|
51
|
+
import { ShadedGeometry } from "../mesh-v2/ShadedGeometry.js";
|
|
50
52
|
import { ShadedGeometrySystem } from "../mesh-v2/ShadedGeometrySystem.js";
|
|
51
53
|
import Mesh from "../mesh/Mesh.js";
|
|
52
54
|
import { MeshSystem } from "../mesh/MeshSystem.js";
|
|
@@ -412,7 +414,35 @@ function makePath({
|
|
|
412
414
|
return new Entity()
|
|
413
415
|
.add(_p)
|
|
414
416
|
.add(pathDisplay)
|
|
415
|
-
|
|
417
|
+
// .add(Highlight.fromOne(0, 1, 1, 1));
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
*
|
|
423
|
+
* @param {Path} path
|
|
424
|
+
* @param {EntityComponentDataset} ecd
|
|
425
|
+
*/
|
|
426
|
+
function drawControlPoints(path, ecd) {
|
|
427
|
+
|
|
428
|
+
const point_count = path.getPointCount();
|
|
429
|
+
|
|
430
|
+
const geo = new OctahedronBufferGeometry(1, 3);
|
|
431
|
+
const mat = new MeshStandardMaterial({});
|
|
432
|
+
|
|
433
|
+
for (let i = 0; i < point_count; i++) {
|
|
434
|
+
const t = new Transform();
|
|
435
|
+
|
|
436
|
+
t.scale.setScalar(0.4);
|
|
437
|
+
|
|
438
|
+
path.getPosition(i, t.position);
|
|
439
|
+
|
|
440
|
+
new Entity()
|
|
441
|
+
.add(t)
|
|
442
|
+
.add(ShadedGeometry.from(geo, mat))
|
|
443
|
+
.build(ecd)
|
|
444
|
+
}
|
|
445
|
+
|
|
416
446
|
|
|
417
447
|
}
|
|
418
448
|
|
|
@@ -424,18 +454,120 @@ function main(engine) {
|
|
|
424
454
|
const cam = ecd.getAnyComponent(Camera);
|
|
425
455
|
// cam.component.projectionType.set(ProjectionType.Orthographic);
|
|
426
456
|
|
|
457
|
+
const points = [
|
|
458
|
+
84,
|
|
459
|
+
20,
|
|
460
|
+
100,
|
|
461
|
+
68.36000061035156,
|
|
462
|
+
5.840000152587891,
|
|
463
|
+
31.1200008392334,
|
|
464
|
+
69.01000213623047,
|
|
465
|
+
8,
|
|
466
|
+
24.020000457763672,
|
|
467
|
+
88.19000244140625,
|
|
468
|
+
35,
|
|
469
|
+
22.729999542236328,
|
|
470
|
+
114.80999755859375,
|
|
471
|
+
35,
|
|
472
|
+
10.970000267028809,
|
|
473
|
+
71,
|
|
474
|
+
35,
|
|
475
|
+
-69.01000213623047,
|
|
476
|
+
-31.809999465942383,
|
|
477
|
+
25,
|
|
478
|
+
-27.850000381469727,
|
|
479
|
+
-11.130000114440918,
|
|
480
|
+
25,
|
|
481
|
+
30.770000457763672,
|
|
482
|
+
20.75,
|
|
483
|
+
25,
|
|
484
|
+
6.539999961853027,
|
|
485
|
+
13.0600004196167,
|
|
486
|
+
25,
|
|
487
|
+
-6.28000020980835,
|
|
488
|
+
7.75,
|
|
489
|
+
17.760000228881836,
|
|
490
|
+
14.109999656677246,
|
|
491
|
+
4.260000228881836,
|
|
492
|
+
10.529999732971191,
|
|
493
|
+
8.869999885559082,
|
|
494
|
+
-5.96999979019165,
|
|
495
|
+
8.079999923706055,
|
|
496
|
+
-2.180000066757202,
|
|
497
|
+
-5.369999885559082,
|
|
498
|
+
6.059999942779541,
|
|
499
|
+
-12.010000228881836,
|
|
500
|
+
-9.359999656677246,
|
|
501
|
+
6.059999942779541,
|
|
502
|
+
-12.369999885559082,
|
|
503
|
+
-10.579999923706055,
|
|
504
|
+
4.789999961853027,
|
|
505
|
+
-15.300000190734863,
|
|
506
|
+
-9.130000114440918,
|
|
507
|
+
4.639999866485596,
|
|
508
|
+
-16.350000381469727,
|
|
509
|
+
-9.119999885559082,
|
|
510
|
+
4.639999866485596,
|
|
511
|
+
-16.360000610351562,
|
|
512
|
+
-9.109999656677246,
|
|
513
|
+
4.639999866485596,
|
|
514
|
+
-16.360000610351562,
|
|
515
|
+
-9.100000381469727,
|
|
516
|
+
4.630000114440918,
|
|
517
|
+
-16.360000610351562,
|
|
518
|
+
-4.429999828338623,
|
|
519
|
+
5,
|
|
520
|
+
-9.720000267028809,
|
|
521
|
+
-7.309999942779541,
|
|
522
|
+
5,
|
|
523
|
+
6.059999942779541,
|
|
524
|
+
-4.170000076293945,
|
|
525
|
+
0.1599999964237213,
|
|
526
|
+
10.720000267028809,
|
|
527
|
+
-1.4600000381469727,
|
|
528
|
+
0.1599999964237213,
|
|
529
|
+
12.109999656677246,
|
|
530
|
+
-0.4399999976158142,
|
|
531
|
+
0.1599999964237213,
|
|
532
|
+
19.25,
|
|
533
|
+
0.5099999904632568,
|
|
534
|
+
0.1599999964237213,
|
|
535
|
+
21.65999984741211,
|
|
536
|
+
2,
|
|
537
|
+
0.1599999964237213,
|
|
538
|
+
21.56999969482422,
|
|
539
|
+
7.880000114440918,
|
|
540
|
+
2.859999895095825,
|
|
541
|
+
21.610000610351562,
|
|
542
|
+
12.039999961853027,
|
|
543
|
+
2.859999895095825,
|
|
544
|
+
21.860000610351562,
|
|
545
|
+
14.369999885559082,
|
|
546
|
+
3.2100000381469727,
|
|
547
|
+
21.760000228881836,
|
|
548
|
+
14.1899995803833,
|
|
549
|
+
4.440000057220459,
|
|
550
|
+
25.639999389648438,
|
|
551
|
+
14.130000114440918,
|
|
552
|
+
5.53000020980835,
|
|
553
|
+
29.149999618530273,
|
|
554
|
+
15.15999984741211,
|
|
555
|
+
7.159999847412109,
|
|
556
|
+
29.899999618530273,
|
|
557
|
+
19.540000915527344,
|
|
558
|
+
700,
|
|
559
|
+
51.060001373291016
|
|
560
|
+
];
|
|
561
|
+
|
|
427
562
|
makePath({
|
|
428
|
-
points:
|
|
429
|
-
|
|
430
|
-
3, 1, 3,
|
|
431
|
-
7, 1, 3,
|
|
432
|
-
7, 1, 7,
|
|
433
|
-
3, 1, 7,
|
|
434
|
-
3, 1, 8
|
|
435
|
-
],
|
|
436
|
-
interp: InterpolationType.Linear
|
|
563
|
+
points: points,
|
|
564
|
+
interp: InterpolationType.CatmullRom
|
|
437
565
|
}).build(ecd);
|
|
438
566
|
|
|
567
|
+
drawControlPoints(Path.fromJSON({
|
|
568
|
+
points
|
|
569
|
+
}), ecd);
|
|
570
|
+
|
|
439
571
|
makePath({
|
|
440
572
|
points: [
|
|
441
573
|
17.600000381469727, 3.2100000381469727, -16.34000015258789,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TubePathBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js"],"names":[],"mappings":"AAoFA;IAEQ;;;OAGG;IACH,OAFU,gBAAc,IAAI,CAEX;IAEjB;;;OAGG;IACH,MAFU,OAAK,IAAI,CAEH;IAEhB;;;OAGG;IACH,WAFU,kBAAgB,IAAI,CAET;IAErB;;;OAGG;IACH,cAFU,eAAa,IAAI,CAEH;IAG5B,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,yCAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,EAAE,QAyElB;CACJ;
|
|
1
|
+
{"version":3,"file":"TubePathBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js"],"names":[],"mappings":"AAoFA;IAEQ;;;OAGG;IACH,OAFU,gBAAc,IAAI,CAEX;IAEjB;;;OAGG;IACH,MAFU,OAAK,IAAI,CAEH;IAEhB;;;OAGG;IACH,WAFU,kBAAgB,IAAI,CAET;IAErB;;;OAGG;IACH,cAFU,eAAa,IAAI,CAEH;IAG5B,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,yCAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,EAAE,QAyElB;CACJ;mBAvMkB,8BAA8B"}
|