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