Skip to content

Can not stop the interactor event[Bug]  #2951

@MountainAndMorning

Description

@MountainAndMorning

Bug description

I am using vtk.js in vue 3 as below:

<script setup>
...

const container = ref(null)
onMounted(async ()=>{
    context.genericRenderWindow = vtkGenericRenderWindow.newInstance({container: toRaw(container.value)})
    const openglRenderWindow = context.genericRenderWindow.getApiSpecificRenderWindow()
    openglRenderWindow.buildPass(true)
    context.renderWindow = context.genericRenderWindow.getRenderWindow()
    context.renderer = context.genericRenderWindow.getRenderer()
    const camera = context.renderer.getActiveCamera()
    camera.setParallelProjection(true);

    context.istyle = vtkInteractorStyleTrackballCamera.newInstance();
    context.interactor = context.renderWindow.getInteractor()
    context.interactor.setInteractorStyle(context.istyle)

    const sphereSource = vtkSphereSource.newInstance({radius: 1.5});
    context.sphereSource = sphereSource
    const sphereMapper = vtkMapper.newInstance();
    context.sphereMapper = sphereMapper
    sphereMapper.setInputConnection(sphereSource.getOutputPort());
    const sphereActor = vtkActor.newInstance();
    sphereActor.getProperty().setColor(1.0, 0.0, 0.0)
    context.sphereActor = sphereActor
    sphereActor.setMapper(sphereMapper);
    context.renderer.addActor(sphereActor);

})

...
</script>


<template>
    <div :style="`width: 100%; height: 100%; border: #8E24AA 1px solid; position: relative; background-color: #000; overflow:hidden`">
        <div
            ref="container"
            :style="`width: 100%; height: 100%; `"
            @mousemove="onMouseMove"
            @mouseup="onMouseUp"
        >
            <svg
                :width="width"
                :height="height"
                :viewBox="viewBox"
                style="position: absolute; top: 0; left: 0;"
                @mousedown.stop="handleSVGEvent"
            >
           
            </svg>
        </div>
        
    </div>
</template>

Sometimes I need to interact with the svg element and don't want to interact with vtk.js, so I use the .stop event modifier. In an old vtk.js version "@kitware/vtk.js": "^21.4.1" this is OK. However, recently I update the vtk.js to @kitware/vtk.js": "^29.0.0" and I find the .stop modifier don't work. When I drag the element in svg the vtk.js camera is modified, too. I also try the .prevent and .self modifiers. In the handleSVGEvent function I also try the e.preventDefault() and e.stopPropagation() methods and nothing Works.

Steps to reproduce

Show in above.

Detailed Behavior

No response

Expected Behavior

Prevent the event in vtk.js.

Environment

  • vtk.js version: 29.0.0
  • OS: MacOS 14.0
  • electron: 24.4.0
"dependencies": {
    "@kitware/vtk.js": "^29.0.0",
    "@tensorflow/tfjs-node": "^4.11.0",
    "dicom-parser": "^1.8.21",
    "itk-image-io": "^1.0.0-b.18",
    "itk-wasm": "^1.0.0-b.18",
    "vue": "^3.2.47",
    "vuetify": "^3.3.3"
  },
"devDependencies": {
    "@mdi/js": "^7.2.96",
    "@vitejs/plugin-vue": "^4.1.0",
    "electron": "^24.4.0",
    "electron-builder": "^23.6.0",
    "typescript": "^5.0.2",
    "vite": "^4.3.2",
    "vite-plugin-electron": "^0.11.2",
    "vite-plugin-electron-renderer": "^0.14.5",
    "vite-plugin-static-copy": "^0.16.0",
    "vue-tsc": "^1.4.2"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions