@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,20 @@
|
|
|
1
|
+
import { interpolate_irradiance_smith } from "./interpolate_irradiance_smith.js";
|
|
2
|
+
|
|
3
|
+
test("sanity check", () => {
|
|
4
|
+
|
|
5
|
+
expect(interpolate_irradiance_smith(3, 3, 3)).toBe(1);
|
|
6
|
+
|
|
7
|
+
expect(interpolate_irradiance_smith(3, 3, 7)).toBe(1);
|
|
8
|
+
|
|
9
|
+
expect(interpolate_irradiance_smith(7, 3, 7)).toBe(0);
|
|
10
|
+
|
|
11
|
+
expect(interpolate_irradiance_smith(0, 3, 7)).toBe(1);
|
|
12
|
+
|
|
13
|
+
expect(interpolate_irradiance_smith(11, 3, 7)).toBe(0);
|
|
14
|
+
|
|
15
|
+
const mid = interpolate_irradiance_smith(5, 3, 7);
|
|
16
|
+
|
|
17
|
+
expect(mid).toBeGreaterThan(0);
|
|
18
|
+
expect(mid).toBeLessThan(1);
|
|
19
|
+
|
|
20
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { min2 } from "../min2.js";
|
|
2
2
|
import { max2 } from "../max2.js";
|
|
3
3
|
import { assert } from "../../assert.js";
|
|
4
|
+
import { spline_bezier3 } from './spline_bezier3'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Compute bounds of a 3-rd degree bezier curve
|
|
@@ -15,7 +16,7 @@ import { assert } from "../../assert.js";
|
|
|
15
16
|
* @param {number} p2
|
|
16
17
|
* @param {number} p3
|
|
17
18
|
*/
|
|
18
|
-
function spline_bezier3_bounds(result, result_offset, result_stride, p0, p1, p2, p3) {
|
|
19
|
+
export function spline_bezier3_bounds(result, result_offset, result_stride, p0, p1, p2, p3) {
|
|
19
20
|
assert.greaterThan(result_stride, 0, 'result_stride must be greater than 0');
|
|
20
21
|
assert.isInteger(result_stride, 'result_stride');
|
|
21
22
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { spline_bezier3_bounds } from "./spline_bezier3_bounds.js";
|
|
2
|
+
|
|
3
|
+
test("spline of 0 length", () => {
|
|
4
|
+
const bounds = [];
|
|
5
|
+
|
|
6
|
+
spline_bezier3_bounds(
|
|
7
|
+
bounds, 0, 1,
|
|
8
|
+
0, 0, 0, 0
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
expect(bounds[0]).toBeCloseTo(0);
|
|
12
|
+
expect(bounds[1]).toBeCloseTo(0);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("line-shaped spline of", () => {
|
|
16
|
+
const bounds = [];
|
|
17
|
+
|
|
18
|
+
spline_bezier3_bounds(
|
|
19
|
+
bounds, 0, 1,
|
|
20
|
+
-2, -1, 1, 2
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(bounds[0]).toBeCloseTo(-2);
|
|
24
|
+
expect(bounds[1]).toBeCloseTo(2);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("overshooting control point spline of", () => {
|
|
28
|
+
const bounds = [];
|
|
29
|
+
|
|
30
|
+
spline_bezier3_bounds(
|
|
31
|
+
bounds, 0, 1,
|
|
32
|
+
0, -1, 1, 0
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(bounds[0]).toBeLessThan(0);
|
|
36
|
+
expect(bounds[1]).toBeGreaterThan(0);
|
|
37
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { computeSampleSize_Cochran } from "./computeSampleSize_Cochran.js";
|
|
2
|
+
|
|
3
|
+
test("sanity for 95% confidence", () => {
|
|
4
|
+
function execute(error) {
|
|
5
|
+
return Math.floor(computeSampleSize_Cochran(1.95996, 0.5, error))
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
expect(execute(0.05)).toEqual(384);
|
|
9
|
+
expect(execute(0.035)).toEqual(783);
|
|
10
|
+
expect(execute(0.025)).toEqual(1536);
|
|
11
|
+
expect(execute(0.01)).toEqual(9603);
|
|
12
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compareNumbersAscending } from "../../function/Functions.js";
|
|
2
|
+
import { assert } from "../../assert.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -8,6 +9,9 @@ import { compareNumbersAscending } from "../../function/Functions.js";
|
|
|
8
9
|
* @returns {number}
|
|
9
10
|
*/
|
|
10
11
|
export function computeStatisticalPartialMedian(values, start, end) {
|
|
12
|
+
assert.isArrayLike(values, 'values');
|
|
13
|
+
assert.lessThan(end, values.length);
|
|
14
|
+
|
|
11
15
|
const copy = values.slice();
|
|
12
16
|
|
|
13
17
|
copy.sort(compareNumbersAscending);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { computeStatisticalPartialMedian } from "./computeStatisticalPartialMedian.js";
|
|
2
|
+
|
|
3
|
+
test("single item", () => {
|
|
4
|
+
expect(computeStatisticalPartialMedian([7], 0, 0)).toEqual(7);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test("[1,2,1]", () => {
|
|
8
|
+
expect(computeStatisticalPartialMedian([1,2,1], 0, 2)).toEqual(1);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("[7,6,2,4,1]", () => {
|
|
12
|
+
expect(computeStatisticalPartialMedian([7,6,2,4,1], 0, 4)).toEqual(4);
|
|
13
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional vector dot product
|
|
3
|
+
* @param {number[]|Float32Array|Float64Array} a
|
|
4
|
+
* @param {number[]|Float32Array|Float64Array} b
|
|
5
|
+
* @param {number} n number of dimensions
|
|
6
|
+
* @return {number}
|
|
7
|
+
*/
|
|
8
|
+
export function vector_nd_dot(a, b, n) {
|
|
9
|
+
let result = 0;
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < n; i++) {
|
|
12
|
+
result += a[i] * b[i]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Assuming the input is an N-dimension vector, normalizes the vector to magnitude of 1
|
|
3
|
-
* @param {number[]|Float32Array} result
|
|
4
|
-
* @param {number[]|Float32Array} data
|
|
3
|
+
* @param {number[]|Float32Array|Float64Array} result
|
|
4
|
+
* @param {number[]|Float32Array|Float64Array} data
|
|
5
5
|
* @param {number} [length] number of dimensions
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function vector_nd_normalize(result, data, length = data.length) {
|
|
8
8
|
|
|
9
9
|
let magnitude2 = 0;
|
|
10
10
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { vector_nd_normalize } from "./vector_nd_normalize.js";
|
|
2
|
+
|
|
3
|
+
test("1d vector normalization", () => {
|
|
4
|
+
const v = [7];
|
|
5
|
+
|
|
6
|
+
vector_nd_normalize(v, v, 1);
|
|
7
|
+
|
|
8
|
+
expect(v[0]).toBeCloseTo(1);
|
|
9
|
+
|
|
10
|
+
v[0] = -13;
|
|
11
|
+
|
|
12
|
+
vector_nd_normalize(v, v, 1);
|
|
13
|
+
|
|
14
|
+
expect(v[0]).toBeCloseTo(-1);
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Achievement } from "./Achievement.js";
|
|
2
|
+
|
|
3
|
+
test("constructor does not throw", () => {
|
|
4
|
+
expect(() => new Achievement()).not.toThrow();
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test("fromJSON correctness", () => {
|
|
8
|
+
const achievement = new Achievement();
|
|
9
|
+
|
|
10
|
+
achievement.fromJSON({
|
|
11
|
+
id: "x",
|
|
12
|
+
condition: "hello == kitty",
|
|
13
|
+
icon: "y",
|
|
14
|
+
secret: true
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(achievement.id).toEqual("x");
|
|
18
|
+
expect(achievement.condition).toEqual("hello == kitty");
|
|
19
|
+
expect(achievement.icon).toEqual("y");
|
|
20
|
+
expect(achievement.secret).toEqual(true);
|
|
21
|
+
});
|
|
@@ -6,7 +6,7 @@ import { lerp } from "../../../../core/math/lerp.js";
|
|
|
6
6
|
import { min3 } from "../../../../core/math/min3.js";
|
|
7
7
|
import { max3 } from "../../../../core/math/max3.js";
|
|
8
8
|
import { downsample_float_array } from "./downsample_float_array.js";
|
|
9
|
-
import { array_copy } from "../../../../core/collection/array/
|
|
9
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
10
10
|
import { isPowerOfTwo } from "../../../../core/math/isPowerOrTwo.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -4,7 +4,7 @@ import { Keyframe } from "../Keyframe.js";
|
|
|
4
4
|
import { EngineConfiguration } from "../../../EngineConfiguration.js";
|
|
5
5
|
import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
|
|
6
6
|
import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
7
|
-
import {
|
|
7
|
+
import { sample_animation_curve_to_float_array } from "./sample_animation_curve_to_float_array.js";
|
|
8
8
|
import { downsample_float_array_curve_by_error } from "./downsample_float_array_curve_by_error.js";
|
|
9
9
|
import { build_plot_entity_from_array } from "../draw/build_plot_entity_from_array.js";
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ async function init() {
|
|
|
28
28
|
|
|
29
29
|
function build_error_scale(ecd, curve) {
|
|
30
30
|
const curve_data = [];
|
|
31
|
-
|
|
31
|
+
sample_animation_curve_to_float_array(curve_data, 0, curve, 256);
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
build_plot_entity_from_array({
|
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
* Sample entire animation curve into a flat array with discrete equal intervals
|
|
6
6
|
* @param {number[]|Float32Array} out
|
|
7
7
|
* @param {number} out_offset
|
|
8
|
-
* @param {number} sample_count
|
|
9
8
|
* @param {AnimationCurve} curve
|
|
9
|
+
* @param {number} sample_count
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function sample_animation_curve_to_float_array(
|
|
12
|
+
out,
|
|
13
|
+
out_offset,
|
|
14
|
+
curve,
|
|
15
|
+
sample_count = out.length
|
|
16
|
+
) {
|
|
12
17
|
const keyframes = curve.keys;
|
|
13
18
|
const keyframe_count = keyframes.length;
|
|
14
19
|
|
|
@@ -25,8 +30,10 @@ export function animation_curve_to_float_array(out, curve, out_offset = 0, sampl
|
|
|
25
30
|
const time_end = key_last.time;
|
|
26
31
|
const time_span = time_end - time_start;
|
|
27
32
|
|
|
33
|
+
const multiplier = sample_count > 1 ? 1 / (sample_count - 1) : 0;
|
|
34
|
+
|
|
28
35
|
for (let i = 0; i < sample_count; i++) {
|
|
29
|
-
const f = i
|
|
36
|
+
const f = i * multiplier;
|
|
30
37
|
|
|
31
38
|
const t = time_start + (f * time_span);
|
|
32
39
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnimationCurve } from "../AnimationCurve.js";
|
|
2
|
+
import { sample_animation_curve_to_float_array } from "./sample_animation_curve_to_float_array.js";
|
|
3
|
+
import { Keyframe } from "../Keyframe.js";
|
|
4
|
+
|
|
5
|
+
test("0 samples should produce valid result", () => {
|
|
6
|
+
|
|
7
|
+
const curve = new AnimationCurve();
|
|
8
|
+
|
|
9
|
+
const result = new Float32Array(0);
|
|
10
|
+
|
|
11
|
+
expect(() => sample_animation_curve_to_float_array(result, 0, curve, 0)).not.toThrow();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("3 samples on a line", () => {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const curve = new AnimationCurve();
|
|
18
|
+
curve.add(Keyframe.from(-1, -1))
|
|
19
|
+
curve.add(Keyframe.from(1, 7))
|
|
20
|
+
|
|
21
|
+
curve.smoothAllTangents();
|
|
22
|
+
|
|
23
|
+
const result = new Float32Array(3);
|
|
24
|
+
sample_animation_curve_to_float_array(result, 0, curve, 3);
|
|
25
|
+
|
|
26
|
+
expect(result[0]).toBeCloseTo(-1);
|
|
27
|
+
expect(result[1]).toBeCloseTo(3);
|
|
28
|
+
expect(result[2]).toBeCloseTo(7);
|
|
29
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
2
2
|
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
3
3
|
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
4
|
-
import AABB2 from "../../../../core/geom/AABB2.js";
|
|
4
|
+
import AABB2 from "../../../../core/geom/2d/aabb/AABB2.js";
|
|
5
5
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
6
6
|
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
7
|
-
import {
|
|
7
|
+
import { sample_animation_curve_to_float_array } from "../compression/sample_animation_curve_to_float_array.js";
|
|
8
8
|
import { plot_data } from "./plot_data.js";
|
|
9
9
|
import { DraggableAspect } from "../../../ui/DraggableAspect.js";
|
|
10
10
|
import { min2 } from "../../../../core/math/min2.js";
|
|
@@ -123,7 +123,7 @@ export function build_curve_editor({
|
|
|
123
123
|
const width = graph.size.x;
|
|
124
124
|
const data = new Float32Array(width);
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
sample_animation_curve_to_float_array(data, 0, curve, data.length);
|
|
127
127
|
|
|
128
128
|
plot_data({
|
|
129
129
|
data,
|
|
@@ -58,7 +58,7 @@ export class RingBufferMetric extends AbstractMetric {
|
|
|
58
58
|
} else {
|
|
59
59
|
|
|
60
60
|
result.mean = computeStatisticalMean(array, 0, data_count);
|
|
61
|
-
result.median = computeStatisticalPartialMedian(array, 0, data_count);
|
|
61
|
+
result.median = computeStatisticalPartialMedian(array, 0, data_count - 1);
|
|
62
62
|
result.max = computeArrayMax(array, 0, data_count);
|
|
63
63
|
result.min = computeArrayMin(array, 0, data_count);
|
|
64
64
|
|
|
@@ -831,7 +831,7 @@ EntityManager.prototype.shutdown = function (readyCallback, errorCallback) {
|
|
|
831
831
|
|
|
832
832
|
system.state.set(System.State.STOPPED);
|
|
833
833
|
|
|
834
|
-
self.on.systemStopped.
|
|
834
|
+
self.on.systemStopped.send1(system);
|
|
835
835
|
if (readyCount === expectedReadyCount) {
|
|
836
836
|
finalizeShutdown();
|
|
837
837
|
}
|
|
@@ -870,210 +870,6 @@ EntityManager.prototype.shutdown = function (readyCallback, errorCallback) {
|
|
|
870
870
|
});
|
|
871
871
|
};
|
|
872
872
|
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* @deprecated
|
|
876
|
-
* @returns {number}
|
|
877
|
-
*/
|
|
878
|
-
EntityManager.prototype.createEntity = function () {
|
|
879
|
-
console.warn("EntityManager.createEntity is deprecated");
|
|
880
|
-
|
|
881
|
-
return this.dataset.createEntity();
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* @deprecated
|
|
886
|
-
* @param id
|
|
887
|
-
*/
|
|
888
|
-
EntityManager.prototype.createEntitySpecific = function (id) {
|
|
889
|
-
console.warn("EntityManager.createEntitySpecific is deprecated");
|
|
890
|
-
this.dataset.createEntitySpecific(id);
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* @deprecated
|
|
896
|
-
* Remove association of specified component type from entity
|
|
897
|
-
* @param {Number} entityId
|
|
898
|
-
* @param {Number} componentType
|
|
899
|
-
*/
|
|
900
|
-
EntityManager.prototype.removeComponentFromEntity = function (entityId, componentType) {
|
|
901
|
-
console.warn("EntityManager.removeComponentFromEntity is deprecated");
|
|
902
|
-
|
|
903
|
-
this.dataset.removeComponentFromEntityByIndex(entityId, componentType);
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* @deprecated use dataset directly
|
|
908
|
-
* Retrieves component instance associated with entity
|
|
909
|
-
* @template T
|
|
910
|
-
* @param {Number} entityId
|
|
911
|
-
* @param {class.<T>} componentClass
|
|
912
|
-
* @returns {T|null}
|
|
913
|
-
* @nosideeffects
|
|
914
|
-
*/
|
|
915
|
-
EntityManager.prototype.getComponent = function (entityId, componentClass) {
|
|
916
|
-
console.warn("EntityManager.getComponent is deprecated");
|
|
917
|
-
|
|
918
|
-
return this.dataset.getComponent(entityId, componentClass);
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* @deprecated use {@link EntityComponentDataset.entityExists} instead
|
|
923
|
-
* @param {number} entityIndex
|
|
924
|
-
* @returns {boolean}
|
|
925
|
-
*/
|
|
926
|
-
EntityManager.prototype.entityExists = function (entityIndex) {
|
|
927
|
-
console.warn("EntityManager.entityExists is deprecated");
|
|
928
|
-
if (this.dataset === null) {
|
|
929
|
-
//no dataset - no entities
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
return this.dataset.entityExists(entityIndex);
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
/**
|
|
937
|
-
* @deprecated Use {@link EntityManager#dataset} direction
|
|
938
|
-
* @param entity
|
|
939
|
-
* @returns {Array}
|
|
940
|
-
*/
|
|
941
|
-
EntityManager.prototype.getComponents = function (entity) {
|
|
942
|
-
console.warn("EntityManager.getComponents is deprecated");
|
|
943
|
-
|
|
944
|
-
return this.dataset.getAllComponents(entity);
|
|
945
|
-
};
|
|
946
|
-
|
|
947
|
-
/**
|
|
948
|
-
* @deprecated
|
|
949
|
-
* Retrieves component instance associated with entity
|
|
950
|
-
* @param {Number} entityId
|
|
951
|
-
* @param {Number} componentType
|
|
952
|
-
* @returns {*|undefined} component of specified type or undefined if it was not found
|
|
953
|
-
*/
|
|
954
|
-
EntityManager.prototype.getComponentByType = function (entityId, componentType) {
|
|
955
|
-
console.warn("EntityManager.getComponentByType is deprecated");
|
|
956
|
-
return this.dataset.getComponentByIndex(entityId, componentType);
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
/**
|
|
960
|
-
* @deprecated
|
|
961
|
-
* does traversal on a subset of entities which have specified components.
|
|
962
|
-
* @example traverseEntities([Transform,Renderable,Tag],function(transform, renderable, tag, entity){ ... }, this);
|
|
963
|
-
* @param {Array.<class>} classes
|
|
964
|
-
* @param {Function} callback
|
|
965
|
-
* @param {Object} [thisArg] specifies context object on which callbacks are to be called, optional
|
|
966
|
-
*/
|
|
967
|
-
EntityManager.prototype.traverseEntities = function (classes, callback, thisArg) {
|
|
968
|
-
console.warn("EntityManager.traverseEntities is deprecated");
|
|
969
|
-
|
|
970
|
-
if (this.dataset === null) {
|
|
971
|
-
//no data to traverse
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
this.dataset.traverseEntities(classes, callback, thisArg);
|
|
975
|
-
};
|
|
976
|
-
|
|
977
|
-
/**
|
|
978
|
-
* @deprecated
|
|
979
|
-
* @param entity
|
|
980
|
-
* @param eventName
|
|
981
|
-
* @param listener
|
|
982
|
-
*/
|
|
983
|
-
EntityManager.prototype.addEntityEventListener = function (entity, eventName, listener) {
|
|
984
|
-
console.warn("EntityManager.addEntityEventListener is deprecated");
|
|
985
|
-
this.dataset.addEntityEventListener(entity, eventName, listener);
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* @deprecated
|
|
990
|
-
* @param {number} entity
|
|
991
|
-
* @param {string} eventName
|
|
992
|
-
* @param {function} listener
|
|
993
|
-
*/
|
|
994
|
-
EntityManager.prototype.removeEntityEventListener = function (entity, eventName, listener) {
|
|
995
|
-
console.warn("EntityManager.removeEntityEventListener is deprecated");
|
|
996
|
-
this.dataset.removeEntityEventListener(entity, eventName, listener);
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* @deprecated use dataset directly instead
|
|
1001
|
-
* @param entity
|
|
1002
|
-
* @param eventName
|
|
1003
|
-
* @param event
|
|
1004
|
-
*/
|
|
1005
|
-
EntityManager.prototype.sendEvent = function (entity, eventName, event) {
|
|
1006
|
-
console.warn("EntityManager.sendEvent is deprecated");
|
|
1007
|
-
this.dataset.sendEvent(entity, eventName, event);
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* @deprecated
|
|
1012
|
-
* @param {function} klazz
|
|
1013
|
-
* @param {function(component: *, entity: number):boolean} callback
|
|
1014
|
-
* @param {*} [thisArg]
|
|
1015
|
-
* @deprecated
|
|
1016
|
-
*/
|
|
1017
|
-
EntityManager.prototype.traverseComponents = function (klazz, callback, thisArg) {
|
|
1018
|
-
console.warn("EntityManager.traverseComponents is deprecated");
|
|
1019
|
-
if (this.dataset !== null) {
|
|
1020
|
-
this.dataset.traverseComponents(klazz, callback, thisArg);
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
/**
|
|
1025
|
-
* @deprecated Use {@link #getSystem} instead
|
|
1026
|
-
* @template T,C
|
|
1027
|
-
* @param {C} klazz
|
|
1028
|
-
* @returns {System|T}
|
|
1029
|
-
*/
|
|
1030
|
-
EntityManager.prototype.getOwnerSystemByComponentClass = function (klazz) {
|
|
1031
|
-
|
|
1032
|
-
console.warn("EntityManager.getOwnerSystemByComponentClass is deprecated, use .getSystem instead");
|
|
1033
|
-
const index = this.getOwnerSystemIdByComponentClass(klazz);
|
|
1034
|
-
return this.systems[index];
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
|
-
/**
|
|
1038
|
-
* @deprecated
|
|
1039
|
-
* @param {function} clazz
|
|
1040
|
-
* @returns {number} value >= 0, representing system Id, or -1 if system was not found
|
|
1041
|
-
*/
|
|
1042
|
-
EntityManager.prototype.getOwnerSystemIdByComponentClass = function (clazz) {
|
|
1043
|
-
console.warn("EntityManager.getOwnerSystemIdByComponentClass is deprecated, use .getSystem instead");
|
|
1044
|
-
|
|
1045
|
-
const systems = this.systems;
|
|
1046
|
-
let i = 0;
|
|
1047
|
-
const l = systems.length;
|
|
1048
|
-
for (; i < l; i++) {
|
|
1049
|
-
if (systems[i].componentClass === clazz) {
|
|
1050
|
-
return i;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
return -1;
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* same as getComponent when component exists, if component is not associated with the entity, callback will be invoked once when it is added.
|
|
1059
|
-
* @param {Number} entityId
|
|
1060
|
-
* @param {Class} componentClass
|
|
1061
|
-
* @param {function} callback
|
|
1062
|
-
* @param {*} [thisArg]
|
|
1063
|
-
*/
|
|
1064
|
-
EntityManager.prototype.getComponentAsync = function (entityId, componentClass, callback, thisArg) {
|
|
1065
|
-
console.warn("EntityManager.getComponentAsync is deprecated");
|
|
1066
|
-
|
|
1067
|
-
const dataset = this.dataset;
|
|
1068
|
-
|
|
1069
|
-
if (dataset === undefined) {
|
|
1070
|
-
throw new Error('No dataset attached');
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
dataset.getComponentAsync(entityId, componentClass, callback, thisArg);
|
|
1074
|
-
|
|
1075
|
-
};
|
|
1076
|
-
|
|
1077
873
|
export {
|
|
1078
874
|
EventType,
|
|
1079
875
|
EntityManager
|