`mergeBufferGeometries` give error for empty array
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 858
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
threeversion: 0.160@types/threeversion:three-stdlibversion:
Problem description:
mergeBufferGeometries gives error Uncaught TypeError: Cannot read properties of undefined (reading 'index')
It is from some sloppy list access
which also exists in three.js upstream
Relevant code:
Suggested solution:
I generally would return some reasonable identity object for such cases than raising sloppy errors.
Maybe null can be reasonable.
Or otherwise, it may be useful to denote the types as [BufferGeometry, ...BufferGeometry[]] instead of BufferGeometry[],
where typescript can just warn users that users should pass array with at least one element.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/utils/BufferGeometryUtils.ts at mergeBufferGeometries and reproduce the empty-array call that triggers the undefined-index TypeError. Compare the linked upstream three.js implementation, settle the intended empty-input behavior, and ensure the runtime behavior and TypeScript signature consistently communicate that result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- threejs, typescript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100