@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
|
@@ -13,7 +13,7 @@ export class Reference {
|
|
|
13
13
|
#onReleased = new Signal();
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Actual value being held
|
|
17
17
|
* @type {T}
|
|
18
18
|
* @private
|
|
19
19
|
*/
|
|
@@ -27,7 +27,7 @@ export class Reference {
|
|
|
27
27
|
*/
|
|
28
28
|
#is_bound = false;
|
|
29
29
|
|
|
30
|
-
get bound(){
|
|
30
|
+
get bound() {
|
|
31
31
|
return this.#is_bound;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -65,6 +65,10 @@ export class Reference {
|
|
|
65
65
|
return this.#value;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Release value being referenced. After this the held value is set to null
|
|
70
|
+
* This method is idempotent, calling it multiple times is safe
|
|
71
|
+
*/
|
|
68
72
|
release() {
|
|
69
73
|
if (!this.#is_bound) {
|
|
70
74
|
// not bound
|
|
@@ -21,7 +21,7 @@ import { computeStringHash } from "../../../../core/primitives/strings/computeSt
|
|
|
21
21
|
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
22
22
|
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
23
23
|
import { compareStrings } from "../../../../core/primitives/strings/compareStrings.js";
|
|
24
|
-
import {
|
|
24
|
+
import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Convert decibel to percentage volume
|
|
@@ -159,36 +159,36 @@ export class SoundEmitter {
|
|
|
159
159
|
return channel;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const distanceMin =
|
|
162
|
+
const distanceMin = number_compare_ascending(this.__distanceMin, other.__distanceMin);
|
|
163
163
|
|
|
164
164
|
if (distanceMin !== 0) {
|
|
165
165
|
return distanceMin;
|
|
166
166
|
}
|
|
167
|
-
const distanceMax =
|
|
167
|
+
const distanceMax = number_compare_ascending(this.__distanceMax, other.__distanceMax);
|
|
168
168
|
|
|
169
169
|
if (distanceMax !== 0) {
|
|
170
170
|
return distanceMax;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
const panningModel =
|
|
173
|
+
const panningModel = number_compare_ascending(this.panningModel, other.panningModel);
|
|
174
174
|
|
|
175
175
|
if (panningModel !== 0) {
|
|
176
176
|
return panningModel;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
const attenuation =
|
|
179
|
+
const attenuation = number_compare_ascending(this.attenuation, other.attenuation);
|
|
180
180
|
|
|
181
181
|
if (attenuation !== 0) {
|
|
182
182
|
return attenuation;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
const flags =
|
|
185
|
+
const flags = number_compare_ascending(this.flags, other.flags);
|
|
186
186
|
|
|
187
187
|
if (flags !== 0) {
|
|
188
188
|
return flags;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
const volume =
|
|
191
|
+
const volume = number_compare_ascending(this.volume.getValue(), other.volume.getValue());
|
|
192
192
|
|
|
193
193
|
if (volume !== 0) {
|
|
194
194
|
return volume;
|
|
@@ -5,7 +5,7 @@ import { computeStringHash } from "../../../../core/primitives/strings/computeSt
|
|
|
5
5
|
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
6
6
|
import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
7
7
|
import { compareStrings } from "../../../../core/primitives/strings/compareStrings.js";
|
|
8
|
-
import {
|
|
8
|
+
import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
9
9
|
|
|
10
10
|
const DEFAULT_FLAGS = SoundTrackFlags.StartWhenReady;
|
|
11
11
|
|
|
@@ -120,8 +120,8 @@ export class SoundTrack {
|
|
|
120
120
|
// Make the sound source use the buffer and start playing it.
|
|
121
121
|
nodes.source.buffer = this.#buffer;
|
|
122
122
|
|
|
123
|
-
nodes.source.onended = ()=> {
|
|
124
|
-
if(!looping){
|
|
123
|
+
nodes.source.onended = () => {
|
|
124
|
+
if (!looping) {
|
|
125
125
|
this.clearFlag(SoundTrackFlags.Playing);
|
|
126
126
|
this.on.ended.send1(this);
|
|
127
127
|
}
|
|
@@ -167,7 +167,7 @@ export class SoundTrack {
|
|
|
167
167
|
return url;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const time =
|
|
170
|
+
const time = number_compare_ascending(this.time, other.time);
|
|
171
171
|
|
|
172
172
|
if (time !== 0) {
|
|
173
173
|
return time;
|
|
@@ -179,13 +179,13 @@ export class SoundTrack {
|
|
|
179
179
|
return channel;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const volume =
|
|
182
|
+
const volume = number_compare_ascending(this.__volume, other.__volume);
|
|
183
183
|
|
|
184
184
|
if (volume !== 0) {
|
|
185
185
|
return volume;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
const flags =
|
|
188
|
+
const flags = number_compare_ascending(this.flags, other.flags);
|
|
189
189
|
|
|
190
190
|
if (flags !== 0) {
|
|
191
191
|
return flags;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CellFilter } from "../../CellFilter.js";
|
|
2
2
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
3
3
|
import { assert } from "../../../../core/assert.js";
|
|
4
|
-
import { v3_angle_between } from "../../../../core/geom/v3_angle_between.js";
|
|
4
|
+
import { v3_angle_between } from "../../../../core/geom/vec3/v3_angle_between.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Distance from the reference point where support points will be sampled to compute derivative
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { inverseLerp } from "../../../../core/math/inverseLerp.js";
|
|
2
|
-
import { lerp } from "../../../../core/math/lerp.js";
|
|
3
1
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
4
2
|
import { GridTaskGenerator } from "../../GridTaskGenerator.js";
|
|
5
3
|
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
@@ -24,6 +22,7 @@ import { MirGridLayers } from "../../../../../samples/generation/grid/MirGridLay
|
|
|
24
22
|
import { actionTask } from "../../../../core/process/task/util/actionTask.js";
|
|
25
23
|
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
26
24
|
import { groupArrayBy } from "../../../../core/collection/array/groupArrayBy.js";
|
|
25
|
+
import { remap } from "../../../../core/math/remap.js";
|
|
27
26
|
|
|
28
27
|
const NODE_TYPE_ROAD_CONNECTOR = 'Road Connector';
|
|
29
28
|
|
|
@@ -427,8 +426,7 @@ function drawPath(path, actions, traversable, grid) {
|
|
|
427
426
|
for (let i = 0; i < n; i++) {
|
|
428
427
|
const index = pathIndices[i];
|
|
429
428
|
|
|
430
|
-
const
|
|
431
|
-
const thickness = lerp(sourceThickness, targetThickness, f);
|
|
429
|
+
const thickness = remap(0, n, sourceThickness, targetThickness, i);
|
|
432
430
|
|
|
433
431
|
const thickness_0 = Math.floor(thickness / 2);
|
|
434
432
|
const thickness_1 = Math.ceil(thickness / 2);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
2
2
|
import { GridCellAction } from "../../GridCellAction.js";
|
|
3
|
-
import { compareNumbers } from "../../../../../core/primitives/numbers/compareNumbers.js";
|
|
4
3
|
import { assert } from "../../../../../core/assert.js";
|
|
5
4
|
import { binarySearchHighIndex } from "../../../../../core/collection/array/binarySearchHighIndex.js";
|
|
5
|
+
import { number_compare_ascending } from "../../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -111,7 +111,7 @@ export class CellActionSelectWeightedRandom extends GridCellAction {
|
|
|
111
111
|
|
|
112
112
|
const targetWeight = this.__random() * totalWeight;
|
|
113
113
|
|
|
114
|
-
const index = binarySearchHighIndex(evaluatedWeights, targetWeight,
|
|
114
|
+
const index = binarySearchHighIndex(evaluatedWeights, targetWeight, number_compare_ascending, 0, n - 1);
|
|
115
115
|
|
|
116
116
|
const targetElement = elements[index];
|
|
117
117
|
|
|
@@ -5,7 +5,6 @@ import { TerrainLayerRuleAggregator } from "./TerrainLayerRuleAggregator.js";
|
|
|
5
5
|
import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
6
6
|
import Task from "../../core/process/task/Task.js";
|
|
7
7
|
import { TaskSignal } from "../../core/process/task/TaskSignal.js";
|
|
8
|
-
import { compareNumbers } from "../../core/primitives/numbers/compareNumbers.js";
|
|
9
8
|
import TaskGroup from "../../core/process/task/TaskGroup.js";
|
|
10
9
|
import Future from "../../core/process/Future.js";
|
|
11
10
|
import { optimizeIndividualMeshesEntitiesToInstances } from "../../engine/ecs/foliage/ecs/InstancedMeshUtils.js";
|
|
@@ -20,6 +19,7 @@ import { actionTask } from "../../core/process/task/util/actionTask.js";
|
|
|
20
19
|
import { countTask } from "../../core/process/task/util/countTask.js";
|
|
21
20
|
import { emptyTask } from "../../core/process/task/util/emptyTask.js";
|
|
22
21
|
import { futureTask } from "../../core/process/task/util/futureTask.js";
|
|
22
|
+
import { number_compare_ascending } from "../../core/primitives/numbers/number_compare_ascending.js";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
@@ -431,7 +431,7 @@ export class ThemeEngine {
|
|
|
431
431
|
//select a theme
|
|
432
432
|
const t = randomFloatBetween(random, 0, influenceSum);
|
|
433
433
|
|
|
434
|
-
const themeIndex = binarySearchLowIndex(themeInfluence, t,
|
|
434
|
+
const themeIndex = binarySearchLowIndex(themeInfluence, t, number_compare_ascending);
|
|
435
435
|
|
|
436
436
|
const themeArea = themeAreas[themeIndex];
|
|
437
437
|
|
package/src/view/View.js
CHANGED
|
@@ -10,7 +10,8 @@ import Signal from "../core/events/signal/Signal.js";
|
|
|
10
10
|
import { SignalBinding } from "../core/events/signal/SignalBinding.js";
|
|
11
11
|
import { assert } from "../core/assert.js";
|
|
12
12
|
import Vector1 from "../core/geom/Vector1.js";
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
import { m3_cm_compose_transform } from "../core/geom/mat3/m3_cm_compose_transform.js";
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
const scratch_m3_0 = new Float32Array(9);
|
|
@@ -362,10 +363,10 @@ class View {
|
|
|
362
363
|
* @returns {View}
|
|
363
364
|
*/
|
|
364
365
|
addChild(child) {
|
|
365
|
-
assert.
|
|
366
|
-
assert.
|
|
367
|
-
assert.
|
|
368
|
-
assert.
|
|
366
|
+
assert.defined(child, 'child');
|
|
367
|
+
assert.notNull(child, 'child');
|
|
368
|
+
assert.isInstanceOf(child, View, 'child');
|
|
369
|
+
assert.equal(child.isLinked, false, 'child is already linked somewhere');
|
|
369
370
|
|
|
370
371
|
child.parent = this;
|
|
371
372
|
|
|
@@ -425,18 +426,25 @@ class View {
|
|
|
425
426
|
/**
|
|
426
427
|
*
|
|
427
428
|
* @param {View} child
|
|
429
|
+
* @returns {boolean}
|
|
428
430
|
*/
|
|
429
431
|
removeChild(child) {
|
|
430
|
-
const
|
|
431
|
-
if (i !== -1) {
|
|
432
|
-
this.children.splice(i, 1);
|
|
433
|
-
this.el.removeChild(child.el);
|
|
434
|
-
child.unlink();
|
|
432
|
+
const children = this.children;
|
|
435
433
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
434
|
+
const i = children.indexOf(child);
|
|
435
|
+
|
|
436
|
+
if (i === -1) {
|
|
437
|
+
//console.warn('Child not found. this:', this, 'child:', child);
|
|
438
|
+
return false;
|
|
439
439
|
}
|
|
440
|
+
|
|
441
|
+
children.splice(i, 1);
|
|
442
|
+
this.el.removeChild(child.el);
|
|
443
|
+
child.unlink();
|
|
444
|
+
|
|
445
|
+
child.parent = null;
|
|
446
|
+
|
|
447
|
+
return true;
|
|
440
448
|
}
|
|
441
449
|
|
|
442
450
|
/**
|
|
@@ -2,8 +2,8 @@ import GuiControl from "../controller/controls/GuiControl.js";
|
|
|
2
2
|
import { GaugeView } from "../../../editor/view/ecs/components/color/GaugeView.js";
|
|
3
3
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
4
4
|
import { drawCheckers } from "../../../editor/view/ecs/components/particles/ColorParameterLUTController.js";
|
|
5
|
-
import { hsv2rgb } from "../../core/color/hsv2rgb.js";
|
|
6
|
-
import { rgb2hsv } from "../../core/color/rgb2hsv.js";
|
|
5
|
+
import { hsv2rgb } from "../../core/color/hsv/hsv2rgb.js";
|
|
6
|
+
import { rgb2hsv } from "../../core/color/hsv/rgb2hsv.js";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export class ColorPickerView extends GuiControl {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MarkerGLAttributes } from "./MarkerGLAttributes.js";
|
|
2
|
+
import { Reference } from "../../../engine/reference/v2/Reference.js";
|
|
2
3
|
|
|
3
4
|
function logPatchLoadError(e) {
|
|
4
5
|
console.error('Failed to load patch:', e);
|
|
@@ -24,21 +25,23 @@ export function MarkerGL(marker, transform, entity, id, manager) {
|
|
|
24
25
|
|
|
25
26
|
this.id = id;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {Reference<AtlasPatch>}
|
|
31
|
+
*/
|
|
32
|
+
this.patch = Reference.NULL;
|
|
28
33
|
|
|
29
34
|
this.manager = manager;
|
|
30
35
|
this.particles = manager.particles;
|
|
31
36
|
|
|
32
37
|
this.active = false;
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.updatePosition = function () {
|
|
39
|
+
this.updatePosition = () => {
|
|
37
40
|
|
|
38
41
|
const position = transform.position;
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
this.particles.executeOperationWriteAttribute_Vector3(
|
|
44
|
+
this.id,
|
|
42
45
|
MarkerGLAttributes.AttributePosition,
|
|
43
46
|
position.x,
|
|
44
47
|
1,
|
|
@@ -48,26 +51,27 @@ export function MarkerGL(marker, transform, entity, id, manager) {
|
|
|
48
51
|
manager.needsRender = true;
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
this.updateIcon =
|
|
54
|
+
this.updateIcon = (newURL, oldURL) => {
|
|
52
55
|
const atlasManager = manager.atlasManager;
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
atlasManager.release(oldURL);
|
|
56
|
-
}
|
|
57
|
+
this.patch.release();
|
|
57
58
|
|
|
58
59
|
atlasManager
|
|
59
60
|
.acquire(newURL)
|
|
60
|
-
.then(
|
|
61
|
+
.then((patch) => {
|
|
62
|
+
this.patch = patch;
|
|
63
|
+
|
|
61
64
|
//check if marker is still active
|
|
62
|
-
if (!
|
|
65
|
+
if (!this.active) {
|
|
63
66
|
//marker is dead
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
const patchUv = patch.uv;
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
const patchUv = patch.getValue().uv;
|
|
72
|
+
|
|
73
|
+
this.particles.executeOperationWriteAttribute_Vector4(
|
|
74
|
+
this.id,
|
|
71
75
|
MarkerGLAttributes.AttributePatch,
|
|
72
76
|
patchUv.position.x,
|
|
73
77
|
patchUv.position.y,
|
|
@@ -76,8 +80,6 @@ export function MarkerGL(marker, transform, entity, id, manager) {
|
|
|
76
80
|
);
|
|
77
81
|
|
|
78
82
|
manager.needsRender = true;
|
|
79
|
-
|
|
80
|
-
self.patch = patch;
|
|
81
83
|
}, logPatchLoadError);
|
|
82
84
|
};
|
|
83
85
|
}
|
|
@@ -110,5 +112,5 @@ MarkerGL.prototype.shutdown = function () {
|
|
|
110
112
|
this.marker.iconURL.onChanged.remove(this.updateIcon);
|
|
111
113
|
|
|
112
114
|
//release reference to icon
|
|
113
|
-
this.
|
|
115
|
+
this.patch.release();
|
|
114
116
|
};
|
|
@@ -225,7 +225,8 @@ export class MinimapMarkersGL extends MinimapWorldLayer {
|
|
|
225
225
|
updateSprites() {
|
|
226
226
|
|
|
227
227
|
this.markers.forEach((marker) => {
|
|
228
|
-
const patch = marker.patch;
|
|
228
|
+
const patch = marker.patch.getValue();
|
|
229
|
+
|
|
229
230
|
if (patch !== null) {
|
|
230
231
|
/**
|
|
231
232
|
* @type {Rectangle}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import Tool from "./engine/Tool.js";
|
|
2
|
-
import Vector1 from "../../src/core/geom/Vector1.js";
|
|
3
|
-
import ObservedValue from "../../src/core/model/ObservedValue.js";
|
|
4
|
-
import Vector4 from "../../src/core/geom/Vector4.js";
|
|
5
|
-
import loadSampler2D from "../../src/engine/graphics/texture/sampler/loadSampler2D.js";
|
|
6
|
-
import convertSampler2D2Canvas from "../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
7
|
-
import { InstancedMeshComponent } from "../../src/engine/ecs/foliage/ecs/InstancedMeshComponent.js";
|
|
8
|
-
import { hex2rgb } from "../../src/core/color/hex2rgb.js";
|
|
9
|
-
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
10
|
-
|
|
11
|
-
class FoliagePaintTool extends Tool {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.name = "foliage_paint";
|
|
15
|
-
|
|
16
|
-
this.settings.layer = new Vector1(0);
|
|
17
|
-
this.settings.value = new Vector1(1);
|
|
18
|
-
this.settings.alphaMultiplier = new Vector1(1);
|
|
19
|
-
this.settings.color = new ObservedValue("#FFFFFF");
|
|
20
|
-
|
|
21
|
-
this.settings.baseColor = new ObservedValue("#000000");
|
|
22
|
-
this.settings.baseColorAlpha = new Vector1(0.6);
|
|
23
|
-
|
|
24
|
-
const self = this;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
updateSelection() {
|
|
29
|
-
self.paint();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
buildColor() {
|
|
33
|
-
|
|
34
|
-
const color = new Vector4();
|
|
35
|
-
const baseColor = hex2rgb(this.settings.color.get());
|
|
36
|
-
color.set(baseColor.r, baseColor.g, baseColor.b, 0);
|
|
37
|
-
color.multiplyScalar(1 / 255);
|
|
38
|
-
|
|
39
|
-
return color;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
buildBaseColor() {
|
|
43
|
-
|
|
44
|
-
const color = new Vector4();
|
|
45
|
-
const baseColor = hex2rgb(this.settings.baseColor.get());
|
|
46
|
-
color.set(baseColor.r, baseColor.g, baseColor.b, 0);
|
|
47
|
-
color.multiplyScalar(1 / 255);
|
|
48
|
-
|
|
49
|
-
color.w = this.settings.baseColorAlpha.getValue();
|
|
50
|
-
|
|
51
|
-
return color;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
initialize() {
|
|
55
|
-
super.initialize();
|
|
56
|
-
|
|
57
|
-
const engine = this.engine;
|
|
58
|
-
const editor = this.editor;
|
|
59
|
-
|
|
60
|
-
this.terrain = obtainTerrain(engine.entityManager.dataset, function (t, entity) {
|
|
61
|
-
self.terrainEntity = entity;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
this.terrain.overlay.push();
|
|
65
|
-
|
|
66
|
-
this.terrain.overlay.borderWidth.set(0);
|
|
67
|
-
|
|
68
|
-
this.paint();
|
|
69
|
-
|
|
70
|
-
editor.selection.on.added.add(this.updateSelection);
|
|
71
|
-
editor.selection.on.removed.add(this.updateSelection);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
shutdown() {
|
|
75
|
-
this.terrain.overlay.pop();
|
|
76
|
-
|
|
77
|
-
this.editor.selection.on.added.remove(this.updateSelection);
|
|
78
|
-
this.editor.selection.on.removed.remove(this.updateSelection);
|
|
79
|
-
|
|
80
|
-
this.settings.value.onChanged.remove(this.updateSelection);
|
|
81
|
-
this.settings.alphaMultiplier.onChanged.remove(this.updateSelection);
|
|
82
|
-
this.settings.color.onChanged.remove(this.updateSelection);
|
|
83
|
-
|
|
84
|
-
super.shutdown();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
paint() {
|
|
88
|
-
|
|
89
|
-
const alphaMultiplier = this.settings.alphaMultiplier.getValue();
|
|
90
|
-
const overlay = this.terrain.overlay;
|
|
91
|
-
overlay.clear();
|
|
92
|
-
|
|
93
|
-
const layer = this.settings.layer.getValue();
|
|
94
|
-
|
|
95
|
-
const color = this.buildColor();
|
|
96
|
-
|
|
97
|
-
const baseColor = this.buildBaseColor();
|
|
98
|
-
|
|
99
|
-
const engine = this.engine;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @param {InstancedMeshComponent} foliage
|
|
104
|
-
* @param {Number} entity
|
|
105
|
-
*/
|
|
106
|
-
function visit(foliage, entity) {
|
|
107
|
-
const foliageLayer = foliage.layers.get(layer);
|
|
108
|
-
loadSampler2D(foliageLayer.densityMap.get(), engine.assetManager).then(function (sampler) {
|
|
109
|
-
|
|
110
|
-
overlay.size.set(sampler.width, sampler.height);
|
|
111
|
-
overlay.clear();
|
|
112
|
-
|
|
113
|
-
const v4c = new Vector4(0, 0, 0, 0);
|
|
114
|
-
|
|
115
|
-
function mappingFunction(index, array, x, y) {
|
|
116
|
-
const address = index;
|
|
117
|
-
const alpha = sampler.data[address / 4] * alphaMultiplier;
|
|
118
|
-
color.w = alpha;
|
|
119
|
-
|
|
120
|
-
Vector4.lerp(color, baseColor, (1 - alpha), v4c);
|
|
121
|
-
|
|
122
|
-
//scale to unsigned byte value
|
|
123
|
-
v4c.multiplyScalar(255);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
array[address] = v4c.x;
|
|
127
|
-
array[address + 1] = v4c.y;
|
|
128
|
-
array[address + 2] = v4c.z;
|
|
129
|
-
//alpha
|
|
130
|
-
array[address + 3] = v4c.w;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
convertSampler2D2Canvas(sampler, 1, 0, overlay.canvas, mappingFunction);
|
|
134
|
-
|
|
135
|
-
overlay.update();
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//initialize overlay
|
|
140
|
-
this.traverse(visit);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
traverse(callback) {
|
|
144
|
-
/**
|
|
145
|
-
* @type {EntityManager}
|
|
146
|
-
*/
|
|
147
|
-
const entityManger = this.engine.entityManager;
|
|
148
|
-
this.editor.selection.forEach(function (entity) {
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
*
|
|
152
|
-
* @type {InstancedMeshComponent}
|
|
153
|
-
*/
|
|
154
|
-
const foliage = entityManger.getComponent(entity, InstancedMeshComponent);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (foliage === null) {
|
|
158
|
-
//do nothing
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
callback(foliage, entity);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
export default FoliagePaintTool;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { SimpleStateMachineDescription } from "../../../src/core/fsm/simple/SimpleStateMachineDescription.js";
|
|
2
|
-
import { ToolState } from "./ToolState.js";
|
|
3
|
-
import { StateMachine } from "../../../src/core/fsm/StateMachine.js";
|
|
4
|
-
|
|
5
|
-
const smd = new SimpleStateMachineDescription();
|
|
6
|
-
|
|
7
|
-
smd.createState(ToolState.Initial);
|
|
8
|
-
smd.createState(ToolState.Ready);
|
|
9
|
-
smd.createState(ToolState.Running);
|
|
10
|
-
|
|
11
|
-
smd.createEdge(ToolState.Initial, ToolState.Ready);
|
|
12
|
-
smd.createEdge(ToolState.Ready, ToolState.Initial);
|
|
13
|
-
smd.createEdge(ToolState.Ready, ToolState.Running);
|
|
14
|
-
smd.createEdge(ToolState.Running, ToolState.Ready);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {Tool} tool
|
|
19
|
-
* @returns {StateMachine}
|
|
20
|
-
*/
|
|
21
|
-
export function buildToolStateMachine(tool) {
|
|
22
|
-
const sm = new StateMachine(smd);
|
|
23
|
-
|
|
24
|
-
sm.addState(ToolState.Initial);
|
|
25
|
-
sm.addState(ToolState.Ready);
|
|
26
|
-
sm.addState(ToolState.Running);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
sm.createTransition(ToolState.Initial, ToolState.Ready, () => {
|
|
30
|
-
tool.initialize();
|
|
31
|
-
return Promise.resolve();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
sm.createTransition(ToolState.Ready, ToolState.Initial, () => {
|
|
35
|
-
tool.shutdown();
|
|
36
|
-
return Promise.resolve();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
sm.createTransition(ToolState.Ready, ToolState.Running, () => {
|
|
40
|
-
tool.start();
|
|
41
|
-
return Promise.resolve();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
sm.createTransition(ToolState.Running, ToolState.Ready, () => {
|
|
45
|
-
tool.stop();
|
|
46
|
-
return Promise.resolve();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
sm.setState(ToolState.Initial);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return sm;
|
|
53
|
-
}
|
package/src/core/NumberFormat.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number} r 0 to 255
|
|
4
|
-
* @param {number} g 0 to 255
|
|
5
|
-
* @param {number} b 0 to 255
|
|
6
|
-
* @returns {{h: number, s: number, v: number}}
|
|
7
|
-
*/
|
|
8
|
-
export function rgb2hsv(r, g, b) {
|
|
9
|
-
|
|
10
|
-
r /= 255;
|
|
11
|
-
g /= 255;
|
|
12
|
-
b /= 255;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const max = Math.max(r, g, b);
|
|
16
|
-
const min = Math.min(r, g, b);
|
|
17
|
-
|
|
18
|
-
var h, s, v = max;
|
|
19
|
-
|
|
20
|
-
var d = max - min;
|
|
21
|
-
|
|
22
|
-
s = max === 0 ? 0 : d / max;
|
|
23
|
-
|
|
24
|
-
if (max === min) {
|
|
25
|
-
h = 0; // achromatic
|
|
26
|
-
} else {
|
|
27
|
-
switch (max) {
|
|
28
|
-
case r:
|
|
29
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
30
|
-
break;
|
|
31
|
-
case g:
|
|
32
|
-
h = (b - r) / d + 2;
|
|
33
|
-
break;
|
|
34
|
-
case b:
|
|
35
|
-
h = (r - g) / d + 4;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
h /= 6;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
h,
|
|
44
|
-
s,
|
|
45
|
-
v
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { rgb2uint24 } from "./rgb2uint24.js";
|
|
2
|
-
|
|
3
|
-
export function rgb_to_YCbCr_uint24(r, g, b) {
|
|
4
|
-
const Y = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
5
|
-
const Cb = -0.169 * r - 0.331 * g + 0.499 * b + 128;
|
|
6
|
-
const Cr = 0.499 * g - 0.418 * g - 0.0813 * b + 128;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @see https://en.wikipedia.org/wiki/YUV
|
|
10
|
-
* @param {number} r
|
|
11
|
-
* @param {number} g
|
|
12
|
-
* @param {number} b
|
|
13
|
-
* @returns {number}
|
|
14
|
-
*/
|
|
15
|
-
return rgb2uint24(Y,Cb,Cr);
|
|
16
|
-
}
|