@woosh/meep-engine 2.133.3 → 2.134.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 (89) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/package.json +2 -2
  3. package/src/core/binary/BinaryBuffer.d.ts +20 -0
  4. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  5. package/src/core/binary/BinaryBuffer.js +50 -0
  6. package/src/core/binary/BitSet.d.ts +6 -0
  7. package/src/core/binary/BitSet.d.ts.map +1 -1
  8. package/src/core/binary/BitSet.js +38 -1
  9. package/src/core/binary/operations/bitCount.d.ts.map +1 -1
  10. package/src/core/binary/operations/bitCount.js +11 -6
  11. package/src/core/geom/3d/aabb/AABB3.d.ts +7 -1
  12. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  13. package/src/core/geom/3d/aabb/AABB3.js +14 -1
  14. package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.d.ts +4 -4
  15. package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.d.ts.map +1 -1
  16. package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.js +2 -2
  17. package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.d.ts +2 -2
  18. package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.d.ts.map +1 -1
  19. package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.js +1 -1
  20. package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.d.ts +2 -2
  21. package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.d.ts.map +1 -1
  22. package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.js +1 -1
  23. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts +4 -4
  24. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts.map +1 -1
  25. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +3 -3
  26. package/src/core/geom/3d/topology/simplify/quadratic/{Quadratic3.d.ts → Quadric3.d.ts} +55 -29
  27. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -0
  28. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +307 -0
  29. package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.d.ts +7 -7
  30. package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.d.ts.map +1 -1
  31. package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +39 -13
  32. package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts +2 -2
  33. package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts.map +1 -1
  34. package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js +1 -1
  35. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +2 -2
  36. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
  37. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +2 -2
  38. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.d.ts +4 -4
  39. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.d.ts.map +1 -1
  40. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.js +5 -5
  41. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.d.ts +8 -0
  42. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.d.ts.map +1 -0
  43. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.js +56 -0
  44. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.d.ts +14 -0
  45. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.d.ts.map +1 -0
  46. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.js +95 -0
  47. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts +17 -0
  48. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -0
  49. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +352 -0
  50. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.d.ts +21 -0
  51. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.d.ts.map +1 -0
  52. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.js +52 -0
  53. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +16 -0
  54. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -0
  55. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +90 -0
  56. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.d.ts +19 -0
  57. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.d.ts.map +1 -0
  58. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.js +83 -0
  59. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.d.ts +22 -0
  60. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.d.ts.map +1 -0
  61. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.js +148 -0
  62. package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_incenter.js +4 -4
  63. package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.d.ts +15 -0
  64. package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.d.ts.map +1 -0
  65. package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.js +48 -0
  66. package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
  67. package/src/engine/ecs/terrain/ecs/Terrain.js +6 -1
  68. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.d.ts.map +1 -1
  69. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +10 -9
  70. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.d.ts.map +1 -1
  71. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +14 -11
  72. package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
  73. package/src/engine/graphics/ecs/water/WaterSystem.js +3 -0
  74. package/src/engine/graphics/material/SplatMaterial.d.ts.map +1 -1
  75. package/src/engine/graphics/material/SplatMaterial.js +2 -4
  76. package/src/engine/graphics/shaders/TerrainShader.js +4 -11
  77. package/src/engine/navigation/mesh/NavigationMesh.d.ts +6 -4
  78. package/src/engine/navigation/mesh/NavigationMesh.d.ts.map +1 -1
  79. package/src/engine/navigation/mesh/NavigationMesh.js +212 -190
  80. package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts.map +1 -1
  81. package/src/engine/navigation/mesh/build/navmesh_build_topology.js +20 -7
  82. package/src/engine/navigation/mesh/bvh_query_nearest_face.d.ts +15 -0
  83. package/src/engine/navigation/mesh/bvh_query_nearest_face.d.ts.map +1 -0
  84. package/src/engine/navigation/mesh/bvh_query_nearest_face.js +131 -0
  85. package/src/engine/physics/gjk/gjk.d.ts +16 -0
  86. package/src/engine/physics/gjk/gjk.d.ts.map +1 -0
  87. package/src/engine/physics/gjk/gjk.js +378 -0
  88. package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.d.ts.map +0 -1
  89. package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +0 -302
@@ -0,0 +1,83 @@
1
+ import { NULL_POINTER } from "../../BinaryTopology.js";
2
+ import { bt_disk_edge_remove } from "../bt_disk_edge_remove.js";
3
+ import { bt_radial_loop_add } from "../bt_radial_loop_add.js";
4
+ import { bt_radial_loop_remove } from "../bt_radial_loop_remove.js";
5
+ import { bt_kill_only_edge } from "./bt_kill_only_edge.js";
6
+
7
+ /**
8
+ * Walk the mesh and fuse any pair of edges that share the same endpoint pair into a single edge.
9
+ *
10
+ * When two edges connect the same vertices, all loops on the victim are moved into the master's
11
+ * radial cycle, the victim is removed from both endpoint disk cycles, and the victim edge is
12
+ * deallocated. This restores the topology invariant that a vertex pair is represented by at most
13
+ * one edge — which is what loop/face neighbour queries rely on.
14
+ *
15
+ * Degenerate edges (v1 === v2) are left alone; callers that want those removed should run a
16
+ * dedicated pass.
17
+ *
18
+ * Typically used after {@link bt_merge_verts_by_distance}, which re-points vertex references but
19
+ * can leave behind multiple edges sharing the same endpoint pair.
20
+ *
21
+ * @param {BinaryTopology} mesh
22
+ * @returns {number} number of edges fused away
23
+ */
24
+ export function bt_mesh_fuse_duplicate_edges(mesh) {
25
+ const edges = mesh.edges;
26
+ const edge_count = edges.size;
27
+
28
+ let removed_count = 0;
29
+
30
+ for (let master = 0; master < edge_count; master++) {
31
+ if (edges.is_allocated(master) === false) {
32
+ continue;
33
+ }
34
+
35
+ const master_v1 = mesh.edge_read_vertex1(master);
36
+ const master_v2 = mesh.edge_read_vertex2(master);
37
+
38
+ if (master_v1 === master_v2) {
39
+ // degenerate edge; skip
40
+ continue;
41
+ }
42
+
43
+ // walk master_v1's disk cycle, fusing any edge that also connects to master_v2
44
+ let curr = mesh.edge_read_v1_disk_next(master);
45
+
46
+ while (curr !== master) {
47
+
48
+ const curr_v1 = mesh.edge_read_vertex1(curr);
49
+ const curr_v2 = mesh.edge_read_vertex2(curr);
50
+
51
+ const curr_on_v1 = curr_v1 === master_v1;
52
+
53
+ // capture next before we potentially splice curr out of the disk cycle
54
+ const next = curr_on_v1
55
+ ? mesh.edge_read_v1_disk_next(curr)
56
+ : mesh.edge_read_v2_disk_next(curr);
57
+
58
+ const other_endpoint = curr_on_v1 ? curr_v2 : curr_v1;
59
+
60
+ if (other_endpoint === master_v2) {
61
+
62
+ // move every loop on curr into master's radial cycle
63
+ let l = mesh.edge_read_loop(curr);
64
+ while (l !== NULL_POINTER) {
65
+ bt_radial_loop_remove(mesh, l, curr);
66
+ bt_radial_loop_add(mesh, l, master);
67
+ l = mesh.edge_read_loop(curr);
68
+ }
69
+
70
+ bt_disk_edge_remove(mesh, curr, master_v1);
71
+ bt_disk_edge_remove(mesh, curr, master_v2);
72
+
73
+ bt_kill_only_edge(mesh, curr);
74
+
75
+ removed_count++;
76
+ }
77
+
78
+ curr = next;
79
+ }
80
+ }
81
+
82
+ return removed_count;
83
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Localized counterpart to {@link bt_mesh_fuse_duplicate_edges} that inspects only
3
+ * `v`'s disk cycle. Any two edges in that cycle sharing the same other endpoint
4
+ * are fused: loops move from the victim to the master, the victim is untangled
5
+ * from both endpoint disk cycles, and its memory is released.
6
+ *
7
+ * If transferring a loop would leave the master edge with two loops on the same
8
+ * face (i.e. the face has collapsed to a degenerate two-edge polygon), that face
9
+ * is killed as well.
10
+ *
11
+ * Self-loops on `v` are left alone; the caller should handle them separately.
12
+ *
13
+ * Typical use: after an iterative edit that may have produced link-vertex
14
+ * duplicates around `v`, run this to restore the one-edge-per-vertex-pair
15
+ * invariant without the cost of a whole-mesh pass.
16
+ *
17
+ * @param {BinaryTopology} mesh
18
+ * @param {number} v
19
+ * @returns {number} Number of faces killed as a side effect.
20
+ */
21
+ export function bt_vert_fuse_duplicate_edges(mesh: BinaryTopology, v: number): number;
22
+ //# sourceMappingURL=bt_vert_fuse_duplicate_edges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_vert_fuse_duplicate_edges.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,sEAHW,MAAM,GACJ,MAAM,CAyHlB"}
@@ -0,0 +1,148 @@
1
+ import { assert } from "../../../../../../../assert.js";
2
+ import { NULL_POINTER } from "../../BinaryTopology.js";
3
+ import { bt_disk_edge_remove } from "../bt_disk_edge_remove.js";
4
+ import { bt_loop_kill } from "../bt_loop_kill.js";
5
+ import { bt_radial_loop_add } from "../bt_radial_loop_add.js";
6
+ import { bt_radial_loop_remove } from "../bt_radial_loop_remove.js";
7
+ import { bt_kill_only_edge } from "../edge/bt_kill_only_edge.js";
8
+
9
+ /**
10
+ * Localized counterpart to {@link bt_mesh_fuse_duplicate_edges} that inspects only
11
+ * `v`'s disk cycle. Any two edges in that cycle sharing the same other endpoint
12
+ * are fused: loops move from the victim to the master, the victim is untangled
13
+ * from both endpoint disk cycles, and its memory is released.
14
+ *
15
+ * If transferring a loop would leave the master edge with two loops on the same
16
+ * face (i.e. the face has collapsed to a degenerate two-edge polygon), that face
17
+ * is killed as well.
18
+ *
19
+ * Self-loops on `v` are left alone; the caller should handle them separately.
20
+ *
21
+ * Typical use: after an iterative edit that may have produced link-vertex
22
+ * duplicates around `v`, run this to restore the one-edge-per-vertex-pair
23
+ * invariant without the cost of a whole-mesh pass.
24
+ *
25
+ * @param {BinaryTopology} mesh
26
+ * @param {number} v
27
+ * @returns {number} Number of faces killed as a side effect.
28
+ */
29
+ export function bt_vert_fuse_duplicate_edges(mesh, v) {
30
+ assert.defined(mesh, 'mesh');
31
+ assert.notNull(mesh, 'mesh');
32
+ assert.isNonNegativeInteger(v, 'v');
33
+
34
+ const edge_pool = mesh.edges;
35
+
36
+ const start_e = mesh.vertex_read_edge(v);
37
+
38
+ if (start_e === NULL_POINTER) {
39
+ return 0;
40
+ }
41
+
42
+ // Snapshot v's disk cycle up front so that later fusion operations, which
43
+ // mutate that cycle, don't invalidate our traversal cursor.
44
+ const edges_in_disk = [];
45
+ let curr_e = start_e;
46
+
47
+ do {
48
+ edges_in_disk.push(curr_e);
49
+
50
+ if (mesh.edge_read_vertex1(curr_e) === v) {
51
+ curr_e = mesh.edge_read_v1_disk_next(curr_e);
52
+ } else {
53
+ curr_e = mesh.edge_read_v2_disk_next(curr_e);
54
+ }
55
+ } while (curr_e !== start_e && curr_e !== NULL_POINTER);
56
+
57
+ // Group edges by other endpoint to detect duplicates in a single pass.
58
+ const master_by_other = new Map();
59
+ const fusion_masters = [];
60
+ const fusion_victims = [];
61
+ const fusion_others = [];
62
+
63
+ for (let i = 0; i < edges_in_disk.length; i++) {
64
+ const e = edges_in_disk[i];
65
+
66
+ if (!edge_pool.is_allocated(e)) {
67
+ continue;
68
+ }
69
+
70
+ const v1 = mesh.edge_read_vertex1(e);
71
+ const v2 = mesh.edge_read_vertex2(e);
72
+ const other = v1 === v ? v2 : v1;
73
+
74
+ if (other === v) {
75
+ // Self-loop; not our concern here.
76
+ continue;
77
+ }
78
+
79
+ if (master_by_other.has(other)) {
80
+ fusion_masters.push(master_by_other.get(other));
81
+ fusion_victims.push(e);
82
+ fusion_others.push(other);
83
+ } else {
84
+ master_by_other.set(other, e);
85
+ }
86
+ }
87
+
88
+ const face_pool = mesh.faces;
89
+
90
+ let faces_killed = 0;
91
+
92
+ for (let i = 0; i < fusion_masters.length; i++) {
93
+ const master = fusion_masters[i];
94
+ const victim = fusion_victims[i];
95
+ const other = fusion_others[i];
96
+
97
+ if (!edge_pool.is_allocated(victim) || !edge_pool.is_allocated(master)) {
98
+ continue;
99
+ }
100
+
101
+ let l = mesh.edge_read_loop(victim);
102
+
103
+ while (l !== NULL_POINTER) {
104
+ bt_radial_loop_remove(mesh, l, victim);
105
+
106
+ const face = mesh.loop_read_face(l);
107
+ let collapse_face = false;
108
+
109
+ if (face !== NULL_POINTER && face_pool.is_allocated(face)) {
110
+ // If master already has a loop on the same face, transferring
111
+ // this loop would give that face two coincident edges -- a
112
+ // degenerate polygon that has to die.
113
+ let mast_l = mesh.edge_read_loop(master);
114
+ if (mast_l !== NULL_POINTER) {
115
+ const mast_start = mast_l;
116
+ do {
117
+ if (mesh.loop_read_face(mast_l) === face) {
118
+ collapse_face = true;
119
+ break;
120
+ }
121
+ mast_l = mesh.loop_read_radial_next(mast_l);
122
+ } while (mast_l !== mast_start && mast_l !== NULL_POINTER);
123
+ }
124
+ }
125
+
126
+ bt_radial_loop_add(mesh, l, master);
127
+
128
+ if (collapse_face) {
129
+ const face_to_kill = face;
130
+ let fl = mesh.face_read_loop(face_to_kill);
131
+ while (fl !== NULL_POINTER) {
132
+ bt_loop_kill(mesh, fl);
133
+ fl = mesh.face_read_loop(face_to_kill);
134
+ }
135
+ face_pool.release(face_to_kill);
136
+ faces_killed++;
137
+ }
138
+
139
+ l = mesh.edge_read_loop(victim);
140
+ }
141
+
142
+ bt_disk_edge_remove(mesh, victim, v);
143
+ bt_disk_edge_remove(mesh, victim, other);
144
+ bt_kill_only_edge(mesh, victim);
145
+ }
146
+
147
+ return faces_killed;
148
+ }
@@ -64,11 +64,11 @@ export function bt_face_get_incenter(
64
64
 
65
65
  do {
66
66
  const vertex_id = mesh.loop_read_vertex(current_loop_id);
67
- mesh.vertex_read_coordinate(scratch_coord, 0, vertex_id);
67
+ mesh.vertex_read_coordinate(scratch_coords, 0, vertex_id);
68
68
 
69
- sum_x += scratch_coord[0];
70
- sum_y += scratch_coord[1];
71
- sum_z += scratch_coord[2];
69
+ sum_x += scratch_coords[0];
70
+ sum_y += scratch_coords[1];
71
+ sum_z += scratch_coords[2];
72
72
 
73
73
  vertex_count++;
74
74
  current_loop_id = mesh.loop_read_next(current_loop_id);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Find the loop in `face_a` whose edge is shared with `face_b`.
3
+ *
4
+ * The returned loop belongs to `face_a` and its edge is also used by a loop in `face_b`.
5
+ * Combined with {@link BinaryTopology#loop_read_vertex} and {@link BinaryTopology#loop_read_next},
6
+ * this is enough to read the two vertices of the shared edge in `face_a`'s winding order,
7
+ * which is useful for constructing directed portals.
8
+ *
9
+ * @param {BinaryTopology} mesh
10
+ * @param {number} face_a
11
+ * @param {number} face_b
12
+ * @returns {number} loop ID in `face_a` that shares an edge with `face_b`, or {@link NULL_POINTER} if no shared edge exists
13
+ */
14
+ export function bt_faces_shared_loop(mesh: BinaryTopology, face_a: number, face_b: number): number;
15
+ //# sourceMappingURL=bt_faces_shared_loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bt_faces_shared_loop.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,mEAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAiClB"}
@@ -0,0 +1,48 @@
1
+ import { assert } from "../../../../../../assert.js";
2
+ import { NULL_POINTER } from "../BinaryTopology.js";
3
+
4
+ /**
5
+ * Find the loop in `face_a` whose edge is shared with `face_b`.
6
+ *
7
+ * The returned loop belongs to `face_a` and its edge is also used by a loop in `face_b`.
8
+ * Combined with {@link BinaryTopology#loop_read_vertex} and {@link BinaryTopology#loop_read_next},
9
+ * this is enough to read the two vertices of the shared edge in `face_a`'s winding order,
10
+ * which is useful for constructing directed portals.
11
+ *
12
+ * @param {BinaryTopology} mesh
13
+ * @param {number} face_a
14
+ * @param {number} face_b
15
+ * @returns {number} loop ID in `face_a` that shares an edge with `face_b`, or {@link NULL_POINTER} if no shared edge exists
16
+ */
17
+ export function bt_faces_shared_loop(mesh, face_a, face_b) {
18
+ assert.defined(mesh, "mesh");
19
+ assert.notNull(mesh, "mesh");
20
+ assert.equal(mesh.isBinaryTopology, true, "mesh.isBinaryTopology !== true");
21
+ assert.isNonNegativeInteger(face_a, "face_a");
22
+ assert.isNonNegativeInteger(face_b, "face_b");
23
+
24
+ const start_loop = mesh.face_read_loop(face_a);
25
+
26
+ if (start_loop === NULL_POINTER) {
27
+ return NULL_POINTER;
28
+ }
29
+
30
+ let current_loop = start_loop;
31
+
32
+ do {
33
+ // walk the radial cycle around the edge of this loop
34
+ let radial_loop = mesh.loop_read_radial_next(current_loop);
35
+
36
+ while (radial_loop !== current_loop) {
37
+ if (mesh.loop_read_face(radial_loop) === face_b) {
38
+ return current_loop;
39
+ }
40
+
41
+ radial_loop = mesh.loop_read_radial_next(radial_loop);
42
+ }
43
+
44
+ current_loop = mesh.loop_read_next(current_loop);
45
+ } while (current_loop !== start_loop);
46
+
47
+ return NULL_POINTER;
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"Terrain.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/Terrain.js"],"names":[],"mappings":";AA4CA;IACI;;;OAGG;IACH,aAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,cAAU;IAEV;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,eAFU,sBAAsB,CAEa;IAE7C;;;OAGG;IACH,mBAFU,MAAM,CAE6B;IAE7C;;;;OAIG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,eAFU,OAAO,CAEQ;IACzB;;;OAGG;IACH,SAFU,cAAc,CAEO;IAC/B;;;OAGG;IACH,gBAFU,YAAY,CAEK;IAE3B;;;OAGG;IACH,iBAFU,aAAa,CAEM;IAE7B;;;OAGG;IACH,oCAAyC;IAEzC;;;OAGG;IACH,cAFU,SAAS,CAEG;IAIlB;;;OAGG;IACH,QAFU,MAAM,CAEU;IAG1B;;;OAGG;IACH,aAFU,MAAM,CAEI;IAGpB;;;OAGG;IACH,eAFU,SAAS,CAE4B;IAE/C;;;OAGG;IACH,eAFU,WAAW,CAE4G;IAejI;;OAEG;IACH,yBAAqC;IAErC;;;OAGG;IACH,eAFU,OAAO,CAEQ;IAEzB;;;;OAIG;IACH,2BAAuC;IAGvC;;;OAGG;IACH,SAFU,cAAc,CAEoB;IAE5C;;;;OAIG;IACH,gBAGE;IAMF;;;;OAIG;IACH,uBAA0B;IAE1B;;;OAGG;IACH,oBAAuB;IAEvB;;;;OAIG;IACH,6BAAgC;IAKpC;;;;OAIG;IACH,cAHW,MAAM,GAAC,YAAY,GACjB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,YAAY,GACjB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gB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M,GACL,QAAQ,WAAW,CAAC,CAqD/B;IAED;;;;OAIG;IACH;;;;;;;;;;6BAiDC;IAxBG,kBAA4B;IA0BhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAeC;CACJ;;;;uCAj6BsC,6BAA6B;oBAhBhD,kCAAkC;+BASvB,sBAAsB;6BAQxB,yBAAyB;8BAHxB,2BAA2B;0BAjB/B,yCAAyC;mBAWhD,qBAAqB;0BAJd,gDAAgD;4BATnE,OAAO;+BAWiB,8BAA8B;6BAYhC,mBAAmB;8BAnBlB,2CAA2C;+BAY1C,gCAAgC"}
@@ -586,7 +586,12 @@ class Terrain {
586
586
 
587
587
  uniforms.splatWeightMap.value = this.splat.weightTexture;
588
588
 
589
- uniforms.splatLayerCount.value = this.layers.count();
589
+ // Update layer count as a compile-time define (AMD GLSL 300 ES requires constant loop bounds)
590
+ const layerCount = this.layers.count();
591
+ if (m.defines.SPLAT_LAYER_COUNT !== layerCount) {
592
+ m.defines.SPLAT_LAYER_COUNT = layerCount;
593
+ m.needsUpdate = true;
594
+ }
590
595
 
591
596
  uniforms.materialScalesMap.value = this.layers.scalesTexture;
592
597
 
@@ -1 +1 @@
1
- {"version":3,"file":"TerrainLayer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js"],"names":[],"mappings":"AA2BA;IA+CI;;;;;OAKG;IACH,iBAJW,MAAM,SACN,MAAM,UACN,MAAM,gBAShB;IAED;;;;OAIG;IACH,oDAFa,YAAY,CAQxB;IAvED;;;OAGG;IACH,0BAAuB;IAEvB;;;OAGG;IACH,SAFU,SAAS,CAEgB;IAEnC;;;OAGG;IACH,MAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,WAAW;IAEX;;;OAGG;IACH,WAFU,MAAM,CAES;IAGzB;;;;;;;MAMC;IAED;;;;aAIC;IA8BD;;;;OAIG;IACH,0DAwDC;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CANpC;0BA9JyB,mDAAmD;oBAJzD,qCAAqC;mBADtC,6CAA6C"}
1
+ {"version":3,"file":"TerrainLayer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js"],"names":[],"mappings":"AA2BA;IA+CI;;;;;OAKG;IACH,iBAJW,MAAM,SACN,MAAM,UACN,MAAM,gBAShB;IAED;;;;OAIG;IACH,oDAFa,YAAY,CAQxB;IAvED;;;OAGG;IACH,0BAAuB;IAEvB;;;OAGG;IACH,SAFU,SAAS,CAEgB;IAEnC;;;OAGG;IACH,MAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,WAAW;IAEX;;;OAGG;IACH,WAFU,MAAM,CAES;IAGzB;;;;;;;MAMC;IAED;;;;aAIC;IA8BD;;;;OAIG;IACH,0DAyDC;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;CANpC;0BA/JyB,mDAAmD;oBAJzD,qCAAqC;mBADtC,6CAA6C"}
@@ -5,7 +5,7 @@ import { computeStringHash } from "../../../../../core/primitives/strings/comput
5
5
  import { string_compute_byte_size } from "../../../../../core/primitives/strings/string_compute_byte_size.js";
6
6
  import { GameAssetType } from "../../../../asset/GameAssetType.js";
7
7
  import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
8
- import { sampler2d_transfer_data } from "../../../../graphics/texture/sampler/sampler2d_transfer_data.js";
8
+ import { sampler2d_ensure_uint8_RGBA } from "../../../../graphics/texture/sampler/sampler2d_ensure_uint8_RGBA.js";
9
9
 
10
10
  /**
11
11
  *
@@ -37,7 +37,7 @@ export class TerrainLayer {
37
37
  *
38
38
  * @type {Sampler2D}
39
39
  */
40
- diffuse = Sampler2D.uint8(3, 1, 1);
40
+ diffuse = Sampler2D.uint8(4, 1, 1);
41
41
 
42
42
  /**
43
43
  *
@@ -135,21 +135,22 @@ export class TerrainLayer {
135
135
  .then(assert => {
136
136
  const image = assert.create();
137
137
 
138
+ const source_data = image.data;
138
139
  const source_item_size = image.itemSize;
139
140
 
140
- const source_data = image.data;
141
+ // RGBA (4 channels) for AMD GPU compatibility
142
+ const destination_item_size = 4;
143
+
144
+ const source = new Sampler2D(source_data, source_item_size, image.width, image.height);
141
145
 
142
- // RGB
143
- const destination_item_size = 3;
146
+ // Convert to uint8 RGBA, handling any source format
147
+ const rgba = sampler2d_ensure_uint8_RGBA(source);
144
148
 
145
149
  if (this.diffuse === null || this.diffuse.width !== image.width || this.diffuse.height !== image.height) {
146
- // loaded image does not match the side of the layer
147
150
  this.diffuse = Sampler2D.uint8(destination_item_size, image.width, image.height);
148
151
  }
149
152
 
150
- const source = new Sampler2D(source_data, source_item_size, image.width, image.height);
151
-
152
- sampler2d_transfer_data(source, this.diffuse);
153
+ this.diffuse.data.set(rgba.data);
153
154
 
154
155
  this.onChanged.send0();
155
156
 
@@ -1 +1 @@
1
- {"version":3,"file":"TerrainLayers.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/layers/TerrainLayers.js"],"names":[],"mappings":"AA6EA;IAGQ;;;OAGG;IACH,QAFU,KAAK,YAAY,CAAC,CAEJ;IAExB;;;OAGG;IACH,YAFU,OAAO,CAEoD;IAMrE;;;OAGG;IACH,SAFU,kBAAkB,CAE8B;IAiB1D,2BAAsF;IAc1F;;;;;;MAKC;IAED;;;aAGC;IAED;;;;OAIG;IACH,gCAHW,MAAM,iBACN,MAAM,QAuChB;IAED;;;;OAIG;IACH,0DAyBC;IAED,sCAIC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACL,YAAY,CAIvB;IAED;;;;OAIG;IACH,8DAFa,MAAM,CAqBlB;IAED;;;;OAIG;IACH,kCAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;OAGG;IACH,SAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,gBAHW,YAAY,GACV,MAAM,CAWlB;IAED;;;;OAIG;IACH,mBAHW,YAAY,GACX,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,0CA8BC;IAED;;;OAGG;IACH,iCAFW,MAAM,QAgChB;IAED,gBAGC;IAED,cAEC;IAGD,qBAsCC;CACJ;iBA5ZgB,6CAA6C;6BAQjC,mBAAmB;oBAP5B,qCAAqC;mCALlD,OAAO;4BAAP,OAAO"}
1
+ {"version":3,"file":"TerrainLayers.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/terrain/ecs/layers/TerrainLayers.js"],"names":[],"mappings":"AA8EA;IAGQ;;;OAGG;IACH,QAFU,KAAK,YAAY,CAAC,CAEJ;IAExB;;;OAGG;IACH,YAFU,OAAO,CAEoD;IAMrE;;;OAGG;IACH,SAFU,kBAAkB,CAE8B;IAiB1D,2BAAsF;IAc1F;;;;;;MAKC;IAED;;;aAGC;IAED;;;;OAIG;IACH,gCAHW,MAAM,iBACN,MAAM,QAuChB;IAED;;;;OAIG;IACH,0DAyBC;IAED,sCAIC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACL,YAAY,CAIvB;IAED;;;;OAIG;IACH,8DAFa,MAAM,CAqBlB;IAED;;;;OAIG;IACH,kCAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;OAGG;IACH,SAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,gBAHW,YAAY,GACV,MAAM,CAWlB;IAED;;;;OAIG;IACH,mBAHW,YAAY,GACX,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,0CAgCC;IAED;;;OAGG;IACH,iCAFW,MAAM,QAgChB;IAED,gBAGC;IAED,cAEC;IAGD,qBAsCC;CACJ;iBA9ZgB,6CAA6C;6BAQjC,mBAAmB;oBAP5B,qCAAqC;mCALlD,OAAO;4BAAP,OAAO"}
@@ -8,6 +8,7 @@ import {
8
8
  LinearMipMapLinearFilter,
9
9
  NearestFilter,
10
10
  RepeatWrapping,
11
+ RGBAFormat,
11
12
  RGFormat,
12
13
  UnsignedByteType
13
14
  } from "three";
@@ -19,9 +20,9 @@ import Vector2 from "../../../../../core/geom/Vector2.js";
19
20
  import { invokeObjectEquals } from "../../../../../core/model/object/invokeObjectEquals.js";
20
21
  import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
21
22
  import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
22
- import { GL_RGBFormat } from "../../../../graphics/texture/GL_RGBFormat.js";
23
23
  import { sampler2d_scale } from "../../../../graphics/texture/sampler/resize/sampler2d_scale.js";
24
24
  import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
25
+ import { sampler2d_ensure_uint8_RGBA } from "../../../../graphics/texture/sampler/sampler2d_ensure_uint8_RGBA.js";
25
26
  import { TerrainLayer } from "./TerrainLayer.js";
26
27
 
27
28
  class ScaledTextureKey {
@@ -91,7 +92,7 @@ export class TerrainLayers {
91
92
  this.resolution = new Vector2(DEFAULT_RESOLUTION, DEFAULT_RESOLUTION);
92
93
 
93
94
 
94
- const layer_data = new Uint8Array(3);
95
+ const layer_data = new Uint8Array(4);
95
96
  layer_data.fill(255); //pre-fill with white
96
97
 
97
98
  /**
@@ -99,7 +100,7 @@ export class TerrainLayers {
99
100
  * @type {DataTexture2DArray}
100
101
  */
101
102
  this.texture = new DataTexture2DArray(layer_data, 1, 1, 1);
102
- this.texture.format = GL_RGBFormat;
103
+ this.texture.format = RGBAFormat;
103
104
  this.texture.type = UnsignedByteType;
104
105
 
105
106
  this.texture.wrapS = RepeatWrapping;
@@ -112,7 +113,7 @@ export class TerrainLayers {
112
113
 
113
114
  this.texture.generateMipmaps = true;
114
115
  this.texture.encoding = LinearEncoding;
115
- this.texture.internalFormat = 'RGB8';
116
+ this.texture.internalFormat = 'RGBA8';
116
117
  this.texture.needsUpdate = true;
117
118
 
118
119
  this.scalesTexture = new DataTexture(new Float32Array(64), 32, 1, RGFormat, FloatType);
@@ -312,7 +313,7 @@ export class TerrainLayers {
312
313
  __obtain_layer_data_at_resolution(layer, resolution) {
313
314
  const layerSampler = layer.diffuse;
314
315
 
315
- assert.equal(layerSampler.itemSize, 3, 'layer sampler must have 3 channels');
316
+ assert.equal(layerSampler.itemSize, 4, 'layer sampler must have 4 channels');
316
317
 
317
318
  const resolution_x = resolution.x;
318
319
  const resolution_y = resolution.y;
@@ -330,14 +331,16 @@ export class TerrainLayers {
330
331
  return existing;
331
332
  }
332
333
 
333
- const scaledLayerSampler = Sampler2D.uint8(3, resolution_x, resolution_y);
334
+ const scaledLayerSampler = Sampler2D.uint8(4, resolution_x, resolution_y);
334
335
 
335
336
  sampler2d_scale(layerSampler, scaledLayerSampler);
336
337
 
337
- // write scaled texture into the cache
338
- scaled_texture_cache.put(key, scaledLayerSampler);
338
+ // Ensure result is uint8 RGBA
339
+ const rgba = sampler2d_ensure_uint8_RGBA(scaledLayerSampler);
339
340
 
340
- return scaledLayerSampler;
341
+ scaled_texture_cache.put(key, rgba);
342
+
343
+ return rgba;
341
344
  }
342
345
  }
343
346
 
@@ -359,7 +362,7 @@ export class TerrainLayers {
359
362
 
360
363
  const resolution = this.resolution;
361
364
 
362
- const single_layer_byte_size = resolution.x * resolution.y * 3;
365
+ const single_layer_byte_size = resolution.x * resolution.y * 4;
363
366
 
364
367
  if (arrayData.length < single_layer_byte_size * index) {
365
368
  throw new Error('Texture data is too small, make sure you rebuild texture data before attempting to write');
@@ -411,7 +414,7 @@ export class TerrainLayers {
411
414
  texture.dispose();
412
415
 
413
416
  //build an array to hold texture array
414
- const arrayData = new Uint8Array(size_x * size_y * 3 * layerCount);
417
+ const arrayData = new Uint8Array(size_x * size_y * 4 * layerCount);
415
418
  arrayData.fill(255); // fill with white
416
419
 
417
420
  if (image.width === size_x && image.height === size_y) {
@@ -1 +1 @@
1
- {"version":3,"file":"WaterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/water/WaterSystem.js"],"names":[],"mappings":";AAWA;IAyBI;;;;OAIG;IACH,sCAYC;IAzCD,+BAAuB;IAEvB;;;OAGG;IACH,cAFU,GAAG,CAEG;IAGhB,cAAY;IAEZ;;;OAGG;IACH,aAFU,KAAK,EAAE,CAEA;IAEjB;;;;OAIG;IACH,qBAAiB;IAWb,+BAA8B;IAE9B;;;OAGG;IACH,aAFU,cAAY,IAAI,CAEH;IAK3B,4CAMC;IAED,2CA0DC;IAED;;;;OAIG;IACH,gBAHW,KAAK,UACL,MAAM,QAsDhB;IAED;;;;OAIG;IACH,kBAHW,KAAK,UACL,MAAM,QAgBhB;IAED,2BAgCC;IAED;;;;;OAKG;IACH,0BAUC;IAED,6BAcC;CACJ;;;;uBA7QsB,wBAAwB;kBAM7B,YAAY;oBAPV,mCAAmC"}
1
+ {"version":3,"file":"WaterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/water/WaterSystem.js"],"names":[],"mappings":";AAYA;IAyBI;;;;OAIG;IACH,sCAYC;IAzCD,+BAAuB;IAEvB;;;OAGG;IACH,cAFU,GAAG,CAEG;IAGhB,cAAY;IAEZ;;;OAGG;IACH,aAFU,KAAK,EAAE,CAEA;IAEjB;;;;OAIG;IACH,qBAAiB;IAWb,+BAA8B;IAE9B;;;OAGG;IACH,aAFU,cAAY,IAAI,CAEH;IAK3B,4CAMC;IAED,2CA4DC;IAED;;;;OAIG;IACH,gBAHW,KAAK,UACL,MAAM,QAsDhB;IAED;;;;OAIG;IACH,kBAHW,KAAK,UACL,MAAM,QAgBhB;IAED,2BAgCC;IAED;;;;;OAKG;IACH,0BAUC;IAED,6BAcC;CACJ;;;;uBA/QsB,wBAAwB;kBAM7B,YAAY;oBAPV,mCAAmC"}
@@ -1,4 +1,5 @@
1
1
  import { BackSide, PlaneBufferGeometry } from 'three';
2
+ import { assert } from "../../../../core/assert.js";
2
3
  import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
3
4
  import { System } from '../../../ecs/System.js';
4
5
  import { obtainTerrain } from "../../../ecs/terrain/util/obtainTerrain.js";
@@ -76,6 +77,8 @@ class WaterSystem extends System {
76
77
  (destination, offset, entity, ecd) => {
77
78
  const component = ecd.getComponent(entity, Water);
78
79
 
80
+ assert.defined(component, 'component');
81
+
79
82
  const mesh = component.__threeObject;
80
83
 
81
84
  if (mesh === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"SplatMaterial.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/material/SplatMaterial.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,oFAPW,OAAO,GAIN,cAAc,CAkIzB;;IAxID;;;;;;;;OAQG;IACH,kEAPW,OAAO,EAsIjB;;wBA5IM,OAAO;+BAAP,OAAO"}
1
+ {"version":3,"file":"SplatMaterial.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/material/SplatMaterial.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,oFAPW,OAAO,GAIN,cAAc,CAgIzB;;IAtID;;;;;;;;OAQG;IACH,kEAPW,OAAO,EAoIjB;;wBA1IM,OAAO;+BAAP,OAAO"}
@@ -47,10 +47,7 @@ export function SplatMaterial(
47
47
  type: "t",
48
48
  value: null
49
49
  },
50
- "splatLayerCount": {
51
- type: "f",
52
- value: 4
53
- },
50
+
54
51
  "splatResolution": {
55
52
  type: 'v2',
56
53
  value: new Vector2(1, 1)
@@ -115,6 +112,7 @@ export function SplatMaterial(
115
112
  transparent: false,
116
113
  lights: true,
117
114
  defines: {
115
+ SPLAT_LAYER_COUNT: 4,
118
116
  SHADOWMAP_CLOUDS: false,
119
117
  DIFFUSE_GRAIN: false
120
118
  },
@@ -95,7 +95,7 @@ function fragment() {
95
95
  precision highp sampler2DArray;
96
96
 
97
97
  uniform sampler2DArray splatWeightMap;
98
- uniform int splatLayerCount;
98
+ // SPLAT_LAYER_COUNT is injected as a #define from the material defines
99
99
 
100
100
  uniform vec2 splatResolution;
101
101
 
@@ -240,14 +240,7 @@ function fragment() {
240
240
  return hsv2rgb(hsv);
241
241
  }
242
242
 
243
- vec3 brighten2(const in vec3 color, in float factor, float p){
244
- vec3 yiq = rgb2yiq*color;
245
-
246
- yiq.x *= p;
247
- yiq.x = pow(yiq.x,factor);
248
-
249
- return yiq2rgb * yiq;
250
- }
243
+
251
244
 
252
245
  vec4 computeGridOverlayTexel(const in vec2 grid_uv, const in vec2 grid_resolution){
253
246
  vec2 grid_texel = vGridPosition + 0.5;
@@ -276,7 +269,7 @@ function fragment() {
276
269
  float weightSum = 0.0;
277
270
  vec4 colorSum = vec4(0.0);
278
271
 
279
- for( int i = 0; i < splatLayerCount; i++){
272
+ for( int i = 0; i < SPLAT_LAYER_COUNT; i++){
280
273
 
281
274
  vec2 scale = texelFetch(materialScalesMap, ivec2(i, 0), 0 ).xy;
282
275
 
@@ -290,7 +283,7 @@ function fragment() {
290
283
  colorSum += diffuseData*weight;
291
284
  }
292
285
 
293
- return colorSum / weightSum;
286
+ return weightSum > 0.0 ? colorSum / weightSum : vec4(0.0);
294
287
  }
295
288
 
296
289
  ${ShaderChunks.clouds_pars_fragment}
@@ -10,20 +10,22 @@ export class NavigationMesh {
10
10
  * @param {BinaryTopology} source
11
11
  * @param {number} [agent_radius]
12
12
  * @param {number} [agent_height]
13
- * @param {number} [agent_max_climb] In radians, how steep of an angle can the agent go up by
13
+ * @param {number} [agent_max_climb_angle] In radians, how steep of an angle can the agent go up by
14
14
  * @param {Vector3} [up] Defines world's "UP" direction, this is what the agent will respect for climbing constraint
15
15
  */
16
- build({ source, agent_radius, agent_height, agent_max_climb, up, }: BinaryTopology): void;
16
+ build({ source, agent_radius, agent_height, agent_max_climb_angle, up, }: BinaryTopology): void;
17
17
  /**
18
+ * Compute a walkable path between the two points.
19
+ * The result is a sequence of 3d points written into `output`. First point matches start, last point matches goal (snapped onto the mesh).
18
20
  *
19
- * @param {Float32Array} output
21
+ * @param {Float32Array} output packed XYZ triples
20
22
  * @param {number} start_x
21
23
  * @param {number} start_y
22
24
  * @param {number} start_z
23
25
  * @param {number} goal_x
24
26
  * @param {number} goal_y
25
27
  * @param {number} goal_z
26
- * @returns {number}
28
+ * @returns {number} number of 3d points written to `output` (0 if no path was found)
27
29
  */
28
30
  find_path(output: Float32Array, start_x: number, start_y: number, start_z: number, goal_x: number, goal_y: number, goal_z: number): number;
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationMesh.d.ts","sourceRoot":"","sources":["../../../../../src/engine/navigation/mesh/NavigationMesh.js"],"names":[],"mappings":"AAmCA;IAEI,yBAAgC;IAEhC;;;OAGG;IACH,KAFU,GAAG,CAEG;IAEhB;;;;;;;OAOG;IACH,oEANW,cAAc,QAwBxB;IAGD;;;;;;;;;;OAUG;IACH,kBATW,YAAY,WACZ,MAAM,WACN,MAAM,WACN,MAAM,UACN,MAAM,UACN,MAAM,UACN,MAAM,GACJ,MAAM,CAwGlB;CAEJ;+BA3L4C,gEAAgE;oBAFzF,gCAAgC"}
1
+ {"version":3,"file":"NavigationMesh.d.ts","sourceRoot":"","sources":["../../../../../src/engine/navigation/mesh/NavigationMesh.js"],"names":[],"mappings":"AAgCA;IAEI,yBAAgC;IAEhC;;;OAGG;IACH,KAFU,GAAG,CAEG;IAEhB;;;;;;;OAOG;IACH,0EANW,cAAc,QAwBxB;IAGD;;;;;;;;;;;;OAYG;IACH,kBATW,YAAY,WACZ,MAAM,WACN,MAAM,WACN,MAAM,UACN,MAAM,UACN,MAAM,UACN,MAAM,GACJ,MAAM,CA+HlB;CAEJ;+BAlN4C,gEAAgE;oBADzF,gCAAgC"}