Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
How to rotate an object in VTK.js

I am trying to create a slider that rotates a 3D Volumes using the vtk.js api

I have already implemented sliders to move the object along the x,y,z axes, which looks like this:

  changePosition({ activeLayer, value, coord }) {
        const currentPosition = api.volumes[activeLayer].getPosition()

        switch (coord) {
          case coord = 'X':
            api.volumes[layer].setPosition(
              value,
              currentPosition[1],
              currentPosition[2])
            break;
          case coord = 'Y':
            api.volumes[layer].setPosition(
              currentPosition[0],
              value,
              currentPosition[2])
            break;
          case coord = 'Z':
            api.volumes[layer].setPosition(
              currentPosition[0],
              currentPosition[1],
              value)
            break;
          default:
            break;
        }
        
        const renderWindow = api.genericRenderWindow.getRenderWindow();
        renderWindow.render()
    },

VTK.js also offers another 2 methods similar to getPosition and setPosition called getOrientation and setOrientation

So one would assume this would work:

    changeOrientation({ activeLayer, value, coord }) {
        const currentOrientation = api.volumes[activeLayer].getOrientation()

        switch (coord) {
          case coord = 'X':
            api.volumes[layer].setOrientation(
              value,
              currentOrientation[1],
              currentOrientation[2])
            break;
          case coord = 'Y':
            api.volumes[layer].setOrientation(
              currentOrientation[0],
              value,
              currentOrientation[2])
            break;
          case coord = 'Z':
            api.volumes[layer].setOrientation(
              currentOrientation[0],
              currentOrientation[1],
              value)
            break;
          default:
            break;
        }

        const renderWindow = api.genericRenderWindow.getRenderWindow();
        renderWindow.render()
      })
    },

Yet getOrientation returns [undefined] (note the brackets), and setOrientation returns: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach')

I've been stuck on this for a few days now, thanks for any help it is much appreciated

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!