-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
69 lines (48 loc) · 1.85 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: "XRFrame: fillPoses() method"
short-title: fillPoses()
slug: Web/API/XRFrame/fillPoses
page-type: web-api-instance-method
status:
- experimental
browser-compat: api.XRFrame.fillPoses
---
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The **`fillPoses()`** method of the {{domxref("XRFrame")}} interface populates a {{jsxref("Float32Array")}} with the matrices of the poses relative to a given base space and returns `true` if successful for all spaces.
## Syntax
```js-nolint
fillPoses(spaces, baseSpace, transforms)
```
### Parameters
- `spaces`
- : An array of {{domxref("XRSpace")}} objects for which to get the poses.
- `baseSpace`
- : An {{domxref("XRSpace")}} object to use as the base or origin for the relative position and orientation.
- `transforms`
- : A {{jsxref("Float32Array")}} that is populated with the matrices of the poses relative to the given `baseSpace`.
### Return value
A boolean indicating if all of the spaces have a valid pose.
### Exceptions
- {{jsxref("TypeError")}}
- : Thrown if the length of `spaces` multiplied by 16 is larger than the number of elements in `transforms`.
## Examples
### Obtaining poses for all joints of a hand
To efficiently get all poses for all 25 joints of each {{domxref("XRHand")}}, you can use the `fillPoses()` method.
```js
let poses1 = new Float32Array(16 * 25);
let poses2 = new Float32Array(16 * 25);
function onXRFrame(xrFrame, renderer) {
let hand1 = xrFrame.session.inputSources[0].hand;
xrFrame.fillPoses(hand1.values(), renderer.referenceSpace, poses1);
let hand2 = xrFrame.session.inputSources[1].hand;
xrFrame.fillPoses(hand2.values(), renderer.referenceSpace, poses2);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("XRHand")}}
- {{domxref("XRJointSpace")}}
- {{jsxref("Float32Array")}}