Skip to content

add a glTF / GLB model loader #9093

Description

@Nixxx19

Increasing access

gltf is what most model sites hand you now, sketchfab included. p5 can load obj and stl, so anyone who finds a gltf model has to go convert it first, and conversions routinely lose the materials. supporting it directly means the models people actually find are the models they can use.

Most appropriate sub-area of p5.js?

  • WebGL

Feature request details

follow up from the multi-material work in #8879, #8955, #9066, #9067 and #9089.

a lot of the groundwork is in place now. models are drawn one part per material, so a gltf file's separate meshes and materials have somewhere to go, and normalTexture() already takes tangent space normal maps, which is the kind gltf uses.

the main thing standing in the way is materials: gltf 2.0 describes them with metallic-roughness rather than phong, so #9092 (pbr materials) is really a prerequisite if imported models are going to look the way they were authored.

rough shape of the work:

  • parse .gltf (json) and .glb (binary), including buffers, accessors and embedded or referenced images
  • map each gltf primitive onto a geometry part with its material state
  • map the pbr material fields onto whatever pbr support lands from add PBR (metallic-roughness) materials #9092
  • handle the node hierarchy and its transforms
  • leave animation and skinning out of a first pass

as discussed on discord, it may be worth doing this as an addon outside p5 first, so its behaviour can settle before committing to it in core. happy to help guide whoever picks this up.

Metadata

Metadata

Assignees

No one assigned

    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