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