@d5techs/3dgs-lib 1.4.50 → 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 +6 -48
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +6 -48
- 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,29 +2137,7 @@ 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 alignGround = u.extra.x > 0.5;
|
|
2144
|
-
let camY = u.extra.z;
|
|
2145
|
-
|
|
2146
|
-
if (alignGround && dir.y < -0.001 && camY > 0.01) {
|
|
2147
|
-
let camX = u.extra.y;
|
|
2148
|
-
let camZ = u.extra.w;
|
|
2149
|
-
|
|
2150
|
-
let t = camY / (-dir.y);
|
|
2151
|
-
let gx = camX + dir.x * t;
|
|
2152
|
-
let gz = camZ + dir.z * t;
|
|
2153
|
-
|
|
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
|
-
let groundColor = textureSample(cubeTexture, cubeSampler, groundDir);
|
|
2157
|
-
let skyColor = textureSample(cubeTexture, cubeSampler, dir);
|
|
2158
|
-
|
|
2159
|
-
let blend = smoothstep(0.0, -0.12, dir.y);
|
|
2160
|
-
return vec4<f32>(mix(skyColor.rgb, groundColor.rgb, blend), 1.0);
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
let color = textureSample(cubeTexture, cubeSampler, dir);
|
|
2140
|
+
let color = textureSample(cubeTexture, cubeSampler, normalize(input.dir));
|
|
2164
2141
|
return vec4<f32>(color.rgb, 1.0);
|
|
2165
2142
|
}
|
|
2166
2143
|
`
|
|
@@ -2172,18 +2149,17 @@ class SkyboxRenderer {
|
|
|
2172
2149
|
__publicField(this, "uniformBuffer");
|
|
2173
2150
|
__publicField(this, "sampler");
|
|
2174
2151
|
__publicField(this, "bindGroupLayout");
|
|
2175
|
-
__publicField(this, "uniformData", new Float32Array(
|
|
2152
|
+
__publicField(this, "uniformData", new Float32Array(12));
|
|
2176
2153
|
__publicField(this, "cubeTexture", null);
|
|
2177
2154
|
__publicField(this, "cubeBindGroup", null);
|
|
2178
2155
|
__publicField(this, "frameReady", false);
|
|
2179
|
-
__publicField(this, "alignToGround", true);
|
|
2180
2156
|
this.device = device;
|
|
2181
2157
|
const shaderModule = device.createShaderModule({ code: WGSL });
|
|
2182
2158
|
this.bindGroupLayout = device.createBindGroupLayout({
|
|
2183
2159
|
entries: [
|
|
2184
2160
|
{
|
|
2185
2161
|
binding: 0,
|
|
2186
|
-
visibility: GPUShaderStage.VERTEX
|
|
2162
|
+
visibility: GPUShaderStage.VERTEX,
|
|
2187
2163
|
buffer: { type: "uniform" }
|
|
2188
2164
|
},
|
|
2189
2165
|
{
|
|
@@ -2216,7 +2192,7 @@ class SkyboxRenderer {
|
|
|
2216
2192
|
}
|
|
2217
2193
|
});
|
|
2218
2194
|
this.uniformBuffer = device.createBuffer({
|
|
2219
|
-
size:
|
|
2195
|
+
size: 48,
|
|
2220
2196
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
2221
2197
|
});
|
|
2222
2198
|
this.sampler = device.createSampler({
|
|
@@ -2273,7 +2249,7 @@ class SkyboxRenderer {
|
|
|
2273
2249
|
});
|
|
2274
2250
|
this.cubeTexture = tex;
|
|
2275
2251
|
}
|
|
2276
|
-
prepareFrame(viewMatrix, projectionMatrix
|
|
2252
|
+
prepareFrame(viewMatrix, projectionMatrix) {
|
|
2277
2253
|
if (!this.isActive) {
|
|
2278
2254
|
this.frameReady = false;
|
|
2279
2255
|
return;
|
|
@@ -2291,17 +2267,6 @@ class SkyboxRenderer {
|
|
|
2291
2267
|
ud[9] = viewMatrix[9];
|
|
2292
2268
|
ud[10] = viewMatrix[10];
|
|
2293
2269
|
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
2270
|
this.device.queue.writeBuffer(this.uniformBuffer, 0, ud);
|
|
2306
2271
|
this.frameReady = true;
|
|
2307
2272
|
}
|
|
@@ -18936,11 +18901,9 @@ class App {
|
|
|
18936
18901
|
this.updateAdaptivePerformance();
|
|
18937
18902
|
this.hotspotManager.updateBillboards();
|
|
18938
18903
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
18939
|
-
const cam = this.camera.position;
|
|
18940
18904
|
this.skyboxRenderer.prepareFrame(
|
|
18941
18905
|
this.camera.viewMatrix,
|
|
18942
|
-
this.camera.projectionMatrix
|
|
18943
|
-
[cam[0], cam[1], cam[2]]
|
|
18906
|
+
this.camera.projectionMatrix
|
|
18944
18907
|
);
|
|
18945
18908
|
}
|
|
18946
18909
|
const pass = this.renderer.beginFrame();
|
|
@@ -19133,11 +19096,6 @@ class App {
|
|
|
19133
19096
|
var _a2;
|
|
19134
19097
|
return ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) ?? false;
|
|
19135
19098
|
}
|
|
19136
|
-
setSkyboxAlignToGround(value) {
|
|
19137
|
-
if (this.skyboxRenderer) {
|
|
19138
|
-
this.skyboxRenderer.alignToGround = value;
|
|
19139
|
-
}
|
|
19140
|
-
}
|
|
19141
19099
|
// ============================================
|
|
19142
19100
|
// Gizmo(委托给 GizmoManager)
|
|
19143
19101
|
// ============================================
|