@d5techs/3dgs-lib 1.4.60 → 1.4.62
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 +66 -28
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +66 -28
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -2215,7 +2215,7 @@ struct V { @builtin(position) pos: vec4<f32>, @location(0) dir: vec3<f32> };
|
|
|
2215
2215
|
const EQUIRECT_WGSL = (
|
|
2216
2216
|
/* wgsl */
|
|
2217
2217
|
`
|
|
2218
|
-
struct Uniforms { col0: vec4<f32>, col1: vec4<f32>, col2: vec4<f32>,
|
|
2218
|
+
struct Uniforms { col0: vec4<f32>, col1: vec4<f32>, col2: vec4<f32>, cam: vec4<f32> };
|
|
2219
2219
|
@group(0) @binding(0) var<uniform> u: Uniforms;
|
|
2220
2220
|
@group(0) @binding(1) var envSampler: sampler;
|
|
2221
2221
|
@group(0) @binding(2) var envTexture: texture_2d<f32>;
|
|
@@ -2235,37 +2235,48 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
|
|
2237
2237
|
@fragment fn fs(i: V) -> @location(0) vec4<f32> {
|
|
2238
|
-
let d
|
|
2239
|
-
let
|
|
2240
|
-
let
|
|
2238
|
+
let d = normalize(i.dir);
|
|
2239
|
+
let cx = u.cam.x;
|
|
2240
|
+
let cy = u.cam.y;
|
|
2241
|
+
let cz = u.cam.z;
|
|
2242
|
+
let R = u.cam.w;
|
|
2241
2243
|
|
|
2242
|
-
// --- sky ---
|
|
2244
|
+
// --- sky (always computed for uniform control flow) ---
|
|
2243
2245
|
let skyUv = dirToUv(d);
|
|
2244
2246
|
|
|
2245
|
-
// --- ground:
|
|
2247
|
+
// --- ground: ray from camera hits Y=0 plane ---
|
|
2246
2248
|
let dyClamped = min(d.y, -0.0001);
|
|
2247
|
-
let t = -
|
|
2248
|
-
|
|
2249
|
-
let
|
|
2250
|
-
let
|
|
2249
|
+
let t = -cy / dyClamped;
|
|
2250
|
+
// Hit point in WORLD space (not camera-relative)
|
|
2251
|
+
let wx = cx + t * d.x;
|
|
2252
|
+
let wz = cz + t * d.z;
|
|
2253
|
+
let wDist = sqrt(wx * wx + wz * wz);
|
|
2251
2254
|
|
|
2252
|
-
// Clamp
|
|
2253
|
-
let s
|
|
2254
|
-
let bx =
|
|
2255
|
-
let bz =
|
|
2256
|
-
//
|
|
2255
|
+
// Clamp inside the bowl radius (centered at world origin)
|
|
2256
|
+
let s = min(1.0, R * 0.999 / max(wDist, 0.001));
|
|
2257
|
+
let bx = wx * s;
|
|
2258
|
+
let bz = wz * s;
|
|
2259
|
+
// Inverted bowl: y = -sqrt(R² - x² - z²)
|
|
2257
2260
|
let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
|
|
2258
2261
|
let groundDir = normalize(vec3(bx, bowlY, bz));
|
|
2259
|
-
let groundUv
|
|
2262
|
+
let groundUv = dirToUv(groundDir);
|
|
2260
2263
|
|
|
2261
2264
|
// --- sample both (uniform control flow) ---
|
|
2262
|
-
let skyColor
|
|
2263
|
-
let
|
|
2265
|
+
let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
|
|
2266
|
+
let hdrGround = textureSample(envTexture, envSampler, groundUv).rgb;
|
|
2267
|
+
|
|
2268
|
+
// Debug checkerboard to verify ground position
|
|
2269
|
+
let cx2 = floor(wx * 2.0);
|
|
2270
|
+
let cz2 = floor(wz * 2.0);
|
|
2271
|
+
let checker = ((cx2 + cz2) % 2.0 + 2.0) % 2.0;
|
|
2272
|
+
let checkerColor = mix(vec3(0.15, 0.15, 0.15), vec3(0.4, 0.4, 0.4), checker);
|
|
2273
|
+
// Mix HDR ground with subtle checker for position reference
|
|
2274
|
+
let groundColor = hdrGround * 0.8 + checkerColor * 0.2;
|
|
2264
2275
|
|
|
2265
|
-
// Blend
|
|
2266
|
-
let horizonBlend = smoothstep(0.0, -0.
|
|
2267
|
-
let aboveGround = step(0.01,
|
|
2268
|
-
let edgeFade = 1.0 - smoothstep(R * 0.7, R,
|
|
2276
|
+
// Blend: horizon transition + fade at bowl edge
|
|
2277
|
+
let horizonBlend = smoothstep(0.0, -0.05, d.y);
|
|
2278
|
+
let aboveGround = step(0.01, cy);
|
|
2279
|
+
let edgeFade = 1.0 - smoothstep(R * 0.7, R, wDist);
|
|
2269
2280
|
let finalBlend = horizonBlend * aboveGround * edgeFade;
|
|
2270
2281
|
let c = mix(skyColor, groundColor, finalBlend);
|
|
2271
2282
|
|
|
@@ -2290,7 +2301,7 @@ class SkyboxRenderer {
|
|
|
2290
2301
|
__publicField(this, "frameReady", false);
|
|
2291
2302
|
__publicField(this, "mode", "none");
|
|
2292
2303
|
/** Ground projection sphere radius (world units). Larger = ground extends further, flatter. */
|
|
2293
|
-
__publicField(this, "groundRadius",
|
|
2304
|
+
__publicField(this, "groundRadius", 50);
|
|
2294
2305
|
this.device = device;
|
|
2295
2306
|
const depthStencil = {
|
|
2296
2307
|
format: depthFormat,
|
|
@@ -2427,10 +2438,10 @@ class SkyboxRenderer {
|
|
|
2427
2438
|
ud[9] = viewMatrix[9];
|
|
2428
2439
|
ud[10] = viewMatrix[10];
|
|
2429
2440
|
ud[11] = 0;
|
|
2430
|
-
ud[12] = cameraPosition ? cameraPosition[
|
|
2431
|
-
ud[13] =
|
|
2432
|
-
ud[14] = 0;
|
|
2433
|
-
ud[15] =
|
|
2441
|
+
ud[12] = cameraPosition ? cameraPosition[0] : 0;
|
|
2442
|
+
ud[13] = cameraPosition ? cameraPosition[1] : 0;
|
|
2443
|
+
ud[14] = cameraPosition ? cameraPosition[2] : 0;
|
|
2444
|
+
ud[15] = this.groundRadius;
|
|
2434
2445
|
this.device.queue.writeBuffer(this.uniformBuffer, 0, ud);
|
|
2435
2446
|
this.frameReady = true;
|
|
2436
2447
|
}
|
|
@@ -19068,10 +19079,37 @@ class App {
|
|
|
19068
19079
|
this.hotspotManager.updateBillboards();
|
|
19069
19080
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
19070
19081
|
const cam = this.camera.position;
|
|
19082
|
+
let groundLevel = 0;
|
|
19083
|
+
const gsRendererForGround = this.sceneManager.getGSRenderer();
|
|
19084
|
+
if (gsRendererForGround) {
|
|
19085
|
+
const bbox = gsRendererForGround.getBoundingBox();
|
|
19086
|
+
if (bbox) {
|
|
19087
|
+
const m = gsRendererForGround.getModelMatrix();
|
|
19088
|
+
groundLevel = m[5] * bbox.min[1] + m[13];
|
|
19089
|
+
if (!this._hdrDebugLogged) {
|
|
19090
|
+
this._hdrDebugLogged = true;
|
|
19091
|
+
console.log(
|
|
19092
|
+
"[HDR Ground Debug]",
|
|
19093
|
+
"bbox.min:",
|
|
19094
|
+
bbox.min,
|
|
19095
|
+
"bbox.max:",
|
|
19096
|
+
bbox.max,
|
|
19097
|
+
"bbox.center:",
|
|
19098
|
+
bbox.center,
|
|
19099
|
+
"groundLevel:",
|
|
19100
|
+
groundLevel,
|
|
19101
|
+
"cam:",
|
|
19102
|
+
[cam[0].toFixed(2), cam[1].toFixed(2), cam[2].toFixed(2)],
|
|
19103
|
+
"camH_effective:",
|
|
19104
|
+
(cam[1] - groundLevel).toFixed(2)
|
|
19105
|
+
);
|
|
19106
|
+
}
|
|
19107
|
+
}
|
|
19108
|
+
}
|
|
19071
19109
|
this.skyboxRenderer.prepareFrame(
|
|
19072
19110
|
this.camera.viewMatrix,
|
|
19073
19111
|
this.camera.projectionMatrix,
|
|
19074
|
-
[cam[0], cam[1], cam[2]]
|
|
19112
|
+
[cam[0], cam[1] - groundLevel, cam[2]]
|
|
19075
19113
|
);
|
|
19076
19114
|
}
|
|
19077
19115
|
const pass = this.renderer.beginFrame();
|