@d5techs/3dgs-lib 1.4.65 → 1.4.67
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 +15 -29
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +15 -29
- 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
|
@@ -2237,38 +2237,23 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2237
2237
|
@fragment fn fs(i: V) -> @location(0) vec4<f32> {
|
|
2238
2238
|
let d = normalize(i.dir);
|
|
2239
2239
|
let cx = u.cam.x;
|
|
2240
|
-
let cy = u.cam.y;
|
|
2240
|
+
let cy = max(u.cam.y, 0.1);
|
|
2241
2241
|
let cz = u.cam.z;
|
|
2242
2242
|
let R = u.cam.w;
|
|
2243
2243
|
|
|
2244
|
-
//
|
|
2245
|
-
let
|
|
2244
|
+
// Ray-sphere intersection: camera at (cx, cy, cz), sphere radius R at origin
|
|
2245
|
+
let origin = vec3(cx, cy, cz);
|
|
2246
|
+
let halfB = dot(origin, d);
|
|
2247
|
+
let cVal = dot(origin, origin) - R * R;
|
|
2248
|
+
let disc = halfB * halfB - cVal;
|
|
2246
2249
|
|
|
2247
|
-
//
|
|
2248
|
-
let
|
|
2249
|
-
let
|
|
2250
|
-
let
|
|
2251
|
-
let wz = cz + t * d.z;
|
|
2252
|
-
let wDist = sqrt(wx * wx + wz * wz);
|
|
2250
|
+
// Far intersection (camera is inside sphere)
|
|
2251
|
+
let t = -halfB + sqrt(max(disc, 0.0));
|
|
2252
|
+
let hitPoint = origin + t * d;
|
|
2253
|
+
let sampleDir = normalize(hitPoint);
|
|
2253
2254
|
|
|
2254
|
-
|
|
2255
|
-
let
|
|
2256
|
-
let bx = wx * s;
|
|
2257
|
-
let bz = wz * s;
|
|
2258
|
-
let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
|
|
2259
|
-
let groundDir = normalize(vec3(bx, bowlY, bz));
|
|
2260
|
-
let groundUv = dirToUv(groundDir);
|
|
2261
|
-
|
|
2262
|
-
// --- sample both (uniform control flow) ---
|
|
2263
|
-
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2264
|
-
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2265
|
-
|
|
2266
|
-
// Sharp blend right at the horizon (d.y = 0)
|
|
2267
|
-
let horizonBlend = smoothstep(0.002, -0.002, d.y);
|
|
2268
|
-
let aboveGround = step(0.01, cy);
|
|
2269
|
-
let edgeFade = 1.0 - smoothstep(R * 0.85, R, wDist);
|
|
2270
|
-
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2271
|
-
let c = mix(skyColor, groundColor, finalBlend);
|
|
2255
|
+
let uv = dirToUv(sampleDir);
|
|
2256
|
+
let c = textureSample(envTexture, envSampler, uv).rgb;
|
|
2272
2257
|
|
|
2273
2258
|
// Reinhard tone mapping + gamma
|
|
2274
2259
|
let mapped = c / (c + vec3(1.));
|
|
@@ -2290,7 +2275,7 @@ class SkyboxRenderer {
|
|
|
2290
2275
|
__publicField(this, "bindGroup", null);
|
|
2291
2276
|
__publicField(this, "frameReady", false);
|
|
2292
2277
|
__publicField(this, "mode", "none");
|
|
2293
|
-
/**
|
|
2278
|
+
/** Virtual HDR capture height (world units). Controls ground texture spread. */
|
|
2294
2279
|
__publicField(this, "groundRadius", 50);
|
|
2295
2280
|
this.device = device;
|
|
2296
2281
|
const depthStencil = {
|
|
@@ -19093,7 +19078,8 @@ class App {
|
|
|
19093
19078
|
);
|
|
19094
19079
|
}
|
|
19095
19080
|
const camH = cam[1] - groundLevel;
|
|
19096
|
-
|
|
19081
|
+
const camDist = Math.sqrt(cam[0] * cam[0] + camH * camH + cam[2] * cam[2]);
|
|
19082
|
+
this.skyboxRenderer.groundRadius = Math.max(500, camDist + 200);
|
|
19097
19083
|
this.skyboxRenderer.prepareFrame(
|
|
19098
19084
|
this.camera.viewMatrix,
|
|
19099
19085
|
this.camera.projectionMatrix,
|