Skip to content

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

Open
@nakednous

Description

@nakednous

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();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions