Closed omerenen closed 4 years ago
It's really hard to say what's going wrong here, but I can take a wild guess. Are you sure you're redrawing after the rotation?
It's really hard to say what's going wrong here, but I can take a wild guess. Are you sure you're redrawing after the rotation?
yes, I am
Perhaps you need to add an argument to QTimer
? https://doc.qt.io/qtforpython/PySide2/QtCore/QTimer.html
The examples show a parent element being passed. I wouldn't expect it to be garbage collected here but I've had some funky issues with that in the past with Qt and Python.
Perhaps you need to add an argument to
QTimer
? https://doc.qt.io/qtforpython/PySide2/QtCore/QTimer.htmlThe examples show a parent element being passed. I wouldn't expect it to be garbage collected here but I've had some funky issues with that in the past with Qt and Python.
I think, there is no problem when the py file is run because the STL file is rotating when it starts. I wonder why it does not continue to its rotating while the random numbers are being written on the console.
Actually, it is rotating the STL file. I realized it when I change the 3D view position. It creates a new stl view every one second, instead of rotating it.
Problem was solved.
Here is the solution:
`
self.m1 = mesh.Mesh.from_file('assets/uydu.stl')
self.timerSim = QtCore.QTimer()
self.timerSim.timeout.connect(self.rotator)
self.timerSim.start(1000)
def rotator (self):
self.m1.rotate([1, 0, 0], math.radians(pitch_array[-1]-pitch_array[-2]))
self.m1.rotate([0, 1, 0], math.radians(roll_array[-1]-roll_array[-2]))
self.m1.rotate([0, 0, 1], math.radians(yaw_array[-1]-yaw_array[-2]))
self.canvas.ax6.add_collection3d(mplot3d.art3d.Poly3DCollection(self.m1.vectors, edgecolor='k'))
self.canvas.ax6.auto_scale_xyz([-135, 135], [-135, 135], [-135, 135])
self.canvas.draw()
self.canvas.ax6.clear()
`
I can rotate stl file that I've imported. However, when I try to rotate it with QTimer by random number every second, it is not working. Although, random numbers are being written, It is just rotating when I run it, after that it is not. How can I do it?
Code is here :