With the use of thingiview.js, Three.js, and trackballControls, I have managed to create a system that allows me to upload an STL file and then display it on the canvas. While trackballControls are quite effective with some tweaks, I am encountering a particular issue:
I am aiming to zoom in at the location of the mouse cursor rather than the center of the grid/plane.
Although I have implemented a simple captureEvent to obtain the mouse's on-screen coordinates and track them, I am struggling to identify where to intervene in the control system to achieve this.
I explored the _zoomStart/_zoomEnd functionalities (which seem confusing as they refer to "y" when I anticipated "z"). However, any attempts to add a _zoomStart.x essentially get disregarded.
While I may not be an expert, I usually feel comfortable experimenting around.
In addition, I would like to ensure that during panning, the zoom and rotation still revolve around the object's center rather than the center of the grid/plane.
Despite scouring through various posts and examples for days, I have yet to discover concrete solutions.
I believe that my searches might be misdirected or I could be heading in the wrong direction. Any helpful guidance or even a forceful push in the right direction would be sincerely appreciated.
EDIT
this.zoomCamera = function () {
var factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * _this.zoomSpeed;
if (factor !== 1.0 && factor > 0.0) {
_eye.multiplyScalar(factor);
if (_this.staticMoving) {
_zoomStart.copy(_zoomEnd);
} else {
_zoomStart.y += (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
}
}
};
I assume the above snippet is where I should explore for altering zoom behavior. My confusion lies in the usage of _zoomStart.y. But assuming that's how it is, how can I implement changes for x?
Considering that _zoomStart and _zoomEnd are Vector2s, where does the given code define x?
confuzzled