vtk.js remote view client failed to build.

I am trying to build vtk.js for remote rendering vtk.js (kitware.github.io).

But spend a lot of time, I could not make the client working. ( I am sure my vtk_server.py works fine, I could make the entire system working if I use pavarviewweb as client following this GitHub - dmreagan/vtk-remote-render: A simple example of a ParaViewWeb remote renderer.).

I try to learn from kitware webset how to build vanillat vtk.js, and found this link Starting a vtk.js project from scratch | vtk.js (kitware.github.io),
1, I do step by step, I can see the cone is rendering correclty with resolution adjustable.
2, but if I replace index.js code with code from vtk.js (kitware.github.io), I got

Can somebody help to set up a simple project, so I can complile the client code here and run remote rederng. vtk.js

I tried this web-project-templates/vue-vtkjs-pvw-template at master · Kitware/web-project-templates · GitHub too, but when I build the project, I got error.
This is a complex project, quite difficult to decribe what I did, but Starting a vtk.js project from scratch | vtk.js (kitware.github.io), insturctions seem quite clear, I don’t know why I cannot make this vtk.js (kitware.github.io). working.

you can use YaoDongcai/study-arco-pro (github.com)

thanks for the link.

I download your code from git, when I run npm install, I got below error. My node version is v20.3.0.

Can you tell how I can build your projec?

Best

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



Or you can focus on https://www.zhihu.com/column/c_1547867426552750080
Or you can use yarn install

If you still can’t, please add my wechat 18556538705 remarks information
Best

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 :roll_eyes:

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

like this
image

and then open this vtk.js example and that’s fine

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?

I can make this GitHub - dmreagan/vtk-remote-render: A simple example of a ParaViewWeb remote renderer.

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.

Thanks, I will try node 16 next week.

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.)

vtk_vanilla_2.zip (156.1 KB)

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)

1: yarn add wslink or npm install wslink --save
2: *Add “setup” as follows

If you have any other questions, please add me on wechat

Thanks for your reply, I tried:
1: yarn add wslink or npm install wslink --save
2: *Add “setup” as follows

Still get a lot of run time error, but adding setup does remove one error. The other errors remains:

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.

Hope you can understand.