Skip to content

Commit 5ee54e5

Browse files
Merge pull request #101 from gelic-idealab/release/v0.5.8
Release/v0.5.8
2 parents af0a337 + c71188b commit 5ee54e5

File tree

23 files changed

+608
-367
lines changed

23 files changed

+608
-367
lines changed

Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// 'esversion: 6'
22

3-
// 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.
3+
// Remember: also change Assets\WebGLTemplates\KomodoWebXRFullView2020\relay.js (or
4+
// re-copy the WebGLTemplates to the Assets folder) if you intend for the changes to
5+
// be reflected in the build. If you are reading this from inside a build folder,
6+
// you can change this file as you please.
47

5-
// 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="<your-server-url>"`, if for some reason you need to do that in real time.
8+
// Tip: if you need to change this on-the-fly, you can edit this file without
9+
// rebuilding. It's also possible to use the inspector to inspect the VR frame and
10+
// call `window.RELAY_API_BASE_URL="<your-server-url>"`, if for some reason you
11+
// need to do that in real time.
612

713
/*
814
* ---------------------------------------------------------------------------------
@@ -11,21 +17,33 @@
1117
*/
1218

1319
// Replace these with your own server's URLs.
14-
15-
var RELAY_BASE_URL = "http://localhost:3000";
16-
var API_BASE_URL = "http://localhost:4040";
17-
var VR_BASE_URL = "http://localhost:8123"; //TODO -- change this to a better default
18-
19-
// init globals which Unity will assign when setup is done.
20-
var sync = null;
21-
var chat = null;
20+
//
21+
// If running each of these without Docker:
22+
// - RELAY_BASE_URL: Look in komodo-relay > serve.js or config.js for the port number
23+
// - API_BASE_URL: Look in komodo-portal > config.js > web.port for the port number
24+
// - VR_BASE_URL: This will be unused for local builds
25+
//
26+
// If running each of these with Docker:
27+
// - RELAY_BASE_URL: Look in komodo-relay > docker-compose.yml >
28+
// services.komodo-relay.labels > traefik.frontend.rule
29+
// - API_BASE_URL: Look in komodo-portal > docker-compose.yml >
30+
// services.backend.labels > traefik.frontend.rule
31+
// - VR_BASE_URL: Look in komodo-portal > .env.* > VUE_APP_VR_CLIENT_BASE_URL
32+
33+
var RELAY_BASE_URL = "http://localhost:3000";
34+
var API_BASE_URL = "http://localhost:4040";
35+
var VR_BASE_URL = "http://localhost:8123";
2236

2337
/*
2438
* ---------------------------------------------------------------------------------
2539
* FUNCTIONALITY
2640
* ---------------------------------------------------------------------------------
2741
*/
2842

43+
// init globals which Unity will assign when setup is done.
44+
var sync = null;
45+
var chat = null;
46+
2947
/**
3048
* Get the URL parameters
3149
* source: https://css-tricks.com/snippets/javascript/get-url-variables/
@@ -92,8 +110,6 @@ var splitAppAndBuild = function (appAndBuild) {
92110

93111
var runtimeAppAndBuild = removeVRBaseUrl(removeQuery(window.location.href));
94112

95-
//console.log(runtimeAppAndBuild);
96-
97113
// TODO(Brandon): in the future, pass app and build as separate details like this:
98114
// var result = splitAppAndBuild(runtimeAppAndBuild);
99115
// var runtimeApp = result.app;
@@ -130,7 +146,7 @@ request.open("GET", url, true);
130146
request.responseType = "json";
131147
request.send();
132148

133-
request.onload = function(){
149+
request.onload = function() {
134150
let res = request.response;
135151

136152
// session details
@@ -145,14 +161,15 @@ request.onload = function(){
145161
details.users = res.users;
146162

147163
let assets_response = res.assetList;
148-
for (idx = 0; idx < assets_response.length; idx++)
149-
{
164+
165+
for (idx = 0; idx < assets_response.length; idx++) {
150166
asset = new Object;
151167
asset.id = assets_response[idx].asset_id;
152168
asset.name = assets_response[idx].asset_name;
153169
asset.url = assets_response[idx].path;
154170
asset.isWholeObject = Boolean(assets_response[idx].is_whole_object);
155171
asset.scale = assets_response[idx].scale || 1;
172+
156173
details.assets.push(asset);
157174
}
158175
};

Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs

Lines changed: 5 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -52,61 +52,6 @@ namespace Komodo.Runtime
5252
[System.Serializable] public class UnityEvent_Int : UnityEvent<int> { }
5353
[System.Serializable] public class UnityEvent_String : UnityEvent<string> { }
5454

55-
//For handling different type of text between clients
56-
public enum STRINGTYPE
57-
{
58-
TUTORIAL,
59-
CLIENT_NAME,
60-
SPEECH_TO_TEXT,
61-
}
62-
public struct SpeechToTextSnippet
63-
{
64-
public int target;
65-
public int stringType;
66-
public string text;
67-
}
68-
//types of data in scene
69-
public enum Entity_Type
70-
{
71-
none = -1,
72-
users_head = 0,
73-
users_Lhand = 1,
74-
users_Rhand = 2,
75-
objects = 3,
76-
physicsObject = 4,
77-
main_Player = 5,
78-
physicsEnd = 8,
79-
Line = 10,
80-
LineEnd = 11,
81-
LineDelete = 12,
82-
LineRender = 13,
83-
LineNotRender = 14,
84-
}
85-
86-
#region INTERACTION TYPES
87-
public enum INTERACTIONS
88-
{
89-
LOOK = 0,
90-
LOOK_END = 1,
91-
SHOW = 2,
92-
HIDE = 3,
93-
GRAB = 4,
94-
DROP = 5,
95-
CHANGE_SCENE = 6,
96-
SLICE_OBJECT = 7,
97-
LOCK = 8,
98-
UNLOCK = 9,
99-
LINE = 10,
100-
LINE_END = 11,
101-
SHOW_MENU = 12,
102-
HIDE_MENU = 13,
103-
104-
SETTING_TAB = 14,
105-
PEOPLE_TAB = 15,
106-
INTERACTION_TAB = 16,
107-
CREATE_TAB = 17,
108-
}
109-
#endregion
11055
/// <summary>
11156
/// This class is meant to:
11257
/// --- set up main player
@@ -560,7 +505,9 @@ public void AddNewClient(int clientID, bool isMainPlayer = false)
560505

561506
var ROT = entityManager.GetComponentData<Rotation>(avatarEntityGroupFromClientId[clientID].rootEntity).Value.value;//.entity_data.rot;
562507

563-
//To prevent offset issues when working with editor
508+
509+
// TODO -- investigate whether this area is a cause of the
510+
// hand position and rotation being wrong in the browser
564511
#if UNITY_WEBGL && !UNITY_EDITOR || TESTING_BEFORE_BUILDING
565512

566513
mainPlayer.transform.position = temp.position;
@@ -719,100 +666,6 @@ public async void DestroyClient(int clientID)
719666
}
720667
#endregion
721668

722-
#region Create A Network Managed Objects
723-
724-
725-
#endregion
726-
727-
#region Draw Receive Calls
728-
//Setting up Line Rendering Calls
729-
private Dictionary<int, LineRenderer> lineRenderersInQueue = new Dictionary<int, LineRenderer>();
730-
private Dictionary<int, int> allStrokeIDValidator = new Dictionary<int, int>();
731-
732-
//To avoid duplicating stroke ids because sending different ids states ma
733-
public void Draw_Refresh(string stringData)//Draw newData)
734-
{
735-
Draw newData = JsonUtility.FromJson<Draw>(stringData);
736-
737-
738-
LineRenderer currentLineRenderer = default;
739-
740-
//we start a new line if there is no ID already corresponding to one in the scene
741-
if (!allStrokeIDValidator.ContainsKey(newData.strokeId))
742-
{
743-
GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject;
744-
lineRendCopy.name = "LineR:" + newData.strokeId;
745-
746-
lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true);
747-
currentLineRenderer = lineRendCopy.GetComponent<LineRenderer>();
748-
749-
currentLineRenderer.positionCount = 0;
750-
751-
allStrokeIDValidator.Add(newData.strokeId, newData.strokeId);
752-
lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer);
753-
}
754-
755-
//we get reference to the linenderer we are supposed to be working with
756-
if (lineRenderersInQueue.ContainsKey(newData.strokeId))
757-
currentLineRenderer = lineRenderersInQueue[newData.strokeId];
758-
759-
switch (newData.strokeType)
760-
{
761-
//Continues A Line
762-
case (int)Entity_Type.Line:
763-
764-
var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w);
765-
currentLineRenderer.startColor = brushColor;
766-
currentLineRenderer.endColor = brushColor;
767-
currentLineRenderer.widthMultiplier = newData.lineWidth;
768-
769-
++currentLineRenderer.positionCount;
770-
currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos);
771-
772-
break;
773-
774-
//Ends A Line A completes its setup
775-
case (int)Entity_Type.LineEnd:
776-
777-
++currentLineRenderer.positionCount;
778-
currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos);
779-
780-
//Create external client stroke instance
781-
DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); //new GameObject("LineRender:" + (newData.strokeId), typeof(BoxCollider//;
782-
783-
break;
784-
785-
//Deletes a Line
786-
case (int)Entity_Type.LineDelete:
787-
788-
if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId))
789-
{
790-
if (lineRenderersInQueue.ContainsKey(newData.strokeId))
791-
lineRenderersInQueue.Remove(newData.strokeId);
792-
793-
Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject);
794-
NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId);
795-
}
796-
break;
797-
798-
case (int)Entity_Type.LineRender:
799-
800-
if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId))
801-
NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true);
802-
803-
break;
804-
805-
case (int)Entity_Type.LineNotRender:
806-
807-
if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId))
808-
NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false);
809-
810-
break;
811-
}
812-
}
813-
814-
#endregion
815-
816669
public void AddClientIfNeeded (int id)
817670
{
818671
if (NetworkUpdateHandler.Instance.client_id == id)
@@ -941,16 +794,8 @@ public void ApplyPositionToRightHand(Position positionData)
941794
}
942795

943796
#region Text Receive Calls
944-
945-
public struct SpeechToText
946-
{
947-
public int session_id;
948-
public int client_id;
949-
public string text;
950-
public string type;
951-
public int ts;
952-
}
953-
797+
// TODO: as much as possible, move these functions to static functions
798+
// in SpeechToText.cs
954799
public void OnReceiveSpeechToTextSnippet(string data)
955800
{
956801
var deserializedData = JsonUtility.FromJson<SpeechToText>(data);
@@ -989,13 +834,9 @@ public void ProcessSpeechToTextSnippet(SpeechToTextSnippet newText)
989834
clientIndex = avatarIndexFromClientId[newText.target];
990835
clientUsernameDisplays[clientIndex].text = newText.text;
991836
break;
992-
993837
}
994-
995838
}
996839

997-
998-
999840
private static string SplitWordsByLength(string str, int maxLength)
1000841
{
1001842
List<string> chunks = new List<string>();
@@ -1057,10 +898,8 @@ public IEnumerator SetTextTimer(int textIndex, string textD, float seconds = 5)
1057898

1058899
}
1059900

1060-
1061901
public IEnumerator ShutOffText(int textIndex, float seconds)
1062902
{
1063-
1064903
clientSpeechToTextDisplays[textIndex].transform.parent.gameObject.SetActive(true);
1065904

1066905
// secondsToWaitDic[index] -= seconds;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace Komodo.Runtime
6+
{
7+
[System.Serializable]
8+
public struct EntityState
9+
{
10+
public int id;
11+
public Position latest;
12+
public bool render;
13+
public bool locked;
14+
}
15+
}

Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace Komodo.Runtime
6+
{
7+
//types of data in scene
8+
public enum Entity_Type
9+
{
10+
none = -1,
11+
users_head = 0,
12+
users_Lhand = 1,
13+
users_Rhand = 2,
14+
objects = 3,
15+
physicsObject = 4,
16+
main_Player = 5,
17+
physicsEnd = 8,
18+
Line = 10,
19+
LineEnd = 11,
20+
LineDelete = 12,
21+
LineRender = 13,
22+
LineNotRender = 14,
23+
}
24+
}

Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)