Browse Source

ConvexGeometry: Support clone(). (#23177)

Michael Herzog 3 năm trước cách đây
mục cha
commit
0f19a3ec42
2 tập tin đã thay đổi với 8 bổ sung14 xóa
  1. 1 1
      examples/jsm/geometries/ConvexGeometry.js
  2. 7 13
      examples/jsm/math/ConvexHull.js

+ 1 - 1
examples/jsm/geometries/ConvexGeometry.js

@@ -6,7 +6,7 @@ import { ConvexHull } from '../math/ConvexHull.js';
 
 class ConvexGeometry extends BufferGeometry {
 
-	constructor( points ) {
+	constructor( points = [] ) {
 
 		super();
 

+ 7 - 13
examples/jsm/math/ConvexHull.js

@@ -46,28 +46,22 @@ class ConvexHull {
 
 	setFromPoints( points ) {
 
-		if ( Array.isArray( points ) !== true ) {
+		// The algorithm needs at least four points.
 
-			console.error( 'THREE.ConvexHull: Points parameter is not an array.' );
+		if ( points.length >= 4 ) {
 
-		}
-
-		if ( points.length < 4 ) {
-
-			console.error( 'THREE.ConvexHull: The algorithm needs at least four points.' );
+			this.makeEmpty();
 
-		}
+			for ( let i = 0, l = points.length; i < l; i ++ ) {
 
-		this.makeEmpty();
+				this.vertices.push( new VertexNode( points[ i ] ) );
 
-		for ( let i = 0, l = points.length; i < l; i ++ ) {
+			}
 
-			this.vertices.push( new VertexNode( points[ i ] ) );
+			this.compute();
 
 		}
 
-		this.compute();
-
 		return this;
 
 	}