@woosh/meep-engine 2.33.3 → 2.33.8

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 (128) hide show
  1. package/core/bvh2/LeafNode.js +6 -1
  2. package/core/bvh2/aabb3/AABB3.js +21 -1
  3. package/core/bvh2/aabb3/aabb3_intersects_frustum.js +10 -2
  4. package/core/collection/RingBuffer.js +40 -10
  5. package/core/collection/array/copyArray.js +2 -2
  6. package/core/collection/array/typed/typed_array_copy.js +2 -2
  7. package/core/collection/set/compute_set_difference.js +32 -0
  8. package/core/collection/set/compute_set_intersection.js +22 -0
  9. package/core/collection/set/set_remove.js +15 -0
  10. package/core/collection/table/RowFirstTableSpec.js +8 -0
  11. package/core/color/Color.js +1 -0
  12. package/core/color/ColorUtils.js +12 -3
  13. package/core/geom/3d/aabb/aabb3_compute_projected_area.js +6 -4
  14. package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
  15. package/core/geom/3d/aabb/aabb3_from_min_max.js +15 -0
  16. package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
  17. package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
  18. package/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +96 -0
  19. package/{engine/graphics/micron/render/v1 → core/geom/3d}/apply_mat4_transform_to_v3_array.js +0 -0
  20. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.js +3 -3
  21. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.spec.js +1 -1
  22. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_sphere_of_2_spheres.js +3 -3
  23. package/{engine/graphics/micron/util → core/geom/3d}/encode_unit3_hemioct.js +0 -0
  24. package/core/geom/3d/frustum/array_normalize_plane.js +25 -0
  25. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +60 -0
  26. package/{engine/graphics/micron/util → core/geom/3d}/unit_hemioct.spec.js +1 -1
  27. package/{engine/graphics/micron/build → core}/graph/MultiNode.js +0 -0
  28. package/{engine/graphics/micron/build → core}/graph/SquareMatrix.js +2 -2
  29. package/{engine/graphics/micron/build → core}/graph/SquareMatrix.spec.js +1 -1
  30. package/{engine/graphics/micron/build → core}/graph/WeightedEdge.js +1 -1
  31. package/{engine/graphics/micron/build → core}/graph/build_face_graph_from_mesh.js +2 -2
  32. package/{engine/graphics/micron/build/clustering → core/graph}/cluster_mesh_metis.js +2 -6
  33. package/{engine/graphics/micron/build → core}/graph/coarsen_graph.js +1 -1
  34. package/{engine/graphics/micron/build → core}/graph/coarsen_graph.spec.js +1 -1
  35. package/{engine/graphics/micron/build → core}/graph/eigen/eigen.js +0 -0
  36. package/{engine/graphics/micron/build → core}/graph/eigen/eigen.spec.js +1 -1
  37. package/{engine/graphics/micron/build/hierarchy → core/graph/eigen}/eigen_values_find_spectral_gap.js +0 -0
  38. package/{engine/graphics/micron/build → core}/graph/graph_adjacency_matrix.js +0 -0
  39. package/{engine/graphics/micron/build → core}/graph/graph_compute_disconnected_clusters.js +0 -0
  40. package/{engine/graphics/micron/build → core}/graph/graph_degree_matrix.js +0 -0
  41. package/{engine/graphics/micron/build → core}/graph/graph_k_means_cluster.js +5 -5
  42. package/{engine/graphics/micron/build → core}/graph/graph_laplacian_matrix.js +1 -1
  43. package/{engine/graphics/micron/build → core}/graph/metis/metis.js +2 -2
  44. package/{engine/graphics/micron/build → core}/graph/metis/metis_options.js +0 -0
  45. package/{engine/graphics/micron/build → core}/graph/mn_graph_collapse_weighted_edge.js +0 -0
  46. package/core/process/undo/ActionProcessor.d.ts +2 -0
  47. package/core/process/undo/ActionProcessor.js +59 -1
  48. package/core/process/undo/ActionProcessor.spec.js +59 -0
  49. package/core/process/undo/Mark.js +2 -1
  50. package/engine/Engine.d.ts +2 -0
  51. package/engine/EngineHarness.js +4 -4
  52. package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
  53. package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
  54. package/engine/ecs/transform/Transform.js +2 -1
  55. package/engine/graphics/GraphicsEngine.js +9 -116
  56. package/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +22 -37
  57. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +155 -0
  58. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +68 -0
  59. package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +31 -0
  60. package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
  61. package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
  62. package/engine/graphics/filter/ImageFilter.js +20 -51
  63. package/engine/graphics/{micron → geometry}/aabb3_to_buffer_geometry.js +0 -0
  64. package/engine/graphics/{micron/build → geometry/buffered}/compute_buffer_geometry_byte_size.js +0 -0
  65. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +25 -16
  66. package/engine/graphics/material/SplatMaterial.js +4 -97
  67. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +2 -6
  68. package/engine/graphics/micron/build/clustering/build_clustering_2.js +2 -2
  69. package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
  70. package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -0
  71. package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +3 -3
  72. package/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -72
  73. package/engine/graphics/micron/build/hierarchy/build_merge_graph.js +2 -2
  74. package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +3 -3
  75. package/engine/graphics/micron/build/hierarchy/merge_patches.js +6 -3
  76. package/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +1 -1
  77. package/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +1 -1
  78. package/engine/graphics/micron/build/hierarchy/patch_combine.js +2 -2
  79. package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +2 -1
  80. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
  81. package/engine/graphics/micron/format/MicronGeometryPatch.js +11 -3
  82. package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
  83. package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -4
  84. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +28 -26
  85. package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
  86. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
  87. package/engine/graphics/micron/render/refinement/ActivePatchList.js +40 -80
  88. package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
  89. package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
  90. package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
  91. package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
  92. package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
  93. package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
  94. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
  95. package/engine/graphics/render/forward_plus/LightManager.js +5 -7
  96. package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
  97. package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
  98. package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
  99. package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
  100. package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
  101. package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
  102. package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
  103. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  104. package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
  105. package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
  106. package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
  107. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
  108. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
  109. package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
  110. package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
  111. package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
  112. package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
  113. package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
  114. package/engine/graphics/texture/cubemap/load_environment_map.js +163 -0
  115. package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
  116. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +3 -2
  117. package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
  118. package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
  119. package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
  120. package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
  121. package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
  122. package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
  123. package/engine/plugin/EnginePluginManager.d.ts +9 -0
  124. package/engine/reference/v2/Reference.d.ts +7 -0
  125. package/package.json +1 -1
  126. package/view/minimap/gl/MinimapMarkersGL.js +2 -2
  127. package/engine/graphics/micron/build/clustering/cluster_mesh_vertices.js +0 -3
  128. package/engine/graphics/micron/render/RefinementSpec.js +0 -159
@@ -0,0 +1,25 @@
1
+ import { v3_length } from "../../Vector3.d.ts";
2
+
3
+ /**
4
+ * Normalize a plane in-place
5
+ * @param {number[]} source
6
+ * @param {number} source_offset
7
+ */
8
+ function array_normalize_plane(source, source_offset) {
9
+ const _x = source[source_offset];
10
+ const _y = source[source_offset + 1];
11
+ const _z = source[source_offset + 2];
12
+
13
+ const length = v3_length(_x, _y, _z);
14
+
15
+ const inverseNormalLength = 1.0 / length;
16
+
17
+ /*
18
+ By re-using values already in the registers instead of using *= we save a few extra READ ops
19
+ */
20
+ source[source_offset] = _x * inverseNormalLength;
21
+ source[source_offset + 1] = _y * inverseNormalLength;
22
+ source[source_offset + 2] = _z * inverseNormalLength;
23
+
24
+ source[source_offset + 3] *= inverseNormalLength;
25
+ }
@@ -0,0 +1,60 @@
1
+ import { v3_length } from "../../Vector3.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} destination
6
+ * @param {number} destination_offset
7
+ * @param {number} x
8
+ * @param {number} y
9
+ * @param {number} z
10
+ * @param {number} w
11
+ */
12
+ function array_set_plane_normalized(destination, destination_offset, x, y, z, w) {
13
+ const length = v3_length(x, y, z);
14
+
15
+ const inverseNormalLength = 1.0 / length;
16
+
17
+ destination[destination_offset] = x * inverseNormalLength;
18
+ destination[destination_offset + 1] = y * inverseNormalLength;
19
+ destination[destination_offset + 2] = z * inverseNormalLength;
20
+ destination[destination_offset + 3] = w * inverseNormalLength;
21
+ }
22
+
23
+ /**
24
+ * Set frustum from projection matrix
25
+ * @param {number[]|Float32Array} frustum_planes
26
+ * @param {number[]} me
27
+ */
28
+ export function array_setFromProjectionMatrix(frustum_planes, me) {
29
+
30
+ const me0 = me[0];
31
+ const me3 = me[3];
32
+
33
+ const me4 = me[4];
34
+ const me7 = me[7];
35
+
36
+ const me8 = me[8];
37
+ const me11 = me[11];
38
+
39
+ const me12 = me[12];
40
+ const me15 = me[15];
41
+
42
+ array_set_plane_normalized(frustum_planes, 0, me3 - me0, me7 - me4, me11 - me8, me15 - me12);
43
+ array_set_plane_normalized(frustum_planes, 4, me3 + me0, me7 + me4, me11 + me8, me15 + me12);
44
+
45
+ const me1 = me[1];
46
+ const me5 = me[5];
47
+ const me9 = me[9];
48
+ const me13 = me[13];
49
+
50
+ array_set_plane_normalized(frustum_planes, 8, me3 + me1, me7 + me5, me11 + me9, me15 + me13);
51
+ array_set_plane_normalized(frustum_planes, 12, me3 - me1, me7 - me5, me11 - me9, me15 - me13);
52
+
53
+ const me2 = me[2];
54
+ const me6 = me[6];
55
+ const me10 = me[10];
56
+ const me14 = me[14];
57
+
58
+ array_set_plane_normalized(frustum_planes, 16, me3 - me2, me7 - me6, me11 - me10, me15 - me14);
59
+ array_set_plane_normalized(frustum_planes, 20, me3 + me2, me7 + me6, me11 + me10, me15 + me14);
60
+ }
@@ -1,5 +1,5 @@
1
1
  import { decode_hemioct_to_unit, encode_unit_to_hemioct } from "./encode_unit3_hemioct.js";
2
- import { v3_length } from "../../../../core/geom/Vector3.js";
2
+ import { v3_length } from "../Vector3.d.ts";
3
3
 
4
4
  test('encode-decode', () => {
5
5
  const v0 = [];
@@ -1,5 +1,5 @@
1
- import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
2
- import { assert } from "../../../../../core/assert.js";
1
+ import { DataType2TypedArrayConstructorMapping } from "../collection/table/DataType2TypedArrayConstructorMapping.js";
2
+ import { assert } from "../assert.js";
3
3
 
4
4
  export class SquareMatrix {
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { SquareMatrix } from "./SquareMatrix.js";
2
- import { DataType } from "../../../../../core/collection/table/DataType.js";
2
+ import { DataType } from "../collection/table/DataType.js";
3
3
 
4
4
  test('set/get cell', () => {
5
5
  const m = new SquareMatrix(2, DataType.Uint8);
@@ -1,4 +1,4 @@
1
- import { Edge } from "../../../../../core/graph/Edge.js";
1
+ import { Edge } from "./Edge.js";
2
2
 
3
3
  export class WeightedEdge extends Edge {
4
4
  constructor(a, b) {
@@ -1,6 +1,6 @@
1
- import { Graph } from "../../../../../core/graph/v2/Graph.js";
1
+ import { Graph } from "./v2/Graph.js";
2
2
  import { MultiNode } from "./MultiNode.js";
3
- import { compute_face_connection_weight } from "../clustering/compute_face_connection_weight.js";
3
+ import { compute_face_connection_weight } from "../../engine/graphics/micron/build/clustering/compute_face_connection_weight.js";
4
4
  import { WeightedEdge } from "./WeightedEdge.js";
5
5
  import { graph_compute_disconnected_clusters } from "./graph_compute_disconnected_clusters.js";
6
6
 
@@ -1,5 +1,5 @@
1
- import { Metis } from "../graph/metis/metis.js";
2
- import { metis_options } from "../graph/metis/metis_options.js";
1
+ import { Metis } from "./metis/metis.js";
2
+ import { metis_options } from "./metis/metis_options.js";
3
3
 
4
4
  /**
5
5
  * How many times to retry partitioning before giving up
@@ -7,10 +7,6 @@ import { metis_options } from "../graph/metis/metis_options.js";
7
7
  */
8
8
  const MAX_STEPS = 50;
9
9
 
10
- function cluster_mesh_metis_detailed(mesh, patch_size) {
11
-
12
- }
13
-
14
10
  /**
15
11
  *
16
12
  * @param {Uint32Array} result
@@ -1,4 +1,4 @@
1
- import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
1
+ import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
2
2
  import { mn_graph_collapse_weighted_edge } from "./mn_graph_collapse_weighted_edge.js";
3
3
  import { WeightedEdge } from "./WeightedEdge.js";
4
4
 
@@ -1,4 +1,4 @@
1
- import { Graph } from "../../../../../core/graph/v2/Graph.js";
1
+ import { Graph } from "./v2/Graph.js";
2
2
  import { MultiNode } from "./MultiNode.js";
3
3
  import { WeightedEdge } from "./WeightedEdge.js";
4
4
  import { coarsen_graph } from "./coarsen_graph.js";
@@ -1,5 +1,5 @@
1
1
  import { SquareMatrix } from "../SquareMatrix.js";
2
- import { DataType } from "../../../../../../core/collection/table/DataType.js";
2
+ import { DataType } from "../../collection/table/DataType.js";
3
3
  import { matrix_eigenvalues_in_place } from "./eigen.js";
4
4
 
5
5
  function roughly_equal_array_vectors(actual, expected) {
@@ -1,10 +1,10 @@
1
1
  //
2
- import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
3
- import { randomIntegerBetween } from "../../../../../core/math/MathUtils.js";
2
+ import { seededRandom } from "../math/random/seededRandom.js";
3
+ import { randomIntegerBetween } from "../math/MathUtils.js";
4
4
  import { SquareMatrix } from "./SquareMatrix.js";
5
- import { DataType } from "../../../../../core/collection/table/DataType.js";
6
- import { BitSet } from "../../../../../core/binary/BitSet.js";
7
- import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
5
+ import { DataType } from "../collection/table/DataType.js";
6
+ import { BitSet } from "../binary/BitSet.js";
7
+ import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
8
8
 
9
9
  /**
10
10
  * @template N
@@ -1,6 +1,6 @@
1
1
  import { graph_degree_matrix } from "./graph_degree_matrix.js";
2
2
  import { SquareMatrix } from "./SquareMatrix.js";
3
- import { DataType } from "../../../../../core/collection/table/DataType.js";
3
+ import { DataType } from "../collection/table/DataType.js";
4
4
  import { graph_adjacency_matrix } from "./graph_adjacency_matrix.js";
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
- import WorkerBuilder from "../../../../../../core/process/worker/WorkerBuilder.js";
2
- import { OnDemandWorkerManager } from "../../../../../../core/process/worker/OnDemandWorkerManager.js";
1
+ import WorkerBuilder from "../../process/worker/WorkerBuilder.js";
2
+ import { OnDemandWorkerManager } from "../../process/worker/OnDemandWorkerManager.js";
3
3
 
4
4
 
5
5
  export class Metis {
@@ -17,6 +17,8 @@ export class ActionProcessor<CTX, MD> {
17
17
 
18
18
  redo(): void
19
19
 
20
+ navigateTo(mark: MD): boolean
21
+
20
22
  doMany(actions: Action<CTX>[]): void
21
23
 
22
24
  do(action: Action<CTX>): this
@@ -202,6 +202,64 @@ export class ActionProcessor {
202
202
 
203
203
  }
204
204
 
205
+ /**
206
+ * Navigate to a specific mark back or forward
207
+ * @param {M} mark_descriptor specific mark description
208
+ * @returns {boolean} true on success, false otherwise (e.g. mark not found)
209
+ * @throws {Error} when mark is non-unique
210
+ */
211
+ navigateTo(mark_descriptor) {
212
+ // find all matching marks
213
+ const matching_marks = this.marks.filter(m => m.description === mark_descriptor);
214
+
215
+ if (matching_marks.length === 0) {
216
+ // not found
217
+ return false;
218
+ }
219
+
220
+ if (matching_marks.length > 1) {
221
+ throw new Error(`Attempting to navigate to a non-unique mark descriptor '${mark_descriptor}'. Mark descriptor must be unique, instead ${matching_marks.length} matches were found`);
222
+ }
223
+
224
+ const match = matching_marks[0];
225
+
226
+ const target = match.index;
227
+
228
+ let temp_cursor = this.cursor;
229
+
230
+ if (target > this.cursor) {
231
+
232
+ while (target > this.cursor) {
233
+ // navigate forward
234
+ this.redo();
235
+
236
+ if (temp_cursor === this.cursor) {
237
+ // no cursor change
238
+ return false;
239
+ }
240
+
241
+ temp_cursor = this.cursor;
242
+ }
243
+
244
+ } else if (target < this.cursor) {
245
+
246
+ while (target < this.cursor) {
247
+ // navigate backwards
248
+ this.undo();
249
+
250
+ if (temp_cursor === this.cursor) {
251
+ // no cursor change
252
+ return false;
253
+ }
254
+
255
+ temp_cursor = this.cursor;
256
+ }
257
+
258
+ }
259
+
260
+ return true;
261
+ }
262
+
205
263
  undo() {
206
264
  let markAddress = 0;
207
265
  /**
@@ -226,7 +284,7 @@ export class ActionProcessor {
226
284
  markAddress = 0;
227
285
  }
228
286
 
229
- //keep rewinding until we hit mark
287
+ //keep rewinding until we hit a mark
230
288
  while (this.cursor > markAddress && this.cursor > 0) {
231
289
  this.cursor--;
232
290
  const action = this.history.get(this.cursor);
@@ -0,0 +1,59 @@
1
+ import { ActionProcessor } from "./ActionProcessor.js";
2
+ import { Action } from "./Action.js";
3
+
4
+ class DummyContext {
5
+ constructor() {
6
+ this.value = 0;
7
+ }
8
+ }
9
+
10
+ class DummyAction extends Action {
11
+ apply(context) {
12
+ // do nothing
13
+ context.value++;
14
+ }
15
+
16
+ revert(context) {
17
+ context.value--;
18
+ }
19
+ }
20
+
21
+ test('navigateTo backwards', () => {
22
+ const ctx = new DummyContext();
23
+ const ap = new ActionProcessor(ctx);
24
+
25
+ ap.mark('a');
26
+ ap.do(new DummyAction());
27
+ ap.mark('b');
28
+ ap.do(new DummyAction());
29
+
30
+ expect(ap.navigateTo('a')).toBe(true);
31
+
32
+ expect(ctx.value).toBe(0);
33
+ });
34
+
35
+ test('navigateTo forward', () => {
36
+ const ctx = new DummyContext();
37
+ const ap = new ActionProcessor(ctx);
38
+
39
+ ap.mark('a');
40
+ ap.do(new DummyAction());
41
+ ap.mark('b');
42
+ ap.do(new DummyAction());
43
+ ap.mark('c');
44
+
45
+ ap.undo();
46
+ ap.undo();
47
+ ap.undo();
48
+
49
+ expect(ap.navigateTo('c')).toBe(true);
50
+
51
+ expect(ctx.value).toBe(2);
52
+ });
53
+
54
+ test('navigateTo non-existent on empty', () => {
55
+ const ctx = new DummyContext();
56
+ const ap = new ActionProcessor(ctx);
57
+
58
+ expect(ap.navigateTo('a')).toBe(false);
59
+ });
@@ -8,13 +8,14 @@ export class Mark {
8
8
  * @constructor
9
9
  */
10
10
  constructor(index, description) {
11
- assert.typeOf(index, 'number', 'index');
11
+ assert.isNumber(index, 'index');
12
12
 
13
13
  /**
14
14
  *
15
15
  * @type {number}
16
16
  */
17
17
  this.index = index;
18
+
18
19
  /**
19
20
  *
20
21
  * @type {D}
@@ -8,6 +8,7 @@ import {AssetManager} from "./asset/AssetManager";
8
8
  import {EntityManager} from "./ecs/EntityManager";
9
9
  import View from "../view/View";
10
10
  import Ticker from "./simulation/Ticker";
11
+ import {EnginePluginManager} from "./plugin/EnginePluginManager";
11
12
 
12
13
  export interface IEngineInitializationOptions {
13
14
  entityManager?: EntityManager
@@ -25,6 +26,7 @@ export default class Engine {
25
26
  public readonly devices: { keyboard: KeyboardDevice, pointer: PointerDevice }
26
27
  public readonly assetManager: AssetManager
27
28
  public readonly ticker: Ticker
29
+ public readonly plugins: EnginePluginManager
28
30
 
29
31
  public start(): Promise<any>
30
32
 
@@ -203,10 +203,10 @@ export class EngineHarness {
203
203
  *
204
204
  * @param {Engine} engine
205
205
  * @param {Vector3} [focus]
206
- * @param heightMap
207
- * @param heightRange
208
- * @param pitch
209
- * @param yaw
206
+ * @param [heightMap]
207
+ * @param [heightRange]
208
+ * @param [pitch]
209
+ * @param [yaw]
210
210
  * @param {number} [distance]
211
211
  * @param {Vector2} [terrainSize]
212
212
  * @param {number} [terrainResolution]
@@ -0,0 +1,19 @@
1
+ /**
2
+ *
3
+ * @param {WebGL2RenderingContext} gl
4
+ * @param {Sampler2D} sampler
5
+ * @param {ImageBitmap} bitmap
6
+ */
7
+ export function bitmap2sampler_gl(gl, sampler, bitmap) {
8
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap);
9
+ gl.drawBuffers([gl.COLOR_ATTACHMENT0]);
10
+
11
+ const w = sampler.width;
12
+ const h = sampler.height;
13
+
14
+ if (sampler.itemSize !== 4) {
15
+ throw new Error(`Expected sampler.itemSize to be 4, instead was '${sampler.itemSize}'`);
16
+ }
17
+
18
+ gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, sampler.data);
19
+ }
@@ -1,6 +1,7 @@
1
1
  import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
3
  import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
4
+ import { bitmap2sampler_gl } from "./bitmap2sampler_gl.js";
4
5
 
5
6
  /**
6
7
  *
@@ -8,23 +9,6 @@ import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqu
8
9
  */
9
10
  const sampler_cache = new WeakMap();
10
11
 
11
- /**
12
- *
13
- * @param {WebGL2RenderingContext} gl
14
- * @param {Sampler2D} sampler
15
- * @param {ImageBitmap} bitmap
16
- */
17
- function bitmap2sampler_gl(gl, sampler, bitmap) {
18
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap);
19
- gl.drawBuffers([gl.COLOR_ATTACHMENT0]);
20
-
21
- const data = new Uint8Array(sampler.width * sampler.height * 4);
22
-
23
- gl.readPixels(0, 0, sampler.width, sampler.height, gl.RGBA, gl.UNSIGNED_BYTE, data);
24
-
25
- sampler.data = data;
26
- }
27
-
28
12
  /**
29
13
  *
30
14
  * @param {ImageBitmap} bitmap
@@ -45,7 +29,7 @@ function obtainSampler(bitmap, ctx) {
45
29
  const width = bitmap.width;
46
30
  const height = bitmap.height;
47
31
 
48
- const sampler = new Sampler2D(null, 4, width, height);
32
+ const sampler = Sampler2D.uint8(4, width, height);
49
33
 
50
34
  bitmap2sampler_gl(ctx, sampler, bitmap);
51
35
 
@@ -75,15 +59,19 @@ function obtainCanvasCtx(width, height) {
75
59
 
76
60
  if (ctx_ref === null || (gl = ctx_ref.deref()) === undefined) {
77
61
  const canvas = document.createElement('canvas');
62
+
78
63
  gl = canvas.getContext("webgl2");
79
64
  gl.activeTexture(gl.TEXTURE0);
65
+
80
66
  const texture = gl.createTexture();
67
+
81
68
  gl.bindTexture(gl.TEXTURE_2D, texture);
69
+
82
70
  const framebuffer = gl.createFramebuffer();
71
+
83
72
  gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
84
73
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
85
74
 
86
-
87
75
  ctx_ref = new WeakRef(gl);
88
76
  }
89
77
 
@@ -6,6 +6,7 @@ import Vector3 from "../../../core/geom/Vector3.js";
6
6
  import Quaternion from "../../../core/geom/Quaternion.js";
7
7
  import { Matrix4 } from "../../../core/geom/Matrix4.js";
8
8
  import { Quaternion as ThreeQuaternion } from "three";
9
+ import { composeMatrix4 } from "../../graphics/util/composeMatrix4.js";
9
10
 
10
11
  const delta = new Vector3();
11
12
 
@@ -175,7 +176,7 @@ export class Transform {
175
176
  * @param {Matrix4} matrix
176
177
  */
177
178
  toThreeMatrix(matrix) {
178
- matrix.compose(this.position, this.rotation, this.scale);
179
+ composeMatrix4(matrix, this.position, this.rotation, this.scale);
179
180
  }
180
181
  }
181
182