Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Fetch funny
Browse files Browse the repository at this point in the history
  • Loading branch information
cjavad committed Oct 25, 2022
1 parent 3e0b323 commit 58f7b22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simplyprint/stlviewer",
"version": "0.0.4",
"version": "0.0.5",
"description": "Javascript STL/OBJ 3D files Viewer",
"source": "src/StlViewer.js",
"targets": {
Expand Down
16 changes: 1 addition & 15 deletions src/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,7 @@ function download_from_local_xhr(filename) {

async function download_from_local_fetch(filename) {
const response = await fetch(filename);
const reader = response.body.getReader();
const total = Number(response.headers.get('content-length'));
const chunksAll = new Uint8Array(total);
let position = 0
while (true) {
const { done, value } = await reader.read()
if (done) break;
if (!value) continue;
chunksAll.set(value, position);
position += value.length;
if (get_progress) {
postMessage({ msg_type: MSG_LOAD_IN_PROGRESS, id: model_id, loaded: position, total: total });
}
}
after_file_load(chunksAll.buffer)
after_file_load(await response.arrayBuffer());
}

function after_file_load(s) {
Expand Down

0 comments on commit 58f7b22

Please sign in to comment.