@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.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/meep.cjs +78 -46
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +78 -47
- package/package.json +1 -1
- package/src/core/binary/int32_to_binary_string.d.ts +3 -2
- package/src/core/binary/int32_to_binary_string.d.ts.map +1 -1
- package/src/core/binary/int32_to_binary_string.js +18 -14
- package/src/core/binary/split_by_3.spec.d.ts +2 -0
- package/src/core/binary/split_by_3.spec.d.ts.map +1 -0
- package/src/core/binary/split_by_3.spec.js +22 -0
- package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
- package/src/core/binary/to_half_float_uint16.js +7 -5
- package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
- package/src/core/collection/array/isArrayEqualStrict.js +2 -2
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +7 -2
- package/src/core/color/hsv/rgb2hsv.d.ts +3 -3
- package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
- package/src/core/color/hsv/rgb2hsv.js +11 -18
- package/src/core/color/rgb_to_luminance.d.ts +9 -0
- package/src/core/color/rgb_to_luminance.d.ts.map +1 -0
- package/src/core/color/rgb_to_luminance.js +10 -0
- package/src/core/geom/3d/sphere/harmonics/README.md +16 -2
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts +6 -0
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +15 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.js +21 -9
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts +3 -3
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +35 -206
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.js +29 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +10 -10
- package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_index.js +9 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +44 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +86 -0
- package/src/core/geom/3d/sphere/in_sphere3d_robust.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/in_sphere3d_robust.js +2 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +20 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +53 -7
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +2 -2
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts +1 -1
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js +12 -7
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts +13 -0
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +135 -0
- package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +38 -24
- package/src/core/geom/3d/tetrahedra/{compute_circumsphere.d.ts → tetrahedron_compute_circumsphere.d.ts} +3 -5
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/{compute_circumsphere.js → tetrahedron_compute_circumsphere.js} +2 -4
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +3 -1
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +1 -0
- package/src/core/geom/mat3/m3_multiply_vec3.d.ts +8 -0
- package/src/core/geom/mat3/m3_multiply_vec3.d.ts.map +1 -0
- package/src/core/geom/mat3/m3_multiply_vec3.js +21 -0
- package/src/core/geom/vec2/v2_cross_product.d.ts +15 -0
- package/src/core/geom/vec2/v2_cross_product.d.ts.map +1 -0
- package/src/core/geom/vec2/v2_cross_product.js +21 -0
- package/src/core/geom/vec3/v3_slerp.d.ts +1 -0
- package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_slerp.js +1 -0
- package/src/core/graph/MultiNode.d.ts +1 -1
- package/src/core/graph/MultiNode.js +1 -1
- package/src/core/graph/WeightedEdge.d.ts +6 -4
- package/src/core/graph/WeightedEdge.d.ts.map +1 -1
- package/src/core/graph/WeightedEdge.js +3 -0
- package/src/core/graph/coloring/colorizeGraph.js +19 -19
- package/src/core/graph/convert_graph_to_dot_string.d.ts +1 -1
- package/src/core/graph/convert_graph_to_dot_string.d.ts.map +1 -1
- package/src/core/graph/convert_graph_to_dot_string.js +10 -6
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts +9 -0
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -0
- package/src/core/graph/{graph_adjacency_matrix.js → graph_compute_adjacency_matrix.js} +1 -2
- package/src/core/graph/graph_compute_degree_matrix.d.ts +10 -0
- package/src/core/graph/graph_compute_degree_matrix.d.ts.map +1 -0
- package/src/core/graph/graph_compute_degree_matrix.js +23 -0
- package/src/core/graph/graph_compute_distance_matrix.d.ts +13 -0
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -0
- package/src/core/graph/graph_compute_distance_matrix.js +103 -0
- package/src/core/graph/{graph_laplacian_matrix.d.ts → graph_compute_laplacian_matrix.d.ts} +2 -2
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -0
- package/src/core/graph/{graph_laplacian_matrix.js → graph_compute_laplacian_matrix.js} +6 -6
- package/src/core/graph/graph_k_means_cluster.d.ts.map +1 -1
- package/src/core/graph/graph_k_means_cluster.js +4 -119
- package/src/core/graph/{coarsen_graph.d.ts → mn_graph_coarsen.d.ts} +2 -2
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -0
- package/src/core/graph/{coarsen_graph.js → mn_graph_coarsen.js} +1 -1
- package/src/core/graph/mn_graph_coarsen.spec.d.ts +2 -0
- package/src/core/graph/mn_graph_coarsen.spec.d.ts.map +1 -0
- package/src/core/graph/{coarsen_graph.spec.js → mn_graph_coarsen.spec.js} +4 -4
- package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts +1 -0
- package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts.map +1 -1
- package/src/core/graph/mn_graph_collapse_weighted_edge.js +7 -1
- package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
- package/src/core/math/physics/brdf/brdf_burley.js +9 -1
- package/src/core/math/physics/brdf/{D_GGX.d.ts → diffuse_GGX.d.ts} +2 -2
- package/src/core/math/physics/brdf/diffuse_GGX.d.ts.map +1 -0
- package/src/core/math/physics/brdf/{D_GGX.js → diffuse_GGX.js} +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick.d.ts +3 -0
- package/src/core/math/physics/brdf/fresnel_Schlick.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick.js +3 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +9 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +12 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts +9 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.js +10 -0
- package/src/core/math/physics/bsdf/bsdf_schlick.d.ts.map +1 -1
- package/src/core/math/physics/bsdf/bsdf_schlick.js +3 -11
- package/src/core/math/physics/ior_to_reflectivity.d.ts +7 -0
- package/src/core/math/physics/ior_to_reflectivity.d.ts.map +1 -0
- package/src/core/math/physics/ior_to_reflectivity.js +9 -0
- package/src/core/math/physics/pdf/README.md +1 -0
- package/src/core/math/physics/pdf/pdf_GGX.d.ts +16 -0
- package/src/core/math/physics/pdf/pdf_GGX.d.ts.map +1 -0
- package/src/core/math/physics/pdf/pdf_GGX.js +25 -0
- package/src/core/math/physics/reflectivity_to_ior.d.ts +7 -0
- package/src/core/math/physics/reflectivity_to_ior.d.ts.map +1 -0
- package/src/core/math/physics/reflectivity_to_ior.js +8 -0
- package/src/engine/EngineHarness.d.ts +10 -1
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +16 -11
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts +25 -11
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNGReader.js +38 -24
- package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +2 -0
- package/src/engine/graphics/GraphicsEngine.js +1 -1
- package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/LightSystem.js +2 -3
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +6 -0
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +22 -11
- package/src/engine/graphics/render/forward_plus/model/DirectionalLight.d.ts.map +1 -1
- package/src/engine/graphics/render/forward_plus/model/DirectionalLight.js +25 -25
- package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +9 -0
- package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -0
- package/src/engine/graphics/sh3/fromCubeRenderTarget.js +145 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +51 -0
- package/src/engine/graphics/sh3/{LightProbeVolume.d.ts → lpv/LightProbeVolume.d.ts} +18 -7
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +340 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts +18 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.js +44 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +123 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts +29 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.js +35 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts +27 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.js +158 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +11 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +127 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +89 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +90 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +352 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +5 -91
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +41 -477
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts +1 -0
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.js +6 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +26 -58
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +7 -1
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +3 -0
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +3 -0
- package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.js → texture/apply_texture_clamping_to_coordinate.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts +11 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +86 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +56 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +87 -195
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +5 -5
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +1 -1
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +8 -8
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +13 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +54 -0
- package/src/engine/graphics/texture/AttributeDataTexture.d.ts +2 -2
- package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
- package/src/engine/graphics/texture/AttributeDataTexture.js +11 -11
- package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
- package/src/view/elements/ColorPickerView.d.ts.map +1 -1
- package/src/view/elements/ColorPickerView.js +7 -7
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.d.ts.map +0 -1
- package/src/core/graph/coarsen_graph.d.ts.map +0 -1
- package/src/core/graph/coarsen_graph.spec.d.ts +0 -2
- package/src/core/graph/coarsen_graph.spec.d.ts.map +0 -1
- package/src/core/graph/graph_adjacency_matrix.d.ts +0 -9
- package/src/core/graph/graph_adjacency_matrix.d.ts.map +0 -1
- package/src/core/graph/graph_degree_matrix.d.ts +0 -9
- package/src/core/graph/graph_degree_matrix.d.ts.map +0 -1
- package/src/core/graph/graph_degree_matrix.js +0 -18
- package/src/core/graph/graph_laplacian_matrix.d.ts.map +0 -1
- package/src/core/math/physics/brdf/D_GGX.d.ts.map +0 -1
- package/src/engine/graphics/sh3/LightProbeVolume.d.ts.map +0 -1
- package/src/engine/graphics/sh3/LightProbeVolume.js +0 -609
- package/src/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.d.ts.map +0 -1
- package/src/engine/graphics/sh3/visualise_probe.d.ts +0 -12
- package/src/engine/graphics/sh3/visualise_probe.d.ts.map +0 -1
- package/src/engine/graphics/sh3/visualise_probe.js +0 -40
- /package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.d.ts → texture/apply_texture_clamping_to_coordinate.d.ts} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Math.sqrt(3)
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
5
|
+
const SQRT_3 = 1.7320508075688772;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Float32Array} M 5x5 matrix
|
|
10
|
+
* @param {number[]} x vec5
|
|
11
|
+
* @return {number[]} vec5
|
|
12
|
+
*/
|
|
13
|
+
function multiply_5d(M, x) {
|
|
14
|
+
return [
|
|
15
|
+
M[0] * x[0] + M[5] * x[1] + M[10] * x[2] + M[15] * x[3] + M[20] * x[4],
|
|
16
|
+
M[1] * x[0] + M[6] * x[1] + M[11] * x[2] + M[16] * x[3] + M[21] * x[4],
|
|
17
|
+
M[2] * x[0] + M[7] * x[1] + M[12] * x[2] + M[17] * x[3] + M[22] * x[4],
|
|
18
|
+
M[3] * x[0] + M[8] * x[1] + M[13] * x[2] + M[18] * x[3] + M[23] * x[4],
|
|
19
|
+
M[4] * x[0] + M[9] * x[1] + M[14] * x[2] + M[19] * x[3] + M[24] * x[4]
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This projects a vec3 to SH2/k space (i.e. we premultiply by 1/k)
|
|
25
|
+
* these are second band SH factors, multiplied by 1/K ( K = Math.sqrt(15) / (2*Math.sqrt(Math.PI)) )
|
|
26
|
+
* @param {number[]|Float32Array} output
|
|
27
|
+
* @param {number} output_offset
|
|
28
|
+
* @param {number} x
|
|
29
|
+
* @param {number} y
|
|
30
|
+
* @param {number} z
|
|
31
|
+
*/
|
|
32
|
+
function project_v3_to_sh2k(output, output_offset, x, y, z) {
|
|
33
|
+
output[output_offset] = (y * x)
|
|
34
|
+
output[output_offset + 1] = -(y * z)
|
|
35
|
+
output[output_offset + 2] = 0.28867513459481287 * (3 * z * z - 1)
|
|
36
|
+
output[output_offset + 3] = -(z * x)
|
|
37
|
+
output[output_offset + 4] = 0.5 * (x * x - y * y)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {number[]} band2 vec5
|
|
43
|
+
* @param {number[]} M mat3
|
|
44
|
+
* @return {number[]} vec5
|
|
45
|
+
*/
|
|
46
|
+
export function sh_rotate_band2(band2, M) {
|
|
47
|
+
const n = Math.SQRT1_2;
|
|
48
|
+
|
|
49
|
+
// Below we precompute (with help of Mathematica):
|
|
50
|
+
// constexpr float3 N0{ 1, 0, 0 };
|
|
51
|
+
// constexpr float3 N1{ 0, 0, 1 };
|
|
52
|
+
// constexpr float3 N2{ n, n, 0 };
|
|
53
|
+
// constexpr float3 N3{ n, 0, n };
|
|
54
|
+
// constexpr float3 N4{ 0, n, n };
|
|
55
|
+
// constexpr float M_SQRT_PI = 1.7724538509f;
|
|
56
|
+
// constexpr float M_SQRT_15 = 3.8729833462f;
|
|
57
|
+
// constexpr float k = M_SQRT_15 / (2.0f * M_SQRT_PI);
|
|
58
|
+
// --> k * inverse(mat5{project(N0), project(N1), project(N2), project(N3), project(N4)})
|
|
59
|
+
const invATimesK = [
|
|
60
|
+
0, 1, 2, 0, 0,
|
|
61
|
+
-1, 0, 0, 0, -2,
|
|
62
|
+
0, SQRT_3, 0, 0, 0,
|
|
63
|
+
1, 1, 0, -2, 0,
|
|
64
|
+
2, 1, 0, 0, 0
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// this is: invA * k * band2
|
|
68
|
+
// 5x5 matrix by vec5 (this a lot of zeroes and constants, which the compiler should eliminate)
|
|
69
|
+
const invATimesKTimesBand2 = multiply_5d(invATimesK, band2);
|
|
70
|
+
|
|
71
|
+
// this is: mat5{project(N0), project(N1), project(N2), project(N3), project(N4)} / k
|
|
72
|
+
// (the 1/k comes from project(), see above)
|
|
73
|
+
const ROverK = new Float32Array(25);
|
|
74
|
+
|
|
75
|
+
project_v3_to_sh2k(ROverK, 0, M[0], M[1], M[2]) // M * N0
|
|
76
|
+
project_v3_to_sh2k(ROverK, 5, M[6], M[7], M[8]) // M * N1
|
|
77
|
+
project_v3_to_sh2k(ROverK, 10, n * (M[0] + M[3]), n * (M[1] + M[4]), n * (M[2] + M[5])) // M * N2
|
|
78
|
+
project_v3_to_sh2k(ROverK, 15, n * (M[0] + M[6]), n * (M[1] + M[7]), n * (M[2] + M[8])) // M * N3
|
|
79
|
+
project_v3_to_sh2k(ROverK, 20, n * (M[3] + M[6]), n * (M[4] + M[7]), n * (M[5] + M[8])) // M * N4;
|
|
80
|
+
|
|
81
|
+
// notice how "k" disappears
|
|
82
|
+
// this is: (R / k) * (invA * k) * band2 == R * invA * band2
|
|
83
|
+
const result = multiply_5d(ROverK, invATimesKTimesBand2);
|
|
84
|
+
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in_sphere3d_robust.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/sphere/in_sphere3d_robust.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,2CARW,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"in_sphere3d_robust.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/sphere/in_sphere3d_robust.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,2CARW,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAyClB"}
|
|
@@ -86,12 +86,26 @@ export class TetrahedralMesh {
|
|
|
86
86
|
* @private
|
|
87
87
|
*/
|
|
88
88
|
private __free_pointer;
|
|
89
|
+
/**
|
|
90
|
+
* Only valid when the mesh is compacted
|
|
91
|
+
* @return {number}
|
|
92
|
+
*/
|
|
93
|
+
get count(): number;
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @return {boolean}
|
|
97
|
+
*/
|
|
98
|
+
get isCompacted(): boolean;
|
|
89
99
|
/**
|
|
90
100
|
* Traverse tetrahedrons
|
|
91
101
|
* @param {function(tet:number,mesh:TetrahedralMesh):*} visitor
|
|
92
102
|
* @param {*} [thisArg]
|
|
93
103
|
*/
|
|
94
104
|
forEach(visitor: any, thisArg?: any): void;
|
|
105
|
+
/**
|
|
106
|
+
* Clears all data from the mesh, making it contain 0 tetrahedrons
|
|
107
|
+
*/
|
|
108
|
+
clear(): void;
|
|
95
109
|
/**
|
|
96
110
|
*
|
|
97
111
|
* @param {number} capacity
|
|
@@ -112,6 +126,11 @@ export class TetrahedralMesh {
|
|
|
112
126
|
* @param {number} capacity
|
|
113
127
|
*/
|
|
114
128
|
growCapacity(capacity: number): void;
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param {number} capacity
|
|
132
|
+
*/
|
|
133
|
+
ensureCapacity(capacity: number): void;
|
|
115
134
|
/**
|
|
116
135
|
* NOTE: this method can be quite slow in cases of sparse allocation, please prefer not to use it
|
|
117
136
|
* @param {number} tet
|
|
@@ -128,7 +147,7 @@ export class TetrahedralMesh {
|
|
|
128
147
|
/**
|
|
129
148
|
* NOTE: the neighbour value must be encoded, see format specification for details
|
|
130
149
|
* @param {number} tetra_index
|
|
131
|
-
* @param {number} neighbour_index which neighbour to set (
|
|
150
|
+
* @param {number} neighbour_index which neighbour to set (00..11)
|
|
132
151
|
* @param {number} neighbour index of the neighbour encoded with the opposite corner
|
|
133
152
|
*/
|
|
134
153
|
setNeighbour(tetra_index: number, neighbour_index: number, neighbour: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAEkD;AAElE;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,4BAFU,MAAM,CAEwB;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACI;;;OAGG;IACH,2BAFW,MAAM,EAqDhB;IAhDG;;;;OAIG;IACH,iBAAsE;IAEtE;;;;OAIG;IACH,sBAAmD;IAEnD;;;;OAIG;IACH,eAAyC;IAEzC;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,mBAAmB;IAEnB;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,uBAAuB;IAG3B;;;;OAIG;IACH,2CAQC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,uBAFW,MAAM,
|
|
1
|
+
{"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAEkD;AAElE;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,4BAFU,MAAM,CAEwB;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACI;;;OAGG;IACH,2BAFW,MAAM,EAqDhB;IAhDG;;;;OAIG;IACH,iBAAsE;IAEtE;;;;OAIG;IACH,sBAAmD;IAEnD;;;;OAIG;IACH,eAAyC;IAEzC;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,mBAAmB;IAEnB;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,uBAAuB;IAG3B;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAQC;IAED;;OAEG;IACH,cAWC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,uBAFW,MAAM,QAchB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,YAHW,MAAM,GACL,OAAO,CAiBlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,aACN,MAAM,QAchB;IAGD;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,UACN,MAAM,QAiBhB;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,GACL,OAAO,CAUlB;IAGD;;;;OAIG;IACH,YAFY,MAAM,CA4BjB;IAED;;;;;;;;OAQG;IACH,eAPW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAmBhB;IAED;;;;OAIG;IACH,oBAFW,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,2CAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,iCAJW,MAAM,EAAE,SACR,MAAM,GACJ,MAAM,CAsBlB;IAGD;;;;;OAKG;IACH,uBAHW,MAAM,qBACN,MAAM,QA6BhB;IAED;;;;OAIG;IACH,WAFa,MAAM,CA2ClB;IAED;;;OAGG;IACH,kBAFW,YAAY,QAUtB;IAED;;;OAGG;IACH,oBAFW,YAAY,QAiBtB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAUjB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAQhB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BArrB4B,iCAAiC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { tetrahedron_contains_point } from "./tetrahedron_contains_point.js";
|
|
2
|
-
import { typed_array_copy } from "../../../collection/array/typed/typed_array_copy.js";
|
|
3
|
-
import { max3 } from "../../../math/max3.js";
|
|
4
1
|
import { assert } from "../../../assert.js";
|
|
2
|
+
import { Base64 } from "../../../binary/Base64.js";
|
|
3
|
+
import { BinaryBuffer } from "../../../binary/BinaryBuffer.js";
|
|
5
4
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
6
5
|
import { array_quick_sort_by_comparator } from "../../../collection/array/arrayQuickSort.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { typed_array_copy } from "../../../collection/array/typed/typed_array_copy.js";
|
|
7
|
+
import { max3 } from "../../../math/max3.js";
|
|
9
8
|
import { number_compare_descending } from "../../../primitives/numbers/number_compare_descending.js";
|
|
9
|
+
import { tetrahedron_contains_point } from "./tetrahedron_contains_point.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @readonly
|
|
@@ -133,6 +133,22 @@ export class TetrahedralMesh {
|
|
|
133
133
|
this.__free_pointer = 0;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Only valid when the mesh is compacted
|
|
138
|
+
* @return {number}
|
|
139
|
+
*/
|
|
140
|
+
get count() {
|
|
141
|
+
return this.__used_end;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @return {boolean}
|
|
147
|
+
*/
|
|
148
|
+
get isCompacted() {
|
|
149
|
+
return this.__free_pointer === 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
136
152
|
/**
|
|
137
153
|
* Traverse tetrahedrons
|
|
138
154
|
* @param {function(tet:number,mesh:TetrahedralMesh):*} visitor
|
|
@@ -148,6 +164,22 @@ export class TetrahedralMesh {
|
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Clears all data from the mesh, making it contain 0 tetrahedrons
|
|
169
|
+
*/
|
|
170
|
+
clear() {
|
|
171
|
+
|
|
172
|
+
// clear data
|
|
173
|
+
this.__data_uint32.fill(0, 0, this.__used_end);
|
|
174
|
+
|
|
175
|
+
// reset metadata
|
|
176
|
+
this.__used_end = 0;
|
|
177
|
+
this.__free_pointer = 0;
|
|
178
|
+
this.__free.splice(0, this.__free.length);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
151
183
|
/**
|
|
152
184
|
*
|
|
153
185
|
* @param {number} capacity
|
|
@@ -203,6 +235,7 @@ export class TetrahedralMesh {
|
|
|
203
235
|
* @param {number} capacity
|
|
204
236
|
*/
|
|
205
237
|
growCapacity(capacity) {
|
|
238
|
+
assert.isNonNegativeInteger(capacity, 'capacity');
|
|
206
239
|
|
|
207
240
|
const existing_capacity = this.__capacity;
|
|
208
241
|
|
|
@@ -215,6 +248,19 @@ export class TetrahedralMesh {
|
|
|
215
248
|
this.setCapacity(new_capacity);
|
|
216
249
|
}
|
|
217
250
|
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* @param {number} capacity
|
|
254
|
+
*/
|
|
255
|
+
ensureCapacity(capacity) {
|
|
256
|
+
assert.isNonNegativeInteger(capacity, 'capacity');
|
|
257
|
+
if (this.__capacity >= capacity) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.growCapacity(capacity);
|
|
262
|
+
}
|
|
263
|
+
|
|
218
264
|
/**
|
|
219
265
|
* NOTE: this method can be quite slow in cases of sparse allocation, please prefer not to use it
|
|
220
266
|
* @param {number} tet
|
|
@@ -258,7 +304,7 @@ export class TetrahedralMesh {
|
|
|
258
304
|
/**
|
|
259
305
|
* NOTE: the neighbour value must be encoded, see format specification for details
|
|
260
306
|
* @param {number} tetra_index
|
|
261
|
-
* @param {number} neighbour_index which neighbour to set (
|
|
307
|
+
* @param {number} neighbour_index which neighbour to set (00..11)
|
|
262
308
|
* @param {number} neighbour index of the neighbour encoded with the opposite corner
|
|
263
309
|
*/
|
|
264
310
|
setNeighbour(tetra_index, neighbour_index, neighbour) {
|
|
@@ -617,7 +663,7 @@ export class TetrahedralMesh {
|
|
|
617
663
|
|
|
618
664
|
this.growCapacity(this.__used_end);
|
|
619
665
|
|
|
620
|
-
buffer.readUint32Array(this.__data_uint32, 0, this.__used_end);
|
|
666
|
+
buffer.readUint32Array(this.__data_uint32, 0, this.__used_end * LAYOUT_TETRA_WORD_COUNT);
|
|
621
667
|
|
|
622
668
|
buffer.readUint32Array(this.__free, 0, this.__free_pointer);
|
|
623
669
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TetrahedralMesh } from "./TetrahedralMesh.js";
|
|
2
1
|
import { jest } from "@jest/globals";
|
|
2
|
+
import { TetrahedralMesh } from "./TetrahedralMesh.js";
|
|
3
3
|
|
|
4
4
|
test("constructor does not throw", () => {
|
|
5
5
|
expect(() => new TetrahedralMesh(1)).not.toThrow();
|
|
@@ -219,7 +219,7 @@ test('Compaction is non-destructive when moving resident data from the very end
|
|
|
219
219
|
const b = mesh.allocate();
|
|
220
220
|
|
|
221
221
|
// force move "a" to free set
|
|
222
|
-
mesh.
|
|
222
|
+
mesh.delete(a);
|
|
223
223
|
|
|
224
224
|
expect(mesh.exists(b)).toBe(true);
|
|
225
225
|
expect(mesh.exists(a)).toBe(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_tetrahedral_mesh_buffer_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_tetrahedral_mesh_buffer_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,4FAHW,YAAY,GAAC,MAAM,EAAE,GACpB,cAAc,CAwEzB;+BA/E6E,OAAO"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { BufferGeometry, Float32BufferAttribute, Uint32BufferAttribute } from "three";
|
|
2
|
-
import { BitSet } from "../../../binary/BitSet.js";
|
|
3
2
|
import { assert } from "../../../assert.js";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* Useful as a visualisation tool, to display tetrahedral mesh
|
|
7
6
|
* @param {TetrahedralMesh} tetrahedra
|
|
8
7
|
* @param {Float32Array|number[]} points
|
|
9
8
|
* @return {BufferGeometry}
|
|
10
9
|
*/
|
|
11
|
-
export function build_tetrahedral_mesh_buffer_geometry(
|
|
12
|
-
|
|
10
|
+
export function build_tetrahedral_mesh_buffer_geometry(
|
|
11
|
+
tetrahedra,
|
|
12
|
+
points
|
|
13
|
+
) {
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const lines = [];
|
|
15
16
|
|
|
16
17
|
const point_count = points.length / 3;
|
|
17
18
|
|
|
19
|
+
const occupancy = {};
|
|
20
|
+
|
|
18
21
|
assert.isNonNegativeInteger(point_count, 'point_count');
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -39,13 +42,15 @@ export function build_tetrahedral_mesh_buffer_geometry(tetrahedra, points) {
|
|
|
39
42
|
v1 = a;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
const
|
|
45
|
+
const key = `${v0}_${v1}`;
|
|
43
46
|
|
|
44
|
-
if (occupancy.
|
|
47
|
+
if (occupancy.hasOwnProperty(key)) {
|
|
45
48
|
// already recorded
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
occupancy[key] = true;
|
|
53
|
+
|
|
49
54
|
// no line record yet, create it
|
|
50
55
|
lines.push(v0, v1);
|
|
51
56
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Special case of tetrahedral mesh generation using a regular 3d grid, useful for generating light probe volumes
|
|
3
|
+
* This is a special case of tetrahedral tessellation, we can handle it much easier due to regular nature of the point distribution
|
|
4
|
+
* Note that if resolution in every dimension should be >= 2
|
|
5
|
+
* @param {TetrahedralMesh} mesh
|
|
6
|
+
* @param {number[]} points point data is written here
|
|
7
|
+
* @param {AABB3} bounds
|
|
8
|
+
* @param {number} resolution_x how many points to generate on the grid in X axis
|
|
9
|
+
* @param {number} resolution_y how many points to generate on the grid in Y axis
|
|
10
|
+
* @param {number} resolution_z how many points to generate on the grid in Y axis
|
|
11
|
+
*/
|
|
12
|
+
export function tetrahedral_mesh_build_from_grid(mesh: TetrahedralMesh, points: number[], bounds: AABB3, resolution_x?: number, resolution_y?: number, resolution_z?: number): void;
|
|
13
|
+
//# sourceMappingURL=tetrahedral_mesh_build_from_grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tetrahedral_mesh_build_from_grid.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,gFANW,MAAM,EAAE,gCAER,MAAM,iBACN,MAAM,iBACN,MAAM,QA6HhB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Special case of tetrahedral mesh generation using a regular 3d grid, useful for generating light probe volumes
|
|
3
|
+
* This is a special case of tetrahedral tessellation, we can handle it much easier due to regular nature of the point distribution
|
|
4
|
+
* Note that if resolution in every dimension should be >= 2
|
|
5
|
+
* @param {TetrahedralMesh} mesh
|
|
6
|
+
* @param {number[]} points point data is written here
|
|
7
|
+
* @param {AABB3} bounds
|
|
8
|
+
* @param {number} resolution_x how many points to generate on the grid in X axis
|
|
9
|
+
* @param {number} resolution_y how many points to generate on the grid in Y axis
|
|
10
|
+
* @param {number} resolution_z how many points to generate on the grid in Y axis
|
|
11
|
+
*/
|
|
12
|
+
export function tetrahedral_mesh_build_from_grid(
|
|
13
|
+
mesh, points,
|
|
14
|
+
bounds,
|
|
15
|
+
resolution_x = 2, resolution_y = 2, resolution_z = 2,
|
|
16
|
+
) {
|
|
17
|
+
|
|
18
|
+
console.error("Implementation is incomplete"); // FIXME
|
|
19
|
+
|
|
20
|
+
mesh.clear();
|
|
21
|
+
|
|
22
|
+
const tetrahedron_count = (resolution_x - 1) * (resolution_y - 1) * (resolution_z - 1) * 6;
|
|
23
|
+
|
|
24
|
+
// we know how many tetrahedrons will be created, so we can avoid some re-allocations by ensuring there's enough capacity
|
|
25
|
+
mesh.ensureCapacity(tetrahedron_count);
|
|
26
|
+
|
|
27
|
+
const bounds_extents_x = bounds.getExtentsX();
|
|
28
|
+
const bounds_extents_y = bounds.getExtentsY();
|
|
29
|
+
const bounds_extents_z = bounds.getExtentsZ();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {number} x
|
|
34
|
+
* @param {number} y
|
|
35
|
+
* @param {number} z
|
|
36
|
+
* @return {number}
|
|
37
|
+
*/
|
|
38
|
+
function vertex_position_to_index(x, y, z) {
|
|
39
|
+
|
|
40
|
+
return z * resolution_y * resolution_x + y * resolution_x + x;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// generate points
|
|
44
|
+
for (let z = 0; z < resolution_z; z++) {
|
|
45
|
+
for (let y = 0; y < resolution_y; y++) {
|
|
46
|
+
for (let x = 0; x < resolution_x; x++) {
|
|
47
|
+
|
|
48
|
+
const index = vertex_position_to_index(x, y, z);
|
|
49
|
+
|
|
50
|
+
const index3 = index * 3;
|
|
51
|
+
|
|
52
|
+
const x_norm = x / (resolution_x - 1);
|
|
53
|
+
const y_norm = y / (resolution_y - 1);
|
|
54
|
+
const z_norm = z / (resolution_z - 1);
|
|
55
|
+
|
|
56
|
+
points[index3] = bounds.x0 + x_norm * bounds_extents_x;
|
|
57
|
+
points[index3 + 1] = bounds.y0 + y_norm * bounds_extents_y;
|
|
58
|
+
points[index3 + 2] = bounds.z0 + z_norm * bounds_extents_z;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {number} v0
|
|
67
|
+
* @param {number} v1
|
|
68
|
+
* @param {number} v2
|
|
69
|
+
* @param {number} v3
|
|
70
|
+
* @return {number}
|
|
71
|
+
*/
|
|
72
|
+
function make_cell(v0, v1, v2, v3) {
|
|
73
|
+
|
|
74
|
+
const tet_0 = mesh.allocate();
|
|
75
|
+
|
|
76
|
+
mesh.setVertexIndex(tet_0, 0, v0);
|
|
77
|
+
mesh.setVertexIndex(tet_0, 1, v1);
|
|
78
|
+
mesh.setVertexIndex(tet_0, 2, v2);
|
|
79
|
+
mesh.setVertexIndex(tet_0, 3, v3);
|
|
80
|
+
|
|
81
|
+
return tet_0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// NOTE: it's possible to tessellate each box into 5 tetrahedrons instead of 6, but orientation becomes inconsistent if we do that
|
|
85
|
+
// reference http://www.iue.tuwien.ac.at/phd/wessner/node32.html
|
|
86
|
+
|
|
87
|
+
for (let z = 1; z < resolution_z; z++) {
|
|
88
|
+
for (let y = 1; y < resolution_y; y++) {
|
|
89
|
+
for (let x = 1; x < resolution_x; x++) {
|
|
90
|
+
const p000 = vertex_position_to_index(x - 1, y - 1, z - 1);
|
|
91
|
+
const p001 = vertex_position_to_index(x - 1, y - 1, z);
|
|
92
|
+
const p010 = vertex_position_to_index(x - 1, y, z - 1);
|
|
93
|
+
const p011 = vertex_position_to_index(x - 1, y, z);
|
|
94
|
+
const p100 = vertex_position_to_index(x, y - 1, z - 1);
|
|
95
|
+
const p101 = vertex_position_to_index(x, y - 1, z);
|
|
96
|
+
const p110 = vertex_position_to_index(x, y, z - 1);
|
|
97
|
+
const p111 = vertex_position_to_index(x, y, z);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// Tessellate the grid volume into six tetrahedra per grid cell.
|
|
101
|
+
|
|
102
|
+
// prism 1
|
|
103
|
+
const tet_0 = make_cell(p111, p110, p010, p000);
|
|
104
|
+
const tet_1 = make_cell(p111, p101, p110, p000);
|
|
105
|
+
const tet_2 = make_cell(p110, p101, p100, p000);
|
|
106
|
+
|
|
107
|
+
// prism 2
|
|
108
|
+
const tet_3 = make_cell(p111, p011, p010, p000);
|
|
109
|
+
const tet_4 = make_cell(p111, p101, p011, p000);
|
|
110
|
+
const tet_5 = make_cell(p011, p101, p001, p000);
|
|
111
|
+
|
|
112
|
+
// link newly created tetrahedrons
|
|
113
|
+
// TODO implement
|
|
114
|
+
|
|
115
|
+
if (x > 1) {
|
|
116
|
+
// link to previous voxel
|
|
117
|
+
// TODO implement
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (y > 1) {
|
|
121
|
+
// link to previous voxel
|
|
122
|
+
// TODO implement
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (z > 1) {
|
|
126
|
+
// link to previous voxel
|
|
127
|
+
// TODO implement
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { EngineHarness } from "../../../../engine/EngineHarness.js";
|
|
2
|
-
import { compute_delaunay_tetrahedral_mesh } from "./delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
3
1
|
import { LineBasicMaterial } from "three";
|
|
4
|
-
import { ShadedGeometry } from "../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
5
|
-
import { DrawMode } from "../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
6
2
|
import Entity from "../../../../engine/ecs/Entity.js";
|
|
7
3
|
import { Transform } from "../../../../engine/ecs/transform/Transform.js";
|
|
4
|
+
import { EngineHarness } from "../../../../engine/EngineHarness.js";
|
|
5
|
+
import { DrawMode } from "../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
6
|
+
import { ShadedGeometry } from "../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
8
7
|
import { ShadedGeometrySystem } from "../../../../engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
9
|
-
import { GizmoRenderingPlugin } from "../../../../engine/graphics/render/gizmo/GizmoRenderingPlugin.js";
|
|
10
8
|
import { Gizmo } from "../../../../engine/graphics/render/gizmo/Gizmo.js";
|
|
11
|
-
import {
|
|
9
|
+
import { GizmoRenderingPlugin } from "../../../../engine/graphics/render/gizmo/GizmoRenderingPlugin.js";
|
|
12
10
|
import { seededRandom } from "../../../math/random/seededRandom.js";
|
|
13
|
-
import {
|
|
11
|
+
import { number_pretty_print } from "../../../primitives/numbers/number_pretty_print.js";
|
|
14
12
|
import { delay } from "../../../process/delay.js";
|
|
13
|
+
import { AABB3 } from "../aabb/AABB3.js";
|
|
14
|
+
import { make_justified_point_grid } from "../util/make_justified_point_grid.js";
|
|
15
|
+
import { build_tetrahedral_mesh_buffer_geometry } from "./build_tetrahedral_mesh_buffer_geometry.js";
|
|
16
|
+
import { compute_delaunay_tetrahedral_mesh } from "./delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
15
17
|
import { TetrahedralMesh } from "./TetrahedralMesh.js";
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -44,26 +46,37 @@ async function main(engine) {
|
|
|
44
46
|
|
|
45
47
|
const random = seededRandom();
|
|
46
48
|
|
|
47
|
-
for (let i = 0; i < 600; i++) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
// for (let i = 0; i < 600; i++) {
|
|
50
|
+
// points.push(
|
|
51
|
+
// randomFloatBetween(random, -100, 100),
|
|
52
|
+
// randomFloatBetween(random, 0, 150),
|
|
53
|
+
// randomFloatBetween(random, -100, 100),
|
|
54
|
+
// );
|
|
55
|
+
// }
|
|
56
|
+
|
|
57
|
+
make_justified_point_grid(
|
|
58
|
+
new AABB3(-100, 0, -100, 100, 150, 100),
|
|
59
|
+
20,
|
|
60
|
+
(x, y, z) => {
|
|
61
|
+
points.push(x, y, z);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
58
64
|
|
|
59
65
|
await delay(1000);
|
|
60
66
|
|
|
61
67
|
const tetrahedra = new TetrahedralMesh();
|
|
62
|
-
|
|
63
|
-
console.profile('mesh build');
|
|
68
|
+
console.time('mesh build');
|
|
69
|
+
// console.profile('mesh build');
|
|
64
70
|
compute_delaunay_tetrahedral_mesh(tetrahedra, points, points.length / 3);
|
|
65
|
-
|
|
66
|
-
//
|
|
71
|
+
// tetrahedral_mesh_build_from_grid(
|
|
72
|
+
// tetrahedra,
|
|
73
|
+
// points,
|
|
74
|
+
// new AABB3(-100, 0, -100, 100, 100, 100),
|
|
75
|
+
// 64, 32, 64
|
|
76
|
+
// )
|
|
77
|
+
// console.profileEnd('mesh build');
|
|
78
|
+
console.timeEnd('mesh build');
|
|
79
|
+
console.log(`Mesh build for ${number_pretty_print(points.length / 3)} points`)
|
|
67
80
|
|
|
68
81
|
console.log(tetrahedra);
|
|
69
82
|
|
|
@@ -75,7 +88,6 @@ async function main(engine) {
|
|
|
75
88
|
const geometry = build_tetrahedral_mesh_buffer_geometry(tetrahedra, points);
|
|
76
89
|
|
|
77
90
|
|
|
78
|
-
|
|
79
91
|
new Entity()
|
|
80
92
|
.add(ShadedGeometry.from(geometry, new LineBasicMaterial({ color: 0xFF0000 }), DrawMode.LineSegments))
|
|
81
93
|
.add(Transform.fromJSON({
|
|
@@ -88,7 +100,9 @@ async function main(engine) {
|
|
|
88
100
|
|
|
89
101
|
Gizmo.color = [1, 1, 1, 1];
|
|
90
102
|
|
|
91
|
-
|
|
103
|
+
const point_count = points.length;
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < point_count; i += 3) {
|
|
92
106
|
|
|
93
107
|
Gizmo.draw_solid_sphere([
|
|
94
108
|
points[i] * scale[0] + offset[0],
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compute the circumcenter (center[3]) and radius squared (method
|
|
3
|
-
* return value) of a tetrahedron defined by the four points x1, x2,
|
|
4
|
-
* x3, and x4.
|
|
2
|
+
* Compute the circumcenter (center[3]) and radius squared (method return value) of a tetrahedron defined by the four points x1, x2, x3, and x4.
|
|
5
3
|
*
|
|
6
4
|
* @see https://github.com/Kitware/VTK/blob/ac3fd8005bce7b3da4423c305f61ffd9df9695ef/Common/DataModel/vtkTetra.cxx
|
|
7
5
|
* @param {number[]} result [center_x, center_y, center_z, radius_squared]
|
|
@@ -11,5 +9,5 @@
|
|
|
11
9
|
* @param {number} c
|
|
12
10
|
* @param {number} d
|
|
13
11
|
*/
|
|
14
|
-
export function
|
|
15
|
-
//# sourceMappingURL=
|
|
12
|
+
export function tetrahedron_compute_circumsphere(result: number[], points: number[], a: number, b: number, c: number, d: number): void;
|
|
13
|
+
//# sourceMappingURL=tetrahedron_compute_circumsphere.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tetrahedron_compute_circumsphere.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,yDAPW,MAAM,EAAE,UACR,MAAM,EAAE,KACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA+EhB"}
|
package/src/core/geom/3d/tetrahedra/{compute_circumsphere.js → tetrahedron_compute_circumsphere.js}
RENAMED
|
@@ -6,9 +6,7 @@ const SMALL_NUMBER = 1e-12;
|
|
|
6
6
|
const VTK_MAX_WARNS = 3;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Compute the circumcenter (center[3]) and radius squared (method
|
|
10
|
-
* return value) of a tetrahedron defined by the four points x1, x2,
|
|
11
|
-
* x3, and x4.
|
|
9
|
+
* Compute the circumcenter (center[3]) and radius squared (method return value) of a tetrahedron defined by the four points x1, x2, x3, and x4.
|
|
12
10
|
*
|
|
13
11
|
* @see https://github.com/Kitware/VTK/blob/ac3fd8005bce7b3da4423c305f61ffd9df9695ef/Common/DataModel/vtkTetra.cxx
|
|
14
12
|
* @param {number[]} result [center_x, center_y, center_z, radius_squared]
|
|
@@ -18,7 +16,7 @@ const VTK_MAX_WARNS = 3;
|
|
|
18
16
|
* @param {number} c
|
|
19
17
|
* @param {number} d
|
|
20
18
|
*/
|
|
21
|
-
export function
|
|
19
|
+
export function tetrahedron_compute_circumsphere(
|
|
22
20
|
result,
|
|
23
21
|
points,
|
|
24
22
|
a, b, c, d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tetrahedron_compute_signed_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tetrahedron_compute_signed_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js"],"names":[],"mappings":"AAkCA;;;;;;;;;GASG;AACH,0DAPW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,KACvC,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CA0ClB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const ONE_OVER_SIX = 1.0 / 6.0;
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Compute signed volume of a tetrahedron with the last point at the origin
|
|
3
5
|
* @see "EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION" by Cha Zhang and Tsuhan Chen
|
|
@@ -25,7 +27,7 @@ function triangle_compute_signed_volume(
|
|
|
25
27
|
const v213 = bx * ay * cz;
|
|
26
28
|
const v123 = ax * by * cz;
|
|
27
29
|
|
|
28
|
-
return
|
|
30
|
+
return ONE_OVER_SIX * (-v321 + v231 + v312 - v132 - v213 + v123);
|
|
29
31
|
|
|
30
32
|
}
|
|
31
33
|
|