From bc44e6b3339976fc08d86eecc79f972fb90aecab Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 1 Jan 2016 21:57:24 +1000 Subject: Import the design docs from Drupal / MediaWiki. --- docs/NGIW.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/NGIW.html (limited to 'docs/NGIW.html') diff --git a/docs/NGIW.html b/docs/NGIW.html new file mode 100644 index 0000000..07ccc63 --- /dev/null +++ b/docs/NGIW.html @@ -0,0 +1,49 @@ + + + + +

See also SledjHamr

+

Random thoughts about Next Generation Immersive Web, or whatever we call it.

+

Here I want to indicate a possible design direction. The buzzword compliant summary is HTTP 1.1, REST and JSON.

+

I don't want to descend into the actual messy details here, so I will make some simplifications. I will assume a simplified world where there are only two kinds of things, boxes and textures. Boxes have a position, a rotation, a size, and a single texture. The software architecture will be simplified to two elements of software, the simulator and the client.

+

Suppose the simulator is at http://simulat.or/sim01 .

+

Then, per usual REST design, to ask about box 104, the client would "GET /sim01/object/b104". Similar to opening http://simulat.or/sim01/object/b104 in a web browser.

+

The sample response might be

+
   {   "at":1000,
+       "id":"b104",
+       "p":[1,1,1],
+       "r":[0,0,0,0],
+       "s":[0.5,0.5,0.5],
+       "t":"/sim01/texture/t104" }
+
+

This is a really important data structure, it is the representation that forms part of the REST acronym. Since we are talking about a simulator, it isn't really complete to say an object has a certain position. In a simulator all properties of objects are dependant on time. The "at" field encodes some time representation. Probably something like Unix time * 1000, aka the number of miliseconds since 1970 UTC. The "id" field is the name of the object. The "p" field is the position encoded as a JSON array of 3 numbers, the "r" the rotation (quaternion) encoded as a JSON array of 4 numbers, the "s" the size encoded as a JSON array of 3 numbers, and "t" is the texture.

+

Since we are talking to a web server, and since we want to sometimes reference textures from other places than the simulator, the value of the texture is a URL. In this case a relative URL that leaves out the server, thus meaning the full URL to the texture is "http://simulat.or/sim01/texture/t104". If the client needs the texture it can do a GET of "http://simulat.or/sim01/texture/t104". There are ways to further compress this information, but let's not fix what isn't broken.

+

Supose the user moved the box up 1 meter by some manipulation of the client. The client would "PUT /sim01/object/b104" with the data

+
   {   "at":1001,
+       "id":"b104",
+       "p":[1,1,2],
+       "r":[0,0,0,0],
+       "s":[0.5,0.5,0.5],
+       "t":"/sim01/texture/t104" }
+
+

Always transfering the full representation of an object could be wastefull and error prone so I slightly bend REST. I will use POST to an object to transmit only the changed fields. So "POST /sim01/object/b104" with the data

+
   {   "at":1001,
+       "id":"b104",
+       "p":[1,1,2]  }
+
+

would cause the same change in the simulator state.

+

To get the current state of the world "GET /sim01/object" would reply with all the objects. In this case it would be a JSON array of JSON objects similar to the first example above:

+
   [   {"at":999,"id":...}, {"at":999,...} ... ]
+
+

But, look what happens when we understand that the reply is using chunked encoding. The simulator might not actually ever finish sending the state of the world. The client might get

+
   [   {"at":999,"id":...}, {"at":999,...},
+
+

in the first chunk, and more

+
   {"at":1000,...}, {"at":1001,...}, ...
+
+

in the second chunk. And so forth. Again, sending all the fields of all the objects, even for just the changed objects is wastefull. I see a few ways to go.

+

If the server knows it has sent a full description of an object to a client, then future updates would, like the POST, only include the changed parts of the object.

+

Alternatively, lowering the load on the server, the client closes the "GET /sim01/object" connection at some point, and does "GET /sim01/object?delta". At that point only updates are ever sent. If the client sees a change to some object it doesn't recognize, is opens a second connection and requests "GET /sim01/object/b999" for example to get the full description.

+

The third alternative is that all the server ever sends in response to "GET /sim01/object" is a stream of changes. If the client doesn't have enough information to render an object, it can query the individual object as in the first example.

+ + -- cgit v1.1