Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.5.8 #101

Merged
merged 18 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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="<your-server-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="<your-server-url>"`, if for some reason you
// need to do that in real time.

/*
* ---------------------------------------------------------------------------------
Expand All @@ -11,21 +17,33 @@
*/

// 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";

/*
* ---------------------------------------------------------------------------------
* FUNCTIONALITY
* ---------------------------------------------------------------------------------
*/

// 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/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,61 +52,6 @@ namespace Komodo.Runtime
[System.Serializable] public class UnityEvent_Int : UnityEvent<int> { }
[System.Serializable] public class UnityEvent_String : UnityEvent<string> { }

//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
/// <summary>
/// This class is meant to:
/// --- set up main player
Expand Down Expand Up @@ -560,7 +505,9 @@ public void AddNewClient(int clientID, bool isMainPlayer = false)

var ROT = entityManager.GetComponentData<Rotation>(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;
Expand Down Expand Up @@ -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<int, LineRenderer> lineRenderersInQueue = new Dictionary<int, LineRenderer>();
private Dictionary<int, int> allStrokeIDValidator = new Dictionary<int, int>();

//To avoid duplicating stroke ids because sending different ids states ma
public void Draw_Refresh(string stringData)//Draw newData)
{
Draw newData = JsonUtility.FromJson<Draw>(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<LineRenderer>();

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)
Expand Down Expand Up @@ -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<SpeechToText>(data);
Expand Down Expand Up @@ -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<string> chunks = new List<string>();
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

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

Original file line number Diff line number Diff line change
@@ -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,
}
}

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

Loading