I have a point in space express a vector in a three js viewer. Attached to this point there is an "HTML annotation"
that I would like to hide when the point is not visible (behind other surfaces of the same mesh or hidden by other meshes). For example in the image below it should be hidden:
I am using some code to check to see if the annotation is in the frustum as suggested in another question but this does not quite work as the annotation disappear only when I rotate the object quite dramatically. See picture below:
Can you help me to solve my problem?
Here my code so far:
const vector = new THREE.Vector3(x, y, z);
this.aCamera.updateMatrix();
this.aCamera.updateMatrixWorld(true);
let frustum = new THREE.Frustum();
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(this.aCamera.projectionMatrix, this.aCamera.matrixWorldInverse));
// check if annotation is in view
if (frustum.containsPoint(vector)) {
anAnnotation.css({opacity: 0});
} else {
anAnnotation.css({opacity: 1});
}