@d5techs/3dgs-lib 1.4.56 → 1.4.58
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 +31 -23
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +31 -23
- 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.cjs
CHANGED
|
@@ -2238,40 +2238,36 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2238
2238
|
|
|
2239
2239
|
@fragment fn fs(i: V) -> @location(0) vec4<f32> {
|
|
2240
2240
|
let d = normalize(i.dir);
|
|
2241
|
-
let
|
|
2242
|
-
let
|
|
2241
|
+
let camH = u.extra.x;
|
|
2242
|
+
let projR = u.extra.y;
|
|
2243
2243
|
|
|
2244
|
-
// --- sky UV (always computed) ---
|
|
2244
|
+
// --- sky UV (always computed for uniform control flow) ---
|
|
2245
2245
|
let skyUv = dirToUv(d);
|
|
2246
2246
|
|
|
2247
|
-
// --- ground projection
|
|
2248
|
-
// Ray from camera
|
|
2247
|
+
// --- flat ground projection ---
|
|
2248
|
+
// Ray from camera at height camH above ground, direction d,
|
|
2249
|
+
// hits ground plane at t = -camH / d.y
|
|
2249
2250
|
let dyClamped = min(d.y, -0.0001);
|
|
2250
|
-
let t = -
|
|
2251
|
+
let t = -camH / dyClamped;
|
|
2251
2252
|
let hitX = t * d.x;
|
|
2252
2253
|
let hitZ = t * d.z;
|
|
2253
2254
|
let hitDist = sqrt(hitX * hitX + hitZ * hitZ);
|
|
2254
2255
|
|
|
2255
|
-
//
|
|
2256
|
-
//
|
|
2257
|
-
|
|
2258
|
-
let
|
|
2259
|
-
let pX = hitX * ratio;
|
|
2260
|
-
let pZ = hitZ * ratio;
|
|
2261
|
-
let pY = -sqrt(max(sphereR * sphereR - pX * pX - pZ * pZ, 0.0));
|
|
2262
|
-
let groundDir = normalize(vec3(pX, pY, pZ));
|
|
2256
|
+
// Reconstruct a sampling direction as if looking from HDR capture
|
|
2257
|
+
// height (1.7m) straight down at the hit point → FLAT ground
|
|
2258
|
+
let captureH = 1.7;
|
|
2259
|
+
let groundDir = normalize(vec3(hitX, -captureH, hitZ));
|
|
2263
2260
|
let groundUv = dirToUv(groundDir);
|
|
2264
2261
|
|
|
2265
|
-
// --- sample both (
|
|
2262
|
+
// --- sample both unconditionally (uniform control flow) ---
|
|
2266
2263
|
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2267
2264
|
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2268
2265
|
|
|
2269
2266
|
// Blend: smooth transition near horizon
|
|
2270
|
-
|
|
2271
|
-
let
|
|
2272
|
-
|
|
2273
|
-
let
|
|
2274
|
-
let finalBlend = groundFactor * edgeFade;
|
|
2267
|
+
let horizonBlend = smoothstep(0.0, -0.12, d.y);
|
|
2268
|
+
let aboveGround = step(0.01, camH);
|
|
2269
|
+
let edgeFade = 1.0 - smoothstep(projR * 0.6, projR, hitDist);
|
|
2270
|
+
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2275
2271
|
let c = mix(skyColor, groundColor, finalBlend);
|
|
2276
2272
|
|
|
2277
2273
|
// Reinhard tone mapping + gamma
|
|
@@ -2414,7 +2410,7 @@ class SkyboxRenderer {
|
|
|
2414
2410
|
this.mode = "equirect";
|
|
2415
2411
|
}
|
|
2416
2412
|
// ---- common ----
|
|
2417
|
-
prepareFrame(viewMatrix, projectionMatrix, cameraPosition) {
|
|
2413
|
+
prepareFrame(viewMatrix, projectionMatrix, cameraPosition, groundY) {
|
|
2418
2414
|
if (!this.isActive) {
|
|
2419
2415
|
this.frameReady = false;
|
|
2420
2416
|
return;
|
|
@@ -2432,7 +2428,9 @@ class SkyboxRenderer {
|
|
|
2432
2428
|
ud[9] = viewMatrix[9];
|
|
2433
2429
|
ud[10] = viewMatrix[10];
|
|
2434
2430
|
ud[11] = 0;
|
|
2435
|
-
|
|
2431
|
+
const camWorldY = cameraPosition ? cameraPosition[1] : 0;
|
|
2432
|
+
const gndY = groundY ?? 0;
|
|
2433
|
+
ud[12] = camWorldY - gndY;
|
|
2436
2434
|
ud[13] = this.groundRadius;
|
|
2437
2435
|
ud[14] = 0;
|
|
2438
2436
|
ud[15] = 0;
|
|
@@ -19073,10 +19071,20 @@ class App {
|
|
|
19073
19071
|
this.hotspotManager.updateBillboards();
|
|
19074
19072
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
19075
19073
|
const cam = this.camera.position;
|
|
19074
|
+
let groundY = 0;
|
|
19075
|
+
const gsRenderer2 = this.sceneManager.getGSRenderer();
|
|
19076
|
+
if (gsRenderer2) {
|
|
19077
|
+
const bbox = gsRenderer2.getBoundingBox();
|
|
19078
|
+
if (bbox) {
|
|
19079
|
+
const m = gsRenderer2.getModelMatrix();
|
|
19080
|
+
groundY = m[5] * bbox.min[1] + m[13];
|
|
19081
|
+
}
|
|
19082
|
+
}
|
|
19076
19083
|
this.skyboxRenderer.prepareFrame(
|
|
19077
19084
|
this.camera.viewMatrix,
|
|
19078
19085
|
this.camera.projectionMatrix,
|
|
19079
|
-
[cam[0], cam[1], cam[2]]
|
|
19086
|
+
[cam[0], cam[1], cam[2]],
|
|
19087
|
+
groundY
|
|
19080
19088
|
);
|
|
19081
19089
|
}
|
|
19082
19090
|
const pass = this.renderer.beginFrame();
|