@zerodensity/realityhub-api 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +7 -0
- package/README.md +78 -53
- package/package.json +3 -3
- package/src/lib/BrokerClient.js +3 -3
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Contributing to RealityHub Open-Source SDK
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to RealityHub Open-Source SDK!
|
|
4
|
+
|
|
5
|
+
## Contribution Guidelines
|
|
6
|
+
|
|
7
|
+
At this time, external contributions are not being accepted. We appreciate your understanding and your support of the RealityHub Open-Source SDK!
|
package/README.md
CHANGED
|
@@ -30,72 +30,87 @@ BrokerClient.initModule({
|
|
|
30
30
|
serverURL: '<your backend module>',
|
|
31
31
|
hub: {
|
|
32
32
|
host: '127.0.0.1',
|
|
33
|
-
port:
|
|
33
|
+
port: 80,
|
|
34
34
|
},
|
|
35
35
|
}).then((brokerClient) => {
|
|
36
36
|
// brokerClient is connected to RealityHub and ready to use
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
### Listing
|
|
40
|
+
### Listing Reality 5 (API v1.2+) engines
|
|
41
41
|
|
|
42
42
|
```js
|
|
43
|
-
brokerClient.api.hub.
|
|
43
|
+
brokerClient.api.hub.reality5_1_2_world.listEngines()
|
|
44
44
|
.then((engines) => {
|
|
45
45
|
console.log(engines);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* [
|
|
49
|
+
* {
|
|
50
|
+
* ip: '172.16.1.181',
|
|
51
|
+
* port: 50052,
|
|
52
|
+
* id: 79,
|
|
53
|
+
* name: 'ZDHQ-HUB-AMPERE',
|
|
54
|
+
* ready: true,
|
|
55
|
+
* status: 'connected',
|
|
56
|
+
* fps: '', // If there is no UE5 node, FPS will be an empty string
|
|
57
|
+
* engineType: 'RE5_1_2'
|
|
58
|
+
* }
|
|
59
|
+
* ]
|
|
60
|
+
*/
|
|
46
61
|
})
|
|
47
62
|
.catch((ex) => console.trace(ex));
|
|
48
63
|
```
|
|
49
64
|
|
|
50
|
-
### Listing the nodes running on an engine
|
|
65
|
+
### Listing the nodes running on an Reality 5 engine (API v1.2+)
|
|
51
66
|
|
|
52
67
|
```js
|
|
53
|
-
brokerClient.api.hub.
|
|
68
|
+
brokerClient.api.hub.reality5_1_2_world.getNodes(79 /* id of the engine */)
|
|
54
69
|
.then((nodes) => {
|
|
55
70
|
console.log(nodes);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* {
|
|
74
|
+
* ...
|
|
75
|
+
* // The keys are the NodePath
|
|
76
|
+
* Cyclorama: {
|
|
77
|
+
* ...
|
|
78
|
+
* Functions: {
|
|
79
|
+
* // The keys are the FunctionPath
|
|
80
|
+
* 'Cyclorama/AddProjection': {...},
|
|
81
|
+
* 'Cyclorama/ClearProjection': {...},
|
|
82
|
+
* }
|
|
83
|
+
* ...
|
|
84
|
+
* }
|
|
85
|
+
* ...
|
|
86
|
+
* }
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
// NOTE: For backward compatiblity, the NodePath and FunctionPath omit the leading '/'.
|
|
56
90
|
})
|
|
57
91
|
.catch((ex) => console.trace(ex));
|
|
58
92
|
```
|
|
59
93
|
|
|
60
|
-
### Calling a
|
|
94
|
+
### Calling a Node's Function
|
|
61
95
|
|
|
62
96
|
You can use `callNodeFunction(params[, engineIds])` to call a node function. `engineIds` is an array
|
|
63
97
|
of engine IDs. If `engineIds` is not supplied then the function will be called on all the engines.
|
|
64
98
|
|
|
65
99
|
```js
|
|
66
100
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @type {object}
|
|
69
|
-
* @property {string} NodePath
|
|
70
|
-
* @property {string} PropertyPath
|
|
71
|
-
* @property {object} payload
|
|
72
|
-
* @property {*} payload.value
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Node_0's PLAY function is called
|
|
101
|
+
* Cyclorama's Add Projection function is called
|
|
77
102
|
* @param {object} params
|
|
78
103
|
* @param {string} params.NodePath
|
|
79
104
|
* @param {string} params.PropertyPath
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {number} [engineIds] - (optional)
|
|
105
|
+
* @param {number} [engineIds] - optional, default is all engines
|
|
82
106
|
*/
|
|
83
|
-
brokerClient.api.hub.
|
|
84
|
-
NodePath: '
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
NodePath: 'Mixer Default',
|
|
89
|
-
PropertyPath: 'Default/DoTransition/Duration/0',
|
|
90
|
-
payload: {
|
|
91
|
-
value: 8,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
}).catch((ex) => console.trace(ex));
|
|
107
|
+
brokerClient.api.hub.reality5_1_2_world.callNodeFunction({
|
|
108
|
+
NodePath: '/Cyclorama',
|
|
109
|
+
FunctionPath: '/Cyclorama/AddProjection',
|
|
110
|
+
}, [/* engine id = */ 79]).catch((ex) => console.trace(ex));
|
|
96
111
|
```
|
|
97
112
|
|
|
98
|
-
### Setting a
|
|
113
|
+
### Setting a Node's Property Value
|
|
99
114
|
|
|
100
115
|
You can use `setNodeProperty(params[, engineIds])` to set a node's property value. `engineIds` is an
|
|
101
116
|
array of engine IDs. If `engineIds` not supplied then all of the engines will receive the set node
|
|
@@ -107,36 +122,46 @@ property command.
|
|
|
107
122
|
* @param {string} params.NodePath
|
|
108
123
|
* @param {string} params.PropertyPath
|
|
109
124
|
* @param {*} params.Value
|
|
110
|
-
* @param {number} [params.Delay=0] - (optional) Delay in seconds
|
|
111
|
-
* @param {number} [params.Duration=0] - (optional) Duration in seconds
|
|
112
|
-
* @param {Jump|Linear|EaseIn|EaseOut|EaseInOut} [params.InterpType=Jump] - (optional)
|
|
113
125
|
* @param {number} [engineIds] - (optional)
|
|
114
126
|
*/
|
|
115
|
-
brokerClient.api.hub.
|
|
116
|
-
NodePath: '
|
|
117
|
-
PropertyPath: '
|
|
127
|
+
brokerClient.api.hub.reality5_1_2_world.setNodeProperty({
|
|
128
|
+
NodePath: '/Add_f32',
|
|
129
|
+
PropertyPath: 'X',
|
|
118
130
|
Value: 0.240,
|
|
119
|
-
|
|
120
|
-
Duration: 1,
|
|
121
|
-
}).catch((ex) => console.trace(ex));
|
|
131
|
+
}, [/* engine id = */ = 79]).catch((ex) => console.trace(ex));
|
|
122
132
|
```
|
|
123
133
|
|
|
124
|
-
###
|
|
134
|
+
### Interpolating a Node's Property Value
|
|
135
|
+
|
|
136
|
+
You can use `interpolate(params[, engineIds])` to interpolate a node's property value. `engineIds` is an array of engine IDs. If `engineIds` not supplied then all of the engines will receive the same interpolate command.
|
|
125
137
|
|
|
126
138
|
```js
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
brokerClient.api.hub.reality5_1_2_world.interpolate({
|
|
140
|
+
NodePath: '/Add_f32',
|
|
141
|
+
PropertyPath: 'X',
|
|
142
|
+
StartValue: 5.0, // optional, default is the current value
|
|
143
|
+
EndValue: 10.0,
|
|
144
|
+
Duration: 2000, // in milliseconds, optional, default is 0
|
|
145
|
+
Delay: 2000, // in milliseconds, optional, default is 0
|
|
146
|
+
|
|
147
|
+
/** @type {'Jump' | 'Linear' | 'EaseIn' | 'EaseOut' | 'EaseInOut'} */
|
|
148
|
+
InterpType: 'EaseIn', // optional, default is 'Jump'
|
|
149
|
+
}, [/* engine id = */ 79]).catch((ex) => console.trace(ex));
|
|
150
|
+
```
|
|
129
151
|
|
|
130
|
-
|
|
131
|
-
.then((engines) => engines[0].id)
|
|
132
|
-
.then((engineId) => {
|
|
133
|
-
brokerClient.api.hub.reality_world.on(`nodepropertyupdate::${engineId}::Mixer_0`, (eventData) => {
|
|
134
|
-
if (eventData.property.PropertyPath !== 'Overlay Options//OverlayOpacity/0') return;
|
|
152
|
+
### Getting a Node's Property Value
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
154
|
+
You can use `getNodeProperty(params[, engineIds])` to get a node's property value. `engineIds` is an array of engine IDs. If `engineIds` not supplied then all of the engines will be queried. That is why this method returns an array of promises.
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
brokerClient.api.hub.reality5_1_2_world.getNodeProperty(
|
|
158
|
+
{ NodePath: '/Add_f32', PropertyPath: 'X', },
|
|
159
|
+
[/* engine id = */ 79]
|
|
160
|
+
)
|
|
161
|
+
.then((results) => {
|
|
162
|
+
console.log(results[0].Value);
|
|
163
|
+
})
|
|
164
|
+
.catch((ex) => console.trace(ex));
|
|
140
165
|
```
|
|
141
166
|
|
|
142
167
|
### Registering Your Own Methods to RealityHub
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodensity/realityhub-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "RealityHub API Javascript Implementation",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/zerodensity/realityhub-api#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"uuid": "^
|
|
34
|
-
"ws": "^
|
|
33
|
+
"uuid": "^11.0.3",
|
|
34
|
+
"ws": "^8.18.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/lib/BrokerClient.js
CHANGED
|
@@ -313,9 +313,9 @@ module.exports = class BrokerClient extends BrokerBase {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
case 'unsubscribe': {
|
|
316
|
-
const
|
|
317
|
-
const eventName =
|
|
318
|
-
const targetModuleName =
|
|
316
|
+
const [vendor, moduleName, ...rest] = message.eventName.split(".");
|
|
317
|
+
const eventName = rest.join(".");
|
|
318
|
+
const targetModuleName = [vendor, moduleName].join(".");
|
|
319
319
|
|
|
320
320
|
if (this.moduleName === targetModuleName) {
|
|
321
321
|
this.emit('unsubscribe', { eventName });
|