@d5techs/3dgs-lib 1.4.55 → 1.4.56
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/dist/3dgs-lib.cjs +23 -21
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +23 -21
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/SkyboxRenderer.d.ts +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -2242,33 +2242,35 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2242
2242
|
// --- sky UV (always computed) ---
|
|
2243
2243
|
let skyUv = dirToUv(d);
|
|
2244
2244
|
|
|
2245
|
-
// --- ground projection
|
|
2246
|
-
//
|
|
2247
|
-
let
|
|
2248
|
-
let t = -camY /
|
|
2245
|
+
// --- ground projection (always computed for uniform control flow) ---
|
|
2246
|
+
// Ray from camera (0, camY, 0) in direction d hits plane y=0 at t
|
|
2247
|
+
let dyClamped = min(d.y, -0.0001);
|
|
2248
|
+
let t = -camY / dyClamped;
|
|
2249
2249
|
let hitX = t * d.x;
|
|
2250
2250
|
let hitZ = t * d.z;
|
|
2251
|
-
let
|
|
2252
|
-
|
|
2253
|
-
//
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
let
|
|
2257
|
-
let
|
|
2258
|
-
|
|
2259
|
-
let
|
|
2260
|
-
let groundDir = normalize(vec3(pX,
|
|
2251
|
+
let hitDist = sqrt(hitX * hitX + hitZ * hitZ);
|
|
2252
|
+
|
|
2253
|
+
// Project the ground hit point back onto a sphere of radius R
|
|
2254
|
+
// centered at the camera projection on y=0 (i.e. center = origin).
|
|
2255
|
+
// For points beyond R, fade to horizon sampling.
|
|
2256
|
+
let ratio = min(hitDist, sphereR) / max(hitDist, 0.001);
|
|
2257
|
+
let pX = hitX * ratio;
|
|
2258
|
+
let pZ = hitZ * ratio;
|
|
2259
|
+
let pY = -sqrt(max(sphereR * sphereR - pX * pX - pZ * pZ, 0.0));
|
|
2260
|
+
let groundDir = normalize(vec3(pX, pY, pZ));
|
|
2261
2261
|
let groundUv = dirToUv(groundDir);
|
|
2262
2262
|
|
|
2263
2263
|
// --- sample both (unconditional = uniform control flow) ---
|
|
2264
2264
|
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2265
2265
|
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2266
2266
|
|
|
2267
|
-
//
|
|
2268
|
-
|
|
2269
|
-
let
|
|
2270
|
-
|
|
2271
|
-
let
|
|
2267
|
+
// Blend: smooth transition near horizon
|
|
2268
|
+
// step(0.01, camY) disables ground projection when camera is at/below ground
|
|
2269
|
+
let groundFactor = smoothstep(0.01, -0.15, d.y) * step(0.01, camY);
|
|
2270
|
+
// Fade out ground color at the sphere edge to avoid hard seam
|
|
2271
|
+
let edgeFade = 1.0 - smoothstep(sphereR * 0.7, sphereR * 0.99, hitDist);
|
|
2272
|
+
let finalBlend = groundFactor * edgeFade;
|
|
2273
|
+
let c = mix(skyColor, groundColor, finalBlend);
|
|
2272
2274
|
|
|
2273
2275
|
// Reinhard tone mapping + gamma
|
|
2274
2276
|
let mapped = c / (c + vec3(1.));
|
|
@@ -2290,8 +2292,8 @@ class SkyboxRenderer {
|
|
|
2290
2292
|
__publicField(this, "bindGroup", null);
|
|
2291
2293
|
__publicField(this, "frameReady", false);
|
|
2292
2294
|
__publicField(this, "mode", "none");
|
|
2293
|
-
/** Ground projection sphere radius (world units). Larger = ground extends further. */
|
|
2294
|
-
__publicField(this, "groundRadius",
|
|
2295
|
+
/** Ground projection sphere radius (world units). Larger = ground extends further, flatter. */
|
|
2296
|
+
__publicField(this, "groundRadius", 500);
|
|
2295
2297
|
this.device = device;
|
|
2296
2298
|
const depthStencil = {
|
|
2297
2299
|
format: depthFormat,
|