@d5techs/3dgs-lib 1.4.53 → 1.4.54
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 +20 -3
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +20 -3
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -2183,6 +2183,18 @@ function decodeScanline(bytes, pos, width) {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
return { pixels, newPos: pos };
|
|
2185
2185
|
}
|
|
2186
|
+
const f32Buf = new Float32Array(1);
|
|
2187
|
+
const u32Buf = new Uint32Array(f32Buf.buffer);
|
|
2188
|
+
function float32ToFloat16(val) {
|
|
2189
|
+
f32Buf[0] = val;
|
|
2190
|
+
const f = u32Buf[0];
|
|
2191
|
+
const sign = f >> 16 & 32768;
|
|
2192
|
+
const exp = (f >> 23 & 255) - 127 + 15;
|
|
2193
|
+
const frac = f >> 13 & 1023;
|
|
2194
|
+
if (exp <= 0) return sign;
|
|
2195
|
+
if (exp >= 31) return sign | 31744;
|
|
2196
|
+
return sign | exp << 10 | frac;
|
|
2197
|
+
}
|
|
2186
2198
|
const CUBE_WGSL = (
|
|
2187
2199
|
/* wgsl */
|
|
2188
2200
|
`
|
|
@@ -2331,15 +2343,20 @@ class SkyboxRenderer {
|
|
|
2331
2343
|
async loadEquirectangular(url) {
|
|
2332
2344
|
this.clear();
|
|
2333
2345
|
const hdr = await loadHdr(url);
|
|
2346
|
+
const pixelCount = hdr.width * hdr.height * 4;
|
|
2347
|
+
const f16 = new Uint16Array(pixelCount);
|
|
2348
|
+
for (let i = 0; i < pixelCount; i++) {
|
|
2349
|
+
f16[i] = float32ToFloat16(hdr.data[i]);
|
|
2350
|
+
}
|
|
2334
2351
|
const tex = this.device.createTexture({
|
|
2335
2352
|
size: [hdr.width, hdr.height],
|
|
2336
|
-
format: "
|
|
2353
|
+
format: "rgba16float",
|
|
2337
2354
|
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
2338
2355
|
});
|
|
2339
2356
|
this.device.queue.writeTexture(
|
|
2340
2357
|
{ texture: tex },
|
|
2341
|
-
|
|
2342
|
-
{ bytesPerRow: hdr.width *
|
|
2358
|
+
f16.buffer,
|
|
2359
|
+
{ bytesPerRow: hdr.width * 8, rowsPerImage: hdr.height },
|
|
2343
2360
|
{ width: hdr.width, height: hdr.height }
|
|
2344
2361
|
);
|
|
2345
2362
|
this.bindGroup = this.device.createBindGroup({
|