Issue raycasting to points on a rotating sphere

So I have a big sphere, and on that sphere I’ve stuck some little tiny spheres, right on the radius. I need to raycast to those little spheres and detect if they’re visible or not. The small spheres are added to the big sphere itself rather than the scene

I actually now have that working quite nicely, and it even works if I use orbit controls to move the sphere around, correctly detecting which points are in front and which behind, all great!

The issue comes when I add a rotation to the main sphere in my animation loop. It stops detecting correctly and all points are detected behind the sphere. A little investigation shows that the vector I’m getting to raycast to a given point with, that does not change with the planets rotation, but it does with orbit controls.

This is the code that works out that vector

this._camera.updateMatrixWorld();
var pos = mesh.position.clone();
pos.project(this._camera);
this.rayCaster.setFromCamera( pos, this._camera );
const intersects = this.rayCaster.intersectObjects( this._scene.children );
...

I’m guessing I’m missing some weird camera/scene/bigsphere.updateSomethingMatrixSomething but I’ve experimented a bit with those (with absolutely no understanding of what I’m doing) and getting nowhere!!

Any thoughts would be hugely appreciated!!

Heh, found the solution

this._camera.updateMatrixWorld();
const pos = new THREE.Vector3();
mesh.getWorldPosition(pos);
pos.project(this._camera);
this.rayCaster.setFromCamera( pos, this._camera );
const intersects = this.rayCaster.intersectObjects( this._scene.children );