@woosh/meep-engine 2.43.17 → 2.43.19
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/core/assert.js +3 -1
- package/core/bvh2/aabb3/aabb3_intersects_ray.js +14 -9
- package/core/bvh2/aabb3/aabb3_intersects_ray_branchless.js +52 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +2 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +162 -10
- package/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +34 -0
- package/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +175 -0
- package/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +122 -0
- package/core/bvh2/bvh3/{bvh_collect_user_data.js → query/bvh_collect_user_data.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_leaves_generic.js → query/bvh_query_leaves_generic.js} +1 -1
- package/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +97 -0
- package/core/bvh2/bvh3/{bvh_query_user_data_generic.js → query/bvh_query_user_data_generic.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_user_data_nearest_to_point.js → query/bvh_query_user_data_nearest_to_point.js} +3 -3
- package/core/bvh2/bvh3/{bvh_query_user_data_nearest_to_point.spec.js → query/bvh_query_user_data_nearest_to_point.spec.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_user_data_overlaps_frustum.js → query/bvh_query_user_data_overlaps_frustum.js} +2 -2
- package/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/core/collection/array/arrayQuickSort.js +1 -1
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- package/core/geom/3d/aabb/compute_aabb_from_points.js +4 -3
- package/core/geom/3d/compute_triangle_normal.js +76 -0
- package/core/geom/3d/topology/samples/sampleFloodFill.js +1 -1
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/core/geom/3d/topology/struct/TopoTriangle.js +1 -57
- package/core/geom/3d/topology/tm_face_normal.js +1 -1
- package/core/geom/3d/topology/tm_vertex_compute_normal.js +1 -1
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +195 -27
- package/core/geom/Vector3.js +12 -12
- package/core/math/physics/brdf/D_GGX.js +13 -0
- package/editor/tools/v2/prototypeTransformControls.js +14 -2
- package/engine/ecs/parent/EntityNode.js +80 -7
- package/engine/ecs/parent/EntityNodeFlags.js +8 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +9 -1
- package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +1 -1
- package/engine/graphics/geometry/AttributeSpec.js +18 -3
- package/engine/graphics/geometry/VertexDataSpec.js +53 -3
- package/engine/graphics/micron/format/VirtualGeometry.js +7 -0
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +1 -1
- package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +5 -2
- package/engine/graphics/particles/particular/engine/parameter/sample/RGBA_LUT_HEATMAP_IR.js +11 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -9
- package/engine/graphics/render/forward_plus/model/DirectionalLight.js +40 -0
- package/engine/graphics/sh3/README.md +1 -0
- package/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +265 -0
- package/engine/graphics/sh3/path_tracer/PathTracedMesh.js +85 -0
- package/engine/graphics/sh3/path_tracer/PathTracer.js +534 -0
- package/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.js +22 -0
- package/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +36 -0
- package/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +55 -0
- package/engine/graphics/sh3/path_tracer/make_one_vector3.js +7 -0
- package/engine/graphics/sh3/path_tracer/make_sky_hosek.js +44 -0
- package/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +17 -0
- package/engine/graphics/sh3/path_tracer/make_zero_vector3.js +7 -0
- package/engine/graphics/sh3/path_tracer/prototypePathTracer.js +631 -0
- package/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +39 -0
- package/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +42 -0
- package/engine/graphics/sh3/path_tracer/ray_reflect.js +27 -0
- package/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +35 -0
- package/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +12 -0
- package/engine/graphics/sh3/sky/hosek/README.md +4 -0
- package/engine/graphics/sh3/sky/hosek/prototype_hosek.js +71 -0
- package/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +4171 -0
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +2 -0
- package/package.json +1 -1
- package/view/elements/progress/SmoothProgressBar.js +1 -1
- package/view/task/TaskProgressView.js +6 -8
- package/core/bvh2/bvh3/bvh_query_leaves_ray.js +0 -95
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GGX diffuse distribution function
|
|
3
|
+
* @see https://google.github.io/filament/Filament.md.html#listing_diffusebrdf
|
|
4
|
+
* @param {number} NoH dot(n,h) where n is surface normal and h is half unit vector between incident light and outgoing light (view vector)
|
|
5
|
+
* @param {number} roughness
|
|
6
|
+
* @returns {number}
|
|
7
|
+
*/
|
|
8
|
+
export function D_GGX(NoH, roughness) {
|
|
9
|
+
const a = NoH * roughness;
|
|
10
|
+
const k = roughness / (1 - NoH * NoH + a * a);
|
|
11
|
+
|
|
12
|
+
return k * k * (1 / Math.PI);
|
|
13
|
+
}
|
|
@@ -9,6 +9,10 @@ import { Camera } from "../../../engine/graphics/ecs/camera/Camera.js";
|
|
|
9
9
|
import { TransformAttachmentSystem } from "../../../engine/ecs/transform-attachment/TransformAttachmentSystem.js";
|
|
10
10
|
import InputController from "../../../engine/input/ecs/components/InputController.js";
|
|
11
11
|
import InputControllerSystem from "../../../engine/input/ecs/systems/InputControllerSystem.js";
|
|
12
|
+
import { GLTFAssetLoader } from "../../../engine/asset/loaders/GLTFAssetLoader.js";
|
|
13
|
+
import {
|
|
14
|
+
three_object_to_entity_composition
|
|
15
|
+
} from "../../../engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js";
|
|
12
16
|
|
|
13
17
|
const harness = new EngineHarness();
|
|
14
18
|
|
|
@@ -17,11 +21,13 @@ const harness = new EngineHarness();
|
|
|
17
21
|
* @param {Engine} engine
|
|
18
22
|
*/
|
|
19
23
|
async function main(engine) {
|
|
20
|
-
EngineHarness.buildBasics({
|
|
24
|
+
await EngineHarness.buildBasics({
|
|
21
25
|
engine,
|
|
22
26
|
cameraController: false
|
|
23
27
|
});
|
|
24
28
|
|
|
29
|
+
const gltf_asset = await engine.assetManager.promise('data/models/sponza-pbr/gltf/sponza.glb', 'gltf');
|
|
30
|
+
|
|
25
31
|
|
|
26
32
|
const ecd = engine.entityManager.dataset;
|
|
27
33
|
|
|
@@ -46,9 +52,13 @@ async function main(engine) {
|
|
|
46
52
|
|
|
47
53
|
const controls = new TransformControls(camera.component.object, engine.gameView.el);
|
|
48
54
|
|
|
55
|
+
const entityNode = three_object_to_entity_composition(gltf_asset.create());
|
|
56
|
+
entityNode.build(ecd);
|
|
57
|
+
entityNode.transform.scale.multiplyScalar(0.1);
|
|
49
58
|
|
|
50
59
|
controls.build(ecd); // add controls to the scene
|
|
51
|
-
controls.attach(cube_entity); // make controls target the cube
|
|
60
|
+
// controls.attach(cube_entity); // make controls target the cube
|
|
61
|
+
controls.attach(entityNode.entity.entity); // make controls target the cube
|
|
52
62
|
|
|
53
63
|
new EntityBuilder()
|
|
54
64
|
.add(new InputController([{
|
|
@@ -76,5 +86,7 @@ harness.initialize({
|
|
|
76
86
|
config.addSystem(new ShadedGeometrySystem(engine));
|
|
77
87
|
config.addSystem(new TransformAttachmentSystem(engine));
|
|
78
88
|
config.addSystem(new InputControllerSystem(engine.devices));
|
|
89
|
+
|
|
90
|
+
config.addLoader('gltf', new GLTFAssetLoader());
|
|
79
91
|
}
|
|
80
92
|
}).then(main);
|
|
@@ -6,6 +6,9 @@ import { array_push_if_unique } from "../../../core/collection/array/array_push_
|
|
|
6
6
|
import { Transform } from "../transform/Transform.js";
|
|
7
7
|
import { TransformAttachment, TransformAttachmentFlags } from "../transform-attachment/TransformAttachment.js";
|
|
8
8
|
import Signal from "../../../core/events/signal/Signal.js";
|
|
9
|
+
import { EntityNodeFlags } from "./EntityNodeFlags.js";
|
|
10
|
+
|
|
11
|
+
const DEFAULT_FLAGS = EntityNodeFlags.LiveManagement;
|
|
9
12
|
|
|
10
13
|
export class EntityNode {
|
|
11
14
|
/**
|
|
@@ -45,6 +48,52 @@ export class EntityNode {
|
|
|
45
48
|
built: new Signal(),
|
|
46
49
|
destroyed: new Signal()
|
|
47
50
|
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
this.flags = DEFAULT_FLAGS;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {number|EntityNodeFlags} flag
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
setFlag(flag) {
|
|
65
|
+
this.flags |= flag;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {number|EntityNodeFlags} flag
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
clearFlag(flag) {
|
|
74
|
+
this.flags &= ~flag;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {number|EntityNodeFlags} flag
|
|
80
|
+
* @param {boolean} value
|
|
81
|
+
*/
|
|
82
|
+
writeFlag(flag, value) {
|
|
83
|
+
if (value) {
|
|
84
|
+
this.setFlag(flag);
|
|
85
|
+
} else {
|
|
86
|
+
this.clearFlag(flag);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {number|EntityNodeFlags} flag
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
getFlag(flag) {
|
|
96
|
+
return (this.flags & flag) === flag;
|
|
48
97
|
}
|
|
49
98
|
|
|
50
99
|
/**
|
|
@@ -263,6 +312,28 @@ export class EntityNode {
|
|
|
263
312
|
return this.__entity.isBuilt;
|
|
264
313
|
}
|
|
265
314
|
|
|
315
|
+
attachListeners() {
|
|
316
|
+
if (this.getFlag(EntityNodeFlags.TransformObserved)) {
|
|
317
|
+
// already observed
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
this.__transform.position.onChanged.add(this.__transform_sync_down, this);
|
|
322
|
+
this.__transform.scale.onChanged.add(this.__transform_sync_down, this);
|
|
323
|
+
this.__transform.rotation.onChanged.add(this.__transform_sync_down, this);
|
|
324
|
+
|
|
325
|
+
this.setFlag(EntityNodeFlags.TransformObserved);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
detachListeners() {
|
|
329
|
+
|
|
330
|
+
this.__transform.position.onChanged.remove(this.__transform_sync_down, this);
|
|
331
|
+
this.__transform.scale.onChanged.remove(this.__transform_sync_down, this);
|
|
332
|
+
this.__transform.rotation.onChanged.remove(this.__transform_sync_down, this);
|
|
333
|
+
|
|
334
|
+
this.clearFlag(EntityNodeFlags.TransformObserved);
|
|
335
|
+
}
|
|
336
|
+
|
|
266
337
|
/**
|
|
267
338
|
*
|
|
268
339
|
* @param {EntityComponentDataset} ecd
|
|
@@ -303,9 +374,9 @@ export class EntityNode {
|
|
|
303
374
|
this.__transform_sync_down();
|
|
304
375
|
|
|
305
376
|
// attach listeners
|
|
306
|
-
this.
|
|
307
|
-
|
|
308
|
-
|
|
377
|
+
if (this.getFlag(EntityNodeFlags.LiveManagement)) {
|
|
378
|
+
this.attachListeners();
|
|
379
|
+
}
|
|
309
380
|
|
|
310
381
|
this.__entity.build(ecd);
|
|
311
382
|
|
|
@@ -321,6 +392,7 @@ export class EntityNode {
|
|
|
321
392
|
this.on.built.send0();
|
|
322
393
|
}
|
|
323
394
|
|
|
395
|
+
|
|
324
396
|
destroy() {
|
|
325
397
|
if (!this.__entity.isBuilt) {
|
|
326
398
|
// not built
|
|
@@ -329,10 +401,11 @@ export class EntityNode {
|
|
|
329
401
|
return;
|
|
330
402
|
}
|
|
331
403
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
404
|
+
if (this.getFlag(EntityNodeFlags.TransformObserved)) {
|
|
405
|
+
|
|
406
|
+
// remove listeners
|
|
407
|
+
this.detachListeners();
|
|
408
|
+
}
|
|
336
409
|
|
|
337
410
|
// destroy children first
|
|
338
411
|
const children = this.__children;
|
|
@@ -11,7 +11,7 @@ import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_comp
|
|
|
11
11
|
import {
|
|
12
12
|
ExplicitBinaryBoundingVolumeHierarchy
|
|
13
13
|
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
14
|
-
import { bvh_query_leaves_generic } from "../../../../core/bvh2/bvh3/bvh_query_leaves_generic.js";
|
|
14
|
+
import { bvh_query_leaves_generic } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_generic.js";
|
|
15
15
|
import { BVHQueryIntersectsRay } from "../../../../core/bvh2/bvh3/query/BVHQueryIntersectsRay.js";
|
|
16
16
|
import Task from "../../../../core/process/task/Task.js";
|
|
17
17
|
import { RuntimeDrawMethodOptimizer } from "./render/optimization/RuntimeDrawMethodOptimizer.js";
|
|
@@ -19,7 +19,7 @@ import { TaskSignal } from "../../../../core/process/task/TaskSignal.js";
|
|
|
19
19
|
import TaskState from "../../../../core/process/task/TaskState.js";
|
|
20
20
|
import {
|
|
21
21
|
bvh_query_user_data_overlaps_frustum
|
|
22
|
-
} from "../../../../core/bvh2/bvh3/bvh_query_user_data_overlaps_frustum.js";
|
|
22
|
+
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -7,6 +7,14 @@ export const SGMeshFlags = {
|
|
|
7
7
|
Loaded: 4
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @readonly
|
|
12
|
+
* @type {number}
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_FLAGS = SGMeshFlags.CastShadow
|
|
15
|
+
| SGMeshFlags.ReceiveShadow
|
|
16
|
+
;
|
|
17
|
+
|
|
10
18
|
export class SGMesh {
|
|
11
19
|
constructor() {
|
|
12
20
|
/**
|
|
@@ -33,7 +41,7 @@ export class SGMesh {
|
|
|
33
41
|
*
|
|
34
42
|
* @type {number}
|
|
35
43
|
*/
|
|
36
|
-
this.flags =
|
|
44
|
+
this.flags = DEFAULT_FLAGS;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
/**
|
|
@@ -5,7 +5,7 @@ import { assert } from "../../../../../core/assert.js";
|
|
|
5
5
|
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
6
6
|
import {
|
|
7
7
|
bvh_query_user_data_overlaps_frustum
|
|
8
|
-
} from "../../../../../core/bvh2/bvh3/bvh_query_user_data_overlaps_frustum.js";
|
|
8
|
+
} from "../../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
9
9
|
import { ShadedGeometryFlags } from "../ShadedGeometryFlags.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -3,22 +3,28 @@ import { computeStringHash } from "../../../core/primitives/strings/computeStrin
|
|
|
3
3
|
import { DataTypeByteSizes } from "../../../core/collection/table/DataTypeByteSizes.js";
|
|
4
4
|
import { assert } from "../../../core/assert.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Describes data structure of a single data attribute, such as a scalar, or a vector
|
|
8
|
+
* This structure is designed to map well to GPU shader formats and is intended for larger datasets, such as meshes or particle clouds
|
|
9
|
+
*/
|
|
6
10
|
export class AttributeSpec {
|
|
7
11
|
constructor() {
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Typically unique within a given set, used to identify the attribute
|
|
10
14
|
* @type {string}
|
|
11
15
|
*/
|
|
12
16
|
this.name = "";
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
19
|
+
* How the attribute is stored in memory and interpreted
|
|
16
20
|
* @type {DataType}
|
|
17
21
|
*/
|
|
18
22
|
this.type = DataType.Float32;
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
25
|
+
* How many elements the attribute uses. This is cardinality of a vector.
|
|
26
|
+
* 1 means the attribute is a scalar
|
|
27
|
+
* must be greater or equal to 1
|
|
22
28
|
* @type {number}
|
|
23
29
|
*/
|
|
24
30
|
this.itemSize = 1;
|
|
@@ -62,6 +68,15 @@ export class AttributeSpec {
|
|
|
62
68
|
this.normalized = normalized;
|
|
63
69
|
}
|
|
64
70
|
|
|
71
|
+
toJSON() {
|
|
72
|
+
return {
|
|
73
|
+
name: this.name,
|
|
74
|
+
type: this.type,
|
|
75
|
+
itemSize: this.itemSize,
|
|
76
|
+
normalized: this.normalized
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
hash() {
|
|
66
81
|
return computeStringHash(this.name);
|
|
67
82
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { invokeObjectHash } from "../../../core/model/object/invokeObjectHash.js";
|
|
2
2
|
import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
|
|
3
3
|
import { isArrayEqual } from "../../../core/collection/array/isArrayEqual.js";
|
|
4
|
+
import { AttributeSpec } from "./AttributeSpec.js";
|
|
5
|
+
import { assert } from "../../../core/assert.js";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @readonly
|
|
9
|
+
* @type {number}
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_HASH = 1234567;
|
|
6
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Describes a set of data attributes. A good analogy would be "all data associated with geometry vertex"
|
|
15
|
+
* @example "uv","position" and "normal" attributes of geometry vertices
|
|
16
|
+
*/
|
|
7
17
|
export class VertexDataSpec {
|
|
8
18
|
constructor() {
|
|
9
19
|
/**
|
|
@@ -13,7 +23,7 @@ export class VertexDataSpec {
|
|
|
13
23
|
this.attributes = [];
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
|
-
*
|
|
26
|
+
* Cached hash for speed
|
|
17
27
|
* @type {number}
|
|
18
28
|
* @private
|
|
19
29
|
*/
|
|
@@ -92,6 +102,8 @@ export class VertexDataSpec {
|
|
|
92
102
|
*/
|
|
93
103
|
add(attribute) {
|
|
94
104
|
|
|
105
|
+
assert.equal(attribute.isAttributeSpec, true, 'attribute.isAttributeSpec !== true');
|
|
106
|
+
|
|
95
107
|
//check uniqueness of name
|
|
96
108
|
if (this.getAttributeByName(attribute.name) !== undefined) {
|
|
97
109
|
throw new Error(`Attribute named '${attribute.name}' already exists`);
|
|
@@ -111,7 +123,19 @@ export class VertexDataSpec {
|
|
|
111
123
|
* @param {AttributeSpec[]} attributes
|
|
112
124
|
*/
|
|
113
125
|
setAttributes(attributes) {
|
|
114
|
-
|
|
126
|
+
|
|
127
|
+
this.clear();
|
|
128
|
+
|
|
129
|
+
const n = attributes.length;
|
|
130
|
+
|
|
131
|
+
for (let i = 0; i < n; i++) {
|
|
132
|
+
this.add(attributes[i]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
clear() {
|
|
138
|
+
this.attributes.splice(0, this.attributes.length);
|
|
115
139
|
|
|
116
140
|
// reset hash to trigger hash update
|
|
117
141
|
this.__hash = DEFAULT_HASH;
|
|
@@ -142,6 +166,32 @@ export class VertexDataSpec {
|
|
|
142
166
|
return this.__hash;
|
|
143
167
|
}
|
|
144
168
|
|
|
169
|
+
toJSON() {
|
|
170
|
+
return {
|
|
171
|
+
attributes: JSON.stringify(this.attributes)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fromJSON({
|
|
176
|
+
attributes = []
|
|
177
|
+
}) {
|
|
178
|
+
|
|
179
|
+
this.clear();
|
|
180
|
+
|
|
181
|
+
const n = attributes.length;
|
|
182
|
+
|
|
183
|
+
for (let i = 0; i < n; i++) {
|
|
184
|
+
|
|
185
|
+
const aj = attributes[i];
|
|
186
|
+
|
|
187
|
+
const attribute = AttributeSpec.fromJSON(aj);
|
|
188
|
+
|
|
189
|
+
this.add(attribute);
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
145
195
|
/**
|
|
146
196
|
*
|
|
147
197
|
* @returns {number}
|
|
@@ -57,8 +57,15 @@ export class VirtualGeometry {
|
|
|
57
57
|
this.stats_source_byte_size = 0;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param {number} patch_count how much must be supported
|
|
63
|
+
* @return {boolean} true if capacity was sufficient, false if had to be resized
|
|
64
|
+
*/
|
|
60
65
|
ensureCapacity(patch_count) {
|
|
61
66
|
if (this.__capacity < patch_count) {
|
|
67
|
+
// grow capacity
|
|
68
|
+
|
|
62
69
|
const new_capacity = Math.ceil(max3(
|
|
63
70
|
patch_count,
|
|
64
71
|
patch_count * CAPACITY_GROW_FACTOR,
|
|
@@ -149,7 +149,7 @@ export class VirtualGeometryBuilder {
|
|
|
149
149
|
output.loolup_geometries[geometry.id] = geometry;
|
|
150
150
|
output.lookup_instance_transforms[instance_id] = transform;
|
|
151
151
|
|
|
152
|
-
// build up
|
|
152
|
+
// build up occurrences
|
|
153
153
|
get_geometry_patch_cut(
|
|
154
154
|
output,
|
|
155
155
|
refinement_spec,
|
|
@@ -95,11 +95,13 @@ export function get_geometry_patch_cut(
|
|
|
95
95
|
for (i = 0; i < child_count; i++) {
|
|
96
96
|
const child = children[i];
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const child_id = child.id;
|
|
99
|
+
|
|
100
|
+
if (included_set.getAndSet(child_id)) {
|
|
99
101
|
continue;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
stack[stack_cursor++] =
|
|
104
|
+
stack[stack_cursor++] = child_id;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
continue;
|
|
@@ -122,6 +124,7 @@ export function get_geometry_patch_cut(
|
|
|
122
124
|
if (!destination.ensureCapacity(output_patch_cursor)) {
|
|
123
125
|
// redo the work
|
|
124
126
|
get_geometry_patch_cut(destination, spec, geometry, instance_id, transform);
|
|
127
|
+
|
|
125
128
|
} else {
|
|
126
129
|
|
|
127
130
|
destination.patch_count = output_patch_cursor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ParameterLookupTable } from "../ParameterLookupTable.js";
|
|
2
|
+
|
|
3
|
+
export const RGBA_LUT_HEATMAP_IR = new ParameterLookupTable(4);
|
|
4
|
+
RGBA_LUT_HEATMAP_IR.write([
|
|
5
|
+
0, 0, 255, 10,
|
|
6
|
+
0, 179, 179, 10,
|
|
7
|
+
0, 255, 0, 10,
|
|
8
|
+
255, 255, 0, 10,
|
|
9
|
+
255, 5, 5, 10
|
|
10
|
+
]);
|
|
11
|
+
RGBA_LUT_HEATMAP_IR.computeUniformPositions();
|
|
@@ -81,6 +81,7 @@ import { pick } from "../../../../../../../ecs/grid/pick.js";
|
|
|
81
81
|
import { clamp01 } from "../../../../../../../core/math/clamp01.js";
|
|
82
82
|
import { randomFromArray } from "../../../../../../../core/math/random/randomFromArray.js";
|
|
83
83
|
import { SamplingFunctionKind } from "./SamplingFunctionKind.js";
|
|
84
|
+
import { RGBA_LUT_HEATMAP_IR } from "../../parameter/sample/RGBA_LUT_HEATMAP_IR.js";
|
|
84
85
|
|
|
85
86
|
const engineHarness = new EngineHarness();
|
|
86
87
|
|
|
@@ -168,15 +169,7 @@ async function init(harness) {
|
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
|
|
171
|
-
const heatmap_lut_0 =
|
|
172
|
-
heatmap_lut_0.write([
|
|
173
|
-
0, 0, 255, 10,
|
|
174
|
-
0, 179, 179, 10,
|
|
175
|
-
0, 255, 0, 10,
|
|
176
|
-
255, 255, 0, 10,
|
|
177
|
-
255, 5, 5, 10
|
|
178
|
-
]);
|
|
179
|
-
heatmap_lut_0.computeUniformPositions();
|
|
172
|
+
const heatmap_lut_0 = RGBA_LUT_HEATMAP_IR;
|
|
180
173
|
|
|
181
174
|
const heatmap_lut_orange_to_red = new ParameterLookupTable(4);
|
|
182
175
|
heatmap_lut_orange_to_red.write([
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AbstractLight } from "./AbstractLight.js";
|
|
2
|
+
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
3
|
+
import { Color } from "../../../../../core/color/Color.js";
|
|
4
|
+
import Vector1 from "../../../../../core/geom/Vector1.js";
|
|
5
|
+
|
|
6
|
+
export class DirectionalLight extends AbstractLight {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {Vector3}
|
|
13
|
+
*/
|
|
14
|
+
this.position = new Vector3();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {Vector3}
|
|
19
|
+
*/
|
|
20
|
+
this.direction = new Vector3();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @readonly
|
|
24
|
+
* @type {Color}
|
|
25
|
+
*/
|
|
26
|
+
this.color = new Color(1, 1, 1);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {Vector1}
|
|
31
|
+
*/
|
|
32
|
+
this.intensity = new Vector1(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @readonly
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
*/
|
|
40
|
+
DirectionalLight.prototype.isDirectionalLight = true;
|
|
@@ -2,3 +2,4 @@ Path tracing ideas:
|
|
|
2
2
|
* https://raytracing.github.io/books/RayTracingInOneWeekend.html
|
|
3
3
|
* [smallpt](https://www.kevinbeason.com/smallpt/) (100 line c implementation of path tracer)
|
|
4
4
|
* [three path tracer](https://github.com/gkjohnson/three-gpu-pathtracer)
|
|
5
|
+
* http://blog.hvidtfeldts.net/index.php/2015/01/path-tracing-3d-fractals/
|