@woosh/meep-engine 2.108.2 → 2.108.4
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/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +490 -193
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +490 -193
- package/package.json +1 -1
- package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +6 -0
- package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +15 -3
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +25 -14
- package/src/core/collection/array/arrayQuickSort.d.ts +0 -9
- package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
- package/src/core/collection/array/arrayQuickSort.js +0 -73
- package/src/core/collection/array/array_quick_sort_by_comparator.d.ts +10 -0
- package/src/core/collection/array/array_quick_sort_by_comparator.d.ts.map +1 -0
- package/src/core/collection/array/array_quick_sort_by_comparator.js +75 -0
- package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +8 -0
- package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +1 -0
- package/src/core/collection/array/array_quick_sort_by_lookup.js +78 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +15 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.js +48 -0
- package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +2 -7
- package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts +11 -0
- package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts.map +1 -0
- package/src/core/geom/3d/aabb3_compute_from_triangle.js +43 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +5 -5
- package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +9 -0
- package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +17 -0
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +6 -3
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +56 -18
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +11 -4
- package/src/core/geom/3d/tetrahedra/{GetDepthForTetrahedronProbe.glsl → triangle/GetDepthForTetrahedronProbe.glsl} +17 -10
- package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts +2 -0
- package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/triangle/prototype.js +128 -0
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts +13 -0
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +120 -0
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +3 -0
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +106 -0
- package/src/core/math/factorial.d.ts +7 -0
- package/src/core/math/factorial.d.ts.map +1 -0
- package/src/core/math/factorial.js +15 -0
- package/src/core/math/factorial.spec.d.ts +2 -0
- package/src/core/math/factorial.spec.d.ts.map +1 -0
- package/src/core/math/factorial.spec.js +9 -0
- package/src/core/model/DebouncedObservedBoolean.d.ts +1 -1
- package/src/core/model/DebouncedObservedBoolean.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeDescription.d.ts +6 -4
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +8 -1
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +1 -1
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +3 -1
- package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts +8 -0
- package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts.map +1 -0
- package/src/engine/graphics/filter/{FlipArrayInPlace.js → sampler2d_flipY_in_place.js} +1 -1
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.d.ts.map +1 -1
- package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +5 -27
- package/src/engine/graphics/render/Lines.d.ts.map +1 -1
- package/src/engine/graphics/render/Lines.js +10 -2
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +24 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +293 -0
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +71 -0
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +256 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +4 -4
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +3 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +12 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +2 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -6
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +8 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +3 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +9 -4
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +18 -8
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +51 -22
- package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
- package/src/engine/graphics/texture/AttributeDataTexture.js +8 -2
- package/src/engine/graphics/texture/computeThreeTextureFormat.js +2 -1
- package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts +7 -0
- package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts.map +1 -0
- package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.js +13 -0
- package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
- package/src/engine/graphics/texture/formatToChannelCount.js +8 -1
- package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts +9 -0
- package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts.map +1 -0
- package/src/engine/graphics/texture/numericTypeFromBinaryDataType.js +31 -0
- package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +47 -19
- package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.js +5 -33
- package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts +11 -0
- package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.js +41 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +0 -4
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +19 -30
- package/src/engine/graphics/filter/FlipArrayInPlace.d.ts +0 -8
- package/src/engine/graphics/filter/FlipArrayInPlace.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +0 -3
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factorial.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/math/factorial.spec.js"],"names":[],"mappings":""}
|
|
@@ -17,7 +17,7 @@ export class DebouncedObservedBoolean extends ObservedBoolean {
|
|
|
17
17
|
constructor(source: ObservedBoolean, time: number, mode?: DebouncedObservedBooleanMode | number);
|
|
18
18
|
__source: ObservedBoolean;
|
|
19
19
|
time: number;
|
|
20
|
-
__timeout: NodeJS.
|
|
20
|
+
__timeout: NodeJS.Timer;
|
|
21
21
|
mode: number;
|
|
22
22
|
link(): void;
|
|
23
23
|
unlink(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebouncedObservedBoolean.d.ts","sourceRoot":"","sources":["../../../../src/core/model/DebouncedObservedBoolean.js"],"names":[],"mappings":"2CAYU,MAAM;;;;;;AAQhB;;GAEG;AACH;IACI;;;;;OAKG;IACH,oBAJW,eAAe,QACf,MAAM,SACN,4BAA4B,GAAC,MAAM,EAY7C;IAPG,0BAAsB;IAEtB,aAAgB;IAEhB,
|
|
1
|
+
{"version":3,"file":"DebouncedObservedBoolean.d.ts","sourceRoot":"","sources":["../../../../src/core/model/DebouncedObservedBoolean.js"],"names":[],"mappings":"2CAYU,MAAM;;;;;;AAQhB;;GAEG;AACH;IACI;;;;;OAKG;IACH,oBAJW,eAAe,QACf,MAAM,SACN,4BAA4B,GAAC,MAAM,EAY7C;IAPG,0BAAsB;IAEtB,aAAgB;IAEhB,wBAAqB;IAErB,aAAgB;IAGpB,aAGC;IAED,eAGC;IAGD;;;OAGG;IACH,uBAKC;IAED;;OAEG;IACH,0BAOC;IAED;;;OAGG;IACH,OAFW,OAAO,QAYjB;IANO,aAAgB;IAQxB;;;;;OAKG;IACH,6BAYC;IAED,gBAEC;CAEJ;4BAhH2B,sBAAsB"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {Port} from "./Port";
|
|
2
1
|
import {DataType} from "../DataType";
|
|
2
|
+
import {Port} from "./Port";
|
|
3
3
|
import {PortDirection} from "./PortDirection";
|
|
4
4
|
|
|
5
5
|
export class NodeDescription {
|
|
6
6
|
|
|
7
|
-
readonly inPorts:Port[]
|
|
8
|
-
readonly outPorts:Port[]
|
|
7
|
+
readonly inPorts: Port[]
|
|
8
|
+
readonly outPorts: Port[]
|
|
9
9
|
|
|
10
10
|
getPorts(): Port[]
|
|
11
11
|
|
|
12
|
-
createPort(type: DataType, name:string,direction:PortDirection): number
|
|
12
|
+
createPort(type: DataType, name: string, direction: PortDirection): number
|
|
13
|
+
|
|
14
|
+
toJSON(): any
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CA8DnB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
|
|
2
1
|
import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
|
|
2
|
+
import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
|
|
3
|
+
import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
|
|
3
4
|
|
|
4
5
|
//
|
|
5
6
|
|
|
@@ -120,6 +121,12 @@ export function textureImagesEqual(a, b) {
|
|
|
120
121
|
|
|
121
122
|
}
|
|
122
123
|
|
|
124
|
+
if (isTypedArray(a.data) && isTypedArray(b.data)) {
|
|
125
|
+
if (!textureMipmapEqual(a, b)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
// assume equivalent
|
|
124
131
|
return true;
|
|
125
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractRenderAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractRenderAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js"],"names":[],"mappings":"AA4BA;IAGQ;;;;OAIG;IACH,0BAHU,MAAM,CAGO;IAEvB;;;;OAIG;IACH,qBAHU,MAAM,QAAQ,EAAE,CAGP;IAGvB;;OAEG;IACH,yBAEC;IAED;;;;;;OAMG;IACH,gBALW,MAAM,cAAc,YACpB,MAAM,QAAQ,kBACd,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,iCAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yBAFa,IAAI,CAIhB;IAGD;;;;OAIG;IACH,sBAHW,MAAM,aAAa,0BAK7B;IAED,kBAEC;IAED,cAEC;IAED;;;;OAIG;IACH,YAFY,SAAS,CAIpB;IAED;;OAEG;IACH,iEAEC;IAED;;OAEG;IACH,2BAEC;IAED,gBAEC;IAGL;;;OAGG;IACH,wCAFU,OAAO,CAE4C;CAN5D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} input
|
|
3
|
+
* @param {number} width
|
|
4
|
+
* @param {number} height
|
|
5
|
+
* @param {number} channel_count
|
|
6
|
+
*/
|
|
7
|
+
export function sampler2d_flipY_in_place(input: Uint8Array, width: number, height: number, channel_count?: number): void;
|
|
8
|
+
//# sourceMappingURL=sampler2d_flipY_in_place.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler2d_flipY_in_place.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/filter/sampler2d_flipY_in_place.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,gDALW,UAAU,SACV,MAAM,UACN,MAAM,kBACN,MAAM,QAyBhB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {number} height
|
|
5
5
|
* @param {number} channel_count
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function sampler2d_flipY_in_place(input, width, height, channel_count = 4) {
|
|
8
8
|
const row_size = width * channel_count;
|
|
9
9
|
let t, x0, x1;
|
|
10
10
|
let i = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvh32_set_leaf_from_triangle.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bvh32_set_leaf_from_triangle.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,mFANW,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,QAQhB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { min3 } from "../../../../../core/math/min3.js";
|
|
1
|
+
import { aabb3_compute_from_triangle } from "../../../../../core/geom/3d/aabb3_compute_from_triangle.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
@@ -11,31 +10,10 @@ import { min3 } from "../../../../../core/math/min3.js";
|
|
|
11
10
|
* @param {number} c_index
|
|
12
11
|
*/
|
|
13
12
|
export function bvh32_set_leaf_from_triangle(bvh, triangle_index, vertices, a_index, b_index, c_index) {
|
|
14
|
-
const a = a_index * 3;
|
|
15
|
-
const b = b_index * 3;
|
|
16
|
-
const c = c_index * 3;
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const aZ = vertices[a + 2];
|
|
14
|
+
const address = bvh.getLeafAddress(triangle_index);
|
|
15
|
+
aabb3_compute_from_triangle(bvh.__data_float32, address, vertices, a_index, b_index, c_index);
|
|
16
|
+
bvh.__data_uint32[address + 6] = triangle_index;
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
const bY = vertices[b + 1];
|
|
25
|
-
const bZ = vertices[b + 2];
|
|
18
|
+
}
|
|
26
19
|
|
|
27
|
-
const cX = vertices[c];
|
|
28
|
-
const cY = vertices[c + 1];
|
|
29
|
-
const cZ = vertices[c + 2];
|
|
30
|
-
|
|
31
|
-
// compute bounds of the triangle
|
|
32
|
-
const x0 = min3(aX, bX, cX);
|
|
33
|
-
const y0 = min3(aY, bY, cY);
|
|
34
|
-
const z0 = min3(aZ, bZ, cZ);
|
|
35
|
-
|
|
36
|
-
const x1 = max3(aX, bX, cX);
|
|
37
|
-
const y1 = max3(aY, bY, cY);
|
|
38
|
-
const z1 = max3(aZ, bZ, cZ);
|
|
39
|
-
|
|
40
|
-
bvh.setLeafData(triangle_index, triangle_index, x0, y0, z0, x1, y1, z1)
|
|
41
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lines.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/render/Lines.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Lines.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/render/Lines.js"],"names":[],"mappings":"AA+BA;IAGQ,cAAc;IACd,iBAAkB;IAElB;;;OAGG;IACH,UAFU,cAAc,GAAC,IAAI,CAEe;IAE5C,sDAAoE;IASxE;;;OAGG;IACH,YAFW,MAAM,QAOhB;IAED;;;OAGG;IACH,mBAFW,MAAM,QAWhB;IAED;;;;;OAKG;IACH,kDA2BC;IAED,cAUC;IAED,gBAGC;CACJ;+BA/H8B,kCAAkC;kCAFC,OAAO;6BAAP,OAAO"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { DynamicDrawUsage, LineBasicMaterial, LineSegments } from "three";
|
|
2
|
-
import { array_copy } from "../../../core/collection/array/array_copy.js";
|
|
3
|
-
import { BufferGeometry } from "three/src/core/BufferGeometry.js";
|
|
4
2
|
import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
|
|
3
|
+
import { BufferGeometry } from "three/src/core/BufferGeometry.js";
|
|
4
|
+
import { assert } from "../../../core/assert.js";
|
|
5
|
+
import { array_copy } from "../../../core/collection/array/array_copy.js";
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {number} capacity
|
|
10
|
+
* @return {BufferGeometry}
|
|
11
|
+
*/
|
|
6
12
|
function buildGeometry(capacity) {
|
|
13
|
+
assert.isNonNegativeInteger(capacity, 'capacity');
|
|
14
|
+
|
|
7
15
|
const geometry = new BufferGeometry();
|
|
8
16
|
|
|
9
17
|
geometry.dynamic = true;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {LightProbeVolume} volume
|
|
5
|
+
*/
|
|
6
|
+
constructor({ volume }: LightProbeVolume);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {number} v
|
|
10
|
+
*/
|
|
11
|
+
set intensity(arg: number);
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @return {number}
|
|
15
|
+
*/
|
|
16
|
+
get intensity(): number;
|
|
17
|
+
update_bounds(): void;
|
|
18
|
+
update_lookup(): void;
|
|
19
|
+
update(): void;
|
|
20
|
+
transform(source: any): any;
|
|
21
|
+
#private;
|
|
22
|
+
}
|
|
23
|
+
import { AbstractMaterialTransformer } from "../../../material/manager/AbstractMaterialTransformer.js";
|
|
24
|
+
//# sourceMappingURL=MaterialTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AA0CA;IAsHI;;;OAGG;IACH,0CAMC;IAlBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAsBD,sBAIC;IAED,sBA2CC;IAED,eAuCC;IAED,4BA2BC;;CACJ;4CA9R2C,0DAA0D"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { DataTexture3D, NearestFilter, RedIntegerFormat, UnsignedIntType, Vector3 } from "three";
|
|
2
|
+
import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
|
|
3
|
+
import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
|
|
4
|
+
import { aabb3_from_v3_array } from "../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
|
|
5
|
+
import { AttributeSpec } from "../../../geometry/AttributeSpec.js";
|
|
6
|
+
import { composeCompile } from "../../../material/composeCompile.js";
|
|
7
|
+
import { AbstractMaterialTransformer } from "../../../material/manager/AbstractMaterialTransformer.js";
|
|
8
|
+
import { isLitMaterial } from "../../../render/forward_plus/plugin/isLitMaterial.js";
|
|
9
|
+
import { AttributeDataTexture } from "../../../texture/AttributeDataTexture.js";
|
|
10
|
+
import { vector_buffer_to_attribute_texture } from "../../lpv/probe_volume_to_textures.js";
|
|
11
|
+
import { tetrahedral_mesh_to_texture } from "../tetrahedral_mesh_to_texture.js";
|
|
12
|
+
import { build_fragment_shader } from "./build_fragment_shader.js";
|
|
13
|
+
import { build_vertex_shader } from "./build_vertex_shader.js";
|
|
14
|
+
|
|
15
|
+
const PROPERTY_TRANSFORMER_MARKER = '@light-probe-volume-material-transformer';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function createLookupTexture(resolution) {
|
|
19
|
+
|
|
20
|
+
const lookup = new DataTexture3D(
|
|
21
|
+
new Uint32Array(resolution * resolution * resolution),
|
|
22
|
+
resolution,
|
|
23
|
+
resolution,
|
|
24
|
+
resolution
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
lookup.name = "Tetrahedron Lookup";
|
|
28
|
+
|
|
29
|
+
lookup.flipY = false;
|
|
30
|
+
lookup.generateMipmaps = false;
|
|
31
|
+
lookup.magFilter = NearestFilter;
|
|
32
|
+
lookup.minFilter = NearestFilter;
|
|
33
|
+
|
|
34
|
+
lookup.type = UnsignedIntType;
|
|
35
|
+
lookup.format = RedIntegerFormat;
|
|
36
|
+
lookup.internalFormat = "R32UI";
|
|
37
|
+
|
|
38
|
+
lookup.needsUpdate = true;
|
|
39
|
+
|
|
40
|
+
return lookup;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {LightProbeVolume|null}
|
|
48
|
+
*/
|
|
49
|
+
#volume = null;
|
|
50
|
+
|
|
51
|
+
#mesh_lookup = createLookupTexture(32);
|
|
52
|
+
#mesh_bounds = new AABB3();
|
|
53
|
+
|
|
54
|
+
#textures = {
|
|
55
|
+
vertex: new AttributeDataTexture(
|
|
56
|
+
AttributeSpec.fromJSON({
|
|
57
|
+
name: "vertex",
|
|
58
|
+
type: BinaryDataType.Uint32,
|
|
59
|
+
itemSize: 4,
|
|
60
|
+
normalized: false
|
|
61
|
+
}),
|
|
62
|
+
256, 1
|
|
63
|
+
),
|
|
64
|
+
neighbour: new AttributeDataTexture(
|
|
65
|
+
AttributeSpec.fromJSON({
|
|
66
|
+
name: "neighbour",
|
|
67
|
+
type: BinaryDataType.Uint32,
|
|
68
|
+
itemSize: 4,
|
|
69
|
+
normalized: false
|
|
70
|
+
}),
|
|
71
|
+
256, 1
|
|
72
|
+
),
|
|
73
|
+
positions: new AttributeDataTexture(
|
|
74
|
+
AttributeSpec.fromJSON({
|
|
75
|
+
name: "positions",
|
|
76
|
+
type: BinaryDataType.Float32,
|
|
77
|
+
itemSize: 3,
|
|
78
|
+
normalized: false
|
|
79
|
+
}),
|
|
80
|
+
256, 1
|
|
81
|
+
),
|
|
82
|
+
harmonics: new AttributeDataTexture(
|
|
83
|
+
AttributeSpec.fromJSON({
|
|
84
|
+
name: "harmonics",
|
|
85
|
+
type: BinaryDataType.Float32,
|
|
86
|
+
itemSize: 3,
|
|
87
|
+
normalized: false
|
|
88
|
+
}),
|
|
89
|
+
256, 9
|
|
90
|
+
)
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
#uniforms = {
|
|
94
|
+
lpv_t_mesh_vertices: {
|
|
95
|
+
type: "t",
|
|
96
|
+
value: this.#textures.vertex.texture
|
|
97
|
+
},
|
|
98
|
+
lpv_t_mesh_neighbours: {
|
|
99
|
+
type: "t",
|
|
100
|
+
value: this.#textures.neighbour.texture
|
|
101
|
+
},
|
|
102
|
+
lpv_t_probe_positions: {
|
|
103
|
+
type: "t",
|
|
104
|
+
value: this.#textures.positions.texture
|
|
105
|
+
},
|
|
106
|
+
lpv_t_probe_data: {
|
|
107
|
+
type: "t",
|
|
108
|
+
value: this.#textures.harmonics.texture
|
|
109
|
+
},
|
|
110
|
+
lpv_t_mesh_lookup: {
|
|
111
|
+
type: "t",
|
|
112
|
+
value: this.#mesh_lookup
|
|
113
|
+
},
|
|
114
|
+
lpv_v3_bounds_min: {
|
|
115
|
+
value: new Vector3(),
|
|
116
|
+
},
|
|
117
|
+
lpv_v3_bounds_max: {
|
|
118
|
+
value: new Vector3(),
|
|
119
|
+
},
|
|
120
|
+
lpv_u_mesh_tet_count: {
|
|
121
|
+
value: 0
|
|
122
|
+
},
|
|
123
|
+
lpv_f_intensity: {
|
|
124
|
+
value: 1
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
#uniform_version = -1;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @param {{uniforms, glslVersion, defines, vertexShader, fragmentShader}} shader
|
|
133
|
+
*/
|
|
134
|
+
#onBeforeCompile = (shader) => {
|
|
135
|
+
Object.assign(shader.uniforms, this.#uniforms);
|
|
136
|
+
|
|
137
|
+
console.log(this.#uniforms)
|
|
138
|
+
|
|
139
|
+
shader.vertexShader = build_vertex_shader(shader.vertexShader);
|
|
140
|
+
shader.fragmentShader = build_fragment_shader(shader.fragmentShader);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
#materials = [];
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
* @return {number}
|
|
148
|
+
*/
|
|
149
|
+
get intensity() {
|
|
150
|
+
return this.#uniforms.lpv_f_intensity.value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @param {number} v
|
|
156
|
+
*/
|
|
157
|
+
set intensity(v) {
|
|
158
|
+
this.#uniforms.lpv_f_intensity.value = v;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* @param {LightProbeVolume} volume
|
|
164
|
+
*/
|
|
165
|
+
constructor({
|
|
166
|
+
volume
|
|
167
|
+
}) {
|
|
168
|
+
super();
|
|
169
|
+
|
|
170
|
+
this.#volume = volume;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
update_bounds() {
|
|
174
|
+
|
|
175
|
+
aabb3_from_v3_array(this.#mesh_bounds, this.#volume.points, this.#volume.count * 3);
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
update_lookup() {
|
|
180
|
+
this.update_bounds();
|
|
181
|
+
|
|
182
|
+
const bounds = this.#mesh_bounds;
|
|
183
|
+
|
|
184
|
+
const lookup = this.#mesh_lookup;
|
|
185
|
+
|
|
186
|
+
const image = lookup.image;
|
|
187
|
+
|
|
188
|
+
const res_z = image.depth;
|
|
189
|
+
const res_y = image.height;
|
|
190
|
+
const res_x = image.width;
|
|
191
|
+
|
|
192
|
+
const volume = this.#volume;
|
|
193
|
+
|
|
194
|
+
let last_tet = 0;
|
|
195
|
+
|
|
196
|
+
for (let z = 0; z < res_z; z++) {
|
|
197
|
+
for (let y = 0; y < res_y; y++) {
|
|
198
|
+
for (let x = 0; x < res_x; x++) {
|
|
199
|
+
|
|
200
|
+
// convert pixel position to world coordinate
|
|
201
|
+
const n_x = (x + 0.5) / res_x
|
|
202
|
+
const n_y = (y + 0.5) / res_y
|
|
203
|
+
const n_z = (z + 0.5) / res_z
|
|
204
|
+
|
|
205
|
+
const w_x = n_x * bounds.getExtentsX() + bounds.x0;
|
|
206
|
+
const w_y = n_y * bounds.getExtentsY() + bounds.y0;
|
|
207
|
+
const w_z = n_z * bounds.getExtentsZ() + bounds.z0;
|
|
208
|
+
|
|
209
|
+
const tet = volume.mesh.findTetraContainingPoint(w_x, w_y, w_z, volume.points, last_tet);
|
|
210
|
+
|
|
211
|
+
if (tet !== -1) {
|
|
212
|
+
last_tet = tet;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
image.data[z * res_y * res_x + y * res_x + x] = last_tet;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
lookup.needsUpdate = true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
update() {
|
|
225
|
+
const lpv = this.#volume;
|
|
226
|
+
|
|
227
|
+
if (lpv === null) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (this.#uniform_version === lpv.version) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this.update_lookup();
|
|
236
|
+
|
|
237
|
+
this.#uniforms.lpv_u_mesh_tet_count.value = lpv.mesh.count;
|
|
238
|
+
|
|
239
|
+
this.#uniforms.lpv_v3_bounds_min.value.set(
|
|
240
|
+
this.#mesh_bounds.x0, this.#mesh_bounds.y0, this.#mesh_bounds.z0
|
|
241
|
+
);
|
|
242
|
+
this.#uniforms.lpv_v3_bounds_max.value.set(
|
|
243
|
+
this.#mesh_bounds.x1, this.#mesh_bounds.y1, this.#mesh_bounds.z1
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
this.#uniform_version = lpv.version;
|
|
247
|
+
|
|
248
|
+
console.time('prepareTextures');
|
|
249
|
+
|
|
250
|
+
vector_buffer_to_attribute_texture(this.#textures.positions, lpv.points, lpv.count, 3);
|
|
251
|
+
vector_buffer_to_attribute_texture(this.#textures.harmonics, lpv.harmonics, lpv.count * 9, 3);
|
|
252
|
+
tetrahedral_mesh_to_texture(
|
|
253
|
+
this.#textures.vertex, this.#textures.neighbour, lpv.mesh
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
console.timeEnd('prepareTextures');
|
|
257
|
+
|
|
258
|
+
for (let i = 0; i < this.#materials.length; i++) {
|
|
259
|
+
const material = this.#materials[i];
|
|
260
|
+
|
|
261
|
+
// material.uniformsNeedUpdate = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
transform(source) {
|
|
266
|
+
if (source.hasOwnProperty(PROPERTY_TRANSFORMER_MARKER)) {
|
|
267
|
+
// already transformed
|
|
268
|
+
|
|
269
|
+
if (source[PROPERTY_TRANSFORMER_MARKER] !== this) {
|
|
270
|
+
throw new Error('The material is already transformed, but is associated with a different transformer instance');
|
|
271
|
+
} else {
|
|
272
|
+
return source;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
let result = source;
|
|
279
|
+
|
|
280
|
+
if (isLitMaterial(source)) {
|
|
281
|
+
|
|
282
|
+
result.clone();
|
|
283
|
+
|
|
284
|
+
result.onBeforeCompile = composeCompile(source.onBeforeCompile, this.#onBeforeCompile);
|
|
285
|
+
|
|
286
|
+
result[PROPERTY_TRANSFORMER_MARKER] = this;
|
|
287
|
+
|
|
288
|
+
this.#materials.push(result);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_fragment_shader.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/build_fragment_shader.js"],"names":[],"mappings":"AAsDA;;;GAGG;AACH,8CAFW,MAAM,UAchB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { insert_after } from "../../../../../core/primitives/strings/insert_after.js";
|
|
2
|
+
|
|
3
|
+
const PREAMBLE = `
|
|
4
|
+
|
|
5
|
+
uniform float lpv_f_intensity;
|
|
6
|
+
|
|
7
|
+
varying vec3[9] lpv_values;
|
|
8
|
+
|
|
9
|
+
// vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
10
|
+
// // normal is assumed to have unit length
|
|
11
|
+
// float x = normal.x, y = normal.y, z = normal.z;
|
|
12
|
+
//
|
|
13
|
+
// // band 0
|
|
14
|
+
// vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
15
|
+
//
|
|
16
|
+
// // band 1
|
|
17
|
+
// result -= shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
18
|
+
// result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
19
|
+
// result -= shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
20
|
+
//
|
|
21
|
+
// // band 2
|
|
22
|
+
// result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
23
|
+
// result -= shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
24
|
+
// result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
25
|
+
// result -= shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
26
|
+
// result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
27
|
+
//
|
|
28
|
+
// return result;
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
|
|
32
|
+
//
|
|
33
|
+
// // matrix is assumed to be orthogonal
|
|
34
|
+
//
|
|
35
|
+
// return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
|
|
36
|
+
//
|
|
37
|
+
// }
|
|
38
|
+
//
|
|
39
|
+
// vec3 lpv_getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
40
|
+
//
|
|
41
|
+
// vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
42
|
+
//
|
|
43
|
+
// vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
44
|
+
//
|
|
45
|
+
// return irradiance;
|
|
46
|
+
//
|
|
47
|
+
// }
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const ACCUMULATION = `
|
|
51
|
+
irradiance += getLightProbeIrradiance(lpv_values, geometryNormal )* lpv_f_intensity;
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {string} source
|
|
58
|
+
*/
|
|
59
|
+
export function build_fragment_shader(source) {
|
|
60
|
+
|
|
61
|
+
let result = PREAMBLE + source;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
result = insert_after(
|
|
65
|
+
result,
|
|
66
|
+
'#include <lights_fragment_begin>',
|
|
67
|
+
ACCUMULATION
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_vertex_shader.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/build_vertex_shader.js"],"names":[],"mappings":"AA+OA;;;GAGG;AACH,4CAFW,MAAM,UAchB"}
|