Rendering mesh at a minimum size to ensure its visible and selectable

I’m having a hard time wrapping my head around the problem of rendering mesh at a minimum size to ensure its visible and selectable. The video shows what I want to achieve. Any suggestions?

Hello :slight_smile:

What you can do is set the scaling depending on distance to camera :

function setConstantSize(mesh, factor=1.0){
    scene.registerBeforeRender( e => {
        const d = factor*camera.position.subtract(mesh.position).length();
        mesh.scaling = new BABYLON.Vector3(d,d,d);
    })
}

:arrow_right: Playground

++
Tricotou

1 Like

Thanks buddy. That’s a start. The tricky part is stopping the automatic once the viewer reaches a certain minimum distance to the object.

Just add a Math.max on the distance :slight_smile:
:arrow_right: Playground

2 Likes

True. Should have had my morning coffee.