@woosh/meep-engine 2.108.0 → 2.108.2

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 (102) hide show
  1. package/build/meep.cjs +178 -127
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +178 -127
  4. package/editor/tools/paint/TerrainHeightPaintTool.js +5 -5
  5. package/package.json +1 -1
  6. package/src/core/binary/float_to_uint8.d.ts +7 -0
  7. package/src/core/binary/float_to_uint8.d.ts.map +1 -0
  8. package/src/core/binary/{float2uint8.js → float_to_uint8.js} +1 -1
  9. package/src/core/binary/uint8_to_float.d.ts +7 -0
  10. package/src/core/binary/uint8_to_float.d.ts.map +1 -0
  11. package/src/core/binary/{uint82float.js → uint8_to_float.js} +1 -1
  12. package/src/core/binary/uint8_to_float.spec.d.ts +2 -0
  13. package/src/core/binary/uint8_to_float.spec.d.ts.map +1 -0
  14. package/src/core/binary/uint8_to_float.spec.js +7 -0
  15. package/src/core/codegen/codeToBlob.d.ts +8 -0
  16. package/src/core/codegen/codeToBlob.d.ts.map +1 -0
  17. package/src/core/codegen/codeToBlob.js +36 -0
  18. package/src/core/codegen/codeToURL.d.ts +8 -0
  19. package/src/core/codegen/codeToURL.d.ts.map +1 -0
  20. package/src/core/codegen/codeToURL.js +22 -0
  21. package/src/core/collection/array/array_shuffle.d.ts +8 -0
  22. package/src/core/collection/array/array_shuffle.d.ts.map +1 -0
  23. package/src/core/collection/array/array_shuffle.js +22 -0
  24. package/src/core/collection/array/array_shuffle.spec.d.ts +2 -0
  25. package/src/core/collection/array/array_shuffle.spec.d.ts.map +1 -0
  26. package/src/core/collection/array/{randomizeArrayElementOrder.spec.js → array_shuffle.spec.js} +4 -4
  27. package/src/core/collection/array/iterator/ArrayIteratorRandom.js +2 -2
  28. package/src/core/collection/array/randomMultipleFromArray.js +2 -2
  29. package/src/core/color/Color.js +9 -9
  30. package/src/core/color/hsv/hsv2rgb.js +4 -4
  31. package/src/core/color/rgb2uint24.js +4 -4
  32. package/src/core/color/sRGB/linear_to_sRGB.d.ts +1 -0
  33. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  34. package/src/core/color/sRGB/linear_to_sRGB.js +4 -4
  35. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  36. package/src/core/geom/3d/aabb/AABB3.js +4 -1
  37. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +3 -3
  38. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  39. package/src/core/geom/3d/shape/UnitSphereShape3D.js +14 -14
  40. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -1
  41. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +2 -0
  42. package/src/core/geom/Vector3.js +3 -3
  43. package/src/core/geom/random/randomPointInSphere.d.ts +1 -1
  44. package/src/core/geom/random/randomPointInSphere.js +2 -2
  45. package/src/core/geom/random/randomPointOnSphere.d.ts +3 -3
  46. package/src/core/geom/random/randomPointOnSphere.d.ts.map +1 -1
  47. package/src/core/geom/random/randomPointOnSphere.js +5 -9
  48. package/src/core/process/task/util/randomCountTask.js +3 -3
  49. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  50. package/src/core/process/worker/WorkerBuilder.js +5 -35
  51. package/src/engine/EngineHarness.d.ts.map +1 -1
  52. package/src/engine/EngineHarness.js +7 -1
  53. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  54. package/src/engine/asset/loaders/ArrayBufferLoader.js +17 -10
  55. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.d.ts.map +1 -1
  56. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +3 -0
  57. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +4 -4
  58. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
  59. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -0
  60. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +7 -7
  62. package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +3 -3
  63. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +1 -1
  64. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -6
  65. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  66. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -5
  67. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +14 -6
  68. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts +10 -0
  69. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts.map +1 -0
  70. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.js +20 -0
  71. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts +10 -0
  72. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts.map +1 -0
  73. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.js +31 -0
  74. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts +9 -0
  75. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts.map +1 -0
  76. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.js +21 -0
  77. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +1 -1
  78. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -1
  79. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +2 -3
  80. package/src/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +4 -4
  81. package/src/engine/graphics/sh3/prototypeSH3Probe.js +74 -6
  82. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  83. package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
  84. package/src/engine/network/convertPathToURL.d.ts +3 -1
  85. package/src/engine/network/convertPathToURL.d.ts.map +1 -1
  86. package/src/engine/network/convertPathToURL.js +68 -51
  87. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  88. package/src/engine/physics/fluid/SliceVisualiser.js +4 -4
  89. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  90. package/src/generation/filtering/numeric/CellFilterCache.js +1 -0
  91. package/src/core/binary/float2uint8.d.ts +0 -7
  92. package/src/core/binary/float2uint8.d.ts.map +0 -1
  93. package/src/core/binary/uint82float.d.ts +0 -7
  94. package/src/core/binary/uint82float.d.ts.map +0 -1
  95. package/src/core/binary/uint82float.spec.d.ts +0 -2
  96. package/src/core/binary/uint82float.spec.d.ts.map +0 -1
  97. package/src/core/binary/uint82float.spec.js +0 -7
  98. package/src/core/collection/array/randomizeArrayElementOrder.d.ts +0 -8
  99. package/src/core/collection/array/randomizeArrayElementOrder.d.ts.map +0 -1
  100. package/src/core/collection/array/randomizeArrayElementOrder.js +0 -24
  101. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts +0 -2
  102. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts.map +0 -1
@@ -2868,10 +2868,10 @@ let Vector3$1 = class Vector3 {
2868
2868
  }
2869
2869
 
2870
2870
  /**
2871
- *
2871
+ * Convert spherical coordinates to cartesian
2872
2872
  * @param {number} radius
2873
- * @param {number} phi
2874
- * @param {number} theta
2873
+ * @param {number} phi Also known as Azimuth
2874
+ * @param {number} theta Also known as Elevation
2875
2875
  */
2876
2876
  setFromSphericalCoords(radius, phi, theta) {
2877
2877
 
@@ -49538,7 +49538,7 @@ class Sampler2D {
49538
49538
  *
49539
49539
  * @param {number} u
49540
49540
  * @param {number} v
49541
- * @param {number[]} result
49541
+ * @param {number[]|Float32Array} result
49542
49542
  * @param {number} result_offset
49543
49543
  */
49544
49544
  sampleBilinearUV(u, v, result, result_offset = 0) {
@@ -49668,7 +49668,7 @@ class Sampler2D {
49668
49668
  *
49669
49669
  * @param {number} u
49670
49670
  * @param {number} v
49671
- * @param {ArrayLike<number>} result
49671
+ * @param {number[]|ArrayLike<number>} result
49672
49672
  */
49673
49673
  sampleNearestUV(u, v, result) {
49674
49674
  const w = this.width;
@@ -50288,7 +50288,7 @@ const WHITE_PIXEL_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA
50288
50288
  * @param {number} v
50289
50289
  * @returns {number}
50290
50290
  */
50291
- function float2uint8(v) {
50291
+ function float_to_uint8(v) {
50292
50292
  return Math.round(v * 255);
50293
50293
  }
50294
50294
 
@@ -50297,7 +50297,7 @@ function float2uint8(v) {
50297
50297
  * @param {number} v
50298
50298
  * @returns {number}
50299
50299
  */
50300
- function uint82float(v) {
50300
+ function uint8_to_float(v) {
50301
50301
  return v / 255;
50302
50302
  }
50303
50303
 
@@ -51696,7 +51696,7 @@ class TerrainOverlay {
51696
51696
  for (let i = 0; i < 4; i++) {
51697
51697
  const v = this.sampler.readChannel(x, y, i);
51698
51698
 
51699
- result[i] = uint82float(v);
51699
+ result[i] = uint8_to_float(v);
51700
51700
  }
51701
51701
  }
51702
51702
 
@@ -51743,7 +51743,7 @@ class TerrainOverlay {
51743
51743
  paintPoint(x, y, vec4) {
51744
51744
  for (let i = 0; i < 4; i++) {
51745
51745
 
51746
- this.sampler.writeChannel(x, y, i, float2uint8(vec4[i]));
51746
+ this.sampler.writeChannel(x, y, i, float_to_uint8(vec4[i]));
51747
51747
 
51748
51748
  }
51749
51749
 
@@ -53220,7 +53220,7 @@ function aabb3_intersects_ray(
53220
53220
  const diff_x = origin_x - center_x;
53221
53221
 
53222
53222
 
53223
- if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
53223
+ if (diff_x * direction_x >= 0 && abs(diff_x) > extents_x) {
53224
53224
  return false;
53225
53225
  }
53226
53226
 
@@ -53232,7 +53232,7 @@ function aabb3_intersects_ray(
53232
53232
  const diff_y = origin_y - center_y;
53233
53233
 
53234
53234
 
53235
- if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
53235
+ if (diff_y * direction_y >= 0 && abs(diff_y) > extents_y) {
53236
53236
  return false;
53237
53237
  }
53238
53238
 
@@ -53244,7 +53244,7 @@ function aabb3_intersects_ray(
53244
53244
  const diff_z = origin_z - center_z;
53245
53245
 
53246
53246
 
53247
- if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
53247
+ if (diff_z * direction_z >= 0 && abs(diff_z) > extents_z) {
53248
53248
  return false;
53249
53249
  }
53250
53250
 
@@ -53524,9 +53524,9 @@ function hsv2rgb(h, s, v) {
53524
53524
  break;
53525
53525
  }
53526
53526
  return {
53527
- r: float2uint8(r),
53528
- g: float2uint8(g),
53529
- b: float2uint8(b)
53527
+ r: float_to_uint8(r),
53528
+ g: float_to_uint8(g),
53529
+ b: float_to_uint8(b)
53530
53530
  };
53531
53531
  }
53532
53532
 
@@ -53617,9 +53617,9 @@ function parse_color(c) {
53617
53617
  * @returns {number}
53618
53618
  */
53619
53619
  function rgb2uint24(r, g, b) {
53620
- const _r = float2uint8(r);
53621
- const _g = float2uint8(g);
53622
- const _b = float2uint8(b);
53620
+ const _r = float_to_uint8(r);
53621
+ const _g = float_to_uint8(g);
53622
+ const _b = float_to_uint8(b);
53623
53623
 
53624
53624
  return (_b & 0xFF)
53625
53625
  | (_g & 0xFF) << 8
@@ -53638,7 +53638,7 @@ function rgb_to_luminance(r, g, b) {
53638
53638
  return 0.299 * r + 0.587 * g + 0.114 * b;
53639
53639
  }
53640
53640
 
53641
- function convert(c) {
53641
+ function convert_channel_linear_to_sRGB(c) {
53642
53642
  if (c < 0.0031308) {
53643
53643
  return c * 12.92;
53644
53644
  } else {
@@ -53661,9 +53661,9 @@ function linear_to_sRGB(
53661
53661
  const g = input[input_offset + 1];
53662
53662
  const b = input[input_offset + 2];
53663
53663
 
53664
- output[output_offset] = convert(r);
53665
- output[output_offset + 1] = convert(g);
53666
- output[output_offset + 2] = convert(b);
53664
+ output[output_offset] = convert_channel_linear_to_sRGB(r);
53665
+ output[output_offset + 1] = convert_channel_linear_to_sRGB(g);
53666
+ output[output_offset + 2] = convert_channel_linear_to_sRGB(b);
53667
53667
  }
53668
53668
 
53669
53669
  /**
@@ -53837,9 +53837,9 @@ class Color {
53837
53837
  */
53838
53838
  setRGBUint8(r, g, b) {
53839
53839
  this.setRGB(
53840
- uint82float(r),
53841
- uint82float(g),
53842
- uint82float(b),
53840
+ uint8_to_float(r),
53841
+ uint8_to_float(g),
53842
+ uint8_to_float(b),
53843
53843
  );
53844
53844
  }
53845
53845
 
@@ -54132,9 +54132,9 @@ class Color {
54132
54132
  */
54133
54133
  toHex() {
54134
54134
  return '#' + rgb2hex(
54135
- float2uint8(this.r),
54136
- float2uint8(this.g),
54137
- float2uint8(this.b)
54135
+ float_to_uint8(this.r),
54136
+ float_to_uint8(this.g),
54137
+ float_to_uint8(this.b)
54138
54138
  );
54139
54139
  }
54140
54140
 
@@ -54143,7 +54143,7 @@ class Color {
54143
54143
  * @returns {string}
54144
54144
  */
54145
54145
  toCssRGBAString() {
54146
- return `rgba(${float2uint8(this.r)},${float2uint8(this.g)},${float2uint8(this.b)},${this.a})`;
54146
+ return `rgba(${float_to_uint8(this.r)},${float_to_uint8(this.g)},${float_to_uint8(this.b)},${this.a})`;
54147
54147
  }
54148
54148
 
54149
54149
  /**
@@ -56759,11 +56759,13 @@ class AABB3 {
56759
56759
  * Get center position of the box
56760
56760
  * @param {Vector3} target where to write result
56761
56761
  */
56762
- getCenter(target) {
56762
+ getCenter(target = new Vector3$1()) {
56763
56763
  const x = this.getCenterX();
56764
56764
  const y = this.getCenterY();
56765
56765
  const z = this.getCenterZ();
56766
56766
  target.set(x, y, z);
56767
+
56768
+ return target;
56767
56769
  }
56768
56770
 
56769
56771
 
@@ -63068,72 +63070,137 @@ const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
63068
63070
  * @param {string} path
63069
63071
  * @return {string}
63070
63072
  */
63071
- function convertPathToURL(path) {
63072
-
63073
- if (!isGlobalPath(path)) {
63073
+ function localPathToGlobal(path) {
63074
+ /**
63075
+ * @type {Window|DedicatedWorkerGlobalScope}
63076
+ */
63077
+ let scope;
63074
63078
 
63075
- /**
63076
- * @type {Window|DedicatedWorkerGlobalScope}
63077
- */
63078
- let scope;
63079
+ if (ENVIRONMENT_IS_WEB) {
63080
+ scope = window;
63081
+ } else if (ENVIRONMENT_IS_WORKER) {
63082
+ scope = self;
63083
+ } else if (ENVIRONMENT_IS_NODE) {
63079
63084
 
63080
- if (ENVIRONMENT_IS_WEB) {
63081
- scope = window;
63082
- } else if (ENVIRONMENT_IS_WORKER) {
63083
- scope = self;
63084
- } else if (ENVIRONMENT_IS_NODE) {
63085
+ let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63085
63086
 
63086
- let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
63087
+ // remove multiple sequential slashes
63088
+ normalized_path = normalized_path.replace(/\/+/g, '/');
63087
63089
 
63088
- // remove multiple sequential slashes
63089
- normalized_path = normalized_path.replace(/\/+/g, '/');
63090
+ if (normalized_path[0] !== '/') {
63091
+ // Windows drive letter must be prefixed with a slash.
63092
+ normalized_path = `/${normalized_path}`;
63093
+ }
63090
63094
 
63091
- if (normalized_path[0] !== '/') {
63092
- // Windows drive letter must be prefixed with a slash.
63093
- normalized_path = `/${normalized_path}`;
63095
+ scope = {
63096
+ location: {
63097
+ pathname: normalized_path,
63098
+ host: '',
63099
+ protocol: 'file:'
63094
63100
  }
63101
+ };
63102
+ } else {
63103
+ throw new Error('Unknown environment');
63104
+ }
63095
63105
 
63096
- scope = {
63097
- location: {
63098
- pathname: normalized_path,
63099
- host: '',
63100
- protocol: 'file:'
63101
- }
63102
- };
63106
+ const location = scope.location;
63107
+ const pathname = location.pathname;
63108
+
63109
+ let directoryPath;
63110
+
63111
+ /*
63112
+ path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63113
+ we need to extract directory to load relative path
63114
+ */
63115
+
63116
+ if (pathname.endsWith('/')) {
63117
+ //path is to a directory, strip last slash
63118
+ directoryPath = pathname.substring(0, pathname.length - 1);
63119
+ } else {
63120
+ //path is to a file
63121
+ const i = pathname.lastIndexOf('/');
63122
+
63123
+ if (i === -1) {
63124
+ //root level file
63125
+ directoryPath = "";
63103
63126
  } else {
63104
- throw new Error('Unknown environment');
63127
+ directoryPath = pathname.substring(0, i);
63105
63128
  }
63129
+ }
63106
63130
 
63107
- const location = scope.location;
63108
- const pathname = location.pathname;
63131
+ const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63132
+ return urlBase + path;
63133
+ }
63109
63134
 
63110
- let directoryPath;
63135
+ /**
63136
+ * Given a path, which may be a local path, produce a fully qualified URL
63137
+ * @example '/path' -> 'http://example.com/path'
63138
+ * @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
63139
+ * @param {string} path
63140
+ * @return {string}
63141
+ */
63142
+ function convertPathToURL(path) {
63111
63143
 
63112
- /*
63113
- path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
63114
- we need to extract directory to load relative path
63115
- */
63144
+ const is_global = isGlobalPath(path);
63116
63145
 
63117
- if (pathname.endsWith('/')) {
63118
- //path is to a directory, strip last slash
63119
- directoryPath = pathname.substring(0, pathname.length - 1);
63120
- } else {
63121
- //path is to a file
63122
- const i = pathname.lastIndexOf('/');
63146
+ let result = path;
63123
63147
 
63124
- if (i === -1) {
63125
- //root level file
63126
- directoryPath = "";
63127
- } else {
63128
- directoryPath = pathname.substring(0, i);
63129
- }
63148
+ if (!is_global) {
63149
+ result = localPathToGlobal(path);
63150
+ }
63151
+
63152
+ return result;
63153
+ }
63154
+
63155
+ /**
63156
+ *
63157
+ * @param {string} code
63158
+ * @param {string} [mime_type]
63159
+ * @return {Blob}
63160
+ */
63161
+ function codeToBlob(code, mime_type = 'application/javascript') {
63162
+
63163
+ let blob;
63164
+
63165
+ if (typeof globalThis.Blob !== "undefined") {
63166
+ blob = new Blob([code], { type: mime_type });
63167
+ } else {
63168
+ // Backwards-compatibility
63169
+ const BlobBuilder = globalThis.BlobBuilder
63170
+ || globalThis.BlobBuilder
63171
+ || globalThis.WebKitBlobBuilder
63172
+ || globalThis.MozBlobBuilder;
63173
+
63174
+ if (BlobBuilder !== undefined) {
63175
+ blob = new BlobBuilder();
63176
+ blob.append(code);
63177
+ blob = blob.getBlob();
63178
+ } else {
63179
+ throw new Error(`No BlobBuilder interface supported in current context`);
63130
63180
  }
63131
63181
 
63132
- const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
63133
- path = urlBase + path;
63134
63182
  }
63135
63183
 
63136
- return path;
63184
+
63185
+ return blob;
63186
+ }
63187
+
63188
+ /**
63189
+ *
63190
+ * @param {string} code
63191
+ * @param {string} [mime_type]
63192
+ * @return {string}
63193
+ */
63194
+ function codeToURL(code, mime_type = 'application/javascript') {
63195
+
63196
+ const blob = codeToBlob(code, mime_type);
63197
+
63198
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
63199
+ return URL.createObjectURL(blob);
63200
+ } else {
63201
+ // build data URL in a slowest way possible
63202
+ return `data:${mime_type},${encodeURIComponent(code)}`;
63203
+ }
63137
63204
  }
63138
63205
 
63139
63206
  class Line {
@@ -63589,6 +63656,7 @@ class WorkerProxy {
63589
63656
 
63590
63657
  const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)/g;
63591
63658
 
63659
+
63592
63660
  class WorkerBuilder {
63593
63661
 
63594
63662
  imports = [];
@@ -63631,9 +63699,9 @@ class WorkerBuilder {
63631
63699
  * @param {string} path
63632
63700
  */
63633
63701
  importScript(path) {
63634
- path = convertPathToURL(path);
63702
+ const qualified_path = convertPathToURL(path);
63635
63703
 
63636
- this.imports.push(path);
63704
+ this.imports.push(qualified_path);
63637
63705
  }
63638
63706
 
63639
63707
  /**
@@ -63643,7 +63711,7 @@ class WorkerBuilder {
63643
63711
  build() {
63644
63712
  const codeLines = [];
63645
63713
 
63646
- codeLines.push('var globalScope = this;');
63714
+ codeLines.push('var globalScope = globalThis;');
63647
63715
 
63648
63716
  //handle imports
63649
63717
  this.imports.forEach(function (url) {
@@ -63744,37 +63812,6 @@ class WorkerBuilder {
63744
63812
 
63745
63813
  return new WorkerProxy(workerURL, this.methods);
63746
63814
  }
63747
- }
63748
- /**
63749
- *
63750
- * @param {string} code
63751
- * @return {string}
63752
- */
63753
- function codeToURL(code) {
63754
- const js_mime = 'application/javascript';
63755
-
63756
- let blob;
63757
-
63758
- if (typeof window === 'object') {
63759
- if (typeof window.Blob !== "undefined") {
63760
- blob = new Blob([code], {type: js_mime});
63761
- } else {
63762
- // Backwards-compatibility
63763
- const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
63764
- if (BlobBuilder !== undefined) {
63765
- blob = new BlobBuilder();
63766
- blob.append(code);
63767
- blob = blob.getBlob();
63768
- }
63769
- }
63770
- }
63771
-
63772
- if (blob !== undefined && URL.createObjectURL !== undefined) {
63773
- return URL.createObjectURL(blob);
63774
- } else {
63775
- // build data URL in a slowest way possible
63776
- return `data:${js_mime},${encodeURIComponent(code)}`;
63777
- }
63778
63815
  }
63779
63816
 
63780
63817
  /**
@@ -67689,20 +67726,19 @@ class AssetLoader {
67689
67726
  function observeResponseProgress(input, progress) {
67690
67727
  let response = input;
67691
67728
 
67692
-
67693
- if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
67729
+ // Workaround: Checking if response.body === undefined for Alipay browser
67730
+ if (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {
67694
67731
 
67695
67732
  return response;
67696
67733
 
67697
67734
  }
67698
67735
 
67699
- /**
67700
- * @type {ReadableStreamDefaultReader<Uint8Array>}
67701
- */
67702
- const reader = response.body.getReader();
67736
+ // Nginx needs X-File-Size check
67737
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
67738
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
67703
67739
 
67704
- const contentLength = response.headers.get('Content-Length');
67705
67740
  const total = contentLength ? parseInt(contentLength) : 0;
67741
+
67706
67742
  let loaded = 0;
67707
67743
 
67708
67744
  // periodically read data into the new stream tracking while download progress
@@ -67710,6 +67746,11 @@ function observeResponseProgress(input, progress) {
67710
67746
  type: "bytes",
67711
67747
  start(controller) {
67712
67748
 
67749
+ /**
67750
+ * @type {ReadableStreamDefaultReader<Uint8Array>}
67751
+ */
67752
+ const reader = response.body.getReader();
67753
+
67713
67754
  pump();
67714
67755
 
67715
67756
  function pump() {
@@ -67727,6 +67768,7 @@ function observeResponseProgress(input, progress) {
67727
67768
  progress(loaded, total);
67728
67769
 
67729
67770
  controller.enqueue(value);
67771
+
67730
67772
  pump();
67731
67773
 
67732
67774
  });
@@ -67798,16 +67840,13 @@ class ArrayBufferLoader extends AssetLoader {
67798
67840
 
67799
67841
  let response = await fetch(request);
67800
67842
 
67801
- if (!(response.status === 200 || response.status === 0)) {
67843
+ const response_status = response.status;
67802
67844
 
67803
- throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
67845
+ if (response_status !== 200 && response_status !== 0) {
67804
67846
 
67805
- }
67806
-
67807
- // Some browsers return HTTP Status 0 when using non-http protocol
67808
- // e.g. 'file://' or 'data://'. Handle as success.
67847
+ throw Error(`fetch for "${response.url}" responded with ${response_status}: ${response.statusText}`);
67809
67848
 
67810
- if (response.status === 0) ;
67849
+ }
67811
67850
 
67812
67851
  try {
67813
67852
  response = observeResponseProgress(response, progress);
@@ -75590,6 +75629,9 @@ const TextureAttachmentsByMaterialType = {
75590
75629
  taDisplacement,
75591
75630
  taAlphaMap
75592
75631
  ],
75632
+ MeshBasicMaterial: [
75633
+ taDiffuse
75634
+ ],
75593
75635
  MeshStandardMaterial: [
75594
75636
  taDiffuse,
75595
75637
  taAlphaMap,
@@ -105066,6 +105108,9 @@ class TopDownCameraController {
105066
105108
 
105067
105109
  this.distance = eye.distanceTo(target);
105068
105110
 
105111
+ // ensure we can maintain this distance
105112
+ this.distanceMax = max2(this.distance, this.distanceMax);
105113
+
105069
105114
  this.target.copy(target);
105070
105115
  }
105071
105116
 
@@ -115602,6 +115647,12 @@ function setLocale(engine) {
115602
115647
  return engine.localization.loadLocale(locale);
115603
115648
  }
115604
115649
 
115650
+ /**
115651
+ * Equal to ~ 5500 K light color
115652
+ * @type {Readonly<Color>}
115653
+ */
115654
+ const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
115655
+
115605
115656
  class EngineHarness {
115606
115657
  constructor() {
115607
115658
  /**
@@ -115879,7 +115930,7 @@ class EngineHarness {
115879
115930
  ecd = engine.entityManager.dataset,
115880
115931
  shadowmapResolution = 1024,
115881
115932
  castShadow = true,
115882
- sun = Color.white,
115933
+ sun = DEFAULT_SUNLIGHT_COLOR,
115883
115934
  sunIntensity = 0.9,
115884
115935
  sunDirection = new Vector3$1(0.1, -1, 0.1),
115885
115936
  ambient = Color.white,
@@ -1,13 +1,13 @@
1
+ import { uint8_to_float } from "../../../src/core/binary/uint8_to_float.js";
2
+ import { QuadTreeNode } from "../../../src/core/geom/2d/quad-tree/QuadTreeNode.js";
1
3
  import { clamp } from "../../../src/core/math/clamp.js";
2
4
  import { inverseLerp } from "../../../src/core/math/inverseLerp.js";
3
5
  import { lerp } from "../../../src/core/math/lerp.js";
4
- import { TerrainPaintTool } from "./TerrainPaintTool.js";
5
- import { PatchTerrainHeightAction } from "../../actions/concrete/PatchTerrainHeightAction.js";
6
- import { QuadTreeNode } from "../../../src/core/geom/2d/quad-tree/QuadTreeNode.js";
7
6
  import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
7
+ import { PatchTerrainHeightAction } from "../../actions/concrete/PatchTerrainHeightAction.js";
8
8
  import TransformModifyAction from "../../actions/concrete/TransformModifyAction.js";
9
9
  import EditorEntity from "../../ecs/EditorEntity.js";
10
- import { uint82float } from "../../../src/core/binary/uint82float.js";
10
+ import { TerrainPaintTool } from "./TerrainPaintTool.js";
11
11
 
12
12
  const LIMIT_VALUE = 1000;
13
13
 
@@ -56,7 +56,7 @@ function make_mod_action(terrain, uv_x0, uv_y0, uv_x1, uv_y1, marker, value_delt
56
56
  //Get alpha
57
57
  const markerValue = marker.sampleChannelBilinearUV(u, v, 3);
58
58
 
59
- const marker_value_normalized = uint82float(markerValue);
59
+ const marker_value_normalized = uint8_to_float(markerValue);
60
60
 
61
61
  const source_address = y * heightMap.width + x;
62
62
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.108.0",
8
+ "version": "2.108.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} v
4
+ * @returns {number}
5
+ */
6
+ export function float_to_uint8(v: number): number;
7
+ //# sourceMappingURL=float_to_uint8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float_to_uint8.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/float_to_uint8.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -3,6 +3,6 @@
3
3
  * @param {number} v
4
4
  * @returns {number}
5
5
  */
6
- export function float2uint8(v) {
6
+ export function float_to_uint8(v) {
7
7
  return Math.round(v * 255);
8
8
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} v
4
+ * @returns {number}
5
+ */
6
+ export function uint8_to_float(v: number): number;
7
+ //# sourceMappingURL=uint8_to_float.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uint8_to_float.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -3,6 +3,6 @@
3
3
  * @param {number} v
4
4
  * @returns {number}
5
5
  */
6
- export function uint82float(v) {
6
+ export function uint8_to_float(v) {
7
7
  return v / 255;
8
8
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=uint8_to_float.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uint8_to_float.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { uint8_to_float } from "./uint8_to_float.js";
2
+
3
+ test("correctness", () => {
4
+ expect(uint8_to_float(0)).toBe(0);
5
+ expect(uint8_to_float(1)).toBeCloseTo(1 / 255);
6
+ expect(uint8_to_float(255)).toBe(1);
7
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {string} code
4
+ * @param {string} [mime_type]
5
+ * @return {Blob}
6
+ */
7
+ export function codeToBlob(code: string, mime_type?: string): Blob;
8
+ //# sourceMappingURL=codeToBlob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeToBlob.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/codeToBlob.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iCAJW,MAAM,cACN,MAAM,GACL,IAAI,CA6Bf"}