MomosArts

Hi everyone,

I'm trying to get an application running in which I can drag bones around and pose a simple puppet in the browser - similar to the hoverboard example you have on the demo page. I've come across this forum thread: http://esotericsoftware.com/forum/How-to-make-a-joint-draggable-17294 and managed to get the example running locally. My (JS) coding skills intermediate at best, though, and I can't seem to get the code to accept anything else than the Spineboy demo (e.g. when I load a different JSON/atlas, it gives me an error that the variable state is not defined).

I assume the problem lies in this section here:
function loadingComplete() {
var atlasLoader = new spine.AtlasAttachmentLoader(assetManager.get("atlas1.atlas"));
var skeletonJson = new spine.SkeletonJson(atlasLoader);
var skeletonData = skeletonJson.readSkeletonData(assetManager.get("demos.json").spineboy);
skeleton = new spine.Skeleton(skeletonData);
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
state.setAnimation(0, "hoverboard", true);
where it reads the skeletonData. I've tried comparing it with the documentation, but everywhere else, the line just reads a JSON file by name, without any extra attributes like the .spineboy in assetManager.get("demos.json").spineboy. I think I would be able to define different control bones etc. on my own, but I am stuck with getting any other skeleton in.

So my question - is it even possible to fairly easily make the code accept another JSON file? If yes, how would I go about that? Happy for any hints!
MomosArts
  • Beiträge: 4

Mario

The demo code you are basing your code on is a bit involved. I'll create a more bare bones example for the spine-ts WebGL runtime. See the issue here:
https://github.com/EsotericSoftware/spine-runtimes/issues/2151
Benutzeravatar
Mario

Mario
  • Beiträge: 3242

MomosArts

That would be great! Thanks for the super quick reply too!
MomosArts
  • Beiträge: 4

Mario

I've added a simple example here:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-ts/spine-webgl/example/bone-dragging.html

Look into the README.md file in the spine-ts/ folder on how to run the examples. The code should be pretty self-explanatory. Happy to answer any questions!
Benutzeravatar
Mario

Mario
  • Beiträge: 3242


Zurück zu Runtimes