diff --git a/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js b/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js index 9bd43b5..6010095 100644 --- a/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js +++ b/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js @@ -1,8 +1,14 @@ // 'esversion: 6' -// Remember: also change Assets\WebGLTemplates\KomodoWebXRFullView2020\relay.js (or re-copy the WebGLTemplates to the Assets folder) if you intend for the changes to be reflected in the build. If you are reading this from inside a build folder, you can change this file as you please. +// Remember: also change Assets\WebGLTemplates\KomodoWebXRFullView2020\relay.js (or +// re-copy the WebGLTemplates to the Assets folder) if you intend for the changes to +// be reflected in the build. If you are reading this from inside a build folder, +// you can change this file as you please. -// Tip: if you need to change this on-the-fly, you can edit this file without rebuilding. It's also possible to use the inspector to inspect the VR frame and call `window.RELAY_API_BASE_URL=""`, if for some reason you need to do that in real time. +// Tip: if you need to change this on-the-fly, you can edit this file without +// rebuilding. It's also possible to use the inspector to inspect the VR frame and +// call `window.RELAY_API_BASE_URL=""`, if for some reason you +// need to do that in real time. /* * --------------------------------------------------------------------------------- @@ -11,14 +17,22 @@ */ // Replace these with your own server's URLs. - -var RELAY_BASE_URL = "http://localhost:3000"; -var API_BASE_URL = "http://localhost:4040"; -var VR_BASE_URL = "http://localhost:8123"; //TODO -- change this to a better default - -// init globals which Unity will assign when setup is done. -var sync = null; -var chat = null; +// +// If running each of these without Docker: +// - RELAY_BASE_URL: Look in komodo-relay > serve.js or config.js for the port number +// - API_BASE_URL: Look in komodo-portal > config.js > web.port for the port number +// - VR_BASE_URL: This will be unused for local builds +// +// If running each of these with Docker: +// - RELAY_BASE_URL: Look in komodo-relay > docker-compose.yml > +// services.komodo-relay.labels > traefik.frontend.rule +// - API_BASE_URL: Look in komodo-portal > docker-compose.yml > +// services.backend.labels > traefik.frontend.rule +// - VR_BASE_URL: Look in komodo-portal > .env.* > VUE_APP_VR_CLIENT_BASE_URL + +var RELAY_BASE_URL = "http://localhost:3000"; +var API_BASE_URL = "http://localhost:4040"; +var VR_BASE_URL = "http://localhost:8123"; /* * --------------------------------------------------------------------------------- @@ -26,6 +40,10 @@ var chat = null; * --------------------------------------------------------------------------------- */ +// init globals which Unity will assign when setup is done. +var sync = null; +var chat = null; + /** * Get the URL parameters * source: https://css-tricks.com/snippets/javascript/get-url-variables/ @@ -92,8 +110,6 @@ var splitAppAndBuild = function (appAndBuild) { var runtimeAppAndBuild = removeVRBaseUrl(removeQuery(window.location.href)); -//console.log(runtimeAppAndBuild); - // TODO(Brandon): in the future, pass app and build as separate details like this: // var result = splitAppAndBuild(runtimeAppAndBuild); // var runtimeApp = result.app; @@ -130,7 +146,7 @@ request.open("GET", url, true); request.responseType = "json"; request.send(); -request.onload = function(){ +request.onload = function() { let res = request.response; // session details @@ -145,14 +161,15 @@ request.onload = function(){ details.users = res.users; let assets_response = res.assetList; - for (idx = 0; idx < assets_response.length; idx++) - { + + for (idx = 0; idx < assets_response.length; idx++) { asset = new Object; asset.id = assets_response[idx].asset_id; asset.name = assets_response[idx].asset_name; asset.url = assets_response[idx].path; asset.isWholeObject = Boolean(assets_response[idx].is_whole_object); asset.scale = assets_response[idx].scale || 1; + details.assets.push(asset); } }; diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs index c6a631f..3bbd7a7 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs @@ -52,61 +52,6 @@ namespace Komodo.Runtime [System.Serializable] public class UnityEvent_Int : UnityEvent { } [System.Serializable] public class UnityEvent_String : UnityEvent { } - //For handling different type of text between clients - public enum STRINGTYPE - { - TUTORIAL, - CLIENT_NAME, - SPEECH_TO_TEXT, - } - public struct SpeechToTextSnippet - { - public int target; - public int stringType; - public string text; - } - //types of data in scene - public enum Entity_Type - { - none = -1, - users_head = 0, - users_Lhand = 1, - users_Rhand = 2, - objects = 3, - physicsObject = 4, - main_Player = 5, - physicsEnd = 8, - Line = 10, - LineEnd = 11, - LineDelete = 12, - LineRender = 13, - LineNotRender = 14, - } - - #region INTERACTION TYPES - public enum INTERACTIONS - { - LOOK = 0, - LOOK_END = 1, - SHOW = 2, - HIDE = 3, - GRAB = 4, - DROP = 5, - CHANGE_SCENE = 6, - SLICE_OBJECT = 7, - LOCK = 8, - UNLOCK = 9, - LINE = 10, - LINE_END = 11, - SHOW_MENU = 12, - HIDE_MENU = 13, - - SETTING_TAB = 14, - PEOPLE_TAB = 15, - INTERACTION_TAB = 16, - CREATE_TAB = 17, - } - #endregion /// /// This class is meant to: /// --- set up main player @@ -560,7 +505,9 @@ public void AddNewClient(int clientID, bool isMainPlayer = false) var ROT = entityManager.GetComponentData(avatarEntityGroupFromClientId[clientID].rootEntity).Value.value;//.entity_data.rot; - //To prevent offset issues when working with editor + + // TODO -- investigate whether this area is a cause of the + // hand position and rotation being wrong in the browser #if UNITY_WEBGL && !UNITY_EDITOR || TESTING_BEFORE_BUILDING mainPlayer.transform.position = temp.position; @@ -719,100 +666,6 @@ public async void DestroyClient(int clientID) } #endregion - #region Create A Network Managed Objects - - - #endregion - - #region Draw Receive Calls - //Setting up Line Rendering Calls - private Dictionary lineRenderersInQueue = new Dictionary(); - private Dictionary allStrokeIDValidator = new Dictionary(); - - //To avoid duplicating stroke ids because sending different ids states ma - public void Draw_Refresh(string stringData)//Draw newData) - { - Draw newData = JsonUtility.FromJson(stringData); - - - LineRenderer currentLineRenderer = default; - - //we start a new line if there is no ID already corresponding to one in the scene - if (!allStrokeIDValidator.ContainsKey(newData.strokeId)) - { - GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject; - lineRendCopy.name = "LineR:" + newData.strokeId; - - lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true); - currentLineRenderer = lineRendCopy.GetComponent(); - - currentLineRenderer.positionCount = 0; - - allStrokeIDValidator.Add(newData.strokeId, newData.strokeId); - lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer); - } - - //we get reference to the linenderer we are supposed to be working with - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - currentLineRenderer = lineRenderersInQueue[newData.strokeId]; - - switch (newData.strokeType) - { - //Continues A Line - case (int)Entity_Type.Line: - - var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w); - currentLineRenderer.startColor = brushColor; - currentLineRenderer.endColor = brushColor; - currentLineRenderer.widthMultiplier = newData.lineWidth; - - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - - break; - - //Ends A Line A completes its setup - case (int)Entity_Type.LineEnd: - - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - - //Create external client stroke instance - DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); //new GameObject("LineRender:" + (newData.strokeId), typeof(BoxCollider//; - - break; - - //Deletes a Line - case (int)Entity_Type.LineDelete: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - lineRenderersInQueue.Remove(newData.strokeId); - - Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject); - NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId); - } - break; - - case (int)Entity_Type.LineRender: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true); - - break; - - case (int)Entity_Type.LineNotRender: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false); - - break; - } - } - - #endregion - public void AddClientIfNeeded (int id) { if (NetworkUpdateHandler.Instance.client_id == id) @@ -941,16 +794,8 @@ public void ApplyPositionToRightHand(Position positionData) } #region Text Receive Calls - - public struct SpeechToText - { - public int session_id; - public int client_id; - public string text; - public string type; - public int ts; - } - + // TODO: as much as possible, move these functions to static functions + // in SpeechToText.cs public void OnReceiveSpeechToTextSnippet(string data) { var deserializedData = JsonUtility.FromJson(data); @@ -989,13 +834,9 @@ public void ProcessSpeechToTextSnippet(SpeechToTextSnippet newText) clientIndex = avatarIndexFromClientId[newText.target]; clientUsernameDisplays[clientIndex].text = newText.text; break; - } - } - - private static string SplitWordsByLength(string str, int maxLength) { List chunks = new List(); @@ -1057,10 +898,8 @@ public IEnumerator SetTextTimer(int textIndex, string textD, float seconds = 5) } - public IEnumerator ShutOffText(int textIndex, float seconds) { - clientSpeechToTextDisplays[textIndex].transform.parent.gameObject.SetActive(true); // secondsToWaitDic[index] -= seconds; diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs new file mode 100644 index 0000000..fa484c5 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + [System.Serializable] + public struct EntityState + { + public int id; + public Position latest; + public bool render; + public bool locked; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta new file mode 100644 index 0000000..b470494 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c28255cb2cf4a9d489bbee5f880787ac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs new file mode 100644 index 0000000..1b0c950 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + //types of data in scene + public enum Entity_Type + { + none = -1, + users_head = 0, + users_Lhand = 1, + users_Rhand = 2, + objects = 3, + physicsObject = 4, + main_Player = 5, + physicsEnd = 8, + Line = 10, + LineEnd = 11, + LineDelete = 12, + LineRender = 13, + LineNotRender = 14, + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta new file mode 100644 index 0000000..5328995 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 553819b7d55679f4c9783217f1282e16 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index ab6aa7e..ce9efd8 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -1,6 +1,5 @@ using UnityEngine; using Unity.Entities; -using static Komodo.Runtime.NetworkUpdateHandler; namespace Komodo.Runtime { @@ -9,14 +8,17 @@ namespace Komodo.Runtime public class TriggerDraw : MonoBehaviour { private Transform thisTransform; + private LineRenderer lineRenderer; public float distanceThreshold = 0.5f; public float timeToCheckNewStrokeIndex; + private float timePass; private int curLineIndex = 0; + private int strokeID = 0; private int strokeIndex; @@ -24,24 +26,19 @@ public class TriggerDraw : MonoBehaviour [Header("IDENTIFY INTERACTION ID, PLACE A UNIQUE NUMBER EXCEPT 0")] public int handID; - - //to disable drawing during color picker selection through unity events; // color+picker.cs adjust this + //to disable drawing during color picker selection through unity events; [HideInInspector] public bool isSelectingColorPicker; private EntityManager entityManager; - //to disable drawing during erassing funcionality + //to disable drawing during erasing funcionality private bool isEraserOn = false; - - public void Set_DRAW_UPDATE(bool active) { isEraserOn = active; } - - public virtual void Start() { entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; @@ -54,7 +51,6 @@ public virtual void Start() thisTransform = transform; } - public void Update() { if (lineRenderer == null || thisTransform == null || isEraserOn || isSelectingColorPicker) @@ -68,30 +64,40 @@ public void Update() float curDistance = 0; - if (lineRenderer.positionCount == 0) { ++lineRenderer.positionCount; lineRenderer.SetPosition(0, thisTransform.position); - curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(0)); + curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(0)); } else + { curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(curLineIndex)); - + } if (curDistance > distanceThreshold) { //update visuals per stroke - ////offset: 5000 + clientid + child render count - /// - - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(strokeID, Entity_Type.Line, lineRenderer.widthMultiplier, lineRenderer.GetPosition(curLineIndex), - new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a)); - + //offset: 5000 + clientid + child render count + + DrawingInstanceManager.Instance.SendDrawUpdate( + strokeID, + Entity_Type.Line, + lineRenderer.widthMultiplier, + lineRenderer.GetPosition(curLineIndex), + new Vector4 + ( + lineRenderer.startColor.r, + lineRenderer.startColor.g, + lineRenderer.startColor.b, + lineRenderer.startColor.a + ) + ); ++lineRenderer.positionCount; + curLineIndex++; lineRenderer.SetPosition(curLineIndex, thisTransform.position); @@ -99,39 +105,56 @@ public void Update() } } - //THIS IS WHERE FUNCTIONS ARE INVOKED (ON RELEASE OF TRIGGER BUTTON WHICH DEACTIVATES PARENT OBJECT public virtual void OnDisable() { //get rid of uncompleted stroke saved up locations if (lineRenderer.positionCount == 1) + { lineRenderer.positionCount = 0; + } if (lineRenderer == null || lineRenderer.positionCount <= 1) + { return; + } //make strokeID identical based on left or right hand add an offset *100 strokeID * 10000 //ALL STROKE IDS HAVE TO BE UNIQUE TO REFERENCE THROGH THE NETWORK if (NetworkUpdateHandler.IsAlive) + { strokeID = handID * 1000000 + 100000 + NetworkUpdateHandler.Instance.client_id * 10000 + strokeIndex; + + // TODO: refactor the multiple instances of this + // calculation into one method. + + // TODO: evaluate reduced human readability if there + // are 100 or more registered clients. + // Consider client 111. Then the equation would be + // 1000000 + 100000 + 1110000 + 1234 + // = 2210000 + 891234 + // = 3101234 + // The apparent hand is 3 and apparent client ID is 10, + // but the actual hand is 1 and the actual client ID is + // 111. + } else + { return; + } - //GameObject pivot = - DrawingInstanceManager.Instance.CreateUserStrokeInstance(strokeID, lineRenderer, true); + DrawingInstanceManager.Instance.InitializeFinishedLineFromOwnClient(strokeID, lineRenderer, true); curLineIndex = 0; - //pivot.transform.SetParent(lineRendererSharedContainer); - strokeIndex++; - //updateID + if (NetworkUpdateHandler.IsAlive) + { strokeID = handID * 1000000 + 100000 + NetworkUpdateHandler.Instance.client_id * 10000 + strokeIndex; + } lineRenderer.positionCount = 0; - } - } } \ No newline at end of file diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs new file mode 100644 index 0000000..7305c72 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + public enum INTERACTIONS + { + LOOK = 0, + LOOK_END = 1, + SHOW = 2, + HIDE = 3, + GRAB = 4, + DROP = 5, + CHANGE_SCENE = 6, + SLICE_OBJECT = 7, + LOCK = 8, + UNLOCK = 9, + LINE = 10, + LINE_END = 11, + SHOW_MENU = 12, + HIDE_MENU = 13, + + SETTING_TAB = 14, + PEOPLE_TAB = 15, + INTERACTION_TAB = 16, + CREATE_TAB = 17, + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta new file mode 100644 index 0000000..e828052 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ecb7ba8a86c8d94cb4c7064cc5ae17f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index 91825a7..ddbdd7a 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -3,16 +3,15 @@ using System.Collections.Generic; using System; using Komodo.Utilities; -//using static Komodo.Runtime.NetworkUpdateHandler; namespace Komodo.Runtime { - //may need to rename this if we are including primitive shapes to our list public class DrawingInstanceManager : SingletonComponent { public static DrawingInstanceManager Instance { - get { return ((DrawingInstanceManager)_Instance); } + get { return (DrawingInstanceManager) _Instance; } + set { _Instance = value; } } @@ -21,8 +20,11 @@ public static DrawingInstanceManager Instance public EntityManager entityManager; [HideInInspector] public Transform userStrokeParent; + [HideInInspector] public Transform externalStrokeParent; + private Dictionary lineRendererFromId = new Dictionary(); + public void Awake() { //used to set our managers alive state to true to detect if it exist within scene @@ -34,18 +36,19 @@ public void Awake() //parent for our stored lines userStrokeParent = new GameObject("UserStrokeParent").transform; + externalStrokeParent = new GameObject("ExternalClientStrokeParent").transform; userStrokeParent.SetParent(transform); + externalStrokeParent.SetParent(transform); - //register our message type with the funcion - GlobalMessageManager.Instance.Subscribe("draw", (str) => Draw_Refresh(str)); + GlobalMessageManager.Instance.Subscribe("draw", (str) => ReceiveDrawUpdate(str)); } - public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bool sendNetworkCall) + public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineRenderer, bool doSendNetworkUpdate) { - //used to set correct pivot point when scalling object by grabbing + //set correct pivot point when scaling object by grabbing GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); if (lineRendererContainerPrefab == null) @@ -54,202 +57,296 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo } GameObject lineRendCopy = Instantiate(lineRendererContainerPrefab).gameObject; + lineRendCopy.name = "LineR:" + strokeID; //Create a reference to use in network - var nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); + NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); + + // Make own client's draw strokes grabbable + pivot.tag = TagList.interactable; - //tag it as a drawing for ECS - pivot.tag = TagList.drawing; entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); var bColl = pivot.GetComponent(); + LineRenderer copiedLR = lineRendCopy.GetComponent(); var color = lineRenderer.startColor; + copiedLR.startColor = color; + copiedLR.endColor = color; copiedLR.widthMultiplier = lineRenderer.widthMultiplier; Bounds newBounds = new Bounds(lineRenderer.GetPosition(0), Vector3.one * 0.01f); + copiedLR.positionCount = 0; for (int i = 0; i < lineRenderer.positionCount; i++) { copiedLR.positionCount++; + copiedLR.SetPosition(i, lineRenderer.GetPosition(i)); - newBounds.Encapsulate(new Bounds(lineRenderer.GetPosition(i), Vector3.one * 0.01f));//lineRenderer.GetPosition(i)); + newBounds.Encapsulate(new Bounds(lineRenderer.GetPosition(i), Vector3.one * 0.01f)); } pivot.transform.position = newBounds.center; - bColl.center = lineRendCopy.transform.position; //newBounds.center;//averageLoc / lr.positionCount;//lr.GetPosition(0)/2; + + bColl.center = lineRendCopy.transform.position; + bColl.size = newBounds.size; lineRendCopy.transform.SetParent(pivot.transform, true); - if (sendNetworkCall) + if (doSendNetworkUpdate) { - SendStrokeNetworkUpdate(strokeID, Entity_Type.LineEnd, copiedLR.widthMultiplier, lineRenderer.GetPosition(lineRenderer.positionCount - 1), new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a)); + SendDrawUpdate( + strokeID, + Entity_Type.LineEnd, + copiedLR.widthMultiplier, + lineRenderer.GetPosition(lineRenderer.positionCount - 1), + new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a) + ); } pivot.transform.SetParent(userStrokeParent, true); if (UndoRedoManager.IsAlive) + { //save undoing process for ourselves and others UndoRedoManager.Instance.savedStrokeActions.Push(() => { pivot.SetActive(false); - //send network update call for everyone else - SendStrokeNetworkUpdate(strokeID, Entity_Type.LineNotRender); + SendDrawUpdate(strokeID, Entity_Type.LineNotRender); }); - + } } - - public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer currentLineRenderer) + public void InitializeFinishedLineFromOtherClient(int strokeID, LineRenderer renderer) { GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); - NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); + NetworkedGameObject netObject = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); + + // Make other clients' draw strokes grabbable + pivot.tag = TagList.interactable; - //overide interactable tag when creatingNetworkGameObject since we are not moving drawings only deleting them - pivot.tag = TagList.drawing; //tag created drawing object will be useful in the future for having items with multiple tags - entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); + entityManager.AddComponentData(netObject.Entity, new DrawingTag { }); - var bColl = pivot.GetComponent(); + var collider = pivot.GetComponent(); - Bounds newBounds = new Bounds(currentLineRenderer.GetPosition(0), Vector3.one * 0.01f); + Bounds newBounds = new Bounds(renderer.GetPosition(0), Vector3.one * 0.01f); - for (int i = 0; i < currentLineRenderer.positionCount; i++) - newBounds.Encapsulate(new Bounds(currentLineRenderer.GetPosition(i), Vector3.one * 0.01f)); + for (int i = 0; i < renderer.positionCount; i++) + { + newBounds.Encapsulate(new Bounds(renderer.GetPosition(i), Vector3.one * 0.01f)); + } pivot.transform.position = newBounds.center; - bColl.center = currentLineRenderer.transform.position; - bColl.size = newBounds.size; - currentLineRenderer.transform.SetParent(pivot.transform, true); + collider.center = renderer.transform.position; + + collider.size = newBounds.size; + + renderer.transform.SetParent(pivot.transform, true); pivot.transform.SetParent(externalStrokeParent, true); } - - public void SendStrokeNetworkUpdate(int sID, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) + public void SendDrawUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { - var drawUpdate = new Draw((int)NetworkUpdateHandler.Instance.client_id, sID - , (int)entityType, lineWidth, curPos, - color); + var drawUpdate = new Draw + ( + (int) NetworkUpdateHandler.Instance.client_id, + id, + (int) entityType, + lineWidth, + curPos, + color + ); + + var serializedUpdate = JsonUtility.ToJson(drawUpdate); - var drawSer = JsonUtility.ToJson(drawUpdate); + KomodoMessage komodoMessage = new KomodoMessage("draw", serializedUpdate); - KomodoMessage komodoMessage = new KomodoMessage("draw", drawSer); komodoMessage.Send(); } + protected bool IsLineRendererRegistered (int id) + { + return lineRendererFromId.ContainsKey(id); + } + protected void RegisterLineRenderer (int id, LineRenderer renderer) + { + lineRendererFromId.Add(id, renderer); + } - #region Draw Receive Calls - //Setting up Line Rendering Calls - private Dictionary lineRenderersInQueue = new Dictionary(); - private Dictionary allStrokeIDValidator = new Dictionary(); + protected LineRenderer GetLineRenderer (int id) + { + return lineRendererFromId[id]; + } - //To avoid duplicating stroke ids because sending different ids states ma - public void Draw_Refresh(string stringData)//Draw newData) + protected void UnregisterLineRenderer (int id) { - Draw newData = JsonUtility.FromJson(stringData); + lineRendererFromId.Remove(id); + } + protected LineRenderer CreateLineRendererContainer (Draw data) + { + GameObject lineRendCopy = Instantiate(lineRendererContainerPrefab).gameObject; - LineRenderer currentLineRenderer = default; + lineRendCopy.name = "LineR:" + data.strokeId; - //we start a new line if there is no ID already corresponding to one in the scene - if (!allStrokeIDValidator.ContainsKey(newData.strokeId)) - { - GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject; - lineRendCopy.name = "LineR:" + newData.strokeId; + lineRendCopy.transform.SetParent(externalStrokeParent, true); - lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true); - currentLineRenderer = lineRendCopy.GetComponent(); + return lineRendCopy.GetComponent(); + } - currentLineRenderer.positionCount = 0; + protected void ContinueLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) + { + Debug.LogWarning($"Line renderer {data.strokeId} will not be started or continued, because it was never registered."); - allStrokeIDValidator.Add(newData.strokeId, newData.strokeId); - lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer); + return; } - //we get reference to the linenderer we are supposed to be working with - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - currentLineRenderer = lineRenderersInQueue[newData.strokeId]; + LineRenderer renderer = GetLineRenderer(data.strokeId); - switch (newData.strokeType) - { - //Continues A Line - case (int)Entity_Type.Line: + var brushColor = new Vector4(data.curColor.x, data.curColor.y, data.curColor.z, data.curColor.w); - var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w); - currentLineRenderer.startColor = brushColor; - currentLineRenderer.endColor = brushColor; - currentLineRenderer.widthMultiplier = newData.lineWidth; + renderer.startColor = brushColor; - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); + renderer.endColor = brushColor; - break; + renderer.widthMultiplier = data.lineWidth; - //Ends A Line A completes its setup - case (int)Entity_Type.LineEnd: + ++renderer.positionCount; - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); + renderer.SetPosition(renderer.positionCount - 1, data.curStrokePos); + } - //Create external client stroke instance - DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); //new GameObject("LineRender:" + (newData.strokeId), typeof(BoxCollider//; + protected void EndLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) + { + Debug.LogWarning($"Line renderer {data.strokeId} will not be ended, because it was never registered."); - break; + return; + } - //Deletes a Line - case (int)Entity_Type.LineDelete: + LineRenderer renderer = GetLineRenderer(data.strokeId); - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - lineRenderersInQueue.Remove(newData.strokeId); + renderer.positionCount += 1; - Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject); - NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId); - } - break; + renderer.SetPosition(renderer.positionCount - 1, data.curStrokePos); - case (int)Entity_Type.LineRender: + InitializeFinishedLineFromOtherClient(data.strokeId, renderer); + } - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true); + protected void DeleteLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) + { + Debug.LogWarning($"Line renderer {data.strokeId} will not be deleted, because it was never registered."); - break; + return; + } - case (int)Entity_Type.LineNotRender: + bool success = NetworkedObjectsManager.Instance.DestroyAndUnregisterEntity(data.strokeId); - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false); + if (!success) + { + Debug.LogWarning($"Could not delete line {data.strokeId}'s networked object."); - break; + return; } + + UnregisterLineRenderer(data.strokeId); } - #endregion + protected void ShowLine (Draw data) + { + bool success = NetworkedObjectsManager.Instance.ShowEntity(data.strokeId); + if (!success) + { + Debug.LogWarning($"Could not show line {data.strokeId}."); + } + } + protected void HideLine (Draw data) + { + bool success = NetworkedObjectsManager.Instance.HideEntity(data.strokeId); + if (!success) + { + Debug.LogWarning($"Could not hide line {data.strokeId}."); + } + } + protected void StartLineAndRegisterLineRenderer (Draw data) + { + LineRenderer currentLineRenderer = CreateLineRendererContainer(data); + currentLineRenderer.positionCount = 0; + RegisterLineRenderer(data.strokeId, currentLineRenderer); + } + public void ReceiveDrawUpdate (string stringData) + { + Draw data = JsonUtility.FromJson(stringData); + if (!IsLineRendererRegistered(data.strokeId)) + { + StartLineAndRegisterLineRenderer(data); + } + + switch (data.strokeType) + { + // Continues a Line + case (int) Entity_Type.Line: + { + ContinueLine(data); + break; + } - } + case (int) Entity_Type.LineEnd: + { + EndLine(data); + + break; + } + + case (int) Entity_Type.LineDelete: + { + DeleteLine(data); + break; + } + + case (int) Entity_Type.LineRender: + { + ShowLine(data); + break; + } + + case (int) Entity_Type.LineNotRender: + { + HideLine(data); + + break; + } + } + } + } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs index 4b39efb..6fdfc74 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs @@ -13,6 +13,7 @@ public static EraseManager Instance } TriggerEraseDraw leftHandErase; + TriggerEraseDraw rightHandErase; public EntityManager entityManager; @@ -37,19 +38,24 @@ public virtual void TryAndErase(NetworkedGameObject netObj) netObj.gameObject.SetActive(false); // when actions of erasing are being captured, the curStrokepos and curColor will both be set to 0. - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(entityID, Entity_Type.LineNotRender); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineNotRender); //save our reverted action for undoing the process with the undo button if (UndoRedoManager.IsAlive) - UndoRedoManager.Instance.savedStrokeActions.Push(() => - { - - netObj.gameObject.SetActive(true); - - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(entityID, Entity_Type.LineRender); - } + { + UndoRedoManager.Instance.savedStrokeActions.Push + ( + (System.Action) + ( + () => + { + netObj.gameObject.SetActive(true); + + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineRender); + } + ) ); - + } } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs index da1fa4b..7df1d99 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs @@ -4,11 +4,25 @@ namespace Komodo.Runtime { public struct Draw { + // Who is sending the draw update public int clientId; + + // An ID unique among all entities (draw strokes, models, model pack subobjects) public int strokeId; + + // The kind of action being performed. + // See Entity_Type.Line ... Entity_Type.LineNotRender public int strokeType; + + // Used for continue line. The visual thickness of the line. public float lineWidth; + + // Used for continue line and end line. + // The endpoint of the currently drawn line segment. public Vector3 curStrokePos; + + // Used for continue line. + // The color of the line segment. public Vector4 curColor; public Draw(int clientId, int strokeId, int strokeType, float lineWidth, Vector3 curStrokePos, Vector4 curColor) @@ -20,5 +34,7 @@ public Draw(int clientId, int strokeId, int strokeType, float lineWidth, Vector3 this.curStrokePos = curStrokePos; this.curColor = curColor; } + + // TODO: Add constructors for ContinueLine, EndLine, ShowLine, HideLIne } } \ No newline at end of file diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs index 2b5148c..b5fad73 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs @@ -73,7 +73,6 @@ public List GetNetworkedSubObjectList(int index) return result; } - public int GenerateEntityIDBase () { return (999 * 1000) + ((int) Entity_Type.objects * 100); @@ -143,7 +142,7 @@ public void ApplyInteraction (Interaction interactionData) switch (interactionData.interactionType) { - case (int)INTERACTIONS.SHOW: + case (int) INTERACTIONS.SHOW: if (UIManager.IsAlive) { @@ -152,7 +151,7 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.HIDE: + case (int) INTERACTIONS.HIDE: if (UIManager.IsAlive) { @@ -161,19 +160,19 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.GRAB: + case (int) INTERACTIONS.GRAB: Instance.ApplyGrabStartInteraction(interactionData); break; - case (int)INTERACTIONS.DROP: + case (int) INTERACTIONS.DROP: Instance.ApplyGrabEndInteraction(interactionData); break; - case (int)INTERACTIONS.CHANGE_SCENE: + case (int) INTERACTIONS.CHANGE_SCENE: if (SceneManagerExtensions.IsAlive) { @@ -183,18 +182,30 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.LOCK: + case (int) INTERACTIONS.LOCK: Instance.ApplyLockInteraction(interactionData); break; - case (int)INTERACTIONS.UNLOCK: + case (int) INTERACTIONS.UNLOCK: Instance.ApplyUnlockInteraction(interactionData); break; + case (int) INTERACTIONS.LOOK: + + // Do nothing + + break; + + case (int) INTERACTIONS.LOOK_END: + + // Do nothing + + break; + default: Debug.LogWarning ($"Tried to ApplyInteraction, but interaction type {interactionData.interactionType} was unknown. Skipping"); @@ -365,5 +376,52 @@ public void LinkNetObjectToButton(int entityID, NetworkedGameObject netObject) ModelImportInitializer.Instance.networkedGameObjects[buttonID] = netObject; } } + + // Returns true for success and false for failure + public bool DestroyAndUnregisterEntity (int id) + { + if (!networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object with key {id} will not be destroyed or unregistered, because it was never registered."); + + return false; + } + + Destroy(networkedObjectFromEntityId[id].gameObject); + + networkedObjectFromEntityId.Remove(id); + + return true; + } + + // Returns true for success and false for failure + public bool ShowEntity (int id) + { + if (!NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object {id} will not be shown, because it was never registered."); + + return false; + } + + NetworkedObjectsManager.Instance.networkedObjectFromEntityId[id].gameObject.SetActive(true); + + return true; + } + + // Returns true for success and false for failure + public bool HideEntity (int id) + { + if (!networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object {id} will not be hidden, because it was never registered."); + + return false; + } + + networkedObjectFromEntityId[id].gameObject.SetActive(false); + + return true; + } } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs index d95e2b2..7b57aeb 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs @@ -13,8 +13,11 @@ public static SocketIOEditorSimulator Instance } public bool isVerbose = false; + public bool doLogClientEvents = true; + public bool doLogCustomInteractions = true; + public bool doLogPositionEvents = false; public bool setSocketIOAdapterNameFails; @@ -48,18 +51,23 @@ public static SocketIOEditorSimulator Instance public int clientId; public int sessionId; - + public int isTeacher; public string sessionDetails = @"{""assets"":[{""id"":111550,""name"":""GraceGremer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/8f5fef97-a735-4c2e-8d28-fc3badfe09a3/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111576,""name"":""GarmentSetup1"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/1843c37c-dc40-4520-91cb-ad1cdc70d72e/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111577,""name"":""GarmentSetup2"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/cb3464eb-f96e-48c6-b774-e4dfbdc8ab78/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111578,""name"":""GarmentSetup3"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/e8567627-ade7-493e-a017-e8b1b61e71af/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111579,""name"":""GarmentSetup4"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/9a133a69-c8ba-4cf8-9539-a9a2b2827226/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111580,""name"":""GarmentSetup5"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/0529709a-803e-4f61-86d1-092dabf0c2cb/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111589,""name"":""ShanenHaigler"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/7bb5d74d-39f3-4b3d-aa56-4708b62bda95/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111597,""name"":""Garment O'Donnell"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/ee63a354-b427-4ca3-a2a0-6e230efabe55/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111602,""name"":""GraceGremer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/14bacabd-7f09-4120-b420-ccfa09b23e03/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111604,""name"":""CarleeIhde"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/de622ac8-eabd-4d3a-ab8f-ab56ee415813/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111605,""name"":""CarleeI"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/29394a64-0e31-4824-86f8-133297f9f84c/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111607,""name"":""G-SarahMiranda"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/f3f1442c-f9cc-454b-8b32-8f3597d79272/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111608,""name"":""SarahMirandaMood"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/0b5036d8-37f0-4c32-b65a-7030cef4718d/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111609,""name"":""G-ShanenHaigleer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/5539b18d-ed67-48cb-8a87-164fc161319a/model.glb"",""isWholeObject"":true,""scale"":1}],""build"":""/test/Brandon-develop-2021-10-19-15xx/"",""course_id"":3,""create_at"":""2021-03-26T01:00:58.000Z"",""description"":""(No description added)"",""end_time"":""2021-03-31T19:03:00.000Z"",""session_id"":141,""session_name"":""SP21 - Critique Group C"",""start_time"":""2021-03-31T18:03:00.000Z"",""users"":[]}"; private float[] _arrayPointer; + private int _relayUpdateSize; + private int _posCursor; public string InstantiationManagerName = "InstantiationManager"; + public string NetworkManagerName = "NetworkManager"; + private ClientSpawnManager _ClientSpawnManager; + private NetworkUpdateHandler _NetworkUpdateHandler; public void Awake() diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs new file mode 100644 index 0000000..093e342 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + [System.Serializable] + public class SessionState + { + public int[] clients; + public EntityState[] entities; + public int scene; + public bool isRecording; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta new file mode 100644 index 0000000..c5fba2a --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ccbf976550777ce4b9dfdb9dfe8290f2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs index 5651fb7..0ae7652 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs @@ -205,22 +205,4 @@ public void ApplyInteraction(Interaction interactionData) NetworkedObjectsManager.Instance.ApplyInteraction(interactionData); } } - - [System.Serializable] - public struct EntityState - { - public int id; - public Position latest; - public bool render; - public bool locked; - } - - [System.Serializable] - public class SessionState - { - public int[] clients; - public EntityState[] entities; - public int scene; - public bool isRecording; - } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs new file mode 100644 index 0000000..7f1a809 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + //For handling different type of text between clients + public enum STRINGTYPE + { + TUTORIAL, + CLIENT_NAME, + SPEECH_TO_TEXT, + } + + public struct SpeechToTextSnippet + { + public int target; + public int stringType; + public string text; + } + + public struct SpeechToText + { + public int session_id; + public int client_id; + public string text; + public string type; + public int ts; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta new file mode 100644 index 0000000..5b7c448 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2f972960dd2da247b6706c5ee5773ac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/package.json b/Komodo/Assets/Packages/KomodoCore/package.json index bdf9e60..486a617 100644 --- a/Komodo/Assets/Packages/KomodoCore/package.json +++ b/Komodo/Assets/Packages/KomodoCore/package.json @@ -1,7 +1,7 @@ { "name": "com.graingeridealab.komodo", "displayName": "KomodoCore", - "version": "0.5.7", + "version": "0.5.8", "unity": "2020.3", "keywords": [ "webxr", diff --git a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js index 8046623..3f46ff4 100644 --- a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js +++ b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js @@ -1,8 +1,15 @@ // 'esversion: 6' -// Remember: also change Assets\Packages\KomodoCore\Hidden~\WebGLTemplates\KomodoWebXRFullView2020\relay.js if you intend for the changes to be reflected in projects that use the package. If you are reading this from inside a build folder, you can change this file as you please. +// Remember: also change +// Assets\Packages\KomodoCore\Hidden~\WebGLTemplates\KomodoWebXRFullView2020\relay.js +// if you intend for the changes to be reflected in projects that use the package. +// If you are reading this from inside a build folder, you can change this file as +// you please. -// Tip: if you need to change this on-the-fly, you can edit this file without rebuilding. It's also possible to use the inspector to inspect the VR frame and call `window.RELAY_API_BASE_URL=""`, if for some reason you need to do that in real time. +// Tip: if you need to change this on-the-fly, you can edit this file without +// rebuilding. It's also possible to use the inspector to inspect the VR frame and +// call `window.RELAY_API_BASE_URL=""`, if for some reason you need +// to do that in real time. /* * --------------------------------------------------------------------------------- @@ -11,14 +18,22 @@ */ // Replace these with your own server's URLs. - -var RELAY_BASE_URL = "http://localhost:3000"; -var API_BASE_URL = "http://localhost:4040"; -var VR_BASE_URL = "http://localhost:8123"; //TODO -- change this to a better default - -// init globals which Unity will assign when setup is done. -var sync = null; -var chat = null; +// +// If running each of these without Docker: +// - RELAY_BASE_URL: Look in komodo-relay > serve.js or config.js for the port number +// - API_BASE_URL: Look in komodo-portal > config.js > web.port for the port number +// - VR_BASE_URL: This will be unused for local builds +// +// If running each of these with Docker: +// - RELAY_BASE_URL: Look in komodo-relay > docker-compose.yml > +// services.komodo-relay.labels > traefik.frontend.rule +// - API_BASE_URL: Look in komodo-portal > docker-compose.yml > +// services.backend.labels > traefik.frontend.rule +// - VR_BASE_URL: Look in komodo-portal > .env.* > VUE_APP_VR_CLIENT_BASE_URL + +var RELAY_BASE_URL = "http://localhost:3000"; +var API_BASE_URL = "http://localhost:4040"; +var VR_BASE_URL = "http://localhost:8123"; /* * --------------------------------------------------------------------------------- @@ -26,6 +41,10 @@ var chat = null; * --------------------------------------------------------------------------------- */ +// init globals which Unity will assign when setup is done. +var sync = null; +var chat = null; + /** * Get the URL parameters * source: https://css-tricks.com/snippets/javascript/get-url-variables/ @@ -92,8 +111,6 @@ var splitAppAndBuild = function (appAndBuild) { var runtimeAppAndBuild = removeVRBaseUrl(removeQuery(window.location.href)); -//console.log(runtimeAppAndBuild); - // TODO(Brandon): in the future, pass app and build as separate details like this: // var result = splitAppAndBuild(runtimeAppAndBuild); // var runtimeApp = result.app; @@ -130,7 +147,7 @@ request.open("GET", url, true); request.responseType = "json"; request.send(); -request.onload = function(){ +request.onload = function() { let res = request.response; // session details @@ -145,14 +162,15 @@ request.onload = function(){ details.users = res.users; let assets_response = res.assetList; - for (idx = 0; idx < assets_response.length; idx++) - { + + for (idx = 0; idx < assets_response.length; idx++) { asset = new Object; asset.id = assets_response[idx].asset_id; asset.name = assets_response[idx].asset_name; asset.url = assets_response[idx].path; asset.isWholeObject = Boolean(assets_response[idx].is_whole_object); asset.scale = assets_response[idx].scale || 1; + details.assets.push(asset); } }; diff --git a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md index 03d2d84..0f4e6d2 100644 --- a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md +++ b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md @@ -70,6 +70,12 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - strokes have correct z depth re:each other _RESULT_ - strokes have correct z depth while drawing _RESULT_ - strokes have correct z depth after drawing is done _RESULT_ +- move own drawings _RESULT_ +- rotate own drawings _RESULT_ +- scale own drawings _RESULT_ +- move others' drawings _RESULT_ +- rotate others' drawings _RESULT_ +- undo own drawings _RESULT_ ### erase - with left hand _RESULT_ @@ -102,15 +108,12 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ ### Model Interactions - Can Grab model _RESULT_ - Grab model pack _RESULT_ -- Grab synchronizes _RESULT_ - Grabbing locks for others _RESULT_ - Can Scale model _RESULT_ - Scale model pack _RESULT_ -- Scale synchronizes _RESULT_ - Scaling locks for others _RESULT_ - Can Show / Hide _RESULT_ -- Synced show / hide _RESULT_ -- Synced show / hide for model packs _RESULT_ +- Show / Hide for model packs _RESULT_ - Can lock model _RESULT_ - Can lock model pack _RESULT_ - Grab lock vs UI lock _RESULT_ @@ -142,7 +145,9 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - “You just left” own _RESULT_ - “Someone just left” others _RESULT_ - Close Connection and Rejoin simulated offline _RESULT_ -- Drawing poses, color _RESULT_ +- Pre-disconnection drawing poses _RESULT_ +- During-disconnection drawings _RESULT_ +- During-disconnection drawing poses _RESULT_ # Spectator Tests @@ -200,11 +205,13 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - pan (Middle Mouse Drag) _RESULT_ - right-click (no dragging yet) to teleport _RESULT_ +## Captures +- capture button starts capture _RESULT_ +- capture button stops capture _RESULT_ + ### Capture file - Capture file includes events for pressing settings, people, interact, create tabs _RESULT_ - Capture file includes events for calling out the VR menu _RESULT_ -- capture button starts capture _RESULT_ -- capture button stops capture _RESULT_ ### Capture output - Capture file is valid _RESULT_ @@ -213,7 +220,6 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - Sync Drawings (type "draw") are included _RESULT_ - All Drawing Messages are well-formed _RESULT_ - Stroke ID is well-formed _RESULT_ - ___ # Issues @@ -250,7 +256,7 @@ ___ ## Transferring new and deleted tests to the template -* Use a text editor with a diff or compare function to easily copy the new tests (or delete tests) without copying the test results. +* Use a text editor with a diff or compare function to easily copy the new tests (or delete tests) to the template without copying the test results. * Keep the test name to one line, and write details on how to execute the test in the Komodo Manual ## Template @@ -268,4 +274,3 @@ where RESULT = … - W.ORKAROUND / NETW.ORKAROUND - N./T ``` - diff --git a/Komodo/ProjectSettings/ProjectSettings.asset b/Komodo/ProjectSettings/ProjectSettings.asset index e50c67b..a9139d2 100644 --- a/Komodo/ProjectSettings/ProjectSettings.asset +++ b/Komodo/ProjectSettings/ProjectSettings.asset @@ -207,10 +207,14 @@ PlayerSettings: - {fileID: 0} - {fileID: 0} - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} - {fileID: 2910771567588298596, guid: ac933aa07b1097d47a08984d469dccfc, type: 2} - {fileID: 11400000, guid: a5e5b7605fb48984988490688c2a74e2, type: 2} - {fileID: 11400000, guid: 8fed9c7708c5a6b46bbde22d82990e10, type: 2} - {fileID: 2478256764130162806, guid: 552445d583cb06c4eaf9d56596dd45c2, type: 2} + - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -738,8 +742,8 @@ PlayerSettings: PrivateNetworkClientServer: False InternetClientServer: False VideosLibrary: False + BackgroundMediaPlayback: False Objects3D: False - InternetClient: False RemoteSystem: False BlockedChatMessages: False PhoneCall: False @@ -760,9 +764,9 @@ PlayerSettings: PointOfService: False RecordedCallsFolder: False Contacts: False + InternetClient: False Proximity: False CodeGeneration: False - BackgroundMediaPlayback: False EnterpriseAuthentication: False metroTargetDeviceFamilies: Desktop: False