playcanvas / engine

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

Morph Animations do not load properly when Container is loaded at runtime #5225

Open bfischlin94 opened 1 year ago

bfischlin94 commented 1 year ago

Description

When loading assets for a 3D Model at runtime with an animation track that includes Morph Animation, the Morph animations seem to be lost. This is an issue, since you may not want to load any assets of a 3D model until needed.

But when using Preload on the container and template of the 3D Model, the morph animations do load. When then all asstes are unloaded and then loaded again an error is thrown when launching with debug mode with versions prior to 1.62 (the error vanishes in 1.62 but the problem doesn't):


morph-instance.js:197 Uncaught TypeError: Cannot read properties of null (reading '_targets')
    at MorphInstance.setWeight (morph-instance.js:197:55)
    at Array.func (default-anim-binder.js:94:47)
    at AnimTarget.callSetters [as _set] (default-anim-binder.js:104:39)
    at AnimEvaluator.update (anim-evaluator.js:264:35)
    at AnimController.update (anim-controller.js:582:29)
    at AnimComponentLayer.update (component-layer.js:257:26)
    at AnimComponent.update (component.js:732:28)
    at AnimComponentSystem.onAnimationUpdate (system.js:84:31)
    at ComponentSystemRegistry.fire (event-handler.js:201:26)
    at Application.update (app-base.js:1171:22)

Steps to Reproduce

Morph anim Lost after asset unload & load with Container and Template preloaded

  1. Execute https://playcanv.as/b/ca15bdcc
  2. Press "Load" Button to load other assets of the 3D Avatar and wait for avatar to show
  3. Press "Unload" Button
  4. Press Load Button again and wait for avatar to show again.
  5. Morph Animations on face (i.e. blinking and correct lips movements) are lost.

Morph anim never loaded when Container and Template are not preloaded

  1. Execute https://playcanv.as/b/bcd88dc3
  2. Press "Load" Button to load all assets of the 3D Avatar and wait for avatar to show
  3. Notice how no moprh animations (no blinking or intricate lips movements are present)
  4. Press "Unload" Button
  5. Press "Load" Button again and wait for avatar to show again.
  6. Morph Animations are still not present.

Project for reference: https://playcanvas.com/project/1055497/overview/morphtester

slimbuck commented 1 year ago

Thanks so much for the detailed repro @bfischlin94. It really helps when debugging these issues. 👍🏻