-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add a flag to indicate if the most recently created canvas is 3D #5750
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
Comments
I think this would be good to have. For canvases, a conditional of |
Would it be better to call it |
If a webGL canvas isn't being used to draw 3D shapes, would it not still let the developer use p5's 3D graphics methods? In my mind, the motivation for adding this flag is so that developers can determine if it's "safe" to use p5's 3D graphics methods. So as long as calling one of those methods will not result in an exception due to the assert3d call, whether that's because the canvas is using a webGL context or some other 3D renderer, then an That being said, I think |
There's a couple non-3d methods in p5, If I understand the problem correctly, what we're really looking for is a way to determine if a specific canvas's renderer is capable of drawing 3d shapes. The ability of the canvas to do so is defined by the type of renderer (canvas2d or webGL), so just knowing that a canvas is in webGL mode should be enough to tell you that. If later down the road, another renderer is added, or the ability to draw 3d shapes is added to existing renderers then Not a hill I need to die on or anything just offering up a thought! |
What I mean by 3D methods is anything that requires a 3D rendering context, including the methods you mentioned. So as long as all of the p5 3D methods would be supported by any future 3D renderer (in the unlikely event that one is added) then the programmer shouldn't care whether it is webGL or some other context. However, since webGL is pretty much the only game in town (as far as I know at least,) it probably makes sense to just call it |
I would suggest going with I'm happy if either of you want to file a PR for this. |
Hi I've started working on this, could I get it assigned? |
Thanks @spikyMalkallam! I've assigned this to you. |
Increasing Access
This will increase access under the following rubric: "People with little or no prior experience in open source and creative coding"
Most appropriate sub-area of p5.js?
Feature request details
While trying to figure out how to easily determine whether the current canvas is in 3D mode or 2D mode for a library I'm creating, I came across this SA article:
https://stackoverflow.com/questions/60931463/programmatically-detect-rendering-mode-in-p5js
It would appear that detecting the current canvas/p5.Graphics mode is less than straightforward. Many of the 3D methods throw an exception if you try to use them on a 2D canvas, so I think it would be useful to make it somewhat easier to determine the current mode.
I propose that we add a readonly property to p5 instances and p5.Graphics instances called
.is3D
, paralleling the existing.isP3D
property of the p5.RendererGL class. Currently, you could also look at the _renderer property to see if it is an instance of p5.Renderer2D or p5.RendererGL, but that's no simpler than the solution proposed in the aforementioned SA article.The text was updated successfully, but these errors were encountered: