Listens on MQTT for ARENA objects to save to mongodb store.
A client then can make an HTTP request to the URL the server this service is running on the retrieve a list of persisted objects to load upon entering any scene.
- Install nodejs
npm install
Note that updating major versions of mongodb will require setting the appropriate compatibility version per documentation
- An ARENA object is added to persist if it has
action: createandpersist: truein its MQTT message.- If the object already exists in persist, it will be replaced in entirety.
- A persisted ARENA object can be updated if it has
action: updateandpersist: trueset in its MQTT message. The properties in itsdatawill be merged on top of the previously saveddata.- If an
updatemessage contains an explicitoverwrite: true, then thedatatherein will replace what is saved in persistence. - If an
updatemessage contains an explicitpersist: false, then thedatatherein will not be updated to persistence.
- If an
Adding a ttl (float seconds) to the top level MQTT message for any create action signals that the object
will be automatically deleted from peristence after set duration, as well as a corresponding delete action message
sent over pubsub. ttl implies that persist is true.
Any scene can be loaded as a template into another scene. This effectively clones all objects from the source scene into the destination scene.
When a template is loaded, a parent container is first created in the target scene. This parent container follows the
object id naming scheme: templateNamespace|templateSceneId::instanceId, e.g. public|lobby::instance_0.
Then every object inside the designated @template scene is replicated as descendents of the parent container. In this
way, the parent can be repositioned, rotated, or scaled to adjust the template all at once. The objects within
the template follow the naming scheme templateNamespace|templateSceneId::instanceId::objectId, e.g. public|lobby::instance_0::cube1.
To clone an instance of a scene, send a POST request to /persist/:targetNamespace/:targetSceneId with JSON payload:
{
action: "clone",
namespace: <string>, // name of source scene namespace
sceneId: <string>, // name of source scene sceneId
allowNonEmptyTarget: <bool>, // (optional) - set to `true` allow templating into a non-empty destination scene
}
After the template load, all objects behave as typical in any scene.
Notes:
- If a template source scene is empty with no objects, or the instanceid already exists within a target scene, the template load will fail.