@inweb/client 25.2.5 → 25.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1082,8 +1082,10 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
1082
1082
  *
1083
1083
  * @param viewpoint - Viewpoint.
1084
1084
  */
1085
- drawViewpoint(viewpoint: any): void {
1086
- this.markup.drawViewpoint(viewpoint);
1085
+ drawViewpoint(viewpoint: object): void {
1086
+ this.setOrthogonalCameraSettings(viewpoint);
1087
+ this.setClippingPlanes(viewpoint);
1088
+ this.markup.setViewpoint(viewpoint);
1087
1089
  }
1088
1090
 
1089
1091
  /**
@@ -1092,10 +1094,90 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
1092
1094
  * {@link File#saveViewpoint | File.saveViewpoint()}.
1093
1095
  */
1094
1096
  createViewpoint(): object {
1095
- const vp = this.markup.createViewpoint();
1097
+ const vp = this.markup.getViewpoint();
1098
+ vp.orthogonal_camera = this.getOrthogonalCameraSettings();
1099
+ vp.clipping_planes = this.getClippingPlanes();
1100
+
1096
1101
  return vp;
1097
1102
  }
1098
1103
 
1104
+ private getPoint3dFromArray(array) {
1105
+ return { x: array[0], y: array[1], z: array[2] };
1106
+ }
1107
+
1108
+ private getLogicalPoint3dAsArray(point3d) {
1109
+ return [point3d.x, point3d.y, point3d.z];
1110
+ }
1111
+
1112
+ private getOrthogonalCameraSettings(): object {
1113
+ const visViewer = this.visViewer();
1114
+ const activeView = visViewer.activeView;
1115
+
1116
+ return {
1117
+ view_point: this.getPoint3dFromArray(activeView.viewPosition),
1118
+ direction: this.getPoint3dFromArray(activeView.viewTarget),
1119
+ up_vector: this.getPoint3dFromArray(activeView.upVector),
1120
+ field_width: activeView.viewFieldWidth,
1121
+ field_height: activeView.viewFieldHeight,
1122
+ };
1123
+ }
1124
+
1125
+ private setOrthogonalCameraSettings(viewpoint) {
1126
+ const visViewer = this.visViewer();
1127
+ const activeView = visViewer.activeView;
1128
+
1129
+ this.resetActiveDragger();
1130
+ this.clearSlices();
1131
+ this.clearOverlay();
1132
+
1133
+ if (viewpoint.orthogonal_camera) {
1134
+ activeView.setView(
1135
+ this.getLogicalPoint3dAsArray(viewpoint.orthogonal_camera.view_point),
1136
+ this.getLogicalPoint3dAsArray(viewpoint.orthogonal_camera.direction),
1137
+ this.getLogicalPoint3dAsArray(viewpoint.orthogonal_camera.up_vector),
1138
+ viewpoint.orthogonal_camera.field_width,
1139
+ viewpoint.orthogonal_camera.field_height,
1140
+ true
1141
+ );
1142
+ }
1143
+
1144
+ this.syncOverlay();
1145
+ }
1146
+
1147
+ private getClippingPlanes(): object {
1148
+ const visViewer = this.visViewer();
1149
+ const activeView = visViewer.activeView;
1150
+
1151
+ const clipping_planes = [];
1152
+ for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
1153
+ const cuttingPlane = activeView.getCuttingPlane(i);
1154
+
1155
+ const plane = {
1156
+ location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
1157
+ direction: this.getPoint3dFromArray(cuttingPlane.normal()),
1158
+ };
1159
+
1160
+ clipping_planes.push(plane);
1161
+ }
1162
+
1163
+ return clipping_planes;
1164
+ }
1165
+
1166
+ private setClippingPlanes(viewpoint) {
1167
+ if (viewpoint.clipping_planes) {
1168
+ const visViewer = this.visViewer();
1169
+ const activeView = visViewer.activeView;
1170
+
1171
+ for (const plane of viewpoint.clipping_planes) {
1172
+ const cuttingPlane = new (this.visLib().OdTvPlane)();
1173
+ cuttingPlane.set(this.getLogicalPoint3dAsArray(plane.location), this.getLogicalPoint3dAsArray(plane.direction));
1174
+
1175
+ activeView.addCuttingPlane(cuttingPlane);
1176
+ activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
1177
+ }
1178
+ }
1179
+ }
1180
+
1099
1181
  /**
1100
1182
  * Executes the command denoted by the given command identifier.
1101
1183
  *