@d5techs/3dgs-lib 1.4.63 → 1.4.65
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 +10 -18
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +10 -18
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -2243,42 +2243,32 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2243
2243
|
let cz = u.cam.z;
|
|
2244
2244
|
let R = u.cam.w;
|
|
2245
2245
|
|
|
2246
|
-
// --- sky
|
|
2246
|
+
// --- sky: sample HDR with original direction ---
|
|
2247
2247
|
let skyUv = dirToUv(d);
|
|
2248
2248
|
|
|
2249
|
-
// --- ground: ray from camera hits
|
|
2249
|
+
// --- ground: ray from camera hits ground plane ---
|
|
2250
2250
|
let dyClamped = min(d.y, -0.0001);
|
|
2251
2251
|
let t = -cy / dyClamped;
|
|
2252
|
-
// Hit point in WORLD space (not camera-relative)
|
|
2253
2252
|
let wx = cx + t * d.x;
|
|
2254
2253
|
let wz = cz + t * d.z;
|
|
2255
2254
|
let wDist = sqrt(wx * wx + wz * wz);
|
|
2256
2255
|
|
|
2257
|
-
//
|
|
2256
|
+
// Bowl projection centered at world origin
|
|
2258
2257
|
let s = min(1.0, R * 0.999 / max(wDist, 0.001));
|
|
2259
2258
|
let bx = wx * s;
|
|
2260
2259
|
let bz = wz * s;
|
|
2261
|
-
// Inverted bowl: y = -sqrt(R² - x² - z²)
|
|
2262
2260
|
let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
|
|
2263
2261
|
let groundDir = normalize(vec3(bx, bowlY, bz));
|
|
2264
2262
|
let groundUv = dirToUv(groundDir);
|
|
2265
2263
|
|
|
2266
2264
|
// --- sample both (uniform control flow) ---
|
|
2267
2265
|
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2268
|
-
let
|
|
2266
|
+
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2269
2267
|
|
|
2270
|
-
//
|
|
2271
|
-
let
|
|
2272
|
-
let cz2 = floor(wz * 2.0);
|
|
2273
|
-
let checker = ((cx2 + cz2) % 2.0 + 2.0) % 2.0;
|
|
2274
|
-
let checkerColor = mix(vec3(0.15, 0.15, 0.15), vec3(0.4, 0.4, 0.4), checker);
|
|
2275
|
-
// Mix HDR ground with subtle checker for position reference
|
|
2276
|
-
let groundColor = hdrGround * 0.8 + checkerColor * 0.2;
|
|
2277
|
-
|
|
2278
|
-
// Blend: horizon transition + fade at bowl edge
|
|
2279
|
-
let horizonBlend = smoothstep(0.0, -0.05, d.y);
|
|
2268
|
+
// Sharp blend right at the horizon (d.y = 0)
|
|
2269
|
+
let horizonBlend = smoothstep(0.002, -0.002, d.y);
|
|
2280
2270
|
let aboveGround = step(0.01, cy);
|
|
2281
|
-
let edgeFade = 1.0 - smoothstep(R * 0.
|
|
2271
|
+
let edgeFade = 1.0 - smoothstep(R * 0.85, R, wDist);
|
|
2282
2272
|
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2283
2273
|
let c = mix(skyColor, groundColor, finalBlend);
|
|
2284
2274
|
|
|
@@ -19104,10 +19094,12 @@ class App {
|
|
|
19104
19094
|
[cam[0].toFixed(2), cam[1].toFixed(2), cam[2].toFixed(2)]
|
|
19105
19095
|
);
|
|
19106
19096
|
}
|
|
19097
|
+
const camH = cam[1] - groundLevel;
|
|
19098
|
+
this.skyboxRenderer.groundRadius = Math.max(200, camH * 3);
|
|
19107
19099
|
this.skyboxRenderer.prepareFrame(
|
|
19108
19100
|
this.camera.viewMatrix,
|
|
19109
19101
|
this.camera.projectionMatrix,
|
|
19110
|
-
[cam[0],
|
|
19102
|
+
[cam[0], camH, cam[2]]
|
|
19111
19103
|
);
|
|
19112
19104
|
}
|
|
19113
19105
|
const pass = this.renderer.beginFrame();
|