@d5techs/3dgs-lib 1.4.57 → 1.4.59
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 +21 -38
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +21 -38
- 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
|
@@ -2236,40 +2236,37 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2236
2236
|
|
|
2237
2237
|
@fragment fn fs(i: V) -> @location(0) vec4<f32> {
|
|
2238
2238
|
let d = normalize(i.dir);
|
|
2239
|
-
let
|
|
2240
|
-
let
|
|
2239
|
+
let camH = u.extra.x;
|
|
2240
|
+
let projR = u.extra.y;
|
|
2241
2241
|
|
|
2242
|
-
// --- sky UV (always computed) ---
|
|
2242
|
+
// --- sky UV (always computed for uniform control flow) ---
|
|
2243
2243
|
let skyUv = dirToUv(d);
|
|
2244
2244
|
|
|
2245
|
-
// --- ground projection
|
|
2246
|
-
// Ray from camera
|
|
2245
|
+
// --- flat ground projection ---
|
|
2246
|
+
// Ray from camera at height camH above ground, direction d,
|
|
2247
|
+
// hits ground plane at t = -camH / d.y
|
|
2247
2248
|
let dyClamped = min(d.y, -0.0001);
|
|
2248
|
-
let t = -
|
|
2249
|
+
let t = -camH / dyClamped;
|
|
2249
2250
|
let hitX = t * d.x;
|
|
2250
2251
|
let hitZ = t * d.z;
|
|
2251
2252
|
let hitDist = sqrt(hitX * hitX + hitZ * hitZ);
|
|
2252
2253
|
|
|
2253
|
-
//
|
|
2254
|
-
//
|
|
2255
|
-
//
|
|
2256
|
-
let
|
|
2257
|
-
let
|
|
2258
|
-
let pZ = hitZ * ratio;
|
|
2259
|
-
let pY = -sqrt(max(sphereR * sphereR - pX * pX - pZ * pZ, 0.0));
|
|
2260
|
-
let groundDir = normalize(vec3(pX, pY, pZ));
|
|
2254
|
+
// Re-map to a direction on the HDR sphere from a virtual capture
|
|
2255
|
+
// height above ground. Larger = more ground texture visible,
|
|
2256
|
+
// smaller = more horizon. 15 matches Three.js GroundProjectedEnv default.
|
|
2257
|
+
let captureH = 15.0;
|
|
2258
|
+
let groundDir = normalize(vec3(hitX, -captureH, hitZ));
|
|
2261
2259
|
let groundUv = dirToUv(groundDir);
|
|
2262
2260
|
|
|
2263
|
-
// --- sample both (
|
|
2261
|
+
// --- sample both unconditionally (uniform control flow) ---
|
|
2264
2262
|
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2265
2263
|
let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2266
2264
|
|
|
2267
2265
|
// Blend: smooth transition near horizon
|
|
2268
|
-
|
|
2269
|
-
let
|
|
2270
|
-
|
|
2271
|
-
let
|
|
2272
|
-
let finalBlend = groundFactor * edgeFade;
|
|
2266
|
+
let horizonBlend = smoothstep(0.0, -0.12, d.y);
|
|
2267
|
+
let aboveGround = step(0.01, camH);
|
|
2268
|
+
let edgeFade = 1.0 - smoothstep(projR * 0.6, projR, hitDist);
|
|
2269
|
+
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2273
2270
|
let c = mix(skyColor, groundColor, finalBlend);
|
|
2274
2271
|
|
|
2275
2272
|
// Reinhard tone mapping + gamma
|
|
@@ -2293,7 +2290,7 @@ class SkyboxRenderer {
|
|
|
2293
2290
|
__publicField(this, "frameReady", false);
|
|
2294
2291
|
__publicField(this, "mode", "none");
|
|
2295
2292
|
/** Ground projection sphere radius (world units). Larger = ground extends further, flatter. */
|
|
2296
|
-
__publicField(this, "groundRadius",
|
|
2293
|
+
__publicField(this, "groundRadius", 1e3);
|
|
2297
2294
|
this.device = device;
|
|
2298
2295
|
const depthStencil = {
|
|
2299
2296
|
format: depthFormat,
|
|
@@ -2412,7 +2409,7 @@ class SkyboxRenderer {
|
|
|
2412
2409
|
this.mode = "equirect";
|
|
2413
2410
|
}
|
|
2414
2411
|
// ---- common ----
|
|
2415
|
-
prepareFrame(viewMatrix, projectionMatrix, cameraPosition
|
|
2412
|
+
prepareFrame(viewMatrix, projectionMatrix, cameraPosition) {
|
|
2416
2413
|
if (!this.isActive) {
|
|
2417
2414
|
this.frameReady = false;
|
|
2418
2415
|
return;
|
|
@@ -2430,9 +2427,7 @@ class SkyboxRenderer {
|
|
|
2430
2427
|
ud[9] = viewMatrix[9];
|
|
2431
2428
|
ud[10] = viewMatrix[10];
|
|
2432
2429
|
ud[11] = 0;
|
|
2433
|
-
|
|
2434
|
-
const gndY = groundY ?? 0;
|
|
2435
|
-
ud[12] = camWorldY - gndY;
|
|
2430
|
+
ud[12] = cameraPosition ? cameraPosition[1] : 0;
|
|
2436
2431
|
ud[13] = this.groundRadius;
|
|
2437
2432
|
ud[14] = 0;
|
|
2438
2433
|
ud[15] = 0;
|
|
@@ -19073,22 +19068,10 @@ class App {
|
|
|
19073
19068
|
this.hotspotManager.updateBillboards();
|
|
19074
19069
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
19075
19070
|
const cam = this.camera.position;
|
|
19076
|
-
let groundY = 0;
|
|
19077
|
-
const gsRenderer2 = this.sceneManager.getGSRenderer();
|
|
19078
|
-
if (gsRenderer2) {
|
|
19079
|
-
const bbox = gsRenderer2.getBoundingBox();
|
|
19080
|
-
if (bbox) {
|
|
19081
|
-
const m = gsRenderer2.getModelMatrix();
|
|
19082
|
-
const minLocalY = bbox.center[1] - bbox.radius;
|
|
19083
|
-
groundY = minLocalY * m[5] + bbox.center[1] * (m[5] - m[5]) + m[13];
|
|
19084
|
-
groundY = (bbox.center[1] - bbox.radius) * m[5] + m[13];
|
|
19085
|
-
}
|
|
19086
|
-
}
|
|
19087
19071
|
this.skyboxRenderer.prepareFrame(
|
|
19088
19072
|
this.camera.viewMatrix,
|
|
19089
19073
|
this.camera.projectionMatrix,
|
|
19090
|
-
[cam[0], cam[1], cam[2]]
|
|
19091
|
-
groundY
|
|
19074
|
+
[cam[0], cam[1], cam[2]]
|
|
19092
19075
|
);
|
|
19093
19076
|
}
|
|
19094
19077
|
const pass = this.renderer.beginFrame();
|