当我使用平移时,three.js 透视相机除了位置之外还有哪些变化?或者我如何将它与 VTK 同步。旋转和缩放我同步只是给 VTK three.js 透视相机参数。这是python中Pan的一些代码:
def pan(self, start_x, start_y, dx, dy):
'''
Moving the model.
'''
end_x = start_x + dx
end_y = start_y + dy
dx = dx * self.world_coords_to_pixel_ratio
dy = dy * self.world_coords_to_pixel_ratio
matrix = self.renderer.GetActiveCamera().GetViewTransformMatrix()
inverted_matrix = vtkMatrix4x4()
dz = 0
matrix.Invert(matrix, inverted_matrix)
x, y, z = self.src_actor.GetPosition()
dx, dy, dz = self._multiply_vtkMatrix4x4_by_vector(inverted_matrix,
[dx, -dy, 0])
camera = self.renderer.GetActiveCamera()
self.src_actor.SetPosition(x + dx, y + dy, z + dz)
self.selection_actor.SetPosition(x + dx, y + dy, z + dz)
self.axes_and_bounding_box_actor.SetBounds(self.src_actor.GetBounds())
self.renderer.ResetCameraClippingRange()
在 three.js 我使用 TrackballControls