playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.65k stars 1.34k forks source link

Cloned Entities with Anim Components do not animate with 1.47.2.min.js but animates with un-minified engine build #3618

Closed yaustar closed 2 years ago

yaustar commented 2 years ago

Thread: https://forum.playcanvas.com/t/bug-cloning-instantiating-a-template-with-anim-component-is-broken/22576

Test project: https://playcanvas.com/editor/scene/1258298

Animates correctly: https://launch.playcanvas.com/1258298?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.47.2.js Does not animate: https://launch.playcanvas.com/1258298?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.47.2.min.js

Looks like there is an issue between the different build versions of the engine 🤔

However, it works fine in the Bitmoji Loader project: 1.47.2: https://launch.playcanvas.com/995061?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.47.2.js

1.47.2.min: https://launch.playcanvas.com/995061?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.47.2.min.js

I think the difference here is how the Anim Component is setup with the root bone set on a different entity that the component is but I'm not sure if this is the cause of the issue:

image

yaustar commented 2 years ago

Looks like something in the terser() build step is causing this issue but not sure what 🤔

yaustar commented 2 years ago

On the minified build, it looks like that the rootBone is not set on the clones which is VERY weird

yaustar commented 2 years ago

Found the issue:

https://github.com/playcanvas/engine/blob/master/src/framework/components/anim/component.js#L151

On a minified build, the constructor.name is set to t because of the minification process therefore the _rootbone = value code path is not executed.