Ejemplo n.º 1
0
    void FollowByHitRotation(WebXRHitPoseData hitPoseData)
    {
        Quaternion rotationOffset = Quaternion.Inverse(hitPoseData.rotation);

        WebXRManager.Instance.transform.localPosition = rotationOffset * (originPosition - hitPoseData.position);
        WebXRManager.Instance.transform.localRotation = rotationOffset;
    }
Ejemplo n.º 2
0
    void FollowByViewRotation(WebXRHitPoseData hitPoseData)
    {
        Vector2    diff           = new Vector2(hitPoseData.position.x, hitPoseData.position.z) - new Vector2(arCameraTransform.localPosition.x, arCameraTransform.localPosition.z);
        float      angle          = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg - 90f;
        Quaternion rotationOffset = Quaternion.Euler(0, angle, 0);

        WebXRManager.Instance.transform.localPosition = rotationOffset * (originPosition - hitPoseData.position);
        WebXRManager.Instance.transform.localRotation = rotationOffset;
    }
Ejemplo n.º 3
0
 void HandleOnViewerHitTestUpdate(WebXRHitPoseData hitPoseData)
 {
     visual.SetActive(hitPoseData.available);
     if (hitPoseData.available)
     {
         isFollowing             = true;
         transform.localPosition = hitPoseData.position;
         transform.localRotation = hitPoseData.rotation;
         FollowByViewRotation(hitPoseData);
     }
 }