メインコンテンツへスキップ

xrhandupdated

概要

このイベントは、 xrhand によって、その後にハンドが見つかったときに呼び出されます。

xrhandupdated.detail : {id, transform, vertices, normals, handKind, attachmentPoints}

プロパティ説明
id位置する手の数値ID。
transform: {position, rotation, scale}位置する手の情報を変換する。
vertices: [{x, y, z}]ハンドポイントの位置、トランスフォームに対する相対位置。
normals: [{x, y, z}]transformに対する相対な頂点の法線方向。
handKind手の位置を数値で表したもの。 有効な値は0(指定なし)、1(左)、2(右)。
attachmentPoints: { name, position: {x,y,z} }利用可能なアタッチメントポイントのリストについては、 XR8.HandController.AttachmentPoints を参照してください。 position は、トランスフォームからの相対位置です。

transform は、以下のプロパティを持つオブジェクトです。

プロパティ説明
position {x, y, z}位置する手の3Dポジション。
rotation {w, x, y, z}配置された手の3次元の局所的な向き。
scaleこの手に取り付けられているオブジェクトに適用されるスケールファクター。

attachmentPoints は、以下のプロパティを持つオブジェクトである:

プロパティ説明
nameアタッチメントポイントの名前。 利用可能なアタッチメントポイントのリストについては、 XR8.HandController.AttachmentPoints を参照してください。
position {x, y, z}位置する手の取り付け位置の3Dポジション。
rotation {w, x, y, z}Y軸正方向ベクトルを取り付け点の骨ベクトルに回転させる回転クォータニオン。
innerPoint {x, y, z}アタッチメントポイントの内側の点。 (例:手のひら側)
outerPoint {x, y, z}アタッチメントポイントの外側の点。 (例:手の甲)
radius指の取り付け点の半径。
minorRadius手の表面から手首の取り付け点までの最短半径。
majorRadius手の表面から手首の取り付け点までの最長半径。

const handRigidComponent = {
init: function () {
const object3D = this.el.object3D
object3D.visible = false
const show = ({detail}) => {
const {position, rotation, scale} = detail.transform
object3D.position.copy(position)
object3D.quaternion.copy(rotation)
object3D.scale.set(scale, scale, scale)
object3D.visible = true
}
const hide = ({detail}) => { object3D.visible = false }
this.el.sceneEl.addEventListener('xrhandfound', show)
this.el.sceneEl.addEventListener('xrhandupdated', show)
this.el.sceneEl.addEventListener('xrhandlost', hide)
}.
}