Orbiting Sphere Around a Rotating Mesh in Three.js (original) (raw)

Currently, there are meshes on the scene, and all of them are not set in any parent-child relationship.
All of them are located at the origin and are being rotated using rotateY().
They are also not in a parent-child relationship with the sphere geometry.
I tried to make them into a parent-child relationship, but it did not work.
I want the sphere geometry to orbit around one specific mesh on the scene, like a satellite, following the rotation of that mesh.
I don’t know the specific way to achieve this, so please tell me.

This is called within the [drag] event of DragControls:

// Rotate the meshes
for (const mesh of this.meshs) {
    if (rotateType === TruckModelRotateType.RIGHT) {
        mesh.rotateY(0.01);
    } else {
        mesh.rotateY(-0.01);
    }
}

type or paste code here

type or paste code here

Oxyn May 6, 2025, 10:26am 2

I’m not gonna do your homework as you barely explained what you try to do.
But here is a codepen for orbiting objects “manually”, then you can use parent-child to incline orbit/follow a target.

https://codepen.io/William-J-Jones/pen/JooZjQe