@woosh/meep-engine 2.47.3 → 2.47.10

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 (130) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -0
  2. package/build/bundle-worker-terrain.js +1 -0
  3. package/build/meep.cjs +1044 -933
  4. package/build/meep.min.js +1 -1
  5. package/build/meep.module.js +1044 -933
  6. package/package.json +2 -2
  7. package/src/core/binary/BitSet.spec.js +3 -3
  8. package/src/core/bvh2/BinaryNode.js +12 -10
  9. package/src/core/bvh2/aabb3/AABB3.js +30 -31
  10. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
  11. package/src/core/bvh2/binary/BinaryBVH.js +1 -1
  12. package/src/core/bvh2/binary/RayLeafIntersectionVisitor.js +1 -1
  13. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
  14. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +2 -2
  15. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +1 -1
  16. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +1 -1
  17. package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +10 -8
  18. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +14 -22
  19. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +13 -15
  20. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +14 -21
  21. package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +16 -24
  22. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +23 -26
  23. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +10 -11
  24. package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +2 -2
  25. package/src/core/bvh2/transform/tryRotateSingleNode.js +2 -2
  26. package/src/core/bvh2/traversal/aabb3_detailed_volume_intersection_callback_based.js +1 -1
  27. package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +1 -1
  28. package/src/core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js +13 -0
  29. package/src/core/color/Color.d.ts +2 -1
  30. package/src/core/color/Color.js +30 -5
  31. package/src/core/color/ColorUtils.js +7 -5
  32. package/src/core/color/parseHex.js +11 -3
  33. package/src/core/color/rgb2hex.js +1 -1
  34. package/src/core/geom/3d/SurfacePoint3.d.ts +7 -0
  35. package/src/core/geom/3d/SurfacePoint3.js +56 -1
  36. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_combine.js +2 -2
  37. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_contains_point.js +1 -1
  38. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_degree.js +2 -2
  39. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_combined_surface_area.js +2 -2
  40. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js +1 -1
  41. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.spec.js +8 -0
  42. package/src/core/geom/3d/aabb/{computeAABB3PlaneSide.js → aabb3_compute_plane_side.js} +1 -1
  43. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_detailed_volume_intersection.js +7 -7
  44. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array.js +4 -4
  45. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array_transformed.js +2 -2
  46. package/src/core/{bvh2/aabb3/aabb3_intersect_aabb3.js → geom/3d/aabb/aabb3_intersects_aabb3.js} +2 -2
  47. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_array.js +2 -2
  48. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_degree.js +4 -4
  49. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_line_segment.js +1 -1
  50. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +87 -0
  51. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray.spec.js +1 -1
  52. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_branchless.js +2 -2
  53. package/src/core/{bvh2/aabb3/aabb3_intersect_ray_slab.js → geom/3d/aabb/aabb3_intersects_ray_slab.js} +35 -17
  54. package/src/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +5 -1
  55. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_nearest_point_on_surface.js +2 -2
  56. package/src/core/geom/3d/aabb/aabb3_raycast.js +103 -0
  57. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_signed_distance_sqr_to_point.js +1 -1
  58. package/src/core/geom/3d/aabb/computeBoundingBoxFromVertexData.js +4 -12
  59. package/src/core/geom/3d/aabb/compute_aabb_from_points.js +8 -1
  60. package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
  61. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +4 -7
  62. package/src/core/model/node-graph/DataType.d.ts +4 -0
  63. package/src/core/model/node-graph/node/NodeDescription.d.ts +11 -1
  64. package/src/core/model/node-graph/node/NodeRegistry.spec.js +47 -1
  65. package/src/core/model/node-graph/node/Port.d.ts +3 -0
  66. package/src/core/model/node-graph/node/Port.js +7 -3
  67. package/src/core/model/node-graph/node/Port.spec.js +44 -0
  68. package/src/core/model/node-graph/node/PortDirection.d.ts +5 -0
  69. package/src/engine/asset/Asset.js +1 -1
  70. package/src/engine/asset/AssetLoadState.js +10 -0
  71. package/src/engine/asset/AssetManager.js +164 -228
  72. package/src/engine/asset/PendingAsset.js +61 -0
  73. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  74. package/src/engine/ecs/foliage/InstancedFoliage.js +1 -1
  75. package/src/engine/ecs/storage/BinaryBufferSerializer.js +13 -1
  76. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +11 -4
  77. package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.js +54 -0
  78. package/src/engine/ecs/systems/RenderSystem.js +1 -33
  79. package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +2 -4
  80. package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +6 -1
  81. package/src/engine/graphics/GraphicsEngine.js +5 -1
  82. package/src/engine/graphics/ecs/decal/v2/Decal.js +44 -2
  83. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +31 -0
  84. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +16 -5
  85. package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +88 -56
  86. package/src/engine/graphics/geometry/buffered/compute_buffer_geometry_byte_size.js +5 -1
  87. package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js +2 -2
  88. package/src/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +1 -1
  89. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +3 -2
  90. package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +3 -2
  91. package/src/engine/graphics/micron/format/MicronGeometry.js +1 -1
  92. package/src/engine/graphics/micron/format/validate_patch_bounds.js +1 -1
  93. package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +1 -1
  94. package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +16 -16
  95. package/src/engine/graphics/render/forward_plus/LightManager.js +3 -0
  96. package/src/engine/graphics/render/forward_plus/LightManager.spec.js +5 -5
  97. package/src/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_APPLY_DECALS.js +4 -0
  98. package/src/engine/graphics/render/forward_plus/model/Decal.js +10 -2
  99. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +2 -2
  100. package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +18 -16
  101. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +2 -0
  102. package/src/engine/graphics/render/visibility/IncrementalDeltaSet.js +26 -13
  103. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +8 -2
  104. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +3 -3
  105. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +18 -15
  106. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.js +1 -1
  107. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min.js +1 -1
  108. package/src/engine/graphics/three/three_computeObjectBoundingBox.js +56 -0
  109. package/src/engine/input/devices/{InputDeviceButton.d.ts → InputDeviceSwitch.d.ts} +1 -1
  110. package/src/engine/input/devices/{InputDeviceButton.js → InputDeviceSwitch.js} +1 -1
  111. package/src/engine/input/devices/KeyboardDevice.d.ts +2 -2
  112. package/src/engine/input/devices/KeyboardDevice.js +58 -40
  113. package/src/engine/input/devices/PointerDevice.js +224 -179
  114. package/src/core/bvh2/aabb3/aabb3_intersects_ray.js +0 -97
  115. package/src/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane_max.spec.js +0 -8
  116. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_array.js +0 -0
  117. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray.js +0 -0
  118. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray_array.js +0 -0
  119. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_box_surface_area_2.js +0 -0
  120. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_half_surface_area.js +0 -0
  121. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_surface_area.js +0 -0
  122. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.js +0 -0
  123. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.spec.js +0 -0
  124. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.js +0 -0
  125. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.spec.js +0 -0
  126. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_plane_mapping.js +0 -0
  127. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_expand_array.js +0 -0
  128. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_fast.js +0 -0
  129. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_score_boxes_SAH.js +0 -0
  130. /package/src/core/{bvh2/aabb3/aabb_score_boxes_SAH_delta.js → geom/3d/aabb/aabb3_score_boxes_SAH_delta.js} +0 -0
package/build/meep.cjs CHANGED
@@ -49633,7 +49633,7 @@ function arraySwapElements(array, index0, index1) {
49633
49633
  array[index1] = t;
49634
49634
  }
49635
49635
 
49636
- const stack$8 = [];
49636
+ const stack$b = [];
49637
49637
 
49638
49638
  /**
49639
49639
  * @template T
@@ -49654,14 +49654,14 @@ function arrayQuickSort(data, score_function, score_function_context, start, end
49654
49654
  let stackPointer = 2;
49655
49655
  let i, j;
49656
49656
 
49657
- stack$8[0] = start;
49658
- stack$8[1] = end;
49657
+ stack$b[0] = start;
49658
+ stack$b[1] = end;
49659
49659
 
49660
49660
  while (stackPointer > 0) {
49661
49661
  stackPointer -= 2;
49662
49662
 
49663
- const right = stack$8[stackPointer + 1];
49664
- const left = stack$8[stackPointer];
49663
+ const right = stack$b[stackPointer + 1];
49664
+ const left = stack$b[stackPointer];
49665
49665
 
49666
49666
  i = left;
49667
49667
  j = right;
@@ -49694,12 +49694,12 @@ function arrayQuickSort(data, score_function, score_function_context, start, end
49694
49694
 
49695
49695
  /* recursion */
49696
49696
  if (left < j) {
49697
- stack$8[stackPointer++] = left;
49698
- stack$8[stackPointer++] = j;
49697
+ stack$b[stackPointer++] = left;
49698
+ stack$b[stackPointer++] = j;
49699
49699
  }
49700
49700
  if (i < right) {
49701
- stack$8[stackPointer++] = i;
49702
- stack$8[stackPointer++] = right;
49701
+ stack$b[stackPointer++] = i;
49702
+ stack$b[stackPointer++] = right;
49703
49703
  }
49704
49704
  }
49705
49705
  }
@@ -49721,14 +49721,14 @@ function array_quick_sort_by_comparator(data, compare_function, compare_function
49721
49721
  let stackPointer = 2;
49722
49722
  let i, j;
49723
49723
 
49724
- stack$8[0] = start;
49725
- stack$8[1] = end;
49724
+ stack$b[0] = start;
49725
+ stack$b[1] = end;
49726
49726
 
49727
49727
  while (stackPointer > 0) {
49728
49728
  stackPointer -= 2;
49729
49729
 
49730
- const right = stack$8[stackPointer + 1];
49731
- const left = stack$8[stackPointer];
49730
+ const right = stack$b[stackPointer + 1];
49731
+ const left = stack$b[stackPointer];
49732
49732
 
49733
49733
  i = left;
49734
49734
  j = right;
@@ -49764,12 +49764,12 @@ function array_quick_sort_by_comparator(data, compare_function, compare_function
49764
49764
 
49765
49765
  /* recursion */
49766
49766
  if (left < j) {
49767
- stack$8[stackPointer++] = left;
49768
- stack$8[stackPointer++] = j;
49767
+ stack$b[stackPointer++] = left;
49768
+ stack$b[stackPointer++] = j;
49769
49769
  }
49770
49770
  if (i < right) {
49771
- stack$8[stackPointer++] = i;
49772
- stack$8[stackPointer++] = right;
49771
+ stack$b[stackPointer++] = i;
49772
+ stack$b[stackPointer++] = right;
49773
49773
  }
49774
49774
  }
49775
49775
  }
@@ -49874,7 +49874,7 @@ function mortonEncode_magicbits(x, y, z) {
49874
49874
  * @param {number} _z1
49875
49875
  * @returns {number}
49876
49876
  */
49877
- function aabb3_computeDistanceAbovePlane_max(
49877
+ function aabb3_compute_distance_above_plane_max(
49878
49878
  plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
49879
49879
  _x0, _y0, _z0,
49880
49880
  _x1, _y1, _z1
@@ -49922,7 +49922,7 @@ function v3_distance_above_plane(
49922
49922
  * @param {number} _z1
49923
49923
  * @returns {number}
49924
49924
  */
49925
- function computeAABB3PlaneSide(
49925
+ function aabb3_compute_plane_side(
49926
49926
  plane_normal_x,
49927
49927
  plane_normal_y,
49928
49928
  plane_normal_z,
@@ -50054,16 +50054,15 @@ function aabb3_intersects_frustum_degree(
50054
50054
  ) {
50055
50055
 
50056
50056
  let result = 2;
50057
- let i = 0;
50058
50057
 
50059
- for (; i < 24; i += 4) {
50058
+ for (let i = 0; i < 24; i += 4) {
50060
50059
 
50061
50060
  const p_x = frustum[i];
50062
50061
  const p_y = frustum[i + 1];
50063
50062
  const p_z = frustum[i + 2];
50064
50063
  const p_w = frustum[i + 3];
50065
50064
 
50066
- const plane_side = computeAABB3PlaneSide(
50065
+ const plane_side = aabb3_compute_plane_side(
50067
50066
  p_x, p_y, p_z, p_w,
50068
50067
  x0, y0, z0, x1, y1, z1
50069
50068
  );
@@ -50072,6 +50071,7 @@ function aabb3_intersects_frustum_degree(
50072
50071
  // completely outside
50073
50072
  return 0;
50074
50073
  } else if (plane_side === 0) {
50074
+ // partially inside - plane intersects AABB
50075
50075
  result = 1;
50076
50076
  }
50077
50077
  }
@@ -50084,7 +50084,7 @@ function aabb3_intersects_frustum_degree(
50084
50084
  * @param {Number} val
50085
50085
  * @returns {number}
50086
50086
  */
50087
- function fabsf(val) {
50087
+ function fabsf$1(val) {
50088
50088
  return val >= 0 ? val : -val;
50089
50089
  }
50090
50090
 
@@ -50130,22 +50130,22 @@ function aabb3_intersects_line_segment(
50130
50130
  boxExtentsX = (x1 - x0) / 2;
50131
50131
  centerX = x0 + boxExtentsX;
50132
50132
  diffX = (0.5 * (endX + startX)) - centerX;
50133
- a = fabsf(dirX);
50134
- if (fabsf(diffX) > boxExtentsX + a) return false;
50133
+ a = fabsf$1(dirX);
50134
+ if (fabsf$1(diffX) > boxExtentsX + a) return false;
50135
50135
  //
50136
50136
  dirY = 0.5 * (endY - startY);
50137
50137
  boxExtentsY = (y1 - y0) / 2;
50138
50138
  centerY = y0 + boxExtentsY;
50139
50139
  diffY = (0.5 * (endY + startY)) - centerY;
50140
- b = fabsf(dirY);
50141
- if (fabsf(diffY) > boxExtentsY + b) return false;
50140
+ b = fabsf$1(dirY);
50141
+ if (fabsf$1(diffY) > boxExtentsY + b) return false;
50142
50142
  //
50143
50143
  dirZ = 0.5 * (endZ - startZ);
50144
50144
  boxExtentsZ = (z1 - z0) / 2;
50145
50145
  centerZ = z0 + boxExtentsZ;
50146
50146
  diffZ = (0.5 * (endZ + startZ)) - centerZ;
50147
- c = fabsf(dirZ);
50148
- if (fabsf(diffZ) > boxExtentsZ + c) return false;
50147
+ c = fabsf$1(dirZ);
50148
+ if (fabsf$1(diffZ) > boxExtentsZ + c) return false;
50149
50149
 
50150
50150
  //Dir.y = 0.5f * (segment.mP1.y - segment.mP0.y);
50151
50151
  //BoxExtents.y = aabb.GetExtents(1);
@@ -50155,15 +50155,17 @@ function aabb3_intersects_line_segment(
50155
50155
 
50156
50156
  let f;
50157
50157
  f = dirY * diffZ - dirZ * diffY;
50158
- if (fabsf(f) > boxExtentsY * c + boxExtentsZ * b) return false;
50158
+ if (fabsf$1(f) > boxExtentsY * c + boxExtentsZ * b) return false;
50159
50159
  f = dirZ * diffX - dirX * diffZ;
50160
- if (fabsf(f) > boxExtentsX * c + boxExtentsZ * a) return false;
50160
+ if (fabsf$1(f) > boxExtentsX * c + boxExtentsZ * a) return false;
50161
50161
  f = dirX * diffY - dirY * diffX;
50162
- if (fabsf(f) > boxExtentsX * b + boxExtentsY * a) return false;
50162
+ if (fabsf$1(f) > boxExtentsX * b + boxExtentsY * a) return false;
50163
50163
 
50164
50164
  return true;
50165
50165
  }
50166
50166
 
50167
+ const fabsf = Math.abs;
50168
+
50167
50169
  /**
50168
50170
  * NOTES:
50169
50171
  * https://web.archive.org/web/20090803054252/http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
@@ -50176,86 +50178,77 @@ function aabb3_intersects_line_segment(
50176
50178
  * @param {number} x1
50177
50179
  * @param {number} y1
50178
50180
  * @param {number} z1
50179
- * @param {number} oX
50180
- * @param {number} oY
50181
- * @param {number} oZ
50182
- * @param {number} dirX
50183
- * @param {number} dirY
50184
- * @param {number} dirZ
50181
+ * @param {number} origin_x
50182
+ * @param {number} origin_y
50183
+ * @param {number} origin_z
50184
+ * @param {number} direction_x
50185
+ * @param {number} direction_y
50186
+ * @param {number} direction_z
50185
50187
  * @returns {boolean}
50186
50188
  */
50187
50189
  function aabb3_intersects_ray(
50188
50190
  x0, y0, z0,
50189
50191
  x1, y1, z1,
50190
- oX, oY, oZ,
50191
- dirX, dirY, dirZ
50192
+ origin_x, origin_y, origin_z,
50193
+ direction_x, direction_y, direction_z
50192
50194
  ) {
50193
50195
 
50194
50196
  // Z Projection
50195
- const boxExtentsX = (x1 - x0) * 0.5;
50197
+ const extents_x = (x1 - x0) * 0.5;
50196
50198
 
50197
- const centerX = x0 + boxExtentsX;
50199
+ const center_x = x0 + extents_x;
50198
50200
 
50199
- const diffX = oX - centerX;
50201
+ const diff_x = origin_x - center_x;
50200
50202
 
50201
50203
 
50202
- if (diffX * dirX >= 0.0 && fabsf(diffX) > boxExtentsX) {
50204
+ if (diff_x * direction_x >= 0.0 && fabsf(diff_x) > extents_x) {
50203
50205
  return false;
50204
50206
  }
50205
50207
 
50206
50208
  // Y projection
50207
- const boxExtentsY = (y1 - y0) * 0.5;
50209
+ const extents_y = (y1 - y0) * 0.5;
50208
50210
 
50209
- const centerY = y0 + boxExtentsY;
50211
+ const center_y = y0 + extents_y;
50210
50212
 
50211
- const diffY = oY - centerY;
50213
+ const diff_y = origin_y - center_y;
50212
50214
 
50213
50215
 
50214
- if (diffY * dirY >= 0.0 && fabsf(diffY) > boxExtentsY) {
50216
+ if (diff_y * direction_y >= 0.0 && fabsf(diff_y) > extents_y) {
50215
50217
  return false;
50216
50218
  }
50217
50219
 
50218
50220
  // Z projection
50219
- const boxExtentsZ = (z1 - z0) * 0.5;
50221
+ const extents_z = (z1 - z0) * 0.5;
50220
50222
 
50221
- const centerZ = z0 + boxExtentsZ;
50223
+ const center_z = z0 + extents_z;
50222
50224
 
50223
- const diffZ = oZ - centerZ;
50225
+ const diff_z = origin_z - center_z;
50224
50226
 
50225
50227
 
50226
- if (diffZ * dirZ >= 0.0 && fabsf(diffZ) > boxExtentsZ) {
50228
+ if (diff_z * direction_z >= 0.0 && fabsf(diff_z) > extents_z) {
50227
50229
  return false;
50228
50230
  }
50229
50231
 
50230
- //Dir.y = 0.5f * (segment.mP1.y - segment.mP0.y);
50231
- //BoxExtents.y = aabb.GetExtents(1);
50232
- //Diff.y = (0.5f * (segment.mP1.y + segment.mP0.y)) - aabb.GetCenter(1);
50233
- //b = fabsf(Dir.y);
50234
- //if(fabsf(Diff.y)>BoxExtents.y + b) return false;
50232
+ const abs_direction_y = fabsf(direction_y);
50233
+ const abs_direction_z = fabsf(direction_z);
50235
50234
 
50236
- const b = fabsf(dirY);
50237
- const c = fabsf(dirZ);
50238
- const a = fabsf(dirX);
50235
+ const f0 = fabsf(direction_y * diff_z - direction_z * diff_y);
50239
50236
 
50240
- const f0 = dirY * diffZ - dirZ * diffY;
50241
-
50242
- if (fabsf(f0) > boxExtentsY * c + boxExtentsZ * b) {
50237
+ if (f0 > extents_y * abs_direction_z + extents_z * abs_direction_y) {
50243
50238
  return false;
50244
50239
  }
50245
50240
 
50246
- const f1 = dirZ * diffX - dirX * diffZ;
50241
+ const abs_direction_x = fabsf(direction_x);
50247
50242
 
50248
- if (fabsf(f1) > boxExtentsX * c + boxExtentsZ * a) {
50249
- return false;
50250
- }
50251
-
50252
- const f2 = dirX * diffY - dirY * diffX;
50243
+ const f1 = fabsf(direction_z * diff_x - direction_x * diff_z);
50253
50244
 
50254
- if (fabsf(f2) > boxExtentsX * b + boxExtentsY * a) {
50245
+ if (f1 > extents_x * abs_direction_z + extents_z * abs_direction_x) {
50255
50246
  return false;
50256
50247
  }
50257
50248
 
50258
- return true;
50249
+ const f2 = fabsf(direction_x * diff_y - direction_y * diff_x);
50250
+
50251
+ return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
50259
50252
  }
50260
50253
 
50261
50254
  /**
@@ -50294,7 +50287,7 @@ function aabb3_intersects_frustum_array(x0, y0, z0, x1, y1, z1, frustum) {
50294
50287
  const plane_z = frustum[i + 2];
50295
50288
  const plane_w = frustum[i + 3];
50296
50289
 
50297
- const plane_distance = aabb3_computeDistanceAbovePlane_max(
50290
+ const plane_distance = aabb3_compute_distance_above_plane_max(
50298
50291
  plane_x, plane_y, plane_z, plane_w,
50299
50292
  x0, y0, z0,
50300
50293
  x1, y1, z1
@@ -50383,6 +50376,25 @@ function aabb3_signed_distance_sqr_to_point(x0, y0, z0, x1, y1, z1, point_x, poi
50383
50376
  }
50384
50377
  }
50385
50378
 
50379
+ //
50380
+
50381
+ /**
50382
+ *
50383
+ * @param {ArrayLike<number>|number[]|AABB3} aabb
50384
+ * @param {number} x
50385
+ * @param {number} y
50386
+ * @param {number} z
50387
+ * @return {boolean}
50388
+ */
50389
+ function aabb3_array_contains_point(aabb, x, y, z) {
50390
+ return x >= aabb[0]
50391
+ && x <= aabb[3]
50392
+ && y >= aabb[1]
50393
+ && y <= aabb[4]
50394
+ && z >= aabb[2]
50395
+ && z <= aabb[5];
50396
+ }
50397
+
50386
50398
  /**
50387
50399
  * Created by Alex on 16/11/2014.
50388
50400
  */
@@ -50474,19 +50486,14 @@ class AABB3 {
50474
50486
  }
50475
50487
 
50476
50488
  /**
50477
- *
50489
+ * @deprecated use {@link aabb3_array_contains_point} directly
50478
50490
  * @param {number} x
50479
50491
  * @param {number} y
50480
50492
  * @param {number} z
50481
50493
  * @returns {boolean}
50482
50494
  */
50483
50495
  containsPoint(x, y, z) {
50484
- return x >= this.x0
50485
- && x <= this.x1
50486
- && y >= this.y0
50487
- && y <= this.y1
50488
- && z >= this.z0
50489
- && z <= this.z1;
50496
+ return aabb3_array_contains_point(this, x, y, z);
50490
50497
  }
50491
50498
 
50492
50499
  /**
@@ -50498,15 +50505,9 @@ class AABB3 {
50498
50505
  * @returns {boolean}
50499
50506
  */
50500
50507
  containsPointWithTolerance(x, y, z, tolerance) {
50501
- if (
50502
- (x + tolerance) < this.x0 || (x - tolerance) > this.x1
50508
+ return !((x + tolerance) < this.x0 || (x - tolerance) > this.x1
50503
50509
  || (y + tolerance) < this.y0 || (y - tolerance) > this.y1
50504
- || (z + tolerance) < this.z0 || (z - tolerance) > this.z1
50505
- ) {
50506
- return false;
50507
- }
50508
-
50509
- return true;
50510
+ || (z + tolerance) < this.z0 || (z - tolerance) > this.z1);
50510
50511
  }
50511
50512
 
50512
50513
  computeMortonCode() {
@@ -50558,6 +50559,13 @@ class AABB3 {
50558
50559
  * @param {Number} z1
50559
50560
  */
50560
50561
  setBounds(x0, y0, z0, x1, y1, z1) {
50562
+ assert.notNaN(x0, 'x0');
50563
+ assert.notNaN(y0, 'y0');
50564
+ assert.notNaN(z0, 'z0');
50565
+ assert.notNaN(x1, 'x1');
50566
+ assert.notNaN(y1, 'y1');
50567
+ assert.notNaN(z1, 'z1');
50568
+
50561
50569
  /**
50562
50570
  *
50563
50571
  * @type {number}
@@ -51084,13 +51092,15 @@ class AABB3 {
51084
51092
  readFromArray(source, offset = 0) {
51085
51093
  assert.isNonNegativeInteger(offset, 'offset');
51086
51094
 
51087
- this.x0 = source[offset];
51088
- this.y0 = source[offset + 1];
51089
- this.z0 = source[offset + 2];
51095
+ const _x0 = source[offset];
51096
+ const _y0 = source[offset + 1];
51097
+ const _z0 = source[offset + 2];
51098
+
51099
+ const _x1 = source[offset + 3];
51100
+ const _y1 = source[offset + 4];
51101
+ const _z1 = source[offset + 5];
51090
51102
 
51091
- this.x1 = source[offset + 3];
51092
- this.y1 = source[offset + 4];
51093
- this.z1 = source[offset + 5];
51103
+ this.setBounds(_x0, _y0, _z0, _x1, _y1, _z1);
51094
51104
  }
51095
51105
 
51096
51106
  /**
@@ -51100,7 +51110,7 @@ class AABB3 {
51100
51110
  computePlaneSide(plane) {
51101
51111
  const normal = plane.normal;
51102
51112
 
51103
- return computeAABB3PlaneSide(
51113
+ return aabb3_compute_plane_side(
51104
51114
  normal.x, normal.y, normal.z, plane.constant,
51105
51115
  this.x0, this.y0, this.z0,
51106
51116
  this.x1, this.y1, this.z1
@@ -51116,7 +51126,7 @@ class AABB3 {
51116
51126
  * @returns {number}
51117
51127
  */
51118
51128
  computeDistanceAbovePlane(normal_x, normal_y, normal_z, offset) {
51119
- return aabb3_computeDistanceAbovePlane_max(
51129
+ return aabb3_compute_distance_above_plane_max(
51120
51130
  normal_x, normal_y, normal_z, offset,
51121
51131
  this.x0, this.y0, this.z0,
51122
51132
  this.x1, this.y1, this.z1
@@ -51601,7 +51611,7 @@ class BVHVisitor {
51601
51611
  }
51602
51612
  }
51603
51613
 
51604
- const stack$7 = [];
51614
+ const stack$a = [];
51605
51615
  let stackPointer$3 = 0;
51606
51616
 
51607
51617
  /**
@@ -51614,11 +51624,11 @@ function traverseBinaryNodeUsingVisitor(node, visitor) {
51614
51624
 
51615
51625
  const stackOffset = stackPointer$3;
51616
51626
 
51617
- stack$7[stackPointer$3++] = node;
51627
+ stack$a[stackPointer$3++] = node;
51618
51628
 
51619
51629
  while (stackPointer$3-- > stackOffset) {
51620
51630
 
51621
- n = stack$7[stackPointer$3];
51631
+ n = stack$a[stackPointer$3];
51622
51632
 
51623
51633
  if (n.isBinaryNode) {
51624
51634
  const traverseDeeper = visitor.visitBinary(n);
@@ -51629,7 +51639,7 @@ function traverseBinaryNodeUsingVisitor(node, visitor) {
51629
51639
 
51630
51640
  // has a LEFT child
51631
51641
 
51632
- stack$7[stackPointer$3++] = n.left;
51642
+ stack$a[stackPointer$3++] = n.left;
51633
51643
 
51634
51644
  }
51635
51645
 
@@ -51637,7 +51647,7 @@ function traverseBinaryNodeUsingVisitor(node, visitor) {
51637
51647
 
51638
51648
  // has a RIGHT child
51639
51649
 
51640
- stack$7[stackPointer$3++] = n.right;
51650
+ stack$a[stackPointer$3++] = n.right;
51641
51651
 
51642
51652
  }
51643
51653
 
@@ -51686,7 +51696,7 @@ function intersects1D(a0, a1, b0, b1) {
51686
51696
  * @param {number} bz1
51687
51697
  * @returns {boolean}
51688
51698
  */
51689
- function aabb3_intersect_aabb3(
51699
+ function aabb3_intersects_aabb3(
51690
51700
  ax0, ay0, az0,
51691
51701
  ax1, ay1, az1,
51692
51702
  bx0, by0, bz0,
@@ -51762,7 +51772,7 @@ let stackPointer$2 = 0;
51762
51772
  *
51763
51773
  * @type {Node[]}
51764
51774
  */
51765
- const stack$6 = [];
51775
+ const stack$9 = [];
51766
51776
 
51767
51777
  class BinaryNode extends Node {
51768
51778
  constructor() {
@@ -51812,22 +51822,22 @@ class BinaryNode extends Node {
51812
51822
 
51813
51823
  const stackOffset = stackPointer$2;
51814
51824
 
51815
- stack$6[stackPointer$2++] = this;
51825
+ stack$9[stackPointer$2++] = this;
51816
51826
  let n;
51817
51827
  while (stackPointer$2-- > stackOffset) {
51818
51828
 
51819
51829
  visitCount++;
51820
51830
 
51821
- n = stack$6[stackPointer$2];
51831
+ n = stack$9[stackPointer$2];
51822
51832
 
51823
51833
  const traverseDeeper = visitor.call(thisArg, n);
51824
51834
 
51825
51835
  if (traverseDeeper !== false && n.isBinaryNode) {
51826
51836
  if (n.right !== null) {
51827
- stack$6[stackPointer$2++] = n.right;
51837
+ stack$9[stackPointer$2++] = n.right;
51828
51838
  }
51829
51839
  if (n.left !== null) {
51830
- stack$6[stackPointer$2++] = n.left;
51840
+ stack$9[stackPointer$2++] = n.left;
51831
51841
  }
51832
51842
  }
51833
51843
  }
@@ -51848,7 +51858,7 @@ class BinaryNode extends Node {
51848
51858
 
51849
51859
  const stackOffset = stackPointer$2;
51850
51860
 
51851
- stack$6[stackPointer$2++] = this;
51861
+ stack$9[stackPointer$2++] = this;
51852
51862
 
51853
51863
  let n;
51854
51864
 
@@ -51856,17 +51866,17 @@ class BinaryNode extends Node {
51856
51866
 
51857
51867
  visitCount++;
51858
51868
 
51859
- n = stack$6[stackPointer$2];
51869
+ n = stack$9[stackPointer$2];
51860
51870
 
51861
51871
  if (n.isLeafNode) {
51862
51872
  visitor.call(thisArg, n);
51863
51873
  } else {
51864
51874
  //a binary node
51865
51875
  if (n.right !== null) {
51866
- stack$6[stackPointer$2++] = n.right;
51876
+ stack$9[stackPointer$2++] = n.right;
51867
51877
  }
51868
51878
  if (n.left !== null) {
51869
- stack$6[stackPointer$2++] = n.left;
51879
+ stack$9[stackPointer$2++] = n.left;
51870
51880
  }
51871
51881
  }
51872
51882
  }
@@ -52122,13 +52132,15 @@ class BinaryNode extends Node {
52122
52132
  const a = this.left;
52123
52133
  const b = this.right;
52124
52134
 
52125
- this.x0 = min2(a.x0, b.x0);
52126
- this.y0 = min2(a.y0, b.y0);
52127
- this.z0 = min2(a.z0, b.z0);
52135
+ const x0 = min2(a.x0, b.x0);
52136
+ const y0 = min2(a.y0, b.y0);
52137
+ const z0 = min2(a.z0, b.z0);
52138
+
52139
+ const x1 = max2(a.x1, b.x1);
52140
+ const y1 = max2(a.y1, b.y1);
52141
+ const z1 = max2(a.z1, b.z1);
52128
52142
 
52129
- this.x1 = max2(a.x1, b.x1);
52130
- this.y1 = max2(a.y1, b.y1);
52131
- this.z1 = max2(a.z1, b.z1);
52143
+ this.setBounds(x0, y0, z0, x1, y1, z1);
52132
52144
  }
52133
52145
 
52134
52146
  bubbleRefit() {
@@ -52443,15 +52455,15 @@ class BinaryNode extends Node {
52443
52455
  requestLeafIntersectionsAABB3(result, x0, y0, z0, x1, y1, z1) {
52444
52456
  const startOffset = stackPointer$2;
52445
52457
 
52446
- stack$6[stackPointer$2++] = this;
52458
+ stack$9[stackPointer$2++] = this;
52447
52459
 
52448
52460
  let count = 0;
52449
52461
 
52450
52462
  while (stackPointer$2 > startOffset) {
52451
52463
  stackPointer$2--;
52452
- const node = stack$6[stackPointer$2];
52464
+ const node = stack$9[stackPointer$2];
52453
52465
 
52454
- if (!aabb3_intersect_aabb3(
52466
+ if (!aabb3_intersects_aabb3(
52455
52467
  x0, y0, z0, x1, y1, z1,
52456
52468
  node.x0, node.y0, node.z0, node.x1, node.y1, node.z1
52457
52469
  )) {
@@ -52466,12 +52478,12 @@ class BinaryNode extends Node {
52466
52478
  } else {
52467
52479
  const left = node.left;
52468
52480
  if (left !== null) {
52469
- stack$6[stackPointer$2++] = left;
52481
+ stack$9[stackPointer$2++] = left;
52470
52482
  }
52471
52483
 
52472
52484
  const right = node.right;
52473
52485
  if (right !== null) {
52474
- stack$6[stackPointer$2++] = right;
52486
+ stack$9[stackPointer$2++] = right;
52475
52487
  }
52476
52488
  }
52477
52489
  }
@@ -55938,14 +55950,14 @@ class IndexedBinaryBVH {
55938
55950
 
55939
55951
  const stackOffset = stackPointer$1;
55940
55952
 
55941
- stack$5[stackPointer$1++] = startIndex;
55953
+ stack$8[stackPointer$1++] = startIndex;
55942
55954
 
55943
55955
  const nodeThreshold = this.binaryNodeCount * 6;
55944
55956
  const endAddress = this.boxCount * 6;
55945
55957
 
55946
55958
  while (stackPointer$1-- > stackOffset) {
55947
55959
 
55948
- const index = stack$5[stackPointer$1];
55960
+ const index = stack$8[stackPointer$1];
55949
55961
 
55950
55962
  const address = index * 6;
55951
55963
 
@@ -55961,7 +55973,7 @@ class IndexedBinaryBVH {
55961
55973
  //right
55962
55974
  if (rightAddress < endAddress) {
55963
55975
  if (rightAddress < nodeThreshold) {
55964
- stack$5[stackPointer$1++] = rightIndex;
55976
+ stack$8[stackPointer$1++] = rightIndex;
55965
55977
  } else {
55966
55978
  visitor.visit(rightAddress, NodeType.LEAF);
55967
55979
  }
@@ -55970,7 +55982,7 @@ class IndexedBinaryBVH {
55970
55982
  //left
55971
55983
  if (leftAddress < endAddress) {
55972
55984
  if (leftAddress < nodeThreshold) {
55973
- stack$5[stackPointer$1++] = leftIndex;
55985
+ stack$8[stackPointer$1++] = leftIndex;
55974
55986
  } else {
55975
55987
  visitor.visit(leftAddress, NodeType.LEAF);
55976
55988
  }
@@ -56146,7 +56158,7 @@ function binaryNodeRefit(array, binaryNode, childNode0, childNode1) {
56146
56158
  }
56147
56159
 
56148
56160
 
56149
- const stack$5 = [];
56161
+ const stack$8 = [];
56150
56162
  let stackPointer$1 = 0;
56151
56163
 
56152
56164
  const rayLeafIntersectionVisitor = new RayLeafIntersectionVisitor();
@@ -56156,7 +56168,16 @@ const rayLeafIntersectionVisitor = new RayLeafIntersectionVisitor();
56156
56168
  */
56157
56169
  class SurfacePoint3 {
56158
56170
  constructor() {
56171
+ /**
56172
+ * @readonly
56173
+ * @type {Vector3}
56174
+ */
56159
56175
  this.normal = new Vector3$1(0, 1, 0);
56176
+
56177
+ /**
56178
+ * @readonly
56179
+ * @type {Vector3}
56180
+ */
56160
56181
  this.position = new Vector3$1(0, 0, 0);
56161
56182
 
56162
56183
  /**
@@ -56167,6 +56188,30 @@ class SurfacePoint3 {
56167
56188
  this.index = -1;
56168
56189
  }
56169
56190
 
56191
+ get 0() {
56192
+ return this.position.x;
56193
+ }
56194
+
56195
+ get 1() {
56196
+ return this.position.y;
56197
+ }
56198
+
56199
+ get 2() {
56200
+ return this.position.z;
56201
+ }
56202
+
56203
+ get 3() {
56204
+ return this.normal.x;
56205
+ }
56206
+
56207
+ get 4() {
56208
+ return this.normal.y;
56209
+ }
56210
+
56211
+ get 5() {
56212
+ return this.normal.z;
56213
+ }
56214
+
56170
56215
  /**
56171
56216
  *
56172
56217
  * @param {number[]|mat4|Float32Array} m
@@ -56216,13 +56261,35 @@ class SurfacePoint3 {
56216
56261
  }
56217
56262
 
56218
56263
  /**
56219
- *
56264
+ * @deprecated use {@link applyMatrix4} instead
56220
56265
  * @param {THREE.Matrix4} matrix4
56221
56266
  */
56222
56267
  applyMatrix4_three(matrix4) {
56268
+ console.warn('applyMatrix4_three is deprecated, use applyMatrix4 instead');
56269
+
56223
56270
  this.applyMatrix4(matrix4.elements);
56224
56271
  }
56225
56272
 
56273
+ /**
56274
+ *
56275
+ * @param {number[]|ArrayLike<number>|Float32Array} array
56276
+ * @param {number} [offset=0]
56277
+ */
56278
+ fromArray(array, offset = 0) {
56279
+ this.position.readFromArray(array, offset);
56280
+ this.normal.readFromArray(array, offset + 3);
56281
+ }
56282
+
56283
+ /**
56284
+ *
56285
+ * @param {number[]|ArrayLike<number>|Float32Array} array
56286
+ * @param {number} [offset=0]
56287
+ */
56288
+ toArray(array, offset = 0) {
56289
+ this.position.writeToArray(array, offset);
56290
+ this.normal.writeToArray(array, offset + 3);
56291
+ }
56292
+
56226
56293
  /**
56227
56294
  *
56228
56295
  * @param {SurfacePoint3} other
@@ -57839,16 +57906,24 @@ function hex2dec(v) {
57839
57906
  /**
57840
57907
  *
57841
57908
  * @param {string} hex
57842
- * @returns {{r: Number, g: Number, b: Number}} rgb
57909
+ * @returns {{r: number, g: number, b: number, a:number}} rgb
57843
57910
  */
57844
57911
  function parseHex(hex) {
57845
57912
 
57846
57913
 
57847
- return {
57914
+ const result = {
57848
57915
  r: hex2dec(hex.slice(1, 3)),
57849
57916
  g: hex2dec(hex.slice(3, 5)),
57850
- b: hex2dec(hex.slice(5))
57917
+ b: hex2dec(hex.slice(5, 7))
57851
57918
  };
57919
+
57920
+ if (hex.length > 7) {
57921
+ result.a = hex2dec(hex.slice(7, 9));
57922
+ }else {
57923
+ result.a = 1;
57924
+ }
57925
+
57926
+ return result;
57852
57927
  }
57853
57928
 
57854
57929
  /**
@@ -57857,7 +57932,7 @@ function parseHex(hex) {
57857
57932
 
57858
57933
 
57859
57934
  const rgbRegEx = /rgb\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+)\s*\)/;
57860
- const rgbaRegEx = /rgba\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+),\s*([0-9]+(?:\.[0-9]*)?)\s*\)/;
57935
+ const rgbaRegEx = /rgba\(\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\s*\)/;
57861
57936
  const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
57862
57937
 
57863
57938
  /**
@@ -57886,10 +57961,10 @@ function parseColor(c) {
57886
57961
 
57887
57962
  } else if ((match = cL.match(rgbaRegEx)) !== null) {
57888
57963
 
57889
- r = parseInt(match[1]);
57890
- g = parseInt(match[2]);
57891
- b = parseInt(match[3]);
57892
- a = parseInt(match[4]);
57964
+ r = parseFloat(match[1]);
57965
+ g = parseFloat(match[2]);
57966
+ b = parseFloat(match[3]);
57967
+ a = parseFloat(match[4]);
57893
57968
 
57894
57969
  } else if ((match = cL.match(hsvRegEx)) !== null) {
57895
57970
 
@@ -57910,6 +57985,8 @@ function parseColor(c) {
57910
57985
  r = rgb.r;
57911
57986
  g = rgb.g;
57912
57987
  b = rgb.b;
57988
+ a = rgb.a;
57989
+
57913
57990
 
57914
57991
  } else {
57915
57992
  throw new Error(`Failed to decode color string '${c}' `);
@@ -58114,7 +58191,7 @@ class Color {
58114
58191
 
58115
58192
  /**
58116
58193
  * @readonly
58117
- * @type {Signal<number,number,number,number,number,number>}
58194
+ * @type {Signal<number,number,number,number,number,number,number,number>}
58118
58195
  */
58119
58196
  this.onChanged = new Signal();
58120
58197
  }
@@ -58190,19 +58267,34 @@ class Color {
58190
58267
  * @param {number} b
58191
58268
  */
58192
58269
  setRGB(r, g, b) {
58270
+
58271
+ this.set(r, g, b, this.a);
58272
+ }
58273
+
58274
+ /**
58275
+ *
58276
+ * @param {number} r
58277
+ * @param {number} g
58278
+ * @param {number} b
58279
+ * @param {number} a
58280
+ */
58281
+ set(r, g, b, a) {
58193
58282
  assert.isNumber(r, 'r');
58194
58283
  assert.isNumber(g, 'g');
58195
58284
  assert.isNumber(b, 'b');
58285
+ assert.isNumber(a, 'a');
58196
58286
 
58197
58287
  const _r = this.r;
58198
58288
  const _g = this.g;
58199
58289
  const _b = this.b;
58290
+ const _a = this.a;
58200
58291
 
58201
58292
  this.r = r;
58202
58293
  this.g = g;
58203
58294
  this.b = b;
58295
+ this.a = a;
58204
58296
 
58205
- this.onChanged.send6(r, g, b, _r, _g, _b);
58297
+ this.onChanged.send8(r, g, b, a, _r, _g, _b, _a);
58206
58298
  }
58207
58299
 
58208
58300
  /**
@@ -58466,7 +58558,10 @@ class Color {
58466
58558
  * @param {Color} other
58467
58559
  */
58468
58560
  equals(other) {
58469
- return this.r === other.r && this.g === other.g && this.b === other.b;
58561
+ return this.r === other.r
58562
+ && this.g === other.g
58563
+ && this.b === other.b
58564
+ && this.a === other.a;
58470
58565
  }
58471
58566
 
58472
58567
  /**
@@ -58502,15 +58597,17 @@ class Color {
58502
58597
  );
58503
58598
  }
58504
58599
 
58505
- fromJSON({ r, g, b }) {
58600
+ fromJSON({ r, g, b, a = 1 }) {
58506
58601
  this.setRGB(r, g, b);
58602
+ this.a = a;
58507
58603
  }
58508
58604
 
58509
58605
  toJSON() {
58510
58606
  return {
58511
58607
  r: this.r,
58512
58608
  g: this.g,
58513
- b: this.b
58609
+ b: this.b,
58610
+ a: this.a
58514
58611
  };
58515
58612
  }
58516
58613
 
@@ -58519,6 +58616,7 @@ class Color {
58519
58616
  yield this.r;
58520
58617
  yield this.g;
58521
58618
  yield this.b;
58619
+ yield this.a;
58522
58620
 
58523
58621
  }
58524
58622
 
@@ -58531,6 +58629,7 @@ class Color {
58531
58629
  destination[destination_offset] = this.r;
58532
58630
  destination[destination_offset + 1] = this.g;
58533
58631
  destination[destination_offset + 2] = this.b;
58632
+ destination[destination_offset + 3] = this.a;
58534
58633
  }
58535
58634
 
58536
58635
  /**
@@ -58541,6 +58640,7 @@ class Color {
58541
58640
  buffer.writeFloat32(this.r);
58542
58641
  buffer.writeFloat32(this.g);
58543
58642
  buffer.writeFloat32(this.b);
58643
+ buffer.writeFloat32(this.a);
58544
58644
  }
58545
58645
 
58546
58646
  /**
@@ -58551,8 +58651,10 @@ class Color {
58551
58651
  const r = buffer.readFloat32();
58552
58652
  const g = buffer.readFloat32();
58553
58653
  const b = buffer.readFloat32();
58654
+ const a = buffer.readFloat32();
58554
58655
 
58555
58656
  this.setRGB(r, g, b);
58657
+ this.a = a;
58556
58658
  }
58557
58659
 
58558
58660
  /**
@@ -65392,106 +65494,6 @@ WorkerBuilder.prototype.build = function () {
65392
65494
  return proxy;
65393
65495
  };
65394
65496
 
65395
- /**
65396
- *
65397
- * @param {Sampler2D} sampler
65398
- * @param {number} [channel=0]
65399
- * @returns {undefined|{x: number, index:number, y: number, value: number}}
65400
- */
65401
- function sampler2d_channel_compute_max(sampler, channel=0){
65402
- const itemSize = sampler.itemSize;
65403
-
65404
- assert.isNumber(channel, "channel");
65405
- assert.isNonNegativeInteger(channel , 'channel');
65406
- assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
65407
-
65408
- const data = sampler.data;
65409
-
65410
- const l = data.length;
65411
-
65412
- if (l === 0) {
65413
- //no data
65414
- return undefined;
65415
- }
65416
-
65417
- let bestValue = data[channel];
65418
- let bestIndex = channel;
65419
-
65420
- for (let i = channel + itemSize; i < l; i += itemSize) {
65421
- const value = data[i];
65422
-
65423
- if (bestValue < value) {
65424
- bestValue = value;
65425
- bestIndex = i;
65426
- }
65427
-
65428
- }
65429
-
65430
- const width = this.width;
65431
-
65432
- const itemIndex = (bestIndex / itemSize) | 0;
65433
-
65434
- const x = itemIndex % width;
65435
- const y = (itemIndex / width) | 0;
65436
-
65437
- return {
65438
- index: bestIndex,
65439
- value: bestValue,
65440
- x,
65441
- y
65442
- };
65443
- }
65444
-
65445
- /**
65446
- *
65447
- * @param {Sampler2D} sampler
65448
- * @param {number} [channel=0]
65449
- * @returns {undefined|{x: number, index:number, y: number, value: number}}
65450
- */
65451
- function sampler2d_channel_compute_min(sampler, channel=0){
65452
- const itemSize = sampler.itemSize;
65453
-
65454
- assert.isNumber(channel, "channel");
65455
- assert.isNonNegativeInteger(channel , 'channel');
65456
- assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
65457
-
65458
- const data = sampler.data;
65459
-
65460
- const l = data.length;
65461
-
65462
- if (l === 0) {
65463
- //no data
65464
- return undefined;
65465
- }
65466
-
65467
- let bestValue = data[channel];
65468
- let bestIndex = channel;
65469
-
65470
- for (let i = channel + itemSize; i < l; i += itemSize) {
65471
- const value = data[i];
65472
-
65473
- if (bestValue > value) {
65474
- bestValue = value;
65475
- bestIndex = i;
65476
- }
65477
-
65478
- }
65479
-
65480
- const width = this.width;
65481
-
65482
- const itemIndex = (bestIndex / itemSize) | 0;
65483
-
65484
- const x = itemIndex % width;
65485
- const y = (itemIndex / width) | 0;
65486
-
65487
- return {
65488
- index: bestIndex,
65489
- value: bestValue,
65490
- x,
65491
- y
65492
- };
65493
- }
65494
-
65495
65497
  /**
65496
65498
  *
65497
65499
  * @return {WorkerProxy}
@@ -65519,8 +65521,8 @@ function makeTerrainWorkerProxy() {
65519
65521
 
65520
65522
  useSampler(function (sampler) {
65521
65523
 
65522
- const min = sampler2d_channel_compute_min(sampler);
65523
- const max = sampler2d_channel_compute_max(sampler);
65524
+ const min = Lib.sampler2d_channel_compute_min(sampler);
65525
+ const max = Lib.sampler2d_channel_compute_max(sampler);
65524
65526
 
65525
65527
  resolve({
65526
65528
  min: min.value,
@@ -69435,7 +69437,7 @@ class ClippingPlaneContainmentComputingVisitor extends GeometrySpatialAccelerato
69435
69437
  const plane_normal_z = plane.normal.z;
69436
69438
  const plane_constant = plane.constant;
69437
69439
 
69438
- const side = computeAABB3PlaneSide(
69440
+ const side = aabb3_compute_plane_side(
69439
69441
  plane_normal_x,
69440
69442
  plane_normal_y,
69441
69443
  plane_normal_z,
@@ -72144,7 +72146,7 @@ class Asset {
72144
72146
 
72145
72147
  /**
72146
72148
  *
72147
- * @type {Array.<AssetDescription>}
72149
+ * @type {Array<AssetDescription>}
72148
72150
  */
72149
72151
  this.dependencies = [];
72150
72152
 
@@ -78034,7 +78036,7 @@ class InstancedMeshGroup {
78034
78036
  * @param {number[]|ArrayLike<number>|Float32Array} transform 4x4 transform matrix of the instance
78035
78037
  */
78036
78038
  setTransformAt(index, transform) {
78037
- this.__attributeTransformArray.set(transform, index * 16);
78039
+ array_copy(transform,0,this.__attributeTransformArray,index*16,16);
78038
78040
  }
78039
78041
 
78040
78042
  /**
@@ -78043,7 +78045,7 @@ class InstancedMeshGroup {
78043
78045
  * @param {number[]|ArrayLike<number>|Float32Array} color RGBA color in uint8 format (0...255), LDR
78044
78046
  */
78045
78047
  setColorAt(index, color) {
78046
- this.__attributeColorArray.set(color, index * 4);
78048
+ array_copy(color,0,this.__attributeColorArray,index*4,4);
78047
78049
  }
78048
78050
 
78049
78051
  /**
@@ -79656,8 +79658,8 @@ class ExplicitBinaryBoundingVolumeHierarchy {
79656
79658
 
79657
79659
  /**
79658
79660
  *
79659
- * @param {number[]} aabb
79660
- * @param {number[]} frustum
79661
+ * @param {number[]|Float32Array} aabb
79662
+ * @param {number[]|Float32Array} frustum
79661
79663
  * @returns {number}
79662
79664
  */
79663
79665
  function aabb3_array_intersects_frustum_degree(aabb, frustum) {
@@ -79672,9 +79674,24 @@ function aabb3_array_intersects_frustum_degree(aabb, frustum) {
79672
79674
  return aabb3_intersects_frustum_degree(x0, y0, z0, x1, y1, z1, frustum);
79673
79675
  }
79674
79676
 
79677
+ /**
79678
+ * Useful for traversals, such as tree-walking. When using - make sure you manage dependencies nad understand the call-graph to avoid overwriting data that is used else-where
79679
+ * Using a pre-allocated continuous chunk of memory gets us better cache coherence
79680
+ * @readonly
79681
+ * @type {Uint32Array|{pointer:number}}
79682
+ */
79683
+ const SCRATCH_UINT32_TRAVERSAL_STACK = new Uint32Array(781250);
79684
+
79685
+ /**
79686
+ * Pointer used to track current top of the stack, make sure to unwind once your traversal is done
79687
+ * @type {number}
79688
+ */
79689
+ SCRATCH_UINT32_TRAVERSAL_STACK.pointer = 0;
79690
+
79675
79691
  //
79676
79692
 
79677
- const traversal_stack$2 = [];
79693
+ const stack$7 = SCRATCH_UINT32_TRAVERSAL_STACK;
79694
+
79678
79695
  /**
79679
79696
  *
79680
79697
  * @param {number[]} destination
@@ -79692,20 +79709,20 @@ function bvh_collect_user_data(destination, destination_offset, bvh, node) {
79692
79709
  *
79693
79710
  * @type {number}
79694
79711
  */
79695
- let traversal_cursor = 0;
79712
+ const stack_top = stack$7.pointer++;
79696
79713
 
79697
- traversal_stack$2[traversal_cursor++] = node;
79714
+ stack$7[stack_top] = node;
79698
79715
 
79699
79716
  let result_cursor = destination_offset;
79700
79717
 
79701
- while (traversal_cursor > 0) {
79702
- traversal_cursor--;
79718
+ while (stack$7.pointer > stack_top) {
79719
+ stack$7.pointer--;
79703
79720
 
79704
79721
  /**
79705
79722
  *
79706
79723
  * @type {number}
79707
79724
  */
79708
- const node = traversal_stack$2[traversal_cursor];
79725
+ const node = stack$7[stack$7.pointer];
79709
79726
 
79710
79727
  const node_is_leaf = bvh.node_is_leaf(node);
79711
79728
 
@@ -79716,8 +79733,8 @@ function bvh_collect_user_data(destination, destination_offset, bvh, node) {
79716
79733
  const child2 = bvh.node_get_child2(node);
79717
79734
 
79718
79735
  // write to stack in reverse order, so that fist child ends up being visited first
79719
- traversal_stack$2[traversal_cursor++] = child1;
79720
- traversal_stack$2[traversal_cursor++] = child2;
79736
+ stack$7[stack$7.pointer++] = child1;
79737
+ stack$7[stack$7.pointer++] = child2;
79721
79738
 
79722
79739
  } else {
79723
79740
  // leaf node
@@ -79733,9 +79750,9 @@ function bvh_collect_user_data(destination, destination_offset, bvh, node) {
79733
79750
 
79734
79751
  //
79735
79752
 
79736
- const traversal_stack$1 = [];
79753
+ const stack$6 = SCRATCH_UINT32_TRAVERSAL_STACK;
79737
79754
 
79738
- const scratch_aabb$1 = [];
79755
+ const scratch_aabb$1 = new Float32Array(6);
79739
79756
 
79740
79757
  /**
79741
79758
  *
@@ -79760,20 +79777,20 @@ function bvh_query_user_data_overlaps_frustum(
79760
79777
  *
79761
79778
  * @type {number}
79762
79779
  */
79763
- let traversal_cursor = 1;
79780
+ const stack_top = stack$6.pointer++;
79764
79781
 
79765
- traversal_stack$1[0] = root;
79782
+ stack$6[stack_top] = root;
79766
79783
 
79767
79784
  let result_cursor = result_offset;
79768
79785
 
79769
- while (traversal_cursor > 0) {
79770
- traversal_cursor--;
79786
+ while (stack$6.pointer > stack_top) {
79787
+ stack$6.pointer--;
79771
79788
 
79772
79789
  /**
79773
79790
  *
79774
79791
  * @type {number}
79775
79792
  */
79776
- const node = traversal_stack$1[traversal_cursor];
79793
+ const node = stack$6[stack$6.pointer];
79777
79794
 
79778
79795
  // test node against the ray
79779
79796
  bvh.node_get_aabb(node, scratch_aabb$1);
@@ -79786,26 +79803,22 @@ function bvh_query_user_data_overlaps_frustum(
79786
79803
 
79787
79804
  const node_is_leaf = bvh.node_is_leaf(node);
79788
79805
 
79789
- if (!node_is_leaf) {
79790
-
79791
- if (intersection === 2) {
79792
- // fully inside, fast collection path
79793
- result_cursor += bvh_collect_user_data(result, result_cursor, bvh, node);
79794
- } else {
79795
- // partially inside
79796
- // read in-order
79797
- const child1 = bvh.node_get_child1(node);
79798
- const child2 = bvh.node_get_child2(node);
79799
-
79800
- // write to stack in reverse order, so that fist child ends up being visited first
79801
- traversal_stack$1[traversal_cursor++] = child1;
79802
- traversal_stack$1[traversal_cursor++] = child2;
79803
- }
79806
+ if (node_is_leaf) {
79807
+ // leaf node
79808
+ result[result_cursor++] = bvh.node_get_user_data(node);
79804
79809
 
79810
+ } else if (intersection === 2) {
79811
+ // fully inside, fast collection path
79812
+ result_cursor += bvh_collect_user_data(result, result_cursor, bvh, node);
79805
79813
  } else {
79806
- // leaf node
79814
+ // partially inside
79815
+ // read in-order
79816
+ const child1 = bvh.node_get_child1(node);
79817
+ const child2 = bvh.node_get_child2(node);
79807
79818
 
79808
- result[result_cursor++] = bvh.node_get_user_data(node);
79819
+ // write to stack in reverse order, so that fist child ends up being visited first
79820
+ stack$6[stack$6.pointer++] = child1;
79821
+ stack$6[stack$6.pointer++] = child2;
79809
79822
  }
79810
79823
  }
79811
79824
 
@@ -79976,18 +79989,7 @@ class ShadedGeometryRendererContext {
79976
79989
  }
79977
79990
  }
79978
79991
 
79979
- /**
79980
- *
79981
- * @type {number[]}
79982
- */
79983
- const traversal_stack = [];
79984
-
79985
- /**
79986
- *
79987
- * @type {number}
79988
- */
79989
- let traversal_cursor = 0;
79990
-
79992
+ const stack$5 = SCRATCH_UINT32_TRAVERSAL_STACK;
79991
79993
 
79992
79994
  /**
79993
79995
  *
@@ -80001,7 +80003,6 @@ function bvh_query_leaves_generic(
80001
80003
  result, result_offset,
80002
80004
  bvh, query
80003
80005
  ) {
80004
- const stack_frame_address = traversal_cursor;
80005
80006
 
80006
80007
  const root = bvh.root;
80007
80008
 
@@ -80009,18 +80010,24 @@ function bvh_query_leaves_generic(
80009
80010
  return 0;
80010
80011
  }
80011
80012
 
80012
- traversal_stack[traversal_cursor++] = root;
80013
+ /**
80014
+ *
80015
+ * @type {number}
80016
+ */
80017
+ const stack_top = stack$5.pointer++;
80018
+
80019
+ stack$5[stack_top] = root;
80013
80020
 
80014
80021
  let result_cursor = result_offset;
80015
80022
 
80016
- while (traversal_cursor > stack_frame_address) {
80017
- traversal_cursor--;
80023
+ while (stack$5.pointer > stack_top) {
80024
+ stack$5.pointer--;
80018
80025
 
80019
80026
  /**
80020
80027
  *
80021
80028
  * @type {number}
80022
80029
  */
80023
- const node = traversal_stack[traversal_cursor];
80030
+ const node = stack$5[stack$5.pointer];
80024
80031
 
80025
80032
  // test node against the ray
80026
80033
  const pass = query.evaluate(node, bvh);
@@ -80038,8 +80045,8 @@ function bvh_query_leaves_generic(
80038
80045
  const child2 = bvh.node_get_child2(node);
80039
80046
 
80040
80047
  // write to stack in reverse order, so that fist child ends up being visited first
80041
- traversal_stack[traversal_cursor++] = child2;
80042
- traversal_stack[traversal_cursor++] = child1;
80048
+ stack$5[stack$5.pointer++] = child2;
80049
+ stack$5[stack$5.pointer++] = child1;
80043
80050
 
80044
80051
  } else {
80045
80052
  // leaf node
@@ -80048,9 +80055,6 @@ function bvh_query_leaves_generic(
80048
80055
  }
80049
80056
  }
80050
80057
 
80051
- // drop stack frame
80052
- traversal_cursor = stack_frame_address;
80053
-
80054
80058
  return result_cursor - result_offset;
80055
80059
  }
80056
80060
 
@@ -82763,223 +82767,6 @@ function tryResolve(unresolvedTask) {
82763
82767
  return ResolutionType.READY;
82764
82768
  }
82765
82769
 
82766
- /**
82767
- * Created by Alex on 21/03/2016.
82768
- */
82769
-
82770
- /**
82771
- *
82772
- * @param {Number} currentValue
82773
- * @param {Number} upperLimit
82774
- * @param {Number} [lowerLimit=0]
82775
- * @constructor
82776
- */
82777
- const BoundedValue = function (currentValue, upperLimit, lowerLimit) {
82778
- /**
82779
- * @property {Number}
82780
- * @private
82781
- */
82782
- this.__value = currentValue !== undefined ? currentValue : 0;
82783
- /**
82784
- * @property {Number}
82785
- * @private
82786
- */
82787
- this.__limitUpper = upperLimit !== undefined ? upperLimit : 0;
82788
-
82789
- /**
82790
- * @type {Number}
82791
- * @private
82792
- */
82793
- this.__limitLower = lowerLimit !== undefined ? lowerLimit : 0;
82794
-
82795
- this.onChanged = new Signal();
82796
- this.onOverflow = new Signal();
82797
- this.onFilled = new Signal();
82798
-
82799
- this.on = {
82800
- changed: this.onChanged,
82801
- overflow: this.onOverflow
82802
- };
82803
- };
82804
-
82805
- /**
82806
- *
82807
- * @param {Number} v
82808
- */
82809
- BoundedValue.prototype.setUpperLimit = function (v) {
82810
- const oldValue = this.__limitUpper;
82811
- if (v === oldValue) {
82812
- //no change
82813
- return;
82814
- }
82815
- this.__limitUpper = v;
82816
- this.onChanged.send4(this.__value, this.__limitUpper, this.__value, oldValue);
82817
- };
82818
-
82819
-
82820
- /**
82821
- *
82822
- * @returns {Number}
82823
- */
82824
- BoundedValue.prototype.getUpperLimit = function () {
82825
- return this.__limitUpper;
82826
- };
82827
-
82828
- /**
82829
- *
82830
- * @returns {Number}
82831
- */
82832
- BoundedValue.prototype.getLowerLimit = function () {
82833
- return this.__limitLower;
82834
- };
82835
- /**
82836
- *
82837
- * @param {Number} v
82838
- */
82839
- BoundedValue.prototype.setLowerLimit = function (v) {
82840
- const old = this.__limitLower;
82841
-
82842
- if (v === old) {
82843
- //no change
82844
- return;
82845
- }
82846
-
82847
- this.__limitLower = v;
82848
-
82849
- //TODO change signal signature to include lower limit
82850
- this.onChanged.dispatch();
82851
- };
82852
-
82853
- /**
82854
- *
82855
- * @param {Number} v
82856
- */
82857
- BoundedValue.prototype.setValue = function (v) {
82858
- const oldValue = this.__value;
82859
- if (oldValue === v) {
82860
- //no change
82861
- return;
82862
- }
82863
-
82864
- const spill = v - this.__limitUpper;
82865
- this.__value = v;
82866
- //dispatch change
82867
- this.onChanged.send4(this.__value, this.__limitUpper, oldValue, this.__limitUpper);
82868
- if (spill > 0) {
82869
- this.onOverflow.send1(spill);
82870
- }
82871
- if (spill >= 0) {
82872
- this.onFilled.send0();
82873
- }
82874
- };
82875
-
82876
- /**
82877
- *
82878
- * @returns {Number}
82879
- */
82880
- BoundedValue.prototype.getValue = function () {
82881
- return this.__value;
82882
- };
82883
-
82884
-
82885
- /**
82886
- *
82887
- * @returns {number}
82888
- */
82889
- BoundedValue.prototype.getFraction = function () {
82890
- return inverseLerp(this.__limitLower, this.__limitUpper, this.__value);
82891
- };
82892
-
82893
- /**
82894
- *
82895
- */
82896
- BoundedValue.prototype.setValueToLimit = function () {
82897
- this.setValue(this.__limitUpper);
82898
- };
82899
-
82900
- /**
82901
- *
82902
- * @return {boolean}
82903
- */
82904
- BoundedValue.prototype.isValueAtLimit = function () {
82905
- return this.__value === this.__limitUpper;
82906
- };
82907
-
82908
- /**
82909
- *
82910
- * @param {Number} val
82911
- */
82912
- BoundedValue.prototype.addValue = function (val) {
82913
- this.setValue(this.__value + val);
82914
- };
82915
-
82916
- /**
82917
- *
82918
- * @param {BoundedValue} other
82919
- * @returns {BoundedValue}
82920
- */
82921
- BoundedValue.prototype.copy = function (other) {
82922
- this.setUpperLimit(other.getUpperLimit());
82923
- this.setValue(other.getValue());
82924
- return this;
82925
- };
82926
-
82927
- /**
82928
- *
82929
- * @param {BoundedValue} other
82930
- * @returns {boolean}
82931
- */
82932
- BoundedValue.prototype.equals = function (other) {
82933
- return this.__value === other.__value && this.__limitLower === other.__limitLower && this.__limitUpper === other.__limitUpper;
82934
- };
82935
-
82936
- /**
82937
- *
82938
- * @returns {number}
82939
- */
82940
- BoundedValue.prototype.hash = function () {
82941
- const v0 = computeHashFloat(this.__value);
82942
- const v1 = computeHashFloat(this.__limitLower);
82943
- const v2 = computeHashFloat(this.__limitUpper);
82944
-
82945
- const h0 = (v0 << 5) - v0 + v1;
82946
-
82947
- return (h0 << 5) - h0 + v2;
82948
- };
82949
-
82950
- BoundedValue.prototype.toJSON = function () {
82951
- return {
82952
- value: this.__value,
82953
- limit: this.__limitUpper
82954
- };
82955
- };
82956
-
82957
- BoundedValue.prototype.fromJSON = function (json) {
82958
- this.setUpperLimit(json.limit);
82959
- this.setValue(json.value);
82960
- };
82961
-
82962
- /**
82963
- *
82964
- * @param {BinaryBuffer} buffer
82965
- */
82966
- BoundedValue.prototype.toBinaryBuffer = function (buffer) {
82967
- buffer.writeFloat64(this.__value);
82968
- buffer.writeFloat64(this.__limitUpper);
82969
- };
82970
-
82971
- /**
82972
- *
82973
- * @param {BinaryBuffer} buffer
82974
- */
82975
- BoundedValue.prototype.fromBinaryBuffer = function (buffer) {
82976
- const value = buffer.readFloat64();
82977
- const upperLimit = buffer.readFloat64();
82978
-
82979
- this.setUpperLimit(upperLimit);
82980
- this.setValue(value);
82981
- };
82982
-
82983
82770
  class ObservedMap {
82984
82771
  /**
82985
82772
  * @template K,V
@@ -83982,10 +83769,6 @@ class BinaryHeap {
83982
83769
  }
83983
83770
  }
83984
83771
 
83985
- /**
83986
- * Created by Alex on 03/09/2014.
83987
- */
83988
-
83989
83772
  /**
83990
83773
  * @enum {number}
83991
83774
  */
@@ -83995,9 +83778,225 @@ const AssetLoadState = {
83995
83778
  Loading: 2,
83996
83779
  Succeeded: 3,
83997
83780
  Failed: 4
83781
+ };
83782
+
83783
+ /**
83784
+ * Created by Alex on 21/03/2016.
83785
+ */
83786
+
83787
+ /**
83788
+ *
83789
+ * @param {Number} currentValue
83790
+ * @param {Number} upperLimit
83791
+ * @param {Number} [lowerLimit=0]
83792
+ * @constructor
83793
+ */
83794
+ const BoundedValue = function (currentValue, upperLimit, lowerLimit) {
83795
+ /**
83796
+ * @property {Number}
83797
+ * @private
83798
+ */
83799
+ this.__value = currentValue !== undefined ? currentValue : 0;
83800
+ /**
83801
+ * @property {Number}
83802
+ * @private
83803
+ */
83804
+ this.__limitUpper = upperLimit !== undefined ? upperLimit : 0;
83805
+
83806
+ /**
83807
+ * @type {Number}
83808
+ * @private
83809
+ */
83810
+ this.__limitLower = lowerLimit !== undefined ? lowerLimit : 0;
83811
+
83812
+ this.onChanged = new Signal();
83813
+ this.onOverflow = new Signal();
83814
+ this.onFilled = new Signal();
83815
+
83816
+ this.on = {
83817
+ changed: this.onChanged,
83818
+ overflow: this.onOverflow
83819
+ };
83820
+ };
83821
+
83822
+ /**
83823
+ *
83824
+ * @param {Number} v
83825
+ */
83826
+ BoundedValue.prototype.setUpperLimit = function (v) {
83827
+ const oldValue = this.__limitUpper;
83828
+ if (v === oldValue) {
83829
+ //no change
83830
+ return;
83831
+ }
83832
+ this.__limitUpper = v;
83833
+ this.onChanged.send4(this.__value, this.__limitUpper, this.__value, oldValue);
83834
+ };
83835
+
83836
+
83837
+ /**
83838
+ *
83839
+ * @returns {Number}
83840
+ */
83841
+ BoundedValue.prototype.getUpperLimit = function () {
83842
+ return this.__limitUpper;
83843
+ };
83844
+
83845
+ /**
83846
+ *
83847
+ * @returns {Number}
83848
+ */
83849
+ BoundedValue.prototype.getLowerLimit = function () {
83850
+ return this.__limitLower;
83851
+ };
83852
+ /**
83853
+ *
83854
+ * @param {Number} v
83855
+ */
83856
+ BoundedValue.prototype.setLowerLimit = function (v) {
83857
+ const old = this.__limitLower;
83858
+
83859
+ if (v === old) {
83860
+ //no change
83861
+ return;
83862
+ }
83863
+
83864
+ this.__limitLower = v;
83865
+
83866
+ //TODO change signal signature to include lower limit
83867
+ this.onChanged.dispatch();
83998
83868
  };
83999
83869
 
83870
+ /**
83871
+ *
83872
+ * @param {Number} v
83873
+ */
83874
+ BoundedValue.prototype.setValue = function (v) {
83875
+ const oldValue = this.__value;
83876
+ if (oldValue === v) {
83877
+ //no change
83878
+ return;
83879
+ }
84000
83880
 
83881
+ const spill = v - this.__limitUpper;
83882
+ this.__value = v;
83883
+ //dispatch change
83884
+ this.onChanged.send4(this.__value, this.__limitUpper, oldValue, this.__limitUpper);
83885
+ if (spill > 0) {
83886
+ this.onOverflow.send1(spill);
83887
+ }
83888
+ if (spill >= 0) {
83889
+ this.onFilled.send0();
83890
+ }
83891
+ };
83892
+
83893
+ /**
83894
+ *
83895
+ * @returns {Number}
83896
+ */
83897
+ BoundedValue.prototype.getValue = function () {
83898
+ return this.__value;
83899
+ };
83900
+
83901
+
83902
+ /**
83903
+ *
83904
+ * @returns {number}
83905
+ */
83906
+ BoundedValue.prototype.getFraction = function () {
83907
+ return inverseLerp(this.__limitLower, this.__limitUpper, this.__value);
83908
+ };
83909
+
83910
+ /**
83911
+ *
83912
+ */
83913
+ BoundedValue.prototype.setValueToLimit = function () {
83914
+ this.setValue(this.__limitUpper);
83915
+ };
83916
+
83917
+ /**
83918
+ *
83919
+ * @return {boolean}
83920
+ */
83921
+ BoundedValue.prototype.isValueAtLimit = function () {
83922
+ return this.__value === this.__limitUpper;
83923
+ };
83924
+
83925
+ /**
83926
+ *
83927
+ * @param {Number} val
83928
+ */
83929
+ BoundedValue.prototype.addValue = function (val) {
83930
+ this.setValue(this.__value + val);
83931
+ };
83932
+
83933
+ /**
83934
+ *
83935
+ * @param {BoundedValue} other
83936
+ * @returns {BoundedValue}
83937
+ */
83938
+ BoundedValue.prototype.copy = function (other) {
83939
+ this.setUpperLimit(other.getUpperLimit());
83940
+ this.setValue(other.getValue());
83941
+ return this;
83942
+ };
83943
+
83944
+ /**
83945
+ *
83946
+ * @param {BoundedValue} other
83947
+ * @returns {boolean}
83948
+ */
83949
+ BoundedValue.prototype.equals = function (other) {
83950
+ return this.__value === other.__value && this.__limitLower === other.__limitLower && this.__limitUpper === other.__limitUpper;
83951
+ };
83952
+
83953
+ /**
83954
+ *
83955
+ * @returns {number}
83956
+ */
83957
+ BoundedValue.prototype.hash = function () {
83958
+ const v0 = computeHashFloat(this.__value);
83959
+ const v1 = computeHashFloat(this.__limitLower);
83960
+ const v2 = computeHashFloat(this.__limitUpper);
83961
+
83962
+ const h0 = (v0 << 5) - v0 + v1;
83963
+
83964
+ return (h0 << 5) - h0 + v2;
83965
+ };
83966
+
83967
+ BoundedValue.prototype.toJSON = function () {
83968
+ return {
83969
+ value: this.__value,
83970
+ limit: this.__limitUpper
83971
+ };
83972
+ };
83973
+
83974
+ BoundedValue.prototype.fromJSON = function (json) {
83975
+ this.setUpperLimit(json.limit);
83976
+ this.setValue(json.value);
83977
+ };
83978
+
83979
+ /**
83980
+ *
83981
+ * @param {BinaryBuffer} buffer
83982
+ */
83983
+ BoundedValue.prototype.toBinaryBuffer = function (buffer) {
83984
+ buffer.writeFloat64(this.__value);
83985
+ buffer.writeFloat64(this.__limitUpper);
83986
+ };
83987
+
83988
+ /**
83989
+ *
83990
+ * @param {BinaryBuffer} buffer
83991
+ */
83992
+ BoundedValue.prototype.fromBinaryBuffer = function (buffer) {
83993
+ const value = buffer.readFloat64();
83994
+ const upperLimit = buffer.readFloat64();
83995
+
83996
+ this.setUpperLimit(upperLimit);
83997
+ this.setValue(value);
83998
+ };
83999
+
84001
84000
  class PendingAsset {
84002
84001
  /**
84003
84002
  *
@@ -84055,7 +84054,12 @@ class PendingAsset {
84055
84054
 
84056
84055
  return max_priority;
84057
84056
  }
84058
- }
84057
+ }
84058
+
84059
+ /**
84060
+ * Created by Alex on 03/09/2014.
84061
+ */
84062
+
84059
84063
 
84060
84064
  let Response$1 = class Response {
84061
84065
  /**
@@ -84086,141 +84090,144 @@ function get_pending_asset_priority_score(pending_asset) {
84086
84090
  class AssetManager {
84087
84091
  /**
84088
84092
  *
84089
- * @param {Engine} engine
84090
- * @constructor
84093
+ * @type {HashMap<AssetDescription, Asset>}
84094
+ * @private
84091
84095
  */
84092
- constructor(engine) {
84093
- /**
84094
- *
84095
- * @type {HashMap<AssetDescription, Asset>}
84096
- * @private
84097
- */
84098
- this.assets = new HashMap({
84099
- capacity: 1024
84100
- });
84096
+ assets = new HashMap({
84097
+ capacity: 1024
84098
+ });
84101
84099
 
84102
- /**
84103
- *
84104
- * @type {ObservedMap<AssetDescription, PendingAsset>}
84105
- * @private
84106
- */
84107
- this.request_map = new ObservedMap(new HashMap());
84100
+ /**
84101
+ *
84102
+ * @type {ObservedMap<AssetDescription, PendingAsset>}
84103
+ */
84104
+ request_map = new ObservedMap(new HashMap());
84108
84105
 
84109
- /**
84110
- * Waiting queue for assets that haven't yet been scheduled (passed to relevant loader)
84111
- * @type {BinaryHeap<PendingAsset>}
84112
- * @private
84113
- */
84114
- this.__pending_asset_wait_queue = new BinaryHeap(get_pending_asset_priority_score);
84115
- /**
84116
- * Assets currently being processed by loaders
84117
- * @type {Set<PendingAsset>}
84118
- * @private
84119
- */
84120
- this.__pending_asset_active_load_set = new Set();
84106
+ /**
84107
+ * Waiting queue for assets that haven't yet been scheduled (passed to relevant loader)
84108
+ * @type {BinaryHeap<PendingAsset>}
84109
+ * @private
84110
+ */
84111
+ #pending_asset_wait_queue = new BinaryHeap(get_pending_asset_priority_score);
84112
+ /**
84113
+ * Assets currently being processed by #loaders
84114
+ * @type {Set<PendingAsset>}
84115
+ * @private
84116
+ */
84117
+ #pending_asset_active_load_set = new Set();
84121
84118
 
84122
- /**
84123
- * Maximum number of requests that can be handled at the same time
84124
- * Since most of the requests are handled over the network, this can help you control network concurrency,
84125
- * this can be useful to keep some network slots available for high-priority requests such as UI related ones
84126
- * TODO currently nested asset requests are not recognized, so if nesting level exceeds concurrency - it will lead to a deadlock
84127
- * @type {number}
84128
- */
84129
- this.load_concurrency = Infinity;
84119
+ /**
84120
+ * Maximum number of requests that can be handled at the same time
84121
+ * Since most of the requests are handled over the network, this can help you control network concurrency,
84122
+ * this can be useful to keep some network slots available for high-priority requests such as UI related ones
84123
+ * TODO currently nested asset requests are not recognized, so if nesting level exceeds concurrency - it will lead to a deadlock
84124
+ * @type {number}
84125
+ */
84126
+ load_concurrency = Infinity;
84130
84127
 
84131
- /**
84132
- * Registered loaders
84133
- * @private
84134
- * @type {Object<AssetLoader>}
84135
- */
84136
- this.loaders = {};
84128
+ /**
84129
+ * Registered #loaders
84130
+ * @private
84131
+ * @type {Object<AssetLoader>}
84132
+ */
84133
+ #loaders = {};
84137
84134
 
84138
- /**
84139
- * After asset is loaded, a chain of transforms can be applied to it, these are registered here
84140
- * Transformers are executed in the order in which they are added
84141
- * Identified by asset "type" string
84142
- * @type {Object<AssetTransformer[]>}
84143
- * @private
84144
- */
84145
- this.transformers = {};
84135
+ /**
84136
+ * After asset is loaded, a chain of transforms can be applied to it, these are registered here
84137
+ * Transformers are executed in the order in which they are added
84138
+ * Identified by asset "type" string
84139
+ * @type {Object<AssetTransformer[]>}
84140
+ * @private
84141
+ */
84142
+ #transformers = {};
84146
84143
 
84147
- /**
84148
- * Named links to specific assets. Useful to later re-mapping assets and having meaningful names for them
84149
- * @type {Map<string, AssetDescription>}
84150
- * @private
84151
- */
84152
- this.aliases = new Map();
84144
+ /**
84145
+ * Named links to specific assets. Useful to later re-mapping assets and having meaningful names for them
84146
+ * @type {Map<string, AssetDescription>}
84147
+ * @private
84148
+ */
84149
+ #aliases = new Map();
84153
84150
 
84154
- /**
84155
- * This will be added to asset path for actual network resolution
84156
- * @type {string}
84157
- * @private
84158
- */
84159
- this.rootPath = '';
84151
+ /**
84152
+ * This will be added to asset path for actual network resolution
84153
+ * @type {string}
84154
+ * @private
84155
+ */
84156
+ rootPath = '';
84160
84157
 
84161
- /**
84162
- *
84163
- * @type {Engine}
84164
- * @private
84165
- */
84166
- this.__engine = engine;
84158
+ /**
84159
+ *
84160
+ * @type {CrossOriginConfig}
84161
+ */
84162
+ crossOriginConfig = new CrossOriginConfig();
84167
84163
 
84168
- /**
84169
- *
84170
- * @type {CrossOriginConfig}
84171
- */
84172
- this.crossOriginConfig = new CrossOriginConfig();
84164
+ /**
84165
+ *
84166
+ * @type {HashSet<AssetDescription>}
84167
+ * @private
84168
+ */
84169
+ #failures = new HashSet();
84173
84170
 
84174
- /**
84175
- *
84176
- * @type {HashSet<AssetDescription>}
84177
- * @private
84178
- */
84179
- this.failures = new HashSet();
84171
+ /**
84172
+ * Queue of responses that are waiting to be dispatched
84173
+ * @type {Deque<Response>}
84174
+ * @private
84175
+ */
84176
+ #response_queue = new Deque();
84180
84177
 
84181
- /**
84182
- * Queue of responses that are waiting to be dispatched
84183
- * @type {Deque<Response>}
84184
- * @private
84185
- */
84186
- this.__response_queue = new Deque();
84178
+ /**
84179
+ *
84180
+ * @type {Task}
84181
+ * @private
84182
+ */
84183
+ #response_processor = new Task({
84184
+ name: "Asset Manager Response processor",
84185
+ cycleFunction: () => {
84186
+ if (this.#response_queue.isEmpty()) {
84187
+ return TaskSignal.Yield;
84188
+ }
84187
84189
 
84188
- /**
84189
- *
84190
- * @type {Task}
84191
- * @private
84192
- */
84193
- this.__response_processor = new Task({
84194
- name: "Asset Manager Response processor",
84195
- cycleFunction: () => {
84196
- if (this.__response_queue.isEmpty()) {
84197
- return TaskSignal.Yield;
84198
- }
84190
+ const response = this.#response_queue.removeFirst();
84199
84191
 
84200
- const response = this.__response_queue.removeFirst();
84192
+ this.#process_response(response);
84201
84193
 
84202
- this.__process_response(response);
84194
+ return TaskSignal.Continue;
84195
+ }
84196
+ });
84203
84197
 
84204
- return TaskSignal.Continue;
84205
- }
84206
- });
84198
+ /**
84199
+ *
84200
+ * @type {boolean}
84201
+ * @private
84202
+ */
84203
+ #is_running = false;
84204
+
84205
+ /**
84206
+ *
84207
+ * @type {Engine|null}
84208
+ * @private
84209
+ */
84210
+ #engine = null;
84211
+
84212
+ /**
84213
+ *
84214
+ * @param {Engine} engine
84215
+ * @constructor
84216
+ */
84217
+ constructor(engine) {
84218
+
84219
+ this.#engine = engine;
84207
84220
 
84208
- /**
84209
- *
84210
- * @type {boolean}
84211
- * @private
84212
- */
84213
- this.__is_running = false;
84214
84221
  }
84215
84222
 
84216
84223
  startup() {
84217
- if (this.__is_running) {
84224
+ if (this.#is_running) {
84218
84225
  return;
84219
84226
  }
84220
84227
 
84221
- this.__engine.executor.run(this.__response_processor);
84228
+ this.#engine.executor.run(this.#response_processor);
84222
84229
 
84223
- this.__is_running = true;
84230
+ this.#is_running = true;
84224
84231
  }
84225
84232
 
84226
84233
  /**
@@ -84229,18 +84236,18 @@ class AssetManager {
84229
84236
  * @return {Promise<void>}
84230
84237
  */
84231
84238
  async shutdown(immediate = false) {
84232
- if (!this.__is_running) {
84239
+ if (!this.#is_running) {
84233
84240
  return;
84234
84241
  }
84235
84242
 
84236
84243
  if (!immediate) {
84237
84244
  // wait until all responses have been processed
84238
- await Promise.allSettled([Task.promise(this.__response_processor)]);
84245
+ await Promise.allSettled([Task.promise(this.#response_processor)]);
84239
84246
  }
84240
84247
 
84241
- this.__engine.executor.removeTask(this.__response_processor);
84248
+ this.#engine.executor.removeTask(this.#response_processor);
84242
84249
 
84243
- this.__is_running = false;
84250
+ this.#is_running = false;
84244
84251
  }
84245
84252
 
84246
84253
  /**
@@ -84329,6 +84336,8 @@ class AssetManager {
84329
84336
  console.warn(`Another asset under ${assetDescription} already exists and will be replaced`);
84330
84337
  }
84331
84338
 
84339
+ // TODO check for assets in-flight
84340
+
84332
84341
  this.assets.set(assetDescription, asset);
84333
84342
  }
84334
84343
 
@@ -84337,7 +84346,7 @@ class AssetManager {
84337
84346
  * @param {Response} response
84338
84347
  * @private
84339
84348
  */
84340
- __process_response(response) {
84349
+ #process_response(response) {
84341
84350
 
84342
84351
  try {
84343
84352
  response.request.successCallback(response.asset);
@@ -84352,8 +84361,8 @@ class AssetManager {
84352
84361
  * @param {AssetRequest} request
84353
84362
  * @private
84354
84363
  */
84355
- __schedule_response(asset, request) {
84356
- this.__response_queue.add(new Response$1(asset, request));
84364
+ #schedule_response(asset, request) {
84365
+ this.#response_queue.add(new Response$1(asset, request));
84357
84366
  }
84358
84367
 
84359
84368
  /**
@@ -84361,11 +84370,11 @@ class AssetManager {
84361
84370
  * @param {PendingAsset} asset
84362
84371
  * @private
84363
84372
  */
84364
- __schedule_load(asset) {
84365
- if (this.__pending_asset_active_load_set.size < this.load_concurrency) {
84366
- this.__dispatch_pending_asset(asset);
84373
+ #schedule_load(asset) {
84374
+ if (this.#pending_asset_active_load_set.size < this.load_concurrency) {
84375
+ this.#dispatch_pending_asset(asset);
84367
84376
  } else {
84368
- this.__pending_asset_wait_queue.push(asset);
84377
+ this.#pending_asset_wait_queue.push(asset);
84369
84378
  }
84370
84379
  }
84371
84380
 
@@ -84374,17 +84383,17 @@ class AssetManager {
84374
84383
  * @param {PendingAsset} asset
84375
84384
  * @private
84376
84385
  */
84377
- __force_load(asset) {
84386
+ #force_load(asset) {
84378
84387
  // check if the asset is already being loaded
84379
- if (this.__pending_asset_active_load_set.has(asset)) {
84388
+ if (this.#pending_asset_active_load_set.has(asset)) {
84380
84389
  return;
84381
84390
  }
84382
84391
 
84383
84392
  // remove from queue
84384
- this.__pending_asset_wait_queue.delete(asset);
84393
+ this.#pending_asset_wait_queue.delete(asset);
84385
84394
 
84386
84395
  // dispatch
84387
- this.__dispatch_pending_asset(asset);
84396
+ this.#dispatch_pending_asset(asset);
84388
84397
 
84389
84398
  }
84390
84399
 
@@ -84393,21 +84402,21 @@ class AssetManager {
84393
84402
  * @param {PendingAsset} pending_asset
84394
84403
  * @private
84395
84404
  */
84396
- __handle_asset_resolved(pending_asset) {
84405
+ #handle_asset_resolved(pending_asset) {
84397
84406
  // console.log(`Asset resolved ${pending_asset.description}`); // DEBUG
84398
84407
 
84399
- const active_set = this.__pending_asset_active_load_set;
84408
+ const active_set = this.#pending_asset_active_load_set;
84400
84409
 
84401
84410
  this.request_map.delete(pending_asset.description);
84402
84411
  active_set.delete(pending_asset);
84403
84412
 
84404
- const queue = this.__pending_asset_wait_queue;
84413
+ const queue = this.#pending_asset_wait_queue;
84405
84414
 
84406
84415
  // schedule more if possible
84407
84416
  while (!queue.isEmpty() && active_set.size < this.load_concurrency) {
84408
84417
  const load = queue.pop();
84409
84418
 
84410
- this.__dispatch_pending_asset(load);
84419
+ this.#dispatch_pending_asset(load);
84411
84420
  }
84412
84421
  }
84413
84422
 
@@ -84416,7 +84425,7 @@ class AssetManager {
84416
84425
  * @param {PendingAsset} pendingAsset
84417
84426
  * @private
84418
84427
  */
84419
- __dispatch_pending_asset(pendingAsset) {
84428
+ #dispatch_pending_asset(pendingAsset) {
84420
84429
  // console.log(`Asset load dispatched ${pendingAsset.description}`); // DEBUG
84421
84430
 
84422
84431
  const requests = pendingAsset.requests;
@@ -84424,7 +84433,7 @@ class AssetManager {
84424
84433
  const type = assetDescription.type;
84425
84434
  const path = assetDescription.path;
84426
84435
 
84427
- const loader = this.loaders[type];
84436
+ const loader = this.#loaders[type];
84428
84437
 
84429
84438
  if (loader === undefined) {
84430
84439
  let reported_error = false;
@@ -84433,7 +84442,7 @@ class AssetManager {
84433
84442
  const assetRequest = requests[i];
84434
84443
 
84435
84444
  if (typeof assetRequest.failureCallback === "function") {
84436
- assetRequest.failureCallback(`no loader exists for asset type '${type}', valid types are: ${Object.keys(this.loaders).join(', ')}`);
84445
+ assetRequest.failureCallback(`no loader exists for asset type '${type}', valid types are: ${Object.keys(this.#loaders).join(', ')}`);
84437
84446
  } else {
84438
84447
  //uncaught
84439
84448
  if (!reported_error) {
@@ -84443,16 +84452,16 @@ class AssetManager {
84443
84452
  }
84444
84453
  }
84445
84454
 
84446
- this.__handle_asset_resolved(pendingAsset);
84455
+ this.#handle_asset_resolved(pendingAsset);
84447
84456
 
84448
84457
  return;
84449
84458
  }
84450
84459
 
84451
84460
  // mark as being loaded
84452
- this.__pending_asset_active_load_set.add(pendingAsset);
84461
+ this.#pending_asset_active_load_set.add(pendingAsset);
84453
84462
 
84454
84463
  const assets = this.assets;
84455
- const failures = this.failures;
84464
+ const failures = this.#failures;
84456
84465
 
84457
84466
 
84458
84467
  /**
@@ -84476,7 +84485,7 @@ class AssetManager {
84476
84485
  let asset = loaded_asset;
84477
84486
 
84478
84487
  // apply transform chain
84479
- const transformers = this.transformers[type];
84488
+ const transformers = this.#transformers[type];
84480
84489
  if (transformers !== undefined) {
84481
84490
  const transformer_count = transformers.length;
84482
84491
  for (let i = 0; i < transformer_count; i++) {
@@ -84499,13 +84508,13 @@ class AssetManager {
84499
84508
  assets.set(assetDescription, asset);
84500
84509
 
84501
84510
  //clear callbacks etc.
84502
- this.__handle_asset_resolved(pendingAsset);
84511
+ this.#handle_asset_resolved(pendingAsset);
84503
84512
 
84504
84513
 
84505
84514
  // process callbacks
84506
84515
  for (let i = 0; i < requests.length; i++) {
84507
84516
  const request = requests[i];
84508
- this.__schedule_response(asset, request);
84517
+ this.#schedule_response(asset, request);
84509
84518
  }
84510
84519
 
84511
84520
  };
@@ -84533,7 +84542,7 @@ class AssetManager {
84533
84542
  }
84534
84543
 
84535
84544
  //clear callbacks etc.
84536
- this.__handle_asset_resolved(pendingAsset);
84545
+ this.#handle_asset_resolved(pendingAsset);
84537
84546
 
84538
84547
  // record failure
84539
84548
  failures.add(assetDescription);
@@ -84599,15 +84608,15 @@ class AssetManager {
84599
84608
 
84600
84609
  if (shouldSchedule) {
84601
84610
  // not loading yet, lets create a load container and schedule it
84602
- this.__schedule_load(pendingAsset);
84611
+ this.#schedule_load(pendingAsset);
84603
84612
  } else {
84604
84613
  // update priority queue if necessary
84605
- this.__pending_asset_wait_queue.updateElementScore(pendingAsset);
84614
+ this.#pending_asset_wait_queue.updateElementScore(pendingAsset);
84606
84615
  }
84607
84616
 
84608
84617
 
84609
84618
  if (request.getFlag(AssetRequestFlags.SkipQueue)) {
84610
- this.__force_load(pendingAsset);
84619
+ this.#force_load(pendingAsset);
84611
84620
  }
84612
84621
  }
84613
84622
 
@@ -84629,7 +84638,7 @@ class AssetManager {
84629
84638
  getLoaderByType(type) {
84630
84639
  assert.isString(type, 'type');
84631
84640
 
84632
- return this.loaders[type];
84641
+ return this.#loaders[type];
84633
84642
  }
84634
84643
 
84635
84644
  /**
@@ -84638,7 +84647,7 @@ class AssetManager {
84638
84647
  * @return {AssetDescription[]}
84639
84648
  * @private
84640
84649
  */
84641
- __getLoadedAssetDescriptorsByType(type) {
84650
+ #getLoadedAssetDescriptorsByType(type) {
84642
84651
  const loaded_assets = Array.from(this.assets.keys());
84643
84652
  return loaded_assets.filter(t => t.type === type);
84644
84653
  }
@@ -84649,18 +84658,18 @@ class AssetManager {
84649
84658
  * @param {AssetTransformer<T>} transformer
84650
84659
  */
84651
84660
  registerTransformer(type, transformer) {
84652
- let transformers = this.transformers[type];
84661
+ let transformers = this.#transformers[type];
84653
84662
 
84654
84663
  if (transformers === undefined) {
84655
84664
  transformers = [];
84656
84665
 
84657
- this.transformers[type] = transformers;
84666
+ this.#transformers[type] = transformers;
84658
84667
  }
84659
84668
 
84660
84669
  transformers.push(transformer);
84661
84670
 
84662
84671
  // check for loaded assets
84663
- const matching_assets = this.__getLoadedAssetDescriptorsByType(type);
84672
+ const matching_assets = this.#getLoadedAssetDescriptorsByType(type);
84664
84673
 
84665
84674
  if (matching_assets.length > 0) {
84666
84675
  console.warn(`Following assets of matching type '${type}' are already loaded and transform is not applied to them:\n\t${matching_assets.join('\n\t')}`);
@@ -84675,7 +84684,7 @@ class AssetManager {
84675
84684
  */
84676
84685
  unregisterTransformer(type, transformer) {
84677
84686
 
84678
- const transformers = this.transformers[type];
84687
+ const transformers = this.#transformers[type];
84679
84688
 
84680
84689
  if (transformers === undefined) {
84681
84690
  // not found
@@ -84688,7 +84697,7 @@ class AssetManager {
84688
84697
  }
84689
84698
 
84690
84699
  // check for loaded assets
84691
- const matching_assets = this.__getLoadedAssetDescriptorsByType(type);
84700
+ const matching_assets = this.#getLoadedAssetDescriptorsByType(type);
84692
84701
 
84693
84702
  if (matching_assets.length > 0) {
84694
84703
  console.warn(`Following assets of matching type '${type}' are already loaded and transform was probably already applied to them:\n\t${matching_assets.join('\n\t')}`);
@@ -84727,11 +84736,11 @@ class AssetManager {
84727
84736
 
84728
84737
  } else {
84729
84738
 
84730
- await loader.link(this, this.__engine);
84739
+ await loader.link(this, this.#engine);
84731
84740
 
84732
84741
  }
84733
84742
 
84734
- this.loaders[type] = loader;
84743
+ this.#loaders[type] = loader;
84735
84744
 
84736
84745
  return loader;
84737
84746
  }
@@ -84750,7 +84759,7 @@ class AssetManager {
84750
84759
  }
84751
84760
 
84752
84761
  // first remove the loader from registry so no further asset requests can be made
84753
- delete this.loaders[type];
84762
+ delete this.#loaders[type];
84754
84763
 
84755
84764
  // TODO address all pending requests, possibly waiting for all of them to finalize
84756
84765
 
@@ -84786,7 +84795,7 @@ class AssetManager {
84786
84795
  isFailed(path, type) {
84787
84796
  const ad = new AssetDescription(path, type);
84788
84797
 
84789
- return this.failures.has(ad);
84798
+ return this.#failures.has(ad);
84790
84799
  }
84791
84800
 
84792
84801
  /**
@@ -84798,7 +84807,7 @@ class AssetManager {
84798
84807
  assert.typeOf(alias, 'string', 'alias');
84799
84808
 
84800
84809
  // resolve alias
84801
- const assetDescription = this.aliases.get(alias);
84810
+ const assetDescription = this.#aliases.get(alias);
84802
84811
 
84803
84812
  if (assetDescription === undefined) {
84804
84813
  return new Promise.reject(`Alias '${alias}' not found`);
@@ -84816,7 +84825,7 @@ class AssetManager {
84816
84825
 
84817
84826
  // todo consider cloning result to protect against mutation
84818
84827
 
84819
- return this.aliases.get(alias);
84828
+ return this.#aliases.get(alias);
84820
84829
 
84821
84830
  }
84822
84831
 
@@ -84833,7 +84842,7 @@ class AssetManager {
84833
84842
 
84834
84843
  const assetDescription = new AssetDescription(path, type);
84835
84844
 
84836
- this.aliases.set(alias, assetDescription);
84845
+ this.#aliases.set(alias, assetDescription);
84837
84846
  }
84838
84847
  }
84839
84848
 
@@ -86416,18 +86425,31 @@ class IncrementalDeltaSet {
86416
86425
  finalizeUpdate() {
86417
86426
  assert.equal(this.state, IncrementalDeltaSetState.Building, `Expected BUILDING state, instead got '${this.state}'`);
86418
86427
 
86419
- this.size = this.__elements_cursor;
86428
+ const array_main_count = this.__elements_cursor;
86429
+ const array_previous_count = this.__swap_elements_count;
86430
+
86431
+ this.size = array_main_count;
86420
86432
 
86421
86433
  // sort newly populated elements array
86422
- array_shrink_to_size(this.__elements, this.size);
86423
- this.__elements.sort(this.__compare);
86434
+ const array_main = this.__elements;
86435
+ const array_previous = this.__swap_elements;
86436
+
86437
+ const compare = this.__compare;
86438
+
86439
+ const onAdded = this.onAdded;
86440
+ const onRemoved = this.onRemoved;
86441
+
86442
+ array_shrink_to_size(array_main, array_main_count);
86443
+ array_main.sort(compare);
86444
+
86424
86445
 
86425
86446
  let i0 = 0, i1 = 0;
86426
- while (i0 < this.size && i1 < this.__swap_elements_count) {
86427
- const el_0 = this.__elements[i0];
86428
- const el_1 = this.__swap_elements[i1];
86429
86447
 
86430
- const diff = this.__compare(el_0, el_1);
86448
+ while (i0 < array_main_count && i1 < array_previous_count) {
86449
+ const el_0 = array_main[i0];
86450
+ const el_1 = array_previous[i1];
86451
+
86452
+ const diff = compare(el_0, el_1);
86431
86453
 
86432
86454
  if (diff === 0) {
86433
86455
  i0++;
@@ -86436,20 +86458,20 @@ class IncrementalDeltaSet {
86436
86458
  } else if (diff < 0) {
86437
86459
  i0++;
86438
86460
  // addition
86439
- this.onAdded.send1(el_0);
86461
+ onAdded.send1(el_0);
86440
86462
  } else {
86441
86463
  i1++;
86442
86464
  // removal
86443
- this.onRemoved.send1(el_1);
86465
+ onRemoved.send1(el_1);
86444
86466
  }
86445
86467
  }
86446
86468
 
86447
86469
  // process remainders
86448
- for (; i0 < this.size; i0++) {
86449
- this.onAdded.send1(this.__elements[i0]);
86470
+ for (; i0 < array_main_count; i0++) {
86471
+ onAdded.send1(array_main[i0]);
86450
86472
  }
86451
- for (; i1 < this.__swap_elements_count; i1++) {
86452
- this.onRemoved.send1(this.__swap_elements[i1]);
86473
+ for (; i1 < array_previous_count; i1++) {
86474
+ onRemoved.send1(array_previous[i1]);
86453
86475
  }
86454
86476
 
86455
86477
  this.state = IncrementalDeltaSetState.Ready;
@@ -95841,7 +95863,11 @@ GraphicsEngine.prototype.start = function () {
95841
95863
  antialias: true,
95842
95864
  logarithmicDepthBuffer: false,
95843
95865
  canvas,
95844
- context
95866
+ context,
95867
+ /**
95868
+ * @see https://registry.khronos.org/webgl/specs/latest/1.0/#5.2
95869
+ */
95870
+ powerPreference:"high-performance"
95845
95871
  };
95846
95872
 
95847
95873
  const webGLRenderer = this.renderer = new WebGLRenderer(rendererParameters);
@@ -96611,117 +96637,166 @@ function readPositionFromMouseEvent(result, event, source = event.target) {
96611
96637
  result.set(x, y);
96612
96638
  }
96613
96639
 
96614
- /**
96615
- *
96616
- * @param {EventTarget} domElement html element
96617
- * @constructor
96618
- */
96619
- function PointerDevice(domElement) {
96620
- assert.notEqual(domElement, undefined, "domElement is undefined");
96640
+ class PointerDevice {
96621
96641
 
96622
96642
  /**
96623
- * @private
96624
- * @type {boolean}
96643
+ * @readonly
96644
+ * @type {Vector2}
96625
96645
  */
96626
- this.isRunning = false;
96646
+ position = new Vector2();
96627
96647
 
96628
96648
  /**
96629
- *
96630
- * @type {Element}
96631
- * @private
96649
+ * @readonly
96650
+ * @type {Vector2}
96632
96651
  */
96633
- this.__target = null;
96652
+ #anchor_touch_last = new Vector2();
96653
+
96654
+ #globalUp = new Signal();
96655
+
96656
+ #touchStart = new Signal();
96657
+ #touchEnd = new Signal();
96658
+ #touchMove = new Signal();
96659
+
96660
+ /**
96661
+ * @readonly
96662
+ */
96663
+ on = {
96664
+ down: new Signal(),
96665
+ up: new Signal(),
96666
+ move: new Signal(),
96667
+ tap: new Signal(),
96668
+ drag: new Signal(),
96669
+ dragStart: new Signal(),
96670
+ dragEnd: new Signal(),
96671
+ wheel: new Signal(),
96672
+ pinch: new Signal(),
96673
+ pinchStart: new Signal(),
96674
+ pinchEnd: new Signal(),
96675
+ };
96634
96676
 
96635
96677
  /**
96636
96678
  *
96637
- * @type {EventTarget}
96679
+ * @type {Element|null}
96680
+ * @private
96638
96681
  */
96639
- this.domElement = domElement;
96682
+ #target = null;
96640
96683
 
96641
- const position = this.position = new Vector2();
96684
+ /**
96685
+ * @private
96686
+ * @type {boolean}
96687
+ */
96688
+ isRunning = false;
96642
96689
 
96643
96690
  /**
96644
96691
  *
96645
- * @param {MouseEvent} event
96692
+ * @param {EventTarget} domElement html element
96693
+ * @constructor
96646
96694
  */
96647
- this.eventHandlerMouseMove = (event) => {
96648
- event.preventDefault();
96695
+ constructor(domElement) {
96696
+ assert.defined(domElement, "domElement");
96649
96697
 
96650
- this.__target = event.target;
96651
96698
 
96652
- this.readPointerPositionFromEvent(position, event);
96699
+ /**
96700
+ *
96701
+ * @type {EventTarget}
96702
+ */
96703
+ this.domElement = domElement;
96653
96704
 
96654
- this.on.move.send3(position, event, new Vector2(event.movementX, event.movementY));
96655
- };
96656
- this.eventHandlerMouseUp = (event) => {
96657
- this.readPointerPositionFromEvent(position, event);
96658
- this.on.up.send2(position, event);
96659
- };
96660
- this.eventHandlerMouseDown = (event) => {
96661
- this.readPointerPositionFromEvent(position, event);
96662
- this.on.down.send2(position, event);
96663
- };
96664
96705
 
96665
- const touchStart = new Signal();
96666
- const touchEnd = new Signal();
96667
- const touchMove = new Signal();
96706
+ this.#touchStart.add((param0, param1, param2) => {
96707
+ this.on.down.send3(param0, param1, param2);
96708
+ });
96668
96709
 
96669
- touchStart.add((param0, param1, param2) => {
96670
- this.on.down.send3(param0, param1, param2);
96671
- });
96710
+ this.#touchEnd.add((param0, param1, param2) => {
96711
+ this.on.up.send3(param0, param1, param2);
96712
+ });
96713
+ this.#touchMove.add((param0, param1, param2) => {
96714
+ this.on.move.send3(param0, param1, param2);
96715
+ });
96672
96716
 
96673
- touchEnd.add((param0, param1, param2) => {
96674
- this.on.up.send3(param0, param1, param2);
96675
- });
96676
- touchMove.add((param0, param1, param2) => {
96677
- this.on.move.send3(param0, param1, param2);
96678
- });
96679
96717
 
96680
- const anchor_touch_last = new Vector2();
96718
+ //constructed events
96719
+ observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
96720
+ observeDrag(this.#globalUp, this.on.down, this.on.move, this.on.dragStart, this.on.dragEnd, this.on.drag);
96721
+ observePinch({
96722
+ touchStart: this.#touchStart,
96723
+ touchEnd: this.#touchEnd,
96724
+ touchMove: this.#touchMove,
96725
+ pinch: this.on.pinch,
96726
+ pinchStart: this.on.pinchStart,
96727
+ pinchEnd: this.on.pinchEnd,
96728
+ device: this
96729
+ });
96730
+ }
96681
96731
 
96682
- this.eventHandlerTouchStart = function (event) {
96683
- getTouchCenter(event.touches, position);
96684
- touchStart.send2(position, event);
96732
+ /**
96733
+ *
96734
+ * @param {MouseEvent} event
96735
+ */
96736
+ #eventHandlerMouseDown = (event) => {
96737
+ this.readPointerPositionFromEvent(this.position, event);
96738
+ this.on.down.send2(this.position, event);
96739
+ }
96685
96740
 
96686
- anchor_touch_last.copy(position);
96687
- };
96741
+ /**
96742
+ *
96743
+ * @param {TouchEvent} event
96744
+ */
96745
+ #eventHandlerGlobalTouchEnd = (event) => {
96746
+ getTouchCenter(event.touches, this.position);
96747
+ this.#globalUp.send2(this.position, event);
96748
+ }
96688
96749
 
96689
- this.eventHandlerTouchEnd = function (event) {
96690
- getTouchCenter(event.touches, position);
96691
- touchEnd.send2(position, event);
96692
- };
96750
+ /**
96751
+ *
96752
+ * @param {MouseEvent} event
96753
+ */
96754
+ #eventHandlerMouseUp = (event) => {
96755
+ this.readPointerPositionFromEvent(this.position, event);
96756
+ this.on.up.send2(this.position, event);
96757
+ }
96758
+
96759
+ /**
96760
+ *
96761
+ * @param {MouseEvent} event
96762
+ */
96763
+ #eventHandlerGlobalMouseUp = (event) => {
96764
+ this.readPointerPositionFromEvent(this.position, event);
96765
+ this.#globalUp.send2(this.position, event);
96766
+ }
96767
+
96768
+ /**
96769
+ *
96770
+ * @param {TouchEvent} event
96771
+ */
96772
+ #eventHandlerTouchEnd = (event) => {
96773
+ getTouchCenter(event.touches, this.position);
96774
+ this.#touchEnd.send2(this.position, event);
96775
+ }
96693
96776
 
96694
- this.eventHandlerTouchMove = function (event) {
96777
+ /**
96778
+ *
96779
+ * @param {TouchEvent} event
96780
+ */
96781
+ #eventHandlerTouchMove = (event) => {
96695
96782
  event.preventDefault();
96696
96783
 
96697
96784
  getTouchCenter(event.touches, position);
96698
96785
 
96699
96786
  const delta = new Vector2();
96700
96787
 
96701
- delta.subVectors(position, anchor_touch_last);
96702
-
96703
- touchMove.send3(position, event, delta);
96788
+ delta.subVectors(this.position, this.#anchor_touch_last);
96704
96789
 
96705
- anchor_touch_last.copy(position);
96706
- };
96707
-
96708
- const globalUp = new Signal();
96709
-
96710
- this.eventHandlerGlobalTouchEnd = (event) => {
96711
- getTouchCenter(event.touches, position);
96712
- globalUp.send2(position, event);
96713
- };
96790
+ this.#touchMove.send3(this.position, event, delta);
96714
96791
 
96715
- this.eventHandlerGlobalMouseUp = (event) => {
96716
- this.readPointerPositionFromEvent(position, event);
96717
- globalUp.send2(position, event);
96718
- };
96792
+ this.#anchor_touch_last.copy(this.position);
96793
+ }
96719
96794
 
96720
96795
  /**
96721
96796
  *
96722
96797
  * @param {WheelEvent} event
96723
96798
  */
96724
- this.eventHandlerWheel = (event) => {
96799
+ #eventHandlerWheel = (event) => {
96725
96800
  event.preventDefault();
96726
96801
 
96727
96802
  //deltas have inconsistent values across browsers, so we will normalize them
@@ -96732,148 +96807,146 @@ function PointerDevice(domElement) {
96732
96807
 
96733
96808
  const delta = new Vector3$1(x, y, z);
96734
96809
 
96735
- this.readPointerPositionFromEvent(position, event);
96810
+ this.readPointerPositionFromEvent(this.position, event);
96736
96811
 
96737
- this.on.wheel.send3(delta, position, event);
96738
- };
96812
+ this.on.wheel.send3(delta, this.position, event);
96813
+ }
96739
96814
 
96815
+ /**
96816
+ *
96817
+ * @param {TouchEvent} event
96818
+ */
96819
+ #eventHandlerTouchStart = (event) => {
96820
+ getTouchCenter(event.touches, this.position);
96821
+ this.#touchStart.send2(this.position, event);
96740
96822
 
96741
- this.on = {
96742
- down: new Signal(),
96743
- up: new Signal(),
96744
- move: new Signal(),
96745
- tap: new Signal(),
96746
- drag: new Signal(),
96747
- dragStart: new Signal(),
96748
- dragEnd: new Signal(),
96749
- wheel: new Signal(),
96750
- pinch: new Signal(),
96751
- pinchStart: new Signal(),
96752
- pinchEnd: new Signal(),
96753
- };
96823
+ this.#anchor_touch_last.copy(this.position);
96824
+ }
96754
96825
 
96755
- //constructed events
96756
- observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
96757
- observeDrag(globalUp, this.on.down, this.on.move, this.on.dragStart, this.on.dragEnd, this.on.drag);
96758
- observePinch({
96759
- touchStart: touchStart,
96760
- touchEnd: touchEnd,
96761
- touchMove: touchMove,
96762
- pinch: this.on.pinch,
96763
- pinchStart: this.on.pinchStart,
96764
- pinchEnd: this.on.pinchEnd
96765
- });
96766
- }
96826
+ /**
96827
+ *
96828
+ * @param {MouseEvent} event
96829
+ */
96830
+ #eventHandlerMouseMove = (event) => {
96831
+ event.preventDefault();
96767
96832
 
96768
- /**
96769
- *
96770
- * @return {Element}
96771
- */
96772
- PointerDevice.prototype.getTargetElement = function () {
96773
- return this.__target;
96774
- };
96833
+ this.#target = event.target;
96775
96834
 
96776
- /**
96777
- *
96778
- * @param {Element} el
96779
- */
96780
- PointerDevice.prototype.setTargetElement = function (el) {
96781
- assert.defined(el, 'el');
96782
- assert.notNull(el, 'el');
96835
+ this.readPointerPositionFromEvent(this.position, event);
96783
96836
 
96784
- if (this.__target === el) {
96785
- // no change
96786
- return;
96837
+ this.on.move.send3(this.position, event, new Vector2(event.movementX, event.movementY));
96787
96838
  }
96788
96839
 
96789
- let was_running = this.isRunning;
96790
-
96791
- if (was_running) {
96792
- // disconnect from previous target
96793
- this.stop();
96840
+ /**
96841
+ *
96842
+ * @return {Element}
96843
+ */
96844
+ getTargetElement() {
96845
+ return this.#target;
96794
96846
  }
96795
96847
 
96796
- this.__target = el;
96848
+ /**
96849
+ *
96850
+ * @param {Element} el
96851
+ */
96852
+ setTargetElement(el) {
96853
+ assert.defined(el, 'el');
96854
+ assert.notNull(el, 'el');
96797
96855
 
96798
- if (was_running) {
96799
- // restart to maintain original state
96800
- this.start();
96801
- }
96802
- };
96856
+ if (this.#target === el) {
96857
+ // no change
96858
+ return;
96859
+ }
96803
96860
 
96804
- /**
96805
- *
96806
- * @param {Vector2} result
96807
- * @param {MouseEvent|TouchEvent} event
96808
- */
96809
- PointerDevice.prototype.readPointerPositionFromEvent = function (result, event) {
96810
- readPositionFromMouseEvent(result, event, this.domElement);
96811
- };
96861
+ let was_running = this.isRunning;
96812
96862
 
96813
- PointerDevice.prototype.start = function () {
96814
- if (this.isRunning) {
96815
- //already running
96816
- return;
96863
+ if (was_running) {
96864
+ // disconnect from previous target
96865
+ this.stop();
96866
+ }
96867
+
96868
+ this.#target = el;
96869
+
96870
+ if (was_running) {
96871
+ // restart to maintain original state
96872
+ this.start();
96873
+ }
96874
+ }
96875
+
96876
+ /**
96877
+ *
96878
+ * @param {Vector2} result
96879
+ * @param {MouseEvent|TouchEvent} event
96880
+ */
96881
+ readPointerPositionFromEvent(result, event) {
96882
+ readPositionFromMouseEvent(result, event, this.domElement);
96817
96883
  }
96818
96884
 
96819
- this.isRunning = true;
96885
+ start() {
96886
+ if (this.isRunning) {
96887
+ //already running
96888
+ return;
96889
+ }
96820
96890
 
96821
- // console.warn("PointerDevice.start");
96891
+ this.isRunning = true;
96822
96892
 
96823
- const domElement = this.domElement;
96893
+ // console.warn("PointerDevice.start");
96824
96894
 
96825
- assert.notEqual(domElement, null, "domElement is null");
96826
- assert.notEqual(domElement, undefined, "domElement is undefined");
96895
+ const domElement = this.domElement;
96827
96896
 
96828
- domElement.addEventListener(MouseEvents.Move, this.eventHandlerMouseMove);
96829
- domElement.addEventListener(MouseEvents.Up, this.eventHandlerMouseUp);
96830
- domElement.addEventListener(MouseEvents.Down, this.eventHandlerMouseDown);
96897
+ assert.notEqual(domElement, null, "domElement is null");
96898
+ assert.notEqual(domElement, undefined, "domElement is undefined");
96831
96899
 
96832
- domElement.addEventListener(TouchEvents.Start, this.eventHandlerTouchStart);
96833
- domElement.addEventListener(TouchEvents.End, this.eventHandlerTouchEnd);
96834
- domElement.addEventListener(TouchEvents.Move, this.eventHandlerTouchMove);
96900
+ domElement.addEventListener(MouseEvents.Move, this.#eventHandlerMouseMove);
96901
+ domElement.addEventListener(MouseEvents.Up, this.#eventHandlerMouseUp);
96902
+ domElement.addEventListener(MouseEvents.Down, this.#eventHandlerMouseDown);
96835
96903
 
96836
- window.addEventListener(MouseEvents.Up, this.eventHandlerGlobalMouseUp);
96837
- window.addEventListener(TouchEvents.End, this.eventHandlerGlobalTouchEnd);
96904
+ domElement.addEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
96905
+ domElement.addEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
96906
+ domElement.addEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
96838
96907
 
96839
- /*
96840
- In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
96841
- see https://www.chromestatus.com/features/6662647093133312
96842
- */
96843
- domElement.addEventListener(MouseEvents.Wheel, this.eventHandlerWheel, { passive: false });
96908
+ window.addEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
96909
+ window.addEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
96844
96910
 
96911
+ /*
96912
+ In some cases wheel event gets registered as "passive" by default. This interferes with "preventDefault()"
96913
+ see https://www.chromestatus.com/features/6662647093133312
96914
+ */
96915
+ domElement.addEventListener(MouseEvents.Wheel, this.#eventHandlerWheel, { passive: false });
96845
96916
 
96846
- domElement.addEventListener("contextmenu", supressContextMenu);
96847
- };
96848
96917
 
96849
- PointerDevice.prototype.stop = function () {
96850
- if (!this.isRunning) {
96851
- //not running
96852
- return;
96918
+ domElement.addEventListener("contextmenu", supressContextMenu);
96853
96919
  }
96854
96920
 
96855
- this.isRunning = false;
96921
+ stop() {
96922
+ if (!this.isRunning) {
96923
+ //not running
96924
+ return;
96925
+ }
96856
96926
 
96857
- // console.warn("PointerDevice.stop");
96927
+ this.isRunning = false;
96858
96928
 
96859
- const domElement = this.domElement;
96929
+ // console.warn("PointerDevice.stop");
96860
96930
 
96861
- domElement.removeEventListener(MouseEvents.Move, this.eventHandlerMouseMove);
96862
- domElement.removeEventListener(MouseEvents.Up, this.eventHandlerMouseUp);
96863
- domElement.removeEventListener(MouseEvents.Down, this.eventHandlerMouseDown);
96931
+ const domElement = this.domElement;
96864
96932
 
96865
- domElement.removeEventListener(TouchEvents.Start, this.eventHandlerTouchStart);
96866
- domElement.removeEventListener(TouchEvents.End, this.eventHandlerTouchEnd);
96867
- domElement.removeEventListener(TouchEvents.Move, this.eventHandlerTouchMove);
96933
+ domElement.removeEventListener(MouseEvents.Move, this.#eventHandlerMouseMove);
96934
+ domElement.removeEventListener(MouseEvents.Up, this.#eventHandlerMouseUp);
96935
+ domElement.removeEventListener(MouseEvents.Down, this.#eventHandlerMouseDown);
96868
96936
 
96869
- window.removeEventListener(MouseEvents.Up, this.eventHandlerGlobalMouseUp);
96870
- window.removeEventListener(TouchEvents.End, this.eventHandlerGlobalTouchEnd);
96937
+ domElement.removeEventListener(TouchEvents.Start, this.#eventHandlerTouchStart);
96938
+ domElement.removeEventListener(TouchEvents.End, this.#eventHandlerTouchEnd);
96939
+ domElement.removeEventListener(TouchEvents.Move, this.#eventHandlerTouchMove);
96871
96940
 
96872
- domElement.removeEventListener(MouseEvents.Wheel, this.eventHandlerWheel);
96941
+ window.removeEventListener(MouseEvents.Up, this.#eventHandlerGlobalMouseUp);
96942
+ window.removeEventListener(TouchEvents.End, this.#eventHandlerGlobalTouchEnd);
96873
96943
 
96944
+ domElement.removeEventListener(MouseEvents.Wheel, this.#eventHandlerWheel);
96874
96945
 
96875
- domElement.removeEventListener("contextmenu", supressContextMenu);
96876
- };
96946
+
96947
+ domElement.removeEventListener("contextmenu", supressContextMenu);
96948
+ }
96949
+ }
96877
96950
 
96878
96951
  const KeyboardEvents = {
96879
96952
  KeyUp: 'keyup',
@@ -96883,7 +96956,7 @@ const KeyboardEvents = {
96883
96956
  /**
96884
96957
  * Representation of an input device key
96885
96958
  */
96886
- class InputDeviceButton {
96959
+ class InputDeviceSwitch {
96887
96960
  /**
96888
96961
  * Button press
96889
96962
  * @type {Signal}
@@ -96940,7 +97013,28 @@ function isFocusable(el) {
96940
97013
  || isInstanceOf(el, HTMLAreaElement)
96941
97014
  }
96942
97015
 
97016
+ /**
97017
+ * @readonly
97018
+ * @type {string[]}
97019
+ */
97020
+ const codeToKeyNameMap = [];
97021
+
96943
97022
  class KeyboardDevice {
97023
+
97024
+ /**
97025
+ * @readonly
97026
+ */
97027
+ on = {
97028
+ down: new Signal(),
97029
+ up: new Signal()
97030
+ };
97031
+
97032
+ /**
97033
+ * @readonly
97034
+ * @type {Object<InputDeviceSwitch>}
97035
+ */
97036
+ keys = {};
97037
+
96944
97038
  /**
96945
97039
  *
96946
97040
  * @param {EventTarget|Element} domElement
@@ -96960,19 +97054,6 @@ class KeyboardDevice {
96960
97054
  */
96961
97055
  this.domElement = domElement;
96962
97056
 
96963
- this.on = {
96964
- down: new Signal(),
96965
- up: new Signal()
96966
- };
96967
-
96968
-
96969
- /**
96970
- *
96971
- * @type {Object<InputDeviceButton>}
96972
- */
96973
- const keys = this.keys = {};
96974
-
96975
- const codeToKeyNameMap = [];
96976
97057
 
96977
97058
  //initialize separate events for each key
96978
97059
  for (let keyName in KeyCodes) {
@@ -96981,51 +97062,61 @@ class KeyboardDevice {
96981
97062
 
96982
97063
  codeToKeyNameMap[keyCode] = keyName;
96983
97064
 
96984
- keys[keyName] = new InputDeviceButton();
97065
+ this.keys[keyName] = new InputDeviceSwitch();
96985
97066
  }
96986
97067
 
96987
- this.__handlerKeyDown = (event) => {
96988
- this.on.down.send1(event);
97068
+ }
96989
97069
 
96990
- //hook up dispatch handler for individual keys
96991
- const keyCode = event.keyCode;
96992
- const keyName = codeToKeyNameMap[keyCode];
97070
+ /**
97071
+ *
97072
+ * @param {KeyboardEvent} event
97073
+ * @private
97074
+ */
97075
+ #handlerKeyDown = (event) => {
97076
+ this.on.down.send1(event);
96993
97077
 
96994
- if (keyName !== undefined) {
96995
- const button = keys[keyName];
97078
+ //hook up dispatch handler for individual keys
97079
+ const keyCode = event.keyCode;
97080
+ const keyName = codeToKeyNameMap[keyCode];
96996
97081
 
96997
- button.is_down = true;
96998
- button.down.send1(event);
97082
+ if (keyName !== undefined) {
97083
+ const button = this.keys[keyName];
96999
97084
 
97000
- }
97001
- };
97085
+ button.is_down = true;
97086
+ button.down.send1(event);
97087
+
97088
+ }
97089
+ }
97002
97090
 
97003
- this.__handlerKeyUp = (event) => {
97004
- this.on.up.send1(event);
97091
+ /**
97092
+ *
97093
+ * @param {KeyboardEvent} event
97094
+ * @private
97095
+ */
97096
+ #handlerKeyUp = (event) => {
97097
+ this.on.up.send1(event);
97005
97098
 
97006
- //hook up dispatch handler for individual keys
97007
- const keyCode = event.keyCode;
97099
+ //hook up dispatch handler for individual keys
97100
+ const keyCode = event.keyCode;
97008
97101
 
97009
- const keyName = codeToKeyNameMap[keyCode];
97102
+ const keyName = codeToKeyNameMap[keyCode];
97010
97103
 
97011
- if (keyName !== undefined) {
97012
- const button = keys[keyName];
97104
+ if (keyName !== undefined) {
97105
+ const button = this.keys[keyName];
97013
97106
 
97014
- button.is_down = false;
97015
- button.up.send1(event);
97016
- }
97017
- };
97107
+ button.is_down = false;
97108
+ button.up.send1(event);
97109
+ }
97018
97110
  }
97019
97111
 
97020
-
97021
97112
  start() {
97022
- this.domElement.addEventListener(KeyboardEvents.KeyDown, this.__handlerKeyDown);
97023
- this.domElement.addEventListener(KeyboardEvents.KeyUp, this.__handlerKeyUp);
97113
+ this.domElement.addEventListener(KeyboardEvents.KeyDown, this.#handlerKeyDown);
97114
+ this.domElement.addEventListener(KeyboardEvents.KeyUp, this.#handlerKeyUp);
97024
97115
  }
97025
97116
 
97026
97117
  stop() {
97027
- this.domElement.removeEventListener(KeyboardEvents.KeyDown, this.__handlerKeyDown);
97028
- this.domElement.removeEventListener(KeyboardEvents.KeyUp, this.__handlerKeyUp);
97118
+ this.domElement.removeEventListener(KeyboardEvents.KeyDown, this.#handlerKeyDown);
97119
+ this.domElement.removeEventListener(KeyboardEvents.KeyUp, this.#handlerKeyUp);
97029
97120
  }
97030
97121
  }
97031
97122
 
@@ -118743,7 +118834,11 @@ AbstractLight.prototype.type = 'Abstract';
118743
118834
  * @param {number[]|Float32Array|Float64Array} aabb_corners
118744
118835
  * @param {number[]|Float32Array|mat4} projection_matrix
118745
118836
  */
118746
- function aabb3_matrix4_project_by_corners(result, aabb_corners, projection_matrix) {
118837
+ function aabb3_matrix4_project_by_corners(
118838
+ result,
118839
+ aabb_corners,
118840
+ projection_matrix
118841
+ ) {
118747
118842
  assert.greaterThanOrEqual(result.length, 6, 'result.length must >= 6');
118748
118843
  assert.greaterThanOrEqual(aabb_corners.length, 24, 'aabb_corners.length must >= 24');
118749
118844
  assert.greaterThanOrEqual(projection_matrix.length, 16, 'projection_matrix.length must >= 16');
@@ -118846,6 +118941,11 @@ class Decal extends AbstractLight {
118846
118941
  this.transform_inverse = new Float32Array(16);
118847
118942
  this.uv = new Float32Array(4);
118848
118943
 
118944
+ this.color = new Float32Array(4);
118945
+ // initialize color to full white
118946
+ this.color.fill(1);
118947
+
118948
+
118849
118949
  /**
118850
118950
  *
118851
118951
  * @type {Sampler2D}
@@ -118925,8 +119025,11 @@ class Decal extends AbstractLight {
118925
119025
  array_copy(this.uv, 0, destination, address + 16, 4);
118926
119026
 
118927
119027
  // required for sorting
118928
- destination[address + 20] = this.draw_priority;
118929
- destination[address + 21] = this.id;
119028
+ // destination[address + 20] = this.draw_priority;
119029
+ // destination[address + 21] = this.id;
119030
+
119031
+ // color
119032
+ array_copy(this.color, 0, destination, address + 20, 4);
118930
119033
 
118931
119034
  return 24;
118932
119035
  }
@@ -119458,11 +119561,7 @@ function point_light_inside_volume(
119458
119561
  }
119459
119562
  }
119460
119563
 
119461
- /**
119462
- *
119463
- * @type {number[]}
119464
- */
119465
- const stack = [];
119564
+ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
119466
119565
 
119467
119566
  /**
119468
119567
  *
@@ -119487,7 +119586,7 @@ function frustum_check(data_view, address, planes) {
119487
119586
  const plane_normal_z = planes[plane_address + 2];
119488
119587
  const plane_constant = planes[plane_address + 3];
119489
119588
 
119490
- const distanceAbovePlane = aabb3_computeDistanceAbovePlane_max(
119589
+ const distanceAbovePlane = aabb3_compute_distance_above_plane_max(
119491
119590
  plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
119492
119591
  n_x0, n_y0, n_z0,
119493
119592
  n_x1, n_y1, n_z1
@@ -119524,8 +119623,6 @@ function query_bvh_frustum_from_texture(
119524
119623
  source_data,
119525
119624
  planes, points
119526
119625
  ) {
119527
-
119528
- let stackPointer = 1;
119529
119626
  let result = 0;
119530
119627
 
119531
119628
  const binary_node_count = root.getBinaryNodeCount();
@@ -119535,19 +119632,26 @@ function query_bvh_frustum_from_texture(
119535
119632
  return 0;
119536
119633
  }
119537
119634
 
119635
+ /**
119636
+ *
119637
+ * @type {number}
119638
+ */
119639
+ const stack_top = stack.pointer++;
119640
+
119538
119641
  /**
119539
119642
  * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
119540
119643
  * @type {number}
119541
119644
  */
119542
- stack[0] = 0;
119645
+ stack[stack_top] = 0;
119543
119646
 
119544
119647
  const last_valid_index = binary_node_count + root.getLeafNodeCount();
119545
119648
  const data_view = root.getDataView();
119546
119649
 
119547
- while (stackPointer-- > 0) {
119650
+ do {
119651
+ stack.pointer--;
119548
119652
 
119549
119653
  // query_bvh_frustum_from_objects.iteration_count++;
119550
- const node_index = stack[stackPointer];
119654
+ const node_index = stack[stack.pointer];
119551
119655
 
119552
119656
  if (node_index < binary_node_count) {
119553
119657
  // is intermediate node
@@ -119562,11 +119666,11 @@ function query_bvh_frustum_from_texture(
119562
119666
 
119563
119667
  // left node ends up on top of the stack, which aligns with the desired access sequence
119564
119668
  if (right_index < last_valid_index) {
119565
- stack[stackPointer++] = right_index;
119669
+ stack[stack.pointer++] = right_index;
119566
119670
  // micro-optimization, since we know that right node is valid and left appears before that, left is valid too
119567
- stack[stackPointer++] = left_index;
119671
+ stack[stack.pointer++] = left_index;
119568
119672
  } else if (left_index < last_valid_index) {
119569
- stack[stackPointer++] = left_index;
119673
+ stack[stack.pointer++] = left_index;
119570
119674
  }
119571
119675
 
119572
119676
 
@@ -119614,7 +119718,7 @@ function query_bvh_frustum_from_texture(
119614
119718
  result++;
119615
119719
  }
119616
119720
 
119617
- }
119721
+ }while (stack.pointer > stack_top)
119618
119722
 
119619
119723
  return result;
119620
119724
  }
@@ -120863,14 +120967,17 @@ class LightManager {
120863
120967
  assert.isNumber(x, 'x');
120864
120968
  assert.isNonNegativeInteger(x, 'x');
120865
120969
  assert.isFiniteNumber(x, 'x');
120970
+ assert.greaterThan(x,0,'x must be > 0');
120866
120971
 
120867
120972
  assert.isNumber(y, 'y');
120868
120973
  assert.isNonNegativeInteger(y, 'y');
120869
120974
  assert.isFiniteNumber(y, 'y');
120975
+ assert.greaterThan(y,0,'y must be > 0');
120870
120976
 
120871
120977
  assert.isNumber(z, 'z');
120872
120978
  assert.isNonNegativeInteger(z, 'z');
120873
120979
  assert.isFiniteNumber(z, 'z');
120980
+ assert.greaterThan(z,0,'z must be > 0');
120874
120981
 
120875
120982
  const r = this.__tiles_resolution;
120876
120983
 
@@ -121212,6 +121319,10 @@ const FP_SHADER_CHUNK_APPLY_DECALS = `
121212
121319
 
121213
121320
  vec4 decal_color = texture2D(fp_t_decal_atlas,decal_uv, -0.2);
121214
121321
 
121322
+ vec4 decal_color_tint = texelFetch(fp_t_light_data, address_to_data_texture_coordinates(light_address+5u), 0);
121323
+
121324
+ decal_color*= decal_color_tint;
121325
+
121215
121326
  // compute decal alpha
121216
121327
  float decal_alpha = decal_color.a * decal_surface_angle_fade;
121217
121328