Actually, when try to build remote view vtk.js client using vanilla method, Starting a vtk.js project from scratch | vtk.js
I can build, but when I run, I got below error message which is same run time error when I try to run it under angular project. Any hint?
The complained functiion are all here: should I call createMethods inside client code? should not, I don’t think the example on kitware official website will miss a call
I just tried to use v20.3.0 and did have problems. I recommend that you use nvm to manage the node version and then use nvm install 16.10.0 and then use nvm use 16.10.0 to switch to the node version
Thanks, most of time, I will be away from computer till next Monday, even internet acesss is limited.
Will try out next week.
Are you able to use vanilla vtk.js Starting a vtk.js project from scratch | vtk.js
to build remote viewer client? Can you try? Although my most of coding experience is on c++ , python. Still feel so frustrated I couldn’t build and run this example vtk.js.
Nothing explained there, then my understanding kitware folks believed it is so simple and obviously
don’t worry, Be heppy! In fact, you can run a python environment directly with this code
# pip install vtk
# pip install wslink
# import to process args
import sys
import os
# import vtk modules.
import vtk
from vtk.web import protocols
from vtk.web import wslink as vtk_wslink
from wslink import server
import argparse
# =============================================================================
# Create custom ServerProtocol class to handle clients requests
# =============================================================================
class _WebCone(vtk_wslink.ServerProtocol):
# Application configuration
view = None
authKey = "wslink-secret"
def initialize(self):
global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor
# Bring used components
self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
self.registerVtkWebProtocol(protocols.vtkWebViewPort())
self.registerVtkWebProtocol(protocols.vtkWebPublishImageDelivery(decode=False))
self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())
# Update authentication key to use
self.updateSecret(_WebCone.authKey)
# tell the C++ web app to use no encoding.
# ParaViewWebPublishImageDelivery must be set to decode=False to match.
self.getApplication().SetImageEncoding(0)
# Create default pipeline (Only once for all the session)
if not _WebCone.view:
# VTK specific code
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
cone = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
actor = vtk.vtkActor()
mapper.SetInputConnection(cone.GetOutputPort())
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renderWindow.Render()
# VTK Web application specific
_WebCone.view = renderWindow
self.getApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)
# =============================================================================
# Main: Parse args and start server
# =============================================================================
if __name__ == "__main__":
# Create argument parser
parser = argparse.ArgumentParser(
description="VTK/Web Cone web-application")
# Add default arguments
server.add_arguments(parser)
# Extract arguments
args = parser.parse_args()
# Configure our current application
_WebCone.authKey = args.authKey
# Start server
server.start_webserver(options=args, protocol=_WebCone)
and then use the command python
python server.py --port 1234
I can run python code, that is for remote server side rendering.
What do you mean open vtk.js
I try to build and run client code following vtk.js build from scratch link. I could build but when I open browser got unregistered method called exception.
Don’t we need to build client vtk.js code ?
Do you mean just open vtk.js example link to see volume rendered?( but I need to build client code by myself, right?
fully work. First run python vtk_ server.py — port 1234.
Then npm install, npm start, open broswer, the entire system works,
But that is using paraview as client. If I try vtk.js as client , I always got error
You actually need to provide a server server.py to run this file and specify the port number 1234, Then because of the https://kitware.github.io/vtk-js/examples/RemoteView/index.html this sample code to run is the connection service is your local service, so you will not need to NPM install and so on, Just open this browser and trust me, you can do it
Thanks , i got you. But I need to build the client code and run, right?
Otherwise how can I use my own code. For example using react or angular for ui, so embed vtk.js component, right? That is why I struggle to build and run
Your node native version is too high, it is recommended to use the stable version 18 or version 16. A lot of versions of 20 don’t fit. You can try it with nvm.
Can you try to build vtk.js
JavaScript client using this method Starting a vtk.js project from scratch | vtk.js ?
That will help a lot for many people I think. Like c++ code come with sln or Cmake, people can download and build.
Don’t know why vtk js doesn’t do this
I send the address of the project is based on the project to write Using vtk.js with vue.js | vtk.js, front-end webpack4 scaffolding tools and webpack5 version is very different, Just like python2 and python3, because much of the underlying library code needs to be version-bound, the front end has a lock file to lock the version of the package.
Hi,
Thanks for all your information. I tried the link you provided Using vtk.js with vue.js | vtk.js , I can build the code to show the cone and adjust the resolution, frame, surface etc. all.
But that is for client side rendering, I don’t know how to put vtk.js client code from remote rendering ( vtk.js) into the vue project link you provided.
For your vue example, I still could not build after using nvm use 16.
I am wondering whether you would help to make the kitware original example working. I attached the project. Inside you can see index_local.js, index_remote.js, index.js. You can run npm install, npm run start to server.
If use the content of index_local.js to replace index.js, you will see the cone displayed well, but this is the client redering.
If use the content of index_remote.js to replace index.js, you will see the errors, non registered method called.
Can you help me to make this work? I appreciate your help very much. ( BTW, I can use method provide at Starting a vtk.js project from scratch | vtk.js to make 1, client side rendering work 2, remote rending but use paraview as client. For remote rendering use vtk.js as client, I could not make it work.)
I tried to using Using vtk.js with vue.js | vtk.js to build vtk client code for remote rendering.
Client code I got from you github: GitHub - YaoDongcai/study-arco-pro .
Directly copy your code have build failure. I don’t know vue and I just may make some changes( mostly bad). But it compiled, then got similar run time error as vanilla javascript built, and angular project built I got before.
Here is my entire project, can you help to modify it to work. ( If you can help with the vanilla javascript project I send at last post, that would be best). my-vtkjs-app-2.zip (214.6 KB)
I understand it maybe more convenient for you to use wechat for communication. But I am testing and building the code on company computer. I cannot install wechat on my company computer. VTK user forum is approved place where I can download source code.