rive-wasm icon indicating copy to clipboard operation
rive-wasm copied to clipboard

Ability to access the current coordinates of a bone

Open noinskit opened this issue 2 years ago • 1 comments

I'd love to be able to access current coordinates of a bone (or something similar really, like curve vertices or bounding box of a node), within the current frame.

Is it already supported somehow? I've tried poking around the API, but couldn't find it.

noinskit avatar May 22 '22 20:05 noinskit

~~@noinskit You might be interested in the new Listeners feature!~~ ~~https://blog.rive.app/new-feature-announcement-listeners/~~

~~Check out the features page to see the minimum version to bump to:~~ ~~https://help.rive.app/runtimes/feature-support~~

See below comment

zplata avatar Jun 28 '22 14:06 zplata

Hi @noinskit - as an update, you can check out our usage guide on low-level JS/WASM APIs for this runtime here: https://help.rive.app/runtimes/overview/web-js/low-level-api-usage

Following the above guide, once you create an artboard (i.e const artboard = file.defaultArtboard()), you can create an instance of a RootBone object, via const bone = artboard.rootBone("name-of-your-bone-in-the-hierarchy"); and with the RootBone you can access its x and y properties to get the position of the bone at any time in your render loop.

Hope this helps!

zplata avatar Jan 18 '23 16:01 zplata

Closing as the above should help satisfy what you need! But feel free to re-open if you have issues with this!

zplata avatar Feb 03 '23 17:02 zplata