Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OctreeHelper: Add update(). #24641

Merged
merged 7 commits into from
Sep 19, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions examples/jsm/helpers/OctreeHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ class OctreeHelper extends LineSegments {

constructor( octree, color = 0xffff00 ) {

const geometry = new BufferGeometry();
super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );

this.octree = octree;
this.color = color;

this.type = 'OctreeHelper';

this.update();

}

update() {

const vertices = [];

function traverse( tree ) {
Expand Down Expand Up @@ -39,17 +53,9 @@ class OctreeHelper extends LineSegments {

}

traverse( octree.subTrees );

const geometry = new BufferGeometry();
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );

super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
traverse( this.octree.subTrees );

this.octree = octree;
this.color = color;

this.type = 'OctreeHelper';
this.geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down