Skip to content

Commit

Permalink
Touch input now properly registers obit, zoom and pan. There is now a…
Browse files Browse the repository at this point in the history
… basic help dialog option. Removing a stream also refocusses the camera view. Updated readme file.
  • Loading branch information
pablothedolphin committed Apr 29, 2020
1 parent 6025568 commit 9a398cb
Show file tree
Hide file tree
Showing 18 changed files with 1,732 additions and 186 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ In this repository you will find the source code, assets and project settings of
| ~0.1~ | ~Material UI framework and orbiting streamed objects~ |
| ~0.2~ | ~Touch support and focussing view on streams~ |
| 0.3 | Select objects and inspect their data |
| 0.4 | Scale some UI panels according to screen dimensions |
| 1.0 | Toggle Augmented Reality view to place, move and scale a world anchor in AR |
462 changes: 308 additions & 154 deletions Speckle Viewer/Assets/Scenes/Main Scene.unity

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions Speckle Viewer/Assets/Scripts/Camera System/CameraSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ public class CameraSystem : MonoBehaviour
protected Vector3 eulerRotation = new Vector3 (15, 30, 0);
protected float distanceFromPivot = 30f;

public float mouseSensitivity = 4f;
public float touchSensitivity = 0.2f;
public float scrollSensitvity = 2f;
public float pinchSensitvity = 0.2f;
public float panSensitivity = 0.5f;

[Space, Space]
public float mouseSensitivity = 4f;
public float scrollSensitvity = 2f;
public float orbitDampening = 20f;
public float scrollDampening = 20f;

Expand Down Expand Up @@ -47,7 +50,8 @@ void LateUpdate ()
if (cameraDisabled) return;
if (InputValidation.IsPointerOverUIObject ()) return;

RegisterDesktopInput ();
if (Application.platform != RuntimePlatform.Android)
RegisterDesktopInput ();
RegisterTouchInput ();

//Actual Camera Rig Transformations
Expand Down Expand Up @@ -103,15 +107,16 @@ private void RegisterTouchInput ()
{
float currentPinchDistance = Vector2.Distance (Input.GetTouch (0).position, Input.GetTouch (1).position);

if (Input.GetTouch (1).phase == TouchPhase.Began)
{
previousPinchDistance = currentPinchDistance;
}
else if (Input.GetTouch (1).phase == TouchPhase.Moved)
{
distanceFromPivot += (previousPinchDistance - currentPinchDistance) * pinchSensitvity;
}
distanceFromPivot += currentPinchDistance * pinchSensitvity * (currentPinchDistance > previousPinchDistance ? -1 : 1);
previousPinchDistance = currentPinchDistance;
}

if (Input.touchCount == 3 && Input.GetTouch (0).phase == TouchPhase.Moved)
{
pivotTransform.Translate (Vector3.right * Input.GetTouch (0).deltaPosition.x * panSensitivity * -1);
pivotTransform.Translate (transform.up * Input.GetTouch (0).deltaPosition.y * panSensitivity * -1, Space.World);
}

/*
if (Touch.activeTouches.Count == 1)
{
Expand Down
7 changes: 6 additions & 1 deletion Speckle Viewer/Assets/Scripts/UI/LoginBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ private void UpdateLoginButtonState ()
loginButton.interactable = serverFieldHasInput && emailFieldHasInput && passwordFieldHasInput;
}

public async void AttemptLogin ()
public void AttemptLogin ()
{
_ = RunAsyncLogin ();
}

private async Task RunAsyncLogin ()
{
manager.SetServerUrl (serverURL);

Expand Down
6 changes: 6 additions & 0 deletions Speckle Viewer/Assets/Scripts/UI/NavDrawerBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class NavDrawerBehaviour : MonoBehaviour
public StreamSelectionBehaviour streamSelector;
public StreamRemoverBehaviour streamRemover;

public DialogBoxConfig helpDialog;
private NavDrawerConfig navDrawer;


Expand All @@ -30,6 +31,11 @@ public void OnRemoveStream ()
navDrawer.Close ();
}

public void OnHelp ()
{
helpDialog.Open ();
}

public void OnLogout ()
{
SceneManager.LoadScene (0);
Expand Down
5 changes: 5 additions & 0 deletions Speckle Viewer/Assets/Scripts/UI/StreamRemoverBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

public class StreamRemoverBehaviour : StreamSelectionBehaviour
{
public CameraSystem cameraSystem;

public override void Initialize ()
{
dialogBox.Open ();
Expand All @@ -16,5 +18,8 @@ public override void SelectStream (SpeckleStream stream)
{
dialogBox.Close ();
manager.RemoveReceiver (stream.StreamId);

Bounds modelBounds = manager.GetBoundsForAllReceivedStreams ();
cameraSystem.FocusOnModel (modelBounds);
}
}
Binary file modified Speckle Viewer/Assets/Sprites/speckle-logo-inverted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9a398cb

Please sign in to comment.