I create a demo project: https://playcanvas.com/project/486629/overview/camera-path-demo
Live demo: https://playcanv.as/p/DGGK6n8d/
What I want to do is moving the camera by a defined path. The user can stop it, and then look around. You can toggle the camera movement by clicking the button on top right. The user can only look around after the camera stop.
Here is the implementation of the “Look Around” feature:
MouseHandler.prototype.onMouseMove = function(e) {
if (this.cameraPath.enabled) return;
if (e.buttons[pc.input.MOUSEBUTTON_LEFT]) {
this.eulerAngles.x -= e.dy * 0.25;
this.eulerAngles.y -= e.dx * 0.25;
}
};
MouseHandler.prototype.update = function(dt) {
if (this.cameraPath.enabled) return;
this.entity.setEulerAngles(this.eulerAngles);
};
Here is the path I defined:
As you can see, there are green path and red path.
When the camera move to the green path, stop it by clicking the top right button, and click down to rotate the camera, the rotate orientation is expect.
However, when the camera move to the red path, stop it and click down to rotate the camera, the rotate orientation is unexpect.
I’ve check the camera’s eulerAngles, it is [0, x, 0]
at the green path, but [180, x, 180]
at the red path.
How can I solve this problem?