Missing (not found) function/object

Dear All,

Where is defined “onRemoteMouseEvent” in

model.interactorStyle.onRemoteMouseEvent((e) => {

in

…node_modules\vtk.js\Sources\Rendering\Misc\RemoteView\index.js

Thanks,

Luís Gonçalves

const remoteView = vtkRemoteView.newInstance();
const interactorStyle = remoteView.getInteractorStyle();
interactorStyle.onRemoteMouseEvent((e) => {
   console.log('event', e);
});

But if you are wondering where the method gets created, it is happening here

Perhaps I am too green in Javascript.

Result of the following command in Windows:
findstr /s onRemote . >> …\lu99.txt


Sources/Rendering/Misc/RemoteView/index.js: model.interactorStyle.onRemoteMouseEvent((e) => {
Sources/Rendering/Misc/RemoteView/index.js: model.interactorStyle.onRemoteWheelEvent((e) => {
Sources/Rendering/Misc/RemoteView/index.js: model.interactorStyle.onRemoteGestureEvent((e) => {
dist/vtk-lite.js: …
dist/vtk-lite.js.map: …
dist/vtk.js: …
dist/vtk.js.map: …

I suppose that vtk-lite.js and vtk.js are the transpilation from the sources. I renamed vtk-lite.js and vtk.js and noticed that them are not needed for the example.

Usually, there is needed, at least, two instances of onRemoteMouseEvent in the sources. Is onRemoteMouseEvent part of Javascript and not VTK?

The example use the Sources rather than the transpiled version. In general, you should use those object by calling methods on them rather that changing the source code to change the defaults to match your needs. Especially since all that tuning can be achieved by method call inside your own code.

I achieved good results and I had to create a new rpc and then I had to change the Sources.

How to create a new rpc without changing the Sources? Perhaps in JavaScript in the code extending the Object.

You had used one for the wheel of the mouse but it was already created in the Sources. Initialized to “null” in the Sources.

Thanks,

Luís Gonçalves

just use the same rpc name as the one used in the source and don’t register the default mouse handler.

Or just call some method on the JS side to rename that rpc to match your name. Either way is fine, and won’t require you to change vtk.js source code.

Good evening (here),

I have this code in a handler in vtk_protocol.py. picker.Pick(x, y, 0, renderer) is returning non zero (Ok).
But “p” and “n” have empty values. 0<x<1 and 0<y<1.
How I put working this Picking inside a “rpc” handler? What is wrong in the code below.

        global picker
        picker = vtk.vtkVolumePicker()
        picker.EnableOn()
        picker.SetTolerance(1e-6)
        picker.SetVolumeOpacityIsovalue(0.1)
        x=event["x"]
        y=event["y"]
        picker.Pick(x, y, 0, renderer)
        self.p = picker.GetPickPosition()
        self.n = picker.GetPickNormal()

Thanks,

Luís Gonçalves

I bet the event[‘x’] (+y) are normalized and should be expanded like we do in the event handling method.

I already put (900x900 display window)

    x=event["x"]*900.0
    y=event["y"]*900.0

and GePickPosition stills do not return nothing.

I don’t know then?

The code above still not works (with the Pick). Must be some Interactor active? I do not use any interactor in the handler.

Without more information I can not help.

Even with your code, I still don’t know.

Get a working C++ or Python VTK code and then, move it to the web. It seems that you don’t have that part working.
The web does not seems to be in fault so far even if the path you took to get the event to the server side is sub-optimal, it is still working…

How can I disable the mouse cursor?

I tried HideCursor in the server side (all the places) without success and I do not find any place in client side to do that. I tried in “style.css” files of the examples with “cursor: none;”.
Must I change “vtk.js” code?

You don’t need to change anything in vtk.js (even for what you already did).
You can indeed use cursor: none in a css but you need to apply it correctly and to the correct DOM element.

Dear All,

I managed to make a successful handler for the key pressed like is done for the mouse. I had to copy createRemoteEvent() function to createRemoteEvent2() and code.

But I have the following problem. Appears the following message in the console of the Firefox when I start “localhost:1234” and not when I press a key.

How can I solve this problem?

Thanks,

Luís Gonçalves

This is an expected error when not using a launcher.

Are you saying that it is normal?

Can you please explain in more detail?