pmndrs / pmndrs/three-stdlib

RangeError: Maximum call stack size exceeded when exporting to gilt file using GLTFExporter

Open
#414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
858
Forks
144
PR merge metrics
No merged PRs in 30d

Description

  • @react-three/drei version: ^10.0.4
  • @react-three/fiber version: ^9.1.0
  • three-stdlib version: 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 GLTF button 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);
  });
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproducer, run npm install and npm run dev, then click the Download GLTF button to reproduce the RangeError. Trace GLTFExporter.parse through readAsDataURL and compare the provided implementation with the FileReader version. Done means exporting no longer exceeds the call stack and produces a GLTF file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, three.js
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.