Hey guys,
I've added every vertex of my terrain mesh into an octree so I can quickly pick which vertices are around me while moving. Issue is it's insanely laggy and I'm not sure why. There are tons of octree examples where it improves performance.
My project is in Three.js, I'm using threeoctree library provided by the developer. BufferGeometry doesn't have an array of vertices so I build it from the positions.
var vertices = Array();
for(var i = 0; i < 100309; i++) {
var vertex = new THREE.Vector3();
vertex.x = node.geometry.getAttribute("position").array[(i*3)]*that.world_scale;
vertex.y = node.geometry.getAttribute("position").array[(i*3)+1]*that.world_scale;
vertex.z = node.geometry.getAttribute("position").array[(i*3)+2]*that.world_scale;
vertices.push(vertex);
}
console.log(vertices);
node.geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3,true) );
node.geometry.vertices = vertices;
that.octree.add(node,{useVertices:true});
I feel like 100k vertices in an octree shouldn't be causing that much of an issue, after adding the vertices into the octree and updating the octree in the loop Im hovering at about 20fps. I have an i7-8700k and GTX1080. I don't think this should be lagging.
Should I be using an octree library that ignores the mesh/rendering completely?
Thanks