function drawQuad(quad) {
const toDelete = scene.getObjectByName("currentQuad");
if (toDelete) {
scene.remove(toDelete);
}
const geometry = new THREE.BufferGeometry();
const res = params.clusterGridResolution;
const from = { x: quad.x * res - res, z: quad.z * res - res };
const to = { x: quad.x * res, z: quad.z * res };
const vertices = new Float32Array([
from.x,
0,
from.z,
to.x,
0,
from.z,
to.x,
0,
to.z,
to.x,
0,
to.z,
from.x,
0,
to.z,
from.x,
0,
from.z
]);
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const material = new THREE.MeshBasicMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
opacity: 0.6,
transparent: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.name = "currentQuad";
scene.add(mesh);
return vertices;
}