@inweb/viewer-visualize 26.9.5 → 26.9.7

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.
@@ -0,0 +1,18 @@
1
+ import { IComponent, IOrthogonalCamera, IPoint } from "@inweb/viewer-core";
2
+ import type { Viewer } from "../Viewer";
3
+ export declare class ResetComponent implements IComponent {
4
+ private viewer;
5
+ private savedCameraSettings;
6
+ constructor(viewer: Viewer);
7
+ dispose(): void;
8
+ onDatabaseChunk: () => void;
9
+ resetCameraPosition(): void;
10
+ getOrthogonalCameraSettings(): IOrthogonalCamera;
11
+ setOrthogonalCameraSettings(settings: IOrthogonalCamera): void;
12
+ getPoint3dFromArray(array: number[]): {
13
+ x: number;
14
+ y: number;
15
+ z: number;
16
+ };
17
+ getLogicalPoint3dAsArray(point3d: IPoint): number[];
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "26.9.5",
3
+ "version": "26.9.7",
4
4
  "description": "JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -29,10 +29,10 @@
29
29
  "docs": "typedoc"
30
30
  },
31
31
  "dependencies": {
32
- "@inweb/client": "~26.9.5",
33
- "@inweb/eventemitter2": "~26.9.5",
34
- "@inweb/markup": "~26.9.5",
35
- "@inweb/viewer-core": "~26.9.5"
32
+ "@inweb/client": "~26.9.7",
33
+ "@inweb/eventemitter2": "~26.9.7",
34
+ "@inweb/markup": "~26.9.7",
35
+ "@inweb/viewer-core": "~26.9.7"
36
36
  },
37
37
  "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -0,0 +1,97 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ // ===================== AI-CODE-FILE ======================
25
+ // Source: Claude Sonnet 4
26
+ // Date: 2025-09-10
27
+ // Reviewer: vitaly.ivanov@opendesign.com
28
+ // Issue: CLOUD-5835
29
+ // Notes: Originally AI-generated, modified manually 2025-09-11
30
+ // =========================================================
31
+
32
+ import { IComponent, IOrthogonalCamera, IPoint } from "@inweb/viewer-core";
33
+ import type { Viewer } from "../Viewer";
34
+
35
+ export class ResetComponent implements IComponent {
36
+ private viewer: Viewer;
37
+ private savedCameraSettings: IOrthogonalCamera | null = null;
38
+
39
+ constructor(viewer: Viewer) {
40
+ this.viewer = viewer;
41
+ this.viewer.addEventListener("databasechunk", this.onDatabaseChunk);
42
+ }
43
+
44
+ dispose() {
45
+ this.viewer.removeEventListener("databasechunk", this.onDatabaseChunk);
46
+ }
47
+
48
+ onDatabaseChunk = () => {
49
+ if (!this.viewer.visualizeJs) return;
50
+
51
+ this.savedCameraSettings = this.getOrthogonalCameraSettings();
52
+ };
53
+
54
+ resetCameraPosition() {
55
+ if (this.savedCameraSettings && this.viewer.visualizeJs) {
56
+ this.setOrthogonalCameraSettings(this.savedCameraSettings);
57
+ }
58
+ }
59
+
60
+ getOrthogonalCameraSettings(): IOrthogonalCamera {
61
+ const visViewer = this.viewer.visViewer();
62
+ const activeView = visViewer.activeView;
63
+
64
+ return {
65
+ view_point: this.getPoint3dFromArray(activeView.viewPosition),
66
+ direction: this.getPoint3dFromArray(activeView.viewTarget),
67
+ up_vector: this.getPoint3dFromArray(activeView.upVector),
68
+ field_width: activeView.viewFieldWidth,
69
+ field_height: activeView.viewFieldHeight,
70
+ view_to_world_scale: 1,
71
+ };
72
+ }
73
+
74
+ setOrthogonalCameraSettings(settings: IOrthogonalCamera) {
75
+ const visViewer = this.viewer.visViewer();
76
+ const activeView = visViewer.activeView;
77
+
78
+ if (settings) {
79
+ activeView.setView(
80
+ this.getLogicalPoint3dAsArray(settings.view_point),
81
+ this.getLogicalPoint3dAsArray(settings.direction),
82
+ this.getLogicalPoint3dAsArray(settings.up_vector),
83
+ settings.field_width,
84
+ settings.field_height,
85
+ true
86
+ );
87
+ }
88
+ }
89
+
90
+ getPoint3dFromArray(array: number[]) {
91
+ return { x: array[0], y: array[1], z: array[2] };
92
+ }
93
+
94
+ getLogicalPoint3dAsArray(point3d: IPoint) {
95
+ return [point3d.x, point3d.y, point3d.z];
96
+ }
97
+ }
@@ -27,6 +27,7 @@ import { RenderLoopComponent } from "./RenderLoopComponent";
27
27
  import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
28
28
  import { ZoomWheelComponent } from "./ZoomWheelComponent";
29
29
  import { GestureManagerComponent } from "./GestureManagerComponent";
30
+ import { ResetComponent } from "./ResetComponent";
30
31
 
31
32
  /**
32
33
  * Viewer components registry. Use this registry to register custom components.
@@ -74,3 +75,4 @@ components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanv
74
75
  components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
75
76
  components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
76
77
  components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
78
+ components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));