Fix STL import feedback and rendering
This commit is contained in:
@@ -66,13 +66,14 @@
|
||||
|
||||
window.rovModel = {
|
||||
load(payload) {
|
||||
try {
|
||||
const bytes=Uint8Array.from(atob(payload.data),c=>c.charCodeAt(0));
|
||||
vertices=parseStl(bytes.buffer);stage.classList.add('model-loaded');
|
||||
document.querySelector('#model-style').disabled=false;
|
||||
document.querySelector('#model-file-name').textContent=payload.name;
|
||||
yaw=-.55;pitch=-.42;zoom=1;requestDraw();
|
||||
} catch (error) { window.showToast?.(error.message,true); }
|
||||
if (!payload?.data) throw new Error('The selected STL returned no mesh data');
|
||||
const binary=atob(payload.data),bytes=new Uint8Array(binary.length);
|
||||
for(let i=0;i<binary.length;i++)bytes[i]=binary.charCodeAt(i);
|
||||
vertices=parseStl(bytes.buffer);stage.classList.add('model-loaded');
|
||||
document.querySelector('#model-style').disabled=false;
|
||||
document.querySelector('#model-file-name').textContent=payload.name;
|
||||
yaw=-.55;pitch=-.42;zoom=1;requestDraw();
|
||||
return {name:payload.name,triangles:vertices.length/9};
|
||||
},
|
||||
toggleStyle() { edgesOnly=!edgesOnly;requestDraw();return edgesOnly; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user