* 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 <michael.herzog@human-interactive.org>
@@ -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 );