jakubdev

Hey,

I'm using spine-ts to manage my spines. I found out difficulity to scale up/down spine animation as when I try to scale it with
skeleton.findBone('root').scaleX = 2
skeleton.findBone('root').getWorldScaleX() // returns 1.0000000000000002
it doesn't nothing even tho logging object shows that scaleX was modified.



Same issues when modyfing:
skeleton.scaleX = 2
,but when i combine it:
skeleton.findBone('root').scaleX = 2
skeleton.scaleX = 2
it will change scaleX ,but x position(in that case, if scale y modifed too it would mess y position too) of global scope is lost.
jakubdev
  • Mesajlar: 11

Nate

When you change the skeleton scale or a bone's local scale, the world transform is not affected until you use Skeleton updateWorldTransform. See:
Runtime Skeletons - Spine Runtimes Guide: World transforms
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 11863

jakubdev

At end of method I go through skeleton and all bones and call updateWorldTransform()
preloadedSkills[characterData.data.name].skeleton.updateWorldTransform();
preloadedSkills[characterData.data.name].skeleton.bones.map((bone) => bone.updateWorldTransform());
EDIT:

Managed to hack a way. For some reason changing 'root' bone and main animation bone in that case make it scale to proper size and remain position:
preloadedSkills[characterData.data.name].skeleton.findBone(animationSequence.bone).scaleX = newScale;
preloadedSkills[characterData.data.name].skeleton.findBone(animationSequence.scaleBone).data.scaleX = newScale;
jakubdev
  • Mesajlar: 11

Nate

You don't need to call Bone updateWorldTransform. Calling Skeleton updateWorldTransform updates all the bones.

Setting the bone local scale and then calling Skeleton updateWorldTransform is sufficient. After that, the world transform has been updated and will reflect the change you made to the local scale.

If you then apply an animation that sets the scale, it will of course overwrite the value you set. In that case you can either avoid keying that scale in animations, or you can modify the local scale after you apply the animation (usually before calling Skeleton updateWorldTransform).

If you change the BoneData local scale, you are changing the setup pose. That will affect all animations and all skeleton instances that use the same skeleton data.
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 11863


Dön Runtimes