@woosh/meep-engine 2.56.1 → 2.57.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/ecs/component/editors/ColorEditor.js +1 -1
- package/editor/ecs/component/editors/ImagePathEditor.js +2 -2
- package/editor/ecs/component/editors/{LargeStrongEditor.js → LargeStringEditor.js} +1 -1
- package/editor/tools/GridPaintTool.js +3 -3
- package/editor/tools/TopDownCameraControlTool.js +1 -1
- package/editor/tools/TransformTool.js +1 -1
- package/editor/tools/engine/Tool.js +9 -23
- package/editor/tools/engine/ToolEngine.js +5 -7
- package/editor/tools/paint/TerrainHeightPaintTool.js +2 -2
- package/editor/tools/paint/TerrainPaintTool.js +2 -2
- package/editor/tools/paint/TerrainTexturePaintTool.js +2 -2
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +1 -1
- package/src/core/bvh2/traversal/__process_point_if_within_planes.js +1 -1
- package/src/core/cache/LoadingCache.js +3 -2
- package/src/core/collection/array/arraySetSortingDiff.spec.js +12 -12
- package/src/core/collection/array/weightedRandomFromArray.js +2 -2
- package/src/core/color/Color.js +6 -6
- package/src/core/color/YCbCr/YCbCr.spec.js +16 -0
- package/src/core/color/{YCbCr_to_rgb_uint24.js → YCbCr/YCbCr_to_rgb_uint24.js} +6 -6
- package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.js +16 -0
- package/src/core/color/{hex2rgb.js → hex/hex2rgb.js} +1 -1
- package/src/core/color/{rgb2hex.js → hex/rgb2hex.js} +1 -1
- package/src/core/color/{hsv2rgb.js → hsv/hsv2rgb.js} +3 -3
- package/src/core/color/hsv/rgb2hsv.js +49 -0
- package/src/core/color/{kelvin_to_rgb.js → kelvin/kelvin_to_rgb.js} +1 -1
- package/src/core/color/{kelvin_to_rgb.spec.js → kelvin/kelvin_to_rgb.spec.js} +2 -2
- package/src/core/color/{prototype_kelvin_to_rgb.js → kelvin/prototype_kelvin_to_rgb.js} +5 -5
- package/src/core/color/{rgb_to_kelvin.spec.js → kelvin/rgb_to_kelvin.spec.js} +1 -1
- package/src/core/color/{parseColor.js → parse_color.js} +4 -4
- package/src/core/color/parse_color.spec.js +18 -0
- package/src/core/color/rgb2uint24.js +3 -3
- package/src/core/color/sRGB/sRGB.spec.js +16 -0
- package/src/core/color/xyz/XYZ.spec.js +16 -0
- package/src/core/color/xyz/rgb_to_xyz.js +15 -0
- package/src/core/color/xyz/xyz_to_rgb.js +14 -0
- package/src/core/events/signal/Signal.js +5 -0
- package/src/core/events/signal/{signalAggregateByTimeWindow.js → signal_aggregate_by_time_window.js} +1 -1
- package/src/core/events/signal/{SignalUtils.js → signal_filter.js} +1 -2
- package/src/core/geom/2d/spline_bezier2_2d.js +26 -0
- package/src/core/geom/2d/spline_bezier2_2d.spec.js +16 -0
- package/src/core/geom/3d/SurfacePoint3.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +1 -1
- package/src/core/geom/3d/compute_circle_bounding_box.js +1 -1
- package/src/core/geom/3d/cone/computeConeBoundingBox.js +1 -1
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +1 -1
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +1 -1
- package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/src/core/geom/3d/normal/spherical/sphere_map_transform.js +1 -1
- package/src/core/geom/3d/plane/is_point_within_planes.js +1 -1
- package/src/core/geom/3d/plane/lerp_planes_to_array.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_convex_3_plane_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_line_segment_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_compute_ray_intersection.js +1 -1
- package/src/core/geom/3d/plane/plane3_lerp.js +2 -2
- package/src/core/geom/3d/plane/plane3_projectPoint.js +1 -1
- package/src/core/geom/3d/plane/plane3_slerp.js +3 -3
- package/src/core/geom/3d/ray/ray_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/ray/ray_distance_to_point.js +1 -1
- package/src/core/geom/3d/shape/UnionShape3D.js +3 -3
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +1 -1
- package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +6 -0
- package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +1 -0
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.spec.js +10 -2
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
- package/src/core/geom/3d/topology/samples/sampleFloodFill.js +1 -1
- package/src/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/src/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +2 -2
- package/src/core/geom/3d/topology/struct/TopoVertex.js +1 -1
- package/src/core/geom/3d/topology/util/compute_face_connection_weight.js +2 -2
- package/src/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +1 -1
- package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
- package/src/core/geom/Quaternion.js +1 -1
- package/src/core/geom/Vector3.js +7 -7
- package/src/core/geom/Vector3.spec.js +68 -1
- package/src/core/geom/mat2/m2_add.js +17 -0
- package/src/core/geom/mat2/m2_determinant.js +8 -0
- package/src/core/geom/mat2/m2_multiply.js +17 -0
- package/src/core/geom/mat2/m2_multiply_scalar.js +18 -0
- package/src/core/geom/mat2/m2_multiply_transposed.js +18 -0
- package/src/core/geom/mat2/m2_sub_transposed.js +17 -0
- package/src/{view → core/geom/mat3}/m3_cm_compose_transform.js +0 -29
- package/src/core/geom/mat3/m3_cm_extract_rotation.js +8 -0
- package/src/core/geom/mat3/m3_cm_from_translation.js +19 -0
- package/src/{view/multiplyMatrices3.js → core/geom/mat3/m3_multiply.js} +2 -2
- package/src/{view → core/geom/mat3}/m3_rm_compose_transform.js +0 -9
- package/src/core/geom/mat3/m3_rm_extract_scale.js +7 -0
- package/src/core/geom/{3d/vector/allocate_v3.js → vec3/v3_allocate.js} +1 -1
- package/src/core/geom/{v3_angle_between.js → vec3/v3_angle_between.js} +1 -1
- package/src/core/geom/vec3/v3_dot_array_array.js +20 -0
- package/src/core/geom/{v3_lerp.js → vec3/v3_lerp.js} +1 -1
- package/src/core/graph/SquareMatrix.js +26 -3
- package/src/core/graph/SquareMatrix.spec.js +52 -2
- package/src/core/math/clamp01.js +1 -0
- package/src/core/math/fract.js +3 -1
- package/src/core/math/inverseLerp.js +7 -5
- package/src/core/math/lerp.js +5 -5
- package/src/core/math/physics/spring/computeHookeForce.js +9 -0
- package/src/core/math/remap.js +19 -0
- package/src/core/math/remap.spec.js +15 -0
- package/src/core/math/smoothStep.spec.js +16 -0
- package/src/core/math/spline/spline_bezier2.js +13 -0
- package/src/core/math/spline/spline_bezier2.spec.js +13 -0
- package/src/core/model/object/compareValues.js +2 -2
- package/src/core/model/object/read_property.js +10 -2
- package/src/core/model/object/write_property.js +3 -23
- package/src/core/model/object/write_property.spec.js +26 -0
- package/src/core/primitives/numbers/number_pretty_print.spec.js +19 -0
- package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +2 -2
- package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +2 -2
- package/src/engine/ecs/systems/SteeringSystem.js +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +1 -1
- package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +3 -11
- package/src/engine/graphics/ecs/highlight/Highlight.js +20 -102
- package/src/engine/graphics/ecs/mesh/Mesh.js +12 -18
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +41 -26
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +3 -3
- package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +1 -1
- package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +5 -6
- package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +3 -3
- package/src/engine/graphics/geometry/MikkT/NormalizeSafe.js +1 -2
- package/src/engine/graphics/geometry/MikkT/STSpace.js +3 -3
- package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +2 -2
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/geometry/clipping/ClippedGeometry.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +102 -95
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.spec.js +25 -0
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +0 -35
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +39 -2
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +22 -6
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -2
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +3 -3
- package/src/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +1 -1
- package/src/engine/graphics/render/layers/RenderLayerUtils.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +3 -2
- package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +1 -1
- package/src/engine/graphics/sh3/sky/hosek/data.js +3744 -0
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +10 -3786
- package/src/engine/graphics/texture/atlas/AbstractTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/atlas/AtlasPatch.js +0 -1
- package/src/engine/graphics/texture/atlas/AtlasPatchFlag.js +8 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +25 -0
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +54 -0
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +101 -160
- package/src/engine/graphics/texture/atlas/TextureAtlas.js +18 -1
- package/src/engine/graphics/texture/sampler/sampler2d_ensure_uint8_RGBA.js +22 -0
- package/src/engine/graphics/util/projectSphere.js +1 -1
- package/src/engine/navigation/ecs/components/Path.js +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +11 -106
- package/src/engine/reference/v2/Reference.js +6 -2
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +7 -7
- package/src/engine/sound/ecs/emitter/SoundTrack.js +6 -6
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +1 -1
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -4
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +2 -2
- package/src/generation/theme/ThemeEngine.js +2 -2
- package/src/generation/theme/ThemeEngine.spec.js +7 -0
- package/src/view/View.js +21 -13
- package/src/view/elements/ColorPickerView.js +2 -2
- package/src/view/minimap/gl/MarkerGL.js +20 -18
- package/src/view/minimap/gl/MinimapMarkersGL.js +2 -1
- package/editor/tools/FoliagePaintTool.js +0 -168
- package/editor/tools/engine/ToolStateMachine.js +0 -53
- package/src/core/NumberFormat.js +0 -4
- package/src/core/color/rgb2hsv.js +0 -47
- package/src/core/color/rgb_to_YCbCr_uint24.js +0 -16
- package/src/core/fsm/StateMachine.js +0 -440
- package/src/core/fsm/Transition.js +0 -65
- package/src/core/geom/Bezier.js +0 -24
- package/src/core/geom/Bezier.spec.js +0 -16
- package/src/core/math/spline/quadraticCurve.js +0 -11
- package/src/core/math/spline/quadraticCurve.spec.js +0 -13
- package/src/core/primitives/numbers/compareNumbers.js +0 -9
- package/src/engine/graphics/ecs/decal/Decal.js +0 -10
- package/src/engine/graphics/ecs/decal/DecalSystem.js +0 -99
- package/src/engine/graphics/ecs/decal/threejs/DecalGeometry.js +0 -298
- package/src/engine/graphics/ecs/trail/Trail.js +0 -83
- package/src/engine/graphics/ecs/trail/TrailMaterial.js +0 -67
- package/src/engine/graphics/ecs/trail/TrailMaterial2.js +0 -73
- package/src/engine/graphics/ecs/trail/TrailSystem.js +0 -162
- package/src/engine/graphics/ecs/water2/NodeWaterShader1.js +0 -213
- package/src/engine/graphics/ecs/water2/shader/JBWaterShader.js +0 -315
- package/src/engine/graphics/geometry/MikkT/Length.js +0 -10
- package/src/engine/graphics/texture/ImageLoader.js +0 -33
- package/src/engine/graphics/three/DDSLoader.js +0 -286
- package/src/engine/graphics/three/Water2.js +0 -343
- package/src/engine/physics/spring/computeHookeForce.js +0 -9
- package/src/engine/reference/v1/ReferenceManager.js +0 -124
- /package/src/core/color/{hex2rgb.spec.js → hex/hex2rgb.spec.js} +0 -0
- /package/src/core/color/{rgb2hex.spec.js → hex/rgb2hex.spec.js} +0 -0
- /package/src/core/color/{hsv2rgb.spec.js → hsv/hsv2rgb.spec.js} +0 -0
- /package/src/core/color/{rgb_to_kelvin.js → kelvin/rgb_to_kelvin.js} +0 -0
- /package/src/core/color/{linear_to_sRGB.js → sRGB/linear_to_sRGB.js} +0 -0
- /package/src/core/color/{sRGB_to_linear.js → sRGB/sRGB_to_linear.js} +0 -0
- /package/src/core/geom/{m3_determinant.js → mat3/m3_determinant.js} +0 -0
- /package/src/core/geom/{v3_distance.js → vec3/v3_distance.js} +0 -0
- /package/src/core/geom/{v3_distance_above_plane.js → vec3/v3_distance_above_plane.js} +0 -0
- /package/src/core/geom/{v3_distance_above_plane.spec.js → vec3/v3_distance_above_plane.spec.js} +0 -0
- /package/src/core/geom/{v3_distance_sqr.d.ts → vec3/v3_distance_sqr.d.ts} +0 -0
- /package/src/core/geom/{v3_distance_sqr.js → vec3/v3_distance_sqr.js} +0 -0
- /package/src/core/geom/{v3_dot.js → vec3/v3_dot.js} +0 -0
- /package/src/core/geom/{v3_length.js → vec3/v3_length.js} +0 -0
- /package/src/core/geom/{v3_length_sqr.js → vec3/v3_length_sqr.js} +0 -0
- /package/src/core/geom/{v3_slerp.js → vec3/v3_slerp.js} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parse_color } from "./parse_color.js";
|
|
2
|
+
|
|
3
|
+
test("number", () => {
|
|
4
|
+
expect(parse_color(0xCAFEBE)).toEqual([0xCA, 0xFE, 0xBE, 1]);
|
|
5
|
+
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("hash", () => {
|
|
9
|
+
expect(parse_color("#CAFEBE")).toEqual([0xCA, 0xFE, 0xBE, 1]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("rgba(r,g,b,a)", () => {
|
|
13
|
+
expect(parse_color("rgba(7,13,11,0.6)")).toEqual([7, 13, 11, 0.6]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("rgba(r,g,b)", () => {
|
|
17
|
+
expect(parse_color("rgb(7,13,11)")).toEqual([7, 13, 11, 1]);
|
|
18
|
+
});
|
|
@@ -2,9 +2,9 @@ import { float2uint8 } from "../binary/float2uint8.js";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
|
-
* @param {number} r
|
|
6
|
-
* @param {number} g
|
|
7
|
-
* @param {number} b
|
|
5
|
+
* @param {number} r in 0..1 range
|
|
6
|
+
* @param {number} g in 0..1 range
|
|
7
|
+
* @param {number} b in 0..1 range
|
|
8
8
|
* @returns {number}
|
|
9
9
|
*/
|
|
10
10
|
export function rgb2uint24(r, g, b) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { linear_to_sRGB } from "./linear_to_sRGB.js";
|
|
2
|
+
import { sRGB_to_linear } from "./sRGB_to_linear.js";
|
|
3
|
+
|
|
4
|
+
test("to/from consistency", () => {
|
|
5
|
+
|
|
6
|
+
const source = [0.7, 0.11, 0.31];
|
|
7
|
+
const srgb = [];
|
|
8
|
+
const decoded = [];
|
|
9
|
+
|
|
10
|
+
linear_to_sRGB(srgb, 0, source, 0);
|
|
11
|
+
sRGB_to_linear(decoded, 0, srgb, 0);
|
|
12
|
+
|
|
13
|
+
expect(decoded[0]).toBeCloseTo(source[0]);
|
|
14
|
+
expect(decoded[1]).toBeCloseTo(source[1]);
|
|
15
|
+
expect(decoded[2]).toBeCloseTo(source[2]);
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rgb_to_xyz } from "./rgb_to_xyz.js";
|
|
2
|
+
import { xyz_to_rgb } from "./xyz_to_rgb.js";
|
|
3
|
+
|
|
4
|
+
test("to/from consistency", () => {
|
|
5
|
+
|
|
6
|
+
const source = [0.7, 0.11, 0.31];
|
|
7
|
+
const srgb = [];
|
|
8
|
+
const decoded = [];
|
|
9
|
+
|
|
10
|
+
rgb_to_xyz(srgb, source);
|
|
11
|
+
xyz_to_rgb(decoded, srgb);
|
|
12
|
+
|
|
13
|
+
expect(decoded[0]).toBeCloseTo(source[0]);
|
|
14
|
+
expect(decoded[1]).toBeCloseTo(source[1]);
|
|
15
|
+
expect(decoded[2]).toBeCloseTo(source[2]);
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assumes linear RGB space
|
|
3
|
+
* @param {vec3} out
|
|
4
|
+
* @param {vec3} input
|
|
5
|
+
*/
|
|
6
|
+
export function rgb_to_xyz(out, input) {
|
|
7
|
+
|
|
8
|
+
const x = input[0];
|
|
9
|
+
const y = input[1];
|
|
10
|
+
const z = input[2];
|
|
11
|
+
|
|
12
|
+
out[0] = 0.4124564 * x + 0.3575761 * y + 0.1804375 * z;
|
|
13
|
+
out[1] = 0.2126729 * x + 0.7151522 * y + 0.0721750 * z;
|
|
14
|
+
out[2] = 0.0193339 * x + 0.1191920 * y + 0.9503041 * z;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {vec3} out
|
|
4
|
+
* @param {vec3} input
|
|
5
|
+
*/
|
|
6
|
+
export function xyz_to_rgb(out, input) {
|
|
7
|
+
const x = input[0];
|
|
8
|
+
const y = input[1];
|
|
9
|
+
const z = input[2];
|
|
10
|
+
|
|
11
|
+
out[0] = 3.2404542 * x - 1.5371385 * y - 0.4985314 * z;
|
|
12
|
+
out[1] = (-0.9692660) * x + 1.8760108 * y + 0.0415560 * z;
|
|
13
|
+
out[2] = 0.0556434 * x - 0.2040259 * y + 1.0572252 * z;
|
|
14
|
+
}
|
|
@@ -16,6 +16,11 @@ import { SignalFlags } from "./SignalFlags.js";
|
|
|
16
16
|
const dispatch_stack = [];
|
|
17
17
|
let dispatch_stack_top = 0;
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Signal is a type of event bus. You can subscribe to events using {@link add) method and dispatch using sendN method where N is the number of arguments you wish to pass
|
|
21
|
+
* Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference. Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
|
|
22
|
+
* @example `const mouseDown = new Signal<MouseEvent>(); mouseDown.send1(myMouseEvent);`
|
|
23
|
+
*/
|
|
19
24
|
export class Signal {
|
|
20
25
|
/**
|
|
21
26
|
* Event dispatcher dedicated to single event type
|
package/src/core/events/signal/{signalAggregateByTimeWindow.js → signal_aggregate_by_time_window.js}
RENAMED
|
@@ -8,7 +8,7 @@ import Signal from "./Signal.js";
|
|
|
8
8
|
* @param {*} [thisArg]
|
|
9
9
|
* @returns {{handler: handler, signal: Signal}}
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function signal_aggregate_by_time_window(delay, transform = passThrough, thisArg) {
|
|
12
12
|
let bucket = [];
|
|
13
13
|
let timeout = null;
|
|
14
14
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { spline_bezier2 } from "../../math/spline/spline_bezier2.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Vector2} result
|
|
6
|
+
* @param {number} p0x
|
|
7
|
+
* @param {number} p0y
|
|
8
|
+
* @param {number} p1x
|
|
9
|
+
* @param {number} p1y
|
|
10
|
+
* @param {number} p2x
|
|
11
|
+
* @param {number} p2y
|
|
12
|
+
* @param {number} t
|
|
13
|
+
*/
|
|
14
|
+
export function spline_bezier2_2d(
|
|
15
|
+
result,
|
|
16
|
+
p0x, p0y,
|
|
17
|
+
p1x, p1y,
|
|
18
|
+
p2x, p2y,
|
|
19
|
+
t
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
const x0 = spline_bezier2(t, p0x, p1x, p2x);
|
|
23
|
+
const y0 = spline_bezier2(t, p0y, p1y, p2y);
|
|
24
|
+
|
|
25
|
+
result.set(x0, y0);
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spline_bezier2_2d } from "./spline_bezier2_2d.js";
|
|
2
|
+
import Vector2 from "../Vector2.js";
|
|
3
|
+
|
|
4
|
+
test("spline_bezier2_2d hits knots",()=>{
|
|
5
|
+
const v2 = new Vector2();
|
|
6
|
+
|
|
7
|
+
spline_bezier2_2d(v2,1,3,5,7,11,13,0);
|
|
8
|
+
|
|
9
|
+
expect(v2.x).toBeCloseTo(1);
|
|
10
|
+
expect(v2.y).toBeCloseTo(3);
|
|
11
|
+
|
|
12
|
+
spline_bezier2_2d(v2,1,3,5,7,11,13,1);
|
|
13
|
+
|
|
14
|
+
expect(v2.x).toBeCloseTo(11);
|
|
15
|
+
expect(v2.y).toBeCloseTo(13);
|
|
16
|
+
});
|
|
@@ -4,7 +4,7 @@ import { aabb3_corner_edge_mapping } from "./aabb3_corner_edge_mapping.js";
|
|
|
4
4
|
import { aabb3_edge_corner_mapping } from "./aabb3_edge_corner_mapping.js";
|
|
5
5
|
import { plane3_compute_convex_3_plane_intersection } from "../plane/plane3_compute_convex_3_plane_intersection.js";
|
|
6
6
|
import { is_point_within_planes } from "../plane/is_point_within_planes.js";
|
|
7
|
-
import { v3_distance_above_plane } from "../../v3_distance_above_plane.js";
|
|
7
|
+
import { v3_distance_above_plane } from "../../vec3/v3_distance_above_plane.js";
|
|
8
8
|
import { EPSILON } from "../../../math/EPSILON.js";
|
|
9
9
|
import { plane3_compute_line_segment_intersection } from "../plane/plane3_compute_line_segment_intersection.js";
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { aabb3_build_corners } from "./aabb3_build_corners.js";
|
|
2
2
|
import { aabb3_matrix4_project_by_corners } from "./aabb3_matrix4_project_by_corners.js";
|
|
3
|
-
import { v3_distance_above_plane } from "../../v3_distance_above_plane.js";
|
|
3
|
+
import { v3_distance_above_plane } from "../../vec3/v3_distance_above_plane.js";
|
|
4
4
|
|
|
5
5
|
const scratch_corners = new Float32Array(24);
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { max2 } from "../../../math/max2.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
|
-
import { v3_angle_between } from "../../v3_angle_between.js";
|
|
3
|
+
import { v3_angle_between } from "../../vec3/v3_angle_between.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: used stackoverflow answer as a basis for circle part: https://stackoverflow.com/questions/2592011/bounding-boxes-for-circle-and-arcs-in-3d
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vector3 from "../../Vector3.js";
|
|
2
2
|
import { plane3_projectPoint } from "../plane/plane3_projectPoint.js";
|
|
3
3
|
import { ray_computeNearestPointToPoint } from "../ray/ray_computeNearestPointToPoint.js";
|
|
4
|
-
import { v3_distance_above_plane } from "../../v3_distance_above_plane.js";
|
|
4
|
+
import { v3_distance_above_plane } from "../../vec3/v3_distance_above_plane.js";
|
|
5
5
|
import {
|
|
6
6
|
plane3_three_compute_convex_3_plane_intersection
|
|
7
7
|
} from "../plane/plane3_three_compute_convex_3_plane_intersection.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encode_unit_to_hemioct } from "./encode_unit3_hemioct.js";
|
|
2
|
-
import { v3_length } from "../../../v3_length.js";
|
|
2
|
+
import { v3_length } from "../../../vec3/v3_length.js";
|
|
3
3
|
import { decode_hemioct_to_unit } from "./decode_hemioct_to_unit.js";
|
|
4
4
|
|
|
5
5
|
test('encode-decode', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
2
|
import Vector3 from "../../Vector3.js";
|
|
3
3
|
import { plane3_intersect_plane } from "./plane3_intersect_plane.js";
|
|
4
|
-
import { v3_dot } from "../../v3_dot.js";
|
|
5
|
-
import { v3_length } from "../../v3_length.js";
|
|
4
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
5
|
+
import { v3_length } from "../../vec3/v3_length.js";
|
|
6
6
|
|
|
7
7
|
const v0 = new Vector3();
|
|
8
8
|
const v1 = new Vector3();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
2
|
import Vector3 from "../../Vector3.js";
|
|
3
|
-
import { v3_dot } from "../../v3_dot.js";
|
|
4
|
-
import { v3_length_sqr } from "../../v3_length_sqr.js";
|
|
5
|
-
import { v3_slerp } from "../../v3_slerp.js";
|
|
3
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
4
|
+
import { v3_length_sqr } from "../../vec3/v3_length_sqr.js";
|
|
5
|
+
import { v3_slerp } from "../../vec3/v3_slerp.js";
|
|
6
6
|
import { EPSILON } from "../../../math/EPSILON.js";
|
|
7
7
|
|
|
8
8
|
const e = new Vector3();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
2
|
import { seededRandom } from "../../../math/random/seededRandom.js";
|
|
3
3
|
import { binarySearchHighIndex } from "../../../collection/array/binarySearchHighIndex.js";
|
|
4
|
-
import { compareNumbers } from "../../../primitives/numbers/compareNumbers.js";
|
|
5
4
|
import { min2 } from "../../../math/min2.js";
|
|
6
5
|
import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
|
|
7
6
|
import { isArrayEqual } from "../../../collection/array/isArrayEqual.js";
|
|
8
7
|
import { max2 } from "../../../math/max2.js";
|
|
8
|
+
import { number_compare_ascending } from "../../../primitives/numbers/number_compare_ascending.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* To avoid severe performance overhead, we limit number of possible rejections
|
|
@@ -128,7 +128,7 @@ export class UnionShape3D extends AbstractShape3D {
|
|
|
128
128
|
const target_weight = random() * child_volume_sum;
|
|
129
129
|
|
|
130
130
|
// weighted search for a sample candidate, preferring larger volumes, resulting in more uniform sample distribution
|
|
131
|
-
const target_child_index = binarySearchHighIndex(child_volume_sums, target_weight,
|
|
131
|
+
const target_child_index = binarySearchHighIndex(child_volume_sums, target_weight, number_compare_ascending, 0, child_count - 1);
|
|
132
132
|
|
|
133
133
|
const child_0 = children[target_child_index];
|
|
134
134
|
|
|
@@ -248,7 +248,7 @@ export class UnionShape3D extends AbstractShape3D {
|
|
|
248
248
|
const target_weight = random() * this.__volume_sum;
|
|
249
249
|
|
|
250
250
|
// weighted search for a sample candidate, preferring larger volumes, resulting in more uniform sample distribution
|
|
251
|
-
const target_child_index = binarySearchHighIndex(this.__volume_sums, target_weight,
|
|
251
|
+
const target_child_index = binarySearchHighIndex(this.__volume_sums, target_weight, number_compare_ascending, 0, child_count - 1);
|
|
252
252
|
|
|
253
253
|
const child = children[target_child_index];
|
|
254
254
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
2
|
import { randomPointInBox } from "../../random/randomPointInBox.js";
|
|
3
|
-
import { v3_length } from "../../v3_length.js";
|
|
3
|
+
import { v3_length } from "../../vec3/v3_length.js";
|
|
4
4
|
import { max2 } from "../../../math/max2.js";
|
|
5
5
|
import { max3 } from "../../../math/max3.js";
|
|
6
6
|
import { min2 } from "../../../math/min2.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
2
|
import { randomPointInSphere } from "../../random/randomPointInSphere.js";
|
|
3
|
-
import { v3_length } from "../../v3_length.js";
|
|
3
|
+
import { v3_length } from "../../vec3/v3_length.js";
|
|
4
4
|
import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v3_dot } from "../../v3_dot.js";
|
|
1
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
3
|
import { max2 } from "../../../math/max2.js";
|
|
4
4
|
import { plane3_compute_convex_3_plane_intersection } from "../plane/plane3_compute_convex_3_plane_intersection.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compute_bounding_simplex_3d } from "./compute_bounding_simplex_3d.js";
|
|
2
|
-
import { v3_distance } from "../../v3_distance.js";
|
|
2
|
+
import { v3_distance } from "../../vec3/v3_distance.js";
|
|
3
3
|
import { orient3d_fast } from "../plane/orient3d_fast.js";
|
|
4
4
|
|
|
5
5
|
test('one point', () => {
|
|
@@ -23,6 +23,7 @@ import { assert } from "../../../../assert.js";
|
|
|
23
23
|
export function compute_delaunay_tetrahedral_mesh(mesh, input, n = input.length / 3) {
|
|
24
24
|
assert.notNull(mesh, 'mesh');
|
|
25
25
|
assert.defined(mesh, 'mesh');
|
|
26
|
+
assert.equal(mesh.isTetrahedralMesh, true, 'mesh.isTetrahedralMesh !== true');
|
|
26
27
|
|
|
27
28
|
assert.isNonNegativeInteger(n, 'n');
|
|
28
29
|
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { compute_delaunay_tetrahedral_mesh } from "./compute_delaunay_tetrahedral_mesh.js";
|
|
6
|
+
import { TetrahedralMesh } from "../TetrahedralMesh.js";
|
|
2
7
|
|
|
3
8
|
test('single point', () => {
|
|
4
|
-
|
|
9
|
+
const mesh = new TetrahedralMesh();
|
|
10
|
+
|
|
11
|
+
compute_delaunay_tetrahedral_mesh(mesh, [1, 2, 3], 1);
|
|
5
12
|
});
|
|
6
13
|
|
|
7
14
|
test('exactly 4 points', () => {
|
|
8
|
-
|
|
15
|
+
const mesh = new TetrahedralMesh();
|
|
16
|
+
compute_delaunay_tetrahedral_mesh(mesh, [
|
|
9
17
|
-1, 0, 0,
|
|
10
18
|
1, 0, 0,
|
|
11
19
|
0.5, 1, 0,
|
|
@@ -3,7 +3,7 @@ import { PointSet } from "../../../packing/miniball/PointSet.js";
|
|
|
3
3
|
import { ConicRay } from "../../../ConicRay.js";
|
|
4
4
|
import { array_copy } from "../../../../collection/array/array_copy.js";
|
|
5
5
|
import { min2 } from "../../../../math/min2.js";
|
|
6
|
-
import { v3_angle_between } from "../../../v3_angle_between.js";
|
|
6
|
+
import { v3_angle_between } from "../../../vec3/v3_angle_between.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Using Shirman and Abi-Ezzi method, compute bounding sphere of points, then build a cone from that
|
|
@@ -12,7 +12,7 @@ import { compute_aabb_from_points } from "../../aabb/compute_aabb_from_points.js
|
|
|
12
12
|
import { AABB3 } from "../../../../geom/3d/aabb/AABB3.js";
|
|
13
13
|
import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
14
14
|
import { makeGeometryIndexed } from "../../../../../engine/graphics/geometry/buffered/makeGeometryIndexed.js";
|
|
15
|
-
import { v3_dot } from "../../../v3_dot.js";
|
|
15
|
+
import { v3_dot } from "../../../vec3/v3_dot.js";
|
|
16
16
|
import { TopoMesh } from "../struct/TopoMesh.js";
|
|
17
17
|
import { SGMeshSystem } from "../../../../../engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js";
|
|
18
18
|
import { SGMesh } from "../../../../../engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { query_edge_other_vertex } from "../query/query_edge_other_vertex.js";
|
|
2
2
|
import { query_face_next_vertex } from "../query/query_face_next_vertex.js";
|
|
3
3
|
import { query_face_prev_vertex } from "../query/query_face_prev_vertex.js";
|
|
4
|
-
import { v3_length_sqr } from "../../../v3_length_sqr.js";
|
|
5
|
-
import { v3_dot } from "../../../v3_dot.js";
|
|
4
|
+
import { v3_length_sqr } from "../../../vec3/v3_length_sqr.js";
|
|
5
|
+
import { v3_dot } from "../../../vec3/v3_dot.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @see https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/bmesh/tools/bmesh_decimate_collapse.c#L164
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../../../assert.js";
|
|
2
2
|
import { array_push_if_unique } from "../../../../collection/array/array_push_if_unique.js";
|
|
3
3
|
import { array_remove_first } from "../../../../collection/array/array_remove_first.js";
|
|
4
|
-
import { v3_distance } from "../../../v3_distance.js";
|
|
4
|
+
import { v3_distance } from "../../../vec3/v3_distance.js";
|
|
5
5
|
|
|
6
6
|
export class TopoVertex {
|
|
7
7
|
constructor() {
|
|
@@ -8,7 +8,7 @@ import Signal from "../events/signal/Signal.js";
|
|
|
8
8
|
import { clamp } from "../math/clamp.js";
|
|
9
9
|
import { lerp } from "../math/lerp.js";
|
|
10
10
|
import Vector3 from "./Vector3.js";
|
|
11
|
-
import { v3_dot } from "./v3_dot.js";
|
|
11
|
+
import { v3_dot } from "./vec3/v3_dot.js";
|
|
12
12
|
import { min2 } from "../math/min2.js";
|
|
13
13
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
14
14
|
import { epsilonEquals } from "../math/epsilonEquals.js";
|
package/src/core/geom/Vector3.js
CHANGED
|
@@ -7,12 +7,12 @@ import { assert } from "../assert.js";
|
|
|
7
7
|
import Signal from "../events/signal/Signal.js";
|
|
8
8
|
import { lerp } from "../math/lerp.js";
|
|
9
9
|
import { sign } from "../math/sign.js";
|
|
10
|
-
import { v3_dot } from "./v3_dot.js";
|
|
11
|
-
import { v3_length_sqr } from "./v3_length_sqr.js";
|
|
12
|
-
import { v3_length } from "./v3_length.js";
|
|
13
|
-
import { v3_angle_between } from "./v3_angle_between.js";
|
|
14
|
-
import { v3_lerp } from "./v3_lerp.js";
|
|
15
|
-
import { v3_slerp } from "./v3_slerp.js";
|
|
10
|
+
import { v3_dot } from "./vec3/v3_dot.js";
|
|
11
|
+
import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
|
|
12
|
+
import { v3_length } from "./vec3/v3_length.js";
|
|
13
|
+
import { v3_angle_between } from "./vec3/v3_angle_between.js";
|
|
14
|
+
import { v3_lerp } from "./vec3/v3_lerp.js";
|
|
15
|
+
import { v3_slerp } from "./vec3/v3_slerp.js";
|
|
16
16
|
import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
|
|
17
17
|
import { epsilonEquals } from "../math/epsilonEquals.js";
|
|
18
18
|
import { EPSILON } from "../math/EPSILON.js";
|
|
@@ -992,7 +992,7 @@ class Vector3 {
|
|
|
992
992
|
* @returns {number}
|
|
993
993
|
*/
|
|
994
994
|
static dot(a, b) {
|
|
995
|
-
return
|
|
995
|
+
return v3_dot(a.x, a.y, a.z, b.x, b.y, b.z);
|
|
996
996
|
}
|
|
997
997
|
|
|
998
998
|
/**
|