@d5techs/3dgs-lib 1.4.58 → 1.4.60

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
@@ -2239,40 +2239,41 @@ 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 camH = u.extra.x;
2242
- let projR = u.extra.y;
2242
+ let R = u.extra.y;
2243
2243
 
2244
- // --- sky UV (always computed for uniform control flow) ---
2244
+ // --- sky ---
2245
2245
  let skyUv = dirToUv(d);
2246
2246
 
2247
- // --- flat ground projection ---
2248
- // Ray from camera at height camH above ground, direction d,
2249
- // hits ground plane at t = -camH / d.y
2247
+ // --- ground: inverted bowl hemisphere at Y=0 ---
2250
2248
  let dyClamped = min(d.y, -0.0001);
2251
2249
  let t = -camH / dyClamped;
2252
2250
  let hitX = t * d.x;
2253
2251
  let hitZ = t * d.z;
2254
2252
  let hitDist = sqrt(hitX * hitX + hitZ * hitZ);
2255
2253
 
2256
- // Reconstruct a sampling direction as if looking from HDR capture
2257
- // height (1.7m) straight down at the hit point → FLAT ground
2258
- let captureH = 1.7;
2259
- let groundDir = normalize(vec3(hitX, -captureH, hitZ));
2254
+ // Clamp hit point inside the bowl radius
2255
+ let s = min(1.0, R * 0.999 / max(hitDist, 0.001));
2256
+ let bx = hitX * s;
2257
+ let bz = hitZ * s;
2258
+ // Project onto the lower hemisphere: y = -sqrt(R² - x² - z²)
2259
+ let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
2260
+ let groundDir = normalize(vec3(bx, bowlY, bz));
2260
2261
  let groundUv = dirToUv(groundDir);
2261
2262
 
2262
- // --- sample both unconditionally (uniform control flow) ---
2263
- let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2263
+ // --- sample both (uniform control flow) ---
2264
+ let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2264
2265
  let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
2265
2266
 
2266
- // Blend: smooth transition near horizon
2267
- let horizonBlend = smoothstep(0.0, -0.12, d.y);
2268
- let aboveGround = step(0.01, camH);
2269
- let edgeFade = 1.0 - smoothstep(projR * 0.6, projR, hitDist);
2270
- let finalBlend = horizonBlend * aboveGround * edgeFade;
2267
+ // Blend near horizon + fade at bowl edge
2268
+ let horizonBlend = smoothstep(0.0, -0.08, d.y);
2269
+ let aboveGround = step(0.01, camH);
2270
+ let edgeFade = 1.0 - smoothstep(R * 0.7, R, hitDist);
2271
+ let finalBlend = horizonBlend * aboveGround * edgeFade;
2271
2272
  let c = mix(skyColor, groundColor, finalBlend);
2272
2273
 
2273
2274
  // Reinhard tone mapping + gamma
2274
2275
  let mapped = c / (c + vec3(1.));
2275
- let gamma = pow(mapped, vec3(1./2.2));
2276
+ let gamma = pow(mapped, vec3(1./2.2));
2276
2277
  return vec4(gamma, 1.);
2277
2278
  }`
2278
2279
  );
@@ -2291,7 +2292,7 @@ class SkyboxRenderer {
2291
2292
  __publicField(this, "frameReady", false);
2292
2293
  __publicField(this, "mode", "none");
2293
2294
  /** Ground projection sphere radius (world units). Larger = ground extends further, flatter. */
2294
- __publicField(this, "groundRadius", 500);
2295
+ __publicField(this, "groundRadius", 1e3);
2295
2296
  this.device = device;
2296
2297
  const depthStencil = {
2297
2298
  format: depthFormat,
@@ -2410,7 +2411,7 @@ class SkyboxRenderer {
2410
2411
  this.mode = "equirect";
2411
2412
  }
2412
2413
  // ---- common ----
2413
- prepareFrame(viewMatrix, projectionMatrix, cameraPosition, groundY) {
2414
+ prepareFrame(viewMatrix, projectionMatrix, cameraPosition) {
2414
2415
  if (!this.isActive) {
2415
2416
  this.frameReady = false;
2416
2417
  return;
@@ -2428,9 +2429,7 @@ class SkyboxRenderer {
2428
2429
  ud[9] = viewMatrix[9];
2429
2430
  ud[10] = viewMatrix[10];
2430
2431
  ud[11] = 0;
2431
- const camWorldY = cameraPosition ? cameraPosition[1] : 0;
2432
- const gndY = groundY ?? 0;
2433
- ud[12] = camWorldY - gndY;
2432
+ ud[12] = cameraPosition ? cameraPosition[1] : 0;
2434
2433
  ud[13] = this.groundRadius;
2435
2434
  ud[14] = 0;
2436
2435
  ud[15] = 0;
@@ -19071,20 +19070,10 @@ class App {
19071
19070
  this.hotspotManager.updateBillboards();
19072
19071
  if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
19073
19072
  const cam = this.camera.position;
19074
- let groundY = 0;
19075
- const gsRenderer2 = this.sceneManager.getGSRenderer();
19076
- if (gsRenderer2) {
19077
- const bbox = gsRenderer2.getBoundingBox();
19078
- if (bbox) {
19079
- const m = gsRenderer2.getModelMatrix();
19080
- groundY = m[5] * bbox.min[1] + m[13];
19081
- }
19082
- }
19083
19073
  this.skyboxRenderer.prepareFrame(
19084
19074
  this.camera.viewMatrix,
19085
19075
  this.camera.projectionMatrix,
19086
- [cam[0], cam[1], cam[2]],
19087
- groundY
19076
+ [cam[0], cam[1], cam[2]]
19088
19077
  );
19089
19078
  }
19090
19079
  const pass = this.renderer.beginFrame();