three-stdlib
three-stdlib copied to clipboard
RangeError: Maximum call stack size exceeded when exporting to gilt file using GLTFExporter
@react-three/dreiversion: ^10.0.4@react-three/fiberversion: ^9.1.0three-stdlibversion: 2.35.14
Problem description:
I get an error when exporting to a gltf file using the following function.
- Components used:
GLTFExporter - Functions used:
parse
Relevant code:
sample: https://github.com/activeguild/gltfexporter-bug
npm install
npm run dev`
Download GLTFbutton clicked
Suggested solution:
before
async function readAsDataURL(blob) {
const buffer = await blob.arrayBuffer();
const data = btoa(String.fromCharCode(...new Uint8Array(buffer)));
return `data:${blob.type || ""};base64,${data}`;
}
after
async function readAsDataURL(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}