[Example Project] (https://holonext.io/api/v1/scene/holonextViewer/6299f72d967706c1fcb89524)
Hi, we are trying to raycasting object and camera to detect is any other mesh exist between mesh and our object .if other mesh exist we are decreasing opacity(alpha) of object. Every camera movement we have to check situation and it causes to fps problems.
const checkMeshisVisible = (mesh) => {
let hitFlag = false;
if (mesh) {
let ray = BABYLON.Ray.CreateNewFromTo(
scene.cameras[0].position,
mesh.position
);
var hits = scene.multiPickWithRay(ray);
if (hits) {
for (var i = 0; i < hits.length; i++) {
if (hits[i].pickedMesh.name != "BackgroundPlane") {
// discard ground plane
hitFlag = true;
}
}
}
const picked = scene.pickWithRay(ray);
titleList.forEach((annoMesh) => {
if (hitFlag && annoMesh._linkedMesh.name == mesh.name) {
annoMesh.alpha = 0.7;
} else if (annoMesh._linkedMesh.name == mesh.name) {
annoMesh.alpha = 1;
}
});
}
};
scene.onPointerMove = (e) => {
fakeMeshList.forEach((meshName) => {
let mesh = scene.getMeshByName(meshName + "-fake-mesh");
checkMeshisVisible(mesh);
});
};
}
here is the some part of code is there any way to optimize this render condition?