I have created the hotspot/annotation but I can’t find a logic to detect a marker if it goes behind the camera’s field of view
So I have tried a couple of methods already
Based on distance between hotspot and camera didn’t work
Angle between normal of hotspot and camera didn’t work
Using raycasters is computationally heavy and hard to work with
the scene just has a GLTF and hotspots and camera
So I made render of GLTF to 1000
and hotspot to 1100
and set the depthTest of marker to false so that marker is rendered ontop of model
set depth test to false to always render the hotspot / disable depth write
in the shader, compare the current depth with the one in the zbuffer (thanks to the depth rendering): set the alpha value of the final color depending on the test (for eg, 1.0 if current depth < z in zbuffer, else 0.3)
Here’s an example. It’s not done in threejs, but it should be easy to port the code.
If the depth in the depth rendering is stored as a linear depth (I don’t know how Threejs does it), here’s a modified sample.
all it does is simply draws the slightly transparent copy of a cube (marker) on top of everything. when not occluded, it draws on top of itself but since it is identical, the result does not change.
@looeee IIRC sprites system was attached to 3js by a duct tape so I am not surprised that something does not work in that department. so, again, I would just use some hack like this https://jsfiddle.net/x8L1nwfh/ but this is now 3rd time, not making any more fiddles here
Sprites will make it easier to have the marker facing towards the camera, which is probably what you want.
Then you can use a transparent PNG to the make the sprite a circle - an abnoxious smiley in my example (sorry about that, it was just the first round transparent image I found on imgur ), but to create markers with numbers in them you could either have a number of pre-made PNG files, or use canvas2D to generate the images on the fly.
@prisoner849 holy smokes you gotta see this: <model-viewer> Interactive Example check add/remove hotspot bottom left then click anywhere in the scene to add the hotspot - thanks @donmccurdy for sharing, absolutely awesome sauce!