Need help with this script, for making meshes clickable

It’s because gltf/glb files are right handed but Babylon is left handed by default.

Set scene.useRightHandedSystem = true; just after scene creation to correct this.

cellA (cell alpha) is how much alpha each facet has.

Did you get this working?

Thanks it’s working now. do you know if I can make outline colour glow?

            mesh.outlineColor = BABYLON.Color3.White();

is it possible to have random wireframe colour for all meshes in the scene?

        for (var i = 0; i <= scene.meshes.length; i++) {
            var mesh = scene.meshes[i];
            barycentric(mesh)
            mesh.material = shaderMaterial;

maybe shaderMaterial.clone()
then mesh.material.onBindObservable.add(()=>{
mesh.material.set what ever
})

how do I turn the wireframe shader on off?

var mouseOverUnit = function (scene) {

    console.log("mouse over" + scene.meshUnderPointer.id);

    console.log(scene);

    if (scene.meshUnderPointer !== null) {

        barycentric(scene.meshUnderPointer)

        scene.meshUnderPointer.material = shaderMaterial;


    }

}

var mouseOutUnit = function (scene) {

    console.log("mouse out" + scene.meshUnderPointer.id);

    console.log(scene);

    if (scene.meshUnderPointer !== null) {

    }

mesh.material = null

I exported the file as glb, the model comes with materials in babylon scene, what code should I write to make the material return to original state when mouse is not over the model? also, I am still getting some triangles with this shader, anything I can tweak to get rid of them?

I think a repro in the Playground would help here.

1 Like

sorry, I can’t share this online. about the wireframe shader, I am still getting some triangles with this shader, anything I can tweak to get rid of them?

If you speak about the shader from @Pryme8, sometimes only triangles can be rendered because of the geometry: see the corner of the pillar in https://www.babylonjs-playground.com/#G3GZA1#162.

i see, alright then. Thank you

is it possible to add a slider to adjust the value of needAlphaBlending? instead of true or false?

No, needAlphaBlending is there to indicate if a material is transparent or not. If it is transparent, you can use the alpha property of the material to make it more or less transparent (if it is a standard or PBR material). You can also use the mesh.visibility property which ranges from 0 to 1.

1 Like