• Runtimes
  • use SceneRenderer to switch different skeleton animations disappear

I want to share a webgl for better performance, so here's my initialization and switching code.
The problem is that the unplayed skeleton can be displayed the first time, and when I switch to something else and come back, there's nothing on the canvas. The renderer.drawSkeleton() logic works, but there's nothing on the canvas

Related Discussions
...

It seems like you are encountering an issue where the skeleton animations disappear when switching between them using WebGL. This could be due to not properly managing the rendering context or the skeleton state when switching. Ensure that you are not recreating the WebGL context or other resources unnecessarily when switching skeletons. Instead, maintain a single instance of the rendering context, shaders, and other resources. You might also need to reset the skeleton's state or pose when switching back to it. Consider using skeleton.setToSetupPose() or similar methods to reset the skeleton's state when switching back to it. Additionally, make sure that the skeleton is being drawn correctly by checking the rendering logic and ensuring that the canvas is being cleared and redrawn properly.

  • kc-learn ответили на это сообщение.

    Spinebot i have used setToSetupPose

    I'm sorry, but for me your screenshots are not enough to understand what you are doing.
    Is it possible for you to share a running code example?

    • kc-learn ответили на это сообщение.

      Davide
      After playing the switch, the character animation disappeared, which makes me very troubled, I don't know what went wrong, resulting in the canvas has been empty, hope you can help me solve this problem

      • Davide ответили на это сообщение.

        kc-learn

        I've noticed that you deeply modified the spine-player. I am sorry, but the changes you did aren't so straightforward to me and I won't be able to go through it today. I'll look at it tomorrow.
        But if I find your modifications are too difficult to follow, I'll point you again to the spine widget I mentioned in the other thread you opened.

        Moreover, if you want to improve performance you should also reduce the number of vertices. Many meshes can be simplified a lot.

        • kc-learn ответили на это сообщение.

          Davide
          thankI didn't make the animation material, I'm just a web developer, I just changed and reused a webgl instance for performance optimization, but the problem is only the switchSkeleton method, the same animation can't be played a second time, the switch disappears

          • Davide ответили на это сообщение.

            kc-learn

            I'm sorry, but you modified the player too much. Even if I was able to point you in the right direction, I'm sure that some other things would break.

            As far as I understood you are making the player loading multiple assets, and so far that's fine.
            Then you should not comment out entire chunks of code, but just try to switch skeleton and "reinitialize" its state when you switch it.

            If you used the widget, it would be just a matter of hiding one and show the other.

            • kc-learn ответили на это сообщение.

              Davide how reinitialize its state, I just commented out the controller related code, the core rendering is basically unchanged

              • Davide ответили на это сообщение.

                kc-learn

                I gave another look at your code. As I told you previously, you commented out important parts of the code.
                You commented out validateConfig that validates the spine player config.
                Right now your configuration is invalid. Especially for the defaultMix property that if missing, should be set to .25 by default.
                When you set your animation for the second time, the animations are mixed together. But since your default mix time is undefined, the skeleton get corrupted and nothing is rendered anymore.

                If you set the defaultMix of the AnimationStateData correctly, the skeletons will be rendered.

                • kc-learn ответили на это сообщение.

                  Davide
                  oh my huge mistake, I mistakenly assumed that defaultMix had a default value in the lower level implementation, and instead used clearTrack to constantly clean up the animation track. After configuring defaultMix, it can play normally. Thank you very much for your patient guidance, which helps me deepen my understanding of spine-runtime