I am creating Web application using React.js and paraview-web.
now I am trying to change axes of 3d model on the server side and it changes the camera position correctly but to reflect this changes to the 3d object on the screen, I have to refresh the page or touch the object directly.
Here is how the server side code looks like
@exportRpc("set_orientation")
def set_orientation(self, orientation):
print(orientation)
if orientation=='X':
normal=[1,0,0]
upNormal=[0,0,1]
elif orientation=='Y':
normal=[0,1,0]
upNormal=[0,0,1]
elif orientation=='Z':
normal=[0,0,1]
upNormal=[0,1,0]
renderView=simple.GetRenderView()
renderView.CameraPosition = [0,0,0]
renderView.CameraFocalPoint = normal
renderView.CameraViewUp = upNormal
renderView.ResetCamera()
renderView.StillRender()
This is how I get the paraview web client on client-side.
const config = { sessionURL: "ws://localhost:1234/ws" };
const smartConnect = SmartConnect.newInstance({ config });
// Connecting to the paraview server
smartConnect.onConnectionReady((connection) => {
if (!pvw) {
const pvwClient = ParaViewWebClient.createClient(
connection,
// Default buit in protocols
["MouseHandler", "ViewPort", "ViewPortImageDelivery"],
// Adding messages to call functions from local protocol in the paraview server
{
local: (session) => createMethods(session),
ContourPlot: (session) => contourPlotMethods(session),
AirFlowStream: (session) => airFlowMethods(session),
CreateReport: (session) => createReportMethods(session),
}
);
// Setting remote renderer
const renderer = new RemoteRenderer(pvwClient);
renderer.setContainer(currentRenderer);
window.renderer = renderer;
SizeHelper.onSizeChange(() => {
renderer.resize();
});
SizeHelper.startListening();
// Set this session to the local state and pass it to the child components
sessionDispatch({ type: "SET_SESSION", payload: pvwClient });
} else {
// Setting remote renderer
const renderer = new RemoteRenderer(pvw);
renderer.setContainer(currentRenderer);
window.renderer = renderer;
SizeHelper.onSizeChange(() => {
renderer.resize();
});
SizeHelper.startListening();
// Set this session to the local state and pass it to the child components
sessionDispatch({ type: "SET_SESSION", payload: pvw });
}
});
smartConnect.connect();
If anyone knows how to reflect the changes on the client-side automatically, please help me.
Thank you