Skip to content

Commit 16d38d4

Browse files
Mugen87RuthySheffi
authored andcommitted
Octree: Improve configurability. (mrdoob#31097)
1 parent e397779 commit 16d38d4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/jsm/math/Octree.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ class Octree {
130130
*/
131131
this.layers = new Layers();
132132

133+
/**
134+
* The number of triangles a leaf can store before it is split.
135+
*
136+
* @type {number}
137+
* @default 8
138+
*/
139+
this.trianglesPerLeaf = 8;
140+
141+
/**
142+
* The maximum level of the Octree. It defines the maximum
143+
* hierarchical depth of the data structure.
144+
*
145+
* @type {number}
146+
* @default 16
147+
*/
148+
this.maxLevel = 16;
149+
133150
// private
134151

135152
this.subTrees = [];
@@ -231,7 +248,7 @@ class Octree {
231248

232249
const len = subTrees[ i ].triangles.length;
233250

234-
if ( len > 8 && level < 16 ) {
251+
if ( len > this.trianglesPerLeaf && level < this.maxLevel ) {
235252

236253
subTrees[ i ].split( level + 1 );
237254

0 commit comments

Comments
 (0)