diff --git a/Runtime/Components/ArenaClickListener.cs b/Runtime/Components/ArenaClickListener.cs index ba43d6b..c8ef80e 100644 --- a/Runtime/Components/ArenaClickListener.cs +++ b/Runtime/Components/ArenaClickListener.cs @@ -112,9 +112,9 @@ internal void PublishMouseEvent(string eventType) ArenaEventJson data = new ArenaEventJson { - ClickPos = ArenaUnity.ToArenaPosition(camPosition), - Position = ArenaUnity.ToArenaPosition(hit.point), - Source = camName, + OriginPosition = ArenaUnity.ToArenaPosition(camPosition), + TargetPosition = ArenaUnity.ToArenaPosition(hit.point), + Target = camName, }; string payload = JsonConvert.SerializeObject(data); if (ArenaClientScene.Instance) diff --git a/Runtime/Schemas/ArenaArenaProgramJson.cs b/Runtime/Schemas/ArenaArenaProgramJson.cs index 03250e0..6427d5a 100644 --- a/Runtime/Schemas/ArenaArenaProgramJson.cs +++ b/Runtime/Schemas/ArenaArenaProgramJson.cs @@ -30,7 +30,7 @@ public class ArenaArenaProgramJson private static string defName = null; [JsonProperty(PropertyName = "name")] - [Tooltip("Name of the program in the format namespace/program-name.")] + [Tooltip("Name of the program.")] public string Name = defName; public bool ShouldSerializeName() { @@ -72,11 +72,29 @@ public bool ShouldSerializeInstantiate() return true; // required in json schema } + private static string defFile = null; + [JsonProperty(PropertyName = "file")] + [Tooltip("The path to a `.wasm` file (e.g. `counter.wasm`, `user1/counter.wasm`) in the ARENA filestore, starting from the location field indicated below. See location. Example: user1/py/counter/counter.py should have file: `counter.py` and location: `user1/py/counter`. Note that the runtime will download all files in parent folder (e.g. you can add a requirements.txt)")] + public string File = defFile; + public bool ShouldSerializeFile() + { + return true; // required in json schema + } + private static string defFilename = null; [JsonProperty(PropertyName = "filename")] - [Tooltip("Filename of the entry binary.")] - public string Filename = defFilename; + [Obsolete("DEPRECATED: data.filename is deprecated for type: program, use data.file and data.location instead.")] + public string Filename { get; protected set; } = defFilename; public bool ShouldSerializeFilename() + { + return false; // deprecated in json schema + } + + private static string defLocation = null; + [JsonProperty(PropertyName = "location")] + [Tooltip("Filestore path starting at user home; Example: `user1/hello` for a program inside folder `hello` of user1. Should, at least be the user filesore home folder.")] + public string Location = defLocation; + public bool ShouldSerializeLocation() { return true; // required in json schema } @@ -98,10 +116,16 @@ public bool ShouldSerializeFiletype() return true; // required in json schema } - private static string defParent = "pytest"; + public enum ParentType + { + [EnumMember(Value = "arena-rt1")] + ArenaRt1, + } + private static ParentType defParent = ParentType.ArenaRt1; + [JsonConverter(typeof(StringEnumConverter))] [JsonProperty(PropertyName = "parent")] - [Tooltip("Request the orchestrator to deploy to this runtime (can be a runtime name or UUID); usually left blank.")] - public string Parent = defParent; + [Tooltip("Request the orchestrator to deploy to this runtime (can be a runtime name or UUID); Temporarily must be arena-rt1.")] + public ParentType Parent = defParent; public bool ShouldSerializeParent() { return true; // required in json schema @@ -109,7 +133,7 @@ public bool ShouldSerializeParent() private static string[] defArgs = null; [JsonProperty(PropertyName = "args")] - [Tooltip("Command-line arguments (passed in argv). Supports variables: ${scene}, ${mqtth}, ${cameraid}, ${username}, ${runtimeid}, ${moduleid}, ${query-string-key}.")] + [Tooltip("Command-line arguments (passed in argv). Supports variables: ${scene}, ${mqtth}, ${userid}, ${username}, ${runtimeid}, ${moduleid}, ${query-string-key}.")] public string[] Args = defArgs; public bool ShouldSerializeArgs() { @@ -119,14 +143,14 @@ public bool ShouldSerializeArgs() private static string[] defEnv = { "MID=${moduleid}", "SCENE=${scene}", "NAMESPACE=${namespace}", "MQTTH=${mqtth}", "REALM=realm" }; [JsonProperty(PropertyName = "env")] - [Tooltip("Environment variables. Supports variables: ${scene}, ${namespace}, ${mqtth}, ${cameraid}, ${username}, ${runtimeid}, ${moduleid}, ${query-string-key}.")] + [Tooltip("Environment variables. Supports variables: ${scene}, ${namespace}, ${mqtth}, ${userid}, ${username}, ${runtimeid}, ${moduleid}, ${query-string-key}.")] public string[] Env = defEnv; public bool ShouldSerializeEnv() { return true; // required in json schema } - private static object[] defChannels = { JsonConvert.DeserializeObject("{'path': '/ch/${scene}', 'type': 'pubsub', 'mode': 'rw', 'params': {'topic': 'realm/s/${scene}'}}") }; + private static object[] defChannels = { JsonConvert.DeserializeObject("{'path': '/ch/${scene}', 'type': 'pubsub', 'mode': 'rw', 'params': {'topic': 'realm/s/${scene}/${namespace}'}}") }; [JsonProperty(PropertyName = "channels")] [Tooltip("Channels describe files representing access to IO from pubsub and client sockets (possibly more in the future; currently only supported for WASM programs).")] public object[] Channels = defChannels; diff --git a/Runtime/Schemas/ArenaEventJson.cs b/Runtime/Schemas/ArenaEventJson.cs index 6b967ad..366d2a4 100644 --- a/Runtime/Schemas/ArenaEventJson.cs +++ b/Runtime/Schemas/ArenaEventJson.cs @@ -28,32 +28,59 @@ public class ArenaEventJson // event member-fields + private static string defTarget = null; + [JsonProperty(PropertyName = "target")] + [Tooltip("The `object_id` of event destination.")] + public string Target = defTarget; + public bool ShouldSerializeTarget() + { + return true; // required in json schema + } + + private static ArenaVector3Json defTargetPosition = null; + [JsonProperty(PropertyName = "targetPosition")] + [Tooltip("The event destination position in 3D.")] + public ArenaVector3Json TargetPosition = defTargetPosition; + public bool ShouldSerializeTargetPosition() + { + return true; // required in json schema + } + + private static ArenaVector3Json defOriginPosition = JsonConvert.DeserializeObject("{'x': 0, 'y': 1.6, 'z': 0}"); + [JsonProperty(PropertyName = "originPosition")] + [Tooltip("The event origination position in 3D.")] + public ArenaVector3Json OriginPosition = defOriginPosition; + public bool ShouldSerializeOriginPosition() + { + // originPosition + return (OriginPosition != defOriginPosition); + } + private static string defSource = null; [JsonProperty(PropertyName = "source")] - [Tooltip("The `object_id` of event origination. e.g camera or client program connection id.")] - public string Source = defSource; + [Obsolete("DEPRECATED: data.source is deprecated for clientEvent, use data.target instead.")] + public string Source { get; protected set; } = defSource; public bool ShouldSerializeSource() { - return true; // required in json schema + return false; // deprecated in json schema } - private static ArenaVector3Json defPosition = null; + private static object defPosition = null; [JsonProperty(PropertyName = "position")] - [Tooltip("The event destination position in 3D.")] - public ArenaVector3Json Position = defPosition; + [Obsolete("DEPRECATED: data.position is deprecated for clientEvent, use data.targetPosition instead.")] + public object Position { get; protected set; } = defPosition; public bool ShouldSerializePosition() { - return true; // required in json schema + return false; // deprecated in json schema } - private static ArenaVector3Json defClickPos = JsonConvert.DeserializeObject("{'x': 0, 'y': 1.6, 'z': 0}"); + private static object defClickPos = null; [JsonProperty(PropertyName = "clickPos")] - [Tooltip("The event origination position in 3D.")] - public ArenaVector3Json ClickPos = defClickPos; + [Obsolete("DEPRECATED: data.clickPos is deprecated for clientEvent, use data.originPosition instead.")] + public object ClickPos { get; protected set; } = defClickPos; public bool ShouldSerializeClickPos() { - // clickPos - return (ClickPos != defClickPos); + return false; // deprecated in json schema } // General json object management diff --git a/Samples~/LaserPointer/Assets/LaserPointer.cs b/Samples~/LaserPointer/Assets/LaserPointer.cs index 3169405..350ab32 100644 --- a/Samples~/LaserPointer/Assets/LaserPointer.cs +++ b/Samples~/LaserPointer/Assets/LaserPointer.cs @@ -47,8 +47,8 @@ private void MouseEventCallback(string event_type, string message) ArenaObjectJson m = JsonConvert.DeserializeObject(message); ArenaEventJson evt = JsonConvert.DeserializeObject(m.data.ToString()); - ArenaVector3Json start = evt.ClickPos; - ArenaVector3Json end = evt.Position; + ArenaVector3Json start = evt.OriginPosition; + ArenaVector3Json end = evt.TargetPosition; start.Y = (float)start.Y - .1f; // lower position for visibility // laser