@woosh/meep-engine 2.109.23 → 2.109.25

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 (55) hide show
  1. package/build/meep.cjs +231 -104
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +231 -104
  4. package/package.json +1 -1
  5. package/src/core/collection/heap/FastBinaryHeap.d.ts +17 -10
  6. package/src/core/collection/heap/FastBinaryHeap.d.ts.map +1 -1
  7. package/src/core/collection/heap/FastBinaryHeap.js +33 -23
  8. package/src/core/collection/heap/FastBinaryHeap.spec.js +10 -10
  9. package/src/core/collection/table/RowFirstTable.d.ts +10 -7
  10. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  11. package/src/core/collection/table/RowFirstTable.js +23 -6
  12. package/src/core/collection/table/bind/TableRecord.d.ts.map +1 -1
  13. package/src/core/collection/table/bind/TableRecord.js +4 -0
  14. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +2 -2
  15. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +2 -2
  16. package/src/core/model/validate_enum_schema.d.ts +10 -0
  17. package/src/core/model/validate_enum_schema.d.ts.map +1 -0
  18. package/src/core/model/validate_enum_schema.js +31 -0
  19. package/src/engine/animation/async/TimeSeries.d.ts +76 -0
  20. package/src/engine/animation/async/TimeSeries.d.ts.map +1 -0
  21. package/src/engine/animation/async/TimeSeries.js +289 -0
  22. package/src/engine/animation/async/prototypeAsyncAnimation.js +31 -83
  23. package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts +9 -0
  24. package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts.map +1 -0
  25. package/src/engine/animation/async/table_find_min_index_in_ordered_column.js +32 -0
  26. package/src/engine/asset/AssetManager.js +1 -1
  27. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
  28. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -11
  29. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
  30. package/src/engine/graphics/sh3/gi/material/common.glsl +1 -1
  31. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +1 -1
  32. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
  33. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +5 -0
  34. package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
  35. package/src/engine/input/devices/InputDeviceSwitch.d.ts.map +1 -1
  36. package/src/engine/input/devices/InputDeviceSwitch.js +18 -0
  37. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  38. package/src/engine/input/devices/KeyboardDevice.js +4 -41
  39. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +11 -0
  40. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -0
  41. package/src/engine/input/devices/LocationalInteractionMetadata.js +18 -0
  42. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  43. package/src/engine/input/devices/PointerDevice.js +90 -37
  44. package/src/engine/input/devices/eventToSourceIdentifier.d.ts +7 -0
  45. package/src/engine/input/devices/eventToSourceIdentifier.d.ts.map +1 -0
  46. package/src/engine/input/devices/eventToSourceIdentifier.js +36 -0
  47. package/src/engine/input/devices/isHTMLElementFocusable.d.ts +6 -0
  48. package/src/engine/input/devices/isHTMLElementFocusable.d.ts.map +1 -0
  49. package/src/engine/input/devices/isHTMLElementFocusable.js +34 -0
  50. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +3 -3
  51. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
  52. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +5 -5
  53. package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts.map +1 -1
  54. package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +3 -3
  55. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
@@ -1,11 +1,7 @@
1
1
  import { GUI } from "dat.gui";
2
2
  import { MeshBasicMaterial, MeshStandardMaterial, OctahedronBufferGeometry } from "three";
3
3
  import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
4
- import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
5
- import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
6
4
  import { Color } from "../../../core/color/Color.js";
7
- import { inverseLerp } from "../../../core/math/inverseLerp.js";
8
- import { lerp } from "../../../core/math/lerp.js";
9
5
  import { max2 } from "../../../core/math/max2.js";
10
6
  import { min2 } from "../../../core/math/min2.js";
11
7
  import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
@@ -27,42 +23,14 @@ import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorCompo
27
23
  import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
28
24
  import { ActionBehavior } from "../../intelligence/behavior/primitive/ActionBehavior.js";
29
25
  import { RandomDelayBehavior } from "../../intelligence/behavior/util/RandomDelayBehavior.js";
26
+ import { TimeSeries } from "./TimeSeries.js";
30
27
 
31
28
  const harness = new EngineHarness();
32
29
 
33
- /**
34
- *
35
- * @param {RowFirstTable} table
36
- * @param {number} time
37
- * @return {number}
38
- */
39
- function findSampleIndex(table, time) {
40
- let minIndex = 0;
41
- let maxIndex = table.length - 1;
42
-
43
- while (minIndex <= maxIndex) {
44
-
45
- const pivotIndex = (minIndex + maxIndex) >> 1;
46
-
47
- const cmp = time - table.readCellValue(pivotIndex, 0);
48
-
49
- if (cmp > 0) {
50
- minIndex = pivotIndex + 1;
51
- } else if (cmp < 0) {
52
- maxIndex = pivotIndex - 1;
53
- } else {
54
- //set low boundary for next step based on assumption that upper bound is higher than lower bound
55
- return pivotIndex;
56
- }
57
- }
58
-
59
- return min2(minIndex, maxIndex);
60
- }
61
-
62
30
  /**
63
31
  *
64
32
  * @param {EntityComponentDataset} ecd
65
- * @param {RowFirstTable} table
33
+ * @param {TimeSeries} table
66
34
  * @param {number} [count]
67
35
  */
68
36
  function makeGhostMarkers({
@@ -108,10 +76,12 @@ function makeGhostMarkers({
108
76
  return {
109
77
  set time(time) {
110
78
 
111
- const ref_index = findSampleIndex(table, time);
79
+ const sample = table.sampleObjectLinear(time);
80
+
81
+ const ref_index = table.findLowSampleIndexByTime(time);
112
82
 
113
83
  const start_index = max2(0, ref_index - Math.floor(count / 2));
114
- const limit_index = min2(table.length - 1, ref_index + Math.ceil(count / 2));
84
+ const limit_index = min2(table.sample_count - 1, ref_index + Math.ceil(count / 2));
115
85
 
116
86
  for (let i = 0; i < count; i++) {
117
87
 
@@ -137,10 +107,12 @@ function makeGhostMarkers({
137
107
 
138
108
  const transform = entity.getComponentSafe(Transform);
139
109
 
110
+ const sample = table.getSampleObjectByIndex(sample_index);
111
+
140
112
  transform.position.set(
141
- table.readCellValue(sample_index, 1),
142
- table.readCellValue(sample_index, 2),
143
- table.readCellValue(sample_index, 3)
113
+ sample.x,
114
+ sample.y,
115
+ sample.z
144
116
  );
145
117
 
146
118
  }
@@ -158,23 +130,19 @@ async function main(engine) {
158
130
  engine
159
131
  });
160
132
 
161
- const table = new RowFirstTable(
162
- RowFirstTableSpec.get([
163
- BinaryDataType.Float64, // time
164
- BinaryDataType.Float32, // x
165
- BinaryDataType.Float32, //y
166
- BinaryDataType.Float32 //z
167
- ])
168
- );
133
+ const timeSeries = new TimeSeries({
134
+ time: BinaryDataType.Float64,
135
+ x: BinaryDataType.Float32,
136
+ y: BinaryDataType.Float32,
137
+ z: BinaryDataType.Float32,
138
+ }, 'time');
169
139
 
170
140
  const random = seededRandom(42);
171
141
 
172
- table.addRow([
142
+ timeSeries.addSample([
173
143
  0, 0, 1, 0
174
144
  ]);
175
145
 
176
- const sample = [];
177
-
178
146
  const sim_clock = new Clock();
179
147
  sim_clock.start();
180
148
 
@@ -183,9 +151,7 @@ async function main(engine) {
183
151
  const time_delta = sim_clock.getDelta();
184
152
 
185
153
  // get last row
186
- const row_count = table.length;
187
-
188
- table.getRow(row_count - 1, sample);
154
+ const last_record = timeSeries.getSampleObjectByIndex(timeSeries.sample_count - 1);
189
155
 
190
156
  const speed = 7;
191
157
 
@@ -196,15 +162,14 @@ async function main(engine) {
196
162
  const displacement_x = displacement * Math.cos(direction);
197
163
  const displacement_y = displacement * Math.sin(direction);
198
164
 
199
- const new_x = sample[1] + displacement_x;
200
- const new_z = sample[3] + displacement_y;
165
+ const new_x = last_record.x + displacement_x;
166
+ const new_z = last_record.z + displacement_y;
201
167
 
202
- table.addRow([
203
- sample[0] + time_delta,
168
+ timeSeries.addSample([
169
+ last_record.time + time_delta,
204
170
  new_x,
205
171
  1,
206
172
  new_z,
207
-
208
173
  ]);
209
174
  }
210
175
 
@@ -226,14 +191,14 @@ async function main(engine) {
226
191
  playing: true,
227
192
  play_time: -1,
228
193
  get latest_data_time() {
229
- return table.readCellValue(table.length - 1, 0);
194
+ return timeSeries.last_timestamp;
230
195
  },
231
196
  get behind_latest() {
232
- return table.readCellValue(table.length - 1, 0) - this.play_time;
197
+ return timeSeries.last_timestamp - this.play_time;
233
198
  },
234
199
  set behind_latest(v) {
235
200
 
236
- const current_delay = table.readCellValue(table.length - 1, 0) - this.play_time;
201
+ const current_delay = timeSeries.last_timestamp - this.play_time;
237
202
 
238
203
  const delta = v - current_delay;
239
204
 
@@ -260,38 +225,21 @@ async function main(engine) {
260
225
  sim_parameters.play_time += delta;
261
226
  }
262
227
 
263
-
264
- // seek to the right sample
265
- const sample_index = max2(0, findSampleIndex(table, sim_parameters.play_time));
266
- const next_sample_index = min2(table.length - 1, sample_index + 1);
267
-
268
- const prev = table.readCellValue(sample_index, 0);
269
- const next = table.readCellValue(next_sample_index, 0);
270
-
271
- const normalized_offset = inverseLerp(prev, next, sim_parameters.play_time);
228
+ const sample = timeSeries.sampleObjectLinear(sim_parameters.play_time);
272
229
 
273
230
  const transform = subject.getComponentSafe(Transform);
274
231
 
275
- const x0 = table.readCellValue(sample_index, 1);
276
- const x1 = table.readCellValue(next_sample_index, 1);
277
-
278
- const y0 = table.readCellValue(sample_index, 2);
279
- const y1 = table.readCellValue(next_sample_index, 2);
280
-
281
- const z0 = table.readCellValue(sample_index, 3);
282
- const z1 = table.readCellValue(next_sample_index, 3);
283
-
284
232
  transform.position.set(
285
- lerp(x0, x1, normalized_offset),
286
- lerp(y0, y1, normalized_offset),
287
- lerp(z0, z1, normalized_offset),
233
+ sample.x,
234
+ sample.y,
235
+ sample.z,
288
236
  );
289
237
  })
290
238
  )))
291
239
  .build(ecd);
292
240
 
293
241
  const markers = makeGhostMarkers({
294
- ecd, table, count: 5
242
+ ecd, table: timeSeries, count: 5
295
243
  });
296
244
 
297
245
  engine.ticker.onTick.add(() => markers.time = sim_parameters.play_time);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Given a column of ordered values in increasing order, returns low index of matching value
3
+ * @param {RowFirstTable} table
4
+ * @param {number} time
5
+ * @param {number} [column_index]
6
+ * @return {number}
7
+ */
8
+ export function table_find_min_index_in_ordered_column(table: RowFirstTable, time: number, column_index?: number): number;
9
+ //# sourceMappingURL=table_find_min_index_in_ordered_column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_find_min_index_in_ordered_column.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/async/table_find_min_index_in_ordered_column.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,mFAJW,MAAM,iBACN,MAAM,GACL,MAAM,CAwBjB"}
@@ -0,0 +1,32 @@
1
+ import { min2 } from "../../../core/math/min2.js";
2
+
3
+ /**
4
+ * Given a column of ordered values in increasing order, returns low index of matching value
5
+ * @param {RowFirstTable} table
6
+ * @param {number} time
7
+ * @param {number} [column_index]
8
+ * @return {number}
9
+ */
10
+ export function table_find_min_index_in_ordered_column(table, time, column_index = 0) {
11
+ let minIndex = 0;
12
+ let maxIndex = table.length - 1;
13
+
14
+ while (minIndex <= maxIndex) {
15
+
16
+ // low midpoint, this is essentially Math.floor( (minIndex + maxIndex) / 2 )
17
+ const pivotIndex = (minIndex + maxIndex) >>> 1;
18
+
19
+ const cmp = time - table.readCellValue(pivotIndex, column_index);
20
+
21
+ if (cmp > 0) {
22
+ minIndex = pivotIndex + 1;
23
+ } else if (cmp < 0) {
24
+ maxIndex = pivotIndex - 1;
25
+ } else {
26
+ // exactly on the pivot sample
27
+ return pivotIndex;
28
+ }
29
+ }
30
+
31
+ return min2(minIndex, maxIndex);
32
+ }
@@ -33,7 +33,7 @@ class Response {
33
33
  }
34
34
 
35
35
  /**
36
- * Used by the priority queue, so the priority is inverted as the BinaryHeap returns elements in ascending score order (from lowest)
36
+ * Used by the priority queue, so the priority is inverted as the FastBinaryHeap returns elements in ascending score order (from lowest)
37
37
  * @param {PendingAsset} pending_asset
38
38
  * @returns {number}
39
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ParticleEmitter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js"],"names":[],"mappings":"AA0FA;IAuiCI;;;;OAIG;IACH,4BAFa,eAAe,CAM3B;IA/iCD;;OAEG;IACH,IAFU,MAAM,CAEE;IAElB;;;;OAIG;IACH,wBAAoB;IAEpB;;;OAGG;IACH,UAFU,OAAO,CAEe;IAChC,eAA6B;IAC7B,qBAAsC;IAEtC;;;;;OAKG;IACH,qCAA2C;IAE3C;;;;OAIG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,cAFU,YAAY,GAAC,MAAM,CAEM;IAEnC;;;OAGG;IACH,WAFU,YAAY,GAAC,IAAI,CAEV;IAEjB;;;OAGG;IACH,MAFU,WAAS,IAAI,CAEX;IAEZ;;;OAGG;IACH,mBAFU,SAAS,CAEQ;IAG3B;;;;OAIG;IACH,yBAFU,KAAK,CAE2E;IAE1F;;;OAGG;IACH,yBAFU,KAAK,CAE8B;IAG7C;;;OAGG;IACH,OAFU,MAAM,CAE6F;IAE7G;;;;OAIG;IACH,eAAW;IAGX;;;OAGG;IACH,qBAFU,YAAY,CAEU;IAWhC,wBAIC;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,mBAAmB,GACxB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,mBAAmB,GACxB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,mBAAmB,SAC1B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,mBAAmB,GACxB,OAAO,CAInB;IAED;;OAEG;IACH,gCAaC;IAED;;;;;;;;;;;;;MAeC;IAED,0BAkEC;IAGD;;;OAGG;IACH,gBAFW,aAAa,QASvB;IAED;;;;OAIG;IACH,kDAUC;IAED;;;;OAIG;IACH,iCAHW,aAAa,GACZ,MAAM,CA2CjB;IAED,8BA0DC;IAED,8BAmBC;IAED,2BAmBC;IAED,6BAkBC;IAED;;;OAGG;IACH,uCAHW,MAAM,GACJ,MAAM,CA+BlB;IAED,cAuCC;IAED,mBA6BC;IAuBD,eAOC;IAED;;;;OAIG;IACH,cAHW,eAAe,GACb,OAAO,CAQnB;IAED;;;;OAIG;IACH,qCAyFC;IAED,eAOC;IAED;;;OAGG;IACH,4BAFY,MAAM,CAejB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAMhB;IAiCD;;;;OAIG;IACH,sCA+GC;IAED;;;;OAIG;IACH,qCA6GC;IAED;;;OAGG;IACH,aA4CC;IAGD;;OAEG;IACH,gBAIC;;CAYJ;;;;;;;;;;;;;;;;oBAhoCmB,wCAAwC;uBAFrC,2CAA2C;6BAOrC,6CAA6C;6BAqB7C,mBAAmB;0BAnCtB,+CAA+C;sBAGnD,8CAA8C;6BAYvC,8BAA8B;oCAiBvB,0BAA0B;8BAChC,oBAAoB;uCAF3C,0BAA0B;6CAA1B,0BAA0B;kDAA1B,0BAA0B;4CAA1B,0BAA0B;4CAA1B,0BAA0B;kDAA1B,0BAA0B;wCAA1B,0BAA0B;sCAA1B,0BAA0B;4CAA1B,0BAA0B;AAWjC,yCAKC"}
1
+ {"version":3,"file":"ParticleEmitter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js"],"names":[],"mappings":"AA2FA;IAyiCI;;;;OAIG;IACH,4BAFa,eAAe,CAM3B;IAjjCD;;OAEG;IACH,IAFU,MAAM,CAEE;IAElB;;;;OAIG;IACH,wBAAoB;IAEpB;;;OAGG;IACH,UAFU,OAAO,CAEe;IAChC,eAA6B;IAC7B,qBAAsC;IAEtC;;;;;OAKG;IACH,qCAA2C;IAE3C;;;;OAIG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,cAFU,YAAY,GAAC,MAAM,CAEM;IAEnC;;;OAGG;IACH,WAFU,YAAY,GAAC,IAAI,CAEV;IAEjB;;;OAGG;IACH,MAFU,WAAS,IAAI,CAEX;IAEZ;;;OAGG;IACH,mBAFU,SAAS,CAEQ;IAG3B;;;;OAIG;IACH,yBAFU,KAAK,CAE2E;IAE1F;;;OAGG;IACH,yBAFU,KAAK,CAE8B;IAG7C;;;OAGG;IACH,OAFU,MAAM,CAE6F;IAE7G;;;;OAIG;IACH,eAAW;IAGX;;;OAGG;IACH,qBAFU,YAAY,CAEU;IAWhC,wBAIC;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,mBAAmB,GACxB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,mBAAmB,GACxB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,mBAAmB,SAC1B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,mBAAmB,GACxB,OAAO,CAInB;IAED;;OAEG;IACH,gCAaC;IAED;;;;;;;;;;;;;MAeC;IAED,0BAkEC;IAGD;;;OAGG;IACH,gBAFW,aAAa,QASvB;IAED;;;;OAIG;IACH,kDAUC;IAED;;;;OAIG;IACH,iCAHW,aAAa,GACZ,MAAM,CA2CjB;IAED,8BA0DC;IAED,8BAmBC;IAED,2BAmBC;IAED,6BAkBC;IAED;;;OAGG;IACH,uCAHW,MAAM,GACJ,MAAM,CA+BlB;IAED,cAuCC;IAED,mBA6BC;IAuBD,eAOC;IAED;;;;OAIG;IACH,cAHW,eAAe,GACb,OAAO,CAQnB;IAED;;;;OAIG;IACH,qCA2FC;IAED,eAOC;IAED;;;OAGG;IACH,4BAFY,MAAM,CAejB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAMhB;IAiCD;;;;OAIG;IACH,sCA+GC;IAED;;;;OAIG;IACH,qCA6GC;IAED;;;OAGG;IACH,aA4CC;IAGD;;OAEG;IACH,gBAIC;;CAYJ;;;;;;;;;;;;;;;;oBAloCmB,wCAAwC;uBAFrC,2CAA2C;6BAOrC,6CAA6C;6BAqB7C,mBAAmB;0BApCtB,+CAA+C;sBAInD,8CAA8C;6BAYvC,8BAA8B;oCAiBvB,0BAA0B;8BAChC,oBAAoB;uCAF3C,0BAA0B;6CAA1B,0BAA0B;kDAA1B,0BAA0B;4CAA1B,0BAA0B;4CAA1B,0BAA0B;kDAA1B,0BAA0B;wCAA1B,0BAA0B;sCAA1B,0BAA0B;4CAA1B,0BAA0B;AAWjC,yCAKC"}
@@ -3,6 +3,7 @@ import { assert } from "../../../../../../core/assert.js";
3
3
  import { BvhClient } from "../../../../../../core/bvh2/bvh3/BvhClient.js";
4
4
  import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
5
5
  import List from "../../../../../../core/collection/list/List.js";
6
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../../../../core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
6
7
  import { AABB3 } from "../../../../../../core/geom/3d/aabb/AABB3.js";
7
8
  import { aabb3_array_combine } from "../../../../../../core/geom/3d/aabb/aabb3_array_combine.js";
8
9
  import { aabb3_expand_array } from "../../../../../../core/geom/3d/aabb/aabb3_expand_array.js";
@@ -60,9 +61,9 @@ const scratch_near_plane_normal = new Float32Array(3);
60
61
 
61
62
  /**
62
63
  *
63
- * @type {number[]}
64
+ * @type {Float32Array}
64
65
  */
65
- const scratch_array = [];
66
+ const scratch_aabb3 = new Float32Array(6);
66
67
 
67
68
  /**
68
69
  *
@@ -484,17 +485,17 @@ export class ParticleEmitter {
484
485
  //retire dead particles
485
486
  const particles = this.particles;
486
487
 
487
- particles.computeAttributeVector3AxisAlignedBoundingBox(PARTICLE_ATTRIBUTE_POSITION, scratch_array);
488
+ particles.computeAttributeVector3AxisAlignedBoundingBox(PARTICLE_ATTRIBUTE_POSITION, scratch_aabb3);
488
489
 
489
490
  //expand bounds by maximum sprite size
490
491
  const extents = this.computeSpriteMaxHalfSize();
491
492
 
492
- aabb3_expand_array(scratch_array, scratch_array, extents);
493
+ aabb3_expand_array(scratch_aabb3, scratch_aabb3, extents);
493
494
 
494
495
  //write updated bonds
495
496
  const bb = this.particleBounds;
496
497
 
497
- bb.readFromArray(scratch_array);
498
+ bb.readFromArray(scratch_aabb3);
498
499
 
499
500
  this.updateGeometryBounds();
500
501
 
@@ -516,7 +517,7 @@ export class ParticleEmitter {
516
517
  const ebb = this.emissionBounds;
517
518
  const pbb = this.particleBounds;
518
519
 
519
- aabb3_array_combine(this.bvh_leaf.bounds,0, ebb,0, pbb,0);
520
+ aabb3_array_combine(this.bvh_leaf.bounds, 0, ebb, 0, pbb, 0);
520
521
 
521
522
  this.bvh_leaf.write_bounds();
522
523
 
@@ -732,15 +733,17 @@ export class ParticleEmitter {
732
733
  }
733
734
 
734
735
  //Stack-based implementation, avoiding recursion for performance improvement
735
- const stack = scratch_array;
736
+ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
737
+
738
+ const stack_top = stack.pointer;
739
+ let stackPointer = stack_top;
736
740
 
737
- stack[0] = 0;
738
- stack[1] = particleCount - 1;
741
+ stack[stackPointer++] = 0;
742
+ stack[stackPointer++] = particleCount - 1;
739
743
 
740
- let stackPointer = 2;
741
744
  let i, j;
742
745
 
743
- while (stackPointer > 0) {
746
+ while (stackPointer > stack_top) {
744
747
  stackPointer -= 2;
745
748
 
746
749
  const right = stack[stackPointer + 1];
@@ -525,7 +525,7 @@ export class ParticlePool {
525
525
 
526
526
  const data = attribute.array;
527
527
 
528
- aabb3_from_v3_array(result,data,particle_count*3);
528
+ aabb3_from_v3_array(result, data, particle_count * 3);
529
529
 
530
530
  }
531
531
 
@@ -362,7 +362,7 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
362
362
  float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
363
363
 
364
364
  // Increase contrast in the weight
365
- // chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
365
+ chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
366
366
 
367
367
  return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
368
368
  }
@@ -35,7 +35,7 @@ export class LightProbeVolume {
35
35
  * Depth map is stored as a 2d texture of size RESOLUTION x RESOLUTION
36
36
  * @type {number}
37
37
  */
38
- #probe_depth_resolution = 16;
38
+ #probe_depth_resolution = 64;
39
39
 
40
40
  /**
41
41
  * Octahedral-encoded depth map for each probe
@@ -1 +1 @@
1
- {"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAiCA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QAuHhB"}
1
+ {"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAiCA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QA4HhB"}
@@ -92,6 +92,11 @@ export function bake_octahedral_depth_map(
92
92
  const u = (oct_x + 0.5) / (resolution);
93
93
  const v = (oct_y + 0.5) / (resolution);
94
94
 
95
+ decode_octahedron_to_unit(
96
+ probe_direction, 0,
97
+ u * 2 - 1, v * 2 - 1
98
+ );
99
+
95
100
  for (let sub_sample_index = 0; sub_sample_index < SUB_SAMPLE_COUNT; sub_sample_index++) {
96
101
 
97
102
  const sample_index2 = sub_sample_index * 2;
@@ -383,13 +383,13 @@ async function main(engine) {
383
383
  // const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
384
384
  // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
385
385
  // const path = 'data/models/sibenik/3-window-less/model.gltf';
386
- const path = 'data/models/sponza-pbr/gltf/sponza.glb';
386
+ // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
387
387
  // const path = 'data/models/samples/susanne.glb';
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
391
  // const path = 'data/models/pica_pica/pica_pica.gltf';
392
- // const path = 'data/models/samples/gi_box_01/model.glb';
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');
@@ -1 +1 @@
1
- {"version":3,"file":"InputDeviceSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/InputDeviceSwitch.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI;;;OAGG;IACH,MAFU,MAAM,CAEG;IACnB;;;OAGG;IACH,IAFU,MAAM,CAEC;IACjB;;;OAGG;IACH,SAFU,OAAO,CAEF;CAClB;mBArBkB,uCAAuC"}
1
+ {"version":3,"file":"InputDeviceSwitch.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/InputDeviceSwitch.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI;;;OAGG;IACH,MAFU,MAAM,CAEG;IACnB;;;OAGG;IACH,IAFU,MAAM,CAEC;IACjB;;;OAGG;IACH,SAFU,OAAO,CAEF;IAEf,cAOC;IAED,gBAOC;CACJ;mBAvCkB,uCAAuC"}
@@ -19,4 +19,22 @@ export class InputDeviceSwitch {
19
19
  * @type {boolean}
20
20
  */
21
21
  is_down = false
22
+
23
+ press() {
24
+ if (this.is_down) {
25
+ return;
26
+ }
27
+
28
+ this.is_down = true;
29
+ this.down.send0();
30
+ }
31
+
32
+ release() {
33
+ if (!this.is_down) {
34
+ return;
35
+ }
36
+
37
+ this.is_down = false;
38
+ this.up.send0();
39
+ }
22
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KeyboardDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/KeyboardDevice.js"],"names":[],"mappings":";AA8CA;IAgBI;;;OAGG;IACH,wBAFW,WAAW,GAAC,OAAO,EA+B7B;IA/CD;;OAEG;IACH;;;MAGE;IAEF;;;OAGG;IACH,mBAAU;IAkBN;;;OAGG;IACH,YAFU,WAAW,CAEO;IA+DhC,cAGC;IAED,aAGC;;CACJ;mBA1JkB,uCAAuC"}
1
+ {"version":3,"file":"KeyboardDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/KeyboardDevice.js"],"names":[],"mappings":";AAYA;IAgBI;;;OAGG;IACH,wBAFW,WAAW,GAAC,OAAO,EA+B7B;IA/CD;;OAEG;IACH;;;MAGE;IAEF;;;OAGG;IACH,mBAAU;IAkBN;;;OAGG;IACH,YAFU,WAAW,CAEO;IA4DhC,cAGC;IAED,aAGC;;CACJ;mBArHkB,uCAAuC"}
@@ -1,43 +1,9 @@
1
1
  import Signal from "../../../core/events/signal/Signal.js";
2
2
  import { KeyboardEvents } from "./events/KeyboardEvents.js";
3
3
  import { InputDeviceSwitch } from "./InputDeviceSwitch.js";
4
+ import { isHTMLElementFocusable } from "./isHTMLElementFocusable.js";
4
5
  import { KeyCodes } from './KeyCodes.js';
5
6
 
6
- /**
7
- *
8
- * @param thing
9
- * @param klass
10
- * @returns {boolean}
11
- */
12
- function isInstanceOf(thing, klass) {
13
- if (klass === undefined) {
14
- return false;
15
- }
16
- if (klass === null) {
17
- return false;
18
- }
19
-
20
- if (typeof klass !== "object") {
21
- return false;
22
- }
23
-
24
-
25
- return thing instanceof klass;
26
- }
27
-
28
- /**
29
- * Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
30
- * @param {Element} el
31
- */
32
- function isFocusable(el) {
33
- return isInstanceOf(el, HTMLInputElement)
34
- || isInstanceOf(el, HTMLSelectElement)
35
- || isInstanceOf(el, HTMLTextAreaElement)
36
- || isInstanceOf(el, HTMLAnchorElement)
37
- || isInstanceOf(el, HTMLButtonElement)
38
- || isInstanceOf(el, HTMLAreaElement)
39
- }
40
-
41
7
  /**
42
8
  * @readonly
43
9
  * @type {string[]}
@@ -70,7 +36,7 @@ class KeyboardDevice {
70
36
  Only element in focus receives keyboard events, so the element supplied here must be focusable in order to be able to receive events
71
37
  */
72
38
  if (
73
- !isFocusable(domElement)
39
+ !isHTMLElementFocusable(domElement)
74
40
  && domElement.getAttribute('tabindex') === null
75
41
  ) {
76
42
  new TypeError('Supplied element is not inherently focusable and does not have tabindex attribute, so it must have a tabindex attribute in order to be able receive keyboard events. Something like tabindex=0 would suffice.');
@@ -116,9 +82,7 @@ class KeyboardDevice {
116
82
  if (keyName !== undefined) {
117
83
  const button = this.keys[keyName];
118
84
 
119
- button.is_down = true;
120
- button.down.send1(event);
121
-
85
+ button.press()
122
86
  }
123
87
  }
124
88
 
@@ -138,8 +102,7 @@ class KeyboardDevice {
138
102
  if (keyName !== undefined) {
139
103
  const button = this.keys[keyName];
140
104
 
141
- button.is_down = false;
142
- button.up.send1(event);
105
+ button.release();
143
106
  }
144
107
  }
145
108
 
@@ -0,0 +1,11 @@
1
+ export class LocationalInteractionMetadata {
2
+ /**
3
+ *
4
+ * @param {Vector2} p
5
+ */
6
+ static from(p: Vector2): LocationalInteractionMetadata;
7
+ timestamp: number;
8
+ position: Vector2;
9
+ }
10
+ import Vector2 from "../../../core/geom/Vector2.js";
11
+ //# sourceMappingURL=LocationalInteractionMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocationalInteractionMetadata.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/LocationalInteractionMetadata.js"],"names":[],"mappings":"AAEA;IAII;;;OAGG;IACH,eAFW,OAAO,iCAQjB;IAbD,kBAA6B;IAC7B,kBAAwB;CAa3B;oBAjBmB,+BAA+B"}
@@ -0,0 +1,18 @@
1
+ import Vector2 from "../../../core/geom/Vector2.js";
2
+
3
+ export class LocationalInteractionMetadata {
4
+ timestamp = performance.now()
5
+ position = new Vector2()
6
+
7
+ /**
8
+ *
9
+ * @param {Vector2} p
10
+ */
11
+ static from(p) {
12
+ const r = new LocationalInteractionMetadata();
13
+
14
+ r.position.copy(p);
15
+
16
+ return r;
17
+ }
18
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"PointerDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/PointerDevice.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,wDAFY,OAAO,EAAE,CAapB;AAiRD;;;;;GAKG;AACH,mDAJW,OAAO,SACP,UAAU,GAAC,KAAK,WAChB,OAAO,QAejB;AAED;;GAEG;AACH;IA2FI;;;;OAIG;IACH,wBAHW,WAAW,EA0CrB;IArID;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;IAczB;;OAEG;IACH;;;;QAII;;WAEG;aADO,OAAO,OAAO,EAAE,CAAC,UAAU,GAAC,UAAU,CAAC,CAAC;;;;;;;;MAUpD;IAeF;;;OAGG;IACH,kBAAkB;IAElB;;;;OAIG;IACH,kBAFU,iBAAiB,EAAE,CAEL;IAExB;;;OAGG;IACH,yCAEC;IAED;;;OAGG;IACH,0CAEC;IAED;;;OAGG;IACH,2CAEC;IAgLD;;;OAGG;IACH,oBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,6BAsBC;IAED,0BAEC;IAED;;;;OAIG;IACH,qCAHW,OAAO,SACP,UAAU,GAAC,KAAK,QAI1B;IAED,cAkCC;IAED,aA2BC;;CACJ;oBA5rBmB,+BAA+B;mBADhC,uCAAuC;kCAMxB,wBAAwB"}
1
+ {"version":3,"file":"PointerDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/PointerDevice.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wDAFY,OAAO,EAAE,CAapB;AA+UD;;;;;GAKG;AACH,mDAJW,OAAO,SACP,UAAU,GAAC,KAAK,WAChB,OAAO,QAejB;AAED;;GAEG;AACH;IA2FI;;;;OAIG;IACH,wBAHW,WAAW,EAoCrB;IA/HD;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;IAczB;;OAEG;IACH;;;;QAII;;WAEG;aADO,OAAO,OAAO,EAAE,CAAC,UAAU,GAAC,UAAU,CAAC,CAAC;;;;;;;;MAUpD;IAeF;;;OAGG;IACH,kBAAkB;IAElB;;;;OAIG;IACH,kBAFU,iBAAiB,EAAE,CAEL;IAExB;;;OAGG;IACH,yCAEC;IAED;;;OAGG;IACH,0CAEC;IAED;;;OAGG;IACH,2CAEC;IAqKD;;;OAGG;IACH,oBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,6BAsBC;IAED,0BAEC;IAED;;;;OAIG;IACH,qCAHW,OAAO,SACP,UAAU,GAAC,KAAK,QAI1B;IAED,cAkCC;IAED,aA2BC;;CACJ;oBAjvBmB,+BAA+B;mBADhC,uCAAuC;kCAOxB,wBAAwB"}