Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
// ----------------------------------------------------------------------------
// Remote rendering setup
// ----------------------------------------------------------------------------
const imageStream = vtkImageStream.newInstance();
const config = { sessionURL: 'ws://localhost:1234/ws' };
const smartConnect = SmartConnect.newInstance({ config });
smartConnect.onConnectionReady((connection) => {
// Network
const session = connection.getSession();
// Image
imageStream.connect(session);
const viewStream = imageStream.createViewStream('-1');
fullScreenRenderer.getOpenGLRenderWindow().setViewStream(viewStream);
// Configure image quality
viewStream.setInteractiveQuality(75);
viewStream.setInteractiveRatio(0.5);
viewStream.setCamera(renderer.getActiveCamera());
viewStream.pushCamera();
// Bind user input
return new Promise((resolve, reject) => {
this.smartConnect = SmartConnect.newInstance({ config });
this.smartConnect.onConnectionReady((connection) => {
this.connection = connection;
this.imageStream = vtkImageStream.newInstance();
this.remote = {};
const session = connection.getSession();
// Link remote API
Object.keys(REMOTE_API).forEach((name) => {
this.remote[name] = busyWrap(
REMOTE_API[name](session),
this.updateBusy
);
});
// Link imageStream
this.imageStream.connect(session);
return new Promise((resolve, reject) => {
this.smartConnect = SmartConnect.newInstance({ config });
this.smartConnect.onConnectionReady((connection) => {
this.connection = connection;
this.imageStream = vtkImageStream.newInstance();
this.remote = {};
const session = connection.getSession();
// Link remote API
Object.keys(REMOTE_API).forEach((name) => {
this.remote[name] = busyWrap(
REMOTE_API[name](session),
this.updateBusy
);
});
// Link imageStream
this.imageStream.connect(session);
import SizeHelper from 'paraviewweb/src/Common/Misc/SizeHelper';
import ParaViewWebClient from 'paraviewweb/src/IO/WebSocket/ParaViewWebClient';
document.body.style.padding = '0';
document.body.style.margin = '0';
const divRenderer = document.createElement('div');
document.body.appendChild(divRenderer);
divRenderer.style.position = 'relative';
divRenderer.style.width = '100vw';
divRenderer.style.height = '100vh';
divRenderer.style.overflow = 'hidden';
const config = { sessionURL: 'ws://localhost:1234/ws' };
const smartConnect = SmartConnect.newInstance({ config });
smartConnect.onConnectionReady((connection) => {
const pvwClient = ParaViewWebClient.createClient(connection, [
'MouseHandler',
'ViewPort',
'ViewPortImageDelivery',
]);
const renderer = new RemoteRenderer(pvwClient);
renderer.setContainer(divRenderer);
renderer.onImageReady(() => {
console.log('We are good');
});
window.renderer = renderer;
SizeHelper.onSizeChange(() => {
renderer.resize();
});
SizeHelper.startListening();
function connect(config = {}) {
smartConnect = SmartConnect.newInstance({ config });
smartConnect.onConnectionReady(start);
smartConnect.onConnectionError(error);
smartConnect.onConnectionClose(close);
smartConnect.connect();
}
export function connect(config = {}) {
loading();
const smartConnect = SmartConnect.newInstance({ config });
smartConnect.onConnectionReady(start);
smartConnect.onConnectionError(triggerError);
smartConnect.onConnectionClose(triggerError);
smartConnect.connect();
}