@d5techs/3dgs-lib 1.4.67 → 1.4.69
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 +21 -15
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +21 -15
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -2239,23 +2239,30 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2239
2239
|
@fragment fn fs(i: V) -> @location(0) vec4<f32> {
|
|
2240
2240
|
let d = normalize(i.dir);
|
|
2241
2241
|
let cx = u.cam.x;
|
|
2242
|
-
let cy = max(u.cam.y, 0.1);
|
|
2242
|
+
let cy = max(u.cam.y, 0.1); // clamp: camera always above ground
|
|
2243
2243
|
let cz = u.cam.z;
|
|
2244
|
-
let
|
|
2244
|
+
let captureH = u.cam.w;
|
|
2245
2245
|
|
|
2246
|
-
//
|
|
2247
|
-
let
|
|
2248
|
-
let halfB = dot(origin, d);
|
|
2249
|
-
let cVal = dot(origin, origin) - R * R;
|
|
2250
|
-
let disc = halfB * halfB - cVal;
|
|
2246
|
+
// --- sky: sample HDR with original direction ---
|
|
2247
|
+
let skyUv = dirToUv(d);
|
|
2251
2248
|
|
|
2252
|
-
//
|
|
2253
|
-
let
|
|
2254
|
-
let
|
|
2255
|
-
let
|
|
2249
|
+
// --- ground: ray→plane at Y=0, camera-centered (no world XZ offset) ---
|
|
2250
|
+
let dyClamped = min(d.y, -0.0001);
|
|
2251
|
+
let t = -cy / dyClamped;
|
|
2252
|
+
let hitX = t * d.x;
|
|
2253
|
+
let hitZ = t * d.z;
|
|
2256
2254
|
|
|
2257
|
-
|
|
2258
|
-
let
|
|
2255
|
+
// Direction from virtual capture point to ground hit point
|
|
2256
|
+
let groundDir = normalize(vec3(hitX, -captureH, hitZ));
|
|
2257
|
+
let groundUv = dirToUv(groundDir);
|
|
2258
|
+
|
|
2259
|
+
// --- sample both (uniform control flow) ---
|
|
2260
|
+
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2261
|
+
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2262
|
+
|
|
2263
|
+
// Sharp blend at horizon — cy is always > 0 so no aboveGround check needed
|
|
2264
|
+
let horizonBlend = smoothstep(0.002, -0.002, d.y);
|
|
2265
|
+
let c = mix(skyColor, groundColor, horizonBlend);
|
|
2259
2266
|
|
|
2260
2267
|
// Reinhard tone mapping + gamma
|
|
2261
2268
|
let mapped = c / (c + vec3(1.));
|
|
@@ -19080,8 +19087,7 @@ class App {
|
|
|
19080
19087
|
);
|
|
19081
19088
|
}
|
|
19082
19089
|
const camH = cam[1] - groundLevel;
|
|
19083
|
-
|
|
19084
|
-
this.skyboxRenderer.groundRadius = Math.max(500, camDist + 200);
|
|
19090
|
+
this.skyboxRenderer.groundRadius = 50;
|
|
19085
19091
|
this.skyboxRenderer.prepareFrame(
|
|
19086
19092
|
this.camera.viewMatrix,
|
|
19087
19093
|
this.camera.projectionMatrix,
|