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

Application crash #6395

Open
LeXXik opened this issue May 18, 2024 · 2 comments
Open

Application crash #6395

LeXXik opened this issue May 18, 2024 · 2 comments

Comments

@LeXXik
Copy link
Contributor

LeXXik commented May 18, 2024

Application crashes, when trying to clone an entity with an Anim Component that has more than 1 animation layer.

Repro:
Open engine example: https://playcanvas.github.io/#/animation/layer-masks
And add to the end:

modelEntity.clone();

image

image

@kungfooman
Copy link
Collaborator

vote for clone button in every example - such a good Litmus test 😅 🙈

The lack of JSDoc makes it hard to figure out, but I got this to work anyway:

const clone = pc.app.root.children[2].clone();
pc.app.root.addChild(clone);
clone.translate(0.5, 0, 0);

image

I saw multiple issues:

  1. Using object spreading for... cloning?

Example:

class Test {
    _hi = 123;
    get hi() {
        return _hi;
    }
}
test = new Test();
const obj = {...test};
console.log("obj", obj);

Outputs: {_hi: 123}, but we need {hi: 123}!

Happens in two places:

for (let i = 0; i < stateGraph.layers.length; i++) {
const layer = stateGraph.layers[i];
this._addLayer({ ...layer });
if (layer.states.some(state => state.blendTree)) {
containsBlendTree = true;
}

this._transitions = transitions.map((transition) => {
return new AnimTransition({
...transition
});

  1. data.stateGraph lacks extra layer

if (data.stateGraph) {
component.stateGraph = data.stateGraph;
component.loadStateGraph(component.stateGraph);
}

You can hack it up like this for making it work:

        if (data.stateGraph) {
            data.stateGraph.layers[0] = data.layers[0]; // hack
            data.stateGraph.layers[1] = data.layers[1]; // hack
            component.stateGraph = data.stateGraph;
            component.loadStateGraph(component.stateGraph);
        }

And then there are even more issues, just simple type bugs basically. The component just needs more JSDoc and such issues would be automatically detectable.

I tried it in the past, but it was blocked: #2986

@willeastcott
Copy link
Contributor

vote for clone button in every example - such a good Litmus test 😅 🙈

I would suggest that the unit tests are designed exactly for checking this type of thing rather than the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants