@woosh/meep-engine 2.49.8 → 2.50.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/editor/actions/concrete/ArrayCopyAction.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.js +1 -1
- package/src/core/binary/BinaryBuffer.spec.js +128 -0
- package/src/core/binary/int32_to_binary_string.js +4 -1
- package/src/core/binary/int32_to_binary_string.spec.js +9 -0
- package/src/core/bvh2/BinaryNode.js +0 -30
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
- package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/src/core/cache/Cache.js +31 -29
- package/src/core/cache/Cache.spec.js +4 -1
- package/src/core/collection/HashMap.js +1 -1
- package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
- package/src/core/collection/array/array_copy_entire.js +21 -0
- package/src/core/collection/array/typed/typed_array_copy.js +1 -1
- package/src/core/collection/queue/Deque.d.ts +4 -0
- package/src/core/collection/queue/Deque.js +5 -7
- package/src/core/collection/queue/Deque.spec.js +107 -0
- package/src/core/collection/table/RowFirstTable.js +1 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
- package/src/core/geom/2d/aabb/AABB2.js +9 -7
- package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
- package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
- package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
- package/src/core/geom/2d/bvh/Node2.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
- package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
- package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
- package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
- package/src/core/geom/Quaternion.d.ts +11 -0
- package/src/core/geom/Quaternion.js +36 -27
- package/src/core/geom/Quaternion.spec.js +141 -0
- package/src/core/geom/Vector2.d.ts +5 -1
- package/src/core/geom/Vector2.js +24 -0
- package/src/core/geom/Vector3.d.ts +4 -0
- package/src/core/geom/Vector3.spec.js +60 -0
- package/src/core/graph/GraphUtils.js +4 -2
- package/src/core/graph/layout/CircleLayout.js +4 -2
- package/src/core/math/bessel_i0.spec.js +43 -0
- package/src/core/math/bessel_j0.js +30 -0
- package/src/core/math/hash/murmur3_32.spec.js +8 -0
- package/src/core/math/hash/squirrel3.spec.js +16 -0
- package/src/core/math/interval/NumericInterval.js +1 -0
- package/src/core/math/{bessel_i0.js → modified_bessel_i0.js} +5 -2
- package/src/core/math/noise/{create_noise_2d.js → create_simplex_noise_2d.js} +2 -2
- package/src/core/math/noise/create_simplex_noise_2d.spec.js +21 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_linear.spec.js +20 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js +4 -4
- package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.spec.js +18 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +1 -1
- package/src/core/math/physics/irradiance/interpolate_irradiance_smith.spec.js +20 -0
- package/src/core/math/random/seededRandomMersenneTwister.spec.js +10 -0
- package/src/core/math/spline/spline_bezier3.js +1 -1
- package/src/core/math/spline/spline_bezier3_bounds.js +2 -1
- package/src/core/math/spline/spline_bezier3_bounds.spec.js +37 -0
- package/src/core/math/statistics/computeSampleSize_Cochran.spec.js +12 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.js +4 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.spec.js +13 -0
- package/src/core/math/vector_nd_dot.js +16 -0
- package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
- package/src/core/math/vector_nd_normalize.spec.js +15 -0
- package/src/core/process/PromiseWatcher.spec.js +1 -1
- package/src/engine/achievements/Achievement.spec.js +21 -0
- package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
- package/src/engine/animation/curve/compression/prototypeCurveCompression.js +2 -2
- package/src/engine/animation/curve/compression/{animation_curve_to_float_array.js → sample_animation_curve_to_float_array.js} +10 -3
- package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.spec.js +29 -0
- package/src/engine/animation/curve/draw/build_curve_editor.js +3 -3
- package/src/engine/development/performance/RingBufferMetric.js +1 -1
- package/src/engine/ecs/EntityManager.js +1 -205
- package/src/engine/ecs/animation/Animation.js +2 -180
- package/src/engine/ecs/animation/AnimationClip.js +132 -0
- package/src/engine/ecs/animation/AnimationClip.spec.js +5 -0
- package/src/engine/ecs/animation/AnimationClipFlag.js +7 -0
- package/src/engine/ecs/animation/AnimationFlags.js +8 -0
- package/src/engine/ecs/animation/AnimationSerializationAdapter.js +32 -0
- package/src/engine/ecs/fow/FogOfWar.js +1 -1
- package/src/engine/ecs/guid/GUID.js +1 -1
- package/src/engine/ecs/systems/AnimationSystem.js +3 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
- package/src/engine/ecs/transform/Transform.d.ts +2 -0
- package/src/engine/ecs/transform/Transform.spec.js +63 -0
- package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
- package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
- package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -1
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
- package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
- package/src/engine/graphics/load_and_set_cubemap_v0.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
- package/src/engine/graphics/render/Lines.js +1 -1
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
- package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
- package/src/engine/graphics/render/view/CameraView.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
- package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
- package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
- package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
- package/src/engine/graphics/texture/CanvasClone.js +5 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
- package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
- package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
- package/src/engine/graphics/texture/sampler/filter/kaiser_1.js +8 -4
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
- package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
- package/src/engine/graphics/trail/TemporalPath.js +0 -36
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
- package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
- package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
- package/src/engine/logging/VoidLoggerBackend.js +12 -0
- package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
- package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
- package/src/engine/save/GameStateLoader.js +1 -1
- package/src/engine/scene/Scene.d.ts +2 -0
- package/src/engine/scene/Scene.js +2 -2
- package/src/engine/scene/Scene.spec.js +20 -0
- package/src/engine/scene/SceneManager.d.ts +4 -0
- package/src/engine/scene/SceneManager.js +46 -23
- package/src/engine/scene/SceneManager.spec.js +107 -0
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +11 -4
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.spec.js +30 -0
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +18 -2
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.spec.js +17 -0
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -2
- package/src/generation/grid/GridData.js +0 -60
- package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
- package/src/generation/markers/MarkerNode.js +2 -2
- package/src/generation/theme/AreaMask.js +3 -1
- package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
- package/src/core/geom/2d/LineSegment2.js +0 -175
- package/src/core/geom/Matrix4.js +0 -275
- package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
- package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
- package/src/engine/physics/cannon/cannon.min.js +0 -27
- /package/src/engine/ecs/{animation → ik}/IKMath.js +0 -0
- /package/src/engine/ecs/{animation → ik}/IKProblem.js +0 -0
- /package/src/engine/ecs/{animation → ik}/IKSolver.js +0 -0
- /package/src/engine/ecs/{animation → ik}/InverseKinematics.js +0 -0
- /package/src/engine/ecs/{animation → ik}/InverseKinematicsSystem.js +0 -0
- /package/src/engine/ecs/{animation → ik}/OneBoneSurfaceAlignmentSolver.js +0 -0
- /package/src/engine/ecs/{animation → ik}/TwoBoneInverseKinematicsSolver.js +0 -0
- /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import SceneManager from "./SceneManager.js";
|
|
2
|
+
import { EntityManager } from "../ecs/EntityManager.js";
|
|
3
|
+
import Clock from "../Clock.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function makeSM() {
|
|
7
|
+
const em = new EntityManager();
|
|
8
|
+
const clock = new Clock();
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
manager: new SceneManager(em, clock),
|
|
12
|
+
entityManager: em
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
test("constructor", () => {
|
|
17
|
+
|
|
18
|
+
const { manager } = makeSM();
|
|
19
|
+
|
|
20
|
+
expect(manager.current_scene).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("create method", () => {
|
|
24
|
+
|
|
25
|
+
const { manager } = makeSM();
|
|
26
|
+
|
|
27
|
+
const scene_x = manager.create('x');
|
|
28
|
+
|
|
29
|
+
expect(scene_x).toBeDefined();
|
|
30
|
+
expect(scene_x).not.toBeNull();
|
|
31
|
+
|
|
32
|
+
expect(() => manager.create('x')).toThrow();
|
|
33
|
+
|
|
34
|
+
const scene_y = manager.create('y');
|
|
35
|
+
|
|
36
|
+
expect(scene_y).toBeDefined();
|
|
37
|
+
expect(scene_y).not.toBeNull();
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("getByName", () => {
|
|
42
|
+
const { manager } = makeSM();
|
|
43
|
+
|
|
44
|
+
expect(manager.getByName('x')).toBeUndefined();
|
|
45
|
+
|
|
46
|
+
const scene_x = manager.create('x');
|
|
47
|
+
|
|
48
|
+
expect(manager.getByName('x')).toBe(scene_x);
|
|
49
|
+
|
|
50
|
+
const scene_y = manager.create('y');
|
|
51
|
+
|
|
52
|
+
expect(manager.getByName('x')).toBe(scene_x);
|
|
53
|
+
expect(manager.getByName('y')).toBe(scene_y);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("remove", () => {
|
|
57
|
+
|
|
58
|
+
const { manager } = makeSM();
|
|
59
|
+
|
|
60
|
+
expect(manager.remove('x')).toBe(false);
|
|
61
|
+
|
|
62
|
+
manager.create('x');
|
|
63
|
+
|
|
64
|
+
expect(manager.remove('x')).toBe(true);
|
|
65
|
+
expect(manager.remove('x')).toBe(false);
|
|
66
|
+
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("exists", () => {
|
|
70
|
+
|
|
71
|
+
const { manager } = makeSM();
|
|
72
|
+
|
|
73
|
+
expect(manager.exists('x')).toBe(false);
|
|
74
|
+
|
|
75
|
+
manager.create('x');
|
|
76
|
+
|
|
77
|
+
expect(manager.exists('x')).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("set active scene", () => {
|
|
81
|
+
const { manager, entityManager } = makeSM();
|
|
82
|
+
|
|
83
|
+
const scene = manager.create('x');
|
|
84
|
+
|
|
85
|
+
manager.set('x');
|
|
86
|
+
|
|
87
|
+
expect(manager.current_scene).toBe(scene);
|
|
88
|
+
expect(entityManager.dataset).toBe(scene.dataset);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("stack push/pop", () => {
|
|
92
|
+
|
|
93
|
+
const { manager } = makeSM();
|
|
94
|
+
|
|
95
|
+
const scene_x = manager.create('x');
|
|
96
|
+
const scene_y = manager.create('y');
|
|
97
|
+
|
|
98
|
+
manager.set('x');
|
|
99
|
+
|
|
100
|
+
manager.stackPush('y');
|
|
101
|
+
|
|
102
|
+
expect(manager.current_scene).toBe(scene_y);
|
|
103
|
+
|
|
104
|
+
manager.stackPop();
|
|
105
|
+
|
|
106
|
+
expect(manager.current_scene).toBe(scene_x);
|
|
107
|
+
});
|
|
@@ -5,7 +5,7 @@ import { SilentSoundMaterial } from "../../concrete/SilentSoundMaterial.js";
|
|
|
5
5
|
import { SingleSoundMaterial } from "../../concrete/SingleSoundMaterial.js";
|
|
6
6
|
import { deserializeSoundMaterialFromJSON } from "../../concrete/json/deserializeSoundMaterialFromJSON.js";
|
|
7
7
|
import { assert } from "../../../../../core/assert.js";
|
|
8
|
-
import {
|
|
8
|
+
import { vector_nd_normalize } from "../../../../../core/math/vector_nd_normalize.js";
|
|
9
9
|
|
|
10
10
|
const v2_temp = new Vector2();
|
|
11
11
|
|
|
@@ -112,7 +112,7 @@ export class TerrainSoundMaterialSurfaceDetector extends SoundMaterialSurfaceDet
|
|
|
112
112
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
vector_nd_normalize(this.__composite.weights, this.__composite.weights, layer_count);
|
|
116
116
|
|
|
117
117
|
const additions = this.__composite.computeInteractionSounds(result, 0, interaction);
|
|
118
118
|
|
|
@@ -3,6 +3,12 @@ import Vector3 from "../../../../core/geom/Vector3.js";
|
|
|
3
3
|
import { assert } from "../../../../core/assert.js";
|
|
4
4
|
import { v3_angle_between } from "../../../../core/geom/v3_angle_between.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Distance from the reference point where support points will be sampled to compute derivative
|
|
8
|
+
* @type {number}
|
|
9
|
+
*/
|
|
10
|
+
const DERIVATIVE_OFFSET = 1;
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* Builds surface normal of another filter, and then computes the angle to a fixed 3d vector
|
|
8
14
|
*/
|
|
@@ -27,6 +33,7 @@ export class CellFilterAngleToNormal extends CellFilter {
|
|
|
27
33
|
*
|
|
28
34
|
* @param {CellFilter} surface
|
|
29
35
|
* @param {Vector3} [reference=Vector3.forward]
|
|
36
|
+
* @returns {CellFilterAngleToNormal}
|
|
30
37
|
*/
|
|
31
38
|
static from(surface, reference = Vector3.forward) {
|
|
32
39
|
assert.equal(surface.isCellFilter, true, 'surface.isCellFilter !== true');
|
|
@@ -51,12 +58,12 @@ export class CellFilterAngleToNormal extends CellFilter {
|
|
|
51
58
|
const filter = this.surface;
|
|
52
59
|
|
|
53
60
|
//read surrounding points
|
|
54
|
-
const top = filter.execute(grid, x, y -
|
|
61
|
+
const top = filter.execute(grid, x, y - DERIVATIVE_OFFSET, 0);
|
|
55
62
|
|
|
56
|
-
const left = filter.execute(grid, x -
|
|
57
|
-
const right = filter.execute(grid, x +
|
|
63
|
+
const left = filter.execute(grid, x - DERIVATIVE_OFFSET, y, 0);
|
|
64
|
+
const right = filter.execute(grid, x + DERIVATIVE_OFFSET, y, 0);
|
|
58
65
|
|
|
59
|
-
const bottom = filter.execute(grid, x, y +
|
|
66
|
+
const bottom = filter.execute(grid, x, y + DERIVATIVE_OFFSET, 0);
|
|
60
67
|
|
|
61
68
|
// compute gradients
|
|
62
69
|
const dX = (right) - (left);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CellFilterAngleToNormal } from "./CellFilterAngleToNormal.js";
|
|
2
|
+
import { CellFilterLiteralFloat } from "../CellFilterLiteralFloat.js";
|
|
3
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
4
|
+
import { GridData } from "../../../grid/GridData.js";
|
|
5
|
+
import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
|
|
6
|
+
|
|
7
|
+
test("constructor does not throw", () => {
|
|
8
|
+
expect(() => new CellFilterAngleToNormal()).not.toThrow();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("angle to flat surface exactly on normal", () => {
|
|
12
|
+
const data = new GridData();
|
|
13
|
+
|
|
14
|
+
const filter = CellFilterAngleToNormal.from(CellFilterLiteralFloat.from(0), new Vector3(0, 0, 1));
|
|
15
|
+
|
|
16
|
+
filter.initialize(data, 0);
|
|
17
|
+
|
|
18
|
+
expect(filter.execute(data, 0, 0, 0)).toBeCloseTo(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("angle to flat surface at 30deg off normal", () => {
|
|
22
|
+
|
|
23
|
+
const data = new GridData();
|
|
24
|
+
|
|
25
|
+
const filter = CellFilterAngleToNormal.from(CellFilterLiteralFloat.from(0), new Vector3(0, 0.49999999999999994, 0.8660254037844386));
|
|
26
|
+
|
|
27
|
+
filter.initialize(data, 0);
|
|
28
|
+
|
|
29
|
+
expect(filter.execute(data, 0, 0, 0)).toBeCloseTo(30 * DEG_TO_RAD);
|
|
30
|
+
})
|
|
@@ -47,6 +47,22 @@ function buildKernel(result, samplesX, samplesY, sigma_x, sigma_y) {
|
|
|
47
47
|
return powerTotal;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* even number of samples, make odd to ensure we sample reference point
|
|
53
|
+
* @param {number} x
|
|
54
|
+
* @return {number}
|
|
55
|
+
*/
|
|
56
|
+
function makeNextOdd(x) {
|
|
57
|
+
if (x % 2 === 0) {
|
|
58
|
+
// even, make odd
|
|
59
|
+
return x + 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// already odd
|
|
63
|
+
return x;
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
export class CellFilterGaussianBlur extends CellFilter {
|
|
51
67
|
constructor() {
|
|
52
68
|
super();
|
|
@@ -141,8 +157,8 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
141
157
|
|
|
142
158
|
r.source = source;
|
|
143
159
|
|
|
144
|
-
r.samples_x = max2(
|
|
145
|
-
r.samples_y = max2(
|
|
160
|
+
r.samples_x = max2(3, makeNextOdd(Math.round(quality * x)));
|
|
161
|
+
r.samples_y = max2(3, makeNextOdd(Math.round(quality * y)));
|
|
146
162
|
|
|
147
163
|
r.size_x = x;
|
|
148
164
|
r.size_y = y;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CellFilterGaussianBlur } from "./CellFilterGaussianBlur.js";
|
|
2
|
+
import { GridData } from "../../../grid/GridData.js";
|
|
3
|
+
import { CellFilterLiteralFloat } from "../CellFilterLiteralFloat.js";
|
|
4
|
+
|
|
5
|
+
test("constructor does not throw", () => {
|
|
6
|
+
expect(() => new CellFilterGaussianBlur()).not.toThrow();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("sample on constant value source", () => {
|
|
10
|
+
const data = new GridData();
|
|
11
|
+
|
|
12
|
+
const filter = CellFilterGaussianBlur.from(CellFilterLiteralFloat.from(7), 3, 3, 1);
|
|
13
|
+
|
|
14
|
+
filter.initialize(data, 0);
|
|
15
|
+
|
|
16
|
+
expect(filter.execute(data, 0, 0, 0)).toBeCloseTo(7);
|
|
17
|
+
});
|
|
@@ -4,7 +4,7 @@ import { CellFilterAdd } from "../math/algebra/CellFilterAdd.js";
|
|
|
4
4
|
import { CellFilterMultiply } from "../math/algebra/CellFilterMultiply.js";
|
|
5
5
|
import { CellFilterLiteralFloat } from "../CellFilterLiteralFloat.js";
|
|
6
6
|
import { CellFilterDivide } from "../math/algebra/CellFilterDivide.js";
|
|
7
|
-
import {
|
|
7
|
+
import { create_simplex_noise_2d } from "../../../../core/math/noise/create_simplex_noise_2d.js";
|
|
8
8
|
|
|
9
9
|
export class CellFilterSimplexNoise extends CellFilter {
|
|
10
10
|
constructor() {
|
|
@@ -109,7 +109,7 @@ export class CellFilterSimplexNoise extends CellFilter {
|
|
|
109
109
|
initialize(grid, seed) {
|
|
110
110
|
this.random.setCurrentSeed(seed + this.__seed);
|
|
111
111
|
|
|
112
|
-
this.noise =
|
|
112
|
+
this.noise = create_simplex_noise_2d(this.random);
|
|
113
113
|
|
|
114
114
|
super.initialize(grid, seed);
|
|
115
115
|
}
|
|
@@ -203,66 +203,6 @@ export class GridData {
|
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {number} x
|
|
209
|
-
* @param {number} y
|
|
210
|
-
* @param {number} mask
|
|
211
|
-
*/
|
|
212
|
-
clearTags(x, y, mask) {
|
|
213
|
-
|
|
214
|
-
const cellIndex = y * this.width + x;
|
|
215
|
-
|
|
216
|
-
const current = this.tags[cellIndex];
|
|
217
|
-
|
|
218
|
-
const newValue = current & (~mask);
|
|
219
|
-
|
|
220
|
-
this.tags[cellIndex] = newValue;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
*
|
|
225
|
-
* @param {number} x
|
|
226
|
-
* @param {number} y
|
|
227
|
-
* @param {number} tags
|
|
228
|
-
*/
|
|
229
|
-
writeTags(x, y, tags) {
|
|
230
|
-
const cellIndex = y * this.width + x;
|
|
231
|
-
|
|
232
|
-
this.tags[cellIndex] = tags;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {number} x
|
|
238
|
-
* @param {number} y
|
|
239
|
-
* @param {number} mask
|
|
240
|
-
*/
|
|
241
|
-
setTags(x, y, mask) {
|
|
242
|
-
|
|
243
|
-
const cellIndex = y * this.width + x;
|
|
244
|
-
|
|
245
|
-
const current = this.tags[cellIndex];
|
|
246
|
-
|
|
247
|
-
const newValue = current | mask;
|
|
248
|
-
|
|
249
|
-
this.tags[cellIndex] = newValue;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
*
|
|
254
|
-
* @param {number} x
|
|
255
|
-
* @param {number} y
|
|
256
|
-
* @return {number}
|
|
257
|
-
*/
|
|
258
|
-
readTags(x, y) {
|
|
259
|
-
const _x = x | 0;
|
|
260
|
-
const _y = y | 0;
|
|
261
|
-
|
|
262
|
-
const cellIndex = _y * this.width + _x;
|
|
263
|
-
|
|
264
|
-
return this.tags[cellIndex];
|
|
265
|
-
}
|
|
266
206
|
}
|
|
267
207
|
|
|
268
208
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { computeUnsignedDistanceField } from "../../../../engine/graphics/texture/sampler/distanceField.js";
|
|
2
1
|
import { Sampler2D } from "../../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
2
|
+
import {
|
|
3
|
+
computeUnsignedDistanceField
|
|
4
|
+
} from "../../../../engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
2
2
|
import { Transform } from "../../engine/ecs/transform/Transform.js";
|
|
3
|
-
import { copyArray } from "../../core/collection/array/copyArray.js";
|
|
4
3
|
import { circleIntersectsCircle } from "../../core/geom/2d/circle/circleIntersectsCircle.js";
|
|
4
|
+
import { array_copy_entire } from "../../core/collection/array/array_copy_entire.js";
|
|
5
5
|
|
|
6
6
|
export class MarkerNode {
|
|
7
7
|
constructor() {
|
|
@@ -95,7 +95,7 @@ export class MarkerNode {
|
|
|
95
95
|
copy(other) {
|
|
96
96
|
this.type = other.type;
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
array_copy_entire(other.tags, this.tags);
|
|
99
99
|
|
|
100
100
|
this.position.copy(other.position);
|
|
101
101
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
2
2
|
import AABB2 from "../../core/geom/2d/aabb/AABB2.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
computeUnsignedDistanceField
|
|
5
|
+
} from "../../engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js";
|
|
4
6
|
|
|
5
7
|
export class AreaMask {
|
|
6
8
|
constructor() {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import View from "../../View.js";
|
|
2
2
|
import SVG from "../../SVG.js";
|
|
3
|
-
import { line2_line2_intersection } from "../../../core/geom/2d/LineSegment2.js";
|
|
4
3
|
import Vector1 from "../../../core/geom/Vector1.js";
|
|
4
|
+
import {
|
|
5
|
+
line_segment_compute_line_segment_intersection_array_2d
|
|
6
|
+
} from "../../../core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js";
|
|
5
7
|
|
|
6
8
|
export class RectangularPieProgressView extends View {
|
|
7
9
|
|
|
@@ -76,31 +78,31 @@ export class RectangularPieProgressView extends View {
|
|
|
76
78
|
|
|
77
79
|
if (fraction < .125) {
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
line_segment_compute_line_segment_intersection_array_2d(p, 0, 0, 0, size_x, 0, center_x, center_y, line_x, line_y);
|
|
80
82
|
|
|
81
83
|
path = `M ${center_x} 0 L ${center_x} ${center_y} L ${p[0]} ${p[1]} L ${size_x} 0 L ${size_x} ${size_y} L 0 ${size_y} L 0 0 Z`;
|
|
82
84
|
|
|
83
85
|
} else if (fraction < 0.375) {
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
line_segment_compute_line_segment_intersection_array_2d(p, 0, size_x, 0, size_x, size_y, center_x, center_y, line_x, line_y);
|
|
86
88
|
|
|
87
89
|
path = `M ${center_x} 0 L ${center_x} ${center_y} L ${p[0]} ${p[1]} L ${size_x} ${size_y} L 0 ${size_y} L 0 0 Z`;
|
|
88
90
|
|
|
89
91
|
} else if (fraction < 0.625) {
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
line_segment_compute_line_segment_intersection_array_2d(p, 0, size_x, size_y, 0, size_y, center_x, center_y, line_x, line_y);
|
|
92
94
|
|
|
93
95
|
path = `M ${center_x} 0 L ${center_x} ${center_y} L ${p[0]} ${p[1]} L 0 ${size_y} L 0 0 Z`;
|
|
94
96
|
|
|
95
97
|
} else if (fraction < 0.875) {
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
line_segment_compute_line_segment_intersection_array_2d(p, 0, 0, size_y, 0, 0, center_x, center_y, line_x, line_y);
|
|
98
100
|
|
|
99
101
|
path = `M ${center_x} 0 L ${center_x} ${center_y} L ${p[0]} ${p[1]} L 0 0 Z`;
|
|
100
102
|
|
|
101
103
|
} else {
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
line_segment_compute_line_segment_intersection_array_2d(p, 0, 0, 0, size_x, 0, center_x, center_y, line_x, line_y);
|
|
104
106
|
|
|
105
107
|
path = `M ${center_x} 0 L ${center_x} ${center_y} L ${p[0]} ${p[1]} Z`;
|
|
106
108
|
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 2-D line Mathematics
|
|
3
|
-
* @author Alex Goldring 2019
|
|
4
|
-
* @copyright Alex Goldring 2019
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @constructor
|
|
10
|
-
*/
|
|
11
|
-
function LineSegment2() {
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {Vector2} p0
|
|
17
|
-
* @param {Vector2} p1
|
|
18
|
-
* @param {Vector2} p2
|
|
19
|
-
* @param {Vector2} p3
|
|
20
|
-
* @returns {[number,number]}
|
|
21
|
-
*/
|
|
22
|
-
export function computeLine2Intersection(p0, p1, p2, p3) {
|
|
23
|
-
const p0_x = p0.x;
|
|
24
|
-
const p0_y = p0.y;
|
|
25
|
-
const p1_x = p1.x;
|
|
26
|
-
const p1_y = p1.y;
|
|
27
|
-
const p2_x = p2.x;
|
|
28
|
-
const p2_y = p2.y;
|
|
29
|
-
const p3_x = p3.x;
|
|
30
|
-
const p3_y = p3.y;
|
|
31
|
-
|
|
32
|
-
const result = [];
|
|
33
|
-
|
|
34
|
-
if (line2_line2_intersection(result, p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y)) {
|
|
35
|
-
return result;
|
|
36
|
-
} else {
|
|
37
|
-
return null; // No collision
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {number[]} result
|
|
45
|
-
* @param {number} a0_x
|
|
46
|
-
* @param {number} a0_y
|
|
47
|
-
* @param {number} a1_x
|
|
48
|
-
* @param {number} a1_y
|
|
49
|
-
* @param {number} b2_x
|
|
50
|
-
* @param {number} b2_y
|
|
51
|
-
* @param {number} b3_x
|
|
52
|
-
* @param {number} b3_y
|
|
53
|
-
* @return {boolean}
|
|
54
|
-
*/
|
|
55
|
-
export function line2_line2_intersection(result, a0_x, a0_y, a1_x, a1_y, b2_x, b2_y, b3_x, b3_y) {
|
|
56
|
-
|
|
57
|
-
const s1_x = a1_x - a0_x;
|
|
58
|
-
const s1_y = a1_y - a0_y;
|
|
59
|
-
const s2_x = b3_x - b2_x;
|
|
60
|
-
const s2_y = b3_y - b2_y;
|
|
61
|
-
|
|
62
|
-
const dy_02 = a0_y - b2_y;
|
|
63
|
-
const dx_02 = a0_x - b2_x;
|
|
64
|
-
|
|
65
|
-
const denom = -s2_x * s1_y + s1_x * s2_y;
|
|
66
|
-
|
|
67
|
-
const s = (-s1_y * dx_02 + s1_x * dy_02) / denom;
|
|
68
|
-
const t = (s2_x * dy_02 - s2_y * dx_02) / denom;
|
|
69
|
-
|
|
70
|
-
if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
|
|
71
|
-
// Collision detected
|
|
72
|
-
|
|
73
|
-
const intX = a0_x + (t * s1_x);
|
|
74
|
-
const intY = a0_y + (t * s1_y);
|
|
75
|
-
|
|
76
|
-
result[0] = intX;
|
|
77
|
-
result[1] = intY;
|
|
78
|
-
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return false; // No collision
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Adapted from answer by iMalc from stackoverflow.com "how do you detect where two line segments intersect"
|
|
87
|
-
* @link https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
|
|
88
|
-
* @param {Vector2} a0 start of first segment
|
|
89
|
-
* @param {Vector2} a1 end of first segment
|
|
90
|
-
* @param {Vector2} b0 start of second segment
|
|
91
|
-
* @param {Vector2} b1 end of second segment
|
|
92
|
-
* @param {Vector2} result resulting intersection point will be stored here if intersection exists
|
|
93
|
-
* @returns {boolean} True if segments intersect, False otherwise
|
|
94
|
-
*/
|
|
95
|
-
function intersectionPoint(a0, a1, b0, b1, result) {
|
|
96
|
-
return intersectionPointRaw(a0.x, a0.y, a1.x, a1.y, b0.x, b0.y, b1.x, b1.y, result);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {number} a0_x
|
|
102
|
-
* @param {number} a0_y
|
|
103
|
-
* @param {number} a1_x
|
|
104
|
-
* @param {number} a1_y
|
|
105
|
-
* @param {number} b0_x
|
|
106
|
-
* @param {number} b0_y
|
|
107
|
-
* @param {number} b1_x
|
|
108
|
-
* @param {number} b1_y
|
|
109
|
-
* @returns {boolean} True if segments intersect, False otherwise
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
export function line2SegmentsIntersect(a0_x, a0_y, a1_x, a1_y, b0_x, b0_y, b1_x, b1_y) {
|
|
113
|
-
const s1_x = a1_x - a0_x;
|
|
114
|
-
const s1_y = a1_y - a0_y;
|
|
115
|
-
const s2_x = b1_x - b0_x;
|
|
116
|
-
const s2_y = b1_y - b0_y;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const denom = (-s2_x * s1_y + s1_x * s2_y);
|
|
120
|
-
|
|
121
|
-
const dy0_ab = a0_y - b0_y;
|
|
122
|
-
const dx0_ab = a0_x - b0_x;
|
|
123
|
-
|
|
124
|
-
const s = (-s1_y * dx0_ab + s1_x * dy0_ab) / denom;
|
|
125
|
-
const t = (s2_x * dy0_ab - s2_y * dx0_ab) / denom;
|
|
126
|
-
|
|
127
|
-
return s >= 0 && s <= 1 && t >= 0 && t <= 1;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
*
|
|
133
|
-
* @param {number} a0_x
|
|
134
|
-
* @param {number} a0_y
|
|
135
|
-
* @param {number} a1_x
|
|
136
|
-
* @param {number} a1_y
|
|
137
|
-
* @param {number} b0_x
|
|
138
|
-
* @param {number} b0_y
|
|
139
|
-
* @param {number} b1_x
|
|
140
|
-
* @param {number} b1_y
|
|
141
|
-
* @param {Vector2} result resulting intersection point will be stored here if intersection exists
|
|
142
|
-
* @returns {boolean} True if segments intersect, False otherwise
|
|
143
|
-
* @public
|
|
144
|
-
*/
|
|
145
|
-
function intersectionPointRaw(a0_x, a0_y, a1_x, a1_y, b0_x, b0_y, b1_x, b1_y, result) {
|
|
146
|
-
const s1_x = a1_x - a0_x;
|
|
147
|
-
const s1_y = a1_y - a0_y;
|
|
148
|
-
const s2_x = b1_x - b0_x;
|
|
149
|
-
const s2_y = b1_y - b0_y;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const denom = (-s2_x * s1_y + s1_x * s2_y);
|
|
153
|
-
|
|
154
|
-
const s = (-s1_y * (a0_x - b0_x) + s1_x * (a0_y - b0_y)) / denom;
|
|
155
|
-
const t = (s2_x * (a0_y - b0_y) - s2_y * (a0_x - b0_x)) / denom;
|
|
156
|
-
|
|
157
|
-
if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
|
|
158
|
-
// Collision detected
|
|
159
|
-
|
|
160
|
-
const i_x = a0_x + (t * s1_x);
|
|
161
|
-
const i_y = a0_y + (t * s1_y);
|
|
162
|
-
|
|
163
|
-
result.set(i_x, i_y);
|
|
164
|
-
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
LineSegment2.intersectionPoint = intersectionPoint;
|
|
173
|
-
LineSegment2.intersectionPointRaw = intersectionPointRaw;
|
|
174
|
-
|
|
175
|
-
export default LineSegment2;
|