rive-wasm
rive-wasm copied to clipboard
Ability to access the current coordinates of a bone
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 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
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!
Closing as the above should help satisfy what you need! But feel free to re-open if you have issues with this!