Skip to content

[p5.js 2.0 Bug Report]: p5.Camera.prototype.slerp fails when using orthographic cameras #7837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 17 tasks
nakednous opened this issue May 21, 2025 · 0 comments
Open
1 of 17 tasks

Comments

@nakednous
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.0.2

Web browser and version

Firefox 138.0.4

Operating system

Archlinux

Steps to reproduce this

The slerp() example on the beta docs works as expected when using perspective cameras.

When all cameras are set to ortho(), the same logic throws an error:

Uncaught (in promise) TypeError: setting getter-only property "mat4"
    slerp https://cdn.jsdelivr.net/npm/p5/lib/p5.min.js:1
    draw http://127.0.0.1:5500/slerp/sketch.js:18

Snippet:

'use strict';

let cam, cam0, cam1;

function setup() {
  createCanvas(100, 100, WEBGL);
  cam = createCamera(); cam.ortho();
  cam0 = createCamera(); cam0.ortho();
  cam1 = createCamera(); cam1.ortho();
  cam1.setPosition(400, -400, 800);
  cam1.lookAt(0, 0, 0);
  setCamera(cam);
}

function draw() {
  background(200);
  let amt = 0.5 * sin(frameCount * 0.01) + 0.5;
  cam.slerp(cam0, cam1, amt);  // 💥 Error here
  box();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant