@d5techs/3dgs-lib 1.4.65 → 1.4.66

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.js CHANGED
@@ -2239,36 +2239,29 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
2239
2239
  let cx = u.cam.x;
2240
2240
  let cy = u.cam.y;
2241
2241
  let cz = u.cam.z;
2242
- let R = u.cam.w;
2242
+ let captureH = u.cam.w;
2243
2243
 
2244
2244
  // --- sky: sample HDR with original direction ---
2245
2245
  let skyUv = dirToUv(d);
2246
2246
 
2247
- // --- ground: ray from camera hits ground plane ---
2247
+ // --- ground: ray→plane at Y=0, then map hit point to HDR direction ---
2248
2248
  let dyClamped = min(d.y, -0.0001);
2249
2249
  let t = -cy / dyClamped;
2250
- let wx = cx + t * d.x;
2251
- let wz = cz + t * d.z;
2252
- let wDist = sqrt(wx * wx + wz * wz);
2250
+ let hitX = cx + t * d.x;
2251
+ let hitZ = cz + t * d.z;
2253
2252
 
2254
- // Bowl projection centered at world origin
2255
- let s = min(1.0, R * 0.999 / max(wDist, 0.001));
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));
2253
+ // Direction from virtual capture point (0, captureH, 0) to ground hit point
2254
+ let groundDir = normalize(vec3(hitX, -captureH, hitZ));
2260
2255
  let groundUv = dirToUv(groundDir);
2261
2256
 
2262
2257
  // --- sample both (uniform control flow) ---
2263
2258
  let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2264
2259
  let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
2265
2260
 
2266
- // Sharp blend right at the horizon (d.y = 0)
2261
+ // Sharp blend at horizon, no edge fade needed
2267
2262
  let horizonBlend = smoothstep(0.002, -0.002, d.y);
2268
2263
  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);
2264
+ let c = mix(skyColor, groundColor, horizonBlend * aboveGround);
2272
2265
 
2273
2266
  // Reinhard tone mapping + gamma
2274
2267
  let mapped = c / (c + vec3(1.));
@@ -2290,7 +2283,7 @@ class SkyboxRenderer {
2290
2283
  __publicField(this, "bindGroup", null);
2291
2284
  __publicField(this, "frameReady", false);
2292
2285
  __publicField(this, "mode", "none");
2293
- /** Ground projection sphere radius (world units). Larger = ground extends further, flatter. */
2286
+ /** Virtual HDR capture height (world units). Controls ground texture spread. */
2294
2287
  __publicField(this, "groundRadius", 50);
2295
2288
  this.device = device;
2296
2289
  const depthStencil = {
@@ -19093,7 +19086,7 @@ class App {
19093
19086
  );
19094
19087
  }
19095
19088
  const camH = cam[1] - groundLevel;
19096
- this.skyboxRenderer.groundRadius = Math.max(200, camH * 3);
19089
+ this.skyboxRenderer.groundRadius = 50;
19097
19090
  this.skyboxRenderer.prepareFrame(
19098
19091
  this.camera.viewMatrix,
19099
19092
  this.camera.projectionMatrix,