|
@@ -20,6 +20,9 @@ import vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource';
|
|
|
import vtkLineSource from '@kitware/vtk.js/Filters/Sources/LineSource';
|
|
|
import vtkSphereMapper from '@kitware/vtk.js/Rendering/Core/SphereMapper';
|
|
|
|
|
|
+
|
|
|
+import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
|
+
|
|
|
export class VtkModel {
|
|
|
constructor() {
|
|
|
|
|
@@ -62,6 +65,8 @@ export class VtkModel {
|
|
|
this.actor2.getProperty().setPointSize(2);
|
|
|
this.actor2.setMapper(this.mapper);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//选取
|
|
|
this.lastActor = null;
|
|
|
this.nodeActors = []; //节点actor 数据
|
|
@@ -182,7 +187,62 @@ export class VtkModel {
|
|
|
|
|
|
this.modelShow();
|
|
|
this.renderer.resetCamera();
|
|
|
+ const cam =this.renderer.getActiveCamera();
|
|
|
+
|
|
|
+ // const cam = vtkCamera.newInstance();
|
|
|
+ // const cam =this.renderer.getActiveCamera();
|
|
|
+ // this.renderer.setActiveCamera(cam);
|
|
|
+ // cam.setFocalPoint(0, 0, 0);
|
|
|
+ // cam.setPosition(0, 0, 10);
|
|
|
+ // cam.setClippingRange(0.1, 2.0);
|
|
|
+ // cam.setViewAngle(300);
|
|
|
+ // console.log(
|
|
|
+ // cam.getPosition(),//摄像头位置
|
|
|
+ // cam.getViewAngle(),//相机视角 默认30
|
|
|
+ // cam.getFocalPoint(),//相机焦点
|
|
|
+ // cam.getViewUp(),//相机方向
|
|
|
+ // );
|
|
|
+
|
|
|
+
|
|
|
+ // position?: number[]; //摄像头位置
|
|
|
+ // focalPoint?: number[]; //相机焦点
|
|
|
+ // viewUp?: number[];//相机方向
|
|
|
+ // directionOfProjection?: number[]; //相机到焦点的方向
|
|
|
+ // parallelProjection?: boolean;//透视 平行
|
|
|
+ // useHorizontalViewAngle?: boolean;//水平视角使用
|
|
|
+ // viewAngle?: number;//相机视角
|
|
|
+ // parallelScale?: number;//平行位置投影比例
|
|
|
+ // clippingRange?: number[];//近远平面
|
|
|
+ // windowCenter?: number[];//窗口中心位置 范围 ([-1,+1],[-1,+1])
|
|
|
+ // viewPlaneNormal?: number[];//投影平面法线 (投影反方向)
|
|
|
+ // useOffAxisProjection?: boolean;//离轴投影
|
|
|
+ // screenBottomLeft?: number[];//左上角的点
|
|
|
+ // screenBottomRight?: number[];//右上角的点
|
|
|
+ // screenTopRight?: number[];//右上角的点 用于离轴投影
|
|
|
+ // freezeFocalPoint?: boolean;
|
|
|
+ // physicalTranslation?: number[];//物理翻译
|
|
|
+ // physicalScale?: number;//物理尺度
|
|
|
+ // physicalViewUp?: number[];//物理方向
|
|
|
+ // physicalViewNorth?: number[];//物理北
|
|
|
+ console.log("摄像头位置",cam.getPosition());
|
|
|
+ console.log("透视或平行相机",cam.getParallelProjection());
|
|
|
+ // cam.setParallelProjection(true);
|
|
|
+ // console.log("透视或平行相机",cam.getParallelProjection());
|
|
|
+ console.log("水平视角使用",cam.getUseHorizontalViewAngle());
|
|
|
+ cam.setUseHorizontalViewAngle(true);
|
|
|
+ console.log("平行位置投影比例",cam.getParallelScale());
|
|
|
+ cam.setParallelScale(600);
|
|
|
+ console.log("窗口中心位置",cam.getWindowCenter());
|
|
|
+ // cam.setWindowCenter([1,-1]);
|
|
|
+ // cam.setViewAngle(15);
|
|
|
+ console.log("相机视角",cam.getViewAngle());
|
|
|
+ console.log("相机焦点",cam.getFocalPoint());
|
|
|
+ // cam.setViewUp([-1,0,0]);
|
|
|
+ console.log("相机方向",cam.getViewUp());
|
|
|
+ // cam.setClippingRange(9241.491986233214,9300.53967078369);
|
|
|
+ // console.log("近远平面",cam.getClippingRange());
|
|
|
this.renderWindow.render();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
modelClearShow() {
|
|
@@ -316,7 +376,13 @@ function pickOnMouseEvent(event) {
|
|
|
}
|
|
|
const [x, y] = eventToWindowXY(event);
|
|
|
// console.log([x,y]);
|
|
|
- // vtkmodel.pointerActor.setVisibility(false);
|
|
|
+ // if(!vtkmodel.getPointData){//没有数据
|
|
|
+ // return ;
|
|
|
+ // }
|
|
|
+ // console.log(vtkmodel.hardwareSelector.getPointData());
|
|
|
+ // if(!vtkmodel.renderer.getActors().size==0){
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
vtkmodel.hardwareSelector
|
|
|
.getSourceDataAsync(vtkmodel.renderer, x, y, x, y)
|
|
|
.then((result) => {
|