@inweb/viewer-three 26.9.6 → 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.
- package/dist/viewer-three.js +28 -1
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +28 -1
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/components/ResetComponent.d.ts +10 -0
- package/package.json +5 -5
- package/src/Viewer/commands/ResetView.ts +5 -1
- package/src/Viewer/components/ResetComponent.ts +64 -0
- package/src/Viewer/components/index.ts +2 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IComponent } from "@inweb/viewer-core";
|
|
2
|
+
import type { Viewer } from "../Viewer";
|
|
3
|
+
export declare class ResetComponent implements IComponent {
|
|
4
|
+
private viewer;
|
|
5
|
+
private savedCameraPosition;
|
|
6
|
+
constructor(viewer: Viewer);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
onDatabaseChunk: () => void;
|
|
9
|
+
resetCameraPosition(): void;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-three",
|
|
3
|
-
"version": "26.9.
|
|
3
|
+
"version": "26.9.7",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using Three.js",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"docs": "typedoc"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@inweb/client": "~26.9.
|
|
39
|
-
"@inweb/eventemitter2": "~26.9.
|
|
40
|
-
"@inweb/markup": "~26.9.
|
|
41
|
-
"@inweb/viewer-core": "~26.9.
|
|
38
|
+
"@inweb/client": "~26.9.7",
|
|
39
|
+
"@inweb/eventemitter2": "~26.9.7",
|
|
40
|
+
"@inweb/markup": "~26.9.7",
|
|
41
|
+
"@inweb/viewer-core": "~26.9.7"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/three": "^0.179.0",
|
|
@@ -22,8 +22,11 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import type { Viewer } from "../Viewer";
|
|
25
|
+
import type { ResetComponent } from "../components/ResetComponent";
|
|
25
26
|
|
|
26
27
|
export function resetView(viewer: Viewer): void {
|
|
28
|
+
const reset = viewer.getComponent("ResetComponent") as ResetComponent;
|
|
29
|
+
|
|
27
30
|
viewer.executeCommand("setActiveDragger");
|
|
28
31
|
viewer.executeCommand("clearSlices");
|
|
29
32
|
viewer.executeCommand("clearOverlay");
|
|
@@ -32,7 +35,8 @@ export function resetView(viewer: Viewer): void {
|
|
|
32
35
|
viewer.executeCommand("showAll");
|
|
33
36
|
viewer.executeCommand("explode", 0);
|
|
34
37
|
viewer.executeCommand("zoomToExtents", true);
|
|
35
|
-
|
|
38
|
+
|
|
39
|
+
reset.resetCameraPosition();
|
|
36
40
|
|
|
37
41
|
viewer.emit({ type: "resetview" });
|
|
38
42
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 } from "@inweb/viewer-core";
|
|
33
|
+
import type { Viewer } from "../Viewer";
|
|
34
|
+
import { Vector3 } from "three";
|
|
35
|
+
|
|
36
|
+
export class ResetComponent implements IComponent {
|
|
37
|
+
private viewer: Viewer;
|
|
38
|
+
private savedCameraPosition: any = null;
|
|
39
|
+
|
|
40
|
+
constructor(viewer: Viewer) {
|
|
41
|
+
this.viewer = viewer;
|
|
42
|
+
this.viewer.addEventListener("databasechunk", this.onDatabaseChunk);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
dispose() {
|
|
46
|
+
this.viewer.removeEventListener("databasechunk", this.onDatabaseChunk);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onDatabaseChunk = () => {
|
|
50
|
+
this.savedCameraPosition = {
|
|
51
|
+
position: this.viewer.camera.position.clone(),
|
|
52
|
+
up: this.viewer.camera.up.clone(),
|
|
53
|
+
direction: this.viewer.camera.getWorldDirection(new Vector3()),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
resetCameraPosition() {
|
|
58
|
+
if (this.savedCameraPosition) {
|
|
59
|
+
this.viewer.camera.position.copy(this.savedCameraPosition.position);
|
|
60
|
+
this.viewer.camera.up.copy(this.savedCameraPosition.up);
|
|
61
|
+
this.viewer.camera.lookAt(this.savedCameraPosition.position.clone().add(this.savedCameraPosition.direction));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -32,6 +32,7 @@ import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
|
|
|
32
32
|
import { HighlighterComponent } from "./HighlighterComponent";
|
|
33
33
|
import { SelectionComponent } from "./SelectionComponent";
|
|
34
34
|
import { WCSHelperComponent } from "./WCSHelperComponent";
|
|
35
|
+
import { ResetComponent } from "./ResetComponent";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Viewer components registry. Use this registry to register custom components.
|
|
@@ -84,3 +85,4 @@ components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopCo
|
|
|
84
85
|
components.registerComponent("HighlighterComponent", (viewer) => new HighlighterComponent(viewer));
|
|
85
86
|
components.registerComponent("SelectionComponent", (viewer) => new SelectionComponent(viewer));
|
|
86
87
|
components.registerComponent("WCSHelperComponent", (viewer) => new WCSHelperComponent(viewer));
|
|
88
|
+
components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
|