[X3D-Ecosystem] Global Socket fields for Protos
John Carlson
yottzumm at gmail.com
Sat Sep 14 22:49:36 PDT 2024
I have looked into X3DOM’s DIS pull request and found out that it uses
websocket URLs, and probably a websocket server (DISWebGateway?).
I am looking at setting up websockets in X_ITE. I prefer X_ITE over X3DOM
because I can use Scripts with typed fields. My current socket approach is
to use a socket.io global socket variable. Obviously, this is very
non-standard, but socket.io has 5M weekly downloads. I already have a
socket.io server that I can modify.
Currently, I can emit events from the client to the server using
socket.emit, in a Script, so I might have a “move” event that sends a
parameter name/value pair.
For receiving events, I use currently use socket.on to register event
handlers outside of X3D. This can be moved into the into the Script
initialize method, I believe. The event handler can call another Script
method to change create an event to transfer the parameter values to a
ComposedShader field. I will validate the parameter name in the script and
X3D will validate the parameter value through typing as SFFloat.
I am planning on using a ProtoDeclare to implement my parameter name/value
pair ProtoInstances (6 of them). The Proto will also display parameter
name/value pairs in Text nodes, and slide the TextNode across the screen to
follow the mouse, and I think the Proto may also include a PlaneSensor.
Another thing I am worried about is setting up event handlers before the
connection occurs. What I can do is set up a connection handler in the
Proto Script initialize method, then deal with events on a per Proto basis,
either by validating the move parameter name fits the ProtoInstance DEF (or
another field), or making my events the same as parameter names (not
desired).
I have not designed the Proto yet, but I am hopeful.
This is not a generic Transform or HAnimJoint solution. I’ll probably get
there if no one else does.
Probably HTTP/3 and WebTransport offers a more performant solution. I
already have a prototype solution that works with localhost and is nearly
deployed. I’m not looking at deploying HTTPS as node.js will likely be
behind Apache/F5, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-ecosystem_web3d.org/attachments/20240915/c421eca4/attachment.html>
More information about the X3D-Ecosystem
mailing list