@d5techs/3dgs-lib 1.4.62 → 1.4.64

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 CHANGED
@@ -2243,37 +2243,28 @@ 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 (always computed for uniform control flow) ---
2247
- let skyUv = dirToUv(d);
2246
+ // --- sky: clamp to upper hemisphere so HDR's own ground doesn't show ---
2247
+ let skyDir = normalize(vec3(d.x, max(d.y, 0.001), d.z));
2248
+ let skyUv = dirToUv(skyDir);
2248
2249
 
2249
- // --- ground: ray from camera hits Y=0 plane ---
2250
+ // --- ground: ray from camera hits ground plane ---
2250
2251
  let dyClamped = min(d.y, -0.0001);
2251
2252
  let t = -cy / dyClamped;
2252
- // Hit point in WORLD space (not camera-relative)
2253
2253
  let wx = cx + t * d.x;
2254
2254
  let wz = cz + t * d.z;
2255
2255
  let wDist = sqrt(wx * wx + wz * wz);
2256
2256
 
2257
- // Clamp inside the bowl radius (centered at world origin)
2257
+ // Bowl projection centered at world origin
2258
2258
  let s = min(1.0, R * 0.999 / max(wDist, 0.001));
2259
2259
  let bx = wx * s;
2260
2260
  let bz = wz * s;
2261
- // Inverted bowl: y = -sqrt(R² - x² - z²)
2262
2261
  let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
2263
2262
  let groundDir = normalize(vec3(bx, bowlY, bz));
2264
2263
  let groundUv = dirToUv(groundDir);
2265
2264
 
2266
2265
  // --- sample both (uniform control flow) ---
2267
2266
  let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2268
- let hdrGround = textureSample(envTexture, envSampler, groundUv).rgb;
2269
-
2270
- // Debug checkerboard to verify ground position
2271
- let cx2 = floor(wx * 2.0);
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;
2267
+ let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
2277
2268
 
2278
2269
  // Blend: horizon transition + fade at bowl edge
2279
2270
  let horizonBlend = smoothstep(0.0, -0.05, d.y);
@@ -19083,30 +19074,26 @@ class App {
19083
19074
  const cam = this.camera.position;
19084
19075
  let groundLevel = 0;
19085
19076
  const gsRendererForGround = this.sceneManager.getGSRenderer();
19086
- if (gsRendererForGround) {
19087
- const bbox = gsRendererForGround.getBoundingBox();
19088
- if (bbox) {
19089
- const m = gsRendererForGround.getModelMatrix();
19090
- groundLevel = m[5] * bbox.min[1] + m[13];
19091
- if (!this._hdrDebugLogged) {
19092
- this._hdrDebugLogged = true;
19093
- console.log(
19094
- "[HDR Ground Debug]",
19095
- "bbox.min:",
19096
- bbox.min,
19097
- "bbox.max:",
19098
- bbox.max,
19099
- "bbox.center:",
19100
- bbox.center,
19101
- "groundLevel:",
19102
- groundLevel,
19103
- "cam:",
19104
- [cam[0].toFixed(2), cam[1].toFixed(2), cam[2].toFixed(2)],
19105
- "camH_effective:",
19106
- (cam[1] - groundLevel).toFixed(2)
19107
- );
19108
- }
19109
- }
19077
+ const bbox = (gsRendererForGround == null ? void 0 : gsRendererForGround.getBoundingBox()) ?? null;
19078
+ if (bbox) {
19079
+ const m = gsRendererForGround.getModelMatrix();
19080
+ groundLevel = m[5] * bbox.min[1] + m[13];
19081
+ }
19082
+ if (!this._hdrDebugLogged) {
19083
+ this._hdrDebugLogged = true;
19084
+ console.log(
19085
+ "[HDR Ground Debug]",
19086
+ "hasGsRenderer:",
19087
+ !!gsRendererForGround,
19088
+ "hasBbox:",
19089
+ !!bbox,
19090
+ "bbox:",
19091
+ bbox ? { min: [...bbox.min], max: [...bbox.max], center: [...bbox.center] } : null,
19092
+ "groundLevel:",
19093
+ groundLevel,
19094
+ "cam:",
19095
+ [cam[0].toFixed(2), cam[1].toFixed(2), cam[2].toFixed(2)]
19096
+ );
19110
19097
  }
19111
19098
  this.skyboxRenderer.prepareFrame(
19112
19099
  this.camera.viewMatrix,