Просмотр исходного кода

Fix: prevent crash when calling BufferGeometry.setFromPoints with too 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 <michael.herzog@human-interactive.org>
Dan Rose 1 год назад
Родитель
Сommit
add7f9ba79
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/core/BufferGeometry.js

+ 3 - 1
src/core/BufferGeometry.js

@@ -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 );

粤ICP备19079148号