glTF-Transform icon indicating copy to clipboard operation
glTF-Transform copied to clipboard

Default scene has two parents?

Open rotu opened this issue 1 year ago • 1 comments

Describe the bug The list returned by listParents() for a default scene contains the root element twice.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://gltf.report/
  2. Load the GLB from here https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/Duck/glTF-Binary/Duck.glb
  3. Run this script:
const p = document.getRoot().getDefaultScene().listParents()
console.log(p.length) // 2
console.log(new Set(p).size) // 1
  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.

rotu avatar Oct 18 '24 17:10 rotu

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

donmccurdy avatar Oct 18 '24 17:10 donmccurdy

Upcoming fix:

  • https://github.com/donmccurdy/property-graph/pull/171
  • https://github.com/donmccurdy/glTF-Transform/pull/1543

donmccurdy avatar Oct 27 '24 15:10 donmccurdy