Hi again. Actually, I think you would be shooting the ray from camera to mesh. A “picking ray”… and that returns a “pickingInfo” or “pickInfo” object… which can contain some yummy info… such as faceID and distance to mesh surface, and maybe a face-normal. These things could be used to position and billboard the annotations.
Also, that mesh.getBoundingInfo().boundngBox is full of good boundingBox measurement values… both local and world space. I haven’t done much with boundingSpheres… though… totally dumb in that department… but a worthwhile pursuit. I’m glad you have some experience in these things… you seem to have good knowledge and have done this kind of thing before. (Forum helpers never know the experience levels of visitors, so people like me sort of “over-explain” a bit.) I did some of that to you… and you don’t need it… sorry about that.
Yeah, you’re on the right track and your code is looking good and interesting. (I’m pretty sure you’re a much better coder than I am.)
Yeah, investigate that darned pickingInfo object. You probably saw it mentioned in the raycast docs. It’s getNormal() method is useful. perhaps.
Have you tested billboardMode for mesh, yet? It will try to keep a plane orthogonal to line-of-view, but it gets a little unwieldy when the camera nears the poles (way up high, looking down at mesh, or vise-versa). Keep your camera near flat/equatorial (set upper/lower .beta limits on arcRotate cam, perhaps), and billboarding works pretty good.
You might also be interested in mesh.lookAt(something)… and similar. lookAt() needs to be inside the renderLoop… constantly refreshed… but it’s very tiny/fast code, under the hood. Having 20 mesh constantly looking-at camera.position or maybe looking-at camera.childedInvisibleMesh (that you created)… is easy, perf-wise. No problems. Vrooooom.
Be sure to forum-search, playground-search, docs-search, and old-forum-search… for some of these terms. These subjects have been talked-about often, especially billboarding’s slight z-spinning of the annotation plane… when the camera gets near polar positions.
dynamicTexture is a hot search term for you, too. It is/was the primary way to write text on a plane… before GUI 2D (and before the short-lived Canvas2D system) came along. An in-code playground search for dynamicTexture brings-back quite a good haul.
DynamicTextures are based-upon “Context 2d”… a system somewhat similar to SVG, if you know what that is. A draw-on-a-texture system.
AdvancedDynamicTextures (the GUI 2D system I love)… is also based-upon Context2d, of course. It’s a much fancier “layer” atop Context2d… than dynamcTextures. Both are fun and interesting. GUI 2d is much easier, especially in the “measuring” department, so I took more interest in that… than in dynamicTextures. DynamicTextures CAN be irritating… sometimes seemingly unpredictable… but not really. Ya just gotta know the Context 2D spec… well. Previous experience with SVG might help.
Ok, cool… ya got some leads, ya got some programming experience… I think you’ll be fartin’ thru silk in no-time. Welcome aboard. I think you should de-solution my post… and wait a bit longer… for better answers. By Monday/Tuesday… you may see some MUCH wiser comments. I’m more the BJS “forum clown” than I am wise-tech. I get the MOST fun from BabylonJS… when I do something weird and it crashes my browser. I love that. It means I’m properly demented.
“discretized” Cool word!