I have two THREE.Points
objects in a three js scene. The scene starts showing all the points in the points1
object which works perfectly. The issue is that a user can type in a search string into the search
var using the dat.gui
library, and I want to show only the points they search for. I am doing this by creating a new vertex array for the pointsS
geometry and assigning it in my update function. points
disappears correctly on search, and I know that pointsS.geometry.vertices
contains the right values, but it never shows them in the scene. Is this kind of update possible? Excerpt from up update loop below.
Thanks!
searchVertices = [];
for (let i = 0; i < vertices.length; i++) {
let particle = vertices[i];
if (search !== "") {
let matchStr = particle.name;
let re = new RegExp(search, 'i');
if (matchStr.match(re)) {
searchVertices.push(particle);
}
}
}
if (search !== "") {
pointsS.geometry.vertices = searchVertices;
points1.visible = false;
} else {
points1.visible = true;
points1.geometry.verticesNeedUpdate = true;
pointsS.geometry.verticesNeedUpdate = true;
BufferGeometry
with avisible
attribute. If you don't care about efficiency, you can just create a new geometry each time, but I wouldn't recommend it. – WestLangley