@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.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,29 +2139,7 @@ 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 alignGround = u.extra.x > 0.5;
|
|
2146
|
-
let camY = u.extra.z;
|
|
2147
|
-
|
|
2148
|
-
if (alignGround && dir.y < -0.001 && camY > 0.01) {
|
|
2149
|
-
let camX = u.extra.y;
|
|
2150
|
-
let camZ = u.extra.w;
|
|
2151
|
-
|
|
2152
|
-
let t = camY / (-dir.y);
|
|
2153
|
-
let gx = camX + dir.x * t;
|
|
2154
|
-
let gz = camZ + dir.z * t;
|
|
2155
|
-
|
|
2156
|
-
let scale = max(camY, 1.0) * 5.0;
|
|
2157
|
-
let groundDir = normalize(vec3<f32>(gx / max(scale, 0.01), -1.0, gz / max(scale, 0.01)));
|
|
2158
|
-
let groundColor = textureSample(cubeTexture, cubeSampler, groundDir);
|
|
2159
|
-
let skyColor = textureSample(cubeTexture, cubeSampler, dir);
|
|
2160
|
-
|
|
2161
|
-
let blend = smoothstep(0.0, -0.12, dir.y);
|
|
2162
|
-
return vec4<f32>(mix(skyColor.rgb, groundColor.rgb, blend), 1.0);
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
let color = textureSample(cubeTexture, cubeSampler, dir);
|
|
2142
|
+
let color = textureSample(cubeTexture, cubeSampler, normalize(input.dir));
|
|
2166
2143
|
return vec4<f32>(color.rgb, 1.0);
|
|
2167
2144
|
}
|
|
2168
2145
|
`
|
|
@@ -2174,18 +2151,17 @@ class SkyboxRenderer {
|
|
|
2174
2151
|
__publicField(this, "uniformBuffer");
|
|
2175
2152
|
__publicField(this, "sampler");
|
|
2176
2153
|
__publicField(this, "bindGroupLayout");
|
|
2177
|
-
__publicField(this, "uniformData", new Float32Array(
|
|
2154
|
+
__publicField(this, "uniformData", new Float32Array(12));
|
|
2178
2155
|
__publicField(this, "cubeTexture", null);
|
|
2179
2156
|
__publicField(this, "cubeBindGroup", null);
|
|
2180
2157
|
__publicField(this, "frameReady", false);
|
|
2181
|
-
__publicField(this, "alignToGround", true);
|
|
2182
2158
|
this.device = device;
|
|
2183
2159
|
const shaderModule = device.createShaderModule({ code: WGSL });
|
|
2184
2160
|
this.bindGroupLayout = device.createBindGroupLayout({
|
|
2185
2161
|
entries: [
|
|
2186
2162
|
{
|
|
2187
2163
|
binding: 0,
|
|
2188
|
-
visibility: GPUShaderStage.VERTEX
|
|
2164
|
+
visibility: GPUShaderStage.VERTEX,
|
|
2189
2165
|
buffer: { type: "uniform" }
|
|
2190
2166
|
},
|
|
2191
2167
|
{
|
|
@@ -2218,7 +2194,7 @@ class SkyboxRenderer {
|
|
|
2218
2194
|
}
|
|
2219
2195
|
});
|
|
2220
2196
|
this.uniformBuffer = device.createBuffer({
|
|
2221
|
-
size:
|
|
2197
|
+
size: 48,
|
|
2222
2198
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
2223
2199
|
});
|
|
2224
2200
|
this.sampler = device.createSampler({
|
|
@@ -2275,7 +2251,7 @@ class SkyboxRenderer {
|
|
|
2275
2251
|
});
|
|
2276
2252
|
this.cubeTexture = tex;
|
|
2277
2253
|
}
|
|
2278
|
-
prepareFrame(viewMatrix, projectionMatrix
|
|
2254
|
+
prepareFrame(viewMatrix, projectionMatrix) {
|
|
2279
2255
|
if (!this.isActive) {
|
|
2280
2256
|
this.frameReady = false;
|
|
2281
2257
|
return;
|
|
@@ -2293,17 +2269,6 @@ class SkyboxRenderer {
|
|
|
2293
2269
|
ud[9] = viewMatrix[9];
|
|
2294
2270
|
ud[10] = viewMatrix[10];
|
|
2295
2271
|
ud[11] = 0;
|
|
2296
|
-
if (this.alignToGround && cameraPosition) {
|
|
2297
|
-
ud[12] = 1;
|
|
2298
|
-
ud[13] = cameraPosition[0];
|
|
2299
|
-
ud[14] = cameraPosition[1];
|
|
2300
|
-
ud[15] = cameraPosition[2];
|
|
2301
|
-
} else {
|
|
2302
|
-
ud[12] = 0;
|
|
2303
|
-
ud[13] = 0;
|
|
2304
|
-
ud[14] = 0;
|
|
2305
|
-
ud[15] = 0;
|
|
2306
|
-
}
|
|
2307
2272
|
this.device.queue.writeBuffer(this.uniformBuffer, 0, ud);
|
|
2308
2273
|
this.frameReady = true;
|
|
2309
2274
|
}
|
|
@@ -18938,11 +18903,9 @@ class App {
|
|
|
18938
18903
|
this.updateAdaptivePerformance();
|
|
18939
18904
|
this.hotspotManager.updateBillboards();
|
|
18940
18905
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
18941
|
-
const cam = this.camera.position;
|
|
18942
18906
|
this.skyboxRenderer.prepareFrame(
|
|
18943
18907
|
this.camera.viewMatrix,
|
|
18944
|
-
this.camera.projectionMatrix
|
|
18945
|
-
[cam[0], cam[1], cam[2]]
|
|
18908
|
+
this.camera.projectionMatrix
|
|
18946
18909
|
);
|
|
18947
18910
|
}
|
|
18948
18911
|
const pass = this.renderer.beginFrame();
|
|
@@ -19135,11 +19098,6 @@ class App {
|
|
|
19135
19098
|
var _a2;
|
|
19136
19099
|
return ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) ?? false;
|
|
19137
19100
|
}
|
|
19138
|
-
setSkyboxAlignToGround(value) {
|
|
19139
|
-
if (this.skyboxRenderer) {
|
|
19140
|
-
this.skyboxRenderer.alignToGround = value;
|
|
19141
|
-
}
|
|
19142
|
-
}
|
|
19143
19101
|
// ============================================
|
|
19144
19102
|
// Gizmo(委托给 GizmoManager)
|
|
19145
19103
|
// ============================================
|