@inweb/viewer-visualize 25.8.15 → 25.8.19
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/README.md +41 -19
- package/dist/viewer-visualize.js +102 -92
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +40 -29
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/MarkupFactory.d.ts +2 -6
- package/lib/Viewer/Viewer.d.ts +66 -63
- package/package.json +6 -6
- package/src/Viewer/Draggers/OdZoomDragger.ts +1 -1
- package/src/Viewer/Markup/MarkupFactory.ts +5 -9
- package/src/Viewer/Viewer.ts +82 -78
package/README.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# Viewer.visualize
|
|
2
2
|
|
|
3
|
-
`Viewer.visualize` is JavaScript library powered by [
|
|
3
|
+
`Viewer.visualize` is JavaScript library implementating 3D viewer powered by [VisualizeJS](https://cloud.opendesign.com/docs/index.html#/visualizejs) for in-browser visualization of 3D CAD and BIM data files.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
With `Viewer.visualize` you can:
|
|
6
|
+
|
|
7
|
+
- Visualize files stored on the [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server), on the web, or on your local computer.
|
|
8
|
+
- Add user interaction with scenes.
|
|
9
|
+
- Create markups.
|
|
10
|
+
- Save and load viewpoints.
|
|
11
|
+
|
|
12
|
+
This library is a part of [CDE SDK](https://www.opendesign.com/products/cde) by [Open Design Alliance](https://opendesign.com).
|
|
6
13
|
|
|
7
14
|
> `Viewer.visualize` uses `VSFX` file format as internal geometry data format. `VSFX` is a [Visualize SDK](https://cloud.opendesign.com/docs/index.html#/visualizejs) file format with support for streaming and partial viewing.
|
|
8
15
|
|
|
@@ -18,6 +25,12 @@ For CDN, you can use [unpkg](https://unpkg.com/) or [jsDelivr](https://www.jsdel
|
|
|
18
25
|
|
|
19
26
|
The global namespace for `Viewer.visualize` is `ODA.Visualize`.
|
|
20
27
|
|
|
28
|
+
```html
|
|
29
|
+
<script>
|
|
30
|
+
const viewer = new ODA.Visualize.Viewer();
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
21
34
|
### Install via [npm](https://npmjs.org)
|
|
22
35
|
|
|
23
36
|
Open a terminal in your project folder and run:
|
|
@@ -30,6 +43,7 @@ The `Viewer.visualize` package will be downloaded and installed. Then you're rea
|
|
|
30
43
|
|
|
31
44
|
```javascript
|
|
32
45
|
import { Viewer } from "@inweb/viewer-visualize";
|
|
46
|
+
const viewer = new Viewer();
|
|
33
47
|
```
|
|
34
48
|
|
|
35
49
|
## Example
|
|
@@ -37,23 +51,31 @@ import { Viewer } from "@inweb/viewer-visualize";
|
|
|
37
51
|
Download and render file from the `Open Cloud Server`:
|
|
38
52
|
|
|
39
53
|
```html
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
<html>
|
|
55
|
+
<body>
|
|
56
|
+
<div>
|
|
57
|
+
<canvas id="canvas" />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<script src="https://unpkg.com/@inweb/client@25.3/dist/client.js"></script>
|
|
61
|
+
<script src="https://unpkg.com/@inweb/viewer-visualize@25.3/dist/viewer-visualize.js"></script>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
const client = new ODA.Api.Client({ serverUrl: "https://cloud.opendesign.com/api" });
|
|
65
|
+
const viewer = new ODA.Visualize.Viewer(client);
|
|
66
|
+
|
|
67
|
+
init();
|
|
68
|
+
|
|
69
|
+
async function init() {
|
|
70
|
+
await client.signInWithEmail("email", "password");
|
|
71
|
+
const files = await client.getFiles();
|
|
72
|
+
await viewer.initialize(canvas);
|
|
73
|
+
await viewer.open(files.result[0]);
|
|
74
|
+
viewer.setActiveDragger("Orbit");
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
</body>
|
|
78
|
+
</html>
|
|
57
79
|
```
|
|
58
80
|
|
|
59
81
|
To learn more, see [First application guide](https://cloud.opendesign.com/docs/index.html#/guide).
|
package/dist/viewer-visualize.js
CHANGED
|
@@ -12800,10 +12800,11 @@
|
|
|
12800
12800
|
constructor(params, ref = null) {
|
|
12801
12801
|
var _a, _b;
|
|
12802
12802
|
this._ratio = 1;
|
|
12803
|
+
this.EPSILON = 1e-5;
|
|
12803
12804
|
if (ref) {
|
|
12804
12805
|
this._ref = ref;
|
|
12805
12806
|
this._canvasImage = ref.image();
|
|
12806
|
-
this._ratio = this._ref.height()
|
|
12807
|
+
this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
|
|
12807
12808
|
return;
|
|
12808
12809
|
}
|
|
12809
12810
|
if (!params || !params.position || !params.src) return;
|
|
@@ -12818,9 +12819,22 @@
|
|
|
12818
12819
|
});
|
|
12819
12820
|
this._canvasImage.onload = () => {
|
|
12820
12821
|
this._ref.image(this._canvasImage);
|
|
12821
|
-
if (this._ref.height()
|
|
12822
|
-
if (this._ref.width()
|
|
12823
|
-
this._ratio = this._ref.height()
|
|
12822
|
+
if (this._ref.height() <= this.EPSILON) this._ref.height(this._canvasImage.height);
|
|
12823
|
+
if (this._ref.width() <= this.EPSILON) this._ref.width(this._canvasImage.width);
|
|
12824
|
+
this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
|
|
12825
|
+
if ((params.width <= this.EPSILON || params.height <= this.EPSILON) && (params.maxWidth >= this.EPSILON || params.maxWidth >= this.EPSILON)) {
|
|
12826
|
+
const heightOutOfCanvas = params.maxHeight - this._canvasImage.height;
|
|
12827
|
+
const widthOutOfCanvas = params.maxWidth - this._canvasImage.width;
|
|
12828
|
+
if (heightOutOfCanvas <= this.EPSILON || widthOutOfCanvas <= this.EPSILON) {
|
|
12829
|
+
if (widthOutOfCanvas <= this.EPSILON && widthOutOfCanvas < heightOutOfCanvas / this._ratio) {
|
|
12830
|
+
this._ref.height(params.maxWidth * this._ratio);
|
|
12831
|
+
this._ref.width(params.maxWidth);
|
|
12832
|
+
} else {
|
|
12833
|
+
this._ref.width(params.maxHeight / this._ratio);
|
|
12834
|
+
this._ref.height(params.maxHeight);
|
|
12835
|
+
}
|
|
12836
|
+
}
|
|
12837
|
+
}
|
|
12824
12838
|
};
|
|
12825
12839
|
this._canvasImage.src = params.src;
|
|
12826
12840
|
this._ref.on("transform", (e => {
|
|
@@ -13917,6 +13931,8 @@
|
|
|
13917
13931
|
src: src,
|
|
13918
13932
|
width: width,
|
|
13919
13933
|
height: height,
|
|
13934
|
+
maxWidth: this._konvaStage.width() - position.x,
|
|
13935
|
+
maxHeight: this._konvaStage.height() - position.y,
|
|
13920
13936
|
id: id
|
|
13921
13937
|
});
|
|
13922
13938
|
this.addObject(konvaImage);
|
|
@@ -15375,7 +15391,7 @@
|
|
|
15375
15391
|
this.beginInteractivity();
|
|
15376
15392
|
}
|
|
15377
15393
|
drag(x, y, dltX, dltY) {
|
|
15378
|
-
if (this.press) {
|
|
15394
|
+
if (this.press && Math.abs(dltY) <= 10e-6) {
|
|
15379
15395
|
const ZOOM_SPEED = 0.025;
|
|
15380
15396
|
const zoomFactor = dltY > 0 ? 1 + ZOOM_SPEED : 1 - ZOOM_SPEED;
|
|
15381
15397
|
this._zoomAction.action(this.pressX, this.pressY, zoomFactor);
|
|
@@ -16568,23 +16584,14 @@
|
|
|
16568
16584
|
}
|
|
16569
16585
|
|
|
16570
16586
|
///////////////////////////////////////////////////////////////////////////////
|
|
16571
|
-
/**
|
|
16572
|
-
* The markup type: `Visualize` (deprecated) or `Konva`.
|
|
16573
|
-
*/
|
|
16574
|
-
exports.MarkupType = void 0;
|
|
16575
|
-
(function (MarkupType) {
|
|
16576
|
-
MarkupType[MarkupType["Unknown"] = 0] = "Unknown";
|
|
16577
|
-
MarkupType["Konva"] = "Konva";
|
|
16578
|
-
MarkupType["Visualize"] = "Visualize";
|
|
16579
|
-
})(exports.MarkupType || (exports.MarkupType = {}));
|
|
16580
16587
|
class MarkupFactory {
|
|
16581
|
-
static createMarkup(markupType =
|
|
16588
|
+
static createMarkup(markupType = "Konva") {
|
|
16582
16589
|
let markup;
|
|
16583
16590
|
switch (markupType) {
|
|
16584
|
-
case
|
|
16591
|
+
case "Konva":
|
|
16585
16592
|
markup = new KonvaMarkup();
|
|
16586
16593
|
break;
|
|
16587
|
-
case
|
|
16594
|
+
case "Visualize":
|
|
16588
16595
|
markup = new VisualizeMarkup();
|
|
16589
16596
|
break;
|
|
16590
16597
|
default:
|
|
@@ -16598,24 +16605,22 @@
|
|
|
16598
16605
|
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
16599
16606
|
const isExist = (value) => value !== undefined && value !== null;
|
|
16600
16607
|
/**
|
|
16601
|
-
*
|
|
16608
|
+
* 3D viewer powered by
|
|
16602
16609
|
* {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS} library.
|
|
16603
16610
|
*/
|
|
16604
16611
|
class Viewer extends EventEmitter2 {
|
|
16605
16612
|
/**
|
|
16606
|
-
* @param client - The `Client` instance that provides access to a
|
|
16607
|
-
* `Client` if you need a standalone viewer instance
|
|
16613
|
+
* @param client - The `Client` instance that provides access to a Open Cloud Server. Do not
|
|
16614
|
+
* specify `Client` if you need a standalone viewer instance to view `VSFX` files from the
|
|
16615
|
+
* web or from local computer.
|
|
16608
16616
|
* @param params - An object containing viewer configuration parameters.
|
|
16609
16617
|
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
16610
|
-
* library instance, or
|
|
16611
|
-
* `
|
|
16612
|
-
*
|
|
16613
|
-
* _Note: Your own `VisualizeJS` library version must match the version of the `Client.js`
|
|
16614
|
-
* you are using._
|
|
16618
|
+
* library instance, or specify `undefined` or blank to use the default URL defined by
|
|
16619
|
+
* `Viewer.visualize` library you are using.
|
|
16615
16620
|
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
16616
|
-
* the auto-update is disabled, you need to register
|
|
16617
|
-
* the viewer and
|
|
16618
|
-
* @param params.markupType -
|
|
16621
|
+
* the auto-update is disabled, you need to register an `update` event handler and update
|
|
16622
|
+
* the `VisualizeJS` viewer and active dragger manually. Default is `true`.
|
|
16623
|
+
* @param params.markupType - The type of the markup core: `Visualize` (deprecated) or
|
|
16619
16624
|
* `Konva`. Default is `Konva`.
|
|
16620
16625
|
*/
|
|
16621
16626
|
constructor(client, params = {}) {
|
|
@@ -16665,7 +16670,7 @@
|
|
|
16665
16670
|
return this._visualizeJsUrl;
|
|
16666
16671
|
}
|
|
16667
16672
|
/**
|
|
16668
|
-
* 2D markup core.
|
|
16673
|
+
* 2D markup core instance used to create markups.
|
|
16669
16674
|
*
|
|
16670
16675
|
* @readonly
|
|
16671
16676
|
*/
|
|
@@ -16673,18 +16678,19 @@
|
|
|
16673
16678
|
return this._markup;
|
|
16674
16679
|
}
|
|
16675
16680
|
/**
|
|
16676
|
-
*
|
|
16681
|
+
* Changes the viewer parameters.
|
|
16677
16682
|
*
|
|
16678
|
-
* @param params - An object containing new
|
|
16683
|
+
* @param params - An object containing new parameters.
|
|
16679
16684
|
* @param params.visualizeJsUrl - `VisualizeJS` library URL. Set this URL to use your own
|
|
16680
|
-
* library instance or
|
|
16685
|
+
* library instance or specify `undefined` or blank to use the default URL defined by
|
|
16686
|
+
* `Viewer.visualize` library you are using.
|
|
16681
16687
|
*/
|
|
16682
16688
|
configure(params) {
|
|
16683
16689
|
this._visualizeJsUrl = params.visualizeJsUrl || "https://opencloud.azureedge.net/libs/visualizejs/master/Visualize.js";
|
|
16684
16690
|
return this;
|
|
16685
16691
|
}
|
|
16686
16692
|
/**
|
|
16687
|
-
*
|
|
16693
|
+
* Loads the `VisualizeJS` module and initialize it with the specified canvas. Call
|
|
16688
16694
|
* {@link dispose | dispose()} to release allocated resources.
|
|
16689
16695
|
*
|
|
16690
16696
|
* Fires:
|
|
@@ -16739,8 +16745,8 @@
|
|
|
16739
16745
|
return this;
|
|
16740
16746
|
}
|
|
16741
16747
|
/**
|
|
16742
|
-
* Releases all resources allocated by this
|
|
16743
|
-
*
|
|
16748
|
+
* Releases all resources allocated by this viewer instance. Call this method before release
|
|
16749
|
+
* the `Viewer` instance.
|
|
16744
16750
|
*/
|
|
16745
16751
|
dispose() {
|
|
16746
16752
|
this.cancel();
|
|
@@ -16771,7 +16777,7 @@
|
|
|
16771
16777
|
return this;
|
|
16772
16778
|
}
|
|
16773
16779
|
/**
|
|
16774
|
-
* Returns `true` if `VisualizeJS` module has been loaded
|
|
16780
|
+
* Returns `true` if `VisualizeJS` module has been loaded and initialized.
|
|
16775
16781
|
*/
|
|
16776
16782
|
isInitialized() {
|
|
16777
16783
|
return !!this.visualizeJs;
|
|
@@ -16807,8 +16813,10 @@
|
|
|
16807
16813
|
return this;
|
|
16808
16814
|
}
|
|
16809
16815
|
/**
|
|
16810
|
-
* Updates the viewer.
|
|
16811
|
-
*
|
|
16816
|
+
* Updates the viewer.
|
|
16817
|
+
*
|
|
16818
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
16819
|
+
* an `update` event handler and update the `Visualize` viewer and active dragger manually.
|
|
16812
16820
|
*
|
|
16813
16821
|
* Fires:
|
|
16814
16822
|
*
|
|
@@ -16830,21 +16838,16 @@
|
|
|
16830
16838
|
}
|
|
16831
16839
|
this.emitEvent({ type: "update", data: force });
|
|
16832
16840
|
}
|
|
16833
|
-
/**
|
|
16834
|
-
* Update with internal schedule, need after change operation when have long update for
|
|
16835
|
-
* update without lock UI
|
|
16836
|
-
*
|
|
16837
|
-
* @param maxScheduleUpdateTimeInMs - Maximum time for one update, by default 30 ms
|
|
16838
|
-
* @param maxScheduleUpdateCount - Maximum count of schedule update
|
|
16839
|
-
* @returns return void Promise
|
|
16840
|
-
*/
|
|
16841
16841
|
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
16842
16842
|
return new Promise((resolve, reject) => {
|
|
16843
16843
|
setTimeout(() => {
|
|
16844
16844
|
var _a, _b;
|
|
16845
16845
|
try {
|
|
16846
|
-
(
|
|
16847
|
-
|
|
16846
|
+
if (this._enableAutoUpdate) {
|
|
16847
|
+
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
16848
|
+
(_b = this.activeDragger()) === null || _b === void 0 ? void 0 : _b.updatePreview();
|
|
16849
|
+
}
|
|
16850
|
+
this.emitEvent({ type: "update", data: false });
|
|
16848
16851
|
resolve();
|
|
16849
16852
|
}
|
|
16850
16853
|
catch (e) {
|
|
@@ -16854,6 +16857,20 @@
|
|
|
16854
16857
|
}, 0);
|
|
16855
16858
|
});
|
|
16856
16859
|
}
|
|
16860
|
+
/**
|
|
16861
|
+
* Updates the viewer asynchronously without locking the user interface. Used to update the
|
|
16862
|
+
* viewer after changes that require a long rendering time.
|
|
16863
|
+
*
|
|
16864
|
+
* Do nothing if the auto-update mode is disabled in the constructor. In this case, register
|
|
16865
|
+
* an `update` event handler and update the `VisualizeJS` viewer and active dragger manually.
|
|
16866
|
+
*
|
|
16867
|
+
* Fires:
|
|
16868
|
+
*
|
|
16869
|
+
* - {@link UpdateEvent | update}
|
|
16870
|
+
*
|
|
16871
|
+
* @param maxScheduleUpdateTimeInMs - Maximum time for one update, default 30 ms.
|
|
16872
|
+
* @param maxScheduleUpdateCount - Maximum count of scheduled updates.
|
|
16873
|
+
*/
|
|
16857
16874
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
16858
16875
|
this._isRunAsyncUpdate = true;
|
|
16859
16876
|
const device = this.visViewer().getActiveDevice();
|
|
@@ -17025,7 +17042,7 @@
|
|
|
17025
17042
|
return this;
|
|
17026
17043
|
}
|
|
17027
17044
|
/**
|
|
17028
|
-
* List of names of
|
|
17045
|
+
* List of names of registered draggers. By default, the following draggers are registered:
|
|
17029
17046
|
*
|
|
17030
17047
|
* - `Line`
|
|
17031
17048
|
* - `Text`
|
|
@@ -17046,7 +17063,8 @@
|
|
|
17046
17063
|
return [...this.draggerFactory.keys()];
|
|
17047
17064
|
}
|
|
17048
17065
|
/**
|
|
17049
|
-
*
|
|
17066
|
+
* Registers a dragger for the viewer. Dragger is an object that received mouse/keyboard
|
|
17067
|
+
* events and does something to the viewer.
|
|
17050
17068
|
*
|
|
17051
17069
|
* @param name - Dragger name.
|
|
17052
17070
|
* @param dragger - Dragger class.
|
|
@@ -17061,7 +17079,7 @@
|
|
|
17061
17079
|
return this._activeDragger;
|
|
17062
17080
|
}
|
|
17063
17081
|
/**
|
|
17064
|
-
*
|
|
17082
|
+
* Changes the active dragger. Viewer must be initialized before enable dragger or exception is thrown.
|
|
17065
17083
|
*
|
|
17066
17084
|
* Fires:
|
|
17067
17085
|
*
|
|
@@ -17099,7 +17117,7 @@
|
|
|
17099
17117
|
return this._activeDragger;
|
|
17100
17118
|
}
|
|
17101
17119
|
/**
|
|
17102
|
-
*
|
|
17120
|
+
* Resets the state of the active dragger.
|
|
17103
17121
|
*/
|
|
17104
17122
|
resetActiveDragger() {
|
|
17105
17123
|
const dragger = this._activeDragger;
|
|
@@ -17109,7 +17127,7 @@
|
|
|
17109
17127
|
}
|
|
17110
17128
|
}
|
|
17111
17129
|
/**
|
|
17112
|
-
*
|
|
17130
|
+
* Removes all cutting planes.
|
|
17113
17131
|
*/
|
|
17114
17132
|
clearSlices() {
|
|
17115
17133
|
if (!this.visualizeJs)
|
|
@@ -17121,7 +17139,7 @@
|
|
|
17121
17139
|
this.update();
|
|
17122
17140
|
}
|
|
17123
17141
|
/**
|
|
17124
|
-
*
|
|
17142
|
+
* Clears the overlay view.
|
|
17125
17143
|
*/
|
|
17126
17144
|
clearOverlay() {
|
|
17127
17145
|
if (!this.visualizeJs)
|
|
@@ -17130,7 +17148,7 @@
|
|
|
17130
17148
|
this.update();
|
|
17131
17149
|
}
|
|
17132
17150
|
/**
|
|
17133
|
-
*
|
|
17151
|
+
* Creates an overlay view. Overlay view is used to draw cutting planes and `Visualize` markups.
|
|
17134
17152
|
*/
|
|
17135
17153
|
syncOverlay() {
|
|
17136
17154
|
if (!this.visualizeJs)
|
|
@@ -17158,7 +17176,7 @@
|
|
|
17158
17176
|
this.update();
|
|
17159
17177
|
}
|
|
17160
17178
|
/**
|
|
17161
|
-
* Returns `true` if current
|
|
17179
|
+
* Returns `true` if current model is 3D model.
|
|
17162
17180
|
*/
|
|
17163
17181
|
is3D() {
|
|
17164
17182
|
if (!this.visualizeJs)
|
|
@@ -17174,21 +17192,18 @@
|
|
|
17174
17192
|
screenToWorld(position) {
|
|
17175
17193
|
if (!this.visualizeJs)
|
|
17176
17194
|
return { x: position.x, y: position.y, z: 0 };
|
|
17177
|
-
const
|
|
17195
|
+
const activeView = this.visViewer().activeView;
|
|
17196
|
+
const worldPoint = activeView.transformScreenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
17178
17197
|
const result = { x: worldPoint[0], y: worldPoint[1], z: worldPoint[2] };
|
|
17198
|
+
activeView.delete();
|
|
17179
17199
|
return result;
|
|
17180
17200
|
}
|
|
17181
17201
|
worldToScreen(position) {
|
|
17182
17202
|
if (!this.visualizeJs)
|
|
17183
17203
|
return { x: position.x, y: position.y };
|
|
17184
17204
|
const activeView = this.visViewer().activeView;
|
|
17185
|
-
const
|
|
17186
|
-
const
|
|
17187
|
-
const devicePoint = worldPoint.transformBy(worldMatrix);
|
|
17188
|
-
const result = { x: devicePoint.x / window.devicePixelRatio, y: devicePoint.y / window.devicePixelRatio };
|
|
17189
|
-
devicePoint.delete();
|
|
17190
|
-
worldPoint.delete();
|
|
17191
|
-
worldMatrix.delete();
|
|
17205
|
+
const devicePoint = activeView.transformWorldToScreen(position.x, position.y, position.z);
|
|
17206
|
+
const result = { x: devicePoint[0] / window.devicePixelRatio, y: devicePoint[1] / window.devicePixelRatio };
|
|
17192
17207
|
activeView.delete();
|
|
17193
17208
|
return result;
|
|
17194
17209
|
}
|
|
@@ -17208,15 +17223,13 @@
|
|
|
17208
17223
|
return result;
|
|
17209
17224
|
}
|
|
17210
17225
|
/**
|
|
17211
|
-
* Returns a list of original handles for the selected
|
|
17226
|
+
* Returns a list of original handles for the selected objects.
|
|
17212
17227
|
*/
|
|
17213
17228
|
getSelected() {
|
|
17214
17229
|
return this.executeCommand("getSelected");
|
|
17215
17230
|
}
|
|
17216
17231
|
/**
|
|
17217
|
-
*
|
|
17218
|
-
* {@link File.getProperties | File.getProperties()} or
|
|
17219
|
-
* {@link File.searchProperties | File.searchProperties()} methods.
|
|
17232
|
+
* Selects the model objects by original handles that are obtained using `File.searchProperties()`.
|
|
17220
17233
|
*
|
|
17221
17234
|
* Fires:
|
|
17222
17235
|
*
|
|
@@ -17227,13 +17240,7 @@
|
|
|
17227
17240
|
setSelected(handles) {
|
|
17228
17241
|
this.executeCommand("setSelected", handles);
|
|
17229
17242
|
}
|
|
17230
|
-
|
|
17231
|
-
* Load model references into the viewer. References are images, fonts, or any other files to
|
|
17232
|
-
* correct rendering of the model.
|
|
17233
|
-
*
|
|
17234
|
-
* @param model - Instance of model with references. If a `File` instance is specified
|
|
17235
|
-
* instead of a model, the file references will be loaded.
|
|
17236
|
-
*/
|
|
17243
|
+
// Internal loading routines
|
|
17237
17244
|
async loadReferences(model) {
|
|
17238
17245
|
var _a;
|
|
17239
17246
|
if (!this.visualizeJs)
|
|
@@ -17256,7 +17263,6 @@
|
|
|
17256
17263
|
}
|
|
17257
17264
|
return this;
|
|
17258
17265
|
}
|
|
17259
|
-
// Internal loading routines
|
|
17260
17266
|
applyModelTransformMatrix(model) {
|
|
17261
17267
|
this.executeCommand("applyModelTransform", model);
|
|
17262
17268
|
}
|
|
@@ -17276,7 +17282,7 @@
|
|
|
17276
17282
|
this.update();
|
|
17277
17283
|
}
|
|
17278
17284
|
/**
|
|
17279
|
-
* Loads a model
|
|
17285
|
+
* Loads a model/file/assembly into the viewer.
|
|
17280
17286
|
*
|
|
17281
17287
|
* This method requires a {@link Client} instance to work. For standalone viewer instance use
|
|
17282
17288
|
* {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
|
|
@@ -17309,7 +17315,7 @@
|
|
|
17309
17315
|
if (!model)
|
|
17310
17316
|
throw new Error("No default model found");
|
|
17311
17317
|
const overrideOptions = new Options();
|
|
17312
|
-
overrideOptions.data = this.
|
|
17318
|
+
overrideOptions.data = this._options.data;
|
|
17313
17319
|
if (file.type === ".rcs" && !overrideOptions.enablePartialMode) {
|
|
17314
17320
|
console.log("Partial load mode is forced for RCS file");
|
|
17315
17321
|
overrideOptions.enablePartialMode = true;
|
|
@@ -17325,7 +17331,7 @@
|
|
|
17325
17331
|
return this;
|
|
17326
17332
|
}
|
|
17327
17333
|
/**
|
|
17328
|
-
* Loads a VSF file into the viewer.
|
|
17334
|
+
* Loads a `VSF` file into the viewer.
|
|
17329
17335
|
*
|
|
17330
17336
|
* Fires:
|
|
17331
17337
|
*
|
|
@@ -17364,7 +17370,7 @@
|
|
|
17364
17370
|
return this;
|
|
17365
17371
|
}
|
|
17366
17372
|
/**
|
|
17367
|
-
* Loads a VSFX file into the viewer.
|
|
17373
|
+
* Loads a `VSFX` file into the viewer.
|
|
17368
17374
|
*
|
|
17369
17375
|
* Fires:
|
|
17370
17376
|
*
|
|
@@ -17417,7 +17423,7 @@
|
|
|
17417
17423
|
return this;
|
|
17418
17424
|
}
|
|
17419
17425
|
/**
|
|
17420
|
-
* Unloads the model and clears the viewer.
|
|
17426
|
+
* Unloads the model and clears the viewer and markups.
|
|
17421
17427
|
*/
|
|
17422
17428
|
clear() {
|
|
17423
17429
|
if (!this.visualizeJs)
|
|
@@ -17434,15 +17440,17 @@
|
|
|
17434
17440
|
return this;
|
|
17435
17441
|
}
|
|
17436
17442
|
/**
|
|
17437
|
-
*
|
|
17438
|
-
*
|
|
17439
|
-
* @returns Color with `RGB` values.
|
|
17443
|
+
* Returns the color of new markup objects.
|
|
17440
17444
|
*/
|
|
17441
17445
|
getMarkupColor() {
|
|
17442
17446
|
return this._markup.getMarkupColor();
|
|
17443
17447
|
}
|
|
17444
17448
|
/**
|
|
17445
|
-
*
|
|
17449
|
+
* Sets the color of new markup objects.
|
|
17450
|
+
*
|
|
17451
|
+
* Fires:
|
|
17452
|
+
*
|
|
17453
|
+
* - {@link ChangeMarkupColorEvent | changemarkupcolor}
|
|
17446
17454
|
*
|
|
17447
17455
|
* @param r - `Red` part of color.
|
|
17448
17456
|
* @param g - `Green` part of color.
|
|
@@ -17454,7 +17462,7 @@
|
|
|
17454
17462
|
this.emitEvent({ type: "changemarkupcolor", data: color });
|
|
17455
17463
|
}
|
|
17456
17464
|
/**
|
|
17457
|
-
*
|
|
17465
|
+
* Colors all markup objects with the specified color.
|
|
17458
17466
|
*
|
|
17459
17467
|
* @param r - `Red` part of color.
|
|
17460
17468
|
* @param g - `Green` part of color.
|
|
@@ -17464,7 +17472,7 @@
|
|
|
17464
17472
|
this._markup.colorizeAllMarkup(r, g, b);
|
|
17465
17473
|
}
|
|
17466
17474
|
/**
|
|
17467
|
-
*
|
|
17475
|
+
* Colors selected markup objects with the specified color.
|
|
17468
17476
|
*
|
|
17469
17477
|
* @param r - `Red` part of color.
|
|
17470
17478
|
* @param g - `Green` part of color.
|
|
@@ -17474,7 +17482,7 @@
|
|
|
17474
17482
|
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
17475
17483
|
}
|
|
17476
17484
|
/**
|
|
17477
|
-
*
|
|
17485
|
+
* Adds an empty `Visualize` markup entity to the overlay.
|
|
17478
17486
|
*/
|
|
17479
17487
|
addMarkupEntity(entityName) {
|
|
17480
17488
|
if (!this.visualizeJs)
|
|
@@ -17492,8 +17500,9 @@
|
|
|
17492
17500
|
return entityId;
|
|
17493
17501
|
}
|
|
17494
17502
|
/**
|
|
17495
|
-
*
|
|
17496
|
-
*
|
|
17503
|
+
* Sets the viewer state to the specified viewpoint.
|
|
17504
|
+
*
|
|
17505
|
+
* To get a list of available model viewpoints, use the `File.getViewpoints()`.
|
|
17497
17506
|
*
|
|
17498
17507
|
* @param viewpoint - Viewpoint data.
|
|
17499
17508
|
*/
|
|
@@ -17503,8 +17512,9 @@
|
|
|
17503
17512
|
this._markup.setViewpoint(viewpoint);
|
|
17504
17513
|
}
|
|
17505
17514
|
/**
|
|
17506
|
-
*
|
|
17507
|
-
*
|
|
17515
|
+
* Saves the viewer state at the viewpoint.
|
|
17516
|
+
*
|
|
17517
|
+
* To save a viewpoint to a model on the server, use the `File.saveViewpoint()`.
|
|
17508
17518
|
*/
|
|
17509
17519
|
createViewpoint() {
|
|
17510
17520
|
const vp = this._markup.getViewpoint();
|