Spaces:
Running
Running
Download src/meshpack.js from VectorW/xlerobot-sim: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/VectorW/xlerobot-sim/resolve/main/src/meshpack.js
- Command line
-
hf download hf://spaces/VectorW/xlerobot-sim/src/meshpack.js
-
curl -L -o meshpack.js https://huggingface.co/spaces/VectorW/xlerobot-sim/resolve/main/src/meshpack.js
1 kB
| // The model's meshes travel as one gzip file plus an index. The Space's static host sends files | |
| // uncompressed and redirects each request, so one 7.5 MB request replaces 33 files of 19 MB. | |
| // Used in the browser and in Node (tools/), which both provide DecompressionStream. | |
| /** Decompress gzip bytes. Bytes without the gzip magic number are returned as they are: some | |
| * servers (Vite's preview, for one) send .gz files with Content-Encoding: gzip, and the browser | |
| * has already inflated them. */ | |
| export async function gunzip(bytes) { | |
| if (bytes[0] !== 0x1f || bytes[1] !== 0x8b) return bytes; | |
| const stream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("gzip")); | |
| return new Uint8Array(await new Response(stream).arrayBuffer()); | |
| } | |
| /** Split an unpacked mesh file into [name, bytes] pairs, from index entries [name, offset, length]. */ | |
| export function unpack(bytes, index) { | |
| return index.map(([name, offset, length]) => [name, bytes.subarray(offset, offset + length)]); | |
| } | |