@woosh/meep-engine 2.108.4 → 2.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/build/meep.cjs +73 -48
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +73 -48
  4. package/package.json +1 -1
  5. package/src/core/assert.d.ts +2 -2
  6. package/src/core/assert.d.ts.map +1 -1
  7. package/src/core/assert.js +1 -1
  8. package/src/core/binary/align_4.spec.d.ts +2 -0
  9. package/src/core/binary/align_4.spec.d.ts.map +1 -0
  10. package/src/core/binary/align_4.spec.js +20 -0
  11. package/src/core/binary/{de_interleave_bits_by_2.d.ts → de_interleave_2_bits.d.ts} +1 -1
  12. package/src/core/binary/de_interleave_2_bits.d.ts.map +1 -0
  13. package/src/core/binary/de_interleave_2_bits.spec.js +1 -1
  14. package/src/core/binary/hex2dec.spec.d.ts +2 -0
  15. package/src/core/binary/hex2dec.spec.d.ts.map +1 -0
  16. package/src/core/binary/hex2dec.spec.js +22 -0
  17. package/src/core/binary/split_by_2.spec.d.ts +2 -0
  18. package/src/core/binary/split_by_2.spec.d.ts.map +1 -0
  19. package/src/core/binary/split_by_2.spec.js +22 -0
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts +4 -1
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  22. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +16 -7
  23. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +1 -1
  24. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -1
  25. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +12 -7
  26. package/src/core/geom/2d/circle/circle_circumference.d.ts +7 -0
  27. package/src/core/geom/2d/circle/circle_circumference.d.ts.map +1 -0
  28. package/src/core/geom/2d/circle/circle_circumference.js +12 -0
  29. package/src/core/geom/2d/compute_polygon_area_2d.d.ts.map +1 -1
  30. package/src/core/geom/2d/compute_polygon_area_2d.js +6 -4
  31. package/src/core/geom/2d/lt-grid/LooseTightGrid.js +1 -1
  32. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +2 -2
  33. package/src/core/geom/2d/triangle2d_get_barycentric.js +2 -2
  34. package/src/core/geom/3d/Ray3.d.ts +19 -0
  35. package/src/core/geom/3d/Ray3.d.ts.map +1 -0
  36. package/src/core/geom/3d/Ray3.js +27 -0
  37. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.d.ts +10 -0
  38. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.d.ts.map +1 -0
  39. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +35 -0
  40. package/src/core/geom/3d/sphere/harmonics/compute_legendre_polynomial.d.ts +1 -0
  41. package/src/core/geom/3d/sphere/harmonics/compute_legendre_polynomial.d.ts.map +1 -0
  42. package/src/core/geom/3d/sphere/harmonics/compute_legendre_polynomial.js +0 -0
  43. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_cosine_kernel.d.ts +9 -0
  44. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_cosine_kernel.d.ts.map +1 -0
  45. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_cosine_kernel.js +25 -0
  46. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
  47. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +2 -4
  48. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +8 -0
  49. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts.map +1 -0
  50. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +94 -0
  51. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +8 -0
  52. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +1 -0
  53. package/src/core/geom/3d/sphere/harmonics/{sh3_rotate.js → sh3_rotate_filament.js} +5 -2
  54. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +3 -3
  55. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +3 -3
  56. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -1
  57. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +29 -14
  58. package/src/core/geom/Quaternion.js +1 -1
  59. package/src/core/geom/vec3/v3_matrix4_multiply.d.ts +10 -0
  60. package/src/core/geom/vec3/v3_matrix4_multiply.d.ts.map +1 -0
  61. package/src/core/geom/vec3/v3_matrix4_multiply.js +27 -0
  62. package/src/core/geom/vec3/v3_shift_along_direction.d.ts +14 -0
  63. package/src/core/geom/vec3/v3_shift_along_direction.d.ts.map +1 -0
  64. package/src/core/geom/vec3/v3_shift_along_direction.js +23 -0
  65. package/src/core/math/compute_legendre_polynomial.d.ts +10 -0
  66. package/src/core/math/compute_legendre_polynomial.d.ts.map +1 -0
  67. package/src/core/math/compute_legendre_polynomial.js +46 -0
  68. package/src/core/math/statistics/softmax.d.ts +11 -0
  69. package/src/core/math/statistics/softmax.d.ts.map +1 -0
  70. package/src/core/math/statistics/softmax.js +24 -0
  71. package/src/core/math/statistics/softmax.spec.d.ts +2 -0
  72. package/src/core/math/statistics/softmax.spec.d.ts.map +1 -0
  73. package/src/core/math/statistics/softmax.spec.js +9 -0
  74. package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
  75. package/src/engine/ecs/transform/Transform.js +19 -4
  76. package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +1 -1
  77. package/src/engine/graphics/ecs/camera/CameraSystem.js +25 -13
  78. package/src/engine/graphics/geometry/decode_attribute_value.d.ts +10 -0
  79. package/src/engine/graphics/geometry/decode_attribute_value.d.ts.map +1 -0
  80. package/src/engine/graphics/geometry/decode_attribute_value.js +28 -0
  81. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.d.ts +11 -0
  82. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.d.ts.map +1 -0
  83. package/src/engine/graphics/geometry/geometry_construct_triangle_normal.js +31 -0
  84. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  85. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +0 -86
  86. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts +1 -0
  87. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts.map +1 -1
  88. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.js +6 -2
  89. package/src/engine/graphics/sh3/path_tracer/{GeometryBVHBatched.d.ts → BufferedGeometryBVH.d.ts} +9 -2
  90. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -0
  91. package/src/engine/graphics/sh3/path_tracer/{GeometryBVHBatched.js → BufferedGeometryBVH.js} +84 -5
  92. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +6 -4
  93. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
  94. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +54 -8
  95. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +6 -10
  96. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  97. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +41 -47
  98. package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.d.ts +11 -0
  99. package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.d.ts.map +1 -0
  100. package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +102 -0
  101. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +9 -0
  102. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -0
  103. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +17 -0
  104. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +31 -0
  105. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -0
  106. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.js +85 -0
  107. package/src/engine/graphics/sh3/path_tracer/material/TextureFilter.d.ts +14 -0
  108. package/src/engine/graphics/sh3/path_tracer/material/TextureFilter.d.ts.map +1 -0
  109. package/src/engine/graphics/sh3/path_tracer/material/TextureFilter.js +17 -0
  110. package/src/engine/graphics/sh3/path_tracer/material/TextureWrapping.d.ts +7 -0
  111. package/src/engine/graphics/sh3/path_tracer/material/TextureWrapping.d.ts.map +1 -0
  112. package/src/engine/graphics/sh3/path_tracer/material/TextureWrapping.js +9 -0
  113. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +104 -9
  114. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts +1 -2
  115. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -1
  116. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +50 -23
  117. package/src/engine/graphics/sh3/prototypeSH3Probe.js +62 -28
  118. package/src/engine/graphics/texture/sampler/one_pixel_sampler_uint8.d.ts +8 -0
  119. package/src/engine/graphics/texture/sampler/one_pixel_sampler_uint8.d.ts.map +1 -0
  120. package/src/engine/graphics/texture/sampler/one_pixel_sampler_uint8.js +10 -0
  121. package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts +8 -0
  122. package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts.map +1 -0
  123. package/src/engine/graphics/texture/sampler/sampler_multiply_vector.js +23 -0
  124. package/src/core/binary/de_interleave_bits_by_2.d.ts.map +0 -1
  125. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts +0 -8
  126. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts.map +0 -1
  127. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts.map +0 -1
  128. /package/src/core/binary/{de_interleave_bits_by_2.js → de_interleave_2_bits.js} +0 -0
package/build/meep.cjs CHANGED
@@ -557,7 +557,7 @@ assert.isArray = function (value, name = 'value') {
557
557
 
558
558
  /**
559
559
  * @template T
560
- * @param {ArrayLike<T>|T[]} value
560
+ * @param {ArrayLike<T>|T[]|Uint32Array|Float32Array} value
561
561
  * @param {string} name
562
562
  */
563
563
  assert.isArrayLike = function (value, name = 'value') {
@@ -3608,7 +3608,7 @@ let Quaternion$1 = class Quaternion {
3608
3608
  /**
3609
3609
  *
3610
3610
  * @param {Quaternion} other
3611
- * @param {number} max_delta
3611
+ * @param {number} max_delta in radians
3612
3612
  */
3613
3613
  rotateTowards(other, max_delta) {
3614
3614
  Quaternion.rotateTowards(this, this, other, max_delta);
@@ -4987,6 +4987,19 @@ class Transform {
4987
4987
  return result;
4988
4988
  }
4989
4989
 
4990
+ /**
4991
+ *
4992
+ * @param {number[]|Float32Array} mat
4993
+ * @returns {Transform}
4994
+ */
4995
+ static fromMatrix(mat) {
4996
+ const result = new Transform();
4997
+
4998
+ result.fromMatrix4(mat);
4999
+
5000
+ return result;
5001
+ }
5002
+
4990
5003
  /**
4991
5004
  * Multiply two transforms, result it written into this one
4992
5005
  * @param {Transform} a
@@ -5000,17 +5013,18 @@ class Transform {
5000
5013
 
5001
5014
  /**
5002
5015
  *
5003
- * @param {mat4|number[]|Float32Array} m
5016
+ * @param {mat4|number[]|Float32Array} matrix
5004
5017
  */
5005
- fromMatrix4(m) {
5018
+ fromMatrix4(matrix) {
5019
+
5006
5020
  // we know we are changing the matrix, so we're going to need to disable the flag that sets matrix from position/rotation/scale changes
5007
5021
  const ad = this.getFlag(TransformFlags.AutomaticChangeDetection);
5008
5022
 
5009
5023
  this.clearFlag(TransformFlags.AutomaticChangeDetection);
5010
5024
 
5011
- this.matrix.set(m);
5025
+ this.matrix.set(matrix);
5012
5026
 
5013
- decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
5027
+ decompose_matrix_4_array(matrix, this.position, this.rotation, this.scale);
5014
5028
 
5015
5029
  // restore value of the flag
5016
5030
  this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
@@ -69343,6 +69357,36 @@ function computeSystemName(system) {
69343
69357
  return system.constructor.name;
69344
69358
  }
69345
69359
 
69360
+ /**
69361
+ *
69362
+ * @param {Object3D} object
69363
+ */
69364
+ function threeUpdateMatrix(object) {
69365
+ object.updateMatrix();
69366
+
69367
+ const children = object.children;
69368
+ for (let i = 0, childCount = children.length; i < childCount; i++) {
69369
+ const child = children[i];
69370
+
69371
+ threeUpdateMatrix(child);
69372
+ }
69373
+ }
69374
+
69375
+ /**
69376
+ *
69377
+ * @param {Object3D} object3
69378
+ */
69379
+ function threeUpdateTransform(object3) {
69380
+
69381
+ /**
69382
+ signal that transformation matrix should be updated
69383
+ @see https://threejs.org/docs/index.html#api/core/Object3D.matrixWorldNeedsUpdate
69384
+ */
69385
+ threeUpdateMatrix(object3);
69386
+
69387
+ object3.updateMatrixWorld(false);
69388
+ }
69389
+
69346
69390
  /**
69347
69391
  *
69348
69392
  * @param {Camera} c
@@ -70089,50 +70133,43 @@ function set_camera_aspect_ratio(camera, width, height) {
70089
70133
 
70090
70134
  /**
70091
70135
  *
70092
- * @param {Object3D} object
70136
+ * @param {Camera} camera
70093
70137
  */
70094
- function threeUpdateMatrix(object) {
70095
- object.updateMatrix();
70138
+ function update_camera_transform(camera) {
70096
70139
 
70097
- const children = object.children;
70098
- for (let i = 0, childCount = children.length; i < childCount; i++) {
70099
- const child = children[i];
70140
+ const three_camera = camera.object;
70100
70141
 
70101
- threeUpdateMatrix(child);
70142
+ if (three_camera === null) {
70143
+ return;
70102
70144
  }
70145
+
70146
+ three_camera.updateProjectionMatrix();
70147
+ threeUpdateTransform(three_camera);
70103
70148
  }
70104
70149
 
70105
70150
  /**
70106
70151
  *
70107
- * @param {Object3D} object3
70152
+ * @param {THREE.Camera} object
70153
+ * @param {Quaternion} rotation
70108
70154
  */
70109
- function threeUpdateTransform(object3) {
70155
+ function three_camera_set_transform_rotation(object, rotation) {
70110
70156
 
70111
- /**
70112
- signal that transformation matrix should be updated
70113
- @see https://threejs.org/docs/index.html#api/core/Object3D.matrixWorldNeedsUpdate
70157
+ /*
70158
+ NOTE: I'm not sure why, but three.js camera points in the opposite direction to normal objects
70159
+ See: https://github.com/mrdoob/three.js/blob/412b99a7f26e117ea97f40eb53d010ab81aa3279/src/core/Object3D.js#L282
70114
70160
  */
70115
- threeUpdateMatrix(object3);
70116
70161
 
70117
- object3.updateMatrixWorld(false);
70118
- }
70119
-
70120
- /**
70121
- *
70122
- * @param {Camera} camera
70123
- */
70124
- function update_camera_transform(camera) {
70162
+ invertQuaternionOrientation(object.quaternion, rotation);
70125
70163
 
70126
- const three_camera = camera.object;
70164
+ object.rotation.setFromQuaternion(object.quaternion);
70127
70165
 
70128
- if (three_camera === null) {
70129
- return;
70130
- }
70166
+ // rotation.__setThreeEuler(camera.object.rotation); // seems unnecessary, based on Object3D.lookAt implementation
70167
+ // camera.object.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);
70168
+
70169
+ object.updateProjectionMatrix();
70170
+ threeUpdateTransform(object);
70171
+ }
70131
70172
 
70132
- three_camera.updateProjectionMatrix();
70133
- threeUpdateTransform(three_camera);
70134
- }
70135
-
70136
70173
  class CameraSystem extends System {
70137
70174
  /**
70138
70175
  *
@@ -70221,19 +70258,7 @@ class CameraSystem extends System {
70221
70258
  function synchronizeRotation() {
70222
70259
  const rotation = transform.rotation;
70223
70260
 
70224
- /*
70225
- NOTE: I'm not sure why, but three.js camera points in the opposite direction to normal objects
70226
- See: https://github.com/mrdoob/three.js/blob/412b99a7f26e117ea97f40eb53d010ab81aa3279/src/core/Object3D.js#L282
70227
- */
70228
-
70229
- invertQuaternionOrientation(camera.object.quaternion, rotation);
70230
-
70231
- camera.object.rotation.setFromQuaternion(camera.object.quaternion);
70232
-
70233
- // rotation.__setThreeEuler(camera.object.rotation); // seems unnecessary, based on Object3D.lookAt implementation
70234
- // camera.object.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);
70235
-
70236
- update_camera_transform(camera);
70261
+ three_camera_set_transform_rotation(camera.object, rotation);
70237
70262
  }
70238
70263
 
70239
70264
  function rebuild() {