Beispiel #1
0
 IObservable <Vector3> DragAsObservable()
 {
     return(Observable.Defer(() =>
     {
         var grabbedAt = InputEmulator.GetRealPosition(Controller.Position);
         return this.UpdateAsObservable().Select(_ => InputEmulator.GetRealPosition(Controller.Position) - grabbedAt);
     }));
 }
Beispiel #2
0
 IObservable <Unit> MoveToRotateAsObservable(IObservable <Vector3> move)
 {
     return(Observable.Defer(() =>
     {
         var offset = Target.localPosition;
         var length = Mathf.Min(BaseHeight / Mathf.Abs(Mathf.Tan(HMD.Rotation.eulerAngles.x * Mathf.Deg2Rad)), CenterOffsetMax);
         var virtualCenter = HMD.Position + Quaternion.Euler(0, HMD.Rotation.eulerAngles.y, 0) * Vector3.forward * length;
         var realCenter = InputEmulator.GetRealPosition(virtualCenter);
         var startVirtualRotation = InputEmulator.CurrentRotation;
         var startRealRotation = InputEmulator.GetRealRotation(HMD.Rotation);
         return Observable.Scan(move, (a, b) => a + b * Time.deltaTime)
         .Select(movement => Quaternion.Inverse(startRealRotation) * movement * Scale)
         .Select(movement => startVirtualRotation * Quaternion.Euler(0, movement.y, 0))
         .ForEachAsync(r => SetRotation(offset, startVirtualRotation, realCenter, r));
     }));
 }