Hi there, I’m trying to render “giftwrapped” objects from a pointcloud. The message has 10 objects with roughly 30 points from the result of a convexhull sort. It seems I can’t get the shapes to get outlined by the line loops individually- the line loop draws across all points. Effectively these should be like constantly updating bounding shapes from the lidar data. I can’t figure out how to get the mesh to understand that I want 10 objects, not one big blob.
Any insight in appreciated. This is my first post so forgive me if I’ve made any formatting errors!
grahamScanListener.subscribe((message) => {
let index = 0;
msgData = message;
for (let i = 0; i < message.grahamScanArray.length; i++) { //
for (let j = 0; j < message.grahamScanArray[i].objects.length; j++) {
positions[index++] = message.grahamScanArray[i].objects[j].x * scalingFactor;
positions[index++] = message.grahamScanArray[i].objects[j].y * scalingFactor;
positions[index++] = 5;
}
colors.push(1, 0, 0, 1);
}
lineGeometry.instanceCount = 1; // set so its initalized for dat.GUI, will be set in first draw otherwise
lineGeometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3).setDynamic(true));
lineGeometry.setAttribute('offset', new THREE.InstancedBufferAttribute(new Float32Array(offsets), 3));
lineGeometry.setAttribute('color', new THREE.InstancedBufferAttribute(new Float32Array(colors), 4));
pointGeometry.instanceCount = 1; // set so its initalized for dat.GUI, will be set in first draw otherwise
pointGeometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3).setDynamic(true));
pointGeometry.setAttribute('offset', new THREE.InstancedBufferAttribute(new Float32Array(offsets), 3));
pointGeometry.setAttribute('color', new THREE.InstancedBufferAttribute(new Float32Array(colors), 4));
const mesh = new THREE.Points(pointGeometry, material);
const lineMesh = new THREE.Line(lineGeometry, material);
group.add(mesh);
group.add(lineMesh);
});
scene.add(group);