@d5techs/3dgs-lib 1.4.51 → 1.4.52
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 +7 -47
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +7 -47
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +0 -1
- package/dist/core/SkyboxRenderer.d.ts +1 -2
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -2105,7 +2105,6 @@ struct Uniforms {
|
|
|
2105
2105
|
col0: vec4<f32>,
|
|
2106
2106
|
col1: vec4<f32>,
|
|
2107
2107
|
col2: vec4<f32>,
|
|
2108
|
-
extra: vec4<f32>,
|
|
2109
2108
|
};
|
|
2110
2109
|
|
|
2111
2110
|
@group(0) @binding(0) var<uniform> u: Uniforms;
|
|
@@ -2140,28 +2139,8 @@ fn vs(@builtin(vertex_index) vi: u32) -> VSOut {
|
|
|
2140
2139
|
|
|
2141
2140
|
@fragment
|
|
2142
2141
|
fn fs(input: VSOut) -> @location(0) vec4<f32> {
|
|
2143
|
-
let
|
|
2144
|
-
|
|
2145
|
-
let camX = u.extra.y;
|
|
2146
|
-
let camY = u.extra.z;
|
|
2147
|
-
let camZ = u.extra.w;
|
|
2148
|
-
|
|
2149
|
-
let doGround = u.extra.x > 0.5 && dir.y < -0.001 && camY > 0.01;
|
|
2150
|
-
let safeDirY = select(dir.y, -0.01, dir.y > -0.001);
|
|
2151
|
-
let t = camY / (-safeDirY);
|
|
2152
|
-
let gx = camX + dir.x * t;
|
|
2153
|
-
let gz = camZ + dir.z * t;
|
|
2154
|
-
let scale = max(camY, 1.0) * 5.0;
|
|
2155
|
-
let groundDir = normalize(vec3<f32>(gx / max(scale, 0.01), -1.0, gz / max(scale, 0.01)));
|
|
2156
|
-
|
|
2157
|
-
let skyColor = textureSample(cubeTexture, cubeSampler, dir);
|
|
2158
|
-
let groundColor = textureSample(cubeTexture, cubeSampler, groundDir);
|
|
2159
|
-
|
|
2160
|
-
let blend = smoothstep(0.0, -0.12, dir.y);
|
|
2161
|
-
let mixed = mix(skyColor.rgb, groundColor.rgb, blend);
|
|
2162
|
-
|
|
2163
|
-
let final_color = select(skyColor.rgb, mixed, doGround);
|
|
2164
|
-
return vec4<f32>(final_color, 1.0);
|
|
2142
|
+
let color = textureSample(cubeTexture, cubeSampler, normalize(input.dir));
|
|
2143
|
+
return vec4<f32>(color.rgb, 1.0);
|
|
2165
2144
|
}
|
|
2166
2145
|
`
|
|
2167
2146
|
);
|
|
@@ -2172,18 +2151,17 @@ class SkyboxRenderer {
|
|
|
2172
2151
|
__publicField(this, "uniformBuffer");
|
|
2173
2152
|
__publicField(this, "sampler");
|
|
2174
2153
|
__publicField(this, "bindGroupLayout");
|
|
2175
|
-
__publicField(this, "uniformData", new Float32Array(
|
|
2154
|
+
__publicField(this, "uniformData", new Float32Array(12));
|
|
2176
2155
|
__publicField(this, "cubeTexture", null);
|
|
2177
2156
|
__publicField(this, "cubeBindGroup", null);
|
|
2178
2157
|
__publicField(this, "frameReady", false);
|
|
2179
|
-
__publicField(this, "alignToGround", true);
|
|
2180
2158
|
this.device = device;
|
|
2181
2159
|
const shaderModule = device.createShaderModule({ code: WGSL });
|
|
2182
2160
|
this.bindGroupLayout = device.createBindGroupLayout({
|
|
2183
2161
|
entries: [
|
|
2184
2162
|
{
|
|
2185
2163
|
binding: 0,
|
|
2186
|
-
visibility: GPUShaderStage.VERTEX
|
|
2164
|
+
visibility: GPUShaderStage.VERTEX,
|
|
2187
2165
|
buffer: { type: "uniform" }
|
|
2188
2166
|
},
|
|
2189
2167
|
{
|
|
@@ -2216,7 +2194,7 @@ class SkyboxRenderer {
|
|
|
2216
2194
|
}
|
|
2217
2195
|
});
|
|
2218
2196
|
this.uniformBuffer = device.createBuffer({
|
|
2219
|
-
size:
|
|
2197
|
+
size: 48,
|
|
2220
2198
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
2221
2199
|
});
|
|
2222
2200
|
this.sampler = device.createSampler({
|
|
@@ -2273,7 +2251,7 @@ class SkyboxRenderer {
|
|
|
2273
2251
|
});
|
|
2274
2252
|
this.cubeTexture = tex;
|
|
2275
2253
|
}
|
|
2276
|
-
prepareFrame(viewMatrix, projectionMatrix
|
|
2254
|
+
prepareFrame(viewMatrix, projectionMatrix) {
|
|
2277
2255
|
if (!this.isActive) {
|
|
2278
2256
|
this.frameReady = false;
|
|
2279
2257
|
return;
|
|
@@ -2291,17 +2269,6 @@ class SkyboxRenderer {
|
|
|
2291
2269
|
ud[9] = viewMatrix[9];
|
|
2292
2270
|
ud[10] = viewMatrix[10];
|
|
2293
2271
|
ud[11] = 0;
|
|
2294
|
-
if (this.alignToGround && cameraPosition) {
|
|
2295
|
-
ud[12] = 1;
|
|
2296
|
-
ud[13] = cameraPosition[0];
|
|
2297
|
-
ud[14] = cameraPosition[1];
|
|
2298
|
-
ud[15] = cameraPosition[2];
|
|
2299
|
-
} else {
|
|
2300
|
-
ud[12] = 0;
|
|
2301
|
-
ud[13] = 0;
|
|
2302
|
-
ud[14] = 0;
|
|
2303
|
-
ud[15] = 0;
|
|
2304
|
-
}
|
|
2305
2272
|
this.device.queue.writeBuffer(this.uniformBuffer, 0, ud);
|
|
2306
2273
|
this.frameReady = true;
|
|
2307
2274
|
}
|
|
@@ -18936,11 +18903,9 @@ class App {
|
|
|
18936
18903
|
this.updateAdaptivePerformance();
|
|
18937
18904
|
this.hotspotManager.updateBillboards();
|
|
18938
18905
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
18939
|
-
const cam = this.camera.position;
|
|
18940
18906
|
this.skyboxRenderer.prepareFrame(
|
|
18941
18907
|
this.camera.viewMatrix,
|
|
18942
|
-
this.camera.projectionMatrix
|
|
18943
|
-
[cam[0], cam[1], cam[2]]
|
|
18908
|
+
this.camera.projectionMatrix
|
|
18944
18909
|
);
|
|
18945
18910
|
}
|
|
18946
18911
|
const pass = this.renderer.beginFrame();
|
|
@@ -19133,11 +19098,6 @@ class App {
|
|
|
19133
19098
|
var _a2;
|
|
19134
19099
|
return ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) ?? false;
|
|
19135
19100
|
}
|
|
19136
|
-
setSkyboxAlignToGround(value) {
|
|
19137
|
-
if (this.skyboxRenderer) {
|
|
19138
|
-
this.skyboxRenderer.alignToGround = value;
|
|
19139
|
-
}
|
|
19140
|
-
}
|
|
19141
19101
|
// ============================================
|
|
19142
19102
|
// Gizmo(委托给 GizmoManager)
|
|
19143
19103
|
// ============================================
|