Skip to content

Move camera along curve while still having mouse control the camera #470

Answered by 1337jick
1337jick asked this question in Q&A
Discussion options

You must be logged in to vote

Found the solution, is to use .setViewOffset. Somehow it's not in the docs in Methods.
Then you can lerp the calculated value for this method and put it in the render.

//fired at this.renderer.render
  rotate() {
    this.mouse.x = MathUtils.lerp(this.mouse.x, this.newMouse.x, 0.05);
    this.mouse.y = MathUtils.lerp(this.mouse.y, this.newMouse.y, 0.05);

    if(this.mouse.x !== 0 || this.mouse.y !== 0) {
      this.camera.instance.setViewOffset(
        this.sizes.viewport.width,
        this.sizes.viewport.height,
        this.mouse.x * 200,
        this.mouse.y * 200,
        this.sizes.viewport.width,
        this.sizes.viewport.height,
      );
      this.camera.instance.updateProjec…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yomotsu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant