hey guys I want a first-person camera but it moves by dragging… some thing like this:
as you can see it’s not orbit-control cause it’s not looking at 1 object and you can move around, do we have some formula for camera rotation only by dragging?
i did manage to get here but i am moving the camera by mouse move which is not I wanted but can’t seem to work out this to drag for camera rotation
const xh = this.input_.current_.mouseXDelta / window.innerWidth;
const yh = this.input_.current_.mouseYDelta / window.innerHeight;
console.log(xh)
this.phi_ += -xh /9;
this.theta_ = clamp(this.theta_ + -yh /9, -Math.PI / 3, Math.PI / 3);
const qx = new THREE.Quaternion();
qx.setFromAxisAngle(new THREE.Vector3(0, 1, 0), this.phi_);
const qz = new THREE.Quaternion();
qz.setFromAxisAngle(new THREE.Vector3(1, 0, 0), this.theta_);
const q = new THREE.Quaternion();
q.multiply(qx);
q.multiply(qz);
this.rotation_.copy(q);
this is my mouse information in input_
this.current_.mouseX = e.pageX - window.innerWidth / 2;
this.current_.mouseY = e.pageY - window.innerHeight / 2;
if (this.previous_ === null) {
this.previous_ = { ...this.current_ };
}
this.current_.mouseXDelta = this.current_.mouseX - this.previous_.mouseX;
this.current_.mouseYDelta = this.current_.mouseY - this.previous_.mouseY;