@inweb/viewer-visualize 26.10.1 → 26.10.3

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,11 @@
1
+ import { CameraMode, IComponent } from "@inweb/viewer-core";
2
+ import type { Viewer } from "../Viewer";
3
+ export declare class CameraComponent implements IComponent {
4
+ protected viewer: Viewer;
5
+ constructor(viewer: Viewer);
6
+ dispose(): void;
7
+ getCameraMode(view: any): CameraMode;
8
+ switchCameraMode(mode: CameraMode): void;
9
+ optionsChange: () => void;
10
+ geometryEnd: () => void;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-visualize",
3
- "version": "26.10.1",
3
+ "version": "26.10.3",
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.10.1",
33
- "@inweb/eventemitter2": "~26.10.1",
34
- "@inweb/markup": "~26.10.1",
35
- "@inweb/viewer-core": "~26.10.1"
32
+ "@inweb/client": "~26.10.3",
33
+ "@inweb/eventemitter2": "~26.10.3",
34
+ "@inweb/markup": "~26.10.3",
35
+ "@inweb/viewer-core": "~26.10.3"
36
36
  },
37
37
  "visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
38
38
  }
@@ -0,0 +1,78 @@
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
+ import { CameraMode, IComponent } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ export class CameraComponent implements IComponent {
28
+ protected viewer: Viewer;
29
+
30
+ constructor(viewer: Viewer) {
31
+ this.viewer = viewer;
32
+ this.viewer.addEventListener("databasechunk", this.geometryEnd);
33
+ this.viewer.addEventListener("clear", this.geometryEnd);
34
+ this.viewer.addEventListener("optionschange", this.optionsChange);
35
+ this.viewer.addEventListener("initialize", this.optionsChange);
36
+ }
37
+
38
+ dispose() {
39
+ this.viewer.removeEventListener("databasechunk", this.geometryEnd);
40
+ this.viewer.removeEventListener("clear", this.geometryEnd);
41
+ this.viewer.removeEventListener("optionschange", this.optionsChange);
42
+ this.viewer.removeEventListener("initialize", this.optionsChange);
43
+ }
44
+
45
+ getCameraMode(view: any): CameraMode {
46
+ return view.perspective ? "perspective" : "orthographic";
47
+ }
48
+
49
+ switchCameraMode(mode: CameraMode) {
50
+ if (!mode) return;
51
+
52
+ const activeView = this.viewer.visViewer().activeView;
53
+
54
+ if (mode !== this.getCameraMode(activeView)) {
55
+ activeView.perspective = !activeView.perspective;
56
+
57
+ this.viewer.update();
58
+ this.viewer.emitEvent({ type: "changecameramode", mode });
59
+ }
60
+
61
+ activeView.delete();
62
+ }
63
+
64
+ optionsChange = () => {
65
+ this.switchCameraMode(this.viewer.options.cameraMode);
66
+ };
67
+
68
+ geometryEnd = () => {
69
+ const activeView = this.viewer.visViewer().activeView;
70
+
71
+ const mode = this.getCameraMode(activeView);
72
+
73
+ this.viewer.options.cameraMode = mode;
74
+ this.viewer.emitEvent({ type: "changecameramode", mode });
75
+
76
+ activeView.delete();
77
+ };
78
+ }
@@ -23,6 +23,7 @@
23
23
 
24
24
  import { IComponentsRegistry, componentsRegistry } from "@inweb/viewer-core";
25
25
 
26
+ import { CameraComponent } from "./CameraComponent";
26
27
  import { RenderLoopComponent } from "./RenderLoopComponent";
27
28
  import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
28
29
  import { ZoomWheelComponent } from "./ZoomWheelComponent";
@@ -71,6 +72,7 @@ export const components: IComponentsRegistry = componentsRegistry("visualizejs")
71
72
 
72
73
  // build-in components
73
74
 
75
+ components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
74
76
  components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
75
77
  components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
76
78
  components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
@@ -246,8 +246,8 @@ export class OdaWalkDragger extends OdBaseDragger {
246
246
  move = Vector3d.createFromArray([0, currentDelta, 0]);
247
247
  }
248
248
 
249
- let newPos = pos.add(move);
250
- let newTarget = target.add(move);
249
+ const newPos = pos.add(move);
250
+ const newTarget = target.add(move);
251
251
 
252
252
  camera.setupCamera(newPos.toArray(), newTarget.toArray(), up.toArray());
253
253
  }