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

[AnimComponent] Layer masks #3264

Merged
merged 50 commits into from
Sep 30, 2021
Merged

[AnimComponent] Layer masks #3264

merged 50 commits into from
Sep 30, 2021

Conversation

ellthompson
Copy link
Contributor

@ellthompson ellthompson commented Jun 24, 2021

This PR adds support for masks in anim component layers. It also adds support for the additive blending of layers using each layers weight property.

Below you can see a character with two animation layers. The first layer contains a blend tree which blends between an idle and running pose. This layer animations the full character body. The second layer contain a wave animation which has been masked to the characters upper body. You can see that the character blends into an upper body wave animation while still maintaining smooth blending between the full body idle and running animations.

Untitled.mov

Updated API

    /**
     * @name AnimComponent#addLayer
     * @returns {AnimComponentLayer} - The created anim component layer
     * @description Adds a new anim component layer to the anim component.
     * @param {string} name - The name of the layer to create.
     * @param {number} [weight] - The blending weight of the layer. Defaults to 1.
     * @param {object[]} [mask] - A list of paths to bones in the model which should be animated in this layer. If omitted the full model is used. Defaults to null.
     * @param {string} [blendType] - Defines how properties animated by this layer blend with animaions of those properties in previous layers. Defaults to pc.ANIM_LAYER_OVERWRITE.
     */
    addLayer(name, weight, mask, blendType);

New API

    /**
     * @name AnimComponentLayer#weight
     * @type {number}
     * @description The blending weight of this layer. Used to calculate the value of properties that are animated by more than one layer.
     */

Masks

Masks are an array of engine property paths which should all be animated by a given layer. If a mask is omitted a layer will animate all of the properties it contains curves for. Each path in the mask can have one of two forms; object or string:

                const mask = [
                    {
                        "path": "path/to/spine",
                        "children": true
                    },
                    "path/to/hip"
                ];

If a path is a string, that path will be included in the mask. If it is an object which contains a path and children property, that path and all of its children will be included in the mask.

Fixes #1727

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@ellthompson ellthompson merged commit 3684936 into master Sep 30, 2021
@ellthompson ellthompson deleted the anim-layer-masks branch September 30, 2021 11:24
ellthompson added a commit that referenced this pull request Oct 12, 2021
slimbuck pushed a commit that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: animation Animation related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animation Blending ~ Multiple Animations
2 participants