Skip to content

WebGL projection matrix not updated after pop() #3054

Closed
@AidanNelson

Description

@AidanNelson

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Most appropriate sub-area of p5.js?

  • Color
  • Core/Environment/Rendering
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Which platform were you using when you encountered this?

  • Mobile/Tablet (touch devices)
  • Desktop/Laptop
  • Others (specify if possible)

Details about the bug:

The projection matrix of the rendererGL doesn't update after a pop(). So, any perspective/ortho calls during a push/pop will remain until the following call to perspective() or ortho().

I will fix this as part of reorganizing camera functionality in webGL.

Below code should render the cubes in perspective projection, ortho projection, then perspective projection, but instead renders as perspective, ortho, ortho:

function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  camera(0, -200, 500, 0, 0, 0, 0, 1, 0);
  normalMaterial();
}

function draw() {
  perspective();
  // left
  push();
  translate(-120, 0, 0);
  fill(0, 200, 0);
  box(100);
  pop();

  // middle (w/ ortho projection)
  push();
  ortho();
  fill(0, 0, 200);
  box(100);
  pop();

  // right (should have perspective projection)
  translate(120, 0, 0);
  fill(200, 0, 0);
  box(100);
}

What we should see:
screen shot 2018-07-02 at 5 22 38 pm
What we do see:
screen shot 2018-07-02 at 5 17 25 pm

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions