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