@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.
Files changed (227) hide show
  1. package/editor/ecs/component/editors/ColorEditor.js +1 -1
  2. package/editor/ecs/component/editors/ImagePathEditor.js +2 -2
  3. package/editor/ecs/component/editors/{LargeStrongEditor.js → LargeStringEditor.js} +1 -1
  4. package/editor/tools/GridPaintTool.js +3 -3
  5. package/editor/tools/TopDownCameraControlTool.js +1 -1
  6. package/editor/tools/TransformTool.js +1 -1
  7. package/editor/tools/engine/Tool.js +9 -23
  8. package/editor/tools/engine/ToolEngine.js +5 -7
  9. package/editor/tools/paint/TerrainHeightPaintTool.js +2 -2
  10. package/editor/tools/paint/TerrainPaintTool.js +2 -2
  11. package/editor/tools/paint/TerrainTexturePaintTool.js +2 -2
  12. package/package.json +1 -1
  13. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
  14. package/src/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +1 -1
  15. package/src/core/bvh2/traversal/__process_point_if_within_planes.js +1 -1
  16. package/src/core/cache/LoadingCache.js +3 -2
  17. package/src/core/collection/array/arraySetSortingDiff.spec.js +12 -12
  18. package/src/core/collection/array/weightedRandomFromArray.js +2 -2
  19. package/src/core/color/Color.js +6 -6
  20. package/src/core/color/YCbCr/YCbCr.spec.js +16 -0
  21. package/src/core/color/{YCbCr_to_rgb_uint24.js → YCbCr/YCbCr_to_rgb_uint24.js} +6 -6
  22. package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.js +16 -0
  23. package/src/core/color/{hex2rgb.js → hex/hex2rgb.js} +1 -1
  24. package/src/core/color/{rgb2hex.js → hex/rgb2hex.js} +1 -1
  25. package/src/core/color/{hsv2rgb.js → hsv/hsv2rgb.js} +3 -3
  26. package/src/core/color/hsv/rgb2hsv.js +49 -0
  27. package/src/core/color/{kelvin_to_rgb.js → kelvin/kelvin_to_rgb.js} +1 -1
  28. package/src/core/color/{kelvin_to_rgb.spec.js → kelvin/kelvin_to_rgb.spec.js} +2 -2
  29. package/src/core/color/{prototype_kelvin_to_rgb.js → kelvin/prototype_kelvin_to_rgb.js} +5 -5
  30. package/src/core/color/{rgb_to_kelvin.spec.js → kelvin/rgb_to_kelvin.spec.js} +1 -1
  31. package/src/core/color/{parseColor.js → parse_color.js} +4 -4
  32. package/src/core/color/parse_color.spec.js +18 -0
  33. package/src/core/color/rgb2uint24.js +3 -3
  34. package/src/core/color/sRGB/sRGB.spec.js +16 -0
  35. package/src/core/color/xyz/XYZ.spec.js +16 -0
  36. package/src/core/color/xyz/rgb_to_xyz.js +15 -0
  37. package/src/core/color/xyz/xyz_to_rgb.js +14 -0
  38. package/src/core/events/signal/Signal.js +5 -0
  39. package/src/core/events/signal/{signalAggregateByTimeWindow.js → signal_aggregate_by_time_window.js} +1 -1
  40. package/src/core/events/signal/{SignalUtils.js → signal_filter.js} +1 -2
  41. package/src/core/geom/2d/spline_bezier2_2d.js +26 -0
  42. package/src/core/geom/2d/spline_bezier2_2d.spec.js +16 -0
  43. package/src/core/geom/3d/SurfacePoint3.js +1 -1
  44. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +1 -1
  45. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
  46. package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +1 -1
  47. package/src/core/geom/3d/compute_circle_bounding_box.js +1 -1
  48. package/src/core/geom/3d/cone/computeConeBoundingBox.js +1 -1
  49. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  50. package/src/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +1 -1
  51. package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +1 -1
  52. package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
  53. package/src/core/geom/3d/normal/spherical/sphere_map_transform.js +1 -1
  54. package/src/core/geom/3d/plane/is_point_within_planes.js +1 -1
  55. package/src/core/geom/3d/plane/lerp_planes_to_array.js +1 -1
  56. package/src/core/geom/3d/plane/plane3_compute_convex_3_plane_intersection.js +1 -1
  57. package/src/core/geom/3d/plane/plane3_compute_line_segment_intersection.js +1 -1
  58. package/src/core/geom/3d/plane/plane3_compute_ray_intersection.js +1 -1
  59. package/src/core/geom/3d/plane/plane3_lerp.js +2 -2
  60. package/src/core/geom/3d/plane/plane3_projectPoint.js +1 -1
  61. package/src/core/geom/3d/plane/plane3_slerp.js +3 -3
  62. package/src/core/geom/3d/ray/ray_computeNearestPointToPoint.js +1 -1
  63. package/src/core/geom/3d/ray/ray_distance_to_point.js +1 -1
  64. package/src/core/geom/3d/shape/UnionShape3D.js +3 -3
  65. package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
  66. package/src/core/geom/3d/shape/UnitSphereShape3D.js +1 -1
  67. package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
  68. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +6 -0
  69. package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +1 -1
  70. package/src/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +1 -1
  71. package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
  72. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +1 -0
  73. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.spec.js +10 -2
  74. package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
  75. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +1 -1
  76. package/src/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
  77. package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
  78. package/src/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +2 -2
  79. package/src/core/geom/3d/topology/struct/TopoVertex.js +1 -1
  80. package/src/core/geom/3d/topology/util/compute_face_connection_weight.js +2 -2
  81. package/src/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
  82. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
  83. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +1 -1
  84. package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
  85. package/src/core/geom/Quaternion.js +1 -1
  86. package/src/core/geom/Vector3.js +7 -7
  87. package/src/core/geom/Vector3.spec.js +68 -1
  88. package/src/core/geom/mat2/m2_add.js +17 -0
  89. package/src/core/geom/mat2/m2_determinant.js +8 -0
  90. package/src/core/geom/mat2/m2_multiply.js +17 -0
  91. package/src/core/geom/mat2/m2_multiply_scalar.js +18 -0
  92. package/src/core/geom/mat2/m2_multiply_transposed.js +18 -0
  93. package/src/core/geom/mat2/m2_sub_transposed.js +17 -0
  94. package/src/{view → core/geom/mat3}/m3_cm_compose_transform.js +0 -29
  95. package/src/core/geom/mat3/m3_cm_extract_rotation.js +8 -0
  96. package/src/core/geom/mat3/m3_cm_from_translation.js +19 -0
  97. package/src/{view/multiplyMatrices3.js → core/geom/mat3/m3_multiply.js} +2 -2
  98. package/src/{view → core/geom/mat3}/m3_rm_compose_transform.js +0 -9
  99. package/src/core/geom/mat3/m3_rm_extract_scale.js +7 -0
  100. package/src/core/geom/{3d/vector/allocate_v3.js → vec3/v3_allocate.js} +1 -1
  101. package/src/core/geom/{v3_angle_between.js → vec3/v3_angle_between.js} +1 -1
  102. package/src/core/geom/vec3/v3_dot_array_array.js +20 -0
  103. package/src/core/geom/{v3_lerp.js → vec3/v3_lerp.js} +1 -1
  104. package/src/core/graph/SquareMatrix.js +26 -3
  105. package/src/core/graph/SquareMatrix.spec.js +52 -2
  106. package/src/core/math/clamp01.js +1 -0
  107. package/src/core/math/fract.js +3 -1
  108. package/src/core/math/inverseLerp.js +7 -5
  109. package/src/core/math/lerp.js +5 -5
  110. package/src/core/math/physics/spring/computeHookeForce.js +9 -0
  111. package/src/core/math/remap.js +19 -0
  112. package/src/core/math/remap.spec.js +15 -0
  113. package/src/core/math/smoothStep.spec.js +16 -0
  114. package/src/core/math/spline/spline_bezier2.js +13 -0
  115. package/src/core/math/spline/spline_bezier2.spec.js +13 -0
  116. package/src/core/model/object/compareValues.js +2 -2
  117. package/src/core/model/object/read_property.js +10 -2
  118. package/src/core/model/object/write_property.js +3 -23
  119. package/src/core/model/object/write_property.spec.js +26 -0
  120. package/src/core/primitives/numbers/number_pretty_print.spec.js +19 -0
  121. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +2 -2
  122. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +2 -2
  123. package/src/engine/ecs/systems/SteeringSystem.js +1 -1
  124. package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
  125. package/src/engine/graphics/ecs/camera/Camera.js +1 -1
  126. package/src/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  127. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +3 -11
  128. package/src/engine/graphics/ecs/highlight/Highlight.js +20 -102
  129. package/src/engine/graphics/ecs/mesh/Mesh.js +12 -18
  130. package/src/engine/graphics/ecs/mesh/MeshSystem.js +41 -26
  131. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +1 -1
  132. package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +1 -1
  133. package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +1 -1
  134. package/src/engine/graphics/ecs/path/tube/build/make_cap.js +3 -3
  135. package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +1 -1
  136. package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +5 -6
  137. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +3 -3
  138. package/src/engine/graphics/geometry/MikkT/NormalizeSafe.js +1 -2
  139. package/src/engine/graphics/geometry/MikkT/STSpace.js +3 -3
  140. package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +2 -2
  141. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  142. package/src/engine/graphics/geometry/clipping/ClippedGeometry.js +1 -1
  143. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +102 -95
  144. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.spec.js +25 -0
  145. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +0 -35
  146. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +39 -2
  147. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +22 -6
  148. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  149. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -2
  150. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +3 -3
  151. package/src/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +1 -1
  152. package/src/engine/graphics/render/layers/RenderLayerUtils.js +1 -1
  153. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +3 -2
  154. package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
  155. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  156. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
  157. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +1 -1
  158. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
  159. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +1 -1
  160. package/src/engine/graphics/sh3/sky/hosek/data.js +3744 -0
  161. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +10 -3786
  162. package/src/engine/graphics/texture/atlas/AbstractTextureAtlas.js +1 -1
  163. package/src/engine/graphics/texture/atlas/AtlasPatch.js +0 -1
  164. package/src/engine/graphics/texture/atlas/AtlasPatchFlag.js +8 -1
  165. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +25 -0
  166. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +54 -0
  167. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +101 -160
  168. package/src/engine/graphics/texture/atlas/TextureAtlas.js +18 -1
  169. package/src/engine/graphics/texture/sampler/sampler2d_ensure_uint8_RGBA.js +22 -0
  170. package/src/engine/graphics/util/projectSphere.js +1 -1
  171. package/src/engine/navigation/ecs/components/Path.js +1 -1
  172. package/src/engine/physics/mls-mpm/MLS_MPM.js +11 -106
  173. package/src/engine/reference/v2/Reference.js +6 -2
  174. package/src/engine/sound/ecs/emitter/SoundEmitter.js +7 -7
  175. package/src/engine/sound/ecs/emitter/SoundTrack.js +6 -6
  176. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +1 -1
  177. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -4
  178. package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +2 -2
  179. package/src/generation/theme/ThemeEngine.js +2 -2
  180. package/src/generation/theme/ThemeEngine.spec.js +7 -0
  181. package/src/view/View.js +21 -13
  182. package/src/view/elements/ColorPickerView.js +2 -2
  183. package/src/view/minimap/gl/MarkerGL.js +20 -18
  184. package/src/view/minimap/gl/MinimapMarkersGL.js +2 -1
  185. package/editor/tools/FoliagePaintTool.js +0 -168
  186. package/editor/tools/engine/ToolStateMachine.js +0 -53
  187. package/src/core/NumberFormat.js +0 -4
  188. package/src/core/color/rgb2hsv.js +0 -47
  189. package/src/core/color/rgb_to_YCbCr_uint24.js +0 -16
  190. package/src/core/fsm/StateMachine.js +0 -440
  191. package/src/core/fsm/Transition.js +0 -65
  192. package/src/core/geom/Bezier.js +0 -24
  193. package/src/core/geom/Bezier.spec.js +0 -16
  194. package/src/core/math/spline/quadraticCurve.js +0 -11
  195. package/src/core/math/spline/quadraticCurve.spec.js +0 -13
  196. package/src/core/primitives/numbers/compareNumbers.js +0 -9
  197. package/src/engine/graphics/ecs/decal/Decal.js +0 -10
  198. package/src/engine/graphics/ecs/decal/DecalSystem.js +0 -99
  199. package/src/engine/graphics/ecs/decal/threejs/DecalGeometry.js +0 -298
  200. package/src/engine/graphics/ecs/trail/Trail.js +0 -83
  201. package/src/engine/graphics/ecs/trail/TrailMaterial.js +0 -67
  202. package/src/engine/graphics/ecs/trail/TrailMaterial2.js +0 -73
  203. package/src/engine/graphics/ecs/trail/TrailSystem.js +0 -162
  204. package/src/engine/graphics/ecs/water2/NodeWaterShader1.js +0 -213
  205. package/src/engine/graphics/ecs/water2/shader/JBWaterShader.js +0 -315
  206. package/src/engine/graphics/geometry/MikkT/Length.js +0 -10
  207. package/src/engine/graphics/texture/ImageLoader.js +0 -33
  208. package/src/engine/graphics/three/DDSLoader.js +0 -286
  209. package/src/engine/graphics/three/Water2.js +0 -343
  210. package/src/engine/physics/spring/computeHookeForce.js +0 -9
  211. package/src/engine/reference/v1/ReferenceManager.js +0 -124
  212. /package/src/core/color/{hex2rgb.spec.js → hex/hex2rgb.spec.js} +0 -0
  213. /package/src/core/color/{rgb2hex.spec.js → hex/rgb2hex.spec.js} +0 -0
  214. /package/src/core/color/{hsv2rgb.spec.js → hsv/hsv2rgb.spec.js} +0 -0
  215. /package/src/core/color/{rgb_to_kelvin.js → kelvin/rgb_to_kelvin.js} +0 -0
  216. /package/src/core/color/{linear_to_sRGB.js → sRGB/linear_to_sRGB.js} +0 -0
  217. /package/src/core/color/{sRGB_to_linear.js → sRGB/sRGB_to_linear.js} +0 -0
  218. /package/src/core/geom/{m3_determinant.js → mat3/m3_determinant.js} +0 -0
  219. /package/src/core/geom/{v3_distance.js → vec3/v3_distance.js} +0 -0
  220. /package/src/core/geom/{v3_distance_above_plane.js → vec3/v3_distance_above_plane.js} +0 -0
  221. /package/src/core/geom/{v3_distance_above_plane.spec.js → vec3/v3_distance_above_plane.spec.js} +0 -0
  222. /package/src/core/geom/{v3_distance_sqr.d.ts → vec3/v3_distance_sqr.d.ts} +0 -0
  223. /package/src/core/geom/{v3_distance_sqr.js → vec3/v3_distance_sqr.js} +0 -0
  224. /package/src/core/geom/{v3_dot.js → vec3/v3_dot.js} +0 -0
  225. /package/src/core/geom/{v3_length.js → vec3/v3_length.js} +0 -0
  226. /package/src/core/geom/{v3_length_sqr.js → vec3/v3_length_sqr.js} +0 -0
  227. /package/src/core/geom/{v3_slerp.js → vec3/v3_slerp.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { TypeEditor } from "../TypeEditor.js";
2
2
  import EmptyView from "../../../../src/view/elements/EmptyView.js";
3
- import { rgb2hex } from "../../../../src/core/color/rgb2hex.js";
3
+ import { rgb2hex } from "../../../../src/core/color/hex/rgb2hex.js";
4
4
 
5
5
  export class ColorEditor extends TypeEditor {
6
6
  build(parent, field) {
@@ -4,13 +4,13 @@ import ImageView from "../../../../src/view/elements/image/ImageView.js";
4
4
  import ButtonView from "../../../../src/view/elements/button/ButtonView.js";
5
5
  import { url_to_data_url } from "../../../../src/core/binary/url_to_data_url.js";
6
6
  import { is_data_url } from "../../../../src/core/binary/is_data_url.js";
7
- import { LargeStrongEditor } from "./LargeStrongEditor.js";
7
+ import { LargeStringEditor } from "./LargeStringEditor.js";
8
8
 
9
9
  export class ImagePathEditor extends TypeEditor {
10
10
  inline = true;
11
11
 
12
12
  build(parent, field, registry) {
13
- const url_editor = new LargeStrongEditor();
13
+ const url_editor = new LargeStringEditor();
14
14
 
15
15
  const editor = url_editor.build(parent, field, registry);
16
16
 
@@ -20,7 +20,7 @@ const MAX_PATH_LENGTH_EDITABLE = 256;
20
20
  */
21
21
  const MAX_CROP_LENGTH = 32;
22
22
 
23
- export class LargeStrongEditor extends TypeEditor {
23
+ export class LargeStringEditor extends TypeEditor {
24
24
  inline = true;
25
25
 
26
26
  build(parent, field, registry) {
@@ -10,7 +10,7 @@ import { decodeMouseEventButtons, PointerDevice } from "../../src/engine/input/d
10
10
  import Vector2 from "../../src/core/geom/Vector2.js";
11
11
  import TopDownCameraControllerSystem
12
12
  from "../../src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
13
- import { hex2rgb } from "../../src/core/color/hex2rgb.js";
13
+ import { hex2rgb } from "../../src/core/color/hex/hex2rgb.js";
14
14
  import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
15
15
  import { pick } from "../../src/engine/ecs/grid/pick.js";
16
16
 
@@ -116,7 +116,7 @@ class GridPaintTool extends Tool {
116
116
  });
117
117
  }
118
118
 
119
- shutdown() {
119
+ finalize() {
120
120
  this.terrain.overlay.pop();
121
121
 
122
122
  this.editor.selection.on.added.remove(this.paint, this);
@@ -128,7 +128,7 @@ class GridPaintTool extends Tool {
128
128
 
129
129
  this.cameraController.stop();
130
130
 
131
- super.shutdown();
131
+ super.finalize();
132
132
  }
133
133
 
134
134
  affectTile(_x, _y) {
@@ -48,7 +48,7 @@ class TopDownCameraControlTool extends Tool {
48
48
  this.__controller.build(ecd);
49
49
  }
50
50
 
51
- shutdown() {
51
+ finalize() {
52
52
  this.system.enabled.set(false);
53
53
 
54
54
  this.__controller.destroy();
@@ -301,7 +301,7 @@ export class TransformTool extends Tool {
301
301
  this.editor.engine.graphics.scene.add(this.editObject);
302
302
  }
303
303
 
304
- shutdown() {
304
+ finalize() {
305
305
  this.editor.selection.forEach(this.handlers.handleSelectionRemoved);
306
306
  this.bindings.forEach(function (b) {
307
307
  b.unlink();
@@ -4,11 +4,12 @@
4
4
 
5
5
 
6
6
  import ObservedValue from '../../../src/core/model/ObservedValue.js';
7
- import { buildToolStateMachine } from "./ToolStateMachine.js";
8
7
  import { ToolState } from "./ToolState.js";
9
8
  import ObservedString from "../../../src/core/model/ObservedString.js";
10
9
 
11
10
  class Tool {
11
+ #state = ToolState.Initial;
12
+
12
13
  /**
13
14
  *
14
15
  * @constructor
@@ -38,12 +39,6 @@ class Tool {
38
39
  * @type {ObservedString}
39
40
  */
40
41
  this.icon = new ObservedString("");
41
-
42
- /**
43
- *
44
- * @type {StateMachine}
45
- */
46
- this.stateMachine = buildToolStateMachine(this);
47
42
  }
48
43
 
49
44
  /**
@@ -59,35 +54,25 @@ class Tool {
59
54
  * @returns {ToolState|number}
60
55
  */
61
56
  getState() {
62
- return this.stateMachine.getState();
57
+ return this.#state;
63
58
  }
64
59
 
65
60
  isRunning() {
66
- return this.getState() === ToolState.Running;
67
- }
68
-
69
- /**
70
- *
71
- * @param {ToolState} s
72
- * @returns {Promise}
73
- */
74
- moveToState(s) {
75
- const sm = this.stateMachine;
76
-
77
- return sm.navigateTo(s);
61
+ return this.#state === ToolState.Running;
78
62
  }
79
63
 
80
64
  /**
81
65
  * Activate the tool and prepare it for usage
82
66
  */
83
67
  initialize() {
68
+ this.#state = ToolState.Ready;
84
69
  }
85
70
 
86
71
  /**
87
72
  * Deactivate the tool and remove and influence it may have
88
73
  */
89
- shutdown() {
90
-
74
+ finalize() {
75
+ this.#state = ToolState.Ready;
91
76
  }
92
77
 
93
78
  /**
@@ -102,6 +87,7 @@ class Tool {
102
87
  * @example Start painting with a brush
103
88
  */
104
89
  start() {
90
+ this.#state = ToolState.Running;
105
91
  }
106
92
 
107
93
  /**
@@ -109,7 +95,7 @@ class Tool {
109
95
  * @example Finish brush stroke
110
96
  */
111
97
  stop() {
112
-
98
+ this.#state = ToolState.Ready;
113
99
  }
114
100
 
115
101
  handleKeyboardEvent(e) {
@@ -10,9 +10,7 @@ import { decodeMouseEventButtons, PointerDevice } from '../../../src/engine/inpu
10
10
  import SelectionTool from '../SelectionTool.js';
11
11
  import TopDownCameraControlTool from '../TopDownCameraControlTool.js';
12
12
  import GridPaintTool from "../GridPaintTool.js";
13
- import FoliagePaintTool from "../FoliagePaintTool.js";
14
13
  import { TransformTool } from "../TransformTool.js";
15
- import { ToolState } from "./ToolState.js";
16
14
  import Clock from "../../../src/engine/Clock.js";
17
15
  import { TerrainHeightPaintTool } from "../paint/TerrainHeightPaintTool.js";
18
16
  import { TerrainTexturePaintTool } from "../paint/TerrainTexturePaintTool.js";
@@ -47,14 +45,14 @@ ToolEngine.prototype.initialize = function () {
47
45
  console.log("active tool changed. Old: ", oldTool, ", New :", newTool);
48
46
 
49
47
  if (oldTool !== null && typeof oldTool === "object") {
50
- oldTool.moveToState(ToolState.Initial);
48
+ oldTool.finalize();
51
49
  }
52
50
 
53
51
  if (newTool !== null && typeof newTool === "object") {
54
52
  newTool.editor = this.editor;
55
53
  newTool.engine = this.engine;
56
54
 
57
- newTool.moveToState(ToolState.Ready);
55
+ newTool.initialize();
58
56
  }
59
57
  });
60
58
 
@@ -88,7 +86,7 @@ ToolEngine.prototype.initialize = function () {
88
86
  .add(terrainTexturePaintTool1)
89
87
  .add(terrainTexturePaintTool2)
90
88
  .add(terrainTexturePaintTool3)
91
- .add(new FoliagePaintTool());
89
+ ;
92
90
  };
93
91
 
94
92
  /**
@@ -144,7 +142,7 @@ ToolEngine.prototype.startup = function (engine, editor) {
144
142
 
145
143
  }
146
144
 
147
- tool.moveToState(ToolState.Running);
145
+ tool.start();
148
146
  }
149
147
  }
150
148
 
@@ -152,7 +150,7 @@ ToolEngine.prototype.startup = function (engine, editor) {
152
150
  const tool = self.active.get();
153
151
  if (tool !== null) {
154
152
 
155
- tool.moveToState(ToolState.Ready);
153
+ tool.stop();
156
154
  }
157
155
  }
158
156
 
@@ -158,8 +158,8 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
158
158
 
159
159
  }
160
160
 
161
- shutdown() {
162
- super.shutdown();
161
+ finalize() {
162
+ super.finalize();
163
163
  }
164
164
 
165
165
  /**
@@ -198,8 +198,8 @@ export class TerrainPaintTool extends Tool {
198
198
  engine.devices.pointer.on.wheel.add(this.__handleMouseWheel, this);
199
199
  }
200
200
 
201
- shutdown() {
202
- super.shutdown();
201
+ finalize() {
202
+ super.finalize();
203
203
 
204
204
 
205
205
  this.terrain.overlay.pop();
@@ -86,8 +86,8 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
86
86
  super.initialize();
87
87
  }
88
88
 
89
- shutdown() {
90
- super.shutdown();
89
+ finalize() {
90
+ super.finalize();
91
91
  }
92
92
 
93
93
  async paint(timeDelta) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.56.1",
8
+ "version": "2.57.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -5,7 +5,7 @@ import { array_copy } from "../../../collection/array/array_copy.js";
5
5
  import { NULL_NODE } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
6
6
  import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
7
7
  import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
8
- import { v3_distance_above_plane } from "../../../geom/v3_distance_above_plane.js";
8
+ import { v3_distance_above_plane } from "../../../geom/vec3/v3_distance_above_plane.js";
9
9
  import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
10
10
 
11
11
  const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
@@ -3,7 +3,7 @@ import { read_frustum_planes_to_array } from "../../geom/3d/frustum/read_frustum
3
3
  import {
4
4
  aabb3_detailed_volume_intersection_callback_based
5
5
  } from "./aabb3_detailed_volume_intersection_callback_based.js";
6
- import { v3_distance_above_plane } from "../../geom/v3_distance_above_plane.js";
6
+ import { v3_distance_above_plane } from "../../geom/vec3/v3_distance_above_plane.js";
7
7
 
8
8
  export class ThreeClippingPlaneComputingBVHVisitor extends BVHVisitor {
9
9
  constructor() {
@@ -1,4 +1,4 @@
1
- import { v3_distance_above_plane } from "../../geom/v3_distance_above_plane.js";
1
+ import { v3_distance_above_plane } from "../../geom/vec3/v3_distance_above_plane.js";
2
2
  import { EPSILON } from "../../math/EPSILON.js";
3
3
 
4
4
  /**
@@ -24,7 +24,7 @@ class Record {
24
24
  * @readonly
25
25
  * @type {number}
26
26
  */
27
- const DEFAULT_TIME_TO_LIVE = 300; // 5 Minutes
27
+ const DEFAULT_TIME_TO_LIVE = Infinity;
28
28
 
29
29
  /**
30
30
  * Asynchronous cache capable of resolving its own values by keys
@@ -56,6 +56,7 @@ export class LoadingCache {
56
56
 
57
57
  /**
58
58
  * @see {@link Cache} for more details on what each parameter means
59
+ * @template K,V
59
60
  * @param [maxWeight]
60
61
  * @param [keyWeigher]
61
62
  * @param [valueWeigher]
@@ -63,7 +64,7 @@ export class LoadingCache {
63
64
  * @param [keyEqualityFunction]
64
65
  * @param [capacity]
65
66
  * @param {number} [timeToLive] in seconds, default is 10 seconds
66
- * @param load
67
+ * @param {function(key:K):Promise<V>} load
67
68
  * @param {boolean} [retryFailed]
68
69
  */
69
70
  constructor({
@@ -1,8 +1,8 @@
1
1
  import { arraySetSortingDiff } from "./arraySetSortingDiff.js";
2
- import { compareNumbers } from "../../primitives/numbers/compareNumbers.js";
2
+ import { number_compare_ascending } from "../../primitives/numbers/number_compare_ascending.js";
3
3
 
4
4
  test('two empty inputs', () => {
5
- expect(arraySetSortingDiff([], [], compareNumbers)).toEqual({
5
+ expect(arraySetSortingDiff([], [], number_compare_ascending)).toEqual({
6
6
  uniqueA: [],
7
7
  uniqueB: [],
8
8
  common: []
@@ -10,7 +10,7 @@ test('two empty inputs', () => {
10
10
  });
11
11
 
12
12
  test('[] and [1] inputs', () => {
13
- expect(arraySetSortingDiff([], [1], compareNumbers)).toEqual({
13
+ expect(arraySetSortingDiff([], [1], number_compare_ascending)).toEqual({
14
14
  uniqueA: [],
15
15
  uniqueB: [1],
16
16
  common: []
@@ -18,7 +18,7 @@ test('[] and [1] inputs', () => {
18
18
  });
19
19
 
20
20
  test('[1] and [] inputs', () => {
21
- expect(arraySetSortingDiff([1], [], compareNumbers)).toEqual({
21
+ expect(arraySetSortingDiff([1], [], number_compare_ascending)).toEqual({
22
22
  uniqueA: [1],
23
23
  uniqueB: [],
24
24
  common: []
@@ -26,7 +26,7 @@ test('[1] and [] inputs', () => {
26
26
  });
27
27
 
28
28
  test('[1] and [1] inputs', () => {
29
- expect(arraySetSortingDiff([1], [1], compareNumbers)).toEqual({
29
+ expect(arraySetSortingDiff([1], [1], number_compare_ascending)).toEqual({
30
30
  uniqueA: [],
31
31
  uniqueB: [],
32
32
  common: [1]
@@ -34,7 +34,7 @@ test('[1] and [1] inputs', () => {
34
34
  });
35
35
 
36
36
  test('[1] and [1,2] inputs', () => {
37
- expect(arraySetSortingDiff([1], [1, 2], compareNumbers)).toEqual({
37
+ expect(arraySetSortingDiff([1], [1, 2], number_compare_ascending)).toEqual({
38
38
  uniqueA: [],
39
39
  uniqueB: [2],
40
40
  common: [1]
@@ -42,7 +42,7 @@ test('[1] and [1,2] inputs', () => {
42
42
  });
43
43
 
44
44
  test('[1,2] and [1] inputs', () => {
45
- expect(arraySetSortingDiff([1, 2], [1], compareNumbers)).toEqual({
45
+ expect(arraySetSortingDiff([1, 2], [1], number_compare_ascending)).toEqual({
46
46
  uniqueA: [2],
47
47
  uniqueB: [],
48
48
  common: [1]
@@ -50,7 +50,7 @@ test('[1,2] and [1] inputs', () => {
50
50
  });
51
51
 
52
52
  test('[5,4,3,2,1] and [1,2,3,4,5] inputs', () => {
53
- expect(arraySetSortingDiff([5, 4, 3, 2, 1], [1, 2, 3, 4, 5], compareNumbers)).toEqual({
53
+ expect(arraySetSortingDiff([5, 4, 3, 2, 1], [1, 2, 3, 4, 5], number_compare_ascending)).toEqual({
54
54
  uniqueA: [],
55
55
  uniqueB: [],
56
56
  common: [1, 2, 3, 4, 5]
@@ -58,16 +58,16 @@ test('[5,4,3,2,1] and [1,2,3,4,5] inputs', () => {
58
58
  });
59
59
 
60
60
  test('[5,1] and [1,2,3,4,5] inputs', () => {
61
- expect(arraySetSortingDiff([5, 1], [1, 2, 3, 4, 5], compareNumbers)).toEqual({
61
+ expect(arraySetSortingDiff([5, 1], [1, 2, 3, 4, 5], number_compare_ascending)).toEqual({
62
62
  uniqueA: [],
63
- uniqueB: [2,3,4],
63
+ uniqueB: [2, 3, 4],
64
64
  common: [1, 5]
65
65
  });
66
66
  });
67
67
 
68
68
  test('[1,2,3,4,5] and [5,1] inputs', () => {
69
- expect(arraySetSortingDiff([1, 2, 3, 4, 5], [5, 1], compareNumbers)).toEqual({
70
- uniqueA: [2,3,4],
69
+ expect(arraySetSortingDiff([1, 2, 3, 4, 5], [5, 1], number_compare_ascending)).toEqual({
70
+ uniqueA: [2, 3, 4],
71
71
  uniqueB: [],
72
72
  common: [1, 5]
73
73
  });
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../assert.js";
2
- import { compareNumbers } from "../../primitives/numbers/compareNumbers.js";
3
2
  import { binarySearchHighIndex } from "./binarySearchHighIndex.js";
3
+ import { number_compare_ascending } from "../../primitives/numbers/number_compare_ascending.js";
4
4
 
5
5
 
6
6
  /**
@@ -45,7 +45,7 @@ export function weightedRandomFromArray(array, random, weight, weightContext, le
45
45
 
46
46
  const target_weight = random() * weight_total;
47
47
 
48
- const index = binarySearchHighIndex(scratch_weights, target_weight, compareNumbers, 0, length - 1);
48
+ const index = binarySearchHighIndex(scratch_weights, target_weight, number_compare_ascending, 0, length - 1);
49
49
 
50
50
  return array[index];
51
51
  }
@@ -1,15 +1,15 @@
1
1
  import { assert } from "../assert.js";
2
2
  import Signal from "../events/signal/Signal.js";
3
- import { parseColor } from "./parseColor.js";
3
+ import { parse_color } from "./parse_color.js";
4
4
  import { min2 } from "../math/min2.js";
5
5
  import { max2 } from "../math/max2.js";
6
6
  import { min3 } from "../math/min3.js";
7
- import { rgb2hsv } from "./rgb2hsv.js";
7
+ import { rgb2hsv } from "./hsv/rgb2hsv.js";
8
8
  import { rgb2uint24 } from "./rgb2uint24.js";
9
9
  import { clamp01 } from "../math/clamp01.js";
10
- import { rgb2hex } from "./rgb2hex.js";
11
- import { linear_to_sRGB } from "./linear_to_sRGB.js";
12
- import { sRGB_to_linear } from "./sRGB_to_linear.js";
10
+ import { rgb2hex } from "./hex/rgb2hex.js";
11
+ import { linear_to_sRGB } from "./sRGB/linear_to_sRGB.js";
12
+ import { sRGB_to_linear } from "./sRGB/sRGB_to_linear.js";
13
13
  import { lerp } from "../math/lerp.js";
14
14
  import { float2uint8 } from "../binary/float2uint8.js";
15
15
 
@@ -534,7 +534,7 @@ export class Color {
534
534
  * @returns {void}
535
535
  */
536
536
  parse(str) {
537
- const c = parseColor(str);
537
+ const c = parse_color(str);
538
538
 
539
539
  if (typeof c[3] === "number") {
540
540
  this.a = c[3];
@@ -0,0 +1,16 @@
1
+ import { rgb_to_YCbCr_uint24 } from "./rgb_to_YCbCr_uint24.js";
2
+ import { YCbCr_to_rgb_uint24 } from "./YCbCr_to_rgb_uint24.js";
3
+
4
+ test("to/from consistency", () => {
5
+
6
+ const encoded = rgb_to_YCbCr_uint24(31, 73, 201);
7
+ const decoded = YCbCr_to_rgb_uint24((encoded >> 16) & 0xFF, (encoded >> 8) & 0xFF, encoded & 0xFF)
8
+
9
+ const r = ((decoded >> 16) & 0xFF);
10
+ const g = ((decoded >> 8) & 0xFF);
11
+ const b = ((decoded) & 0xFF);
12
+
13
+ expect(Math.abs(r - 31)).toBeLessThan(30);
14
+ expect(Math.abs(g - 73)).toBeLessThan(30);
15
+ expect(Math.abs(b - 201)).toBeLessThan(30);
16
+ });
@@ -1,10 +1,8 @@
1
- import { rgb2uint24 } from "./rgb2uint24.js";
2
-
3
1
  /**
4
2
  * @see https://en.wikipedia.org/wiki/YUV
5
- * @param {number} Y
6
- * @param {number} Cb
7
- * @param {number} Cr
3
+ * @param {number} Y in range 0...255
4
+ * @param {number} Cb in range 0...255
5
+ * @param {number} Cr in range 0...255
8
6
  * @returns {number}
9
7
  */
10
8
  export function YCbCr_to_rgb_uint24(Y, Cb, Cr) {
@@ -15,5 +13,7 @@ export function YCbCr_to_rgb_uint24(Y, Cb, Cr) {
15
13
  const g = Y - ((_Cb >> 2) + (_Cb >> 4) + (_Cb >> 5)) - ((_Cr >> 1) + (_Cr >> 3) + (_Cr >> 4) + (_Cr >> 5));
16
14
  const b = Y + _Cb + (_Cb >> 1) + (_Cb >> 2) + (_Cb >> 6);
17
15
 
18
- return rgb2uint24(r, g, b);
16
+ return ((r << 16) & 0xFF0000)
17
+ | ((g << 8) & 0xFF00)
18
+ | (b & 0xFF);
19
19
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * @param r in range 0...255
4
+ * @param g in range 0...255
5
+ * @param b in range 0...255
6
+ * @return {number}
7
+ */
8
+ export function rgb_to_YCbCr_uint24(r, g, b) {
9
+ const Y = 0.299 * r + 0.587 * g + 0.114 * b;
10
+ const Cb = -0.169 * r - 0.331 * g + 0.499 * b + 128;
11
+ const Cr = 0.499 * g - 0.418 * g - 0.0813 * b + 128;
12
+
13
+ return ((Y << 16) & 0xFF0000)
14
+ | ((Cb << 8) & 0xFF00)
15
+ | (Cr & 0xFF);
16
+ }
@@ -1,4 +1,4 @@
1
- import { hex2dec } from "../binary/hex2dec.js";
1
+ import { hex2dec } from "../../binary/hex2dec.js";
2
2
 
3
3
  /**
4
4
  *
@@ -1,4 +1,4 @@
1
- import { dec2hex } from "../binary/dec2hex.js";
1
+ import { dec2hex } from "../../binary/dec2hex.js";
2
2
 
3
3
  /**
4
4
  * Takes values in 0..255 range
@@ -1,12 +1,12 @@
1
- import { clamp01 } from "../math/clamp01.js";
2
- import { float2uint8 } from "../binary/float2uint8.js";
1
+ import { clamp01 } from "../../math/clamp01.js";
2
+ import { float2uint8 } from "../../binary/float2uint8.js";
3
3
 
4
4
  /**
5
5
  *
6
6
  * @param {number} h from 0 to 1
7
7
  * @param {number} s from 0 to 1
8
8
  * @param {number} v from 0 to 1
9
- * @returns {{r: number, g: number, b: number}}
9
+ * @returns {{r: number, g: number, b: number}} output in range 0..255
10
10
  */
11
11
  export function hsv2rgb(h, s, v) {
12
12
 
@@ -0,0 +1,49 @@
1
+ import { uint82float } from "../../binary/uint82float.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} r 0 to 255
6
+ * @param {number} g 0 to 255
7
+ * @param {number} b 0 to 255
8
+ * @returns {{h: number, s: number, v: number}}
9
+ */
10
+ export function rgb2hsv(r, g, b) {
11
+
12
+ const _r = uint82float(r);
13
+ const _g = uint82float(g);
14
+ const _b = uint82float(b);
15
+
16
+
17
+ const max = Math.max(_r, _g, _b);
18
+ const min = Math.min(_r, _g, _b);
19
+
20
+ let h, s, v = max;
21
+
22
+ const d = max - min;
23
+
24
+ s = max === 0 ? 0 : d / max;
25
+
26
+ if (max === min) {
27
+ h = 0; // achromatic
28
+ } else {
29
+ switch (max) {
30
+ case _r:
31
+ h = (_g - _b) / d + (_g < _b ? 6 : 0);
32
+ break;
33
+ case _g:
34
+ h = (_b - _r) / d + 2;
35
+ break;
36
+ case _b:
37
+ h = (_r - _g) / d + 4;
38
+ break;
39
+ }
40
+
41
+ h /= 6;
42
+ }
43
+
44
+ return {
45
+ h,
46
+ s,
47
+ v
48
+ };
49
+ }
@@ -1,4 +1,4 @@
1
- import { clamp01 } from "../math/clamp01.js";
1
+ import { clamp01 } from "../../math/clamp01.js";
2
2
 
3
3
  /**
4
4
  * @see https://www.zombieprototypes.com/?p=210
@@ -1,6 +1,6 @@
1
1
  import { kelvin_to_rgb } from "./kelvin_to_rgb.js";
2
- import { v3_distance } from "../geom/v3_distance.js";
3
- import { Color } from "./Color.js";
2
+ import { v3_distance } from "../../geom/vec3/v3_distance.js";
3
+ import { Color } from "../Color.js";
4
4
 
5
5
  function rgb([r255, g255, b255]) {
6
6
  return [r255 * 255, g255 * 255, b255 * 255];
@@ -1,9 +1,9 @@
1
- import { CanvasView } from "../../view/elements/CanvasView.js";
1
+ import { CanvasView } from "../../../view/elements/CanvasView.js";
2
2
  import { kelvin_to_rgb } from "./kelvin_to_rgb.js";
3
- import { lerp } from "../math/lerp.js";
4
- import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
5
- import sampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
6
- import { sRGB_to_linear } from "./sRGB_to_linear.js";
3
+ import { lerp } from "../../math/lerp.js";
4
+ import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
5
+ import sampler2D2Canvas from "../../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
6
+ import { sRGB_to_linear } from "../sRGB/sRGB_to_linear.js";
7
7
 
8
8
  const view = new CanvasView();
9
9
 
@@ -1,5 +1,5 @@
1
1
  import { rgb_to_kelvin } from "./rgb_to_kelvin.js";
2
- import { Color } from "./Color.js";
2
+ import { Color } from "../Color.js";
3
3
 
4
4
 
5
5
  test("1000 K", () => {
@@ -2,8 +2,8 @@
2
2
  * Created by Alex on 02/05/2016.
3
3
  */
4
4
 
5
- import { hsv2rgb } from "./hsv2rgb.js";
6
- import { hex2rgb } from "./hex2rgb.js";
5
+ import { hsv2rgb } from "./hsv/hsv2rgb.js";
6
+ import { hex2rgb } from "./hex/hex2rgb.js";
7
7
 
8
8
 
9
9
  const rgbRegEx = /rgb\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+)\s*\)/;
@@ -11,11 +11,11 @@ const rgbaRegEx = /rgba\(\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([
11
11
  const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
12
12
 
13
13
  /**
14
- *
14
+ * Parses most CSS-format colors
15
15
  * @param {string|number} c
16
16
  * @returns {number[]} Numeric array, values are in Uint8 range (0...255)
17
17
  */
18
- export function parseColor(c) {
18
+ export function parse_color(c) {
19
19
 
20
20
  const result = [];
21
21