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