Răsfoiți Sursa

Octree: Improve configurability. (#31097)

Michael Herzog 8 luni în urmă
părinte
comite
9a1f4da602
1 a modificat fișierele cu 18 adăugiri și 1 ștergeri
  1. 18 1
      examples/jsm/math/Octree.js

+ 18 - 1
examples/jsm/math/Octree.js

@@ -130,6 +130,23 @@ class Octree {
 		 */
 		this.layers = new Layers();
 
+		/**
+		 * The number of triangles a leaf can store before it is split.
+		 *
+		 * @type {number}
+		 * @default 8
+		 */
+		this.trianglesPerLeaf = 8;
+
+		/**
+		 * The maximum level of the Octree. It defines the maximum
+		 * hierarchical depth of the data structure.
+		 *
+		 * @type {number}
+		 * @default 16
+		 */
+		this.maxLevel = 16;
+
 		// private
 
 		this.subTrees = [];
@@ -231,7 +248,7 @@ class Octree {
 
 			const len = subTrees[ i ].triangles.length;
 
-			if ( len > 8 && level < 16 ) {
+			if ( len > this.trianglesPerLeaf && level < this.maxLevel ) {
 
 				subTrees[ i ].split( level + 1 );
 

粤ICP备19079148号