pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Core glTF 2.0 support #147

Closed vorg closed 5 years ago

vorg commented 5 years ago

Currently there is few examples for loading glTF each using copy pasted piece of code. As we are aligning our features with glTF it would be good to have glTF support in the core.

There are different approaches

Scene loader:

const scene = await rederer.loadGltf('assets/damaged_helmet/damaged_helmet.gltf')
renderer.add(scene.root)

Scene component:

const gltfEnt = renderer.entity([
  rederer.gltf({ src: 'assets/damaged_helmet/damaged_helmet.gltf' })
])
renderer.add(gltfEnt)

Interesting extensions

dmnsgn commented 5 years ago

I'd go for a modified option 1: scene loader. It would be good to keep loading and parsing decoupled IMO. The glTF loader should handle the binaries and images. The glTF parser should be responsible for creating pex-renderer entities.

This way we can still keep the freedom of updating a scene/model's properties/images at runtime before rendering it.

To sum up, I don't see the glTF functionality as a component but as an entity builder.

dmnsgn commented 5 years ago

Fixed by dcc40ef8081c621caaba9487e35ebfbbded48100