donmccurdy / donmccurdy/glTF-Transform

Prune fails to clean up accessors referenced by non-root properties

Open
#1,389 2 comments 0 reactions 0 assignees View on GitHub
bug package:functions
Dominant language
TypeScript
Stars
2k
Forks
206
Avg merge
2d 2h
Merged PRs (30d)
16

Description

Resources like Accessors may be considered 'in use' by prune() if they're referenced by unused primitives or primitive targets. Because no references exist to the primitives or primitive targets, we won't find those and dispose them when iterating over meshes, and the empty accessors are written to disk despite no real use.

The other non-root entity types in the core spec are TextureInfo, AnimationSampler, and AnimationChannel. TextureInfo won't have this issue, but the other two might. Conceivably this could also happen with extensions, but prune() doesn't currently attempt to identify unused extension resources, so that's out of scope for now.

Perhaps it would be better to do a formal tree-shake, iterating all nodes in the graph, and pruning those we can't trace to the Root? This might simplify the current implementation of prune() as well.

Contributor guide

Open the contributing guide

Research direction

Start at the prune() implementation and trace how references are collected while iterating meshes, then inspect handling for Accessors, primitive targets, AnimationSampler, and AnimationChannel. Done means unused non-root resources are removed without affecting resources reachable from Root; extensions remain out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.