Default scene has two parents?
Describe the bug
The list returned by listParents() for a default scene contains the root element twice.
To Reproduce Steps to reproduce the behavior:
- Go to https://gltf.report/
- Load the GLB from here https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/Duck/glTF-Binary/Duck.glb
- Run this script:
const p = document.getRoot().getDefaultScene().listParents()
console.log(p.length) // 2
console.log(new Set(p).size) // 1
- Observe the length of the node list is 2 but the size as a Set is 1.
Expected behavior
The list returned by listParents() contains the single parent element once. It might even be nice to return a Set object to make this clear at the type level.
Versions:
- Version: 4.0.2
- Environment: Browser
Additional context
I assume this is because the graph is actually a hypergraph and the scene is reachable through both the "scene" and the "scenes" attribute.
Indeed, that's a bug! All entries in the array should be unique. I think the cause is here, in the property-graph package:
https://github.com/donmccurdy/property-graph/blob/ca888d62ab0892ca4126fa3c3d849e0fe8e6e46b/src/graph.ts#L26-L29
Upcoming fix:
- https://github.com/donmccurdy/property-graph/pull/171
- https://github.com/donmccurdy/glTF-Transform/pull/1543