Closed davepagurek closed 1 month ago
@davepagurek would this approach also affect/reset transformations applied elsewhere in code?
I think it would only affect transforms if you're calling setCamera
in the middle of draw
rather than in setup
or in an event handler. But if you were previously calling setCamera
mid-draw, arguably the resulting things you draw wouldn't have been in the correct spot anyway since they wouldn't be using the camera's transform yet?
As long as the reference is clear about where/when to call setCamera()
I think we're good. This test case is a little contrived but it surprised me.
Right, I guess the rule would be, set the camera before you draw the content?
Also, we have this PR basically ready to start testing as soon as we're done making quick docs releases for the website release: https://github.com/processing/p5.js/pull/6761 I think after this change, since the camera and model transform matrices will not be merged into a single variable, we actually might not need to reset at all, since we'll be able to discern what part came from transforms vs what part came from the camera. So maybe the thing to do is to wait until we can merge and test to see if that refactor fixes this for us? (The reason for the wait is that it's a pretty big change to a core part of the rendering algorithm, which I think warrants a beta testing period before release, which we've been skipping for our expedited docs releases.)
Agreed that beta testing for this kind of change is a good call.
Just put up https://github.com/processing/p5.js/pull/7067 with something that augments https://github.com/processing/p5.js/pull/6761 so that only the view matrix updates when you change cameras. We can play around with that and see if there are any situations that would cause issues
Most appropriate sub-area of p5.js?
p5.js version
1.9.3
Web browser and version
All
Operating system
All
Steps to reproduce this
Currently, setting a camera just updates the projection matrix and does not change the model view matrix. I assume that normally this is not an issue because people don't switch cameras in the middle of
draw
. However, this leads to some confusion when using cameras on framebuffers, which must be applied withindraw
. If you comment out theresetMatrix
call, changing cameras has no effect:Live: https://editor.p5js.org/davepagurek/sketches/8uENBvPU3
I think
setCamera
should also updateuMVMatrix
, basically also updating the camera position.