@aics/agave-webclient 1.6.1
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/es/agave.js +788 -0
- package/es/commandbuffer.js +232 -0
- package/es/index.js +2 -0
- package/es/types/agave.d.ts +380 -0
- package/es/types/commandbuffer.d.ts +58 -0
- package/es/types/index.d.ts +2 -0
- package/es/types/test/placeholder.test.d.ts +1 -0
- package/package.json +64 -0
package/es/agave.js
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import { CommandBuffer, COMMANDS } from "./commandbuffer";
|
|
6
|
+
export var AgaveClient = /*#__PURE__*/function () {
|
|
7
|
+
function AgaveClient() {
|
|
8
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://localhost:1235/";
|
|
9
|
+
var rendermode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "pathtrace";
|
|
10
|
+
var onOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
|
|
11
|
+
return;
|
|
12
|
+
};
|
|
13
|
+
var onJson = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (_json) {
|
|
14
|
+
return;
|
|
15
|
+
};
|
|
16
|
+
var onImage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (_data) {
|
|
17
|
+
return;
|
|
18
|
+
};
|
|
19
|
+
_classCallCheck(this, AgaveClient);
|
|
20
|
+
if (rendermode !== "pathtrace" && rendermode !== "raymarch") {
|
|
21
|
+
rendermode = "pathtrace";
|
|
22
|
+
}
|
|
23
|
+
this.onOpen = onOpen;
|
|
24
|
+
this.onJson = onJson;
|
|
25
|
+
this.onImage = onImage;
|
|
26
|
+
this.cb = new CommandBuffer();
|
|
27
|
+
this.sessionName = "";
|
|
28
|
+
this.url = url + "?mode=" + rendermode;
|
|
29
|
+
this.socket = undefined;
|
|
30
|
+
}
|
|
31
|
+
_createClass(AgaveClient, [{
|
|
32
|
+
key: "connect",
|
|
33
|
+
value: function () {
|
|
34
|
+
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
|
+
var _this = this;
|
|
36
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
40
|
+
// First order of business: connect!
|
|
41
|
+
_this.socket = new WebSocket(_this.url);
|
|
42
|
+
|
|
43
|
+
// set binarytype according to how we expect clients to deal with received image data
|
|
44
|
+
_this.socket.binaryType = "blob"; //"arraybuffer";
|
|
45
|
+
|
|
46
|
+
// do some stuff on initial connection
|
|
47
|
+
_this.socket.onopen = function (_ev) {
|
|
48
|
+
_this.setResolution(256, 256);
|
|
49
|
+
// put agave in streaming mode from the get-go
|
|
50
|
+
_this.streamMode(1);
|
|
51
|
+
_this.flushCommandBuffer();
|
|
52
|
+
|
|
53
|
+
// user provided callback
|
|
54
|
+
if (_this.onOpen) {
|
|
55
|
+
_this.onOpen();
|
|
56
|
+
}
|
|
57
|
+
resolve(_this);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// TODO - handle this better, understand when and why it happens.
|
|
61
|
+
_this.socket.onclose = function (_ev) {
|
|
62
|
+
console.warn("AGAVE websocket connection closed.");
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// handle incoming messages
|
|
66
|
+
_this.socket.onmessage = function (evt) {
|
|
67
|
+
if (typeof evt.data === "string") {
|
|
68
|
+
var returnedObj = JSON.parse(evt.data);
|
|
69
|
+
if (returnedObj.commandId === COMMANDS.LOAD_DATA[0]) {
|
|
70
|
+
console.log(returnedObj);
|
|
71
|
+
// let users do something with this data
|
|
72
|
+
if (_this.onJson) {
|
|
73
|
+
_this.onJson(returnedObj);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
var arraybuf = evt.data;
|
|
79
|
+
// let users do something with this data
|
|
80
|
+
if (_this.onImage) {
|
|
81
|
+
_this.onImage(arraybuf);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// TODO handle this better
|
|
86
|
+
_this.socket.onerror = function (evt) {
|
|
87
|
+
console.log("error", evt);
|
|
88
|
+
reject(evt);
|
|
89
|
+
};
|
|
90
|
+
}));
|
|
91
|
+
case 1:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}));
|
|
97
|
+
function connect() {
|
|
98
|
+
return _connect.apply(this, arguments);
|
|
99
|
+
}
|
|
100
|
+
return connect;
|
|
101
|
+
}()
|
|
102
|
+
}, {
|
|
103
|
+
key: "isReady",
|
|
104
|
+
value: function isReady() {
|
|
105
|
+
if (this.socket) {
|
|
106
|
+
return this.socket.readyState === 1;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "disconnect",
|
|
112
|
+
value: function disconnect() {
|
|
113
|
+
if (this.socket) {
|
|
114
|
+
this.socket.close();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Set the current session name. Use the full path to the name of the output
|
|
120
|
+
* image here.
|
|
121
|
+
*
|
|
122
|
+
* @param name This name is the full path to the output image, ending in .png or .jpg.
|
|
123
|
+
* Make sure the directory has already been created.
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
}, {
|
|
127
|
+
key: "session",
|
|
128
|
+
value: function session(name) {
|
|
129
|
+
// 0
|
|
130
|
+
this.cb.addCommand("SESSION", name);
|
|
131
|
+
this.sessionName = name;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Sets a search path for volume files. NOT YET IMPLEMENTED.
|
|
135
|
+
*
|
|
136
|
+
* @param name This name is the path where volume images are located.
|
|
137
|
+
*/
|
|
138
|
+
}, {
|
|
139
|
+
key: "assetPath",
|
|
140
|
+
value: function assetPath(name) {
|
|
141
|
+
// 1
|
|
142
|
+
this.cb.addCommand("ASSET_PATH", name);
|
|
143
|
+
}
|
|
144
|
+
// load_ome_tif(name: string) {
|
|
145
|
+
// /*
|
|
146
|
+
// DEPRECATED. Use load_data
|
|
147
|
+
// */
|
|
148
|
+
// // 2
|
|
149
|
+
// this.cb.addCommand("LOAD_OME_TIF", name);
|
|
150
|
+
// }
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Set the viewer camera position. Default is (500,500,500).
|
|
154
|
+
*
|
|
155
|
+
* @param x The x coordinate
|
|
156
|
+
* @param y The y coordinate
|
|
157
|
+
* @param z The z coordinate
|
|
158
|
+
*/
|
|
159
|
+
}, {
|
|
160
|
+
key: "eye",
|
|
161
|
+
value: function eye(x, y, z) {
|
|
162
|
+
// 3
|
|
163
|
+
this.cb.addCommand("EYE", x, y, z);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Set the viewer target position. This is a point toward which we are looking.
|
|
168
|
+
* Default is (0,0,0).
|
|
169
|
+
*
|
|
170
|
+
* @param x The x coordinate
|
|
171
|
+
* @param y The y coordinate
|
|
172
|
+
* @param z The z coordinate
|
|
173
|
+
*/
|
|
174
|
+
}, {
|
|
175
|
+
key: "target",
|
|
176
|
+
value: function target(x, y, z) {
|
|
177
|
+
// 4
|
|
178
|
+
this.cb.addCommand("TARGET", x, y, z);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set the viewer camera up direction. This is a vector which should be nearly
|
|
183
|
+
* perpendicular to the view direction (target-eye), and defines the "roll" amount
|
|
184
|
+
* for the camera.
|
|
185
|
+
* Default is (0,0,1).
|
|
186
|
+
*
|
|
187
|
+
* @param x The x coordinate
|
|
188
|
+
* @param y The y coordinate
|
|
189
|
+
* @param z The z coordinate
|
|
190
|
+
*/
|
|
191
|
+
}, {
|
|
192
|
+
key: "up",
|
|
193
|
+
value: function up(x, y, z) {
|
|
194
|
+
// 5
|
|
195
|
+
this.cb.addCommand("UP", x, y, z);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Set the viewer camera aperture size.
|
|
200
|
+
*
|
|
201
|
+
* @param x The aperture size. This is a number between 0 and 1. 0 means no defocusing will occur, like a pinhole camera. 1 means maximum defocus. Default is 0.
|
|
202
|
+
*/
|
|
203
|
+
}, {
|
|
204
|
+
key: "aperture",
|
|
205
|
+
value: function aperture(x) {
|
|
206
|
+
// 6
|
|
207
|
+
this.cb.addCommand("APERTURE", x);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Set the viewer camera projection type, along with a relevant parameter.
|
|
212
|
+
* @param projectionType 0 for Perspective, 1 for Orthographic. Default: 0
|
|
213
|
+
* @param x If Perspective, then this is the vertical Field of View angle in degrees.
|
|
214
|
+
* If Orthographic, then this is the orthographic scale dimension.
|
|
215
|
+
* Default: 55.0 degrees. (default Orthographic scale is 0.5)
|
|
216
|
+
*/
|
|
217
|
+
}, {
|
|
218
|
+
key: "cameraProjection",
|
|
219
|
+
value: function cameraProjection(projectionType, x) {
|
|
220
|
+
// 7
|
|
221
|
+
this.cb.addCommand("CAMERA_PROJECTION", projectionType, x);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Set the viewer camera focal distance
|
|
226
|
+
*
|
|
227
|
+
* @param x The focal distance. Has no effect if aperture is 0.
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "focaldist",
|
|
231
|
+
value: function focaldist(x) {
|
|
232
|
+
// 8
|
|
233
|
+
this.cb.addCommand("FOCALDIST", x);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Set the exposure level
|
|
238
|
+
*
|
|
239
|
+
* @param x The exposure level between 0 and 1. Default is 0.75. Higher numbers are brighter.
|
|
240
|
+
*/
|
|
241
|
+
}, {
|
|
242
|
+
key: "exposure",
|
|
243
|
+
value: function exposure(x) {
|
|
244
|
+
// 9
|
|
245
|
+
this.cb.addCommand("EXPOSURE", x);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set the diffuse color of a channel
|
|
250
|
+
*
|
|
251
|
+
* @param channel Which channel index, 0 based.
|
|
252
|
+
* @param r The red value between 0 and 1
|
|
253
|
+
* @param g The green value between 0 and 1
|
|
254
|
+
* @param b The blue value between 0 and 1
|
|
255
|
+
* @param a The alpha value between 0 and 1 (currently unused)
|
|
256
|
+
*/
|
|
257
|
+
}, {
|
|
258
|
+
key: "matDiffuse",
|
|
259
|
+
value: function matDiffuse(channel, r, g, b, a) {
|
|
260
|
+
// 10
|
|
261
|
+
this.cb.addCommand("MAT_DIFFUSE", channel, r, g, b, a);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Set the specular color of a channel (defaults to black, for no specular
|
|
266
|
+
* response)
|
|
267
|
+
*
|
|
268
|
+
* @param channel Which channel index, 0 based.
|
|
269
|
+
* @param r The red value between 0 and 1
|
|
270
|
+
* @param g The green value between 0 and 1
|
|
271
|
+
* @param b The blue value between 0 and 1
|
|
272
|
+
* @param a The alpha value between 0 and 1 (currently unused)
|
|
273
|
+
*/
|
|
274
|
+
}, {
|
|
275
|
+
key: "matSpecular",
|
|
276
|
+
value: function matSpecular(channel, r, g, b, a) {
|
|
277
|
+
// 11
|
|
278
|
+
this.cb.addCommand("MAT_SPECULAR", channel, r, g, b, a);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Set the emissive color of a channel (defaults to black, for no emission)
|
|
283
|
+
*
|
|
284
|
+
* @param channel Which channel index, 0 based.
|
|
285
|
+
* @param r The red value between 0 and 1
|
|
286
|
+
* @param g The green value between 0 and 1
|
|
287
|
+
* @param b The blue value between 0 and 1
|
|
288
|
+
* @param a The alpha value between 0 and 1 (currently unused)
|
|
289
|
+
*/
|
|
290
|
+
}, {
|
|
291
|
+
key: "matEmissive",
|
|
292
|
+
value: function matEmissive(channel, r, g, b, a) {
|
|
293
|
+
// 12
|
|
294
|
+
this.cb.addCommand("MAT_EMISSIVE", channel, r, g, b, a);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Set the number of paths per pixel to accumulate.
|
|
299
|
+
*
|
|
300
|
+
* @param x How many paths per pixel. The more paths, the less noise in the image.
|
|
301
|
+
*/
|
|
302
|
+
}, {
|
|
303
|
+
key: "renderIterations",
|
|
304
|
+
value: function renderIterations(x) {
|
|
305
|
+
// 13
|
|
306
|
+
this.cb.addCommand("RENDER_ITERATIONS", x);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Turn stream mode on or off. Stream mode will send an image back to the client
|
|
311
|
+
* on each iteration up to some server-defined amount. This mode is useful for
|
|
312
|
+
* interactive client-server applications but not for batch-mode offline rendering.
|
|
313
|
+
*
|
|
314
|
+
* @param x 0 for off, 1 for on. Default is off.
|
|
315
|
+
*/
|
|
316
|
+
}, {
|
|
317
|
+
key: "streamMode",
|
|
318
|
+
value: function streamMode(x) {
|
|
319
|
+
// 14
|
|
320
|
+
this.cb.addCommand("STREAM_MODE", x);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Tell the server to process all commands and return an image
|
|
325
|
+
* TODO , and then save the image.
|
|
326
|
+
* TODO This function will block and wait for the image to be returned.
|
|
327
|
+
* TODO The image returned will be saved automatically using the session_name.
|
|
328
|
+
* TODO: a timeout is not yet implemented.
|
|
329
|
+
*/
|
|
330
|
+
}, {
|
|
331
|
+
key: "redraw",
|
|
332
|
+
value: function redraw() {
|
|
333
|
+
// 15
|
|
334
|
+
// issue command buffer
|
|
335
|
+
this.cb.addCommand("REDRAW");
|
|
336
|
+
this.flushCommandBuffer();
|
|
337
|
+
// // and then WAIT for render to be completed
|
|
338
|
+
// binarydata = this.ws.wait_for_image();
|
|
339
|
+
// // and save image
|
|
340
|
+
// im = Image.open(binarydata);
|
|
341
|
+
// print(this.session_name);
|
|
342
|
+
// im.save(this.session_name);
|
|
343
|
+
// // ready for next frame
|
|
344
|
+
// this.session_name = "";
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Set the image resolution in pixels.
|
|
349
|
+
*
|
|
350
|
+
* @param x x resolution in pixels
|
|
351
|
+
* @param y y resolution in pixels
|
|
352
|
+
*/
|
|
353
|
+
}, {
|
|
354
|
+
key: "setResolution",
|
|
355
|
+
value: function setResolution(x, y) {
|
|
356
|
+
// 16
|
|
357
|
+
this.cb.addCommand("SET_RESOLUTION", x, y);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Set the scattering density.
|
|
362
|
+
*
|
|
363
|
+
* @param x The scattering density, 0-100. Higher values will make the volume seem
|
|
364
|
+
* more opaque. Default is 8.5, which is relatively transparent.
|
|
365
|
+
*/
|
|
366
|
+
}, {
|
|
367
|
+
key: "density",
|
|
368
|
+
value: function density(x) {
|
|
369
|
+
// 17
|
|
370
|
+
this.cb.addCommand("DENSITY", x);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Automatically set camera parameters so that the volume fills the view.
|
|
375
|
+
* Useful when you have insufficient information to position the camera accurately.
|
|
376
|
+
*/
|
|
377
|
+
}, {
|
|
378
|
+
key: "frameScene",
|
|
379
|
+
value: function frameScene() {
|
|
380
|
+
// 18
|
|
381
|
+
this.cb.addCommand("FRAME_SCENE");
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Set the channel's glossiness.
|
|
386
|
+
*
|
|
387
|
+
* @param channel Which channel index, 0 based.
|
|
388
|
+
* @param glossiness Sets the shininess, a number between 0 and 100.
|
|
389
|
+
*/
|
|
390
|
+
}, {
|
|
391
|
+
key: "matGlossiness",
|
|
392
|
+
value: function matGlossiness(channel, glossiness) {
|
|
393
|
+
// 19
|
|
394
|
+
this.cb.addCommand("MAT_GLOSSINESS", channel, glossiness);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Show or hide a given channel
|
|
399
|
+
*
|
|
400
|
+
* @param channel Which channel index, 0 based.
|
|
401
|
+
* @param enabled 0 to hide, 1 to show
|
|
402
|
+
*/
|
|
403
|
+
}, {
|
|
404
|
+
key: "enableChannel",
|
|
405
|
+
value: function enableChannel(channel, enabled) {
|
|
406
|
+
// 20
|
|
407
|
+
this.cb.addCommand("ENABLE_CHANNEL", channel, enabled);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Set intensity threshold for a given channel based on Window/Level
|
|
412
|
+
*
|
|
413
|
+
* @param channel Which channel index, 0 based.
|
|
414
|
+
* @param window Width of the window, from 0-1.
|
|
415
|
+
* @param level Intensity level mapped to middle of window, from 0-1
|
|
416
|
+
*/
|
|
417
|
+
}, {
|
|
418
|
+
key: "setWindowLevel",
|
|
419
|
+
value: function setWindowLevel(channel, window, level) {
|
|
420
|
+
// 21
|
|
421
|
+
this.cb.addCommand("SET_WINDOW_LEVEL", channel, window, level);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Rotate the camera around the volume by angle deltas
|
|
426
|
+
*
|
|
427
|
+
* @param theta polar angle in degrees
|
|
428
|
+
* @param phi azimuthal angle in degrees
|
|
429
|
+
*/
|
|
430
|
+
}, {
|
|
431
|
+
key: "orbitCamera",
|
|
432
|
+
value: function orbitCamera(theta, phi) {
|
|
433
|
+
// 22
|
|
434
|
+
this.cb.addCommand("ORBIT_CAMERA", theta, phi);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Rotate the camera around the volume by angle deltas
|
|
439
|
+
*
|
|
440
|
+
* @param theta vertical screen angle in degrees
|
|
441
|
+
* @param phi horizontal screen angle in degrees
|
|
442
|
+
*/
|
|
443
|
+
}, {
|
|
444
|
+
key: "trackballCamera",
|
|
445
|
+
value: function trackballCamera(theta, phi) {
|
|
446
|
+
// 43
|
|
447
|
+
this.cb.addCommand("TRACKBALL_CAMERA", theta, phi);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Set the "north pole" color of the sky sphere
|
|
452
|
+
*
|
|
453
|
+
* @param r The red value between 0 and 1
|
|
454
|
+
* @param g The green value between 0 and 1
|
|
455
|
+
* @param b The blue value between 0 and 1
|
|
456
|
+
*/
|
|
457
|
+
}, {
|
|
458
|
+
key: "skylightTopColor",
|
|
459
|
+
value: function skylightTopColor(r, g, b) {
|
|
460
|
+
// 23
|
|
461
|
+
this.cb.addCommand("SKYLIGHT_TOP_COLOR", r, g, b);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Set the "equator" color of the sky sphere
|
|
466
|
+
*
|
|
467
|
+
* @param r The red value between 0 and 1
|
|
468
|
+
* @param g The green value between 0 and 1
|
|
469
|
+
* @param b The blue value between 0 and 1
|
|
470
|
+
*/
|
|
471
|
+
}, {
|
|
472
|
+
key: "skylightMiddleColor",
|
|
473
|
+
value: function skylightMiddleColor(r, g, b) {
|
|
474
|
+
// 24
|
|
475
|
+
this.cb.addCommand("SKYLIGHT_MIDDLE_COLOR", r, g, b);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Set the "south pole" color of the sky sphere
|
|
480
|
+
*
|
|
481
|
+
* @param r The red value between 0 and 1
|
|
482
|
+
* @param g The green value between 0 and 1
|
|
483
|
+
* @param b The blue value between 0 and 1
|
|
484
|
+
*/
|
|
485
|
+
}, {
|
|
486
|
+
key: "skylightBottomColor",
|
|
487
|
+
value: function skylightBottomColor(r, g, b) {
|
|
488
|
+
// 25
|
|
489
|
+
this.cb.addCommand("SKYLIGHT_BOTTOM_COLOR", r, g, b);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Set the position of an area light, in spherical coordinates
|
|
494
|
+
*
|
|
495
|
+
* @param index Which light to set. Currently unused as there is only one area light.
|
|
496
|
+
* @param r The radius, as distance from the center of the volume
|
|
497
|
+
* @param theta The polar angle
|
|
498
|
+
* @param phi The azimuthal angle
|
|
499
|
+
*/
|
|
500
|
+
}, {
|
|
501
|
+
key: "lightPos",
|
|
502
|
+
value: function lightPos(index, r, theta, phi) {
|
|
503
|
+
// 26
|
|
504
|
+
this.cb.addCommand("LIGHT_POS", index, r, theta, phi);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Set the color of an area light. Overdrive the values higher than 1 to increase
|
|
509
|
+
* the light's intensity.
|
|
510
|
+
*
|
|
511
|
+
* @param index Which light to set. Currently unused as there is only one area light.
|
|
512
|
+
* @param r The red value between 0 and 1
|
|
513
|
+
* @param g The green value between 0 and 1
|
|
514
|
+
* @param b The blue value between 0 and 1
|
|
515
|
+
*/
|
|
516
|
+
}, {
|
|
517
|
+
key: "lightColor",
|
|
518
|
+
value: function lightColor(index, r, g, b) {
|
|
519
|
+
// 27
|
|
520
|
+
this.cb.addCommand("LIGHT_COLOR", index, r, g, b);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Set the size dimensions of a rectangular area light.
|
|
525
|
+
*
|
|
526
|
+
* @param index Which light to set. Currently unused as there is only one area light.
|
|
527
|
+
* @param x The width dimension of the area light
|
|
528
|
+
* @param y The height dimension of the area light
|
|
529
|
+
*/
|
|
530
|
+
}, {
|
|
531
|
+
key: "lightSize",
|
|
532
|
+
value: function lightSize(index, x, y) {
|
|
533
|
+
// 28
|
|
534
|
+
this.cb.addCommand("LIGHT_SIZE", index, x, y);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Set the axis aligned region of interest of the volume. All axis values are
|
|
539
|
+
* relative, where 0 is one extent of the volume and 1 is the opposite extent.
|
|
540
|
+
* For example, (0,1, 0,1, 0,0.5) will select the lower half of the volume's z
|
|
541
|
+
* slices.
|
|
542
|
+
*
|
|
543
|
+
* @param minx The lower x extent between 0 and 1
|
|
544
|
+
* @param maxx The higher x extent between 0 and 1
|
|
545
|
+
* @param miny The lower y extent between 0 and 1
|
|
546
|
+
* @param maxy The higher y extent between 0 and 1
|
|
547
|
+
* @param minz The lower z extent between 0 and 1
|
|
548
|
+
* @param maxz The higher z extent between 0 and 1
|
|
549
|
+
*/
|
|
550
|
+
}, {
|
|
551
|
+
key: "setClipRegion",
|
|
552
|
+
value: function setClipRegion(minx, maxx, miny, maxy, minz, maxz) {
|
|
553
|
+
// 29
|
|
554
|
+
this.cb.addCommand("SET_CLIP_REGION", minx, maxx, miny, maxy, minz, maxz);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Set the relative scale of the pixels in the volume. Typically this is filled in
|
|
559
|
+
* with the physical pixel dimensions from the microscope metadata. Often the x
|
|
560
|
+
* and y scale will differ from the z scale. Defaults to (1,1,1)
|
|
561
|
+
*
|
|
562
|
+
* @param x x scale
|
|
563
|
+
* @param y y scale
|
|
564
|
+
* @param z z scale
|
|
565
|
+
*/
|
|
566
|
+
}, {
|
|
567
|
+
key: "setVoxelScale",
|
|
568
|
+
value: function setVoxelScale(x, y, z) {
|
|
569
|
+
// 30
|
|
570
|
+
this.cb.addCommand("SET_VOXEL_SCALE", x, y, z);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Automatically determine the intensity thresholds
|
|
575
|
+
*
|
|
576
|
+
* @param channel Which channel index, 0 based.
|
|
577
|
+
* @param method Allowed values:
|
|
578
|
+
* 0: Auto2
|
|
579
|
+
* 1: Auto
|
|
580
|
+
* 2: BestFit
|
|
581
|
+
* 3: ChimeraX emulation
|
|
582
|
+
* 4: between 0.5 percentile and 0.98 percentile
|
|
583
|
+
*/
|
|
584
|
+
}, {
|
|
585
|
+
key: "autoThreshold",
|
|
586
|
+
value: function autoThreshold(channel, method) {
|
|
587
|
+
// 31
|
|
588
|
+
this.cb.addCommand("AUTO_THRESHOLD", channel, method);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Set intensity thresholds based on percentiles of pixels to clip min and max
|
|
593
|
+
* intensity
|
|
594
|
+
*
|
|
595
|
+
* @param channel Which channel index, 0 based.
|
|
596
|
+
* @param pctLow The low percentile to remap to 0(min) intensity
|
|
597
|
+
* @param pctHigh The high percentile to remap to 1(max) intensity
|
|
598
|
+
*/
|
|
599
|
+
}, {
|
|
600
|
+
key: "setPercentileThreshold",
|
|
601
|
+
value: function setPercentileThreshold(channel, pctLow, pctHigh) {
|
|
602
|
+
// 32
|
|
603
|
+
this.cb.addCommand("SET_PERCENTILE_THRESHOLD", channel, pctLow, pctHigh);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Set channel opacity. This is a multiplier against all intensity values in the
|
|
608
|
+
* channel.
|
|
609
|
+
*
|
|
610
|
+
* @param channel Which channel index, 0 based.
|
|
611
|
+
* @param opacity A multiplier between 0 and 1. Default is 1
|
|
612
|
+
*/
|
|
613
|
+
}, {
|
|
614
|
+
key: "matOpacity",
|
|
615
|
+
value: function matOpacity(channel, opacity) {
|
|
616
|
+
// 33
|
|
617
|
+
this.cb.addCommand("MAT_OPACITY", channel, opacity);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Set primary ray step size. This is an accuracy versus speed tradeoff. Low
|
|
622
|
+
* values are more accurate. High values will render faster.
|
|
623
|
+
* Primary rays are the rays that are cast from the camera out into the volume.
|
|
624
|
+
*
|
|
625
|
+
* @param stepSize A value in voxels. Default is 4. Minimum sensible value is 1.
|
|
626
|
+
*/
|
|
627
|
+
}, {
|
|
628
|
+
key: "setPrimaryRayStepSize",
|
|
629
|
+
value: function setPrimaryRayStepSize(stepSize) {
|
|
630
|
+
// 34
|
|
631
|
+
this.cb.addCommand("SET_PRIMARY_RAY_STEP_SIZE", stepSize);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Set secondary ray step size. This is an accuracy versus speed tradeoff. Low
|
|
636
|
+
* values are more accurate. High values will render faster.
|
|
637
|
+
* The secondary rays are rays which are cast toward lights after they have
|
|
638
|
+
* scattered within the volume.
|
|
639
|
+
*
|
|
640
|
+
* @param stepSize A value in voxels. Default is 4. Minimum sensible value is 1.
|
|
641
|
+
*/
|
|
642
|
+
}, {
|
|
643
|
+
key: "setSecondaryRayStepSize",
|
|
644
|
+
value: function setSecondaryRayStepSize(stepSize) {
|
|
645
|
+
// 35
|
|
646
|
+
this.cb.addCommand("SET_SECONDARY_RAY_STEP_SIZE", stepSize);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Set the background color of the rendering
|
|
651
|
+
*
|
|
652
|
+
* @param r The red value between 0 and 1
|
|
653
|
+
* @param g The green value between 0 and 1
|
|
654
|
+
* @param b The blue value between 0 and 1
|
|
655
|
+
*/
|
|
656
|
+
}, {
|
|
657
|
+
key: "backgroundColor",
|
|
658
|
+
value: function backgroundColor(r, g, b) {
|
|
659
|
+
// 36
|
|
660
|
+
this.cb.addCommand("BACKGROUND_COLOR", r, g, b);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Set intensity thresholds based on values around an isovalue.
|
|
665
|
+
*
|
|
666
|
+
* @param channel Which channel index, 0 based.
|
|
667
|
+
* @param isovalue The value to center at maximum intensity, between 0 and 1
|
|
668
|
+
* @param isorange A range around the isovalue to keep at constant intensity, between 0 and 1.
|
|
669
|
+
* Typically small, to select for a single isovalue.
|
|
670
|
+
*/
|
|
671
|
+
}, {
|
|
672
|
+
key: "setIsovalueThreshold",
|
|
673
|
+
value: function setIsovalueThreshold(channel, isovalue, isorange) {
|
|
674
|
+
// 37
|
|
675
|
+
this.cb.addCommand("SET_ISOVALUE_THRESHOLD", channel, isovalue, isorange);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Set intensity thresholds based on a piecewise linear transfer function.
|
|
680
|
+
*
|
|
681
|
+
* @param channel Which channel index, 0 based.
|
|
682
|
+
* @param data An array of values. 5 floats per control point. first is position (0-1),
|
|
683
|
+
* next four are rgba (all 0-1). Only alpha is currently used as the remapped
|
|
684
|
+
* intensity value. All others are linearly interpolated.
|
|
685
|
+
*/
|
|
686
|
+
}, {
|
|
687
|
+
key: "setControlPoints",
|
|
688
|
+
value: function setControlPoints(channel, data) {
|
|
689
|
+
// 38
|
|
690
|
+
this.cb.addCommand("SET_CONTROL_POINTS", channel, data);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// load_volume_from_file(path: string, scene: number, time: number) {
|
|
694
|
+
// /*
|
|
695
|
+
// DEPRECATED. Use load_data
|
|
696
|
+
// */
|
|
697
|
+
// // 39
|
|
698
|
+
// this.cb.addCommand("LOAD_VOLUME_FROM_FILE", path, scene, time);
|
|
699
|
+
// }
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Load a time from the current volume file
|
|
703
|
+
*
|
|
704
|
+
* @param time zero-based index to select the time sample. Defaults to 0
|
|
705
|
+
*/
|
|
706
|
+
}, {
|
|
707
|
+
key: "setTime",
|
|
708
|
+
value: function setTime(time) {
|
|
709
|
+
// 40
|
|
710
|
+
this.cb.addCommand("SET_TIME", time);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Set the color for the bounding box display
|
|
715
|
+
*
|
|
716
|
+
* @param r the red value, from 0 to 1
|
|
717
|
+
* @param g the green value, from 0 to 1
|
|
718
|
+
* @param b the blue value, from 0 to 1
|
|
719
|
+
*/
|
|
720
|
+
}, {
|
|
721
|
+
key: "boundingBoxColor",
|
|
722
|
+
value: function boundingBoxColor(r, g, b) {
|
|
723
|
+
// 41
|
|
724
|
+
this.cb.addCommand("SET_BOUNDING_BOX_COLOR", r, g, b);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Turn bounding box display on or off
|
|
729
|
+
*
|
|
730
|
+
* @param on 0 to hide bounding box, 1 to show it
|
|
731
|
+
*/
|
|
732
|
+
}, {
|
|
733
|
+
key: "showBoundingBox",
|
|
734
|
+
value: function showBoundingBox(on) {
|
|
735
|
+
// 42
|
|
736
|
+
this.cb.addCommand("SHOW_BOUNDING_BOX", on);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Completely specify volume data to load
|
|
741
|
+
*
|
|
742
|
+
* @param path URL or directory or file path to the data. The path must be locally
|
|
743
|
+
* accessible from the AGAVE server.
|
|
744
|
+
* @param scene zero-based index to select the scene, for multi-scene files. Defaults to 0
|
|
745
|
+
* @param multiresolutionLevel zero-based index to select the multiresolution level. Defaults to 0
|
|
746
|
+
* @param time zero-based index to select the time sample. Defaults to 0
|
|
747
|
+
* @param channels zero-based indices to select the channels. Defaults to all channels
|
|
748
|
+
* @param region 6 integers specifying the region to load. Defaults to the entire volume.
|
|
749
|
+
* Any list length other than 0 or 6 is an error.
|
|
750
|
+
*/
|
|
751
|
+
}, {
|
|
752
|
+
key: "loadData",
|
|
753
|
+
value: function loadData(path) {
|
|
754
|
+
var scene = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
755
|
+
var multiresolutionLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
756
|
+
var time = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
757
|
+
var channels = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
758
|
+
var region = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
|
|
759
|
+
// 44
|
|
760
|
+
this.cb.addCommand("LOAD_DATA", path, scene, multiresolutionLevel, time, channels, region);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Turn scale bar display on or off
|
|
765
|
+
*
|
|
766
|
+
* @param on 0 to hide scale bar, 1 to show it
|
|
767
|
+
*/
|
|
768
|
+
}, {
|
|
769
|
+
key: "showScaleBar",
|
|
770
|
+
value: function showScaleBar(on) {
|
|
771
|
+
// 45
|
|
772
|
+
this.cb.addCommand("SHOW_SCALE_BAR", on);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// send all data in our current command buffer to the server
|
|
776
|
+
}, {
|
|
777
|
+
key: "flushCommandBuffer",
|
|
778
|
+
value: function flushCommandBuffer() {
|
|
779
|
+
if (this.cb.length() > 0 && this.socket) {
|
|
780
|
+
var buf = this.cb.prebufferToBuffer();
|
|
781
|
+
this.socket.send(buf);
|
|
782
|
+
// assuming the buffer is sent, prepare a new one
|
|
783
|
+
this.cb = new CommandBuffer();
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}]);
|
|
787
|
+
return AgaveClient;
|
|
788
|
+
}();
|