@woosh/meep-engine 2.163.1 → 2.163.3
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/core/geom/3d/equirectangular/equirectangular_direction_to_uv.d.ts +12 -0
- package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.d.ts.map +1 -0
- package/src/core/geom/3d/equirectangular/equirectangular_direction_to_uv.js +18 -0
- package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.d.ts +14 -0
- package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.d.ts.map +1 -0
- package/src/core/geom/3d/equirectangular/equirectangular_uv_to_direction.js +24 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_island_erode.js +368 -290
- package/src/core/geom/vec3/v3_uniform_sample_cone.d.ts +11 -0
- package/src/core/geom/vec3/v3_uniform_sample_cone.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_uniform_sample_cone.js +21 -0
- package/src/core/math/physics/brdf/cone_cosine_from_roughness.d.ts +13 -0
- package/src/core/math/physics/brdf/cone_cosine_from_roughness.d.ts.map +1 -0
- package/src/core/math/physics/brdf/cone_cosine_from_roughness.js +28 -0
- package/src/core/math/physics/brdf/reflection_sample_weight.d.ts +18 -0
- package/src/core/math/physics/brdf/reflection_sample_weight.d.ts.map +1 -0
- package/src/core/math/physics/brdf/reflection_sample_weight.js +48 -0
- package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
- package/src/engine/graphics/GraphicsEngine.js +52 -0
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +306 -226
- package/src/engine/graphics/ecs/path/tube/build/make_cap.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +26 -17
- package/src/engine/graphics/sh3/sky/hosek/make_environment_sky_hosek.d.ts +26 -0
- package/src/engine/graphics/sh3/sky/hosek/make_environment_sky_hosek.d.ts.map +1 -0
- package/src/engine/graphics/sh3/sky/hosek/make_environment_sky_hosek.js +49 -0
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts +26 -0
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts.map +1 -0
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.js +70 -0
- package/src/engine/graphics/sh3/sky/hosek/setup_environment_sky_from_ecd.d.ts +24 -0
- package/src/engine/graphics/sh3/sky/hosek/setup_environment_sky_from_ecd.d.ts.map +1 -0
- package/src/engine/graphics/sh3/sky/hosek/setup_environment_sky_from_ecd.js +51 -0
- package/src/engine/graphics/texture/EnvironmentTextureProjection.d.ts +9 -0
- package/src/engine/graphics/texture/EnvironmentTextureProjection.d.ts.map +1 -0
- package/src/engine/graphics/texture/EnvironmentTextureProjection.js +15 -0
- package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.d.ts +44 -0
- package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.d.ts.map +1 -0
- package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.js +189 -0
- package/src/engine/graphics/texture/reflection/equirectangular_reflection_roughness.d.ts +25 -0
- package/src/engine/graphics/texture/reflection/equirectangular_reflection_roughness.d.ts.map +1 -0
- package/src/engine/graphics/texture/reflection/equirectangular_reflection_roughness.js +51 -0
- package/src/engine/graphics/texture/sampler/sampler2d_sample_equirectangular_direction.d.ts +15 -0
- package/src/engine/graphics/texture/sampler/sampler2d_sample_equirectangular_direction.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/sampler2d_sample_equirectangular_direction.js +63 -0
- package/src/engine/navigation/mesh/build/bt_mesh_carve_height_clearance.d.ts +27 -0
- package/src/engine/navigation/mesh/build/bt_mesh_carve_height_clearance.d.ts.map +1 -0
- package/src/engine/navigation/mesh/build/bt_mesh_carve_height_clearance.js +323 -0
- package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts.map +1 -1
- package/src/engine/navigation/mesh/build/navmesh_build_topology.js +223 -226
- package/src/engine/.fuse_hidden0000001500000001 +0 -581
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uniformly sample a direction within a cone around +Z (solid-angle uniform).
|
|
3
|
+
*
|
|
4
|
+
* @param {number[]|Float32Array} out
|
|
5
|
+
* @param {number} out_offset
|
|
6
|
+
* @param {number} u random value in [0, 1] (controls polar angle)
|
|
7
|
+
* @param {number} v random value in [0, 1] (controls azimuth)
|
|
8
|
+
* @param {number} cos_theta_max cosine of the cone half-angle; 1 = a single direction, -1 = full sphere
|
|
9
|
+
*/
|
|
10
|
+
export function v3_uniform_sample_cone(out: number[] | Float32Array, out_offset: number, u: number, v: number, cos_theta_max: number): void;
|
|
11
|
+
//# sourceMappingURL=v3_uniform_sample_cone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3_uniform_sample_cone.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_uniform_sample_cone.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,4CANW,MAAM,EAAE,GAAC,YAAY,cACrB,MAAM,KACN,MAAM,KACN,MAAM,iBACN,MAAM,QAWhB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const TWO_PI = Math.PI * 2;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uniformly sample a direction within a cone around +Z (solid-angle uniform).
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]|Float32Array} out
|
|
7
|
+
* @param {number} out_offset
|
|
8
|
+
* @param {number} u random value in [0, 1] (controls polar angle)
|
|
9
|
+
* @param {number} v random value in [0, 1] (controls azimuth)
|
|
10
|
+
* @param {number} cos_theta_max cosine of the cone half-angle; 1 = a single direction, -1 = full sphere
|
|
11
|
+
*/
|
|
12
|
+
export function v3_uniform_sample_cone(out, out_offset, u, v, cos_theta_max) {
|
|
13
|
+
const cos_theta = (1.0 - u) + u * cos_theta_max;
|
|
14
|
+
const sin_theta = Math.sqrt(Math.max(0.0, 1.0 - cos_theta * cos_theta));
|
|
15
|
+
|
|
16
|
+
const phi = v * TWO_PI;
|
|
17
|
+
|
|
18
|
+
out[out_offset] = Math.cos(phi) * sin_theta;
|
|
19
|
+
out[out_offset + 1] = Math.sin(phi) * sin_theta;
|
|
20
|
+
out[out_offset + 2] = cos_theta;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cosine of the importance-sampling cone aperture (cos of twice the half-angle)
|
|
3
|
+
* for a given perceptual roughness, derived by inverting the spherical-gaussian
|
|
4
|
+
* specular lobe. Roughness 1 maps to roughly a half-pi half-angle.
|
|
5
|
+
*
|
|
6
|
+
* Pairs with {@link reflection_sample_weight}; used to bound the set of sampled
|
|
7
|
+
* directions when convolving an environment map.
|
|
8
|
+
*
|
|
9
|
+
* @param {number} linear_roughness perceptual roughness in [0, 1]
|
|
10
|
+
* @returns {number} cone cosine in [-1, 1]
|
|
11
|
+
*/
|
|
12
|
+
export function cone_cosine_from_roughness(linear_roughness: number): number;
|
|
13
|
+
//# sourceMappingURL=cone_cosine_from_roughness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cone_cosine_from_roughness.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/physics/brdf/cone_cosine_from_roughness.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,6DAHW,MAAM,GACJ,MAAM,CAgBlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { lerp } from "../../lerp.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cosine of the importance-sampling cone aperture (cos of twice the half-angle)
|
|
5
|
+
* for a given perceptual roughness, derived by inverting the spherical-gaussian
|
|
6
|
+
* specular lobe. Roughness 1 maps to roughly a half-pi half-angle.
|
|
7
|
+
*
|
|
8
|
+
* Pairs with {@link reflection_sample_weight}; used to bound the set of sampled
|
|
9
|
+
* directions when convolving an environment map.
|
|
10
|
+
*
|
|
11
|
+
* @param {number} linear_roughness perceptual roughness in [0, 1]
|
|
12
|
+
* @returns {number} cone cosine in [-1, 1]
|
|
13
|
+
*/
|
|
14
|
+
export function cone_cosine_from_roughness(linear_roughness) {
|
|
15
|
+
// From linear roughness to GGX roughness input.
|
|
16
|
+
const m = linear_roughness * linear_roughness;
|
|
17
|
+
|
|
18
|
+
// Chosen so that roughness of 1.0 maps to a half-pi cone aperture.
|
|
19
|
+
const cutoff_value = lerp(0.01, 0.14, m);
|
|
20
|
+
|
|
21
|
+
// Inversion of the spherical gaussian: cutoff for the half angle from N.H.
|
|
22
|
+
const half_angle_cos = Math.log(cutoff_value) * (m * m) * 0.5 + 1.0;
|
|
23
|
+
const half_angle_cos_sqr = half_angle_cos * half_angle_cos;
|
|
24
|
+
const half_angle_sin_sqr = Math.max(0.0, 1.0 - half_angle_cos_sqr);
|
|
25
|
+
|
|
26
|
+
// cos(2 * half_angle) via the cosine double-angle identity.
|
|
27
|
+
return half_angle_cos_sqr - half_angle_sin_sqr;
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spherical-gaussian approximation of the GGX specular weight for a sample,
|
|
3
|
+
* used when convolving an environment map for prefiltered reflections.
|
|
4
|
+
*
|
|
5
|
+
* From "SG Series Part 4: Specular Lighting From an SG Light Source" by MJP.
|
|
6
|
+
* Both directions are assumed unit length.
|
|
7
|
+
*
|
|
8
|
+
* @param {number} out_x reflection (output) direction
|
|
9
|
+
* @param {number} out_y
|
|
10
|
+
* @param {number} out_z
|
|
11
|
+
* @param {number} in_x sampled (input) direction
|
|
12
|
+
* @param {number} in_y
|
|
13
|
+
* @param {number} in_z
|
|
14
|
+
* @param {number} linear_roughness perceptual roughness in [0, 1]
|
|
15
|
+
* @returns {number} non-negative weight
|
|
16
|
+
*/
|
|
17
|
+
export function reflection_sample_weight(out_x: number, out_y: number, out_z: number, in_x: number, in_y: number, in_z: number, linear_roughness: number): number;
|
|
18
|
+
//# sourceMappingURL=reflection_sample_weight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection_sample_weight.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/physics/brdf/reflection_sample_weight.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,gDATW,MAAM,SACN,MAAM,SACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,oBACN,MAAM,GACJ,MAAM,CA+BlB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { clamp01 } from "../../clamp01.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Spherical-gaussian approximation of the GGX specular weight for a sample,
|
|
5
|
+
* used when convolving an environment map for prefiltered reflections.
|
|
6
|
+
*
|
|
7
|
+
* From "SG Series Part 4: Specular Lighting From an SG Light Source" by MJP.
|
|
8
|
+
* Both directions are assumed unit length.
|
|
9
|
+
*
|
|
10
|
+
* @param {number} out_x reflection (output) direction
|
|
11
|
+
* @param {number} out_y
|
|
12
|
+
* @param {number} out_z
|
|
13
|
+
* @param {number} in_x sampled (input) direction
|
|
14
|
+
* @param {number} in_y
|
|
15
|
+
* @param {number} in_z
|
|
16
|
+
* @param {number} linear_roughness perceptual roughness in [0, 1]
|
|
17
|
+
* @returns {number} non-negative weight
|
|
18
|
+
*/
|
|
19
|
+
export function reflection_sample_weight(
|
|
20
|
+
out_x, out_y, out_z,
|
|
21
|
+
in_x, in_y, in_z,
|
|
22
|
+
linear_roughness
|
|
23
|
+
) {
|
|
24
|
+
// From linear roughness to GGX roughness input.
|
|
25
|
+
const m = linear_roughness * linear_roughness;
|
|
26
|
+
|
|
27
|
+
// Half vector H = normalize(out + in)
|
|
28
|
+
let h_x = out_x + in_x;
|
|
29
|
+
let h_y = out_y + in_y;
|
|
30
|
+
let h_z = out_z + in_z;
|
|
31
|
+
|
|
32
|
+
const h_length = Math.sqrt(h_x * h_x + h_y * h_y + h_z * h_z);
|
|
33
|
+
|
|
34
|
+
if (h_length === 0) {
|
|
35
|
+
// out and in are antiparallel; no contribution
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const inv = 1.0 / h_length;
|
|
40
|
+
|
|
41
|
+
// NH = saturate(dot(N = out, H))
|
|
42
|
+
const NH = clamp01((out_x * h_x + out_y * h_y + out_z * h_z) * inv);
|
|
43
|
+
|
|
44
|
+
const m2 = m * m;
|
|
45
|
+
|
|
46
|
+
// Spherical Gaussian: exp(2 * (NH - 1) / m^2)
|
|
47
|
+
return Math.exp(2.0 * (NH - 1.0) / m2);
|
|
48
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicsEngine.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/GraphicsEngine.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GraphicsEngine.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/GraphicsEngine.js"],"names":[],"mappings":"AAgEA;IAOI;;;;;OAKG;IACH,+BAJW,MAAM,EAgLhB;IAtLD,gCAEC;IAgBG;;;;OAIG;IACH,2BAA+C;IAK/C;;;;;QAOI;;WAEG;;QAEH;;WAEG;;;;;MAMN;IAED;;OAEG;IACH,YAFU,OAAO,CAEe;IAEhC;;;;;;OAMG;IACH,4BAFU,OAAO,CAEyB;IAE1C;;;OAGG;IACH,QAFU,kBAAkB,CAEU;IAWtC;;;OAGG;IACH,aAAkB;IAGlB;;;OAGG;IACH,cAFU,KAAK,CAEgB;IAK/B;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,UAFU,aAAa,CAEH;IAGpB,+BAA0C;IAU1C;;OAEG;IACH,eAA+B;IAI/B;;;OAGG;I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
2
4
|
Group,
|
|
3
5
|
LinearEncoding,
|
|
4
6
|
NoToneMapping,
|
|
7
|
+
PMREMGenerator,
|
|
5
8
|
Raycaster as ThreeRaycaster,
|
|
6
9
|
Scene as ThreeScene,
|
|
7
10
|
Vector3 as ThreeVector3,
|
|
@@ -32,6 +35,7 @@ import { CameraViewManager } from "./render/view/CameraViewManager.js";
|
|
|
32
35
|
import { ShadowMapRenderer } from "./shadows/ShadowMapRenderer.js";
|
|
33
36
|
import { StandardFrameBuffers } from "./StandardFrameBuffers.js";
|
|
34
37
|
import { three_setSceneAutoUpdate } from "./three/three_setSceneAutoUpdate.js";
|
|
38
|
+
import { EnvironmentTextureProjection } from "./texture/EnvironmentTextureProjection.js";
|
|
35
39
|
|
|
36
40
|
/**
|
|
37
41
|
*
|
|
@@ -261,6 +265,54 @@ export class GraphicsEngine {
|
|
|
261
265
|
return this.renderer;
|
|
262
266
|
}
|
|
263
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Set the scene's environment map. The supplied texture is treated as BOTH:
|
|
270
|
+
* - the skybox background (shown directly), and
|
|
271
|
+
* - the image-based-lighting (IBL) source for physically based materials.
|
|
272
|
+
*
|
|
273
|
+
* The texture is run through three.js' PMREMGenerator to produce the
|
|
274
|
+
* prefiltered radiance assigned to `scene.environment`, while the original
|
|
275
|
+
* texture is assigned to `scene.background`.
|
|
276
|
+
*
|
|
277
|
+
* Must be called after the renderer has started up.
|
|
278
|
+
*
|
|
279
|
+
* @param {THREE.Texture} texture environment texture (equirectangular or cube)
|
|
280
|
+
* @param {EnvironmentTextureProjection} [projection=EnvironmentTextureProjection.Equirectangular] how the texture is projected
|
|
281
|
+
*/
|
|
282
|
+
set_environment_texture(texture, projection = EnvironmentTextureProjection.Equirectangular) {
|
|
283
|
+
assert.defined(texture, 'texture');
|
|
284
|
+
|
|
285
|
+
const renderer = this.renderer;
|
|
286
|
+
|
|
287
|
+
if (renderer === null || renderer === undefined) {
|
|
288
|
+
throw new Error('GraphicsEngine.set_environment_texture: renderer is not initialized, call after startup');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const pmrem = new PMREMGenerator(renderer);
|
|
292
|
+
|
|
293
|
+
let target;
|
|
294
|
+
|
|
295
|
+
if (projection === EnvironmentTextureProjection.Equirectangular) {
|
|
296
|
+
texture.mapping = EquirectangularReflectionMapping;
|
|
297
|
+
target = pmrem.fromEquirectangular(texture);
|
|
298
|
+
} else if (projection === EnvironmentTextureProjection.Cube) {
|
|
299
|
+
texture.mapping = CubeReflectionMapping;
|
|
300
|
+
target = pmrem.fromCubemap(texture);
|
|
301
|
+
} else {
|
|
302
|
+
pmrem.dispose();
|
|
303
|
+
throw new Error(`GraphicsEngine.set_environment_texture: unsupported projection '${projection}'`);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
pmrem.dispose();
|
|
307
|
+
|
|
308
|
+
const scene = this.scene;
|
|
309
|
+
|
|
310
|
+
// prefiltered radiance used by PBR materials as the IBL source
|
|
311
|
+
scene.environment = target.texture;
|
|
312
|
+
// original texture shown as the skybox
|
|
313
|
+
scene.background = texture;
|
|
314
|
+
}
|
|
315
|
+
|
|
264
316
|
updateSize() {
|
|
265
317
|
const size = this.viewport.size;
|
|
266
318
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"AAsJA;;;;;;;;;;GAUG;AACH,mFAPW,MAAM,EAAE,gBACR,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,EAAE,iBACR,MAAM,eACN,MAAM,GACL,MAAM,cAAc,CAkJ/B"}
|