@d5techs/3dgs-lib 1.4.39 → 1.4.41
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 +24 -9
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +24 -9
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/SkyboxRenderer.d.ts +9 -1
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -2109,7 +2109,8 @@ fn vs(@builtin(vertex_index) vi: u32) -> VSOut {
|
|
|
2109
2109
|
|
|
2110
2110
|
@fragment
|
|
2111
2111
|
fn fs(input: VSOut) -> @location(0) vec4<f32> {
|
|
2112
|
-
|
|
2112
|
+
let color = textureSample(cubeTexture, cubeSampler, normalize(input.dir));
|
|
2113
|
+
return vec4<f32>(color.rgb, 1.0);
|
|
2113
2114
|
}
|
|
2114
2115
|
`
|
|
2115
2116
|
);
|
|
@@ -2129,6 +2130,7 @@ class SkyboxRenderer {
|
|
|
2129
2130
|
__publicField(this, "scratchInv", new Float32Array(16));
|
|
2130
2131
|
__publicField(this, "cubeTexture", null);
|
|
2131
2132
|
__publicField(this, "cubeBindGroup", null);
|
|
2133
|
+
__publicField(this, "uniformDirty", false);
|
|
2132
2134
|
this.device = device;
|
|
2133
2135
|
this.format = format;
|
|
2134
2136
|
this.depthFormat = depthFormat;
|
|
@@ -2212,7 +2214,7 @@ class SkyboxRenderer {
|
|
|
2212
2214
|
dimension: "2d",
|
|
2213
2215
|
size: [width, height, 6],
|
|
2214
2216
|
format: "rgba8unorm",
|
|
2215
|
-
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
2217
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
|
|
2216
2218
|
});
|
|
2217
2219
|
for (let layer = 0; layer < 6; layer++) {
|
|
2218
2220
|
this.device.queue.copyExternalImageToTexture(
|
|
@@ -2234,19 +2236,28 @@ class SkyboxRenderer {
|
|
|
2234
2236
|
this.cubeTexture = tex;
|
|
2235
2237
|
this.cubeBindGroup = bindGroup;
|
|
2236
2238
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2239
|
+
/**
|
|
2240
|
+
* Must be called BEFORE beginFrame() to write uniform data outside the render pass.
|
|
2241
|
+
*/
|
|
2242
|
+
prepareFrame(viewMatrix, projectionMatrix) {
|
|
2243
|
+
if (!this.isActive) return;
|
|
2241
2244
|
this.scratchViewNoTrans.set(viewMatrix);
|
|
2242
2245
|
this.scratchViewNoTrans[12] = 0;
|
|
2243
2246
|
this.scratchViewNoTrans[13] = 0;
|
|
2244
2247
|
this.scratchViewNoTrans[14] = 0;
|
|
2245
2248
|
SkyboxRenderer.multiplyMat4(this.scratchVp, projectionMatrix, this.scratchViewNoTrans);
|
|
2246
2249
|
if (!SkyboxRenderer.invertMat4(this.scratchInv, this.scratchVp)) {
|
|
2250
|
+
this.uniformDirty = false;
|
|
2247
2251
|
return;
|
|
2248
2252
|
}
|
|
2249
2253
|
this.device.queue.writeBuffer(this.uniformBuffer, 0, this.scratchInv);
|
|
2254
|
+
this.uniformDirty = true;
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Draw the skybox into the given render pass. Call prepareFrame() first.
|
|
2258
|
+
*/
|
|
2259
|
+
draw(pass) {
|
|
2260
|
+
if (!this.uniformDirty || !this.cubeBindGroup) return;
|
|
2250
2261
|
pass.setPipeline(this.pipeline);
|
|
2251
2262
|
pass.setBindGroup(0, this.cubeBindGroup);
|
|
2252
2263
|
pass.draw(3);
|
|
@@ -2257,6 +2268,7 @@ class SkyboxRenderer {
|
|
|
2257
2268
|
this.cubeTexture = null;
|
|
2258
2269
|
}
|
|
2259
2270
|
this.cubeBindGroup = null;
|
|
2271
|
+
this.uniformDirty = false;
|
|
2260
2272
|
}
|
|
2261
2273
|
destroy() {
|
|
2262
2274
|
this.clear();
|
|
@@ -18904,14 +18916,17 @@ class App {
|
|
|
18904
18916
|
}
|
|
18905
18917
|
}
|
|
18906
18918
|
render() {
|
|
18907
|
-
var _a2;
|
|
18919
|
+
var _a2, _b2;
|
|
18908
18920
|
this.camera.setAspect(this.renderer.getAspectRatio());
|
|
18909
18921
|
this.controls.update();
|
|
18910
18922
|
this.updateAdaptivePerformance();
|
|
18911
18923
|
this.hotspotManager.updateBillboards();
|
|
18912
|
-
const pass = this.renderer.beginFrame();
|
|
18913
18924
|
if ((_a2 = this.skyboxRenderer) == null ? void 0 : _a2.isActive) {
|
|
18914
|
-
this.skyboxRenderer.
|
|
18925
|
+
this.skyboxRenderer.prepareFrame(this.camera.viewMatrix, this.camera.projectionMatrix);
|
|
18926
|
+
}
|
|
18927
|
+
const pass = this.renderer.beginFrame();
|
|
18928
|
+
if ((_b2 = this.skyboxRenderer) == null ? void 0 : _b2.isActive) {
|
|
18929
|
+
this.skyboxRenderer.draw(pass);
|
|
18915
18930
|
}
|
|
18916
18931
|
const gsRenderer = this.sceneManager.getGSRenderer();
|
|
18917
18932
|
if (gsRenderer) {
|