Skip to content

Commit

Permalink
Set up app icon and spash screen. Tested various configurations of to…
Browse files Browse the repository at this point in the history
…uch input with no luck.
  • Loading branch information
pablothedolphin committed Apr 29, 2020
1 parent 06b9c45 commit 6025568
Show file tree
Hide file tree
Showing 9 changed files with 435 additions and 31 deletions.
5 changes: 3 additions & 2 deletions Speckle Viewer/Assets/Scenes/Main Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
mouseSensitivity: 4
touchSensitivity: 0.2
touchSensitivity: 0.01
scrollSensitvity: 2
pinchSensitvity: 0.005
orbitDampening: 20
scrollDampening: 20
cameraDisabled: 0
Expand Down Expand Up @@ -2183,7 +2184,7 @@ MonoBehaviour:
pointMaterial: {fileID: 0}
scaleFactor: 0.001
renderingRule: {fileID: 11400000, guid: 7d66ffdb47f1cc445a885cea41fc7b43, type: 2}
spawnSpeed: 100
spawnSpeed: 10
onUpdateProgress:
m_PersistentCalls:
m_Calls:
Expand Down
76 changes: 63 additions & 13 deletions Speckle Viewer/Assets/Scripts/Camera System/CameraSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.EnhancedTouch;
//using UnityEngine.InputSystem;
//using UnityEngine.InputSystem.EnhancedTouch;
using System.Collections;
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
//using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;

public class CameraSystem : MonoBehaviour
{
Expand All @@ -16,19 +16,23 @@ public class CameraSystem : MonoBehaviour
public float mouseSensitivity = 4f;
public float touchSensitivity = 0.2f;
public float scrollSensitvity = 2f;
public float pinchSensitvity = 0.2f;
public float orbitDampening = 20f;
public float scrollDampening = 20f;

public bool cameraDisabled = false;

private float previousPinchDistance = 0;

// Use this for initialization
void Start ()
{
Application.targetFrameRate = 30;

camTransform = transform;
pivotTransform = transform.parent;

EnhancedTouchSupport.Enable ();
//EnhancedTouchSupport.Enable ();
}

public void FocusOnModel (Bounds modelBounds)
Expand All @@ -43,20 +47,22 @@ void LateUpdate ()
if (cameraDisabled) return;
if (InputValidation.IsPointerOverUIObject ()) return;

ApplyDesktopInput ();
ApplyTouchInput ();
RegisterDesktopInput ();
RegisterTouchInput ();

//Actual Camera Rig Transformations
Quaternion QT = Quaternion.Euler (eulerRotation.x, eulerRotation.y, 0);
pivotTransform.rotation = Quaternion.Lerp (pivotTransform.rotation, QT, Time.deltaTime * orbitDampening);
Quaternion desiredRotation = Quaternion.Euler (eulerRotation.x, eulerRotation.y, 0);
pivotTransform.rotation = Quaternion.Lerp (pivotTransform.rotation, desiredRotation, Time.deltaTime * orbitDampening);

distanceFromPivot = Mathf.Clamp (distanceFromPivot, 1, 10000);

if (camTransform.localPosition.z != distanceFromPivot * -1f)
{
camTransform.localPosition = new Vector3 (0f, 0f, Mathf.Lerp (camTransform.localPosition.z, distanceFromPivot * -1f, Time.deltaTime * scrollDampening));
}
}

private void ApplyDesktopInput ()
private void RegisterDesktopInput ()
{
if (Input.GetMouseButton (0))
{
Expand All @@ -83,14 +89,58 @@ private void ApplyDesktopInput ()
}
}

private void ApplyTouchInput ()
private void RegisterTouchInput ()
{
if (Touch.activeTouches.Count > 0)
if (Input.touchCount == 1 && Input.GetTouch (0).phase == TouchPhase.Moved)
{
eulerRotation.y += Touch.activeTouches[0].delta.x * touchSensitivity;
eulerRotation.x -= Touch.activeTouches[0].delta.y * touchSensitivity;
eulerRotation.y += Input.GetTouch (0).deltaPosition.x * touchSensitivity;
eulerRotation.x -= Input.GetTouch (0).deltaPosition.y * touchSensitivity;

eulerRotation.x = Mathf.Clamp (eulerRotation.x, -90f, 90f);
}

if (Input.touchCount == 2 && (Input.GetTouch (0).phase == TouchPhase.Moved || Input.GetTouch (1).phase == TouchPhase.Moved))
{
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;
}
}
/*
if (Touch.activeTouches.Count == 1)
{
if (Touch.activeTouches[0].phase == UnityEngine.InputSystem.TouchPhase.Began)
{
Touch.activeTouches[0].screenPosition
}
if (Touch.activeTouches[0].phase != UnityEngine.InputSystem.TouchPhase.Began)
{
eulerRotation.y += Touch.activeTouches[0].delta.x * touchSensitivity;
eulerRotation.x -= Touch.activeTouches[0].delta.y * touchSensitivity;
eulerRotation.x = Mathf.Clamp (eulerRotation.x, -90f, 90f);
}
}
if (Touch.activeTouches.Count == 2)
{
float currentPinchDistance = Vector2.Distance (Touch.activeTouches[0].screenPosition, Touch.activeTouches[1].screenPosition);
if (Touch.activeTouches[1].phase == UnityEngine.InputSystem.TouchPhase.Began)
{
previousPinchDistance = currentPinchDistance;
}
else if (Touch.activeTouches[1].phase == UnityEngine.InputSystem.TouchPhase.Moved)
{
distanceFromPivot += (previousPinchDistance - currentPinchDistance) * pinchSensitvity;
}
}
*/
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions Speckle Viewer/Assets/Sprites/speckle-logo-inverted.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Speckle Viewer/Assets/Sprites/speckle-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions Speckle Viewer/Assets/Sprites/speckle-logo.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Speckle Viewer/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"com.unity.device-simulator": "2.2.2-preview",
"com.unity.ide.visualstudio": "2.0.1",
"com.unity.inputsystem": "1.0.0-preview.7",
"com.unity.mobile.android-logcat": "1.1.1",
"com.unity.render-pipelines.universal": "8.0.1",
"com.unity.xr.arcore": "3.0.4",
"com.unity.xr.arfoundation": "3.0.1",
Expand Down
Loading

0 comments on commit 6025568

Please sign in to comment.