@woosh/meep-engine 2.107.0 → 2.108.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 (231) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/meep.cjs +78 -46
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +78 -47
  5. package/package.json +1 -1
  6. package/src/core/binary/int32_to_binary_string.d.ts +3 -2
  7. package/src/core/binary/int32_to_binary_string.d.ts.map +1 -1
  8. package/src/core/binary/int32_to_binary_string.js +18 -14
  9. package/src/core/binary/split_by_3.spec.d.ts +2 -0
  10. package/src/core/binary/split_by_3.spec.d.ts.map +1 -0
  11. package/src/core/binary/split_by_3.spec.js +22 -0
  12. package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
  13. package/src/core/binary/to_half_float_uint16.js +7 -5
  14. package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
  15. package/src/core/collection/array/isArrayEqualStrict.js +2 -2
  16. package/src/core/color/Color.d.ts.map +1 -1
  17. package/src/core/color/Color.js +7 -2
  18. package/src/core/color/hsv/rgb2hsv.d.ts +3 -3
  19. package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
  20. package/src/core/color/hsv/rgb2hsv.js +11 -18
  21. package/src/core/color/rgb_to_luminance.d.ts +9 -0
  22. package/src/core/color/rgb_to_luminance.d.ts.map +1 -0
  23. package/src/core/color/rgb_to_luminance.js +10 -0
  24. package/src/core/geom/3d/sphere/harmonics/README.md +16 -2
  25. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts +6 -0
  26. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -0
  27. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +15 -0
  28. package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts.map +1 -1
  29. package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.js +21 -9
  30. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts +3 -3
  31. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
  32. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +35 -206
  33. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts +8 -0
  34. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts.map +1 -0
  35. package/src/core/geom/3d/sphere/harmonics/sh3_rotate.js +29 -0
  36. package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +10 -10
  37. package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts +8 -0
  38. package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts.map +1 -0
  39. package/src/core/geom/3d/sphere/harmonics/sh_index.js +9 -0
  40. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +8 -0
  41. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +1 -0
  42. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +44 -0
  43. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +8 -0
  44. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +1 -0
  45. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +86 -0
  46. package/src/core/geom/3d/sphere/in_sphere3d_robust.d.ts.map +1 -1
  47. package/src/core/geom/3d/sphere/in_sphere3d_robust.js +2 -1
  48. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +20 -1
  49. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  50. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +53 -7
  51. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +2 -2
  52. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts +1 -1
  53. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts.map +1 -1
  54. package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js +12 -7
  55. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts +13 -0
  56. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -0
  57. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +135 -0
  58. package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +38 -24
  59. package/src/core/geom/3d/tetrahedra/{compute_circumsphere.d.ts → tetrahedron_compute_circumsphere.d.ts} +3 -5
  60. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -0
  61. package/src/core/geom/3d/tetrahedra/{compute_circumsphere.js → tetrahedron_compute_circumsphere.js} +2 -4
  62. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts.map +1 -1
  63. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +3 -1
  64. package/src/core/geom/Vector3.d.ts.map +1 -1
  65. package/src/core/geom/Vector3.js +1 -0
  66. package/src/core/geom/mat3/m3_multiply_vec3.d.ts +8 -0
  67. package/src/core/geom/mat3/m3_multiply_vec3.d.ts.map +1 -0
  68. package/src/core/geom/mat3/m3_multiply_vec3.js +21 -0
  69. package/src/core/geom/vec2/v2_cross_product.d.ts +15 -0
  70. package/src/core/geom/vec2/v2_cross_product.d.ts.map +1 -0
  71. package/src/core/geom/vec2/v2_cross_product.js +21 -0
  72. package/src/core/geom/vec3/v3_slerp.d.ts +1 -0
  73. package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
  74. package/src/core/geom/vec3/v3_slerp.js +1 -0
  75. package/src/core/graph/MultiNode.d.ts +1 -1
  76. package/src/core/graph/MultiNode.js +1 -1
  77. package/src/core/graph/WeightedEdge.d.ts +6 -4
  78. package/src/core/graph/WeightedEdge.d.ts.map +1 -1
  79. package/src/core/graph/WeightedEdge.js +3 -0
  80. package/src/core/graph/coloring/colorizeGraph.js +19 -19
  81. package/src/core/graph/convert_graph_to_dot_string.d.ts +1 -1
  82. package/src/core/graph/convert_graph_to_dot_string.d.ts.map +1 -1
  83. package/src/core/graph/convert_graph_to_dot_string.js +10 -6
  84. package/src/core/graph/graph_compute_adjacency_matrix.d.ts +9 -0
  85. package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -0
  86. package/src/core/graph/{graph_adjacency_matrix.js → graph_compute_adjacency_matrix.js} +1 -2
  87. package/src/core/graph/graph_compute_degree_matrix.d.ts +10 -0
  88. package/src/core/graph/graph_compute_degree_matrix.d.ts.map +1 -0
  89. package/src/core/graph/graph_compute_degree_matrix.js +23 -0
  90. package/src/core/graph/graph_compute_distance_matrix.d.ts +13 -0
  91. package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -0
  92. package/src/core/graph/graph_compute_distance_matrix.js +103 -0
  93. package/src/core/graph/{graph_laplacian_matrix.d.ts → graph_compute_laplacian_matrix.d.ts} +2 -2
  94. package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -0
  95. package/src/core/graph/{graph_laplacian_matrix.js → graph_compute_laplacian_matrix.js} +6 -6
  96. package/src/core/graph/graph_k_means_cluster.d.ts.map +1 -1
  97. package/src/core/graph/graph_k_means_cluster.js +4 -119
  98. package/src/core/graph/{coarsen_graph.d.ts → mn_graph_coarsen.d.ts} +2 -2
  99. package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -0
  100. package/src/core/graph/{coarsen_graph.js → mn_graph_coarsen.js} +1 -1
  101. package/src/core/graph/mn_graph_coarsen.spec.d.ts +2 -0
  102. package/src/core/graph/mn_graph_coarsen.spec.d.ts.map +1 -0
  103. package/src/core/graph/{coarsen_graph.spec.js → mn_graph_coarsen.spec.js} +4 -4
  104. package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts +1 -0
  105. package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts.map +1 -1
  106. package/src/core/graph/mn_graph_collapse_weighted_edge.js +7 -1
  107. package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
  108. package/src/core/math/physics/brdf/brdf_burley.js +9 -1
  109. package/src/core/math/physics/brdf/{D_GGX.d.ts → diffuse_GGX.d.ts} +2 -2
  110. package/src/core/math/physics/brdf/diffuse_GGX.d.ts.map +1 -0
  111. package/src/core/math/physics/brdf/{D_GGX.js → diffuse_GGX.js} +1 -1
  112. package/src/core/math/physics/brdf/fresnel_Schlick.d.ts +3 -0
  113. package/src/core/math/physics/brdf/fresnel_Schlick.d.ts.map +1 -0
  114. package/src/core/math/physics/brdf/fresnel_Schlick.js +3 -0
  115. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +9 -0
  116. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -0
  117. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +12 -0
  118. package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts +9 -0
  119. package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts.map +1 -0
  120. package/src/core/math/physics/brdf/fresnel_Schlick_original.js +10 -0
  121. package/src/core/math/physics/bsdf/bsdf_schlick.d.ts.map +1 -1
  122. package/src/core/math/physics/bsdf/bsdf_schlick.js +3 -11
  123. package/src/core/math/physics/ior_to_reflectivity.d.ts +7 -0
  124. package/src/core/math/physics/ior_to_reflectivity.d.ts.map +1 -0
  125. package/src/core/math/physics/ior_to_reflectivity.js +9 -0
  126. package/src/core/math/physics/pdf/README.md +1 -0
  127. package/src/core/math/physics/pdf/pdf_GGX.d.ts +16 -0
  128. package/src/core/math/physics/pdf/pdf_GGX.d.ts.map +1 -0
  129. package/src/core/math/physics/pdf/pdf_GGX.js +25 -0
  130. package/src/core/math/physics/reflectivity_to_ior.d.ts +7 -0
  131. package/src/core/math/physics/reflectivity_to_ior.d.ts.map +1 -0
  132. package/src/core/math/physics/reflectivity_to_ior.js +8 -0
  133. package/src/engine/EngineHarness.d.ts +10 -1
  134. package/src/engine/EngineHarness.d.ts.map +1 -1
  135. package/src/engine/EngineHarness.js +16 -11
  136. package/src/engine/asset/loaders/image/png/PNGReader.d.ts +25 -11
  137. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  138. package/src/engine/asset/loaders/image/png/PNGReader.js +38 -24
  139. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +2 -0
  140. package/src/engine/graphics/GraphicsEngine.js +1 -1
  141. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  142. package/src/engine/graphics/ecs/light/LightSystem.js +2 -3
  143. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +6 -0
  144. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  145. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +22 -11
  146. package/src/engine/graphics/render/forward_plus/model/DirectionalLight.d.ts.map +1 -1
  147. package/src/engine/graphics/render/forward_plus/model/DirectionalLight.js +25 -25
  148. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +9 -0
  149. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -0
  150. package/src/engine/graphics/sh3/fromCubeRenderTarget.js +145 -0
  151. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts +8 -0
  152. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts.map +1 -0
  153. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +51 -0
  154. package/src/engine/graphics/sh3/{LightProbeVolume.d.ts → lpv/LightProbeVolume.d.ts} +18 -7
  155. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -0
  156. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +340 -0
  157. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts +18 -0
  158. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
  159. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.js +44 -0
  160. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +12 -0
  161. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -0
  162. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +123 -0
  163. package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts +29 -0
  164. package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts.map +1 -0
  165. package/src/engine/graphics/sh3/lpv/ProbeRenderer.js +35 -0
  166. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts +27 -0
  167. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts.map +1 -0
  168. package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.js +158 -0
  169. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +11 -0
  170. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -0
  171. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +127 -0
  172. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +12 -0
  173. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -0
  174. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +89 -0
  175. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +90 -0
  176. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -0
  177. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +352 -0
  178. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +5 -91
  179. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  180. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +41 -477
  181. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts +1 -0
  182. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts.map +1 -1
  183. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.js +6 -3
  184. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +26 -58
  185. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +1 -1
  186. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +7 -1
  187. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
  188. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +1 -1
  189. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +1 -1
  190. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +3 -0
  191. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +1 -0
  192. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +3 -0
  193. package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.d.ts.map +1 -0
  194. package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.js → texture/apply_texture_clamping_to_coordinate.js} +2 -2
  195. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts +11 -0
  196. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -0
  197. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +86 -0
  198. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts +10 -0
  199. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -0
  200. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +56 -0
  201. package/src/engine/graphics/sh3/prototypeSH3Probe.js +87 -195
  202. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +5 -5
  203. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +1 -1
  204. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +8 -8
  205. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +13 -0
  206. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -0
  207. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +54 -0
  208. package/src/engine/graphics/texture/AttributeDataTexture.d.ts +2 -2
  209. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  210. package/src/engine/graphics/texture/AttributeDataTexture.js +11 -11
  211. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
  212. package/src/view/elements/ColorPickerView.d.ts.map +1 -1
  213. package/src/view/elements/ColorPickerView.js +7 -7
  214. package/src/core/geom/3d/tetrahedra/compute_circumsphere.d.ts.map +0 -1
  215. package/src/core/graph/coarsen_graph.d.ts.map +0 -1
  216. package/src/core/graph/coarsen_graph.spec.d.ts +0 -2
  217. package/src/core/graph/coarsen_graph.spec.d.ts.map +0 -1
  218. package/src/core/graph/graph_adjacency_matrix.d.ts +0 -9
  219. package/src/core/graph/graph_adjacency_matrix.d.ts.map +0 -1
  220. package/src/core/graph/graph_degree_matrix.d.ts +0 -9
  221. package/src/core/graph/graph_degree_matrix.d.ts.map +0 -1
  222. package/src/core/graph/graph_degree_matrix.js +0 -18
  223. package/src/core/graph/graph_laplacian_matrix.d.ts.map +0 -1
  224. package/src/core/math/physics/brdf/D_GGX.d.ts.map +0 -1
  225. package/src/engine/graphics/sh3/LightProbeVolume.d.ts.map +0 -1
  226. package/src/engine/graphics/sh3/LightProbeVolume.js +0 -609
  227. package/src/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.d.ts.map +0 -1
  228. package/src/engine/graphics/sh3/visualise_probe.d.ts +0 -12
  229. package/src/engine/graphics/sh3/visualise_probe.d.ts.map +0 -1
  230. package/src/engine/graphics/sh3/visualise_probe.js +0 -40
  231. /package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.d.ts → texture/apply_texture_clamping_to_coordinate.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {Array} a
4
- * @param {Array} b
3
+ * @param {Array|Uint8Array} a
4
+ * @param {Array|Uint8Array} b
5
5
  * @returns {boolean}
6
6
  */
7
7
  function isArrayEqualStrict(a, b) {
@@ -2047,6 +2047,7 @@ function v3_lerp(
2047
2047
 
2048
2048
  /**
2049
2049
  * Spherical linear interpolation
2050
+ * NOTE: vectors are assumed to be normalized
2050
2051
  * @see https://en.wikipedia.org/wiki/Slerp
2051
2052
  * @param {Vector3} result
2052
2053
  * @param {number} a_x
@@ -2669,6 +2670,7 @@ let Vector3$1 = class Vector3 {
2669
2670
  const y = this.y;
2670
2671
  const z = this.z;
2671
2672
 
2673
+ // This is just 3x3 matrix multiplication
2672
2674
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
2673
2675
  const _y = m4[1] * x + m4[5] * y + m4[9] * z;
2674
2676
  const _z = m4[2] * x + m4[6] * y + m4[10] * z;
@@ -53398,20 +53400,15 @@ function rgb2hex(r, g, b) {
53398
53400
 
53399
53401
  /**
53400
53402
  *
53401
- * @param {number} r 0 to 255
53402
- * @param {number} g 0 to 255
53403
- * @param {number} b 0 to 255
53403
+ * @param {number} r 0 to 1
53404
+ * @param {number} g 0 to 1
53405
+ * @param {number} b 0 to 1
53404
53406
  * @returns {{h: number, s: number, v: number}}
53405
53407
  */
53406
53408
  function rgb2hsv(r, g, b) {
53407
53409
 
53408
- const _r = uint82float(r);
53409
- const _g = uint82float(g);
53410
- const _b = uint82float(b);
53411
-
53412
-
53413
- const max = Math.max(_r, _g, _b);
53414
- const min = Math.min(_r, _g, _b);
53410
+ const max = Math.max(r, g, b);
53411
+ const min = Math.min(r, g, b);
53415
53412
 
53416
53413
  let h, s, v = max;
53417
53414
 
@@ -53423,14 +53420,14 @@ function rgb2hsv(r, g, b) {
53423
53420
  h = 0; // achromatic
53424
53421
  } else {
53425
53422
  switch (max) {
53426
- case _r:
53427
- h = (_g - _b) / d + (_g < _b ? 6 : 0);
53423
+ case r:
53424
+ h = (g - b) / d + (g < b ? 6 : 0);
53428
53425
  break;
53429
- case _g:
53430
- h = (_b - _r) / d + 2;
53426
+ case g:
53427
+ h = (b - r) / d + 2;
53431
53428
  break;
53432
- case _b:
53433
- h = (_r - _g) / d + 4;
53429
+ case b:
53430
+ h = (r - g) / d + 4;
53434
53431
  break;
53435
53432
  }
53436
53433
 
@@ -53630,6 +53627,17 @@ function rgb2uint24(r, g, b) {
53630
53627
  ;
53631
53628
  }
53632
53629
 
53630
+ /**
53631
+ *
53632
+ * @param {number} r
53633
+ * @param {number} g
53634
+ * @param {number} b
53635
+ * @return {number}
53636
+ */
53637
+ function rgb_to_luminance(r, g, b) {
53638
+ return 0.299 * r + 0.587 * g + 0.114 * b;
53639
+ }
53640
+
53633
53641
  function convert(c) {
53634
53642
  if (c < 0.0031308) {
53635
53643
  return c * 12.92;
@@ -54084,11 +54092,15 @@ class Color {
54084
54092
  * @return {number}
54085
54093
  */
54086
54094
  computeLuminance() {
54087
- return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b;
54095
+ return rgb_to_luminance(this.r, this.g, this.b);
54088
54096
  }
54089
54097
 
54090
54098
  getHSV() {
54091
- return rgb2hsv(this.r * 255, this.g * 255, this.b * 255);
54099
+ return rgb2hsv(
54100
+ this.r,
54101
+ this.g,
54102
+ this.b
54103
+ );
54092
54104
  }
54093
54105
 
54094
54106
  /**
@@ -75663,7 +75675,9 @@ const TextureAttachmentsByMaterialType = {
75663
75675
  }
75664
75676
  })
75665
75677
  ]
75666
- };
75678
+ };
75679
+
75680
+ TextureAttachmentsByMaterialType.MeshPhysicalMaterial = TextureAttachmentsByMaterialType.MeshStandardMaterial;
75667
75681
 
75668
75682
  /**
75669
75683
  * Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
@@ -90630,6 +90644,7 @@ class GraphicsEngine {
90630
90644
  const camera = this.camera;
90631
90645
 
90632
90646
  if (scene.children.indexOf(camera) < 0) {
90647
+ // console.log("added camera");
90633
90648
  scene.add(camera);
90634
90649
  }
90635
90650
 
@@ -112369,6 +112384,27 @@ function scene_object_filter(object3D) {
112369
112384
  return true;
112370
112385
  }
112371
112386
 
112387
+ /**
112388
+ *
112389
+ * @param {LightShadow} shadow
112390
+ * @param {number} resolution
112391
+ */
112392
+ function three_set_shadow_resolution(shadow, resolution) {
112393
+ const mapSize = shadow.mapSize;
112394
+
112395
+ if (mapSize.width !== resolution || mapSize.height !== resolution) {
112396
+
112397
+ mapSize.width = mapSize.height = resolution;
112398
+
112399
+ //destroy old map
112400
+ if (shadow.map !== null) {
112401
+ shadow.map.dispose(); // important
112402
+ shadow.map = null;
112403
+ }
112404
+
112405
+ }
112406
+ }
112407
+
112372
112408
  class ThreeLightBinding extends LightBinding {
112373
112409
 
112374
112410
  constructor() {
@@ -112633,17 +112669,7 @@ class ThreeLightBinding extends LightBinding {
112633
112669
  shadow.radius = 1;
112634
112670
  shadow.blurSamples = 8;
112635
112671
 
112636
- if (shadow.mapSize.width !== resolution || shadow.mapSize.height !== resolution) {
112637
-
112638
- shadow.mapSize.width = shadow.mapSize.height = resolution;
112639
-
112640
- //destroy old map
112641
- if (shadow.map !== null) {
112642
- shadow.map.dispose(); // important
112643
- shadow.map = null;
112644
- }
112645
-
112646
- }
112672
+ three_set_shadow_resolution(shadow, resolution);
112647
112673
 
112648
112674
  }
112649
112675
  }
@@ -113271,7 +113297,7 @@ class LightSystem extends AbstractContextSystem {
113271
113297
 
113272
113298
  l.castShadow = true;
113273
113299
 
113274
- updateShadowMap(this.__camera_object, l, this.__graphics);
113300
+ three_update_shadow_camera_extents(this.__camera_object, l, this.__graphics);
113275
113301
 
113276
113302
  } else {
113277
113303
 
@@ -113322,9 +113348,8 @@ const scratch_aabb3 = new AABB3();
113322
113348
  * @author Alex Goldring 02.06.2016 (Komrade)
113323
113349
  * @param {Camera} camera
113324
113350
  * @param {Light} light
113325
- * @param {GraphicsEngine} graphics
113326
113351
  */
113327
- function updateShadowMap(camera, light, graphics) {
113352
+ function three_update_shadow_camera_extents(camera, light) {
113328
113353
 
113329
113354
 
113330
113355
  // Fit shadow camera's ortho frustum to camera frustum
@@ -114546,6 +114571,8 @@ class InputControllerSystem extends System {
114546
114571
 
114547
114572
  this.devices = devices;
114548
114573
 
114574
+ // console.log("Input Controller System started. Devices: ", devices);
114575
+
114549
114576
  const self = this;
114550
114577
 
114551
114578
  this.enabled.onChanged.add(function (v) {
@@ -115842,12 +115869,21 @@ class EngineHarness {
115842
115869
  * @param {EntityComponentDataset} [param.ecd]
115843
115870
  * @param {number} [param.shadowmapResolution]
115844
115871
  * @param {boolean} [param.castShadow]
115872
+ * @param {Color} [param.sun]
115873
+ * @param {number} [param.sunIntensity]
115874
+ * @param {Color} [param.ambient]
115875
+ * @param {number} [param.ambientIntensity]
115845
115876
  */
115846
115877
  static async buildLights({
115847
115878
  engine,
115848
115879
  ecd = engine.entityManager.dataset,
115849
115880
  shadowmapResolution = 1024,
115850
- castShadow = true
115881
+ castShadow = true,
115882
+ sun = Color.white,
115883
+ sunIntensity = 0.9,
115884
+ sunDirection = new Vector3$1(0.1, -1, 0.1),
115885
+ ambient = Color.white,
115886
+ ambientIntensity = 0.1
115851
115887
  }) {
115852
115888
  const em = engine.entityManager;
115853
115889
 
@@ -115863,18 +115899,13 @@ class EngineHarness {
115863
115899
 
115864
115900
  const key = new Light();
115865
115901
  key.type.set(Light.Type.DIRECTION);
115866
- key.color.setRGB(1, 1, 1);
115867
- key.intensity.set(0.8);
115902
+ key.color.copy(sun);
115903
+ key.intensity.set(sunIntensity);
115868
115904
  key.castShadow.set(castShadow);
115869
115905
 
115870
115906
  const transform = new Transform();
115871
115907
  transform.position.set(30, 70, 30);
115872
- transform.rotation.set(
115873
- -0.18780341950959473,
115874
- 0.8049745556929917,
115875
- -0.4533975611897181,
115876
- -0.3334313787830773
115877
- );
115908
+ transform.rotation.lookRotation(sunDirection);
115878
115909
 
115879
115910
  new Entity()
115880
115911
  .add(key)
@@ -115885,8 +115916,8 @@ class EngineHarness {
115885
115916
 
115886
115917
  const fill = new Light();
115887
115918
  fill.type.set(Light.Type.AMBIENT);
115888
- fill.color.setRGB(1, 1, 1);
115889
- fill.intensity.set(0.1);
115919
+ fill.color.copy(ambient);
115920
+ fill.intensity.set(ambientIntensity);
115890
115921
 
115891
115922
 
115892
115923
  new Entity()
@@ -117664,4 +117695,4 @@ function v4_distance_sqr(
117664
117695
  return v4_length_sqr(x0 - x1, y0 - y1, z0 - z1, w0 - w1);
117665
117696
  }
117666
117697
 
117667
- export { AmbientOcclusionPostProcessEffect, Behavior, BehaviorStatus, Blackboard, Cache, EngineConfiguration, EngineHarness, ForwardPlusRenderingPlugin, HashMap, Light, ParallelBehavior, ParallelBehaviorPolicy, SGMesh, SGMeshSystem, SelectorBehavior, SequenceBehavior, ShadedGeometry, ShadedGeometrySystem, Signal, SignalBinding, Transform, dispatchViaProxy, findSignalHandlerIndexByHandle, findSignalHandlerIndexByHandleAndContext, find_path_on_grid_astar, quat3_createFromAxisAngle, v2_angle_between, v2_bearing_angle_towards, v2_distance, v2_dot, v2_length_sqr, v2_magnitude, v4_distance_sqr, v4_dot, v4_length_sqr, v4_multiply_mat4 };
117698
+ export { AmbientOcclusionPostProcessEffect, Behavior, BehaviorStatus, Blackboard, Cache, EngineConfiguration, EngineHarness, ForwardPlusRenderingPlugin, HashMap, Light, ParallelBehavior, ParallelBehaviorPolicy, SGMesh, SGMeshSystem, SelectorBehavior, SequenceBehavior, ShadedGeometry, ShadedGeometrySystem, Signal, SignalBinding, Transform, dispatchViaProxy, findSignalHandlerIndexByHandle, findSignalHandlerIndexByHandleAndContext, find_path_on_grid_astar, quat3_createFromAxisAngle, three_update_shadow_camera_extents, v2_angle_between, v2_bearing_angle_towards, v2_distance, v2_dot, v2_length_sqr, v2_magnitude, v4_distance_sqr, v4_dot, v4_length_sqr, v4_multiply_mat4 };
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.107.0",
8
+ "version": "2.108.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -3,8 +3,9 @@
3
3
  * @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
4
4
  * @example 1024 -> "00000000 00000000 00000100 00000000"
5
5
  * @example -1 -> "11111111 11111111 11111111 11111111"
6
- * @param {number} nMask
6
+ * @param {number} input_value
7
+ * @param {string} [byte_separator] insert this string between each group of 8 bits
7
8
  * @returns {string}
8
9
  */
9
- export function int32_to_binary_string(nMask: number): string;
10
+ export function int32_to_binary_string(input_value: number, byte_separator?: string): string;
10
11
  //# sourceMappingURL=int32_to_binary_string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AACH,8CAHW,MAAM,GACJ,MAAM,CAuBlB"}
1
+ {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,oDAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CA4BlB"}
@@ -1,7 +1,5 @@
1
1
  import { assert } from "../assert.js";
2
2
 
3
- const RX = /\B(?=(.{8})+(?!.))/g;
4
-
5
3
  /**
6
4
  * 2147483647
7
5
  * @type {number}
@@ -19,28 +17,34 @@ const MIN_VALUE = -1 * (2 ** 31);
19
17
  * @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
20
18
  * @example 1024 -> "00000000 00000000 00000100 00000000"
21
19
  * @example -1 -> "11111111 11111111 11111111 11111111"
22
- * @param {number} nMask
20
+ * @param {number} input_value
21
+ * @param {string} [byte_separator] insert this string between each group of 8 bits
23
22
  * @returns {string}
24
23
  */
25
- export function int32_to_binary_string(nMask) {
24
+ export function int32_to_binary_string(input_value, byte_separator = " ") {
26
25
  // nMask must be between -2147483648 and 2147483647
27
- if (nMask > MAX_VALUE) {
26
+ if (input_value > MAX_VALUE) {
28
27
  throw "number too large. number shouldn't be > 2**31-1";//added
29
28
  }
30
- if (nMask < MIN_VALUE) {
29
+ if (input_value < MIN_VALUE) {
31
30
  throw "number too far negative, number shouldn't be < 2**31"//added
32
31
  }
33
32
 
34
- assert.isInteger(nMask, 'nMask');
33
+ assert.isInteger(input_value, 'input_value');
35
34
 
36
- let nFlag = 0, nShifted = nMask, sMask = '';
35
+ let result = '';
37
36
 
38
- for (; nFlag < 32;
39
- nFlag++, sMask += String(nShifted >>> 31), nShifted <<= 1
40
- ) {
41
- }
37
+ for (let bit_index = 0; bit_index < 32; bit_index++) {
38
+
39
+ if (bit_index > 0 && bit_index % 8 === 0) {
40
+ result += byte_separator;
41
+ }
42
42
 
43
- sMask = sMask.replace(RX, " ") // added
43
+ const bit_value = (input_value << bit_index) >>> 31;
44
+
45
+ result += String(bit_value);
46
+
47
+ }
44
48
 
45
- return sMask;
49
+ return result;
46
50
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=split_by_3.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split_by_3.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/split_by_3.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { int32_to_binary_string } from "./int32_to_binary_string.js";
2
+ import { split_by_3 } from "./split_by_3.js";
3
+
4
+ test("zero", () => {
5
+
6
+ expect(split_by_3(0)).toEqual(0);
7
+
8
+ });
9
+
10
+ test("max value", () => {
11
+
12
+ expect(
13
+ int32_to_binary_string(split_by_3(0xFFFFFFFF))
14
+ ).toEqual("00001001 00100100 10010010 01001001");
15
+
16
+ });
17
+
18
+ test("max 10bit value",()=>{
19
+ expect(
20
+ int32_to_binary_string(split_by_3(0b1111111111))
21
+ ).toEqual("00001001 00100100 10010010 01001001");
22
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"to_half_float_uint16.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/to_half_float_uint16.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,0CAHW,MAAM,GACJ,MAAM,CAyDlB"}
1
+ {"version":3,"file":"to_half_float_uint16.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/to_half_float_uint16.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,0CAHW,MAAM,GACJ,MAAM,CA2DlB"}
@@ -20,9 +20,10 @@ export function to_half_float_uint16(val) {
20
20
 
21
21
  // Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410
22
22
 
23
- /* This method is faster than the OpenEXR implementation (very often
24
- * used, eg. in Ogre), with the additional benefit of rounding, inspired
25
- * by James Tursa?s half-precision code. */
23
+ /*
24
+ This method is faster than the OpenEXR implementation (very often used, eg. in Ogre),
25
+ with the additional benefit of rounding, inspired by James Tursa's half-precision code.
26
+ */
26
27
 
27
28
  _floatView[0] = _val;
28
29
  const x = _int32View[0];
@@ -58,8 +59,9 @@ export function to_half_float_uint16(val) {
58
59
  }
59
60
 
60
61
  bits |= ((e - 112) << 10) | (m >> 1);
61
- /* Extra rounding. An overflow will set mantissa to 0 and increment
62
- * the exponent, which is OK. */
62
+
63
+ /* Extra rounding. An overflow will set mantissa to 0 and increment the exponent, which is OK. */
64
+
63
65
  bits += m & 1;
64
66
  return bits;
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"isArrayEqualStrict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqualStrict.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wDAFa,OAAO,CAsBnB"}
1
+ {"version":3,"file":"isArrayEqualStrict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqualStrict.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sCAJW,QAAM,UAAU,KAChB,QAAM,UAAU,GACd,OAAO,CAsBnB"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  *
3
- * @param {Array} a
4
- * @param {Array} b
3
+ * @param {Array|Uint8Array} a
4
+ * @param {Array|Uint8Array} b
5
5
  * @returns {boolean}
6
6
  */
7
7
  export function isArrayEqualStrict(a, b) {
@@ -1 +1 @@
1
- {"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"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"}
@@ -11,6 +11,7 @@ import { rgb2hex } from "./hex/rgb2hex.js";
11
11
  import { rgb2hsv } from "./hsv/rgb2hsv.js";
12
12
  import { parse_color } from "./parse_color.js";
13
13
  import { rgb2uint24 } from "./rgb2uint24.js";
14
+ import { rgb_to_luminance } from "./rgb_to_luminance.js";
14
15
  import { linear_to_sRGB } from "./sRGB/linear_to_sRGB.js";
15
16
  import { sRGB_to_linear } from "./sRGB/sRGB_to_linear.js";
16
17
 
@@ -420,11 +421,15 @@ export class Color {
420
421
  * @return {number}
421
422
  */
422
423
  computeLuminance() {
423
- return 0.299 * this.r + 0.587 * this.g + 0.114 * this.b;
424
+ return rgb_to_luminance(this.r, this.g, this.b);
424
425
  }
425
426
 
426
427
  getHSV() {
427
- return rgb2hsv(this.r * 255, this.g * 255, this.b * 255);
428
+ return rgb2hsv(
429
+ this.r,
430
+ this.g,
431
+ this.b
432
+ );
428
433
  }
429
434
 
430
435
  /**
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  *
3
- * @param {number} r 0 to 255
4
- * @param {number} g 0 to 255
5
- * @param {number} b 0 to 255
3
+ * @param {number} r 0 to 1
4
+ * @param {number} g 0 to 1
5
+ * @param {number} b 0 to 1
6
6
  * @returns {{h: number, s: number, v: number}}
7
7
  */
8
8
  export function rgb2hsv(r: number, g: number, b: number): {
@@ -1 +1 @@
1
- {"version":3,"file":"rgb2hsv.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/hsv/rgb2hsv.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,2BALW,MAAM,KACN,MAAM,KACN,MAAM;OACA,MAAM;OAAK,MAAM;OAAK,MAAM;EAyC5C"}
1
+ {"version":3,"file":"rgb2hsv.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/hsv/rgb2hsv.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,2BALW,MAAM,KACN,MAAM,KACN,MAAM;OACA,MAAM;OAAK,MAAM;OAAK,MAAM;EAoC5C"}
@@ -1,21 +1,14 @@
1
- import { uint82float } from "../../binary/uint82float.js";
2
-
3
1
  /**
4
2
  *
5
- * @param {number} r 0 to 255
6
- * @param {number} g 0 to 255
7
- * @param {number} b 0 to 255
3
+ * @param {number} r 0 to 1
4
+ * @param {number} g 0 to 1
5
+ * @param {number} b 0 to 1
8
6
  * @returns {{h: number, s: number, v: number}}
9
7
  */
10
8
  export function rgb2hsv(r, g, b) {
11
9
 
12
- const _r = uint82float(r);
13
- const _g = uint82float(g);
14
- const _b = uint82float(b);
15
-
16
-
17
- const max = Math.max(_r, _g, _b);
18
- const min = Math.min(_r, _g, _b);
10
+ const max = Math.max(r, g, b);
11
+ const min = Math.min(r, g, b);
19
12
 
20
13
  let h, s, v = max;
21
14
 
@@ -27,14 +20,14 @@ export function rgb2hsv(r, g, b) {
27
20
  h = 0; // achromatic
28
21
  } else {
29
22
  switch (max) {
30
- case _r:
31
- h = (_g - _b) / d + (_g < _b ? 6 : 0);
23
+ case r:
24
+ h = (g - b) / d + (g < b ? 6 : 0);
32
25
  break;
33
- case _g:
34
- h = (_b - _r) / d + 2;
26
+ case g:
27
+ h = (b - r) / d + 2;
35
28
  break;
36
- case _b:
37
- h = (_r - _g) / d + 4;
29
+ case b:
30
+ h = (r - g) / d + 4;
38
31
  break;
39
32
  }
40
33
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {number} r
4
+ * @param {number} g
5
+ * @param {number} b
6
+ * @return {number}
7
+ */
8
+ export function rgb_to_luminance(r: number, g: number, b: number): number;
9
+ //# sourceMappingURL=rgb_to_luminance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgb_to_luminance.d.ts","sourceRoot":"","sources":["../../../../src/core/color/rgb_to_luminance.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oCALW,MAAM,KACN,MAAM,KACN,MAAM,GACL,MAAM,CAIjB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {number} r
4
+ * @param {number} g
5
+ * @param {number} b
6
+ * @return {number}
7
+ */
8
+ export function rgb_to_luminance(r, g, b) {
9
+ return 0.299 * r + 0.587 * g + 0.114 * b;
10
+ }
@@ -8,8 +8,22 @@ There are basically 3 approaches,
8
8
  * Optimization of the polynomial (generally to remove negative values)
9
9
  * Piece-wise reconstruction
10
10
 
11
+ ## Coefficients of SH basis
12
+ see [3] (Stupid Spherical Harmonics)
13
+
14
+ 1.0 / (2.0 * M_SQRT_PI), // 0: 0 0
15
+ -M_SQRT_3 / (2.0 * M_SQRT_PI), // 1: 1 -1
16
+ M_SQRT_3 / (2.0 * M_SQRT_PI), // 2: 1 0
17
+ -M_SQRT_3 / (2.0 * M_SQRT_PI), // 3: 1 1
18
+ M_SQRT_15 / (2.0 * M_SQRT_PI), // 4: 2 -2
19
+ -M_SQRT_15 / (2.0 * M_SQRT_PI), // 5: 2 -1
20
+ M_SQRT_5 / (4.0 * M_SQRT_PI), // 6: 2 0
21
+ -M_SQRT_15 / (2.0 * M_SQRT_PI), // 7: 2 1
22
+ M_SQRT_15 / (4.0 * M_SQRT_PI) // 8: 2 2
23
+
11
24
  ### References:
12
25
 
13
26
  ---
14
- * 2008 - GDC - Stupid Spherical Harmonics (SH) Tricks by Peter-Pike Sloan
15
- * [Computing product of 2 sphecial harmonics](https://github.com/ruba/cortex-vfx/blob/c256b7274516a02fa64a0260351b86f1d6ebe8c2/include/IECore/SphericalHarmonicsAlgo.inl)
27
+ * [1] 2008 - GDC - Stupid Spherical Harmonics (SH) Tricks by Peter-Pike Sloan
28
+ * [2] [Computing product of 2 sphecial harmonics](https://github.com/ruba/cortex-vfx/blob/c256b7274516a02fa64a0260351b86f1d6ebe8c2/include/IECore/SphericalHarmonicsAlgo.inl)
29
+ * [3] Stupid Spherical Harmonics
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @readonly
3
+ * @type {Float32Array}
4
+ */
5
+ export const SH3_COEFFICIENTS: Float32Array;
6
+ //# sourceMappingURL=SH3_COEFFICIENTS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SH3_COEFFICIENTS.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+BAFU,YAAY,CAYnB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @readonly
3
+ * @type {Float32Array}
4
+ */
5
+ export const SH3_COEFFICIENTS = new Float32Array([
6
+ 0.28209479177387814, // 0: 0 0
7
+ -0.4886025119029199, // 1: 1 -1
8
+ 0.4886025119029199, // 2: 1 0
9
+ -0.4886025119029199, // 3: 1 1
10
+ 1.0925484305920792, // 4: 2 -2
11
+ -1.0925484305920792, // 5: 2 -1
12
+ 0.31539156525252005, // 6: 2 0
13
+ -1.0925484305920792, // 7: 2 1
14
+ 0.5462742152960396 // 8: 2 2
15
+ ]);
@@ -1 +1 @@
1
- {"version":3,"file":"sh3_basis_at.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/sphere/harmonics/sh3_basis_at.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,gCALW,MAAM,KACN,MAAM,KACN,MAAM,WACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,QAsB9D"}
1
+ {"version":3,"file":"sh3_basis_at.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/sphere/harmonics/sh3_basis_at.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,gCALW,MAAM,KACN,MAAM,KACN,MAAM,WACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,QA+B9D"}