@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,4 +1,5 @@
1
1
  import { string_capitalize } from "../../primitives/strings/string_capitalize.js";
2
+ import { read_property } from "./read_property.js";
2
3
 
3
4
  /**
4
5
  * @template T
@@ -9,32 +10,11 @@ import { string_capitalize } from "../../primitives/strings/string_capitalize.js
9
10
  * @param {T} value
10
11
  */
11
12
  export function write_property(root, parts, part_offset, part_count, value) {
12
- let thing = root;
13
13
 
14
14
  const last_index = part_offset + part_count - 1;
15
15
 
16
- for (let i = 0; i < last_index; i++) {
17
-
18
- const part = parts[i + part_offset];
19
-
20
- const thing_part = thing[part];
21
-
22
- if (typeof thing_part !== 'undefined') {
23
- thing = thing_part;
24
- } else {
25
-
26
- const getter_name = `get${string_capitalize(part)}`;
27
- const getter = thing[getter_name];
28
-
29
- if (typeof getter === "function") {
30
- // resolve via getter
31
- thing = getter.call(thing);
32
- } else {
33
- // no getter
34
- throw new Error(`No no property or getter found for '${part}' on [${i}]'${parts.slice(part_offset, part_offset + part_count).join('/')}'`);
35
- }
36
- }
37
- }
16
+ // resolve parent of the property
17
+ const thing = read_property(root, parts, 0, last_index, true);
38
18
 
39
19
  const last_part = parts[last_index];
40
20
 
@@ -0,0 +1,26 @@
1
+ import { write_property } from "./write_property.js";
2
+
3
+ test("write via setter method", () => {
4
+
5
+ let value = 1;
6
+
7
+ const thing = {
8
+ setValue(v) {
9
+ value = v
10
+ }
11
+ }
12
+
13
+ write_property(thing, ['value'], 0, 1, 31);
14
+
15
+ expect(value).toEqual(31);
16
+ });
17
+ test("write via property accessor", () => {
18
+
19
+ const thing = {
20
+ value: 1
21
+ }
22
+
23
+ write_property(thing, ['value'], 0, 1, 31);
24
+
25
+ expect(thing.value).toEqual(31);
26
+ });
@@ -0,0 +1,19 @@
1
+ import { number_pretty_print } from "./number_pretty_print.js";
2
+
3
+ test("sanity", () => {
4
+
5
+ const zero = number_pretty_print(0);
6
+
7
+ expect(typeof zero).toBe('string');
8
+ expect(zero.trim().length).toBeGreaterThan(0);
9
+
10
+
11
+ const fraction = number_pretty_print(-1.123456790);
12
+
13
+ expect(typeof fraction).toBe('string');
14
+ expect(fraction.trim().length).toBeGreaterThan(0);
15
+
16
+
17
+ // different strings for different inputs
18
+ expect(zero).not.toEqual(fraction);
19
+ });
@@ -6,8 +6,8 @@ import Quaternion from "../../../core/geom/Quaternion.js";
6
6
  import Vector3 from "../../../core/geom/Vector3.js";
7
7
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
8
8
  import { v3_computeOffsetVector } from "./IKMath.js";
9
- import { v3_dot } from "../../../core/geom/v3_dot.js";
10
- import { v3_length } from "../../../core/geom/v3_length.js";
9
+ import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
10
+ import { v3_length } from "../../../core/geom/vec3/v3_length.js";
11
11
  import { clamp01 } from "../../../core/math/clamp01.js";
12
12
 
13
13
  const boneWorldPosition = new Vector3();
@@ -7,8 +7,8 @@ import { findSkeletonBoneByType } from "../../graphics/ecs/mesh/SkeletonUtils.js
7
7
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
8
8
  import { IKSolver } from "./IKSolver.js";
9
9
  import { v3_computeOffsetVector } from "./IKMath.js";
10
- import { v3_dot } from "../../../core/geom/v3_dot.js";
11
- import { v3_length } from "../../../core/geom/v3_length.js";
10
+ import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
11
+ import { v3_length } from "../../../core/geom/vec3/v3_length.js";
12
12
  import { clamp01 } from "../../../core/math/clamp01.js";
13
13
 
14
14
  const boneWorldPositionC = new Vector3();
@@ -12,7 +12,7 @@ import { Transform } from '../transform/Transform.js';
12
12
  import Steering, { SteeringEvents, SteeringFlags } from '../components/Steering.js';
13
13
  import Vector3 from "../../../core/geom/Vector3.js";
14
14
  import { alignToVector } from "../terrain/ecs/cling/ClingToTerrainSystem.js";
15
- import { v3_dot } from "../../../core/geom/v3_dot.js";
15
+ import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
16
16
  import { solveQuadratic } from "../../../core/math/solveQuadratic.js";
17
17
 
18
18
  /**
@@ -11,7 +11,7 @@ import Vector2 from "../../../../../core/geom/Vector2.js";
11
11
  import Vector4 from "../../../../../core/geom/Vector4.js";
12
12
  import { MersenneTwister } from "../../../../../core/math/random/MersenneTwister.js";
13
13
  import { arrayPickBestElement } from "../../../../../core/collection/array/arrayPickBestElement.js";
14
- import { hsv2rgb } from "../../../../../core/color/hsv2rgb.js";
14
+ import { hsv2rgb } from "../../../../../core/color/hsv/hsv2rgb.js";
15
15
 
16
16
  function removeAllChildren(node) {
17
17
  const children = node.children;
@@ -12,7 +12,7 @@ import { unprojectPoint } from "./unprojectPoint.js";
12
12
  import Vector3 from "../../../../core/geom/Vector3.js";
13
13
  import { frustum_from_camera } from "./frustum_from_camera.js";
14
14
  import { invertQuaternionOrientation } from "./InvertQuaternionOrientation.js";
15
- import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
15
+ import { v3_distance_above_plane } from "../../../../core/geom/vec3/v3_distance_above_plane.js";
16
16
  import { ProjectionType } from "./ProjectionType.js";
17
17
  import { plane3_compute_ray_intersection } from "../../../../core/geom/3d/plane/plane3_compute_ray_intersection.js";
18
18
 
@@ -1,5 +1,5 @@
1
1
  import { Frustum as ThreeFrustum } from "three";
2
- import { v3_dot } from "../../../../core/geom/v3_dot.js";
2
+ import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
3
3
  import { isValueBetweenInclusive } from "../../../../core/math/interval/isValueBetweenInclusive.js";
4
4
  import { frustum_from_camera } from "./frustum_from_camera.js";
5
5
  import { is_valid_distance_value } from "./is_valid_distance_value.js";
@@ -10,7 +10,6 @@ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
10
10
  import { GameAssetType } from "../../../../asset/GameAssetType.js";
11
11
  import { assert } from "../../../../../core/assert.js";
12
12
  import { AsyncLoadingCache } from "../../../../../core/collection/map/AsyncLoadingCache.js";
13
- import { sampler2d_to_uint8_RGBA } from "../../../texture/sampler/sampler2d_to_uint8_RGBA.js";
14
13
  import { returnTrue } from "../../../../../core/function/Functions.js";
15
14
  import {
16
15
  ExplicitBinaryBoundingVolumeHierarchy
@@ -29,6 +28,7 @@ import {
29
28
  import {
30
29
  aabb3_transformed_compute_plane_side
31
30
  } from "../../../../../core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js";
31
+ import { sampler2d_ensure_uint8_RGBA } from "../../../texture/sampler/sampler2d_ensure_uint8_RGBA.js";
32
32
 
33
33
  const placeholder_texture = Sampler2D.uint8(4, 1, 1);
34
34
  placeholder_texture.data.fill(255);
@@ -249,15 +249,7 @@ export class FPDecalSystem extends AbstractContextSystem {
249
249
  return this.__assets.promise(key, GameAssetType.Image).then(asset => {
250
250
  const asset_sampler = asset.create();
251
251
 
252
- if (asset_sampler.itemSize === 4) {
253
- return asset_sampler;
254
- }
255
-
256
- const resampled = Sampler2D.uint8(4, asset_sampler.width, asset_sampler.height);
257
-
258
- sampler2d_to_uint8_RGBA(resampled, asset_sampler);
259
-
260
- return resampled;
252
+ return sampler2d_ensure_uint8_RGBA(asset_sampler);
261
253
  });
262
254
  });
263
255
 
@@ -389,7 +381,7 @@ export class FPDecalSystem extends AbstractContextSystem {
389
381
 
390
382
  const bvh = this.bvh;
391
383
 
392
- const hit_count = bvh_query_leaves_ray(bvh,bvh.root, leaves, 0,
384
+ const hit_count = bvh_query_leaves_ray(bvh, bvh.root, leaves, 0,
393
385
  origin_x, origin_y, origin_z,
394
386
  direction_x, direction_y, direction_z
395
387
  );
@@ -5,111 +5,12 @@ import List from "../../../../core/collection/list/List.js";
5
5
  import { HighlightDefinition } from "./HighlightDefinition.js";
6
6
 
7
7
  class Highlight {
8
- constructor() {
9
- /**
10
- *
11
- * @type {List<HighlightDefinition>}
12
- */
13
- this.elements = new List();
14
- }
15
-
16
- /**
17
- * @deprecated
18
- * @param {number} v
19
- */
20
- set r(v) {
21
- console.warn('deprecated, use .elements instead');
22
-
23
- const first = this.elements.get(0);
24
-
25
- first.color.setRGB(v, first.color.g, first.color.b);
26
- }
27
-
28
- /**
29
- * @deprecated
30
- * @returns {number}
31
- */
32
- get r() {
33
- console.warn('deprecated, use .elements instead');
34
-
35
- const first = this.elements.get(0);
36
- const color = first.color;
37
-
38
- return color.r;
39
- }
40
-
41
- /**
42
- * @deprecated
43
- * @param {number} v
44
- */
45
- set g(v) {
46
- console.warn('deprecated, use .elements instead');
47
-
48
- const first = this.elements.get(0);
49
-
50
- first.color.setRGB(first.color.r, v, first.color.b);
51
- }
52
-
53
- /**
54
- * @deprecated
55
- * @returns {number}
56
- */
57
- get g() {
58
- console.warn('deprecated, use .elements instead');
59
-
60
- const first = this.elements.get(0);
61
- const color = first.color;
62
-
63
- return color.g;
64
- }
65
-
66
- /**
67
- * @deprecated
68
- * @param {number} v
69
- */
70
- set b(v) {
71
- console.warn('deprecated, use .elements instead');
72
-
73
- const first = this.elements.get(0);
74
-
75
- first.color.setRGB(first.color.r, first.color.g, v);
76
- }
77
-
78
- /**
79
- * @deprecated
80
- * @returns {number}
81
- */
82
- get b() {
83
- console.warn('deprecated, use .elements instead');
84
-
85
- const first = this.elements.get(0);
86
- const color = first.color;
87
-
88
- return color.b;
89
- }
90
-
91
- /**
92
- * @deprecated
93
- * @param {number} v
94
- */
95
- set a(v) {
96
- console.warn('deprecated, use .elements instead');
97
-
98
- const first = this.elements.get(0);
99
-
100
- first.opacity = v;
101
- }
102
8
 
103
9
  /**
104
- * @deprecated
105
- * @returns {number}
10
+ *
11
+ * @type {List<HighlightDefinition>}
106
12
  */
107
- get a() {
108
- console.warn('deprecated, use .elements instead');
109
-
110
- const first = this.elements.get(0);
111
- return first.opacity;
112
- }
13
+ elements = new List();
113
14
 
114
15
  /**
115
16
  *
@@ -140,6 +41,23 @@ class Highlight {
140
41
  return el;
141
42
  }
142
43
 
44
+ /**
45
+ *
46
+ * @param {Highlight} other
47
+ * @return {boolean}
48
+ */
49
+ equals(other) {
50
+ return this.elements.equals(other.elements);
51
+ }
52
+
53
+ /**
54
+ *
55
+ * @return {number}
56
+ */
57
+ hash() {
58
+ return this.elements.hash();
59
+ }
60
+
143
61
  toJSON() {
144
62
  return {
145
63
  elements: this.elements.toJSON()
@@ -2,15 +2,15 @@
2
2
  * Created by Alex Goldring on 25.02.2015.
3
3
  */
4
4
  import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
5
- import { LeafNode } from "../../../../core/bvh2/LeafNode.js";
6
5
  import { getSkeletonBoneByType } from "./SkeletonUtils.js";
7
6
  import { assert } from "../../../../core/assert.js";
8
7
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
9
8
  import { Transform } from "../../../ecs/transform/Transform.js";
10
- import { updateNodeByTransformAndBBB } from "./updateNodeByTransformAndBBB.js";
11
9
  import { applyTransformToThreeObject } from "./applyTransformToThreeObject.js";
12
10
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
13
11
  import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
12
+ import { EBBVHLeafProxy } from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
13
+ import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
14
14
 
15
15
  /**
16
16
  *
@@ -69,18 +69,18 @@ class Mesh {
69
69
  */
70
70
  this.opacity = 1;
71
71
 
72
- /**
73
- * Managed by MeshSystem, do not change
74
- * @type {LeafNode}
75
- */
76
- this.bvh = new LeafNode(this, 0, 0, 0, 0, 0, 0);
77
-
78
72
  /**
79
73
  * Initialized to size 1x1x1
80
74
  * @type {AABB3}
81
75
  */
82
76
  this.boundingBox = new AABB3(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
83
77
 
78
+ /**
79
+ *
80
+ * @type {EBBVHLeafProxy}
81
+ */
82
+ this.__bvh_leaf = new EBBVHLeafProxy();
83
+
84
84
  /**
85
85
  * @private
86
86
  * @type {number}
@@ -126,7 +126,9 @@ class Mesh {
126
126
  applyTransformToThreeObject(m, _t);
127
127
 
128
128
  //set bvh
129
- updateNodeByTransformAndBBB(this.bvh, this.boundingBox, _t);
129
+ aabb3_matrix4_project(this.__bvh_leaf.bounds, this.boundingBox, _t.matrix);
130
+
131
+ this.__bvh_leaf.write_bounds();
130
132
 
131
133
  // override
132
134
  if (this.override_mesh !== null) {
@@ -139,7 +141,7 @@ class Mesh {
139
141
  * @param {AABB3} destination
140
142
  */
141
143
  getBoundingBox(destination) {
142
- destination.copy(this.bvh);
144
+ destination.readFromArray(this.__bvh_leaf.bounds);
143
145
  }
144
146
 
145
147
  /**
@@ -150,14 +152,6 @@ class Mesh {
150
152
  destination.copy(this.boundingBox);
151
153
  }
152
154
 
153
- set center(v) {
154
- throw new Error("Mesh.center is deprecated");
155
- }
156
-
157
- get center() {
158
- throw new Error("Mesh.center is deprecated");
159
- }
160
-
161
155
  /**
162
156
  *
163
157
  * @return {boolean}
@@ -21,6 +21,12 @@ import { MeshEvents } from "./MeshEvents.js";
21
21
  import { assert } from "../../../../core/assert.js";
22
22
  import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
23
23
  import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
24
+ import {
25
+ ExplicitBinaryBoundingVolumeHierarchy
26
+ } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
27
+ import {
28
+ bvh_query_user_data_overlaps_frustum
29
+ } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
24
30
 
25
31
  const placeholderGeometry = new BoxBufferGeometry(1, 1, 1);
26
32
 
@@ -30,6 +36,8 @@ const placeholderTexture = checkerTexture.create();
30
36
 
31
37
  const placeholderMaterial = new MeshLambertMaterial({ map: placeholderTexture });
32
38
 
39
+ const scratch_array = [];
40
+
33
41
  export class MeshSystem extends System {
34
42
  /**
35
43
  *
@@ -89,9 +97,10 @@ export class MeshSystem extends System {
89
97
 
90
98
  /**
91
99
  *
92
- * @type {BinaryNode}
100
+ * @type {ExplicitBinaryBoundingVolumeHierarchy}
101
+ * @private
93
102
  */
94
- this.bvh = null;
103
+ this.__bvh_binary = new ExplicitBinaryBoundingVolumeHierarchy();
95
104
  }
96
105
 
97
106
  /**
@@ -152,29 +161,37 @@ export class MeshSystem extends System {
152
161
  const graphics = this.graphics;
153
162
  this.renderLayer = graphics.layers.create("mesh-system");
154
163
 
155
- /**
156
- *
157
- * @param {Mesh} component
158
- * @return {Object3D}
159
- */
160
- const extractRenderable = (component) => {
161
- if (component.override_mesh !== null) {
162
- // use override mesh
163
- return component.override_mesh;
164
- } else {
165
- // use standard mesh
166
- return component.mesh;
164
+ this.renderLayer.buildVisibleSet = (destination, destination_offset, view) => {
165
+
166
+ const ecd = entityManager.dataset;
167
+
168
+ if (ecd === null) {
169
+ return 0;
167
170
  }
168
- };
169
171
 
170
- /**
171
- *
172
- * @param {Mesh} component
173
- * @return {Object3D|null}
174
- */
175
- this.renderLayer.extractRenderable = extractRenderable;
172
+ const view_frustum = view.frustum;
173
+
174
+ const hit_count = bvh_query_user_data_overlaps_frustum(scratch_array, 0, this.__bvh_binary, view_frustum);
175
+
176
+ let added = 0;
177
+
178
+ for (let i = 0; i < hit_count; i++) {
179
+ const entity = scratch_array[i];
180
+
181
+ const component = ecd.getComponent(entity, Mesh);
182
+
183
+ const object3D = component.mesh;
176
184
 
177
- this.bvh = this.renderLayer.bvh;
185
+ if (object3D === null) {
186
+ continue;
187
+ }
188
+
189
+ destination[destination_offset + added] = object3D;
190
+ added++;
191
+ }
192
+
193
+ return added;
194
+ };
178
195
 
179
196
  const visibleSet = this.renderLayer.visibleSet;
180
197
 
@@ -272,8 +289,6 @@ export class MeshSystem extends System {
272
289
  */
273
290
  link(model, transform, entity) {
274
291
  //remember entity for fast lookup
275
- model.bvh.entity = entity;
276
-
277
292
  this.process(entity, model);
278
293
 
279
294
  function apply_transform() {
@@ -305,7 +320,7 @@ export class MeshSystem extends System {
305
320
 
306
321
  apply_transform();
307
322
 
308
- this.bvh.insertNode(model.bvh);
323
+ model.__bvh_leaf.link(this.__bvh_binary, entity);
309
324
  }
310
325
 
311
326
  /**
@@ -343,7 +358,7 @@ export class MeshSystem extends System {
343
358
  }
344
359
  }
345
360
 
346
- model.bvh.disconnect();
361
+ model.__bvh_leaf.unlink();
347
362
 
348
363
  // cleanup resources
349
364
  model.dispose();
@@ -2,7 +2,7 @@ import { ShadedGeometry } from "./ShadedGeometry.js";
2
2
  import { Transform } from "../../../ecs/transform/Transform.js";
3
3
  import { System } from "../../../ecs/System.js";
4
4
  import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
5
- import { v3_distance_sqr } from "../../../../core/geom/v3_distance_sqr.js";
5
+ import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
6
6
  import { mat4 } from "gl-matrix";
7
7
  import { returnTrue } from "../../../../core/function/Functions.js";
8
8
  import { ShadedGeometryRendererContext } from "./render/ShadedGeometryRendererContext.js";
@@ -8,10 +8,10 @@ import { build_geometry_linear } from "./build_geometry_linear.js";
8
8
  import { build_geometry_catmullrom } from "./build_geometry_catmullrom.js";
9
9
  import { ShadedGeometry } from "../../../mesh-v2/ShadedGeometry.js";
10
10
  import { ShadedGeometryFlags } from "../../../mesh-v2/ShadedGeometryFlags.js";
11
- import { m3_rm_compose_transform } from "../../../../../../view/m3_rm_compose_transform.js";
12
11
  import { fix_shape_normal_order } from "./fix_shape_normal_order.js";
13
12
  import { compute_smooth_profile_normals } from "./compute_smooth_profile_normals.js";
14
13
  import { assert } from "../../../../../../core/assert.js";
14
+ import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
15
15
 
16
16
  /**
17
17
  *
@@ -5,7 +5,7 @@ import { make_ring_vertices } from "./make_ring_vertices.js";
5
5
  import { assert } from "../../../../../../core/assert.js";
6
6
  import { make_ring_faces } from "./make_ring_faces.js";
7
7
  import { append_compute_cap_geometry_size, make_cap } from "./make_cap.js";
8
- import { v3_angle_cos_between } from "../../../../../../core/geom/v3_angle_between.js";
8
+ import { v3_angle_cos_between } from "../../../../../../core/geom/vec3/v3_angle_between.js";
9
9
 
10
10
 
11
11
  const v4_array = new Float32Array(4);
@@ -1,11 +1,11 @@
1
1
  import { Vector3 } from "three";
2
2
  import { max2 } from "../../../../../../core/math/max2.js";
3
- import { m3_rm_compose_transform } from "../../../../../../view/m3_rm_compose_transform.js";
4
- import { m3_multiply } from "../../../../../../view/multiplyMatrices3.js";
5
3
  import { make_ring_vertices } from "./make_ring_vertices.js";
6
4
  import { make_ring_faces } from "./make_ring_faces.js";
7
5
  import { v2_distance } from "../../../../../../core/geom/Vector2.js";
8
6
  import { CapType } from "../CapType.js";
7
+ import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
8
+ import { m3_multiply } from "../../../../../../core/geom/mat3/m3_multiply.js";
9
9
 
10
10
  /**
11
11
  *
@@ -116,7 +116,7 @@ function make_cap_round(
116
116
 
117
117
  // build shape transform matrix that scales original shape down
118
118
  m3_rm_compose_transform(m3, 0, 0, sin_b, sin_b, 0, 0, 0);
119
- m3_multiply(m3, shape_transform, m3);
119
+ m3_multiply(m3, m3, shape_transform);
120
120
 
121
121
  const _d = radius;
122
122
 
@@ -1,6 +1,6 @@
1
1
  //
2
2
 
3
- import { v3_dot } from "../../../../../../core/geom/v3_dot.js";
3
+ import { v3_dot } from "../../../../../../core/geom/vec3/v3_dot.js";
4
4
 
5
5
  /**
6
6
  *
@@ -5,7 +5,6 @@ import { GetTexCoord } from "./GetTexCoord.js";
5
5
  import { ORIENT_PRESERVING } from "./constants/ORIENT_PRESERVING.js";
6
6
  import { NotZero } from "./NotZero.js";
7
7
  import { fabsf } from "../../../../core/math/fabsf.js";
8
- import { Length } from "./Length.js";
9
8
  import { MARK_DEGENERATE } from "./constants/MARK_DEGENERATE.js";
10
9
  import { CalcTexArea } from "./CalcTexArea.js";
11
10
  import { BuildNeighborsFast } from "./BuildNeighborsFast.js";
@@ -70,9 +69,9 @@ export function InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn) {
70
69
  // initial values
71
70
  const f3 = f * 3;
72
71
 
73
- GetPosition(v1,0, pContext, piTriListIn[f3 + 0]);
74
- GetPosition(v2,0, pContext, piTriListIn[f3 + 1]);
75
- GetPosition(v3,0, pContext, piTriListIn[f3 + 2]);
72
+ GetPosition(v1, 0, pContext, piTriListIn[f3 + 0]);
73
+ GetPosition(v2, 0, pContext, piTriListIn[f3 + 1]);
74
+ GetPosition(v3, 0, pContext, piTriListIn[f3 + 2]);
76
75
 
77
76
  GetTexCoord(t1, pContext, piTriListIn[f3 + 0]);
78
77
  GetTexCoord(t2, pContext, piTriListIn[f3 + 1]);
@@ -105,8 +104,8 @@ export function InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn) {
105
104
  if (NotZero(fSignedAreaSTx2)) {
106
105
  const fAbsArea = fabsf(fSignedAreaSTx2);
107
106
 
108
- const fLenOs = Length(vOs);
109
- const fLenOt = Length(vOt);
107
+ const fLenOs = vec3.length(vOs);
108
+ const fLenOt = vec3.length(vOt);
110
109
 
111
110
  const fS = (tri_info.iFlag & ORIENT_PRESERVING) === 0 ? (-1.0) : 1.0;
112
111
 
@@ -8,7 +8,7 @@ import { InitTriInfo } from "./InitTriInfo.js";
8
8
  import { GenerateTSpaces } from "./GenerateTSpaces.js";
9
9
  import { DegenEpilogue } from "./DegenEpilogue.js";
10
10
  import { Build4RuleGroups } from "./Build4RuleGroups.js";
11
- import { allocate_v3 } from "../../../../core/geom/3d/vector/allocate_v3.js";
11
+ import { v3_allocate } from "../../../../core/geom/vec3/v3_allocate.js";
12
12
  import { m_getNumFaces } from "./m_getNumFaces.js";
13
13
  import { GenerateInitialVerticesIndexList } from "./GenerateInitialVerticesIndexList.js";
14
14
  import { DegenPrologue } from "./DegenPrologue.js";
@@ -79,11 +79,11 @@ class STriInfo {
79
79
  /**
80
80
  * @type {vec3|Float32Array}
81
81
  */
82
- this.vOs = allocate_v3();
82
+ this.vOs = v3_allocate();
83
83
  /**
84
84
  * @type {vec3|Float32Array}
85
85
  */
86
- this.vOt = allocate_v3();
86
+ this.vOt = v3_allocate();
87
87
 
88
88
  // original magnitudes
89
89
  this.fMagS = 0;
@@ -1,4 +1,3 @@
1
- import { Length } from "./Length.js";
2
1
  import { vec3 } from "gl-matrix";
3
2
 
4
3
  /**
@@ -8,7 +7,7 @@ import { vec3 } from "gl-matrix";
8
7
  */
9
8
  export function NormalizeSafe(out, input) {
10
9
 
11
- const len = Length(input);
10
+ const len = vec3.length(input);
12
11
 
13
12
  if (len !== 0) {
14
13
  const m = 1 / len;