Skip to content

Add a flag to indicate if the most recently created canvas is 3D #5750

@SanzSeraph

Description

@SanzSeraph

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?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Localization Tools
  • Friendly Errors
  • Other (specify if possible)

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions