@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
@@ -5,7 +5,11 @@
5
5
  * @param {Map<*,string>} [classNames]
6
6
  */
7
7
  export function serializeNodeGraphToJSON({ graph, serializers, classNames }: NodeGraph): {
8
- nodes: any[];
8
+ nodes: {
9
+ id: any;
10
+ description: number;
11
+ parameters: {};
12
+ }[];
9
13
  connections: any[];
10
14
  descriptions: any[];
11
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"serializeNodeGraphToJSON.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/json/serializeNodeGraphToJSON.js"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH;;;;EAwEC"}
1
+ {"version":3,"file":"serializeNodeGraphToJSON.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/json/serializeNodeGraphToJSON.js"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH;;;;;;;;EA6EC"}
@@ -49,7 +49,9 @@ export function serializeNodeGraphToJSON({ graph, serializers = new Map(), class
49
49
  const descriptions = [];
50
50
 
51
51
  // extract node descriptions
52
- graph.traverseNodes(node => {
52
+ const node_instances = graph.getNodes();
53
+ for (let i = 0; i < node_instances.length; i++) {
54
+ const node = node_instances[i];
53
55
 
54
56
  const description = node.description;
55
57
 
@@ -57,7 +59,7 @@ export function serializeNodeGraphToJSON({ graph, serializers = new Map(), class
57
59
 
58
60
  if (index !== -1) {
59
61
  // already recorded
60
- return;
62
+ continue;
61
63
  }
62
64
 
63
65
  index = description_objects.length;
@@ -66,19 +68,22 @@ export function serializeNodeGraphToJSON({ graph, serializers = new Map(), class
66
68
  description_to_index_map.set(description, index);
67
69
 
68
70
  descriptions[index] = abstractJSONSerializer(description, serializers, classNames);
69
- });
71
+ }
70
72
 
71
73
  const nodes = [];
72
74
 
73
- graph.traverseNodes(node => {
75
+ for (let i = 0; i < node_instances.length; i++) {
76
+ const node = node_instances[i];
77
+
78
+ const parameters = nodeParametersToJSON(node, serializers, classNames);
74
79
 
75
80
  nodes.push({
76
81
  id: node.id,
77
82
  description: description_to_index_map.get(node.description),
78
- parameters: nodeParametersToJSON(node, serializers, classNames)
83
+ parameters: parameters
79
84
  });
80
85
 
81
- });
86
+ }
82
87
 
83
88
  const connections = [];
84
89
 
@@ -1 +1 @@
1
- {"version":3,"file":"AssetLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/AssetLoader.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACI;;;OAGG;IACH,2BAAoB;IAEpB;;;OAGG;IACH,SAFU,GAAG,CAEE;IAEf;;;;OAIG;IACH,0CAFW,GAAG,iBAKb;IAED;;OAEG;IACH,wBAEC;IAED;;;;;;;OAOG;IACH,qCALW,MAAM,kBACG,KAAK,kDAMxB;CACJ"}
1
+ {"version":3,"file":"AssetLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/AssetLoader.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACI;;;OAGG;IACH,2BAAoB;IAEpB;;;OAGG;IACH,SAFU,GAAG,CAEE;IAEf;;;;OAIG;IACH,0CAFW,GAAG,iBAKb;IAED;;OAEG;IACH,wBAEC;IAED;;;;;;;OAOG;IACH,qCALW,MAAM,wDAOhB;CACJ"}
@@ -36,7 +36,7 @@ export class AssetLoader {
36
36
  *
37
37
  * @param {AssetRequestScope} scope
38
38
  * @param {string} path
39
- * @param {function(Asset)} success
39
+ * @param {function(asset:Asset)} success
40
40
  * @param {function} failure
41
41
  * @param {function(current:number, total:number)} progress
42
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CA8DnB"}
1
+ {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CAmEnB"}
@@ -93,7 +93,12 @@ export function textureImagesEqual(a, b) {
93
93
  return false;
94
94
  }
95
95
 
96
- if (a instanceof ImageBitmap && b instanceof ImageBitmap) {
96
+ if (
97
+ // check that browser/environment has the class at all to avoid potential exceptions
98
+ // Required for Safari below version 15.6
99
+ ImageBitmap !== undefined
100
+ && (a instanceof ImageBitmap && b instanceof ImageBitmap)
101
+ ) {
97
102
  return computeImageBitmapEquality(a, b);
98
103
  }
99
104
 
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAkCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAiClB"}
1
+ {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAuCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAiClB"}
@@ -1,8 +1,8 @@
1
- import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
2
1
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
3
- import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
4
2
  import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
3
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
5
4
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
5
+ import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
6
6
 
7
7
  /**
8
8
  *
@@ -35,7 +35,12 @@ export function computeImageDataHash(image) {
35
35
 
36
36
  let result = 0;
37
37
 
38
- if (image instanceof ImageBitmap) {
38
+ if (
39
+ // check that browser/environment has the class at all to avoid potential exceptions
40
+ // Required for Safari below version 15.6
41
+ ImageBitmap !== undefined
42
+ && (image instanceof ImageBitmap)
43
+ ) {
39
44
  result = computeImageBitmapHash(image);
40
45
  } else if (image instanceof HTMLImageElement) {
41
46
  result = computeStringHash(image.src);
@@ -1 +1 @@
1
- {"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"AAsCA;IA4iBI;;;;;OAKG;IACH,sBAJW,oBAAoB,uBAElB,kBAAkB,CAS9B;IAnjBG;;;;OAIG;IACH,wBAA2B;IAE3B;;;;OAIG;IACH,gCAAmC;IAEnC;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAEK;IACrB;;;OAGG;IACH,cAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,gBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,6BAAgC;IAEhC;;;;OAIG;IACH,kCAAqC;IAGrC;;;;;OAKG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,8BAAiC;IAEjC;;;;OAIG;IACH,wBAAuC;IAEvC;;;;OAIG;IACH,mBAAsB;IAEtB,eAAiB;IACjB,kBAAoB;IAEpB;;;;OAIG;IACH,oBAAqC;IAErC,kFAAqC;IAErC,mBAAqB;IAGzB,qBA8BC;IAED;;;OAGG;IACH,6BAUC;IAED;;;OAGG;IACH,+BAcC;IAED;;;OAGG;IACH,4BAEC;IAED,gBAIC;IAED;;;OAGG;IACH,sBAFW,oBAAoB,QAU9B;IA4CD;;;OAGG;IACH,4BAFW,MAAM,QAAQ,GAAC,MAAM,cAAc,QAS7C;IAED;;;OAGG;IACH,kBAFW,MAAM,QAWhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QA6BhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;OAIG;IACH,kBAHW,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAWhB;IAED,+BAMC;IAED;;;;OAIG;IACH,qCAEC;IAED;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,YAFY,MAAM,MAAI,CAIrB;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,sDAcC;IAED;;;OAGG;IACH,6BAoDC;IAED,cAwEC;;CAgBJ;;;;;+BAtlBM,OAAO;qBAAP,OAAO;yBAQW,+BAA+B"}
1
+ {"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"AAuCA;IAqiBI;;;;;OAKG;IACH,sBAJW,oBAAoB,uBAElB,kBAAkB,CAS9B;IA5iBG;;;;OAIG;IACH,wBAA2B;IAE3B;;;;OAIG;IACH,gCAAmC;IAEnC;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAEK;IACrB;;;OAGG;IACH,cAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,gBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,6BAAgC;IAEhC;;;;OAIG;IACH,kCAAqC;IAGrC;;;;;OAKG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,8BAAiC;IAEjC;;;;OAIG;IACH,wBAAuC;IAEvC;;;;OAIG;IACH,mBAAsB;IAEtB,eAAiB;IACjB,kBAAoB;IAEpB;;;;OAIG;IACH,oBAAqC;IAErC,kFAAqC;IAErC,mBAAqB;IAGzB,qBA8BC;IAED;;;OAGG;IACH,6BAUC;IAED;;;OAGG;IACH,+BAcC;IAED;;;OAGG;IACH,4BAEC;IAED,gBAIC;IAED;;;OAGG;IACH,sBAFW,oBAAoB,QAU9B;IA4CD;;;OAGG;IACH,4BAFW,MAAM,QAAQ,GAAC,MAAM,cAAc,QAS7C;IAED;;;OAGG;IACH,kBAFW,MAAM,QAWhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QA6BhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;OAIG;IACH,kBAHW,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAWhB;IAED,+BAMC;IAED;;;;OAIG;IACH,qCAEC;IAED;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,YAFY,MAAM,MAAI,CAIrB;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,sDAcC;IAED;;;OAGG;IACH,6BAoDC;IAED,cAiEC;;CAgBJ;;;;;+BAhlBM,OAAO;qBAAP,OAAO;yBAQW,+BAA+B"}
@@ -9,17 +9,18 @@ import {
9
9
  MeshDepthMaterial,
10
10
  RGBADepthPacking
11
11
  } from 'three';
12
- import ThreeFactory from "../../three/ThreeFactory.js";
13
- import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
14
- import { composeCompile } from "../../material/composeCompile.js";
12
+ import { Cache } from "../../../../core/cache/Cache.js";
13
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
15
14
  import { typed_array_copy } from "../../../../core/collection/array/typed/typed_array_copy.js";
16
- import { rewriteMaterial } from "./rewriteMaterial.js";
17
15
  import { max3 } from "../../../../core/math/max3.js";
18
16
  import { min2 } from "../../../../core/math/min2.js";
19
- import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
20
- import { array_copy } from "../../../../core/collection/array/array_copy.js";
21
- import { Cache } from "../../../../core/cache/Cache.js";
22
17
  import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
18
+ import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
19
+ import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
20
+ import { composeCompile } from "../../material/composeCompile.js";
21
+ import ThreeFactory from "../../three/ThreeFactory.js";
22
+ import { geometry_copy } from "./geometry_copy.js";
23
+ import { rewriteMaterial } from "./rewriteMaterial.js";
23
24
 
24
25
  /**
25
26
  * @typedef {Object} CacheKey
@@ -533,14 +534,7 @@ export class InstancedMeshGroup {
533
534
  geometry.dynamic = true;
534
535
 
535
536
  //copy instance attributes
536
- geometry.index = instance.index;
537
- for (let attributeName in instance.attributes) {
538
- if (!instance.attributes.hasOwnProperty(attributeName)) {
539
- continue;
540
- }
541
-
542
- geometry.attributes[attributeName] = instance.attributes[attributeName];
543
- }
537
+ geometry_copy(geometry, instance);
544
538
 
545
539
  //build instanced attributes
546
540
  const newTransformArray = new Float32Array(this.capacity * 16);
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {BufferGeometry} target
4
+ * @param {BufferGeometry} source
5
+ */
6
+ export function geometry_copy(target: BufferGeometry, source: BufferGeometry): void;
7
+ //# sourceMappingURL=geometry_copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry_copy.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/geometry_copy.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oFASC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param {BufferGeometry} target
4
+ * @param {BufferGeometry} source
5
+ */
6
+ export function geometry_copy(target, source) {
7
+ target.index = source.index;
8
+ for (let attributeName in source.attributes) {
9
+ if (!source.attributes.hasOwnProperty(attributeName)) {
10
+ continue;
11
+ }
12
+
13
+ target.attributes[attributeName] = source.attributes[attributeName];
14
+ }
15
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":";AAoBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAsOvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,WAAU,IAAI,CAAA;KAAC,EAAE,GAIrC,mBAAmB,CAqE/B;CACJ;oCAxVmC,0BAA0B;qBACnC,WAAW"}
1
+ {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":";AAoBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAgPvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,WAAU,IAAI,CAAA;KAAC,EAAE,GAIrC,mBAAmB,CAmE/B;CACJ;oCApVmC,0BAA0B;qBAhBnC,WAAW"}
@@ -1,21 +1,21 @@
1
- import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
2
- import { assert } from "../../../../core/assert.js";
3
- import { isPowerOfTwo } from "../../../../core/math/isPowerOrTwo.js";
4
- import { Mesh, OrthographicCamera, Scene, Vector4, WebGLMultipleRenderTargets } from "three";
5
- import { ImpostorDescription } from "./ImpostorDescription.js";
6
1
  import { mat4, vec3 } from "gl-matrix";
7
- import { BakeShaderStandard } from "./shader/BakeShaderStandard.js";
8
- import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
9
- import Signal from "../../../../core/events/signal/Signal.js";
2
+ import { Mesh, OrthographicCamera, Scene, Vector4, WebGLMultipleRenderTargets } from "three";
3
+ import { assert } from "../../../../core/assert.js";
4
+ import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
10
5
  import { HashMap } from "../../../../core/collection/map/HashMap.js";
11
- import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
6
+ import Signal from "../../../../core/events/signal/Signal.js";
7
+ import { isPowerOfTwo } from "../../../../core/math/isPowerOrTwo.js";
12
8
  import { computeMaterialEquality } from "../../../asset/loaders/material/computeMaterialEquality.js";
13
- import { UvEncoder } from "./grid/UvEncoder.js";
14
- import { OctahedralUvEncoder } from "./grid/OctahedralUvEncoder.js";
15
- import { HemiOctahedralUvEncoder } from "./grid/HemiOctahedralUvEncoder.js";
16
- import { prepare_bake_material } from "./bake/prepare_bake_material.js";
17
- import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
9
+ import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
10
+ import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
18
11
  import { compute_bounding_sphere } from "./bake/compute_bounding_sphere.js";
12
+ import { prepare_bake_material } from "./bake/prepare_bake_material.js";
13
+ import { HemiOctahedralUvEncoder } from "./grid/HemiOctahedralUvEncoder.js";
14
+ import { OctahedralUvEncoder } from "./grid/OctahedralUvEncoder.js";
15
+ import { UvEncoder } from "./grid/UvEncoder.js";
16
+ import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
17
+ import { ImpostorDescription } from "./ImpostorDescription.js";
18
+ import { BakeShaderStandard } from "./shader/BakeShaderStandard.js";
19
19
  import { build_cutout_from_atlas_by_alpha } from "./util/build_cutout_from_atlas_by_alpha.js";
20
20
 
21
21
  export class ImpostorBaker {
@@ -62,6 +62,7 @@ export class ImpostorBaker {
62
62
 
63
63
  const cam = new OrthographicCamera();
64
64
  const rt = new WebGLMultipleRenderTargets(resolution, resolution, 3);
65
+
65
66
  rt.scissorTest = false;
66
67
  rt.stencilBuffer = false;
67
68
 
@@ -185,14 +186,14 @@ export class ImpostorBaker {
185
186
  const max_frame_index = frames - 1;
186
187
 
187
188
  for (let i = 0; i < frames; i++) {
188
- const octahedron_u = max_frame_index > 0 ? (i / max_frame_index) : 0;
189
+ const frame_u = max_frame_index > 0 ? (i / max_frame_index) : 0;
189
190
 
190
191
  for (let j = 0; j < frames; j++) {
191
192
 
192
- const octahedron_v = max_frame_index > 0 ? (j / max_frame_index) : 0;
193
+ const frame_v = max_frame_index > 0 ? (j / max_frame_index) : 0;
193
194
 
194
195
  // compute vector direction where to place camera
195
- encoder.uv_to_unit(unit_sphere_direction, [octahedron_u, octahedron_v]);
196
+ encoder.uv_to_unit(unit_sphere_direction, [frame_u, frame_v]);
196
197
 
197
198
  // offset by the radius of the sphere
198
199
  const camera_px = distance * unit_sphere_direction[0] + bounding_sphere[0];
@@ -206,6 +207,7 @@ export class ImpostorBaker {
206
207
  cam.right = distance;
207
208
  cam.top = distance;
208
209
  cam.bottom = -distance;
210
+
209
211
  cam.near = 0;
210
212
  cam.far = distance * 2;
211
213
 
@@ -265,7 +267,15 @@ export class ImpostorBaker {
265
267
  id.rt = rt;
266
268
 
267
269
  // build cutout
268
- id.cutout = build_cutout_from_atlas_by_alpha(id, renderer);
270
+ id.cutout = build_cutout_from_atlas_by_alpha({
271
+ impostor: id,
272
+ renderer,
273
+ vertex_limit: 5
274
+ });
275
+
276
+
277
+ id.sphere_radius = bounding_sphere[3];
278
+ vec3.copy(id.offset, bounding_sphere);
269
279
 
270
280
  return id;
271
281
  }
@@ -339,8 +349,6 @@ export class ImpostorBaker {
339
349
  });
340
350
 
341
351
  r.capture_type = type;
342
- r.sphere_radius = bounding_sphere[3];
343
- vec3.copy(r.offset, bounding_sphere);
344
352
 
345
353
  console.timeEnd('bake');
346
354
 
@@ -1,3 +1,4 @@
1
+ export type ImpostorCaptureType = number;
1
2
  export namespace ImpostorCaptureType {
2
3
  let FullSphere: number;
3
4
  let Hemisphere: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ImpostorCaptureType.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"ImpostorCaptureType.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js"],"names":[],"mappings":"kCAEU,MAAM"}
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
1
5
  export const ImpostorCaptureType = {
2
6
  /**
3
7
  * Capture from all sides
@@ -1,6 +1,6 @@
1
1
  import { vec3 } from "gl-matrix";
2
2
  import { v3_dot } from "../../../../../core/geom/vec3/v3_dot.js";
3
- import { sign } from "../../../../../core/math/sign.js";
3
+ import { sign_not_zero } from "../../../../../core/math/sign_not_zero.js";
4
4
  import { UvEncoder } from "./UvEncoder.js";
5
5
 
6
6
  export class OctahedralUvEncoder extends UvEncoder {
@@ -13,8 +13,8 @@ export class OctahedralUvEncoder extends UvEncoder {
13
13
  const py = 1 - abs_x - abs_z;
14
14
 
15
15
  if (py < 0) {
16
- px = sign(px) * (1 - abs_z);
17
- pz = sign(pz) * (1 - abs_x);
16
+ px = sign_not_zero(px) * (1 - abs_z);
17
+ pz = sign_not_zero(pz) * (1 - abs_x);
18
18
  }
19
19
 
20
20
  output[0] = px;
@@ -30,9 +30,9 @@ export class OctahedralUvEncoder extends UvEncoder {
30
30
  const input_y = input[1];
31
31
  const input_z = input[2];
32
32
 
33
- const octant_x = sign(input_x);
34
- const octant_y = sign(input_y);
35
- const octant_z = sign(input_z);
33
+ const octant_x = sign_not_zero(input_x);
34
+ const octant_y = sign_not_zero(input_y);
35
+ const octant_z = sign_not_zero(input_z);
36
36
 
37
37
  // |x| + |y| + |z| = 1
38
38
  const sum = v3_dot(input_x, input_y, input_z, octant_x, octant_y, octant_z);
@@ -38,7 +38,14 @@ async function main(engine) {
38
38
  engine,
39
39
  enableWater: false,
40
40
  cameraFieldOfView: 45,
41
- showFps: false
41
+ showFps: false,
42
+ enableLights: false
43
+ });
44
+
45
+ await EngineHarness.buildLights({
46
+ engine,
47
+ sunIntensity: 0,
48
+ ambientIntensity: 1
42
49
  });
43
50
 
44
51
  const ecd = engine.entityManager.dataset;
@@ -47,13 +54,15 @@ async function main(engine) {
47
54
  const renderer = engine.graphics.renderer;
48
55
  baker.renderer = renderer;
49
56
 
50
-
51
57
  // const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
58
+ // const path = 'data/models/samples/textured_unit_cube.gltf';
59
+ // const path = 'data/models/samples/teapot.gltf';
60
+ const path = 'data/models/samples/just_a_girl/scene.gltf';
52
61
  // const path = 'data/models/road_bike/road_bike.gltf'; //large CAD-type model
53
62
  // const path = 'data/models/LowPolyTownshipSet/Barrel/model.gltf';
54
63
  // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
55
64
  // const path = 'data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf';
56
- const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
65
+ // const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
57
66
  // const path = 'data/models/samples/transform-hierarchy.glb';
58
67
  // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
59
68
  // const path = 'data/models/snaps/cube_blue.gltf';
@@ -66,9 +75,9 @@ async function main(engine) {
66
75
  // console.profile('bake');
67
76
  const id = baker.bake({
68
77
  objects,
69
- frames: 12,
78
+ frames: 8,
70
79
  resolution: 1024,
71
- type: ImpostorCaptureType.Hemisphere
80
+ type: ImpostorCaptureType.FullSphere
72
81
  });
73
82
  // console.profileEnd('bake');
74
83
 
@@ -80,14 +89,14 @@ async function main(engine) {
80
89
  mode: 'diffuse'
81
90
  });
82
91
 
83
- ctrl.scale.setScalar(0.5);
92
+ ctrl.scale.setScalar(1);
84
93
 
85
94
  new Entity()
86
95
  .add(ViewportPosition.fromJSON({
87
96
  offset: new Vector2(0, 0)
88
97
  }))
89
98
  .add(GUIElement.fromView(ctrl))
90
- .build(ecd);
99
+ .build(ecd);
91
100
 
92
101
  // build out preview scene with impostor and the original
93
102
  const t0 = Transform.fromJSON({
@@ -3,7 +3,8 @@
3
3
  * A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
4
4
  * @param {ImpostorDescription} impostor
5
5
  * @param {THREE.WebGLRenderer} renderer
6
- * @returns {number}
6
+ * @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
7
+ * @returns {number[]}
7
8
  */
8
- export function build_cutout_from_atlas_by_alpha(impostor: ImpostorDescription, renderer: THREE.WebGLRenderer): number;
9
+ export function build_cutout_from_atlas_by_alpha({ impostor, renderer, vertex_limit }: ImpostorDescription): number[];
9
10
  //# sourceMappingURL=build_cutout_from_atlas_by_alpha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,0FAHW,MAAM,aAAa,GACjB,MAAM,CA4GlB"}
1
+ {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,6GAFa,MAAM,EAAE,CAqHpB"}
@@ -1,25 +1,38 @@
1
1
  //
2
2
 
3
- import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
3
+ import { assert } from "../../../../../core/assert.js";
4
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
5
+ import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
4
6
  import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
5
7
  import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
6
- import { array_copy } from "../../../../../core/collection/array/array_copy.js";
7
- import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
8
8
  import { max2 } from "../../../../../core/math/max2.js";
9
- import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
9
+ import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
10
+ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
10
11
  import {
11
12
  make_edge_condition_channel_threshold
12
13
  } from "../../../texture/sampler/search/make_edge_condition_channel_threshold.js";
13
- import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
14
+ import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
14
15
 
15
16
  /**
16
17
  * TODO For this specific use-case with octahedral impostors we can get away tracing a circular shape in general.
17
18
  * A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
18
19
  * @param {ImpostorDescription} impostor
19
20
  * @param {THREE.WebGLRenderer} renderer
20
- * @returns {number}
21
+ * @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
22
+ * @returns {number[]}
21
23
  */
22
- export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
24
+ export function build_cutout_from_atlas_by_alpha({
25
+
26
+ impostor,
27
+ renderer,
28
+ vertex_limit = 8
29
+ }) {
30
+
31
+ assert.isNonNegativeInteger(vertex_limit, 'vertex_limit');
32
+ assert.greaterThanOrEqual(vertex_limit, 3);
33
+
34
+ assert.defined(renderer, 'renderer');
35
+
23
36
  // get impostor data first
24
37
 
25
38
  const ctrl = renderSamplerFromTexture({
@@ -98,23 +111,21 @@ export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
98
111
  array_copy(filtered_edge_pixels, hpi * 2, hull_points, i * 2, 2);
99
112
  }
100
113
 
101
- const cutout_vertex_count = 8;
102
-
103
- const cutout_points = new Float32Array(cutout_vertex_count * 2);
114
+ const cutout_points = new Float32Array(vertex_limit * 2);
104
115
 
105
- fixed_convex_hull_relaxation(cutout_points, 0, cutout_vertex_count, hull_points, hull_point_indices.length);
116
+ fixed_convex_hull_relaxation(cutout_points, 0, vertex_limit, hull_points, hull_point_indices.length);
106
117
 
107
118
  // normalize points
108
- for (let i = 0; i < cutout_vertex_count; i++) {
119
+ for (let i = 0; i < vertex_limit; i++) {
109
120
  cutout_points[i * 2] /= frame_size;
110
121
  cutout_points[i * 2 + 1] /= frame_size;
111
122
  }
112
123
 
113
- const area = compute_polygon_area_2d(cutout_points, cutout_vertex_count);
124
+ const area = compute_polygon_area_2d(cutout_points, vertex_limit);
114
125
 
115
126
  console.log(`Cutout area: ${area}`);
116
127
 
117
- if (area >= 0.99 && cutout_vertex_count >= 4) {
128
+ if (area >= 0.99 && vertex_limit >= 4) {
118
129
  // default back to aligned quad, produced result is a degradation
119
130
  return new Float32Array([
120
131
  0, 0,
@@ -287,3 +287,4 @@ export function buildCanvasViewFromTexture({
287
287
  }
288
288
  }
289
289
  }
290
+
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AA0CA;IAoHI;;;OAGG;IACH,0CAMC;IAlBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAsBD,sBAIC;IAED,sBA2CC;IAED,eAuCC;IAED,4BA2BC;;CACJ;4CA5R2C,0DAA0D"}
1
+ {"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AAiCA;IAuII;;;OAGG;IACH,0CAOC;IAnBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAuBD,sBAIC;IAED,sBA2CC;IAED,eA2CC;IAED,4BA2BC;;CACJ;4CA3S2C,0DAA0D"}