Skip to content

Commit

Permalink
Fix: prevent crash when calling BufferGeometry.setFromPoints with too…
Browse files Browse the repository at this point in the history
… few points (#29956)

* Fix: prevent crash when calling BufferGeometry.setFromPoints with too few points

* lint

* Update BufferGeometry.js

Clean up.

* Update BufferGeometry.js

Clean up.

---------

Co-authored-by: Michael Herzog <[email protected]>
  • Loading branch information
rotu and Mugen87 authored Nov 25, 2024
1 parent 4cc2eb5 commit add7f9b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/BufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ class BufferGeometry extends EventDispatcher {

} else {

for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
const l = Math.min( points.length, positionAttribute.count ); // make sure data do not exceed buffer size

for ( let i = 0; i < l; i ++ ) {

const point = points[ i ];
positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
Expand Down

0 comments on commit add7f9b

Please sign in to comment.