Is there a way to select a point of the splat? i imagine for example a way to insert a hotspot. is collision with splat points handled?
As usual…thanks a lot!!
Is there a way to select a point of the splat? i imagine for example a way to insert a hotspot. is collision with splat points handled?
As usual…thanks a lot!!
cc @ryantrem as I guess some work was done for hotspots and I wonder if it could be reused here ?
This seems to work:
scene.onPointerObservable.add((pointerInfo) => {
if (pointerInfo.type === BABYLON.PointerEventTypes.POINTERPICK) {
const pickResult = scene.pick(scene.pointerX, scene.pointerY);
if (pickResult.hit) {
console.log("Hit point:", pickResult.pickedPoint);
console.log("Hit mesh:", pickResult.pickedMesh);
}
}
});
Gaussian Splatting | Babylon.js Playground
ChatGPT
Yes, selecting a point (or splat) from a Gaussian Splatting Mesh in Babylon.js requires interaction techniques that depend on how the Gaussian Splatting Mesh is implemented. Here’s a step-by-step outline to achieve this:
Gaussian Splatting Meshes typically render points or splats as Gaussian blobs in 3D space. The interaction logic will depend on whether the splats are:
Babylon.js supports raycasting for mesh selection. If the splats are implemented as part of a mesh, you can use Babylon’s Scene.pick
or Scene.pickWithRay
methods to detect which part of the mesh (or which vertex) the user is interacting with.
// Create a pointer observable for mouse clicks
scene.onPointerObservable.add((pointerInfo) => {
if (pointerInfo.type === BABYLON.PointerEventTypes.POINTERPICK) {
const pickResult = scene.pick(scene.pointerX, scene.pointerY);
if (pickResult.hit) {
console.log("Hit point:", pickResult.pickedPoint);
console.log("Hit mesh:", pickResult.pickedMesh);
}
}
});
pickResult.pickedMesh
is the Gaussian Splatting Mesh, use additional data structures (like vertex buffers or custom shaders) to identify the specific splat.If the splats are GPU-rendered without explicit mesh geometry (e.g., using custom shaders or textures), you may need to implement:
const ray = scene.createPickingRay(scene.pointerX, scene.pointerY, BABYLON.Matrix.Identity(), camera);
// Iterate over splats' positions
splatPositions.forEach((position, index) => {
const distance = BABYLON.Vector3.Distance(ray.origin, position);
if (distance < splatSize) {
console.log("Selected splat index:", index);
}
});
For high-performance applications:
engine.readPixels
to get the ID.To visualize splats for debugging, you can add bounding spheres or small markers to each splat position, making it easier to see what is selected.
splatPositions.forEach((position) => {
const sphere = BABYLON.MeshBuilder.CreateSphere("marker", { diameter: 0.1 }, scene);
sphere.position = position;
sphere.material = new BABYLON.StandardMaterial("markerMat", scene);
sphere.material.diffuseColor = new BABYLON.Color3(1, 0, 0); // Red
});
If you provide more details about your Gaussian Splatting implementation, I can tailor the solution further!
Thank you!
I’ll try it
Gaussian Splatting mesh has a bounding volume information. So 1st level of picking is possible (you can check the picking with the Inspector and you can pick GS). But getting more precision like picking individual splat is more difficult because of the amount of them. A CPU solution involves computing individual volume and testing each one. This can be daunting when your GS is made of million of individual splats. But because each splat is semi transparent, using a GPU solution with 2D buffer (rasterizing each individual splat with some ID per splat instead of a color) may not return perfect solution.
ChatGPU explains it better with far more details
splatPositions.forEach((position) => {
const sphere = BABYLON.MeshBuilder.CreateSphere("marker", { diameter: 0.1 }, scene);
Valid in theory, not in practice