Third person control

How to rotate object to side which look camera ?

class ThirdPersonCamera extends Camera {
    boot(domElement) {
        this.cameraManager = new CameraManager(domElement);
    }

    tick(target = null) {
        if (target !== null) {
            this.cameraManager.target.applyMatrix4(target.matrixWorld);
            this.cameraManager.target.set(target.position.x, target.position.y + 2, target.position.z);
        }

        let targetX = this.cameraManager.target.x;
        let targetY = this.cameraManager.target.y;
        let targetZ = this.cameraManager.target.z;

        let radius = this.cameraManager.radius;
        let theta = this.cameraManager.theta;
        let phi = this.cameraManager.phi;

        let posX = targetX + radius * Math.sin(theta * Math.PI / 360) * Math.cos(phi * Math.PI / 360);
        let posY = targetY + radius * Math.sin(phi * Math.PI / 360);
        let posZ = targetZ + radius * Math.cos(theta * Math.PI / 360) * Math.cos(phi * Math.PI / 360);


        this.position.set(posX, posY, posZ);
        this.lookAt(this.cameraManager.target);
    }
}

in function tick - target is my object http://joxi.net/bmoYbaBIxVNM8A

And this is my CameraManager:

class CameraManager extends Manager {
    implements() {
        this.sensitivity = new Vector2(1, 1);
        this.target = new Vector3();
        this.character = {};

        this.radius = 15;
        this.theta = 0;
        this.phi = 0;
    }

    realised(deltaX, deltaY) {
        this.theta -= deltaX * this.sensitivity.x;
        this.theta %= 720;

        this.phi += deltaY * this.sensitivity.y;
        this.phi = Math.min(170, Math.max(-170, this.phi));
    }

    event() {
        this.boundLockedPointer = () => this.domElement.requestPointerLock();
        this.boundMouseMove = event => this.realised(event.movementX, event.movementY);

        this.domElement.addEventListener('mousedown', this.boundLockedPointer, false);
        this.domElement.addEventListener('mousemove', this.boundMouseMove, false);
    }
}

When i move mouse my camera just rotate around my object, but i wanna make rotate object with camera only by axes Y

How i can get it? Thank you

Can you please demonstrate the issue with a live example?

Sorry, but it’s not clear what you are asking for. Can you please elaborate a bit?

oh, ye, sure

I decided upload full project to my gitlab, coz im not sure that i can make live demo,
There few files and easy to install, so its few steps:

npm i
npm run prod
node server.js

And its will running on http://localhost:3000

I wanna add control to character like its normally in third person game, like, when you move your mouse to right side, your character rotate to right side :slight_smile: Now my character can move only back and forward