@woosh/meep-engine 2.109.5 → 2.109.7

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 (170) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +211 -179
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +211 -179
  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/collection/queue/Deque.d.ts.map +1 -1
  12. package/src/core/collection/queue/Deque.js +8 -5
  13. package/src/core/geom/3d/Ray3.js +1 -1
  14. package/src/core/geom/3d/aabb/AABB3.js +1 -1
  15. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
  16. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  17. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
  18. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
  19. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
  20. package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
  21. package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
  22. package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
  23. package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
  24. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
  25. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
  26. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
  27. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
  28. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
  29. package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
  30. package/src/core/geom/vec3/v3_distance.js +5 -5
  31. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
  32. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  33. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
  34. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
  35. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  36. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
  37. package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
  38. package/src/engine/asset/loaders/AssetLoader.js +1 -1
  39. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  40. package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
  41. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  42. package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
  43. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  44. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
  45. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
  46. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
  47. package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
  48. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  49. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
  50. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
  51. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
  52. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
  53. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
  54. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
  55. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
  56. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  57. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
  58. package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
  59. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  60. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +48 -33
  61. package/src/engine/graphics/sh3/gi/material/common.glsl +434 -0
  62. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
  63. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
  64. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
  65. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
  66. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
  67. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
  68. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
  69. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +53 -0
  70. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
  71. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
  72. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
  73. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
  74. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
  75. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
  76. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
  78. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
  79. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
  80. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
  81. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
  82. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
  83. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
  84. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
  85. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
  86. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
  87. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  88. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
  89. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
  90. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +67 -8
  91. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +10 -0
  92. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  93. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -41
  94. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
  95. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
  96. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
  97. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
  98. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
  99. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
  100. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
  101. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
  102. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
  103. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
  104. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
  105. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
  106. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
  107. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +146 -0
  108. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +159 -0
  109. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
  110. package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
  111. package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
  112. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
  113. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  114. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
  115. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  116. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
  117. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
  118. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  119. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
  120. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
  121. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
  122. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
  123. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
  124. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  125. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
  126. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  127. 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
  128. package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  129. 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
  130. package/src/engine/graphics/sh3/prototypeSH3Probe.js +40 -7
  131. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
  132. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
  133. package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
  134. package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
  135. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
  136. package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
  137. package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
  138. package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
  139. package/src/engine/graphics/texture/virtual/prototype.js +4 -3
  140. package/src/view/View.d.ts.map +1 -1
  141. package/src/view/View.js +2 -0
  142. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
  143. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
  144. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
  145. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
  146. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
  147. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
  148. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
  149. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
  150. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
  151. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
  152. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
  153. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
  154. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
  155. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
  156. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
  157. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
  158. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
  159. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
  160. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
  161. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
  162. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
  163. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
  164. /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
  165. /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
  166. /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
  167. /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
  168. /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
  169. /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
  170. /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
@@ -132,6 +132,14 @@ export class BVH {
132
132
  return this.__root;
133
133
  }
134
134
 
135
+ /**
136
+ * Make sure you understand what you're doing before using this
137
+ * @param {number} v
138
+ */
139
+ set root(v) {
140
+ this.__root = v;
141
+ }
142
+
135
143
  /**
136
144
  *
137
145
  * @returns {number}
@@ -1 +1 @@
1
- {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,sEALW,MAAM,EAAE,GAAC,YAAY,kBACrB,MAAM,EAAE,GAAC,YAAY,iBACrB,WAAW,WACX,KAAK,QA0Ff;sBAzGqB,6BAA6B"}
1
+ {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,sEALW,MAAM,EAAE,GAAC,YAAY,kBACrB,MAAM,EAAE,GAAC,YAAY,iBACrB,WAAW,WACX,KAAK,QA4Ff;sBA3GqB,6BAA6B"}
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAqFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA2BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,CAAC,GAAC,SAAS,CAiBvB;IAED;;;;;OAKG;IACH,iBAJW,CAAC,EAAE,kBACH,MAAM,GACJ,CAAC,EAAE,CAUf;IAoBL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;IAzBf;;;OAGG;IACH,qBAFa,UAAU,CAAC,EAAC,IAAI,CAAC,CAS7B;;CACJ"}
1
+ {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAqFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA4BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAED;;;;OAIG;IACH,yBAHW,MAAM,GACJ,CAAC,GAAC,SAAS,CAmBvB;IAED;;;;;OAKG;IACH,iBAJW,CAAC,EAAE,kBACH,MAAM,GACJ,CAAC,EAAE,CAUf;IAoBL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;IAzBf;;;OAGG;IACH,qBAFa,UAAU,CAAC,EAAC,IAAI,CAAC,CAS7B;;CACJ"}
@@ -117,8 +117,8 @@ export class Deque {
117
117
 
118
118
  let new_length = length * 2;
119
119
 
120
- // bigger than Integer.MAX_VALUE
121
120
  if (new_length > UINT32_MAX) {
121
+ // clamp to max uint32 value
122
122
  new_length = UINT32_MAX;
123
123
  }
124
124
 
@@ -148,7 +148,7 @@ export class Deque {
148
148
  * @return {boolean}
149
149
  */
150
150
  isEmpty() {
151
- return this.size() === 0;
151
+ return this.#status === STATUS_EMPTY;
152
152
  }
153
153
 
154
154
  clear() {
@@ -257,9 +257,10 @@ export class Deque {
257
257
 
258
258
  const data = this.#data;
259
259
  const capacity = data.length;
260
+ const head = this.#head;
260
261
 
261
262
  for (let i = 0; i < size; i++) {
262
- const index = (this.#head + i) % capacity;
263
+ const index = (head + i) % capacity;
263
264
 
264
265
  const el = data[index];
265
266
 
@@ -358,13 +359,15 @@ export class Deque {
358
359
  return undefined;
359
360
  }
360
361
 
362
+ const data = this.#data;
363
+
361
364
  /**
362
365
  *
363
366
  * @type {number}
364
367
  */
365
- const position = (this.#head + index) % this.#data.length;
368
+ const position = (this.#head + index) % data.length;
366
369
 
367
- return this.#data[position];
370
+ return data[position];
368
371
  }
369
372
 
370
373
  /**
@@ -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;
@@ -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
+ }