@inweb/viewer-visualize 25.3.13

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.
Files changed (164) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +63 -0
  3. package/dist/viewer-visualize.js +16982 -0
  4. package/dist/viewer-visualize.js.map +1 -0
  5. package/dist/viewer-visualize.min.js +1 -0
  6. package/dist/viewer-visualize.module.js +5267 -0
  7. package/dist/viewer-visualize.module.js.map +1 -0
  8. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +1 -0
  9. package/lib/Viewer/Commands/ClearMarkup.d.ts +1 -0
  10. package/lib/Viewer/Commands/ClearSlices.d.ts +1 -0
  11. package/lib/Viewer/Commands/CreatePreview.d.ts +1 -0
  12. package/lib/Viewer/Commands/Explode.d.ts +1 -0
  13. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +1 -0
  14. package/lib/Viewer/Commands/GetModels.d.ts +1 -0
  15. package/lib/Viewer/Commands/GetSelected.d.ts +1 -0
  16. package/lib/Viewer/Commands/HideSelected.d.ts +1 -0
  17. package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -0
  18. package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -0
  19. package/lib/Viewer/Commands/ResetView.d.ts +1 -0
  20. package/lib/Viewer/Commands/SelectModel.d.ts +1 -0
  21. package/lib/Viewer/Commands/SetActiveDragger.d.ts +1 -0
  22. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +1 -0
  23. package/lib/Viewer/Commands/SetMarkupColor.d.ts +1 -0
  24. package/lib/Viewer/Commands/SetSelected.d.ts +1 -0
  25. package/lib/Viewer/Commands/ShowAll.d.ts +1 -0
  26. package/lib/Viewer/Commands/Unselect.d.ts +1 -0
  27. package/lib/Viewer/Commands/ZoomToExtents.d.ts +1 -0
  28. package/lib/Viewer/Commands/ZoomToObjects.d.ts +1 -0
  29. package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -0
  30. package/lib/Viewer/Commands/index.d.ts +22 -0
  31. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +21 -0
  32. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +17 -0
  33. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +7 -0
  34. package/lib/Viewer/Draggers/Common/Geometry.d.ts +114 -0
  35. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +40 -0
  36. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +53 -0
  37. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +29 -0
  38. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +30 -0
  39. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +19 -0
  40. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +23 -0
  41. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +26 -0
  42. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +7 -0
  43. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +7 -0
  44. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +7 -0
  45. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +14 -0
  46. package/lib/Viewer/Draggers/OdPanDragger.d.ts +11 -0
  47. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +11 -0
  48. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +10 -0
  49. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +18 -0
  50. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +13 -0
  51. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +14 -0
  52. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +15 -0
  53. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +29 -0
  54. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +18 -0
  55. package/lib/Viewer/Loaders/BaseLoader.d.ts +10 -0
  56. package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
  57. package/lib/Viewer/Loaders/TCSLoader.d.ts +4 -0
  58. package/lib/Viewer/Loaders/UpdaterController.d.ts +14 -0
  59. package/lib/Viewer/Loaders/VsfXLoader.d.ts +4 -0
  60. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +4 -0
  61. package/lib/Viewer/Loaders/VsfXStreamingLoader.d.ts +4 -0
  62. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +21 -0
  63. package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +14 -0
  64. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +4 -0
  65. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +14 -0
  66. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +14 -0
  67. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +12 -0
  68. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +11 -0
  69. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +14 -0
  70. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +12 -0
  71. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +46 -0
  72. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaCloud.d.ts +35 -0
  73. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
  74. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
  75. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +36 -0
  76. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
  77. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
  78. package/lib/Viewer/Markup/IMarkup.d.ts +39 -0
  79. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +70 -0
  80. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +18 -0
  81. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
  82. package/lib/Viewer/Markup/MarkupFactory.d.ts +6 -0
  83. package/lib/Viewer/Viewer.d.ts +346 -0
  84. package/lib/Viewer/utils.d.ts +3 -0
  85. package/lib/index.d.ts +3 -0
  86. package/package.json +44 -0
  87. package/src/Viewer/Commands/ApplyModelTransform.ts +69 -0
  88. package/src/Viewer/Commands/ClearMarkup.ts +28 -0
  89. package/src/Viewer/Commands/ClearSlices.ts +27 -0
  90. package/src/Viewer/Commands/CreatePreview.ts +33 -0
  91. package/src/Viewer/Commands/Explode.ts +38 -0
  92. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
  93. package/src/Viewer/Commands/GetModels.ts +43 -0
  94. package/src/Viewer/Commands/GetSelected.ts +58 -0
  95. package/src/Viewer/Commands/HideSelected.ts +37 -0
  96. package/src/Viewer/Commands/IsolateSelected.ts +37 -0
  97. package/src/Viewer/Commands/RegenerateAll.ts +37 -0
  98. package/src/Viewer/Commands/ResetView.ts +43 -0
  99. package/src/Viewer/Commands/SelectModel.ts +52 -0
  100. package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
  101. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
  102. package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
  103. package/src/Viewer/Commands/SetSelected.ts +47 -0
  104. package/src/Viewer/Commands/ShowAll.ts +37 -0
  105. package/src/Viewer/Commands/Unselect.ts +37 -0
  106. package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
  107. package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
  108. package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
  109. package/src/Viewer/Commands/index.ts +45 -0
  110. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
  111. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
  112. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
  113. package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
  114. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
  115. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
  116. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
  117. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
  118. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
  119. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
  120. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
  121. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
  122. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
  123. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
  124. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
  125. package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
  126. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
  127. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
  128. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
  129. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
  130. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
  131. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
  132. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
  133. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
  134. package/src/Viewer/Loaders/BaseLoader.ts +40 -0
  135. package/src/Viewer/Loaders/LoaderFactory.ts +48 -0
  136. package/src/Viewer/Loaders/TCSLoader.ts +82 -0
  137. package/src/Viewer/Loaders/UpdaterController.ts +36 -0
  138. package/src/Viewer/Loaders/VsfXLoader.ts +65 -0
  139. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
  140. package/src/Viewer/Loaders/VsfXStreamingLoader.ts +87 -0
  141. package/src/Viewer/Markup/Api/IMarkupArrow.ts +12 -0
  142. package/src/Viewer/Markup/Api/IMarkupCloud.ts +15 -0
  143. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
  144. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
  145. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
  146. package/src/Viewer/Markup/Api/IMarkupLine.ts +13 -0
  147. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
  148. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
  149. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
  150. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +117 -0
  151. package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +208 -0
  152. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +118 -0
  153. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +123 -0
  154. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +131 -0
  155. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +119 -0
  156. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +110 -0
  157. package/src/Viewer/Markup/IMarkup.ts +42 -0
  158. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +1144 -0
  159. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
  160. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +229 -0
  161. package/src/Viewer/Markup/MarkupFactory.ts +32 -0
  162. package/src/Viewer/Viewer.ts +1183 -0
  163. package/src/Viewer/utils.ts +74 -0
  164. package/src/index.ts +26 -0
@@ -0,0 +1,33 @@
1
+ import { IViewpoint } from "@inweb/viewer-core";
2
+ import { IMarkup } from "../../IMarkup";
3
+ import { Viewer } from "../../../Viewer";
4
+ import { OdBaseDragger } from "../../../Draggers/Common/OdBaseDragger";
5
+ import { IMarkupObject } from "../../Api/IMarkupObject";
6
+ export declare class VisualizeMarkup implements IMarkup {
7
+ private _viewer;
8
+ protected _markupColor: {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ };
13
+ lineWidth: number;
14
+ initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents: string[]): void;
15
+ dispose(): void;
16
+ getDraggers(): Map<string, typeof OdBaseDragger>;
17
+ clearOverlay(): void;
18
+ getMarkupColor(): {
19
+ r: number;
20
+ g: number;
21
+ b: number;
22
+ };
23
+ setMarkupColor(r: number, g: number, b: number): void;
24
+ colorizeAllMarkup(r?: number, g?: number, b?: number): void;
25
+ setViewpoint(viewpoint: IViewpoint): void;
26
+ getViewpoint(): IViewpoint;
27
+ getLayer(): any;
28
+ createObject(type: string, params: any): IMarkupObject;
29
+ getObjects(): IMarkupObject[];
30
+ getSelectedObjects(): IMarkupObject[];
31
+ selectObjects(objects: IMarkupObject[]): void;
32
+ clearSelected(): void;
33
+ }
@@ -0,0 +1,6 @@
1
+ import { IMarkup, MarkupType } from "./IMarkup";
2
+ export declare class MarkupFactory {
3
+ static createMarkup(markupType: MarkupType): IMarkup;
4
+ private static createKonva;
5
+ private static createVisualize;
6
+ }
@@ -0,0 +1,346 @@
1
+ import { EventEmitter2 } from "@inweb/eventemitter2";
2
+ import { Assembly, Client, File, Model } from "@inweb/client";
3
+ import { IViewpoint, IViewer, Options, OptionsData, OptionsEventMap, ViewerEventMap } from "@inweb/viewer-core";
4
+ import { OdBaseDragger } from "./Draggers/Common/OdBaseDragger";
5
+ import { IMarkup, MarkupType } from "./Markup/IMarkup";
6
+ /**
7
+ * The `Client.js` library class that provides methods to integrate with the
8
+ * [VisualizeJS](https://cloud.opendesign.com/docs/index.html#/visualizejs) library.
9
+ */
10
+ export declare class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> implements IViewer {
11
+ private _activeDragger;
12
+ private _zoomWheelDragger;
13
+ private _gestureManager;
14
+ private _enableAutoUpdate;
15
+ private _isNeedRender;
16
+ private _isRunAsyncUpdate;
17
+ private _renderTime;
18
+ protected _options: Options;
19
+ protected _visualizeJsUrl: string;
20
+ protected _abortControllerForReferences: AbortController | undefined;
21
+ private canvaseventlistener;
22
+ draggerFactory: Map<string, typeof OdBaseDragger>;
23
+ canvasEvents: string[];
24
+ private frameId;
25
+ private _resizeObserver;
26
+ canvas: HTMLCanvasElement | undefined;
27
+ markup: IMarkup;
28
+ visualizeJs: any;
29
+ _abortController: AbortController | undefined;
30
+ _abortControllerForRequestMap: Map<string, AbortController> | undefined;
31
+ client: Client;
32
+ /**
33
+ * @param client - The `Client` instance that provides access to a server. Do not specify
34
+ * `Client` if you need a standalone viewer instance without access to server models.
35
+ * @param params - An object containing viewer configuration parameters.
36
+ * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
37
+ * library instance, or leave it undefined or blank to use the default URL defined by
38
+ * `Client.js` you are using.
39
+ *
40
+ * _Note: Your own `VisualizeJS` library version must match the version of the `Client.js`
41
+ * you are using._
42
+ * @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
43
+ * the auto-update is disabled, you need to update the `VisualizeJS` viewer and the active
44
+ * dragger manually using the `update` event. Default is `true`.
45
+ */
46
+ constructor(client?: Client, params?: {
47
+ visualizeJsUrl?: string;
48
+ enableAutoUpdate?: boolean;
49
+ markupType?: MarkupType;
50
+ });
51
+ /**
52
+ * `VisualizeJS` parameters.
53
+ */
54
+ get options(): Options;
55
+ /**
56
+ * `VisualizeJS` library URL. Use {@link Viewer#configure | configure()} to change library URL.
57
+ *
58
+ * @readonly
59
+ */
60
+ get visualizeJsUrl(): string;
61
+ /**
62
+ * Change the viewer configuration parameters.
63
+ *
64
+ * @param params - An object containing new configuration parameters.
65
+ * @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
66
+ * library instance or leave it blank to use the default URL defined by `Client.js`.
67
+ */
68
+ configure(params: {
69
+ visualizeJsUrl?: string;
70
+ }): this;
71
+ /**
72
+ * A [Viewer]{@link Viewer} event measuring progress of loading a `VisualizeJS` library.
73
+ *
74
+ * @property {string} type - `visualizeprogress`
75
+ * @property {number} loaded - A 64-bit unsigned integer value indicating the amount of work
76
+ * already performed by the underlying process. The ratio of work done can be calculated by
77
+ * dividing total by the value of this property.
78
+ * @property {number} total - A 64-bit unsigned integer representing the total amount of work
79
+ * that the underlying process is in the progress of performing.
80
+ * @event visualizeprogress
81
+ */
82
+ /**
83
+ * Load `VisualizeJS` module and initialize it with the specified canvas. Call
84
+ * {@link Viewer#dispose | dispose()} to release allocated resources.
85
+ *
86
+ * @async
87
+ * @param canvas - HTML `<canvas>` element for `VisualizeJS`.
88
+ * @param onProgress - A callback function that handles events measuring progress of loading
89
+ * of the `VisualizeJS` library. Retrieves {@link event:visualizeprogress | visualizeprogress} event.
90
+ */
91
+ initialize(canvas: HTMLCanvasElement, onProgress?: (event: ProgressEvent) => void): Promise<this>;
92
+ /**
93
+ * Releases all resources allocated by this `Viewer` instance. Call this method before
94
+ * release the `Viewer` instance.
95
+ */
96
+ dispose(): this;
97
+ /**
98
+ * Returns `true` if `VisualizeJS` module has been loaded andinitialized.
99
+ */
100
+ isInitialized(): boolean;
101
+ private render;
102
+ resize(): this;
103
+ /**
104
+ * Updates the viewer. Do nothing if the auto-update mode is disabled in the constructor (use
105
+ * the `update` event to update viewer manually).
106
+ *
107
+ * Fires:
108
+ *
109
+ * - {@link UpdateEvent | update}
110
+ *
111
+ * @param force - If `true` updates the viewer immidietly. Otherwise updates on next
112
+ * animation frame. Default is `false`.
113
+ */
114
+ update(force?: boolean): void;
115
+ /**
116
+ * Update with internal schedule, need after change operation when have long update for
117
+ * update without lock UI
118
+ *
119
+ * @param maxScheduleUpdateTimeInMs - Maximum time for one update, by default 30 ms
120
+ * @param maxScheduleUpdateCount - Maximum count of schedule update
121
+ * @returns return void Promise
122
+ */
123
+ private scheduleUpdateAsync;
124
+ updateAsync(maxScheduleUpdateTimeInMs?: number, maxScheduleUpdateCount?: number): Promise<void>;
125
+ /**
126
+ * Returns `VisualizeJS`
127
+ * {@link https://cloud.opendesign.com/docs/index.html#/visualizejs_api | module} instance.
128
+ */
129
+ visLib(): any;
130
+ /**
131
+ * Returns `VisualizeJS`
132
+ * {@link https://cloud.opendesign.com/docs/index.html#/vis/Viewer | Viewer} instance.
133
+ */
134
+ visViewer(): any;
135
+ syncOpenCloudVisualStyle(isInitializing: boolean): this;
136
+ syncOptions(options?: OptionsData): this;
137
+ syncHighlightingOptions(options?: OptionsData): this;
138
+ /**
139
+ * List of names of available draggers:
140
+ *
141
+ * - `Line`
142
+ * - `Text`
143
+ * - `Pan`
144
+ * - `Orbit`
145
+ * - `Zoom`
146
+ * - `ZoomWindow`
147
+ * - `OrbitAroundBuilding`
148
+ * - `MeasureLine`
149
+ * - `CuttingPlaneXAxis`
150
+ * - `CuttingPlaneYAxis`
151
+ * - `CuttingPlaneZAxis`
152
+ * - `Walk`
153
+ *
154
+ * @readonly
155
+ */
156
+ get draggers(): string[];
157
+ /**
158
+ * Register dragger on draggerFactory.
159
+ *
160
+ * @param name - Dragger name.
161
+ * @param dragger - Dragger class.
162
+ */
163
+ registerDragger(name: string, dragger: typeof OdBaseDragger): void;
164
+ /**
165
+ * Returns active dragger instance or `null` if there is no active dragger.
166
+ */
167
+ activeDragger(): any | null;
168
+ /**
169
+ * Set active dragger. `Viewer` must be {@link Viewer#initialize | initialized} before enable
170
+ * dragger or exception is thrown.
171
+ *
172
+ * Fires:
173
+ *
174
+ * - {@link ChangeActiveDragger | changeactivedragger}
175
+ *
176
+ * @param name - Dragger name. Can be one of the {@link Viewer#draggers | draggers} list.
177
+ * @returns Returns active dragger instance or `null` if there is no dragger with the given name.
178
+ */
179
+ setActiveDragger(name: string): OdBaseDragger | null;
180
+ /**
181
+ * Reset the state of the active dragger.
182
+ */
183
+ resetActiveDragger(): void;
184
+ /**
185
+ * Remove all cutting planes.
186
+ */
187
+ clearSlices(): void;
188
+ /**
189
+ * Remove markup overlay.
190
+ */
191
+ clearOverlay(): void;
192
+ /**
193
+ * Synchronize markup overlay.
194
+ */
195
+ syncOverlay(): any;
196
+ /**
197
+ * Returns `true` if current drawing is 3D drawing.
198
+ */
199
+ is3D(): boolean;
200
+ /**
201
+ * Returns a list of original handles for the selected entities.
202
+ */
203
+ getSelected(): string[];
204
+ /**
205
+ * Select model entities by original handles that are obtained using
206
+ * {@link File.getProperties | File.getProperties()} or
207
+ * {@link File.searchProperties | File.searchProperties()} methods.
208
+ *
209
+ * Fires:
210
+ *
211
+ * - {@link SelectEvent | select}
212
+ *
213
+ * @param handles - The list of original handles.
214
+ */
215
+ setSelected(handles?: string[]): void;
216
+ /**
217
+ * Load model references into the viewer. References are images, fonts, or any other files to
218
+ * correct rendering of the model.
219
+ *
220
+ * @async
221
+ * @param model - Instance of model with references. If a `File` instance is specified
222
+ * instead of a model, the file references will be loaded.
223
+ */
224
+ loadReferences(model: Model | File | Assembly): Promise<this>;
225
+ applyModelTransformMatrix(model: Model | Assembly): void;
226
+ applySceneGraphSettings(options?: Options): void;
227
+ /**
228
+ * Loads a model of a file or assembly into the viewer.
229
+ *
230
+ * This method requires a [Client]{@link Client | Client} instance to work. For standalone
231
+ * viewer instance use {@link Viewer#openVsfFile | openVsfFile()} or
232
+ * {@link Viewer#openVsfxFile | openVsfxFile()}.
233
+ *
234
+ * Fires:
235
+ *
236
+ * - {@link OpenEvent | open}
237
+ * - {@link GeometryStartEvent | geometrystart}
238
+ * - {@link GeometryProgressEvent | geometryprogress}
239
+ * - {@link DatabaseChunkEvent | databasechunk}
240
+ * - {@link GeometryChunkEvent | geometrychunk}
241
+ * - {@link GeometryEndEvent | geometryend}
242
+ * - {@link GeometryErrorEvent | geometryerror}
243
+ *
244
+ * @async
245
+ * @param file - File or Assembly or Model instance to load. If a `File` instance with
246
+ * multiple models is specified, the default model will be loaded. If there is no default
247
+ * model, first availiable model will be loaded.
248
+ */
249
+ open(file: File | Assembly | Model): Promise<this>;
250
+ /**
251
+ * Loads a VSF file into the viewer.
252
+ *
253
+ * Fires:
254
+ *
255
+ * - {@link OpenEvent | open}
256
+ * - {@link GeometryStartEvent | geometrystart}
257
+ * - {@link GeometryProgressEvent | geometryprogress}
258
+ * - {@link DatabaseChunkEvent | databasechunk}
259
+ * - {@link GeometryEndEvent | geometryend}
260
+ * - {@link GeometryErrorEvent | geometryerror}
261
+ *
262
+ * @param buffer - Binary data buffer to load.
263
+ */
264
+ openVsfFile(buffer: Uint8Array | ArrayBuffer): this;
265
+ /**
266
+ * Loads a VSFX file into the viewer.
267
+ *
268
+ * Fires:
269
+ *
270
+ * - {@link OpenEvent | open}
271
+ * - {@link GeometryStartEvent | geometrystart}
272
+ * - {@link GeometryProgressEvent | geometryprogress}
273
+ * - {@link DatabaseChunkEvent | databasechunk}
274
+ * - {@link GeometryEndEvent | geometryend}
275
+ * - {@link GeometryErrorEvent | geometryerror}
276
+ *
277
+ * @param buffer - Binary data buffer to load.
278
+ */
279
+ openVsfxFile(buffer: Uint8Array | ArrayBuffer): this;
280
+ /**
281
+ * Cancels asynchronous model loading started by {@link Viewer#open | open()}.
282
+ */
283
+ cancel(): this;
284
+ /**
285
+ * Unloads the model and clears the viewer.
286
+ */
287
+ clear(): this;
288
+ /**
289
+ * Get markup color.
290
+ *
291
+ * @returns Color with `RGB` values.
292
+ */
293
+ getMarkupColor(): {
294
+ r: number;
295
+ g: number;
296
+ b: number;
297
+ };
298
+ /**
299
+ * Set markup color.
300
+ *
301
+ * @param r - `Red` part of color.
302
+ * @param g - `Green` part of color.
303
+ * @param b - `Blue` part of color.
304
+ */
305
+ setMarkupColor(r?: number, g?: number, b?: number): void;
306
+ /**
307
+ * Colorize all markup entities with the specified color.
308
+ *
309
+ * @param r - `Red` part of color.
310
+ * @param g - `Green` part of color.
311
+ * @param b - `Blue` part of color.
312
+ */
313
+ colorizeAllMarkup(r?: number, g?: number, b?: number): void;
314
+ /**
315
+ * Add an empty markup entity to the overlay.
316
+ */
317
+ addMarkupEntity(entityName: string): any;
318
+ /**
319
+ * Draw a viewpoint. To get a list of available model viewpoints, use the
320
+ * {@link Model#getViewpoints | Model.getViewpoints()} or
321
+ * {@link File#getViewpoints | File.getViewpoints()}.
322
+ *
323
+ * @param viewpoint - Viewpoint.
324
+ */
325
+ drawViewpoint(viewpoint: IViewpoint): void;
326
+ /**
327
+ * Create a viewpoint. To add a viewpoint to the list of model viewpoints, use the
328
+ * {@link Model#saveViewpoint | Model.saveViewpoint()} or
329
+ * {@link File#saveViewpoint | File.saveViewpoint()}.
330
+ */
331
+ createViewpoint(): IViewpoint;
332
+ private getPoint3dFromArray;
333
+ private getLogicalPoint3dAsArray;
334
+ private getOrthogonalCameraSettings;
335
+ private setOrthogonalCameraSettings;
336
+ private getClippingPlanes;
337
+ private setClippingPlanes;
338
+ /**
339
+ * Executes the command denoted by the given command identifier.
340
+ *
341
+ * @param id - Identifier of the command to execute.
342
+ * @param args - Parameters passed to the command function.
343
+ * @returns A returned value of the given command. Returns `undefined` when the command doesn't exists.
344
+ */
345
+ executeCommand(id: string, ...args: any[]): any;
346
+ }
@@ -0,0 +1,3 @@
1
+ export declare function loadScript(url: string): Promise<unknown>;
2
+ export declare const memoize: (f: any) => (...args: any[]) => any;
3
+ export declare const loadVisualizeJs: (url: string, onprogress: any) => Promise<unknown>;
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { commands } from "@inweb/viewer-core";
2
+ export { Viewer } from "./Viewer/Viewer";
3
+ export { OdBaseDragger } from "./Viewer/Draggers/Common/OdBaseDragger";
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@inweb/viewer-visualize",
3
+ "version": "25.3.13",
4
+ "description": "Visualize.js based 3D CAD and BIM data Viewer for the inWEB Open Cloud platform.",
5
+ "homepage": "https://cloud.opendesign.com/docs/index.html",
6
+ "license": "SEE LICENSE IN LICENSE",
7
+ "author": "Open Design Alliance",
8
+ "keywords": [
9
+ "opendesign",
10
+ "opencloud",
11
+ "inweb",
12
+ "viewer",
13
+ "visualize",
14
+ "visualizejs",
15
+ "visualize.js"
16
+ ],
17
+ "sideEffects": false,
18
+ "main": "dist/viewer-visualize.js",
19
+ "module": "dist/viewer-visualize.module.js",
20
+ "types": "lib/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "lib/**/*.d.ts",
24
+ "src"
25
+ ],
26
+ "scripts": {
27
+ "build": "rollup -c rollup.config.js",
28
+ "test": "karma start karma.conf.js"
29
+ },
30
+ "dependencies": {
31
+ "@inweb/client": "^25.3.12",
32
+ "@inweb/eventemitter2": "^25.3.12",
33
+ "@inweb/viewer-core": "^25.3.12"
34
+ },
35
+ "devDependencies": {
36
+ "canvas": "^2.11.2",
37
+ "konva": "^9.2.0"
38
+ },
39
+ "peerDependencies": {
40
+ "canvas": "^2.11.2",
41
+ "konva": "^9.2.0"
42
+ },
43
+ "visualizeJS": "https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js"
44
+ }
@@ -0,0 +1,69 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, 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-2021 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 { Model, File, Assembly } from "@inweb/client";
25
+ import { commands } from "@inweb/viewer-core";
26
+ import { Viewer } from "../Viewer";
27
+
28
+ export const composeMatrixFromTransform = (translate, rotate, scale, modelCenter, matrix) => {
29
+ const translateMatrix = matrix.setTranslation([translate.x, translate.y, translate.z]);
30
+ const rotateMatrix = matrix.setToRotation(rotate.angle, [rotate.x, rotate.y, rotate.z], modelCenter);
31
+ const scaleMatrix = matrix.setToScaling(scale, modelCenter);
32
+ return translateMatrix.postMultBy(rotateMatrix).postMultBy(scaleMatrix);
33
+ };
34
+
35
+ function applyModelTransform(viewer: Viewer, model: Model | File | Assembly) {
36
+ if (!viewer.visualizeJs) return;
37
+
38
+ const assembly = model instanceof Model ? model.assembly : model;
39
+ if (!(assembly instanceof Assembly)) return;
40
+
41
+ const visLib = viewer.visLib();
42
+ const visViewer = visLib.getViewer();
43
+
44
+ const modelItr = visViewer.getModelIterator();
45
+ for (; !modelItr.done(); modelItr.step()) {
46
+ const modelPtr = modelItr.getModel();
47
+
48
+ const transform = assembly.getModelTransformMatrix(modelPtr.getDatabaseHandle());
49
+ if (transform) {
50
+ const extents = modelPtr.getExtents();
51
+ const matrix = composeMatrixFromTransform(
52
+ transform.translate,
53
+ transform.rotation,
54
+ transform.scale,
55
+ extents.center(),
56
+ new visLib.Matrix3d()
57
+ );
58
+
59
+ modelPtr.setModelingMatrix(matrix, true);
60
+ }
61
+ }
62
+ modelItr.delete();
63
+
64
+ visViewer.clearViewExtentsCache?.();
65
+
66
+ viewer.update();
67
+ }
68
+
69
+ commands("VisualizeJS").registerCommand("applyModelTransform", applyModelTransform);
@@ -0,0 +1,28 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, 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-2021 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 { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ commands("VisualizeJS").registerCommand("clearMarkup", (viewer: Viewer) => viewer.clearOverlay());
28
+ commands("VisualizeJS").registerCommandAlias("clearMarkup", "clearOverlay");
@@ -0,0 +1,27 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, 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-2021 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 { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ commands("VisualizeJS").registerCommand("clearSlices", (viewer: Viewer) => viewer.clearSlices());
@@ -0,0 +1,33 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, 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-2021 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 { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ function createPreview(viewer: Viewer, type = "image/jpeg", encoderOptions = 0.25): string {
28
+ if (!viewer.visualizeJs) return "";
29
+
30
+ return viewer.canvas?.toDataURL(type, encoderOptions) || "";
31
+ }
32
+
33
+ commands("VisualizeJS").registerCommand("createPreview", createPreview);
@@ -0,0 +1,38 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, 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-2021 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 { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ function explode(viewer: Viewer, index = 0): void {
28
+ if (!viewer.visualizeJs) return;
29
+
30
+ const visViewer = viewer.visViewer();
31
+ visViewer.explode(index);
32
+
33
+ viewer.update();
34
+ viewer.emit({ type: "explode", data: index });
35
+ }
36
+
37
+ commands("VisualizeJS").registerCommand("explode", explode);
38
+ commands("VisualizeJS").registerCommand("collect", (viewer: any) => explode(viewer, 0));