most of us actually have the rotate around selection
for the viewport set on and the viewport is essentially a camera. This looked easy when messing around, but actually implementing it by code is just nightmare.
I have a trackball like camera and an object that always stays at the center, now, I wanted a camera that would rotate around the object(at the origin) but, would also pan. Immediately we can see that when we translate the camera for panning, the camera loses it's pivot, and it just snaps:
how can we implement panning and rotating in a camera?(in maths)
below is basically my camera system transformation for reference:
class Trackball extends Camera{
constructor(vec4_position, vec4_target, vec4_upVector) {
super(vec4_position, vec4_target, vec4_upVector);
}
/*
* lookAt transform via inverse matrices
* */
viewTransform(vec4In , vec4Out) {
vec4Out.x = ((vec4In.x * this.R.x) + (vec4In.y * this.R.y) + (vec4In.z * this.R.z))
- ((this.R.x * this.P.x) + (this.R.y * this.P.y) + (this.R.z * this.P.z));
vec4Out.y = ((vec4In.x * this.U.x) + (vec4In.y * this.U.y) + (vec4In.z * this.U.z))
- ((this.U.x * this.P.x) + (this.U.y * this.P.y) + (this.U.z * this.P.z));
vec4Out.z = ((vec4In.x * this.D.x) + (vec4In.y * this.D.y) + (vec4In.z * this.D.z))
- ((this.D.x * this.P.x) + (this.D.y * this.P.y) + (this.D.z * this.P.z));
this.buildLookAtVectors(this.P,this.target, this.upVector);
return vec4Out;
}
}
question from:
https://stackoverflow.com/questions/65913524/type-of-camera-system-that-blender-uses 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…