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
234 stars 16 forks source link

GLTF root not included in list of entities #255

Closed vorg closed 1 year ago

vorg commented 4 years ago

Synthetic root we create for the loaded scene is not included in the list of scene.entities. That causes problems when trying to find certain components like Animations

const scene = renderer.loadScene(url)
scene.entities.filter((e) => e.getComponent('Animation')) // -> length 0
root.getComponent('Animation') // -> Animation

Adding root to entities array would solve that issue but in a way it modifies the gltf file which might be unexpected.

vorg commented 4 years ago

It seems that one of the reasons to have root in the first place is that animations don't belong to any particular node and are considered part of the scene. In our case root entity takes role of the scene.

vorg commented 4 years ago

IBL lights will be also defined at the scene level https://github.com/KhronosGroup/glTF/tree/821b2bd58bfc400e575d37fce77bf5cf47dec531/extensions/2.0/Vendor/EXT_lights_image_based#adding-light-instances-to-scenes

The question if scene.root should be part of scene.entities (ideally scene.entities[0]) remains. @dmnsgn ?

vorg commented 1 year ago

Fixed in https://github.com/pex-gl/pex-renderer/blob/v4/loaders/glTF.js#L1392