public void SetupSkeleton()
        {
            if (skeletonDesc == null)
            {
                return;
            }

            if (showMesh)
            {
                if (skeleton != null)
                {
                    DestroySkeleton();
                }
                skeletonDesc.referencePose.ScaleTranslations(scaleFactor);
                initSkeletonFromExistingCharacter(rootTransform, skeletonDesc);

                Debug.Log("init skeleton from existing character");
            }
            else
            {
                skeletonDesc.referencePose.ScaleTranslations(scaleFactor);

                skeleton      = skeletonManager.GetSkeleton(skeletonDesc);
                rootTransform = skeleton.transform;
                root          = skeletonManager.GetRootJoint(skeletonDesc);
                skeletonManager.ShowSkeleton(skeletonDesc.name);
                root.setPose(skeletonDesc.referencePose, indexMap);
                if (skeletonDesc.referencePose.translations.Length > 0 && skeletonDesc.jointDescs.Length > 0)
                {
                    var     t        = skeletonDesc.referencePose.translations[0];
                    var     rootDesc = skeletonDesc.jointDescs[0];
                    Vector3 offset   = new Vector3(rootDesc.offset[0], rootDesc.offset[1], rootDesc.offset[2]);
                    rootTransform.position = t + offset * scaleFactor;
                }
                Debug.Log("generated skeleton");
            }
        }
        public void Update()
        {
            if (init && root != null && motion != null)
            {
                frameIdx = (int)(animationTime / frameTime);
                if (frameIdx >= numFrames)
                {
                    frameIdx = numFrames - 1;
                }
                Vector3 pos = motion.getRootTranslation(frameIdx);
                if (rootTransform != null)
                {
                    var     rootDesc = skeletonDesc.jointDescs[0];
                    Vector3 offset   = new Vector3(rootDesc.offset[0], rootDesc.offset[1], rootDesc.offset[2]);
                    rootTransform.position = pos + offset * scaleFactor;
                }
                root.setPose(motion.getPose(frameIdx), indexMap);

                if (playAnimation)
                {
                    animationTime += Time.deltaTime * speedFactor;
                    if (loop)
                    {
                        animationTime %= maxAnimatTime;
                    }
                    else
                    {
                        if (animationTime >= maxAnimatTime)
                        {
                            playAnimation = false;
                            animationTime = maxAnimatTime;
                        }
                    }
                }
            }
        }