|
@@ -9,6 +9,19 @@ class OctreeHelper extends LineSegments {
|
|
|
|
|
|
constructor( octree, color = 0xffff00 ) {
|
|
|
|
|
|
+ super( new BufferGeometry(), new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
|
|
+
|
|
|
+ this.octree = octree;
|
|
|
+ this.color = color;
|
|
|
+
|
|
|
+ this.type = 'OctreeHelper';
|
|
|
+
|
|
|
+ this.update();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ update() {
|
|
|
+
|
|
|
const vertices = [];
|
|
|
|
|
|
function traverse( tree ) {
|
|
@@ -39,20 +52,21 @@ class OctreeHelper extends LineSegments {
|
|
|
|
|
|
}
|
|
|
|
|
|
- traverse( octree.subTrees );
|
|
|
+ traverse( this.octree.subTrees );
|
|
|
|
|
|
- const geometry = new BufferGeometry();
|
|
|
- geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
|
+ this.geometry.dispose();
|
|
|
|
|
|
- super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
|
|
+ this.geometry = new BufferGeometry();
|
|
|
+ this.geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
|
|
|
|
- this.octree = octree;
|
|
|
- this.color = color;
|
|
|
+ }
|
|
|
|
|
|
- this.type = 'OctreeHelper';
|
|
|
+ dispose() {
|
|
|
|
|
|
- }
|
|
|
+ this.geometry.dispose();
|
|
|
+ this.material.dispose();
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export { OctreeHelper };
|