@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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BufferGeometry, MeshBasicMaterial, MeshMatcapMaterial, MeshStandardMaterial } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { assert } from "../../../../../../core/assert.js";
|
|
3
|
+
import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
|
|
4
|
+
import { GameAssetType } from "../../../../../asset/GameAssetType.js";
|
|
3
5
|
import Entity from "../../../../../ecs/Entity.js";
|
|
4
6
|
import { Transform } from "../../../../../ecs/transform/Transform.js";
|
|
5
|
-
import {
|
|
6
|
-
import { GameAssetType } from "../../../../../asset/GameAssetType.js";
|
|
7
|
-
import { build_geometry_linear } from "./build_geometry_linear.js";
|
|
8
|
-
import { build_geometry_catmullrom } from "./build_geometry_catmullrom.js";
|
|
7
|
+
import { InterpolationType } from "../../../../../navigation/ecs/components/InterpolationType.js";
|
|
9
8
|
import { ShadedGeometry } from "../../../mesh-v2/ShadedGeometry.js";
|
|
10
9
|
import { ShadedGeometryFlags } from "../../../mesh-v2/ShadedGeometryFlags.js";
|
|
11
|
-
import {
|
|
10
|
+
import { TubeMaterialType } from "../TubeMaterialType.js";
|
|
11
|
+
import { build_geometry_catmullrom } from "./build_geometry_catmullrom.js";
|
|
12
|
+
import { build_geometry_linear } from "./build_geometry_linear.js";
|
|
12
13
|
import { compute_smooth_profile_normals } from "./compute_smooth_profile_normals.js";
|
|
13
|
-
import {
|
|
14
|
-
import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
|
|
14
|
+
import { fix_shape_normal_order } from "./fix_shape_normal_order.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
@@ -61,7 +61,7 @@ function make_material(style, am) {
|
|
|
61
61
|
} else if (material_type === TubeMaterialType.Standard) {
|
|
62
62
|
material_def = new MeshStandardMaterial({
|
|
63
63
|
metalness: style.material.metalness,
|
|
64
|
-
roughness: style.material.roughness
|
|
64
|
+
roughness: style.material.roughness,
|
|
65
65
|
});
|
|
66
66
|
} else if (material_type === TubeMaterialType.Matcap) {
|
|
67
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"AAmFA;;;;;;;;;;GAUG;AACH,mFAPW,MAAM,EAAE,gBACR,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,EAAE,iBACR,MAAM,eACN,MAAM,GACL,MAAM,cAAc,CAoI/B"}
|
|
@@ -1,7 +1,85 @@
|
|
|
1
|
+
import { v3_dot } from "../../../../../../core/geom/vec3/v3_dot.js";
|
|
2
|
+
import { clamp } from "../../../../../../core/math/clamp.js";
|
|
3
|
+
import { max2 } from "../../../../../../core/math/max2.js";
|
|
4
|
+
import {
|
|
5
|
+
computeNonuniformCaltmullRomSplineDerivative
|
|
6
|
+
} from "../../../../../../core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js";
|
|
7
|
+
import { PathNormalType } from "../PathNormalType.js";
|
|
1
8
|
import { computeFrenetFrames } from "./computeFrenetFrames.js";
|
|
2
9
|
import { makeTubeGeometry } from "./makeTubeGeometry.js";
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const scratch_array_0 = [];
|
|
13
|
+
const scratch_array_1 = [];
|
|
14
|
+
const scratch_array_2 = [];
|
|
15
|
+
const scratch_array_3 = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {number[]} positions
|
|
20
|
+
* @param {number[]} derivatives
|
|
21
|
+
* @param {number} result_offset
|
|
22
|
+
* @param {Path} path
|
|
23
|
+
* @param {number} offset
|
|
24
|
+
*/
|
|
25
|
+
function sample_path(positions, derivatives, result_offset, path, offset) {
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (!path.find_index_and_normalized_distance(scratch_array_0, offset)) {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {number}
|
|
36
|
+
*/
|
|
37
|
+
const i1 = scratch_array_0[0];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
const t = scratch_array_0[1];
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const input_length = path.getPointCount();
|
|
47
|
+
|
|
48
|
+
const max_index = input_length - 1;
|
|
49
|
+
|
|
50
|
+
const i0 = clamp(i1 - 1, 0, max_index);
|
|
51
|
+
const i2 = clamp(i1 + 1, 0, max_index);
|
|
52
|
+
const i3 = clamp(i1 + 2, 0, max_index);
|
|
53
|
+
|
|
54
|
+
path.readPositionToArray(i0, scratch_array_0, 0);
|
|
55
|
+
path.readPositionToArray(i1, scratch_array_1, 0);
|
|
56
|
+
path.readPositionToArray(i2, scratch_array_2, 0);
|
|
57
|
+
path.readPositionToArray(i3, scratch_array_3, 0);
|
|
58
|
+
|
|
59
|
+
computeNonuniformCaltmullRomSplineDerivative(
|
|
60
|
+
positions, result_offset,
|
|
61
|
+
derivatives, result_offset,
|
|
62
|
+
scratch_array_0, scratch_array_1, scratch_array_2, scratch_array_3,
|
|
63
|
+
3, t, 0.5
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// normalize derivative
|
|
67
|
+
const dx = derivatives[result_offset];
|
|
68
|
+
const dy = derivatives[result_offset + 1];
|
|
69
|
+
const dz = derivatives[result_offset + 2];
|
|
70
|
+
|
|
71
|
+
const mag = Math.hypot(dx, dy, dz);
|
|
72
|
+
|
|
73
|
+
if (mag !== 0) {
|
|
74
|
+
const inv_mag = 1 / mag;
|
|
75
|
+
|
|
76
|
+
derivatives[result_offset] = dx * inv_mag;
|
|
77
|
+
derivatives[result_offset + 1] = dy * inv_mag;
|
|
78
|
+
derivatives[result_offset + 2] = dz * inv_mag;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return i1;
|
|
82
|
+
}
|
|
5
83
|
|
|
6
84
|
/**
|
|
7
85
|
*
|
|
@@ -25,51 +103,123 @@ export function build_geometry_catmullrom(
|
|
|
25
103
|
// resample curve
|
|
26
104
|
const total_points = Math.ceil(point_count * style.resolution);
|
|
27
105
|
|
|
28
|
-
const
|
|
106
|
+
const reference_step_size = 1 / max2(0.00001, style.resolution);
|
|
107
|
+
const reference_min_step_size = reference_step_size * 0.25;
|
|
29
108
|
|
|
30
|
-
|
|
109
|
+
let step_size = reference_step_size;
|
|
31
110
|
|
|
32
|
-
const
|
|
111
|
+
const path_length = path.length;
|
|
33
112
|
|
|
113
|
+
const sample_positions_f32 = [];
|
|
114
|
+
const sample_derivatives_f32 = [];
|
|
34
115
|
|
|
35
116
|
let added_points = 0;
|
|
36
|
-
let i;
|
|
37
117
|
|
|
38
118
|
// initial segment
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
119
|
+
let last_knot_index = sample_path(
|
|
120
|
+
sample_positions_f32,
|
|
121
|
+
sample_derivatives_f32,
|
|
122
|
+
added_points * 3,
|
|
123
|
+
path,
|
|
124
|
+
segment_start * path_length
|
|
125
|
+
);
|
|
42
126
|
|
|
43
127
|
added_points++;
|
|
44
128
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
129
|
+
let current_offset = segment_start * path_length;
|
|
130
|
+
|
|
131
|
+
let step_resized_direction = 0;
|
|
132
|
+
|
|
133
|
+
const absolute_end_offset = segment_end * path_length;
|
|
134
|
+
|
|
135
|
+
for (; current_offset < absolute_end_offset; current_offset += step_size) {
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
const point_address = added_points * 3;
|
|
139
|
+
|
|
140
|
+
const knot_index = sample_path(
|
|
141
|
+
sample_positions_f32,
|
|
142
|
+
sample_derivatives_f32,
|
|
143
|
+
point_address,
|
|
144
|
+
path,
|
|
145
|
+
current_offset
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// check difference with previous derivative
|
|
149
|
+
const previous_point_index = added_points - 1;
|
|
150
|
+
const previous_point_address = previous_point_index * 3;
|
|
151
|
+
|
|
152
|
+
// derivatives are basically normals, and dot product is has Cosine value of angle between two vectors
|
|
153
|
+
const dot = v3_dot(
|
|
154
|
+
sample_derivatives_f32[previous_point_address], sample_derivatives_f32[previous_point_address + 1], sample_derivatives_f32[previous_point_address + 2],
|
|
155
|
+
sample_derivatives_f32[point_address], sample_derivatives_f32[point_address + 1], sample_derivatives_f32[point_address + 2]
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// angular difference results in larger visual error for longer runs
|
|
159
|
+
const error_size = (1 - dot) * step_size;
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
(step_size > reference_min_step_size)
|
|
163
|
+
&& (
|
|
164
|
+
(
|
|
165
|
+
// check if we jumped over a knot, so that we can sample down to get closer to it
|
|
166
|
+
knot_index > last_knot_index
|
|
167
|
+
&& step_size > reference_min_step_size
|
|
168
|
+
)
|
|
169
|
+
|| (
|
|
170
|
+
error_size * 10 > reference_min_step_size
|
|
171
|
+
&& step_resized_direction <= 0
|
|
172
|
+
)
|
|
173
|
+
|| (
|
|
174
|
+
// check if we're getting too close to the end of the segment, this lets us create a nice end
|
|
175
|
+
current_offset + step_size > absolute_end_offset
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
) {
|
|
179
|
+
|
|
180
|
+
// step looks to be too large
|
|
181
|
+
current_offset -= step_size;
|
|
182
|
+
step_size *= 0.5;
|
|
183
|
+
step_resized_direction = -1;
|
|
184
|
+
continue; // retry
|
|
185
|
+
|
|
186
|
+
} else if (
|
|
187
|
+
error_size < 0.02
|
|
188
|
+
&& step_resized_direction >= 0
|
|
189
|
+
) {
|
|
190
|
+
|
|
191
|
+
// step looks to be too small
|
|
192
|
+
current_offset -= step_size;
|
|
193
|
+
step_size *= 2;
|
|
194
|
+
step_resized_direction = 1;
|
|
195
|
+
continue; // retry
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// reset adaptive step direction
|
|
200
|
+
step_resized_direction = 0;
|
|
201
|
+
// remember the last knot, so we know when we get to the end of the segment
|
|
202
|
+
last_knot_index = knot_index;
|
|
53
203
|
|
|
54
204
|
added_points++
|
|
55
205
|
}
|
|
56
206
|
|
|
57
|
-
if (
|
|
207
|
+
if ((absolute_end_offset - current_offset + step_size) > 0.0001) {
|
|
58
208
|
// end
|
|
59
209
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
point.writeToArray(points_f32, added_points * 3);
|
|
210
|
+
sample_path(sample_positions_f32, sample_derivatives_f32, added_points * 3, path, absolute_end_offset);
|
|
63
211
|
|
|
64
212
|
added_points++;
|
|
65
213
|
}
|
|
66
214
|
|
|
215
|
+
// console.log(`Total Points ${added_points}`) // DEBUG info
|
|
216
|
+
|
|
67
217
|
const normal_hint = style.path_normal_type === PathNormalType.FixedStart ? style.path_normal : undefined;
|
|
68
218
|
|
|
69
|
-
const frames = computeFrenetFrames(
|
|
219
|
+
const frames = computeFrenetFrames(sample_positions_f32, false, normal_hint);
|
|
70
220
|
|
|
71
221
|
return makeTubeGeometry(
|
|
72
|
-
|
|
222
|
+
sample_positions_f32, frames.normals, frames.binormals, frames.tangents,
|
|
73
223
|
shape, shape_normal, shape.length / 2, shape_transform, false, style.cap_type
|
|
74
224
|
);
|
|
75
225
|
}
|
|
@@ -2,7 +2,7 @@ import FacingDirectionSystem from "../../../../../../../model/game/ecs/system/Fa
|
|
|
2
2
|
import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
3
3
|
import { enableEditor } from "../../../../../../editor/enableEditor.js";
|
|
4
4
|
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
5
|
-
import {
|
|
5
|
+
import { clamp01 } from "../../../../../core/math/clamp01.js";
|
|
6
6
|
import { computeCatmullRomSpline } from "../../../../../core/math/spline/computeCatmullRomSpline.js";
|
|
7
7
|
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
8
8
|
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
@@ -64,6 +64,7 @@ import { PathDisplaySpec } from "../PathDisplaySpec.js";
|
|
|
64
64
|
import { PathDisplaySystem } from "../PathDisplaySystem.js";
|
|
65
65
|
import { PathDisplayType } from "../PathDisplayType.js";
|
|
66
66
|
import { RibbonPathStyle } from "../ribbon/RibbonPathStyle.js";
|
|
67
|
+
import { CapType } from "./CapType.js";
|
|
67
68
|
import { MatcapMaterialDefinition } from "./MatcapMaterialDefinition.js";
|
|
68
69
|
import { TubeMaterialType } from "./TubeMaterialType.js";
|
|
69
70
|
import { TubePathStyle } from "./TubePathStyle.js";
|
|
@@ -308,6 +309,8 @@ function sample_style_tube() {
|
|
|
308
309
|
style.material.texture = "data/textures/matcap/nidorx/3E2335_D36A1B_8E4A2E_2842A5.jpg";
|
|
309
310
|
|
|
310
311
|
style.width = 0.1;
|
|
312
|
+
style.resolution = 50;
|
|
313
|
+
style.cap_type = CapType.None;
|
|
311
314
|
|
|
312
315
|
style.path_mask = [
|
|
313
316
|
0, 1,
|
|
@@ -370,7 +373,18 @@ function main(engine) {
|
|
|
370
373
|
new Entity()
|
|
371
374
|
.add(BehaviorComponent.looping_function((delta) => {
|
|
372
375
|
time += delta * 0.01;
|
|
373
|
-
|
|
376
|
+
|
|
377
|
+
const segment_count = 23;
|
|
378
|
+
|
|
379
|
+
tube_style.path_mask = [];
|
|
380
|
+
for (let i = 0; i < segment_count; i++) {
|
|
381
|
+
const offset_start = (i / (segment_count - 1) + time) % 1;
|
|
382
|
+
const offset_end = offset_start + 1 / (segment_count * 1.5);
|
|
383
|
+
|
|
384
|
+
tube_style.path_mask.push(
|
|
385
|
+
clamp01(offset_start), clamp01(offset_end)
|
|
386
|
+
);
|
|
387
|
+
}
|
|
374
388
|
|
|
375
389
|
path_entity.sendEvent(PathEvents.Changed);
|
|
376
390
|
}))
|