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