• Runtimes
  • how can i replace current inited SpinePlayer skeleton

how can i replace current inited SpinePlayer skeleton, i have most 8 diifren skeletonJson and atlas,i only want to use one webgl instance to switch play then, pls give a guide,I hope to maintain good performance on mobile

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

    To replace the current initialized skeleton in a SpinePlayer while maintaining good performance on mobile, you can follow these steps:

    1. Dispose of the Current Player: Use the dispose() method to clean up the current SpinePlayer instance. This will help manage resources effectively and prevent memory leaks.

    2. Reinitialize the Player: After disposing of the current player, create a new SpinePlayer instance with the new skeleton JSON and atlas files. This approach ensures that you are using a single WebGL context efficiently.

    3. Consider Using spine-webgl: If you need more control over rendering and performance, consider using spine-webgl directly. This runtime allows you to manage multiple skeletons within a single WebGL context, which can be more efficient than using multiple SpinePlayer instances.

    4. Optimize for Mobile: Be mindful of the number of WebGL contexts and resources used, as mobile devices have limitations. Ensure that you are not exceeding these limits by managing your resources carefully.

    By following these steps, you can switch between different skeletons using a single WebGL instance while maintaining good performance on mobile devices.

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

      Spinebot After Dispose, will the loaded resources be removed? Can it be handled more conveniently? I looked at the source code of the player, I noticed the implementation of linitialize and loadSkeleton, I tried

      kc-learn

      The Spine Player is not designed to handle on-the-fly changes to the displayed skeleton without disposing of the player.

      The easiest solution is to replace the current spine player. Have a look at this example.
      Just pass the assets location to the createPlayer function.

      Does this solution fits your needs?

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

        Davide thank you answer, i actually use that solution in my project, people click switch buttom, make player dispose and initialization frequently, in mobiel web side,it make my phone so hot, I wonder if there is a problem with content leakage, can i re-implementation with spine-webgl avoid this performance issue.i want some high performance practice

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

          kc-learn

          The dispose function actually disposes everything was initialized by the player. If there was a memory leak, the result would be more likely a page crash.

          Can you link or share your project so that I can have a look at your setup? If you don't want to share it publicly, you can send it to contact@esotericsoftware.com.

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

            Davide
            I used the browser performance analysis, found that because I draw the graph is too big, the bigger the graph, the more awkward, there is a loss of recorded frames, like the following picture, is there any way to optimize

            The spine player sits into the given HTMLElement and no overflow should happen. If it overflows, maybe there something wrong with your setup.
            You shouldn't look at the size of what's inside the webgl canvas since it depends on the devicePixelRatio.

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

              Davide
              I want to show only the middle area on the premise of ensuring the proportion of animation size. How can I cut and optimize, I find that the bigger the animation of the painting, the more serious the phone hot phenomenon

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

                kc-learn

                Unfortunately, you can't achieve that with the spine-player. You could modify the code and get that result, but it might not be the easier thing to do. If you want to try that, you have to modify spine-webgl since spine-player uses it.

                This might be a interesting use case for our work in progress spine-widget. It basically uses a single webgl context to render multiple skeletons. And you can clip the viewport at your desired bounds.
                You can give it a try by switching to the ts-webgl-overlay branch of our repository and learn how to use it launching the webcomponent-tutorial example.

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

                  Davide
                  So I really need to learn spine-webgl, which can help me understand the basic logic of the entire runtime. I am curious about whether spine-play has done performance test on mobile terminals. When drawing animations close to the full screen, the hot phenomenon makes me worry that old mobile phones cannot be well compatible (thank you answer again)

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

                    kc-learn

                    Before deep diving into spine-webgl, I really encourage you to try the spine-widget mentioned above since it already does what you want. You can actually see the tutorial here.

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

                      Davide I did not find the source code for spine-widget :

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

                        kc-learn

                        As mentioned yesterday, you can get it by switching to the ts-webgl-overlay. Then you can build it by yourseld. Its source is in the spine-webgl folder right now.
                        But I suggest you to just directly download the library from the page I linked yesterday.

                        • kc-learn ответили на это сообщение.
                          7 дней спустя

                          Davide oh my mistake,i have found the example i need,thank you !