@inweb/viewer-three 27.1.4 → 27.1.5

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,9 @@
1
+ import { IComponent } from "@inweb/viewer-core";
2
+ import type { Viewer } from "../Viewer";
3
+ export declare class CanvasRemoveComponent implements IComponent {
4
+ protected viewer: Viewer;
5
+ protected mutationObserver: MutationObserver;
6
+ constructor(viewer: Viewer);
7
+ dispose(): void;
8
+ cleanupViewer: (mutations: MutationRecord[]) => void;
9
+ }
@@ -1,6 +1,6 @@
1
1
  import { IComponent } from "@inweb/viewer-core";
2
2
  import type { Viewer } from "../Viewer";
3
- export declare class ResizeCanvasComponent implements IComponent {
3
+ export declare class CanvasResizeComponent implements IComponent {
4
4
  protected viewer: Viewer;
5
5
  protected resizeObserver: ResizeObserver;
6
6
  constructor(viewer: Viewer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/viewer-three",
3
- "version": "27.1.4",
3
+ "version": "27.1.5",
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": "~27.1.4",
39
- "@inweb/eventemitter2": "~27.1.4",
40
- "@inweb/markup": "~27.1.4",
41
- "@inweb/viewer-core": "~27.1.4"
38
+ "@inweb/client": "~27.1.5",
39
+ "@inweb/eventemitter2": "~27.1.5",
40
+ "@inweb/markup": "~27.1.5",
41
+ "@inweb/viewer-core": "~27.1.5"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@streamparser/json": "^0.0.22",
@@ -681,7 +681,7 @@ export class Viewer
681
681
  camera.bottom = -orthogonal_camera.field_height / 2;
682
682
  camera.left = camera.bottom * aspectRatio;
683
683
  camera.right = camera.top * aspectRatio;
684
- camera.near = 0;
684
+ camera.near = -extentsSize * 1000;
685
685
  camera.far = extentsSize * 1000;
686
686
  camera.zoom = orthogonal_camera.view_to_world_scale;
687
687
  camera.updateProjectionMatrix();
@@ -59,7 +59,7 @@ export class CameraComponent implements IComponent {
59
59
  if (camera.isOrthographicCamera) {
60
60
  camera.left = camera.bottom * aspectRatio;
61
61
  camera.right = camera.top * aspectRatio;
62
- camera.near = 0;
62
+ camera.near = -extentsSize * 1000;
63
63
  camera.far = extentsSize * 1000;
64
64
  }
65
65
 
@@ -0,0 +1,55 @@
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 { IComponent } from "@inweb/viewer-core";
25
+ import type { Viewer } from "../Viewer";
26
+
27
+ export class CanvasRemoveComponent implements IComponent {
28
+ protected viewer: Viewer;
29
+ protected mutationObserver: MutationObserver;
30
+
31
+ constructor(viewer: Viewer) {
32
+ this.viewer = viewer;
33
+ this.mutationObserver = new MutationObserver(this.cleanupViewer);
34
+ this.mutationObserver.observe(document, { childList: true, subtree: true });
35
+ }
36
+
37
+ dispose() {
38
+ this.mutationObserver.disconnect();
39
+ this.mutationObserver = undefined;
40
+ }
41
+
42
+ cleanupViewer = (mutations: MutationRecord[]) => {
43
+ for (const mutation of mutations) {
44
+ if (mutation.type === "childList" && mutation.removedNodes.length > 0) {
45
+ for (const node of mutation.removedNodes) {
46
+ if (node === this.viewer.canvas || node.contains(this.viewer.canvas)) {
47
+ this.viewer.emitEvent({ type: "canvasremoved" });
48
+ this.viewer.dispose();
49
+ return;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ };
55
+ }
@@ -24,7 +24,7 @@
24
24
  import { IComponent } from "@inweb/viewer-core";
25
25
  import type { Viewer } from "../Viewer";
26
26
 
27
- export class ResizeCanvasComponent implements IComponent {
27
+ export class CanvasResizeComponent implements IComponent {
28
28
  protected viewer: Viewer;
29
29
  protected resizeObserver: ResizeObserver;
30
30
 
@@ -28,8 +28,9 @@ import { CameraComponent } from "./CameraComponent";
28
28
  import { ExtentsComponent } from "./ExtentsComponent";
29
29
  import { LightComponent } from "./LightComponent";
30
30
  import { InfoComponent } from "./InfoComponent";
31
+ import { CanvasResizeComponent } from "./CanvasResizeComponent";
32
+ import { CanvasRemoveComponent } from "./CanvasRemoveComponent";
31
33
  import { RenderLoopComponent } from "./RenderLoopComponent";
32
- import { ResizeCanvasComponent } from "./ResizeCanvasComponent";
33
34
  import { HighlighterComponent } from "./HighlighterComponent";
34
35
  import { SelectionComponent } from "./SelectionComponent";
35
36
  import { WCSHelperComponent } from "./WCSHelperComponent";
@@ -82,7 +83,8 @@ components.registerComponent("CameraComponent", (viewer) => new CameraComponent(
82
83
  components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
83
84
  components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
84
85
  components.registerComponent("InfoComponent", (viewer) => new InfoComponent(viewer));
85
- components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
86
+ components.registerComponent("CanvasResizeComponent", (viewer) => new CanvasResizeComponent(viewer));
87
+ components.registerComponent("CanvasRemoveComponent", (viewer) => new CanvasRemoveComponent(viewer));
86
88
  components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
87
89
  components.registerComponent("HighlighterComponent", (viewer) => new HighlighterComponent(viewer));
88
90
  components.registerComponent("SelectionComponent", (viewer) => new SelectionComponent(viewer));