@d5techs/3dgs-lib 1.4.64 → 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.cjs +15 -21
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +15 -21
- 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.cjs
CHANGED
|
@@ -2241,37 +2241,29 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2241
2241
|
let cx = u.cam.x;
|
|
2242
2242
|
let cy = u.cam.y;
|
|
2243
2243
|
let cz = u.cam.z;
|
|
2244
|
-
let
|
|
2244
|
+
let captureH = u.cam.w;
|
|
2245
2245
|
|
|
2246
|
-
// --- sky:
|
|
2247
|
-
let
|
|
2248
|
-
let skyUv = dirToUv(skyDir);
|
|
2246
|
+
// --- sky: sample HDR with original direction ---
|
|
2247
|
+
let skyUv = dirToUv(d);
|
|
2249
2248
|
|
|
2250
|
-
// --- ground: ray
|
|
2249
|
+
// --- ground: ray→plane at Y=0, then map hit point to HDR direction ---
|
|
2251
2250
|
let dyClamped = min(d.y, -0.0001);
|
|
2252
2251
|
let t = -cy / dyClamped;
|
|
2253
|
-
let
|
|
2254
|
-
let
|
|
2255
|
-
let wDist = sqrt(wx * wx + wz * wz);
|
|
2252
|
+
let hitX = cx + t * d.x;
|
|
2253
|
+
let hitZ = cz + t * d.z;
|
|
2256
2254
|
|
|
2257
|
-
//
|
|
2258
|
-
let
|
|
2259
|
-
let bx = wx * s;
|
|
2260
|
-
let bz = wz * s;
|
|
2261
|
-
let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
|
|
2262
|
-
let groundDir = normalize(vec3(bx, bowlY, bz));
|
|
2255
|
+
// Direction from virtual capture point (0, captureH, 0) to ground hit point
|
|
2256
|
+
let groundDir = normalize(vec3(hitX, -captureH, hitZ));
|
|
2263
2257
|
let groundUv = dirToUv(groundDir);
|
|
2264
2258
|
|
|
2265
2259
|
// --- sample both (uniform control flow) ---
|
|
2266
2260
|
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2267
2261
|
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2268
2262
|
|
|
2269
|
-
//
|
|
2270
|
-
let horizonBlend = smoothstep(0.
|
|
2263
|
+
// Sharp blend at horizon, no edge fade needed
|
|
2264
|
+
let horizonBlend = smoothstep(0.002, -0.002, d.y);
|
|
2271
2265
|
let aboveGround = step(0.01, cy);
|
|
2272
|
-
let
|
|
2273
|
-
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2274
|
-
let c = mix(skyColor, groundColor, finalBlend);
|
|
2266
|
+
let c = mix(skyColor, groundColor, horizonBlend * aboveGround);
|
|
2275
2267
|
|
|
2276
2268
|
// Reinhard tone mapping + gamma
|
|
2277
2269
|
let mapped = c / (c + vec3(1.));
|
|
@@ -2293,7 +2285,7 @@ class SkyboxRenderer {
|
|
|
2293
2285
|
__publicField(this, "bindGroup", null);
|
|
2294
2286
|
__publicField(this, "frameReady", false);
|
|
2295
2287
|
__publicField(this, "mode", "none");
|
|
2296
|
-
/**
|
|
2288
|
+
/** Virtual HDR capture height (world units). Controls ground texture spread. */
|
|
2297
2289
|
__publicField(this, "groundRadius", 50);
|
|
2298
2290
|
this.device = device;
|
|
2299
2291
|
const depthStencil = {
|
|
@@ -19095,10 +19087,12 @@ class App {
|
|
|
19095
19087
|
[cam[0].toFixed(2), cam[1].toFixed(2), cam[2].toFixed(2)]
|
|
19096
19088
|
);
|
|
19097
19089
|
}
|
|
19090
|
+
const camH = cam[1] - groundLevel;
|
|
19091
|
+
this.skyboxRenderer.groundRadius = 50;
|
|
19098
19092
|
this.skyboxRenderer.prepareFrame(
|
|
19099
19093
|
this.camera.viewMatrix,
|
|
19100
19094
|
this.camera.projectionMatrix,
|
|
19101
|
-
[cam[0],
|
|
19095
|
+
[cam[0], camH, cam[2]]
|
|
19102
19096
|
);
|
|
19103
19097
|
}
|
|
19104
19098
|
const pass = this.renderer.beginFrame();
|