Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Root::push() and Index::push() to assist with glTF construction. #404

Merged
merged 2 commits into from
Dec 29, 2023

Commits on Dec 24, 2023

  1. Add Root::push() and Index::push() to assist with glTF construction.

    These methods reduce the amount of boilerplate and possible mistakes
    involved in constructing a glTF asset from scratch.
    
    Most use cases are served by `Root::push()`; `Index::push()` is useful
    for cases like animation samplers where the vector of objects is not in
    the `Root`, or in algorithmically complex situations such as pushing
    both within and outside closures, which would produce borrow conflicts
    if `&mut Root` was required for everything.
    
    This introduces a new paradigm for child object access: implementing
    `AsMut<Vec<T>>`. This could also replace the `Get` trait's function via
    `AsRef<[T]>` implementations, but that would be a breaking change, so if
    that is to be done, let's do it separately. This commit includes those
    `AsRef` implementations, though, since they're harmless and parallel to
    the `AsMut` implementations.
    kpreid committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    0a0727a View commit details
    Browse the repository at this point in the history
  2. Use Root::push() in export example.

    This way, all `Index`es are guaranteed valid and the dependencies
    between the glTF objects are reflected in the program's variables.
    
    I have manually tested that the output of the example is valid glTF.
    kpreid committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    a9c5622 View commit details
    Browse the repository at this point in the history