Hello,
I hope you guys are well!
I’m playing with your hand/input tutorials and I’m not sure how to plug in the buttons animations?
https://developer.playcanvas.com/en/tutorials/webxr-controllerhand-models/
Is it supported at all?
Thanks for the support!
Mykel
I’ve just tried this with Quest 1.
Hand tracking with animation works fine.
The controller models from what I can see are not supposed to be animating in the project.
If you are looking to have an animated hand model around the controller when using the controller input, that’s not supported in the project.
Hello Yaustar.
I’m not looking for the animated hand but to controller itself, the buttons, the trigger, etc… I’m wondering how to connect that to playcanvas.
# WebXR Input Profiles - Motion Controllers
[](https://travis-ci.org/immersive-web/webxr-input-profiles)
## Overview
This package provides a 3D engine agnostic javascript library for synchronizing the status of an `XRInputSource` object with a 3D model representing that `XRInputSource`. The library consumes JSON files in the format published from the [@webxr-input-profiles/assets](../assets/README.md) package to create `MotionController` objects that enable a simple path for developers to:
1. Find the best matching profile for an `XRInputSource`
1. Enumerate the component parts (trigger, squeeze, touchpad, thumbstick, button, etc)
1. If a 3D asset is available for the matching profile, provide a path to load it
1. On each render frame, apply precomputed deformations to the 3D asset to reflect the state `XRInputSource`
1. Optionally attach descriptive explanations to each component that will not overlap the rest of the 3D asset
The state of an XR motion controller's trigger, squeeze, touchpad, thumbstick, and button components is made available to developers via the `XRInputSource.Gamepad` object. The behavior of this object is described in [WebXR Gamepads Module](https://www.w3.org/TR/webxr-gamepads-module/) and the [Gamepad API](https://www.w3.org/TR/gamepad/). These objects expose detailed state in the `Gamepad.buttons` array and the `Gamepad.axes` array. While this system was adequate for the relatively homogenous console gaming controllers, it is less effective for XR motion controllers as they have not converged on a common form factor. In addition, the `Gamepad` object does not provide any information about the visualization of a `XRInputSource` object which is a requirement to display a virtual copy of a motion controller on opaque XR headsets.
## Contributing
### Filing a bug
To file bugs, use this [issue template](https://github.com/immersive-web/webxr-input-profiles/issues/new?assignees=&labels=motion-controller&template=motioncontroller-library-bug-report.md&title=)
This file has been truncated. show original
Thanks for the support
Looking at the what you have linked, it looks like they find the node that represents the button/stick on the model and animate directly by tweening/modifying the transform https://github.com/immersive-web/webxr-input-profiles/blob/main/packages/motion-controllers/README.md#animating-components
So you would get the state of the buttons and sticks rotate/translate accordingly.
It looks like you can get that state from the gamepads and events on XrInputSource:
InputSource object is returned when the controllers are detected:
https://playcanvas.com/editor/code/706679?tabs=33666523
Or you can get a list from https://api.playcanvas.com/classes/Engine.XrInput.html#inputSources where XrInput can be retrieved from https://api.playcanvas.com/classes/Engine.XrManager.html#input which is found on the application object https://api.playcanvas.com/classes/Engine.Application.html#xr
1 Like
Good!
They are talking about calling every frame :
motionController.updateFromGamepad();
what would be the equivalent in playcanvas of motionController?
Thank you?
@max will know more but AFAIK, that’s not needed here. Your animation code can just read use the https://api.playcanvas.com/classes/Engine.XrInputSource.html#gamepad state and/or events on the Xr Input Source
1 Like
OK then! I’ll give a try.
Thank you
moka
May 20, 2021, 9:44am
8
Hi @memleak , models in the example above, are provided by the WebXR community, and do have individual buttons there. You would need to inspect the model, either by using container asset import settings in a project or using PlayCanvas glTF Viewer - so you can find the right node for each button.
Then you can access each axis and button state through gamepad
property on input source: https://api.playcanvas.com/classes/Engine.XrInputSource.html#gamepad
2 Likes