@woosh/meep-engine 2.111.0 → 2.111.2

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 (25) hide show
  1. package/build/meep.cjs +2 -1
  2. package/build/meep.module.js +2 -1
  3. package/package.json +1 -1
  4. package/src/core/events/signal/Signal.d.ts.map +1 -1
  5. package/src/core/events/signal/Signal.js +2 -1
  6. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +12 -7
  7. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  8. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +32 -13
  9. package/src/core/geom/3d/tetrahedra/cube_split_to_6_tetr.png +0 -0
  10. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts +2 -1
  11. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -1
  12. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +89 -35
  13. package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +1 -1
  14. package/src/core/geom/vec3/v3_array_immediate_add.d.ts +10 -0
  15. package/src/core/geom/vec3/v3_array_immediate_add.d.ts.map +1 -0
  16. package/src/core/geom/vec3/v3_array_immediate_add.js +19 -0
  17. package/src/core/model/node-graph/NodeGraph.d.ts +2 -2
  18. package/src/core/model/node-graph/node/NodeInstance.d.ts +5 -5
  19. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +10 -0
  20. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  21. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +17 -2
  22. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +1 -1
  23. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  24. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +15 -5
  25. package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
package/build/meep.cjs CHANGED
@@ -1015,7 +1015,8 @@ SignalHandler.prototype.isSignalHandler = true;
1015
1015
 
1016
1016
  /**
1017
1017
  * Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass
1018
- * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference. Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
1018
+ * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference.
1019
+ * Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
1019
1020
  * @example `const mouseDown = new Signal<MouseEvent>(); mouseDown.send1(myMouseEvent);`
1020
1021
  */
1021
1022
  class Signal {
@@ -1013,7 +1013,8 @@ SignalHandler.prototype.isSignalHandler = true;
1013
1013
 
1014
1014
  /**
1015
1015
  * Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass
1016
- * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference. Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
1016
+ * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference.
1017
+ * Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
1017
1018
  * @example `const mouseDown = new Signal<MouseEvent>(); mouseDown.send1(myMouseEvent);`
1018
1019
  */
1019
1020
  class Signal {
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.111.0",
8
+ "version": "2.111.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAcnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAOC;IA4BD;;;;;OAKG;IACH,oCAFa,OAAO,CA2CnB;IAED;;;;;;OAMG;IACH,kBAEC;IAqDD;;;OAGG;IACH,+BAoCC;IAGD;;;OAGG;IACH,cAoCC;IAED;;;;OAIG;IACH,sBAoCC;IAED;;;;OAIG;IACH,4BAmCC;IAED;;;;;OAKG;IACH,oCAoCC;IAED;;;;;;OAMG;IACH,4CAoCC;IAED;;;;;;;;OAQG;IACH,4DAoCC;IAED;;;;;;;;;;OAUG;IACH,4EAmCC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;;CAPxB"}
1
+ {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAcnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAOC;IA4BD;;;;;OAKG;IACH,oCAFa,OAAO,CA2CnB;IAED;;;;;;OAMG;IACH,kBAEC;IAqDD;;;OAGG;IACH,+BAoCC;IAGD;;;OAGG;IACH,cAoCC;IAED;;;;OAIG;IACH,sBAoCC;IAED;;;;OAIG;IACH,4BAmCC;IAED;;;;;OAKG;IACH,oCAoCC;IAED;;;;;;OAMG;IACH,4CAoCC;IAED;;;;;;;;OAQG;IACH,4DAoCC;IAED;;;;;;;;;;OAUG;IACH,4EAmCC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;;CAPxB"}
@@ -6,7 +6,8 @@ import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
6
6
 
7
7
  /**
8
8
  * Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass
9
- * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference. Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
9
+ * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference.
10
+ * Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
10
11
  * @example `const mouseDown = new Signal<MouseEvent>(); mouseDown.send1(myMouseEvent);`
11
12
  */
12
13
  export class Signal {
@@ -87,12 +87,9 @@ export class TetrahedralMesh {
87
87
  */
88
88
  private __free_pointer;
89
89
  /**
90
- * Only valid when the mesh is compacted
91
- * @return {number}
92
- */
93
- get count(): number;
94
- /**
95
- *
90
+ * Exposes internal state, when this is false there are hole in the allocated memory
91
+ * Useful mainly for serialization and debugging.
92
+ * When serializing, you would want to get rid of any holes first by calling {@link compact}
96
93
  * @return {boolean}
97
94
  */
98
95
  get isCompacted(): boolean;
@@ -110,6 +107,7 @@ export class TetrahedralMesh {
110
107
  getLive(): number[];
111
108
  /**
112
109
  * Clears all data from the mesh, making it contain 0 tetrahedrons
110
+ * Ensures that consequent allocation requests will be sequential
113
111
  */
114
112
  clear(): void;
115
113
  /**
@@ -124,9 +122,16 @@ export class TetrahedralMesh {
124
122
  getCapacity(): number;
125
123
  /**
126
124
  * How many tetrahedrons are contained in the mesh, includes any unallocated tetrahedrons
125
+ * @deprecated use {@link count} instead
127
126
  * @return {number}
128
127
  */
129
128
  size(): number;
129
+ /**
130
+ * Number of currently live tetrahedrons.
131
+ * Excludes unallocated tetrahedrons.
132
+ * @return {number}
133
+ */
134
+ get count(): number;
130
135
  /**
131
136
  * Grow capacity to at least the specified size
132
137
  * @private
@@ -202,7 +207,7 @@ export class TetrahedralMesh {
202
207
  */
203
208
  disconnect(tetra_index: number): void;
204
209
  /**
205
- * Remove tetrahedron
210
+ * Remove tetrahedron, de-allocating memory
206
211
  * Please note that if there are any dangling references in the mesh neighbourhood - you will need to take care of that separately
207
212
  * @param {number} tetra_index
208
213
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG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AAM,GACJ,MAAM,CAqBlB;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAmBhB;IAED;;;;OAIG;IACH,oBAFW,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,2CAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;;;;OAQG;IACH,8BAPW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CA8DlB;IAGD;;;;;OAKG;IACH,uBAHW,MAAM,qBACN,MAAM,QA6BhB;IAED;;;;OAIG;IACH,WAFa,MAAM,CA2ClB;IAED;;;OAGG;IACH,kBAFW,YAAY,QAUtB;IAED;;;OAGG;IACH,oBAFW,YAAY,QAiBtB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAUjB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAQhB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BAvvB4B,iCAAiC"}
1
+ {"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAEkD;AAElE;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,4BAFU,MAAM,CAEwB;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACI;;;OAGG;IACH,2BAFW,MAAM,EAqDhB;IAhDG;;;;OAIG;IACH,iBAAsE;IAEtE;;;;OAIG;IACH,sBAAmD;IAEnD;;;;OAIG;IACH,eAAyC;IAEzC;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,mBAAmB;IAEnB;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,uBAAuB;IAG3B;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAUC;IAED;;;;OAIG;IACH,WAFY,MAAM,EAAE,CAYnB;IAED;;;OAGG;IACH,c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hB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BA1wB4B,iCAAiC"}
@@ -134,17 +134,9 @@ export class TetrahedralMesh {
134
134
  }
135
135
 
136
136
  /**
137
- * Only valid when the mesh is compacted
138
- * @return {number}
139
- */
140
- get count() {
141
- assert.equal(this.isCompacted, true, 'must be compacted');
142
-
143
- return this.__used_end;
144
- }
145
-
146
- /**
147
- *
137
+ * Exposes internal state, when this is false there are hole in the allocated memory
138
+ * Useful mainly for serialization and debugging.
139
+ * When serializing, you would want to get rid of any holes first by calling {@link compact}
148
140
  * @return {boolean}
149
141
  */
150
142
  get isCompacted() {
@@ -187,6 +179,7 @@ export class TetrahedralMesh {
187
179
 
188
180
  /**
189
181
  * Clears all data from the mesh, making it contain 0 tetrahedrons
182
+ * Ensures that consequent allocation requests will be sequential
190
183
  */
191
184
  clear() {
192
185
 
@@ -245,12 +238,25 @@ export class TetrahedralMesh {
245
238
 
246
239
  /**
247
240
  * How many tetrahedrons are contained in the mesh, includes any unallocated tetrahedrons
241
+ * @deprecated use {@link count} instead
248
242
  * @return {number}
249
243
  */
250
244
  size() {
245
+ console.warn('Deprecated, use .count instead');
246
+
251
247
  return this.__used_end;
252
248
  }
253
249
 
250
+ /**
251
+ * Number of currently live tetrahedrons.
252
+ * Excludes unallocated tetrahedrons.
253
+ * @return {number}
254
+ */
255
+ get count() {
256
+ return this.__used_end - this.__free_pointer;
257
+ }
258
+
259
+
254
260
  /**
255
261
  * Grow capacity to at least the specified size
256
262
  * @private
@@ -492,7 +498,7 @@ export class TetrahedralMesh {
492
498
  }
493
499
 
494
500
  /**
495
- * Remove tetrahedron
501
+ * Remove tetrahedron, de-allocating memory
496
502
  * Please note that if there are any dangling references in the mesh neighbourhood - you will need to take care of that separately
497
503
  * @param {number} tetra_index
498
504
  */
@@ -624,6 +630,14 @@ export class TetrahedralMesh {
624
630
  * @param {number} destination_index new index, where the source tetrahedron is to be moved
625
631
  */
626
632
  relocate(source_index, destination_index) {
633
+ assert.isNonNegativeInteger(source_index, 'source_index');
634
+ assert.isNonNegativeInteger(destination_index, 'destination_index');
635
+
636
+ if (source_index === destination_index) {
637
+ // avoid unnecessary work
638
+ return;
639
+ }
640
+
627
641
  // validate_tetrahedron_neighbourhood(this, source_index, console.error);
628
642
 
629
643
  // patch neighbours
@@ -647,7 +661,12 @@ export class TetrahedralMesh {
647
661
 
648
662
 
649
663
  const layout_word_size = LAYOUT_TETRA_BYTE_SIZE >> 2;
650
- array_copy(this.__data_uint32, source_index * layout_word_size, this.__data_uint32, destination_index * layout_word_size, layout_word_size);
664
+
665
+ array_copy(
666
+ this.__data_uint32, source_index * layout_word_size,
667
+ this.__data_uint32, destination_index * layout_word_size,
668
+ layout_word_size
669
+ );
651
670
 
652
671
  // validate_tetrahedron_neighbourhood(this, destination_index, console.error);
653
672
  }
@@ -8,6 +8,7 @@
8
8
  * @param {number} resolution_x how many points to generate on the grid in X axis
9
9
  * @param {number} resolution_y how many points to generate on the grid in Y axis
10
10
  * @param {number} resolution_z how many points to generate on the grid in Y axis
11
+ * @returns {number} number of added points
11
12
  */
12
- export function tetrahedral_mesh_build_from_grid(mesh: TetrahedralMesh, points: number[], bounds: AABB3, resolution_x?: number, resolution_y?: number, resolution_z?: number): void;
13
+ export function tetrahedral_mesh_build_from_grid(mesh: TetrahedralMesh, points: number[], bounds: AABB3, resolution_x?: number, resolution_y?: number, resolution_z?: number): number;
13
14
  //# sourceMappingURL=tetrahedral_mesh_build_from_grid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tetrahedral_mesh_build_from_grid.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,gFANW,MAAM,EAAE,gCAER,MAAM,iBACN,MAAM,iBACN,MAAM,QA4IhB"}
1
+ {"version":3,"file":"tetrahedral_mesh_build_from_grid.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,gFAPW,MAAM,EAAE,gCAER,MAAM,iBACN,MAAM,iBACN,MAAM,GACJ,MAAM,CA+LlB"}
@@ -1,3 +1,5 @@
1
+ import { assert } from "../../../../assert.js";
2
+
1
3
  /**
2
4
  * Special case of tetrahedral mesh generation using a regular 3d grid, useful for generating light probe volumes
3
5
  * This is a special case of tetrahedral tessellation, we can handle it much easier due to regular nature of the point distribution
@@ -8,6 +10,7 @@
8
10
  * @param {number} resolution_x how many points to generate on the grid in X axis
9
11
  * @param {number} resolution_y how many points to generate on the grid in Y axis
10
12
  * @param {number} resolution_z how many points to generate on the grid in Y axis
13
+ * @returns {number} number of added points
11
14
  */
12
15
  export function tetrahedral_mesh_build_from_grid(
13
16
  mesh, points,
@@ -15,7 +18,9 @@ export function tetrahedral_mesh_build_from_grid(
15
18
  resolution_x = 2, resolution_y = 2, resolution_z = 2,
16
19
  ) {
17
20
 
18
- console.error("Implementation is incomplete"); // FIXME
21
+ assert.isNonNegativeInteger(resolution_x, 'resolution_x');
22
+ assert.isNonNegativeInteger(resolution_y, 'resolution_y');
23
+ assert.isNonNegativeInteger(resolution_z, 'resolution_z');
19
24
 
20
25
  mesh.clear();
21
26
 
@@ -40,6 +45,11 @@ export function tetrahedral_mesh_build_from_grid(
40
45
  return z * resolution_y * resolution_x + y * resolution_x + x;
41
46
  }
42
47
 
48
+ function voxel_position_to_tetrahedral(x, y, z, index) {
49
+
50
+ return (z * (resolution_y - 1) * (resolution_x - 1) + y * (resolution_x - 1) + x) * 6 + index;
51
+ }
52
+
43
53
  // generate points
44
54
  for (let z = 0; z < resolution_z; z++) {
45
55
  for (let y = 0; y < resolution_y; y++) {
@@ -83,63 +93,104 @@ export function tetrahedral_mesh_build_from_grid(
83
93
 
84
94
  // NOTE: it's possible to tessellate each box into 5 tetrahedrons instead of 6, but orientation becomes inconsistent if we do that
85
95
  // reference http://www.iue.tuwien.ac.at/phd/wessner/node32.html
86
-
87
96
  for (let z = 1; z < resolution_z; z++) {
88
97
  for (let y = 1; y < resolution_y; y++) {
89
98
  for (let x = 1; x < resolution_x; x++) {
99
+
90
100
  const A = vertex_position_to_index(x - 1, y - 1, z - 1);
91
101
  const B = vertex_position_to_index(x - 1, y - 1, z);
92
- const C = vertex_position_to_index(x - 1, y, z - 1);
93
- const D = vertex_position_to_index(x - 1, y, z);
94
- const E = vertex_position_to_index(x, y - 1, z - 1);
95
- const F = vertex_position_to_index(x, y - 1, z);
96
- const G = vertex_position_to_index(x, y, z - 1);
97
- const H = vertex_position_to_index(x, y, z);
98
-
99
- // const p000 = vertex_position_to_index(x - 1, y - 1, z - 1);
100
- // const p001 = vertex_position_to_index(x - 1, y - 1, z);
101
- // const p010 = vertex_position_to_index(x - 1, y, z - 1);
102
- // const p011 = vertex_position_to_index(x - 1, y, z);
103
- // const p100 = vertex_position_to_index(x, y - 1, z - 1);
104
- // const p101 = vertex_position_to_index(x, y - 1, z);
105
- // const p110 = vertex_position_to_index(x, y, z - 1);
106
- // const p111 = vertex_position_to_index(x, y, z);
107
-
102
+ const C = vertex_position_to_index(x, y - 1, z);
103
+ const D = vertex_position_to_index(x, y - 1, z - 1);
104
+ const E = vertex_position_to_index(x - 1, y, z - 1);
105
+ const F = vertex_position_to_index(x - 1, y, z);
106
+ const G = vertex_position_to_index(x, y, z);
107
+ const H = vertex_position_to_index(x, y, z - 1);
108
108
 
109
109
  // Tessellate the grid volume into six tetrahedra per grid cell.
110
110
 
111
111
  // prism 1
112
- const tet_0 = make_cell(E, F, G, A);
113
- const tet_1 = make_cell(A, B, F, G);
114
- const tet_2 = make_cell(A, C, B, G);
112
+ const tet_0 = make_cell(B, A, D, H); // purple
113
+ const tet_1 = make_cell(B, A, H, E); // blue
114
+ const tet_2 = make_cell(H, B, E, F); // red
115
115
 
116
116
  // prism 2
117
- const tet_3 = make_cell(E, G, H, A);
118
- const tet_4 = make_cell(A, H, D, G);
119
- const tet_5 = make_cell(A, D, C, G);
117
+ const tet_3 = make_cell(C, B, D, H); // orange
118
+ const tet_4 = make_cell(C, B, H, G); // yellow
119
+ const tet_5 = make_cell(B, H, G, F); // green
120
120
 
121
121
  // link newly created tetrahedrons
122
- mesh.setNeighbour(tet_0, 1, (tet_3 << 2) & 2);
123
- mesh.setNeighbour(tet_3, 2, (tet_0 << 2) & 1);
124
122
 
125
- mesh.setNeighbour(tet_0, 1, (tet_1 << 2) & 2);
126
- mesh.setNeighbour(tet_1, 2, (tet_0 << 2) & 1);
123
+ // purple
124
+ mesh.setNeighbour(tet_0, 1, (tet_3 << 2) | 0); // A - orange C
125
+ mesh.setNeighbour(tet_0, 2, (tet_1 << 2) | 3); // D - blue E
127
126
 
128
- // TODO implement
127
+ // blue
128
+ mesh.setNeighbour(tet_1, 1, (tet_2 << 2) | 3); // A - red F
129
+ mesh.setNeighbour(tet_1, 3, (tet_0 << 2) | 2); // E - purple D
129
130
 
131
+ // red
132
+ mesh.setNeighbour(tet_2, 2, (tet_5 << 2) | 2); // E - green G
133
+ mesh.setNeighbour(tet_2, 3, (tet_1 << 2) | 1); // F - blue A
134
+
135
+ // orange
136
+ mesh.setNeighbour(tet_3, 0, (tet_0 << 2) | 1); // C - purple A
137
+ mesh.setNeighbour(tet_3, 2, (tet_4 << 2) | 3); // D - yellow G
138
+
139
+ // yellow
140
+ mesh.setNeighbour(tet_4, 0, (tet_5 << 2) | 3); // C - green F
141
+ mesh.setNeighbour(tet_4, 3, (tet_3 << 2) | 2); // G - orange D
142
+
143
+ // green
144
+ mesh.setNeighbour(tet_5, 2, (tet_2 << 2) | 2); // G - red E
145
+ mesh.setNeighbour(tet_5, 3, (tet_4 << 2) | 0); // F - yellow C
146
+
147
+ // links to previous voxel
148
+
149
+ // prev x
130
150
  if (x > 1) {
131
- // link to previous voxel
132
- // TODO implement
151
+ const tet_3_prev_x = voxel_position_to_tetrahedral(x - 2, y - 1, z - 1, 3);// prev x orange
152
+ const tet_4_prev_x = voxel_position_to_tetrahedral(x - 2, y - 1, z - 1, 4); // prev x yellow
153
+
154
+ // blue
155
+ mesh.setNeighbour(tet_1, 2, (tet_3_prev_x << 2) | 1); // H - prev x orange B
156
+ // orange prev x
157
+ mesh.setNeighbour(tet_3_prev_x, 1, (tet_1 << 2) | 2); // B - blue H
158
+
159
+ // red
160
+ mesh.setNeighbour(tet_2, 0, (tet_4_prev_x << 2) | 1); // H - prev x yellow B
161
+ // yellow prev x
162
+ mesh.setNeighbour(tet_4_prev_x, 1, (tet_2 << 2) | 0); // B - red H
133
163
  }
134
164
 
165
+ // prev y
135
166
  if (y > 1) {
136
- // link to previous voxel
137
- // TODO implement
167
+ const tet_2_prev_y = voxel_position_to_tetrahedral(x - 1, y - 2, z - 1, 2); // prev y red
168
+ const tet_5_prev_y = voxel_position_to_tetrahedral(x - 1, y - 2, z - 1, 5); // prev y green
169
+
170
+ // purple
171
+ mesh.setNeighbour(tet_0, 3, (tet_2_prev_y << 2) | 1); // H - prev y red B
172
+ // prev y red
173
+ mesh.setNeighbour(tet_2_prev_y, 1, (tet_0 << 2) | 3); // B - blue H
174
+
175
+ // orange
176
+ mesh.setNeighbour(tet_3, 3, (tet_5_prev_y << 2) | 0); // H - prev y green B
177
+ // prev y green
178
+ mesh.setNeighbour(tet_5_prev_y, 0, (tet_3 << 2) | 3); // B - orange H
138
179
  }
139
180
 
140
181
  if (z > 1) {
141
- // link to previous voxel
142
- // TODO implement
182
+ const tet_4_prev_z = voxel_position_to_tetrahedral(x - 1, y - 1, z - 2, 4); // prev z yellow
183
+ const tet_5_prev_z = voxel_position_to_tetrahedral(x - 1, y - 1, z - 2, 5); // prev z green
184
+
185
+ // purple
186
+ mesh.setNeighbour(tet_0, 0, (tet_4_prev_z << 2) | 2); // B - prev z yellow H
187
+ // prev z yellow
188
+ mesh.setNeighbour(tet_4_prev_z, 2, (tet_0 << 2) | 0); // H - purple B
189
+
190
+ // blue
191
+ mesh.setNeighbour(tet_1, 0, (tet_5_prev_z << 2) | 1); // B - prev z green H
192
+ // prev z green
193
+ mesh.setNeighbour(tet_5_prev_z, 1, (tet_1 << 2) | 0); // H - blue B
143
194
  }
144
195
 
145
196
  }
@@ -147,4 +198,7 @@ export function tetrahedral_mesh_build_from_grid(
147
198
  }
148
199
 
149
200
  }
201
+
202
+ // number of points added
203
+ return resolution_x * resolution_y * resolution_z;
150
204
  }
@@ -76,7 +76,7 @@ async function main(engine) {
76
76
  tetrahedra,
77
77
  points,
78
78
  new AABB3(-10, 0, -10, 10, 10, 10),
79
- 8, 4, 8
79
+ 4, 4, 4
80
80
  )
81
81
  console.timeEnd('mesh build');
82
82
  console.log(`Mesh build for ${number_pretty_print(points.length / 3)} points`)
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Adds input to output
3
+ * `out += input`
4
+ * @param {number[]} out
5
+ * @param {number} out_offset
6
+ * @param {number[]} input
7
+ * @param {number} input_offset
8
+ */
9
+ export function v3_array_immediate_add(out: number[], out_offset: number, input: number[], input_offset: number): void;
10
+ //# sourceMappingURL=v3_array_immediate_add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_array_immediate_add.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_array_immediate_add.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,4CALW,MAAM,EAAE,cACR,MAAM,SACN,MAAM,EAAE,gBACR,MAAM,QAYhB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Adds input to output
3
+ * `out += input`
4
+ * @param {number[]} out
5
+ * @param {number} out_offset
6
+ * @param {number[]} input
7
+ * @param {number} input_offset
8
+ */
9
+ export function v3_array_immediate_add(out, out_offset, input, input_offset) {
10
+
11
+ const x = input[input_offset];
12
+ const y = input[input_offset + 1];
13
+ const z = input[input_offset + 2];
14
+
15
+ out[out_offset] += x;
16
+ out[out_offset + 1] += y;
17
+ out[out_offset + 2] += z;
18
+
19
+ }
@@ -33,12 +33,12 @@ export class NodeGraph {
33
33
  * @readonly
34
34
  * @type {Signal<NodeInstance,number>}
35
35
  */
36
- readonly nodeAdded: Signal<NodeInstance, number>;
36
+ readonly nodeAdded: Signal<NodeInstance<import("./node/NodeDescription.js").NodeDescription>, number>;
37
37
  /**
38
38
  * @readonly
39
39
  * @type {Signal<NodeInstance,number>}
40
40
  */
41
- readonly nodeRemoved: Signal<NodeInstance, number>;
41
+ readonly nodeRemoved: Signal<NodeInstance<import("./node/NodeDescription.js").NodeDescription>, number>;
42
42
  /**
43
43
  * @readonly
44
44
  * @type {Signal<Connection,number>}
@@ -1,18 +1,18 @@
1
- import {NodeDescription} from "./NodeDescription";
2
- import {NodeInstancePortReference} from "./NodeInstancePortReference";
3
1
  import List from "../../../collection/list/List";
4
2
  import {Connection} from "../Connection";
3
+ import {NodeDescription} from "./NodeDescription";
4
+ import {NodeInstancePortReference} from "./NodeInstancePortReference";
5
5
 
6
- export class NodeInstance {
6
+ export class NodeInstance<N extends NodeDescription = NodeDescription> {
7
7
  readonly id: number
8
8
 
9
- readonly description: NodeDescription
9
+ readonly description: N
10
10
 
11
11
  readonly endpoints: NodeInstancePortReference[]
12
12
 
13
13
  readonly connections: List<Connection>
14
14
 
15
- setDescription(d: NodeDescription): void
15
+ setDescription(d: N): void
16
16
 
17
17
  setParameters(hash: { [key: string]: any }): void
18
18
  }
@@ -28,6 +28,16 @@ export class LightProbeVolume {
28
28
  * @param {number} z
29
29
  */
30
30
  add_point(x: number, y: number, z: number): void;
31
+ /**
32
+ *
33
+ * @param {AABB3} bounds
34
+ * @param {Vector3|{x:number, y:number, z:number}} resolution
35
+ */
36
+ build_grid(bounds: AABB3, resolution: Vector3 | {
37
+ x: number;
38
+ y: number;
39
+ z: number;
40
+ }): void;
31
41
  /**
32
42
  * Build tetrahedral mesh
33
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;;OAKG;IACH,mCAJW,MAAM,GAEJ,UAAU,CAsBtB;IAGD,yBAEC;;CAEJ;gCAvL+B,wDAAwD;2BAC7D,mCAAmC"}
1
+ {"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;;;OAIG;IACH,sCAFW,UAAQ;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,QAOhD;IAED;;OAEG;IACH,mBAaC;IAGD;;;;;OAKG;IACH,mCAJW,MAAM,GAEJ,UAAU,CAsBtB;IAGD,yBAEC;;CAEJ;gCAnM+B,wDAAwD;2BAC7D,mCAAmC"}
@@ -2,6 +2,9 @@ import { assert } from "../../../../core/assert.js";
2
2
  import {
3
3
  compute_delaunay_tetrahedral_mesh
4
4
  } from "../../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
5
+ import {
6
+ tetrahedral_mesh_build_from_grid
7
+ } from "../../../../core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js";
5
8
  import { TetrahedralMesh } from "../../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
6
9
  import { EntityNode } from "../../../ecs/parent/EntityNode.js";
7
10
  import { Transform } from "../../../ecs/transform/Transform.js";
@@ -35,7 +38,7 @@ export class LightProbeVolume {
35
38
  * Depth map is stored as a 2d texture of size RESOLUTION x RESOLUTION
36
39
  * @type {number}
37
40
  */
38
- #probe_depth_resolution = 16;
41
+ #probe_depth_resolution = 12;
39
42
 
40
43
  /**
41
44
  * Octahedral-encoded depth map for each probe, 2 channels for mean and mean squared for variance recovery in the shader
@@ -133,6 +136,18 @@ export class LightProbeVolume {
133
136
  this.#probe_count++;
134
137
  }
135
138
 
139
+ /**
140
+ *
141
+ * @param {AABB3} bounds
142
+ * @param {Vector3|{x:number, y:number, z:number}} resolution
143
+ */
144
+ build_grid(bounds, resolution) {
145
+ this.#probe_count = tetrahedral_mesh_build_from_grid(
146
+ this.#mesh, this.#probe_positions,
147
+ bounds, resolution.x, resolution.y, resolution.z
148
+ );
149
+ }
150
+
136
151
  /**
137
152
  * Build tetrahedral mesh
138
153
  */
@@ -148,7 +163,7 @@ export class LightProbeVolume {
148
163
 
149
164
  const t2 = performance.now();
150
165
 
151
- console.log(`Tetrahedral mesh (${this.#probe_count} points, ${this.#mesh.size()} tets) build took ${t2 - t0}ms`);
166
+ console.log(`Tetrahedral mesh (${this.#probe_count} points, ${this.#mesh.count} tets) build took ${t2 - t0}ms`);
152
167
  }
153
168
 
154
169
 
@@ -24,7 +24,7 @@ const sampled_irradiance = new Float32Array(3);
24
24
  export class PathTracerProbeRenderer extends ProbeRenderer {
25
25
  tracer = new PathTracer();
26
26
  max_bounce_count = 5;
27
- sample_count = 190;
27
+ sample_count = 256;
28
28
  // sample_count = 40960;
29
29
  random = seededRandom(0);
30
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"build_probes_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/build_probes_for_scene.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH,iFAPW,gBAAgB,GAKd,QAAQ,gBAAgB,CAAC,CAoFrC;iCA9FgC,uBAAuB"}
1
+ {"version":3,"file":"build_probes_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/build_probes_for_scene.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH,iFAPW,gBAAgB,GAKd,QAAQ,gBAAgB,CAAC,CA8FrC;iCAxGgC,uBAAuB"}
@@ -1,6 +1,6 @@
1
1
  import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
2
- import { make_justified_point_grid } from "../../../../core/geom/3d/util/make_justified_point_grid.js";
3
2
  import Vector2 from "../../../../core/geom/Vector2.js";
3
+ import Vector3 from "../../../../core/geom/Vector3.js";
4
4
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
5
5
  import { delay } from "../../../../core/process/delay.js";
6
6
  import Entity from "../../../ecs/Entity.js";
@@ -60,18 +60,28 @@ export async function build_probes_for_scene(
60
60
  // );
61
61
  // }
62
62
 
63
- make_justified_point_grid(model_bounds, probe_grid_spacing, (x, y, z) => {
64
- volume.add_point(x, y, z);
65
- });
63
+ // make_justified_point_grid(model_bounds, probe_grid_spacing, (x, y, z) => {
64
+ // volume.add_point(x, y, z);
65
+ // });
66
66
 
67
67
  // lpv.add_point(10, 1, -10);
68
68
 
69
69
  await delay(1);
70
70
 
71
+
71
72
  //
72
73
  // console.profile('lpv build');
73
74
  //
74
- volume.build_mesh();
75
+ // volume.build_mesh();
76
+ console.time('Grid Build')
77
+ volume.build_grid(model_bounds, new Vector3(
78
+ Math.ceil(model_bounds.width / probe_grid_spacing),
79
+ Math.ceil(model_bounds.height / probe_grid_spacing),
80
+ Math.ceil(model_bounds.depth / probe_grid_spacing)
81
+ ));
82
+
83
+ console.timeEnd('Grid Build');
84
+
75
85
  const lpv_baker = new LightProbeVolumeBaker();
76
86
  const task = lpv_baker.bake(volume, ecd);
77
87
  // console.profileEnd('lpv build');
@@ -388,8 +388,8 @@ async function main(engine) {
388
388
  // const path = 'data/models/samples/teapot.gltf';
389
389
  // const path = 'data/models/samples/salle_de_bain/model.glb';
390
390
  // const path = 'data/models/samples/conference/model-no-curtains.glb';
391
- // const path = 'data/models/pica_pica/pica_pica.gltf';
392
- const path = 'data/models/samples/gi_box_01/model.glb';
391
+ const path = 'data/models/pica_pica/pica_pica.gltf';
392
+ // const path = 'data/models/samples/gi_box_01/model.glb';
393
393
  // const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
394
394
 
395
395
  const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');