@woosh/meep-engine 2.119.45 → 2.119.46
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.
- package/package.json +1 -1
- package/src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.d.ts +10 -0
- package/src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.js +84 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -61
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Engine} engine
|
|
4
|
+
* @param {string} path
|
|
5
|
+
* @param {LightProbeVolume} [volume]
|
|
6
|
+
* @return {Promise<LightProbeVolume>}
|
|
7
|
+
*/
|
|
8
|
+
export function lpv_obtain_storage_cached_volume({ engine, path, volume }: Engine): Promise<LightProbeVolume>;
|
|
9
|
+
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
10
|
+
//# sourceMappingURL=lpv_obtain_storage_cached_volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lpv_obtain_storage_cached_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,oFAFY,QAAQ,gBAAgB,CAAC,CAqEpC;iCA7EgC,uBAAuB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
3
|
+
import { number_pretty_print } from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
4
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
5
|
+
import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
|
|
6
|
+
import { build_probes_for_scene } from "./build_probes_for_scene.js";
|
|
7
|
+
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
8
|
+
import { LightProbeVolumeSerializationAdapter } from "./serialization/LightProbeVolumeSerializationAdapter.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {Engine} engine
|
|
13
|
+
* @param {string} path
|
|
14
|
+
* @param {LightProbeVolume} [volume]
|
|
15
|
+
* @return {Promise<LightProbeVolume>}
|
|
16
|
+
*/
|
|
17
|
+
export async function lpv_obtain_storage_cached_volume({
|
|
18
|
+
engine,
|
|
19
|
+
path,
|
|
20
|
+
volume = new LightProbeVolume()
|
|
21
|
+
}) {
|
|
22
|
+
|
|
23
|
+
volume.clear();
|
|
24
|
+
|
|
25
|
+
const key = `lpv:${path}`;
|
|
26
|
+
|
|
27
|
+
const adapter = new LightProbeVolumeSerializationAdapter();
|
|
28
|
+
|
|
29
|
+
if (await engine.storage.promiseContains(key)
|
|
30
|
+
// && false // TODO re-enable
|
|
31
|
+
) {
|
|
32
|
+
const data = await engine.storage.promiseLoadBinary(key);
|
|
33
|
+
|
|
34
|
+
console.log(`LPV data size ${number_pretty_print(data.byteLength)} bytes`);
|
|
35
|
+
|
|
36
|
+
const buffer = BinaryBuffer.fromArrayBuffer(data);
|
|
37
|
+
|
|
38
|
+
adapter.deserialize(buffer, volume);
|
|
39
|
+
|
|
40
|
+
return volume;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const ecd = engine.entityManager.dataset;
|
|
45
|
+
|
|
46
|
+
// build bounding box for the scene
|
|
47
|
+
const mesh_bounds = new AABB3();
|
|
48
|
+
mesh_bounds.setNegativelyInfiniteBounds();
|
|
49
|
+
|
|
50
|
+
ecd.traverseEntities([ShadedGeometry, Transform],
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {ShadedGeometry} sg
|
|
54
|
+
* @param transform
|
|
55
|
+
* @param entity
|
|
56
|
+
*/
|
|
57
|
+
(sg, transform, entity) => {
|
|
58
|
+
|
|
59
|
+
const box = new AABB3();
|
|
60
|
+
|
|
61
|
+
sg.getBoundingBox(box);
|
|
62
|
+
|
|
63
|
+
mesh_bounds.expandToFit(box);
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await build_probes_for_scene({
|
|
68
|
+
volume,
|
|
69
|
+
engine,
|
|
70
|
+
ecd,
|
|
71
|
+
bounds: mesh_bounds,
|
|
72
|
+
density: 500
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const buffer = new BinaryBuffer();
|
|
76
|
+
|
|
77
|
+
adapter.serialize(buffer, volume);
|
|
78
|
+
|
|
79
|
+
buffer.trim();
|
|
80
|
+
|
|
81
|
+
engine.storage.promiseStoreBinary(key, buffer.data)
|
|
82
|
+
|
|
83
|
+
return volume;
|
|
84
|
+
}
|
|
@@ -19,6 +19,7 @@ import { array_copy } from "../../../core/collection/array/array_copy.js";
|
|
|
19
19
|
import { is_typed_array_equals } from "../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
20
20
|
import { Color } from "../../../core/color/Color.js";
|
|
21
21
|
import { kelvin_to_rgb } from "../../../core/color/kelvin/kelvin_to_rgb.js";
|
|
22
|
+
import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
|
|
22
23
|
import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
|
|
23
24
|
import { visualize_tetrahedral_mesh } from "../../../core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js";
|
|
24
25
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
@@ -29,7 +30,6 @@ import { min2 } from "../../../core/math/min2.js";
|
|
|
29
30
|
import { RAD_TO_DEG } from "../../../core/math/RAD_TO_DEG.js";
|
|
30
31
|
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
31
32
|
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
32
|
-
import { number_pretty_print } from "../../../core/primitives/numbers/number_pretty_print.js";
|
|
33
33
|
import { delay } from "../../../core/process/delay.js";
|
|
34
34
|
import ButtonView from "../../../view/elements/button/ButtonView.js";
|
|
35
35
|
import { GLTFAssetLoader } from "../../asset/loaders/GLTFAssetLoader.js";
|
|
@@ -53,11 +53,10 @@ import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
|
53
53
|
import { three_object_to_entity_composition } from "../ecs/mesh-v2/three_object_to_entity_composition.js";
|
|
54
54
|
import { GizmoRenderingPlugin } from "../render/gizmo/GizmoRenderingPlugin.js";
|
|
55
55
|
import { MaterialTransformer } from "./gi/material/MaterialTransformer.js";
|
|
56
|
-
import { build_probes_for_scene } from "./lpv/build_probes_for_scene.js";
|
|
57
56
|
import { OctahedralDepthDebuggerWidget } from "./lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js";
|
|
58
57
|
import { VLPDepthMapVisualisation } from "./lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js";
|
|
59
58
|
import { LightProbeVolume } from "./lpv/LightProbeVolume.js";
|
|
60
|
-
import {
|
|
59
|
+
import { lpv_obtain_storage_cached_volume } from "./lpv/lpv_obtain_storage_cached_volume.js";
|
|
61
60
|
import { lpv_visualize_probes } from "./lpv/util/lpv_visualise_probes.js";
|
|
62
61
|
|
|
63
62
|
/**
|
|
@@ -203,63 +202,6 @@ function make_test_texture(t = 1) {
|
|
|
203
202
|
return tex;
|
|
204
203
|
}
|
|
205
204
|
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {Engine} engine
|
|
209
|
-
* @param {string} path
|
|
210
|
-
* @param {LightProbeVolume} volume
|
|
211
|
-
* @return {Promise<LightProbeVolume>}
|
|
212
|
-
*/
|
|
213
|
-
async function getVolume({
|
|
214
|
-
engine,
|
|
215
|
-
path,
|
|
216
|
-
volume = new LightProbeVolume()
|
|
217
|
-
}) {
|
|
218
|
-
|
|
219
|
-
volume.clear();
|
|
220
|
-
|
|
221
|
-
const key = `lpv:${path}`;
|
|
222
|
-
|
|
223
|
-
const adapter = new LightProbeVolumeSerializationAdapter();
|
|
224
|
-
|
|
225
|
-
if (await engine.storage.promiseContains(key)
|
|
226
|
-
// && false // TODO re-enable
|
|
227
|
-
) {
|
|
228
|
-
const data = await engine.storage.promiseLoadBinary(key);
|
|
229
|
-
|
|
230
|
-
console.log(`LPV data size ${number_pretty_print(data.byteLength)} bytes`);
|
|
231
|
-
|
|
232
|
-
const buffer = BinaryBuffer.fromArrayBuffer(data);
|
|
233
|
-
|
|
234
|
-
adapter.deserialize(buffer, volume);
|
|
235
|
-
|
|
236
|
-
return volume;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
240
|
-
const mesh_bounds = mesh_asset.boundingBox;
|
|
241
|
-
|
|
242
|
-
const ecd = engine.entityManager.dataset;
|
|
243
|
-
|
|
244
|
-
await build_probes_for_scene({
|
|
245
|
-
volume,
|
|
246
|
-
engine,
|
|
247
|
-
ecd,
|
|
248
|
-
bounds: mesh_bounds,
|
|
249
|
-
density: 500
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const buffer = new BinaryBuffer();
|
|
253
|
-
|
|
254
|
-
adapter.serialize(buffer, volume);
|
|
255
|
-
|
|
256
|
-
buffer.trim();
|
|
257
|
-
|
|
258
|
-
engine.storage.promiseStoreBinary(key, buffer.data)
|
|
259
|
-
|
|
260
|
-
return volume;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
205
|
/**
|
|
264
206
|
*
|
|
265
207
|
* @param {EntityComponentDataset} ecd
|
|
@@ -495,7 +437,7 @@ async function main(engine) {
|
|
|
495
437
|
|
|
496
438
|
console.time('getVolume');
|
|
497
439
|
// console.profile('getVolume');
|
|
498
|
-
await
|
|
440
|
+
await lpv_obtain_storage_cached_volume({ engine, path, volume });
|
|
499
441
|
// console.profileEnd('getVolume');
|
|
500
442
|
console.timeEnd('getVolume');
|
|
501
443
|
|