Skip to content

RFC: Geometry3D refactor #1056

Closed
Closed
@indefinit

Description

@indefinit

While patching #1009 and paving the way for #904, I found that Geometry3D could benefit from a refactor. As such, I wanted to post my thinking here, and request feedback in case anyone has a strong opinion, either for or against the refactor.

Currently, when a user calls sphere() the geometry and buffers are created and added to respective hash tables. This is what we've labeled "retainedMode". It's part of the secret sauce behind the performant, non-scene-graph style architecture in p5.js. When a user calls line() or quad() in WEBGL mode, however, their 2D geometries are created directly as webgl array buffer data, and consequently are not entered into the geometry hash table. We've labeled this implementation approach as "immediateMode". While I do see many strengths in an immediateMode approach (namely begin and endShape()), I don't think we need to have all 2D drawing be done in this way. The benefits of consolidating geometry in webgl include a performance boost and less error prone source code.

With a Geometry3D refactor, both 3D and 2D geometry primitives would be created similarly, each in "retainedMode". Because the Geometry3D class would consequently contain both 3D and "2D" primitives, we'd rename the class to simply "p5.Geometry", and 3d_primitives.js would become primitives.js.

Objections or encouragements? tagging:
@karenpeng @codeanticode @lmccart @shiffman @mindofmatthew
but comments from others are welcome.

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