@woosh/meep-engine 2.109.6 → 2.109.8

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 (180) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +203 -174
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +203 -174
  5. package/editor/tools/v2/TransformControls.js +39 -33
  6. package/package.json +1 -1
  7. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  8. package/src/core/bvh2/bvh3/BVH.js +8 -0
  9. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
  11. package/src/core/geom/3d/Ray3.js +1 -1
  12. package/src/core/geom/3d/aabb/AABB3.js +1 -1
  13. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
  14. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  15. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
  16. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
  17. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
  18. package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
  19. package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
  20. package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
  21. package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
  22. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
  23. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
  24. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
  25. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  26. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
  27. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
  28. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
  29. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
  30. package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
  31. package/src/core/geom/vec3/v3_distance.js +5 -5
  32. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
  33. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  34. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
  35. package/src/core/model/node-graph/DataType.d.ts.map +1 -1
  36. package/src/core/model/node-graph/DataType.js +16 -10
  37. package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
  38. package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
  39. package/src/core/model/node-graph/ParametricDataType.js +63 -0
  40. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
  41. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  42. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
  43. package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
  44. package/src/engine/asset/loaders/AssetLoader.js +1 -1
  45. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  46. package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
  47. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  48. package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
  49. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  50. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
  51. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
  52. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
  53. package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
  54. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  55. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
  56. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
  57. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
  58. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
  59. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
  60. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
  61. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
  62. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  63. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
  64. package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
  65. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  66. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +59 -37
  67. package/src/engine/graphics/sh3/gi/material/common.glsl +484 -0
  68. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
  69. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
  70. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
  71. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
  72. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
  73. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
  74. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
  75. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +51 -0
  76. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
  78. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
  79. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
  80. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
  81. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
  82. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
  83. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
  84. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
  85. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
  86. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
  87. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
  88. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
  89. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
  90. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
  91. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
  92. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
  93. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  94. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
  95. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
  96. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +26 -9
  97. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +11 -1
  98. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  99. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -61
  100. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  101. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +8 -6
  102. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
  103. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
  104. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
  105. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
  106. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
  107. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
  108. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
  109. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
  110. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
  111. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
  112. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
  113. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
  114. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
  115. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +149 -0
  116. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +161 -0
  117. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
  118. package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
  119. package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
  120. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
  121. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
  122. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
  123. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
  124. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  125. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
  126. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  127. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
  128. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
  129. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  130. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
  131. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
  132. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
  133. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
  134. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
  135. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  136. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
  137. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  138. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
  139. package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  140. package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
  141. package/src/engine/graphics/sh3/prototypeSH3Probe.js +41 -8
  142. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
  143. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
  144. package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
  145. package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
  146. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
  147. package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
  148. package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
  149. package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
  150. package/src/view/View.d.ts.map +1 -1
  151. package/src/view/View.js +2 -0
  152. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
  153. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
  154. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
  155. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
  156. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
  157. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
  158. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
  159. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
  160. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
  161. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
  162. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
  163. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
  164. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
  165. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
  166. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
  167. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
  168. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
  169. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
  170. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
  171. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
  172. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
  173. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
  174. /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
  175. /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
  176. /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
  177. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
  178. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
  179. /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
  180. /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
@@ -6,7 +6,7 @@ import { aabb3_from_v3_array } from "../../geom/3d/aabb/aabb3_from_v3_array.js";
6
6
  import { aabb3_compute_from_triangle } from "../../geom/3d/aabb3_compute_from_triangle.js";
7
7
  import { max2 } from "../../math/max2.js";
8
8
  import { build_triangle_morton_codes } from "./build_triangle_morton_codes.js";
9
- import { ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
9
+ import { COLUMN_CHILD_1, COLUMN_HEIGHT, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
10
10
  import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
11
11
 
12
12
  /**
@@ -75,6 +75,10 @@ export function ebvh_build_for_geometry_morton(
75
75
  // sort leaves by morton codes
76
76
  array_quick_sort_by_lookup_uint(sorted_triangle_order, morton_codes, 0, tri_count - 1);
77
77
 
78
+
79
+ const bvh_float32 = bvh.__data_float32;
80
+ const bvh_uint32 = bvh.__data_uint32;
81
+
78
82
  // assign leaves
79
83
  for (let i = 0; i < tri_count; i++) {
80
84
  const node = nodes[i];
@@ -87,17 +91,15 @@ export function ebvh_build_for_geometry_morton(
87
91
  const b_index = index_array[triangle_index3 + 1];
88
92
  const c_index = index_array[triangle_index3 + 2];
89
93
 
90
- const aabb_address = ELEMENT_WORD_COUNT * node;
91
-
94
+ const node_address = ELEMENT_WORD_COUNT * node;
92
95
  aabb3_compute_from_triangle(
93
- bvh.__data_float32, aabb_address,
96
+ bvh_float32, node_address,
94
97
  position_array, a_index, b_index, c_index
95
98
  );
96
99
 
97
- bvh.node_set_child1(node, NULL_NODE); //mark node as a leaf
98
- bvh.node_set_user_data(node, triangle_index);
99
-
100
- bvh.node_set_height(node, 0);
100
+ bvh_uint32[node_address + COLUMN_CHILD_1] = NULL_NODE; //mark node as a leaf
101
+ bvh_uint32[node_address + COLUMN_USER_DATA] = triangle_index;
102
+ bvh_uint32[node_address + COLUMN_HEIGHT] = 0;
101
103
  }
102
104
 
103
105
  // record newly generated nodes as "unprocessed"
@@ -105,5 +107,5 @@ export function ebvh_build_for_geometry_morton(
105
107
  array_copy(nodes, 0, unprocessed_nodes, 0, tri_count);
106
108
 
107
109
  // assign root
108
- bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, tri_count);
110
+ bvh.root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, tri_count);
109
111
  }
@@ -23,7 +23,7 @@ export class Ray3 extends Float32Array {
23
23
  }
24
24
 
25
25
  get direction() {
26
- return new Float32Array(this.buffer, this.byteOffset + 3, 3);
26
+ return new Float32Array(this.buffer, this.byteOffset + 3 * 4, 3);
27
27
  }
28
28
 
29
29
  get origin() {
@@ -629,7 +629,7 @@ export class AABB3 {
629
629
 
630
630
  /**
631
631
  * Get center position of the box
632
- * @param {Vector3} target where to write result
632
+ * @param {Vector3} [target] where to write result
633
633
  */
634
634
  getCenter(target = new Vector3()) {
635
635
  const x = this.getCenterX();
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
3
3
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
4
- * @param {number[]|Vector3} output
4
+ * @param {number[]|Vector3|Float32Array} output
5
5
  * @param {number} output_offset
6
- * @param {number} x range [0,1]
7
- * @param {number} y range [0,1]
6
+ * @param {number} u range [-1,1]
7
+ * @param {number} v range [-1,1]
8
8
  */
9
- export function decode_octahedron_to_unit(output: number[] | Vector3, output_offset: number, x: number, y: number): void;
9
+ export function decode_octahedron_to_unit(output: number[] | Vector3 | Float32Array, output_offset: number, u: number, v: number): void;
10
10
  //# sourceMappingURL=decode_octahedron_to_unit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,UAAQ,iBAChB,MAAM,KACN,MAAM,KACN,MAAM,QAsBhB"}
1
+ {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,aAAS,YAAY,iBAC7B,MAAM,KACN,MAAM,KACN,MAAM,QA0BhB"}
@@ -3,23 +3,27 @@ import { sign_not_zero } from "../../../../math/sign_not_zero.js";
3
3
  /**
4
4
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
5
5
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
6
- * @param {number[]|Vector3} output
6
+ * @param {number[]|Vector3|Float32Array} output
7
7
  * @param {number} output_offset
8
- * @param {number} x range [0,1]
9
- * @param {number} y range [0,1]
8
+ * @param {number} u range [-1,1]
9
+ * @param {number} v range [-1,1]
10
10
  */
11
- export function decode_octahedron_to_unit(output, output_offset, x, y) {
12
- let v_x = x;
13
- let v_y = y;
11
+ export function decode_octahedron_to_unit(
12
+ output, output_offset,
13
+ u, v
14
+ ) {
15
+ let v_x = u;
16
+ let v_z = v;
14
17
 
15
18
  const abs_x = Math.abs(v_x);
16
- const abs_y = Math.abs(v_y);
19
+ const abs_z = Math.abs(v_z);
17
20
 
18
- let v_z = 1 - abs_x - abs_y;
21
+ let v_y = 1 - abs_x - abs_z;
19
22
 
20
- if (v_z < 0) {
21
- v_x = (1 - abs_y) * sign_not_zero(v_x);
22
- v_y = (1 - abs_x) * sign_not_zero(v_y);
23
+ // Handle octahedron's fold
24
+ if (v_y < 0) {
25
+ v_x = (1 - abs_z) * sign_not_zero(v_x);
26
+ v_z = (1 - abs_x) * sign_not_zero(v_z);
23
27
  }
24
28
 
25
29
  // normalize
@@ -1 +1 @@
1
- {"version":3,"file":"encode_unit_to_octahedron.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,kDANW,MAAM,EAAE,iBACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAoBhB"}
1
+ {"version":3,"file":"encode_unit_to_octahedron.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,kDANW,MAAM,EAAE,iBACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA0BhB"}
@@ -12,20 +12,26 @@ import { sign_not_zero } from "../../../../math/sign_not_zero.js";
12
12
  * @param {number} y range [-1,1]
13
13
  * @param {number} z range [-1,1]
14
14
  */
15
- export function encode_unit_to_octahedron(output, output_offset, x, y, z) {
15
+ export function encode_unit_to_octahedron(
16
+ output, output_offset,
17
+ x, y, z
18
+ ) {
19
+
16
20
  // Project the sphere onto the octahedron, and then onto the xy plane
17
- const l2 = 1 / (Math.abs(x) + Math.abs(y) + Math.abs(z));
21
+ const abs_sum = Math.abs(x) + Math.abs(y) + Math.abs(z);
22
+
23
+ const inverse_sum = 1 / abs_sum;
18
24
 
19
- let p_x = x * l2;
20
- let p_y = y * l2;
25
+ let p_x = x * inverse_sum;
26
+ let p_y = y * inverse_sum;
21
27
 
22
28
  // Reflect the folds of the lower hemisphere over the diagonals
23
- if (z <= 0) {
29
+ if (z < 0) {
24
30
  const abs_x = Math.abs(p_x);
25
31
  const abs_y = Math.abs(p_y);
26
32
 
27
- p_x = sign_not_zero(p_x) * (1 - abs_y);
28
- p_y = sign_not_zero(p_y) * (1 - abs_x);
33
+ p_x = (1 - abs_y) * sign_not_zero(p_x);
34
+ p_y = (1 - abs_x) * sign_not_zero(p_y);
29
35
  }
30
36
 
31
37
  output[output_offset] = p_x;
@@ -1,5 +1,5 @@
1
- import { encode_unit_to_octahedron } from "./encode_unit_to_octahedron.js";
2
1
  import { decode_octahedron_to_unit } from "./decode_octahedron_to_unit.js";
2
+ import { encode_unit_to_octahedron } from "./encode_unit_to_octahedron.js";
3
3
 
4
4
  /**
5
5
  *
@@ -26,4 +26,29 @@ test("encoding/decoding consistency", () => {
26
26
 
27
27
  // center
28
28
  try_one(0.5, 0.5);
29
+
30
+ // sweep
31
+ try_one(0.1, 0);
32
+ try_one(0.1, 0.1);
33
+ try_one(0.1, 0.4);
34
+ try_one(0.1, 0.6);
35
+ try_one(0.1, 0.9);
36
+
37
+ try_one(0.4, 0);
38
+ try_one(0.4, 0.1);
39
+ try_one(0.4, 0.4);
40
+ try_one(0.4, 0.6);
41
+ try_one(0.4, 0.9);
42
+
43
+ try_one(0.6, 0);
44
+ try_one(0.6, 0.1);
45
+ try_one(0.6, 0.4);
46
+ try_one(0.6, 0.6);
47
+ try_one(0.6, 0.9);
48
+
49
+ try_one(0.9, 0);
50
+ try_one(0.9, 0.1);
51
+ try_one(0.9, 0.4);
52
+ try_one(0.9, 0.6);
53
+ try_one(0.9, 0.9);
29
54
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/prototype.js"],"names":[],"mappings":""}
@@ -0,0 +1,226 @@
1
+ import {
2
+ AmbientLight,
3
+ Mesh,
4
+ MeshStandardMaterial,
5
+ OctahedronBufferGeometry,
6
+ PerspectiveCamera,
7
+ Scene,
8
+ TextureLoader,
9
+ Vector3,
10
+ WebGLRenderer
11
+ } from "three";
12
+ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
13
+ import { makeSolidArrowGeometry } from "../../../../../../editor/process/symbolic/makeSolidArrowGeometry.js";
14
+ import { AssetManager } from "../../../../../engine/asset/AssetManager.js";
15
+ import { ImageRGBADataLoader } from "../../../../../engine/asset/loaders/image/ImageRGBADataLoader.js";
16
+ import sampler2D2Canvas from "../../../../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
17
+ import { MouseEvents } from "../../../../../engine/input/devices/events/MouseEvents.js";
18
+ import { CSS_ABSOLUTE_POSITIONING } from "../../../../../view/CSS_ABSOLUTE_POSITIONING.js";
19
+ import { CanvasView } from "../../../../../view/elements/CanvasView.js";
20
+ import EmptyView from "../../../../../view/elements/EmptyView.js";
21
+ import { Color } from "../../../../color/Color.js";
22
+ import { decode_octahedron_to_unit } from "./decode_octahedron_to_unit.js";
23
+
24
+ const renderer = new WebGLRenderer();
25
+
26
+ const scene = new Scene();
27
+
28
+ const camera = new PerspectiveCamera();
29
+
30
+
31
+ function onWindowResize() {
32
+
33
+
34
+ camera.aspect = window.innerWidth / window.innerHeight;
35
+ camera.updateProjectionMatrix();
36
+ renderer.setSize(window.innerWidth, window.innerHeight);
37
+
38
+ }
39
+
40
+
41
+ onWindowResize();
42
+
43
+
44
+ window.addEventListener('resize', onWindowResize, false);
45
+
46
+ const vContainer = new EmptyView({
47
+ css: {
48
+ ...CSS_ABSOLUTE_POSITIONING
49
+ }
50
+ });
51
+
52
+ const vCanvas = new CanvasView();
53
+ vCanvas.size.set(512, 512);
54
+
55
+ vContainer.addChild(vCanvas);
56
+
57
+ const assetManager = new AssetManager();
58
+
59
+
60
+ function placeMarker(u, v, color = "rgba(255,0,0,1)") {
61
+
62
+ const direciton_0 = new Vector3(0, 1, 0);
63
+
64
+ const encoded = [];
65
+ decode_octahedron_to_unit(encoded, 0, u, v);
66
+
67
+ direciton_0.fromArray(encoded);
68
+
69
+ const arrow_mesh_0 = new Mesh(
70
+ makeSolidArrowGeometry(),
71
+ new MeshStandardMaterial({
72
+ color: color
73
+ })
74
+ );
75
+
76
+ arrow_mesh_0.position.copy(direciton_0).multiplyScalar(1);
77
+
78
+ arrow_mesh_0.lookAt(
79
+ arrow_mesh_0.position.clone().add(direciton_0)
80
+ );
81
+
82
+ scene.add(arrow_mesh_0);
83
+ }
84
+
85
+ function canvasPlaceDot(u, v, color = "rgba(255,0,0,1)") {
86
+
87
+
88
+ const marker_0 = new EmptyView({
89
+ css: {
90
+ ...CSS_ABSOLUTE_POSITIONING,
91
+ borderRadius: "5px",
92
+ width: "5px",
93
+ height: "5px",
94
+ background: color,
95
+ boxShadow: "0 0 4px 2px black"
96
+ }
97
+ });
98
+
99
+ marker_0.position.set(u * vCanvas.size.x, v * vCanvas.size.y);
100
+
101
+ vContainer.addChild(marker_0);
102
+ }
103
+
104
+ async function init_debug() {
105
+
106
+ const ctx2d = vCanvas.context2d;
107
+
108
+ ctx2d.fillStyle = 'rgba(0,0,0,0.5)';
109
+ ctx2d.fillRect(0, 0, vCanvas.size.x, vCanvas.size.y);
110
+
111
+ const asset = await assetManager.promise("data/textures/utility/uv_map_reference.png", 'image');
112
+
113
+ /**
114
+ *
115
+ * @type {Sampler2D}
116
+ */
117
+ const sampler = asset.create();
118
+
119
+ sampler2D2Canvas(sampler, 1, 0, vCanvas.el);
120
+
121
+
122
+ const marker_0 = new EmptyView({
123
+ css: {
124
+ ...CSS_ABSOLUTE_POSITIONING,
125
+ borderRadius: "5px",
126
+ width: "5px",
127
+ height: "5px",
128
+ background: "rgba(255,0,0,1)",
129
+ boxShadow: "0 0 4px 2px black"
130
+ }
131
+ });
132
+
133
+ function make_grid(RESOLUTION = 16) {
134
+
135
+ const color = new Color();
136
+
137
+ const sample_color = [255, 255, 255];
138
+
139
+ const pixel_size = 1 / RESOLUTION;
140
+
141
+ for (let i = 0; i < RESOLUTION; i++) {
142
+
143
+ for (let j = 0; j < RESOLUTION; j++) {
144
+
145
+ const u = (i) / (RESOLUTION);
146
+ const v = (j) / (RESOLUTION);
147
+
148
+ sampler.sampleBicubicUV(u + pixel_size * 0.1, v + pixel_size * 0.1, sample_color);
149
+
150
+ color.setRGBUint8(sample_color[0], sample_color[1], sample_color[2]);
151
+
152
+ const color_string = color.toCssRGBAString();
153
+
154
+ const centered_u = u + pixel_size * 0.5;
155
+ const centered_v = v + pixel_size * 0.5;
156
+
157
+ canvasPlaceDot(centered_u, centered_v, color_string);
158
+ placeMarker(centered_u * 2 - 1, centered_v * 2 - 1, color_string);
159
+ }
160
+
161
+ }
162
+ }
163
+
164
+ make_grid(16);
165
+
166
+ vContainer.addChild(marker_0);
167
+
168
+ vCanvas.el.addEventListener(MouseEvents.Down,
169
+ /**
170
+ *
171
+ * @param {MouseEvent} mouseEvent
172
+ */
173
+ (mouseEvent) => {
174
+
175
+ const x = mouseEvent.clientX;
176
+ const y = mouseEvent.clientY;
177
+ marker_0.position.set(x, y);
178
+ });
179
+ }
180
+
181
+ function animate() {
182
+ requestAnimationFrame(animate);
183
+
184
+
185
+ renderer.render(scene, camera);
186
+ }
187
+
188
+ async function init() {
189
+ await assetManager.registerLoader('image', new ImageRGBADataLoader());
190
+
191
+ assetManager.startup();
192
+
193
+ document.body.appendChild(renderer.domElement);
194
+ document.body.appendChild(vContainer.el);
195
+ vContainer.link();
196
+
197
+ await init_debug();
198
+
199
+ // camera
200
+
201
+ camera.position.set(0, 0, -3);
202
+ camera.lookAt(0, 0, 0);
203
+
204
+ // meshes
205
+
206
+ const geometry = new OctahedronBufferGeometry(1, 3);
207
+
208
+ const texture = new TextureLoader().load("data/textures/utility/uv_map_reference.png");
209
+ texture.flipY = true;
210
+
211
+ const mesh = new Mesh(geometry, new MeshStandardMaterial({
212
+ map: texture
213
+ }));
214
+
215
+ scene.add(mesh);
216
+
217
+ // lights
218
+
219
+ scene.add(new AmbientLight(0x333333));
220
+
221
+ const controls = new OrbitControls(camera, document.body);
222
+
223
+ animate();
224
+ }
225
+
226
+ init();
@@ -1,5 +1,5 @@
1
1
  /**
2
- *
2
+ * Rotate spherical harmonics
3
3
  * @param {number[]|Float32Array} result sh3
4
4
  * @param {number[]} sh input
5
5
  * @param {number[]} rotation 3x3 rotation matrix
@@ -1,7 +1,7 @@
1
1
  const scratch_mat_5x5 = new Float64Array(25);
2
2
 
3
3
  /**
4
- *
4
+ * Rotate spherical harmonics
5
5
  * @param {number[]|Float32Array} result sh3
6
6
  * @param {number[]} sh input
7
7
  * @param {number[]} rotation 3x3 rotation matrix
@@ -22,15 +22,15 @@ export function sh3_rotate_bl(result, sh, rotation) {
22
22
  const r22 = rotation[8];
23
23
 
24
24
 
25
- // Constant
25
+ // band-0 : Constant
26
26
  result[0] = sh[0];
27
27
 
28
- // Linear
28
+ // band-1: Linear
29
29
  result[1] = r11 * sh[1] - r12 * sh[2] + r10 * sh[3];
30
30
  result[2] = -r21 * sh[1] + r22 * sh[2] - r20 * sh[3];
31
31
  result[3] = r01 * sh[1] - r02 * sh[2] + r00 * sh[3];
32
32
 
33
- // Quadratic
33
+ // band-2: Quadratic
34
34
  const t41 = r01 * r00;
35
35
  const t43 = r11 * r10;
36
36
  const t48 = r11 * r12;
@@ -208,15 +208,15 @@ export class TetrahedralMesh {
208
208
  */
209
209
  removeTetrasConnectedToPoints(range_start: number, range_end: number): void;
210
210
  /**
211
- *
211
+ * Note that this method does not guarantee to find the containing tet in case of concave mesh, that is - if there is a gap between the starting tet and the countaining tet
212
212
  * @param {number} x
213
213
  * @param {number} y
214
214
  * @param {number} z
215
215
  * @param {number[]} points Positions of vertices of tetrahedrons
216
- * @param {number} [hint_tetrahedron]
216
+ * @param {number} [start_tetrahedron]
217
217
  * @returns {number} index of tetra or -1 if no containing tetra found
218
218
  */
219
- findTetraContainingPoint(x: number, y: number, z: number, points: number[], hint_tetrahedron?: number): number;
219
+ walkToTetraContainingPoint(x: number, y: number, z: number, points: number[], start_tetrahedron?: number): number;
220
220
  /**
221
221
  * Relocate tetrahedron in memory, patches neighbourhood links as well
222
222
  * NOTE: The destination slot will be overwritten. This is a dangerous method that can break the topology, make sure you fully understand what you are doing when using it
@@ -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;;;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;;;;;;;;OAQG;IACH,4BAPW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,qBACR,MAAM,GACJ,MAAM,CAyDlB;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;6BA1tB4B,iCAAiC"}
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;;;;;;;;OAQG;IACH,8BAPW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CA8DlB;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;6BA/tB4B,iCAAiC"}
@@ -522,19 +522,19 @@ export class TetrahedralMesh {
522
522
  }
523
523
 
524
524
  /**
525
- *
525
+ * Note that this method does not guarantee to find the containing tet in case of concave mesh, that is - if there is a gap between the starting tet and the countaining tet
526
526
  * @param {number} x
527
527
  * @param {number} y
528
528
  * @param {number} z
529
529
  * @param {number[]} points Positions of vertices of tetrahedrons
530
- * @param {number} [hint_tetrahedron]
530
+ * @param {number} [start_tetrahedron]
531
531
  * @returns {number} index of tetra or -1 if no containing tetra found
532
532
  */
533
- findTetraContainingPoint(x, y, z, points, hint_tetrahedron = 0) {
533
+ walkToTetraContainingPoint(x, y, z, points, start_tetrahedron = 0) {
534
534
 
535
535
  let entering_face = 4;
536
536
 
537
- let cur_tet = hint_tetrahedron;
537
+ let cur_tet = start_tetrahedron;
538
538
 
539
539
  let i;
540
540
  while (true) {
@@ -570,7 +570,12 @@ export class TetrahedralMesh {
570
570
  // point is outside the tet on the neighbour's side, move in that direction
571
571
  const neighbour = this.getNeighbour(cur_tet, i);
572
572
 
573
- assert.notEqual(neighbour, INVALID_NEIGHBOUR, 'walked outside of the mesh');
573
+ if(neighbour === INVALID_NEIGHBOUR){
574
+ // walked outside the mesh, point is not contained within
575
+ return -1;
576
+ }
577
+
578
+ // assert.notEqual(neighbour, INVALID_NEIGHBOUR, 'walked outside of the mesh');
574
579
 
575
580
  cur_tet = neighbour >>> 2;
576
581
  entering_face = neighbour & 3;
@@ -1,3 +1,9 @@
1
- export function triangle_encode_rasterized_depth(barycentric_x: any, barycentric_y: any): number;
1
+ /**
2
+ *
3
+ * @param {number} barycentric_x
4
+ * @param {number} barycentric_y
5
+ * @returns {number}
6
+ */
7
+ export function triangle_encode_rasterized_depth(barycentric_x: number, barycentric_y: number): number;
2
8
  export function triangle_decode_depth(encodedDepth: any, input_offset: any, barycentric_x: any, barycentric_y: any): number;
3
9
  //# sourceMappingURL=triangle_encode_rasterized_depth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"triangle_encode_rasterized_depth.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js"],"names":[],"mappings":"AAEA,iGA6CC;AAkBD,4HAwCC"}
1
+ {"version":3,"file":"triangle_encode_rasterized_depth.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,gEAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CA+ClB;AAkBD,4HAwCC"}
@@ -1,5 +1,11 @@
1
1
  import { uint8_to_float } from "../../../../binary/uint8_to_float.js";
2
2
 
3
+ /**
4
+ *
5
+ * @param {number} barycentric_x
6
+ * @param {number} barycentric_y
7
+ * @returns {number}
8
+ */
3
9
  export function triangle_encode_rasterized_depth(barycentric_x, barycentric_y) {
4
10
  const sampleY = (barycentric_y * 4.0) >>> 0;
5
11
  const sampleX = (barycentric_x * 4.0) >>> 0;
@@ -1 +1 @@
1
- {"version":3,"file":"v3_distance.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_distance.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,gCARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAKlB"}
1
+ {"version":3,"file":"v3_distance.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_distance.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,gCARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAOlB"}
@@ -1,5 +1,3 @@
1
- import { v3_distance_sqr } from "./v3_distance_sqr.js";
2
-
3
1
  /**
4
2
  *
5
3
  * @param {number} x0
@@ -10,7 +8,9 @@ import { v3_distance_sqr } from "./v3_distance_sqr.js";
10
8
  * @param {number} z1
11
9
  * @returns {number}
12
10
  */
13
- export function v3_distance(x0, y0, z0, x1, y1, z1) {
14
-
15
- return Math.sqrt(v3_distance_sqr(x0, y0, z0, x1, y1, z1));
11
+ export function v3_distance(
12
+ x0, y0, z0,
13
+ x1, y1, z1
14
+ ) {
15
+ return Math.hypot(x1 - x0, y1 - y0, z1 - z0);
16
16
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {number[]} result
4
+ * @param {number} result_offset
5
+ * @param {TetrahedralMesh} mesh
6
+ * @param {number} vertex_index
7
+ * @returns {number}
8
+ */
9
+ export function tetrahedral_mesh_find_tets_attached_to_vertex(result: number[], result_offset: number, mesh: TetrahedralMesh, vertex_index: number): number;
10
+ //# sourceMappingURL=tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tetrahedral_mesh_find_tets_attached_to_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,sEANW,MAAM,EAAE,iBACR,MAAM,uCAEN,MAAM,GACJ,MAAM,CAyBlB"}
@@ -0,0 +1,34 @@
1
+ import { assert } from "../../../assert.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} result
6
+ * @param {number} result_offset
7
+ * @param {TetrahedralMesh} mesh
8
+ * @param {number} vertex_index
9
+ * @returns {number}
10
+ */
11
+ export function tetrahedral_mesh_find_tets_attached_to_vertex(
12
+ result, result_offset,
13
+ mesh, vertex_index
14
+ ) {
15
+
16
+ assert.isNonNegativeInteger(vertex_index, "vertex_index");
17
+
18
+ let offset = result_offset;
19
+
20
+ mesh.forEach((tet) => {
21
+
22
+ for (let i = 0; i < 4; i++) {
23
+ const vert = mesh.getVertexIndex(tet, i);
24
+
25
+ if (vert === vertex_index) {
26
+ result[offset++] = tet;
27
+ break;
28
+ }
29
+ }
30
+
31
+ });
32
+
33
+ return offset - result_offset;
34
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.js"],"names":[],"mappings":"AAEA;IAgDI;;;;OAIG;IACH,yBAFa,QAAQ,CAQpB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,QAAQ,CAYpB;IA3ED;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV,mBAEC;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAKnB;IAED,eAEC;IAED;;;aAMC;IAmCL;;;OAGG;IACH,qBAFU,OAAO,CAEY;CAP5B"}
1
+ {"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.js"],"names":[],"mappings":"AAEA;IAyDI;;;;OAIG;IACH,yBAFa,QAAQ,CAQpB;IAGD;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,QAAQ,CAQpB;IAjFD;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV,mBAEC;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAKnB;IAED;;;;OAIG;IACH,QAHW,MAAM,QACN,MAAM,QAQhB;IAED,eAEC;IAED;;;aAEC;IAgCL;;;OAGG;IACH,qBAFU,OAAO,CAEY;CAP5B"}