@woosh/meep-engine 2.117.25 → 2.117.27

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 (28) hide show
  1. package/build/meep.cjs +4 -4
  2. package/build/meep.module.js +4 -4
  3. package/editor/ecs/component/editors/Sampler2DEditor.js +2 -2
  4. package/package.json +1 -1
  5. package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
  6. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +17 -9
  7. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts +3 -3
  8. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  9. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +5 -2
  10. package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.d.ts +10 -0
  11. package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.d.ts.map +1 -0
  12. package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js +45 -0
  13. package/src/core/geom/3d/sphere/sphere_fibonacci_point.d.ts +1 -1
  14. package/src/core/geom/3d/sphere/sphere_fibonacci_point.js +1 -1
  15. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +7 -0
  16. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  17. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +11 -0
  18. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +2 -2
  19. package/src/engine/graphics/canvas/computeImageCanvasEquality.js +3 -3
  20. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  21. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +2 -0
  22. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +4 -4
  23. package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
  24. package/src/engine/graphics/texture/html_canvas_to_sampler2d.d.ts +9 -0
  25. package/src/engine/graphics/texture/html_canvas_to_sampler2d.d.ts.map +1 -0
  26. package/src/engine/graphics/texture/{Canvas2Sampler2D.js → html_canvas_to_sampler2d.js} +2 -2
  27. package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts +0 -9
  28. package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts.map +0 -1
package/build/meep.cjs CHANGED
@@ -51205,7 +51205,7 @@ const context_cache = new WeakMap();
51205
51205
  * @param {HTMLCanvasElement} canvas
51206
51206
  * @returns {Sampler2D}
51207
51207
  */
51208
- function canvas2Sampler2D(canvas) {
51208
+ function html_canvas_to_sampler2d(canvas) {
51209
51209
  const width = canvas.width;
51210
51210
  const height = canvas.height;
51211
51211
 
@@ -51805,7 +51805,7 @@ class TerrainOverlay {
51805
51805
  * @param {number} [dHeight]
51806
51806
  */
51807
51807
  paintImage(image, dx, dy, dWidth, dHeight) {
51808
- const source = canvas2Sampler2D(image);
51808
+ const source = html_canvas_to_sampler2d(image);
51809
51809
 
51810
51810
  this.paintSampler(source, dx, dy, dWidth, dHeight);
51811
51811
  }
@@ -76798,8 +76798,8 @@ function computeImageCanvasEquality(a, b) {
76798
76798
  return false;
76799
76799
  }
76800
76800
 
76801
- const sampler_a = canvas2Sampler2D(a);
76802
- const sampler_b = canvas2Sampler2D(b);
76801
+ const sampler_a = html_canvas_to_sampler2d(a);
76802
+ const sampler_b = html_canvas_to_sampler2d(b);
76803
76803
 
76804
76804
  if(!sampler_a.equals(sampler_b)){
76805
76805
  return false;
@@ -51203,7 +51203,7 @@ const context_cache = new WeakMap();
51203
51203
  * @param {HTMLCanvasElement} canvas
51204
51204
  * @returns {Sampler2D}
51205
51205
  */
51206
- function canvas2Sampler2D(canvas) {
51206
+ function html_canvas_to_sampler2d(canvas) {
51207
51207
  const width = canvas.width;
51208
51208
  const height = canvas.height;
51209
51209
 
@@ -51803,7 +51803,7 @@ class TerrainOverlay {
51803
51803
  * @param {number} [dHeight]
51804
51804
  */
51805
51805
  paintImage(image, dx, dy, dWidth, dHeight) {
51806
- const source = canvas2Sampler2D(image);
51806
+ const source = html_canvas_to_sampler2d(image);
51807
51807
 
51808
51808
  this.paintSampler(source, dx, dy, dWidth, dHeight);
51809
51809
  }
@@ -76796,8 +76796,8 @@ function computeImageCanvasEquality(a, b) {
76796
76796
  return false;
76797
76797
  }
76798
76798
 
76799
- const sampler_a = canvas2Sampler2D(a);
76800
- const sampler_b = canvas2Sampler2D(b);
76799
+ const sampler_a = html_canvas_to_sampler2d(a);
76800
+ const sampler_b = html_canvas_to_sampler2d(b);
76801
76801
 
76802
76802
  if(!sampler_a.equals(sampler_b)){
76803
76803
  return false;
@@ -2,7 +2,7 @@ import {
2
2
  typedArrayConstructorByInstance
3
3
  } from "../../../../src/core/collection/array/typed/typedArrayConstructorByInstance.js";
4
4
  import { FrameRunner } from "../../../../src/engine/graphics/FrameRunner.js";
5
- import canvas2Sampler2D from "../../../../src/engine/graphics/texture/Canvas2Sampler2D.js";
5
+ import html_canvas_to_sampler2d from "../../../../src/engine/graphics/texture/html_canvas_to_sampler2d.js";
6
6
  import {
7
7
  copy_Sampler2D_channel_data
8
8
  } from "../../../../src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js";
@@ -93,7 +93,7 @@ function enable_drop(parent, element, field) {
93
93
  // ctx.drawImage(img, 0, 0);
94
94
  ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height); // stretch img to canvas size
95
95
 
96
- const file_data_sampler = canvas2Sampler2D(canvas);
96
+ const file_data_sampler = html_canvas_to_sampler2d(canvas);
97
97
 
98
98
  /**
99
99
  * @type {Sampler2D}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.117.25",
8
+ "version": "2.117.27",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QA8DhB"}
1
+ {"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QAsEhB"}
@@ -26,10 +26,18 @@ export function build_triangle_morton_codes(
26
26
  const aabb_size_y = aabb_y1 - aabb_y0;
27
27
  const aabb_size_z = aabb_z1 - aabb_z0;
28
28
 
29
+ /*
30
+ NOTE: to avoid division by 3 when computing triangle center, we instead add that factor into our morton scale
31
+ */
32
+
33
+ const aabb_3_x0 = aabb_x0 * 3;
34
+ const aabb_3_y0 = aabb_y0 * 3;
35
+ const aabb_3_z0 = aabb_z0 * 3;
36
+
29
37
  // compute multipliers to bring normalized values in range of 10bit unsigned integer each
30
- const morton_scale_x = aabb_size_x === 0 ? 0 : 1023 / aabb_size_x;
31
- const morton_scale_y = aabb_size_y === 0 ? 0 : 1023 / aabb_size_y;
32
- const morton_scale_z = aabb_size_z === 0 ? 0 : 1023 / aabb_size_z;
38
+ const morton_scale_x = aabb_size_x === 0 ? 0 : 1023 / (aabb_size_x*3);
39
+ const morton_scale_y = aabb_size_y === 0 ? 0 : 1023 / (aabb_size_y*3);
40
+ const morton_scale_z = aabb_size_z === 0 ? 0 : 1023 / (aabb_size_z*3);
33
41
 
34
42
  // compute morton codes
35
43
  for (let i = 0; i < tri_count; i++) {
@@ -58,14 +66,14 @@ export function build_triangle_morton_codes(
58
66
  const cy = position_array[c_address + 1];
59
67
  const cz = position_array[c_address + 2];
60
68
 
61
- const center_x = (ax + bx + cx) * 0.333333333;
62
- const center_y = (ay + by + cy) * 0.333333333;
63
- const center_z = (az + bz + cz) * 0.333333333;
69
+ const center_x = (ax + bx + cx);
70
+ const center_y = (ay + by + cy);
71
+ const center_z = (az + bz + cz);
64
72
 
65
73
  // normalize to 10bit range
66
- const ncx = (center_x - aabb_x0) * morton_scale_x;
67
- const ncy = (center_y - aabb_y0) * morton_scale_y;
68
- const ncz = (center_z - aabb_z0) * morton_scale_z;
74
+ const ncx = (center_x - aabb_3_x0) * morton_scale_x;
75
+ const ncy = (center_y - aabb_3_y0) * morton_scale_y;
76
+ const ncz = (center_z - aabb_3_z0) * morton_scale_z;
69
77
 
70
78
  morton_codes[i] = morton(
71
79
  Math.round(ncx),
@@ -2,11 +2,11 @@
2
2
  * Build the BVH bottom-up using spatial hash sorting
3
3
  * Resulting BVH is produced very quickly, has perfect balance and is of decent quality
4
4
  * @param {BVH} bvh
5
- * @param {number[]|Float32Array} index_array
6
- * @param {number[]|Float32Array} position_array
5
+ * @param {number[]|Uint32Array|Uint16Array} index_array
6
+ * @param {number[]|Float32Array|Float64Array} position_array
7
7
  * @param {Uint32Array} [morton_codes]
8
8
  * @param {AABB3} [bounds] Bounding box of the entire geometry, if not supplied will be computed internally
9
9
  */
10
- export function ebvh_build_for_geometry_morton(bvh: BVH, index_array: number[] | Float32Array, position_array: number[] | Float32Array, morton_codes?: Uint32Array, bounds?: AABB3): void;
10
+ export function ebvh_build_for_geometry_morton(bvh: BVH, index_array: number[] | Uint32Array | Uint16Array, position_array: number[] | Float32Array | Float64Array, morton_codes?: Uint32Array, bounds?: AABB3): void;
11
11
  import { AABB3 } from "../../geom/3d/aabb/AABB3.js";
12
12
  //# sourceMappingURL=ebvh_build_for_geometry_morton.d.ts.map
@@ -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,QAgHf;sBA/HqB,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":"AAYA;;;;;;;;GAQG;AACH,sEALW,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,kBAChC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,WAAW,WACX,KAAK,QAkHf;sBAlIqB,6BAA6B"}
@@ -8,13 +8,14 @@ import { max2 } from "../../math/max2.js";
8
8
  import { build_triangle_morton_codes } from "./build_triangle_morton_codes.js";
9
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
+ import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
11
12
 
12
13
  /**
13
14
  * Build the BVH bottom-up using spatial hash sorting
14
15
  * Resulting BVH is produced very quickly, has perfect balance and is of decent quality
15
16
  * @param {BVH} bvh
16
- * @param {number[]|Float32Array} index_array
17
- * @param {number[]|Float32Array} position_array
17
+ * @param {number[]|Uint32Array|Uint16Array} index_array
18
+ * @param {number[]|Float32Array|Float64Array} position_array
18
19
  * @param {Uint32Array} [morton_codes]
19
20
  * @param {AABB3} [bounds] Bounding box of the entire geometry, if not supplied will be computed internally
20
21
  */
@@ -122,6 +123,8 @@ export function ebvh_build_for_geometry_morton(
122
123
  bvh_uint32[node_address + COLUMN_HEIGHT] = 0;
123
124
  }
124
125
 
126
+ ebvh_nodes_sort_sah_local4(bvh, nodes, 0, tri_count );
127
+
125
128
  // record newly generated nodes as "unprocessed"
126
129
  const unprocessed_nodes = new Uint32Array(tri_count);
127
130
  array_copy(nodes, 0, unprocessed_nodes, 0, tri_count);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Sort consequent 4 nodes to reduce SAH among each consequent pair.
3
+ * Useful for optimizing topology for traversal.
4
+ * @param {BVH} bvh
5
+ * @param {number[]|Uint32Array} nodes
6
+ * @param {number} offset
7
+ * @param {number} count
8
+ */
9
+ export function ebvh_nodes_sort_sah_local4(bvh: BVH, nodes: number[] | Uint32Array, offset: number, count: number): void;
10
+ //# sourceMappingURL=ebvh_nodes_sort_sah_local4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ebvh_nodes_sort_sah_local4.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,4DAJW,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,SACN,MAAM,QAsChB"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Sort consequent 4 nodes to reduce SAH among each consequent pair.
3
+ * Useful for optimizing topology for traversal.
4
+ * @param {BVH} bvh
5
+ * @param {number[]|Uint32Array} nodes
6
+ * @param {number} offset
7
+ * @param {number} count
8
+ */
9
+ export function ebvh_nodes_sort_sah_local4(bvh, nodes, offset, count) {
10
+
11
+ // the bit manipulation rounds count down to nearest value divisible by 4
12
+ const end = offset + ((count >>> 2) << 2);
13
+
14
+ for (let i = offset; i < end; i += 4) {
15
+ const a = nodes[i];
16
+ const b = nodes[i + 1];
17
+ const c = nodes[i + 2];
18
+ const d = nodes[i + 3];
19
+
20
+ /*
21
+ possible combinations:
22
+ AB CD
23
+ AC BD
24
+ AD CB
25
+
26
+ Other combinations are not of interest as order among each pair is irrelevant for traversal performance
27
+ */
28
+ const cost0 = bvh.node_get_combined_surface_area(a, b) + bvh.node_get_combined_surface_area(c, d);
29
+ const cost1 = bvh.node_get_combined_surface_area(a, c) + bvh.node_get_combined_surface_area(b, d);
30
+ const cost2 = bvh.node_get_combined_surface_area(a, d) + bvh.node_get_combined_surface_area(c, b);
31
+
32
+ if (cost0 < cost1 && cost0 < cost2) {
33
+ // no change
34
+ } else if (cost1 < cost2) {
35
+ // swap C and B
36
+ nodes[i + 1] = c;
37
+ nodes[i + 2] = b;
38
+ } else {
39
+ // swap B and D
40
+ nodes[i + 1] = d;
41
+ nodes[i + 3] = b;
42
+ }
43
+ }
44
+
45
+ }
@@ -9,7 +9,7 @@
9
9
  * }
10
10
  *
11
11
  * The points go from z = +1 down to z = -1 in a spiral. To generate samples on the +z hemisphere, just stop before i > N/2.
12
- * @param {number[]|Float32Array} output
12
+ * @param {number[]|Float32Array} output 3d point
13
13
  * @param {number} output_offset
14
14
  * @param {number} i index of a point, from 0 to n-1
15
15
  * @param {number} n total number of points
@@ -25,7 +25,7 @@ const PHI = Math.sqrt(5) * 0.5 + 0.5;
25
25
  * }
26
26
  *
27
27
  * The points go from z = +1 down to z = -1 in a spiral. To generate samples on the +z hemisphere, just stop before i > N/2.
28
- * @param {number[]|Float32Array} output
28
+ * @param {number[]|Float32Array} output 3d point
29
29
  * @param {number} output_offset
30
30
  * @param {number} i index of a point, from 0 to n-1
31
31
  * @param {number} n total number of points
@@ -86,6 +86,13 @@ export class TetrahedralMesh {
86
86
  * @private
87
87
  */
88
88
  private __free_pointer;
89
+ /**
90
+ * Access raw data
91
+ * Useful for serialization
92
+ * If you intend to modify the data directly - make sure you fully understand the implications of doing so
93
+ * @returns {ArrayBuffer}
94
+ */
95
+ get data_buffer(): ArrayBuffer;
89
96
  /**
90
97
  * Exposes internal state, when this is false there are hole in the allocated memory
91
98
  * Useful mainly for serialization and debugging.
@@ -1 +1 @@
1
- {"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAiBA;;;;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;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAUC;IAED;;;;OAIG;IACH,WAFY,MAAM,EAAE,CAYnB;IAED;;;OAGG;IACH,cAWC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,QAFY,MAAM,CAMjB;IAED;;;;OAIG;IACH,oBAEC;IAGD;;;;OAIG;IACH,qBAYC;IAED;;;OAGG;IACH,yBAFW,MAAM,QAWhB;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,QA0ChB;IAED;;;;OAIG;IACH,WAFa,MAAM,CA2ClB;IAED;;;OAGG;IACH,kBAFW,YAAY,QAUtB;IAED;;;OAGG;IACH,oBAFW,YAAY,QAiBtB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAYjB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAUhB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BA/wB4B,iCAAiC"}
1
+ {"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAiBA;;;;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;IAI3B;;;;;OAKG;IACH,+BAEC;IAED;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAUC;IAED;;;;OAIG;IACH,WAFY,MAAM,EAAE,CAYnB;IAED;;;OAGG;IACH,cAWC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,QAFY,MAAM,CAMjB;IAED;;;;OAIG;IACH,oBAEC;IAGD;;;;OAIG;IACH,qBAYC;IAED;;;OAGG;IACH,yBAFW,MAAM,QAWhB;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,QA0ChB;IAED;;;;OAIG;IACH,WAFa,MAAM,CA2ClB;IAED;;;OAGG;IACH,kBAFW,YAAY,QAUtB;IAED;;;OAGG;IACH,oBAFW,YAAY,QAiBtB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAYjB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAUhB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BA1xB4B,iCAAiC"}
@@ -134,6 +134,17 @@ export class TetrahedralMesh {
134
134
  this.__free_pointer = 0;
135
135
  }
136
136
 
137
+
138
+ /**
139
+ * Access raw data
140
+ * Useful for serialization
141
+ * If you intend to modify the data directly - make sure you fully understand the implications of doing so
142
+ * @returns {ArrayBuffer}
143
+ */
144
+ get data_buffer(){
145
+ return this.__buffer;
146
+ }
147
+
137
148
  /**
138
149
  * Exposes internal state, when this is false there are hole in the allocated memory
139
150
  * Useful mainly for serialization and debugging.
@@ -8,7 +8,7 @@ import Vector1 from "../../../../core/geom/Vector1.js";
8
8
  import Vector2 from "../../../../core/geom/Vector2.js";
9
9
  import Vector4 from '../../../../core/geom/Vector4.js';
10
10
  import ObservedString from "../../../../core/model/ObservedString.js";
11
- import canvas2Sampler2D from "../../../graphics/texture/Canvas2Sampler2D.js";
11
+ import html_canvas_to_sampler2d from "../../../graphics/texture/html_canvas_to_sampler2d.js";
12
12
  import { sampler2d_scale } from "../../../graphics/texture/sampler/resize/sampler2d_scale.js";
13
13
  import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
14
14
  import { sampler2d_paint } from "../../../graphics/texture/sampler/sampler2d_paint.js";
@@ -293,7 +293,7 @@ export class TerrainOverlay {
293
293
  * @param {number} [dHeight]
294
294
  */
295
295
  paintImage(image, dx, dy, dWidth, dHeight) {
296
- const source = canvas2Sampler2D(image);
296
+ const source = html_canvas_to_sampler2d(image);
297
297
 
298
298
  this.paintSampler(source, dx, dy, dWidth, dHeight);
299
299
  }
@@ -1,4 +1,4 @@
1
- import canvas2Sampler2D from "../texture/Canvas2Sampler2D.js";
1
+ import html_canvas_to_sampler2d from "../texture/html_canvas_to_sampler2d.js";
2
2
 
3
3
 
4
4
  /**
@@ -20,8 +20,8 @@ export function computeImageCanvasEquality(a, b) {
20
20
  return false;
21
21
  }
22
22
 
23
- const sampler_a = canvas2Sampler2D(a);
24
- const sampler_b = canvas2Sampler2D(b);
23
+ const sampler_a = html_canvas_to_sampler2d(a);
24
+ const sampler_b = html_canvas_to_sampler2d(b);
25
25
 
26
26
  if(!sampler_a.equals(sampler_b)){
27
27
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAgCA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAG1B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,mBAAmB,CAAC,CAElC;IAmBtB;;;;OAIG;IACH,6BAA6C;IAiF7C,iBAOC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,mBAAmB,CAmB9B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAiCnB;IAED;;;;OAIG;IACH,iBAHW,cAAc,GACZ,OAAO,CAgBnB;IAED;;;;OAIG;IACH,yBAHW,MAAM,QAAQ,oBAKxB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QAavB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,IAAI,QA0Cd;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAsCnB;IAED;;;;;OAKG;IACH,WAJW,MAAM,EAAE,OACR,MAAM,EAAE,GAAC,IAAI,GACZ,MAAM,CA+CjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,QAkElB;;CACJ;oBA/gB8B,mCAAmC;+BAkBnC,qBAAqB;8BAJtB,kDAAkD;oCAC5C,0BAA0B;qBALzC,kCAAkC"}
1
+ {"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAiCA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAG1B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,mBAAmB,CAAC,CAElC;IAmBtB;;;;OAIG;IACH,6BAA6C;IAkF7C,iBAOC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,mBAAmB,CAmB9B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAiCnB;IAED;;;;OAIG;IACH,iBAHW,cAAc,GACZ,OAAO,CAgBnB;IAED;;;;OAIG;IACH,yBAHW,MAAM,QAAQ,oBAKxB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QAavB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,IAAI,QA0Cd;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAsCnB;IAED;;;;;OAKG;IACH,WAJW,MAAM,EAAE,OACR,MAAM,EAAE,GAAC,IAAI,GACZ,MAAM,CA+CjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,QAkElB;;CACJ;oBAjhB8B,mCAAmC;+BAmBnC,qBAAqB;8BAJtB,kDAAkD;oCAC5C,0BAA0B;qBALzC,kCAAkC"}
@@ -1,6 +1,7 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import { BVH, NULL_NODE } from "../../../../core/bvh2/bvh3/BVH.js";
3
3
  import { ebvh_build_hierarchy } from "../../../../core/bvh2/bvh3/ebvh_build_hierarchy.js";
4
+ import { ebvh_nodes_sort_sah_local4 } from "../../../../core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js";
4
5
  import { bvh_query_user_data_ray_segment } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.js";
5
6
  import { Cache } from "../../../../core/cache/Cache.js";
6
7
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
@@ -151,6 +152,7 @@ export class PathTracedScene {
151
152
  bvh.node_set_height(node, 0);
152
153
 
153
154
  }
155
+ ebvh_nodes_sort_sah_local4(bvh, nodes, 0, node_leaf_count);
154
156
 
155
157
  // record newly generated nodes as "unprocessed"
156
158
  const unprocessed_nodes = new Uint32Array(node_leaf_count);
@@ -67,8 +67,8 @@ vCanvas.css({
67
67
  * How many rays to use per-pixel
68
68
  * @type {number}
69
69
  */
70
- const PIXEL_SAMPLE_COUNT = 16;
71
- const PIXEL_RENDER_RATIO = 1;
70
+ const PIXEL_SAMPLE_COUNT = 1;
71
+ const PIXEL_RENDER_RATIO = 0.5;
72
72
 
73
73
  const scene = new PathTracedScene();
74
74
  const pt = new PathTracer();
@@ -534,8 +534,8 @@ async function start_renderer(camera) {
534
534
  // await prepare_scene_lucy(scene, camera);
535
535
  // await prepare_scene_rtiow(pt, camera);
536
536
  // await prepare_scene_sphere_01(pt, camera);
537
- await prepare_gi_box_scene(scene, camera);
538
- // await prepare_sponza(scene, camera);
537
+ // await prepare_gi_box_scene(scene, camera);
538
+ await prepare_sponza(scene, camera);
539
539
  // await prepare_attic_scene(scene, camera);
540
540
  // await prepare_scene_gltf({scene, camera, path, url: path});
541
541
 
@@ -382,7 +382,7 @@ async function main(engine) {
382
382
  // const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
383
383
  // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
384
384
  // const path = 'data/models/sibenik/3-window-less/model.gltf';
385
- // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
385
+ const path = 'data/models/sponza-pbr/gltf/sponza.glb';
386
386
  // const path = 'data/models/samples/susanne.glb';
387
387
  // const path = 'data/models/samples/teapot.gltf';
388
388
  // const path = 'data/models/samples/salle_de_bain/model.glb';
@@ -390,7 +390,7 @@ async function main(engine) {
390
390
  // const path = 'data/models/pica_pica/pica_pica.gltf';
391
391
  // const path = 'data/models/samples/gi_box_01/model.glb';
392
392
  // const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
393
- const path = 'customer_data/halon_scene.glb';
393
+ // const path = 'customer_data/halon_scene.glb';
394
394
 
395
395
  const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
396
396
  const gltf = mesh_asset.gltf;
@@ -0,0 +1,9 @@
1
+ export default html_canvas_to_sampler2d;
2
+ /**
3
+ *
4
+ * @param {HTMLCanvasElement} canvas
5
+ * @returns {Sampler2D}
6
+ */
7
+ declare function html_canvas_to_sampler2d(canvas: HTMLCanvasElement): Sampler2D;
8
+ import { Sampler2D } from './sampler/Sampler2D.js';
9
+ //# sourceMappingURL=html_canvas_to_sampler2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html_canvas_to_sampler2d.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/html_canvas_to_sampler2d.js"],"names":[],"mappings":";AAQA;;;;GAIG;AACH,kDAHW,iBAAiB,GACf,SAAS,CAmBrB;0BA9ByB,wBAAwB"}
@@ -11,7 +11,7 @@ const context_cache = new WeakMap();
11
11
  * @param {HTMLCanvasElement} canvas
12
12
  * @returns {Sampler2D}
13
13
  */
14
- function canvas2Sampler2D(canvas) {
14
+ function html_canvas_to_sampler2d(canvas) {
15
15
  const width = canvas.width;
16
16
  const height = canvas.height;
17
17
 
@@ -30,4 +30,4 @@ function canvas2Sampler2D(canvas) {
30
30
 
31
31
  }
32
32
 
33
- export default canvas2Sampler2D;
33
+ export default html_canvas_to_sampler2d;
@@ -1,9 +0,0 @@
1
- export default canvas2Sampler2D;
2
- /**
3
- *
4
- * @param {HTMLCanvasElement} canvas
5
- * @returns {Sampler2D}
6
- */
7
- declare function canvas2Sampler2D(canvas: HTMLCanvasElement): Sampler2D;
8
- import { Sampler2D } from './sampler/Sampler2D.js';
9
- //# sourceMappingURL=Canvas2Sampler2D.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Canvas2Sampler2D.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/Canvas2Sampler2D.js"],"names":[],"mappings":";AAQA;;;;GAIG;AACH,0CAHW,iBAAiB,GACf,SAAS,CAmBrB;0BA9ByB,wBAAwB"}