@xeokit/xeokit-sdk 2.4.2-beta-30 → 2.4.2-beta-32
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/xeokit-sdk.cjs.js +175 -39
- package/dist/xeokit-sdk.es.js +175 -39
- package/dist/xeokit-sdk.es5.js +87 -13
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +35 -10
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +39 -15
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +100 -13
- package/src/viewer/scene/scene/Scene.js +1 -1
- package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +235 -231
package/package.json
CHANGED
|
@@ -62,7 +62,25 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
62
62
|
|
|
63
63
|
this._currentAngleMeasurement = null;
|
|
64
64
|
|
|
65
|
+
// init markerDiv element (think about making its style configurable)
|
|
66
|
+
this._initMarkerDiv()
|
|
67
|
+
|
|
68
|
+
this._onMouseHoverSurface = null;
|
|
69
|
+
this._onHoverNothing = null;
|
|
70
|
+
this._onPickedNothing = null;
|
|
71
|
+
this._onPickedSurface = null;
|
|
72
|
+
|
|
73
|
+
this._onInputMouseDown = null;
|
|
74
|
+
this._onInputMouseUp = null;
|
|
75
|
+
|
|
76
|
+
this._snapping = cfg.snapping !== false;
|
|
77
|
+
|
|
78
|
+
this._attachPlugin(angleMeasurementsPlugin, cfg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_initMarkerDiv() {
|
|
65
82
|
const markerDiv = document.createElement('div');
|
|
83
|
+
markerDiv.setAttribute('id', 'myMarkerDiv');
|
|
66
84
|
const canvas = this.scene.canvas.canvas;
|
|
67
85
|
canvas.parentNode.insertBefore(markerDiv, canvas);
|
|
68
86
|
|
|
@@ -77,17 +95,14 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
77
95
|
markerDiv.style.pointerEvents = "none";
|
|
78
96
|
|
|
79
97
|
this.markerDiv = markerDiv;
|
|
80
|
-
|
|
81
|
-
this._onHoverNothing = null;
|
|
82
|
-
this._onPickedNothing = null;
|
|
83
|
-
this._onPickedSurface = null;
|
|
84
|
-
|
|
85
|
-
this._onInputMouseDown = null;
|
|
86
|
-
this._onInputMouseUp = null;
|
|
87
|
-
|
|
88
|
-
this._snapping = cfg.snapping !== false;
|
|
98
|
+
}
|
|
89
99
|
|
|
90
|
-
|
|
100
|
+
_destroyMarkerDiv() {
|
|
101
|
+
if (this._markerDiv) {
|
|
102
|
+
const element = document.getElementById('myMarkerDiv')
|
|
103
|
+
element.parentNode.removeChild(element)
|
|
104
|
+
this._markerDiv = null
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
_attachPlugin(angleMeasurementsPlugin, cfg = {}) {
|
|
@@ -155,6 +170,9 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
155
170
|
if (this._active) {
|
|
156
171
|
return;
|
|
157
172
|
}
|
|
173
|
+
if (!this.markerDiv) {
|
|
174
|
+
this._initMarkerDiv() // if the marker is destroyed after deactivation, we recreate it
|
|
175
|
+
}
|
|
158
176
|
const angleMeasurementsPlugin = this.angleMeasurementsPlugin;
|
|
159
177
|
const scene = this.scene;
|
|
160
178
|
const input = scene.input;
|
|
@@ -359,6 +377,9 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
359
377
|
if (this.pointerLens) {
|
|
360
378
|
this.pointerLens.visible = false;
|
|
361
379
|
}
|
|
380
|
+
if (this._markerDiv) {
|
|
381
|
+
this._destroyMarkerDiv()
|
|
382
|
+
}
|
|
362
383
|
this.reset();
|
|
363
384
|
const canvas = this.scene.canvas.canvas;
|
|
364
385
|
canvas.removeEventListener("mousedown", this._onMouseDown);
|
|
@@ -383,6 +404,10 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
383
404
|
if (!this._active) {
|
|
384
405
|
return;
|
|
385
406
|
}
|
|
407
|
+
|
|
408
|
+
this._destroyMarkerDiv()
|
|
409
|
+
this._initMarkerDiv()
|
|
410
|
+
|
|
386
411
|
if (this._currentAngleMeasurement) {
|
|
387
412
|
this._currentAngleMeasurement.destroy();
|
|
388
413
|
this._currentAngleMeasurement = null;
|
|
@@ -58,21 +58,6 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
58
58
|
|
|
59
59
|
this._active = false;
|
|
60
60
|
|
|
61
|
-
const markerDiv = document.createElement('div');
|
|
62
|
-
const canvas = this.scene.canvas.canvas;
|
|
63
|
-
canvas.parentNode.insertBefore(markerDiv, canvas);
|
|
64
|
-
markerDiv.style.background = "black";
|
|
65
|
-
markerDiv.style.border = "2px solid blue";
|
|
66
|
-
markerDiv.style.borderRadius = "10px";
|
|
67
|
-
markerDiv.style.width = "5px";
|
|
68
|
-
markerDiv.style.height = "5px";
|
|
69
|
-
markerDiv.style.margin = "-200px -200px";
|
|
70
|
-
markerDiv.style.zIndex = "100";
|
|
71
|
-
markerDiv.style.position = "absolute";
|
|
72
|
-
markerDiv.style.pointerEvents = "none";
|
|
73
|
-
|
|
74
|
-
this._markerDiv = markerDiv;
|
|
75
|
-
|
|
76
61
|
this._currentDistanceMeasurement = null;
|
|
77
62
|
|
|
78
63
|
this._currentDistanceMeasurementInitState = {
|
|
@@ -84,6 +69,8 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
84
69
|
targetVisible: null,
|
|
85
70
|
}
|
|
86
71
|
|
|
72
|
+
this._initMarkerDiv()
|
|
73
|
+
|
|
87
74
|
this._onCameraControlHoverSnapOrSurface = null;
|
|
88
75
|
this._onCameraControlHoverSnapOrSurfaceOff = null;
|
|
89
76
|
this._onMouseDown = null;
|
|
@@ -96,6 +83,32 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
96
83
|
this._attachPlugin(distanceMeasurementsPlugin, cfg);
|
|
97
84
|
}
|
|
98
85
|
|
|
86
|
+
_initMarkerDiv() {
|
|
87
|
+
const markerDiv = document.createElement('div');
|
|
88
|
+
markerDiv.setAttribute('id', 'myMarkerDiv');
|
|
89
|
+
const canvas = this.scene.canvas.canvas;
|
|
90
|
+
canvas.parentNode.insertBefore(markerDiv, canvas);
|
|
91
|
+
markerDiv.style.background = "black";
|
|
92
|
+
markerDiv.style.border = "2px solid blue";
|
|
93
|
+
markerDiv.style.borderRadius = "10px";
|
|
94
|
+
markerDiv.style.width = "5px";
|
|
95
|
+
markerDiv.style.height = "5px";
|
|
96
|
+
markerDiv.style.margin = "-200px -200px";
|
|
97
|
+
markerDiv.style.zIndex = "100";
|
|
98
|
+
markerDiv.style.position = "absolute";
|
|
99
|
+
markerDiv.style.pointerEvents = "none";
|
|
100
|
+
|
|
101
|
+
this._markerDiv = markerDiv;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_destroyMarkerDiv() {
|
|
105
|
+
if (this._markerDiv) {
|
|
106
|
+
const element = document.getElementById('myMarkerDiv')
|
|
107
|
+
element.parentNode.removeChild(element)
|
|
108
|
+
this._markerDiv = null
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
_attachPlugin(distanceMeasurementsPlugin, cfg = {}) {
|
|
100
113
|
|
|
101
114
|
/**
|
|
@@ -161,6 +174,10 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
161
174
|
return;
|
|
162
175
|
}
|
|
163
176
|
|
|
177
|
+
if (!this._markerDiv) {
|
|
178
|
+
this._initMarkerDiv()
|
|
179
|
+
}
|
|
180
|
+
|
|
164
181
|
this.fire("activated", true);
|
|
165
182
|
|
|
166
183
|
const distanceMeasurementsPlugin = this.distanceMeasurementsPlugin;
|
|
@@ -316,6 +333,9 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
316
333
|
if (this.pointerLens) {
|
|
317
334
|
this.pointerLens.visible = false;
|
|
318
335
|
}
|
|
336
|
+
if (this._markerDiv) {
|
|
337
|
+
this._destroyMarkerDiv()
|
|
338
|
+
}
|
|
319
339
|
this.reset();
|
|
320
340
|
const canvas = this.scene.canvas.canvas;
|
|
321
341
|
canvas.removeEventListener("mousedown", this._onMouseDown);
|
|
@@ -342,6 +362,10 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
342
362
|
if (!this._active) {
|
|
343
363
|
return;
|
|
344
364
|
}
|
|
365
|
+
|
|
366
|
+
this._destroyMarkerDiv()
|
|
367
|
+
this._initMarkerDiv()
|
|
368
|
+
|
|
345
369
|
if (this._currentDistanceMeasurement) {
|
|
346
370
|
this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
|
|
347
371
|
this._currentDistanceMeasurement.destroy();
|
|
@@ -431,6 +431,15 @@ parsers[ParserV10.version] = ParserV10;
|
|
|
431
431
|
* myViewer.scene.setObjectVisibilities("myModel1#0BTBFw6f90Nfh9rP1dlXrb", true);
|
|
432
432
|
*````
|
|
433
433
|
*
|
|
434
|
+
* We can also provide an HTTP URL to the XKT file:
|
|
435
|
+
*
|
|
436
|
+
* ````javascript
|
|
437
|
+
* const sceneModel = xktLoader.load({
|
|
438
|
+
* manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
|
|
439
|
+
* id: "myModel",
|
|
440
|
+
* });
|
|
441
|
+
* ````
|
|
442
|
+
*
|
|
434
443
|
* # Loading a model from a manifest of XKT files
|
|
435
444
|
*
|
|
436
445
|
* The `ifc2gltf` tool from Creoox, which converts IFC files into glTF geometry and JSON metadata files, has the option to
|
|
@@ -517,6 +526,65 @@ parsers[ParserV10.version] = ParserV10;
|
|
|
517
526
|
* They work much reliably (and faster) when processing smaller files (eg. 20MB) than when processing large files (eg. 500MB), where
|
|
518
527
|
* they have less trouble allocating the system memory they need for conversion and parsing.
|
|
519
528
|
*
|
|
529
|
+
* We can also provide an HTTP URL to the manifest:
|
|
530
|
+
*
|
|
531
|
+
* ````javascript
|
|
532
|
+
* const sceneModel = xktLoader.load({
|
|
533
|
+
* manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt.manifest.json",
|
|
534
|
+
* id: "myModel",
|
|
535
|
+
* });
|
|
536
|
+
* ````
|
|
537
|
+
*
|
|
538
|
+
* We can also provide the manifest as parameter object:
|
|
539
|
+
*
|
|
540
|
+
* ````javascript
|
|
541
|
+
* const sceneModel = xktLoader.load({
|
|
542
|
+
* id: "myModel",
|
|
543
|
+
* manifest: {
|
|
544
|
+
* inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
|
|
545
|
+
* converterApplication: "convert2xkt",
|
|
546
|
+
* converterApplicationVersion: "v1.1.10",
|
|
547
|
+
* conversionDate": "09-11-2023- 18-29-01",
|
|
548
|
+
* xktFiles: [
|
|
549
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
|
|
550
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
|
|
551
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
|
|
552
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
|
|
553
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
|
|
554
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
|
|
555
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
|
|
556
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
|
|
557
|
+
* "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
|
|
558
|
+
* ]
|
|
559
|
+
* }
|
|
560
|
+
* });
|
|
561
|
+
* ````
|
|
562
|
+
*
|
|
563
|
+
* We can also provide the paths to the XKT files as HTTP URLs:
|
|
564
|
+
*
|
|
565
|
+
* ````javascript
|
|
566
|
+
* const sceneModel = xktLoader.load({
|
|
567
|
+
* id: "myModel",
|
|
568
|
+
* manifest: {
|
|
569
|
+
* inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
|
|
570
|
+
* converterApplication: "convert2xkt",
|
|
571
|
+
* converterApplicationVersion: "v1.1.10",
|
|
572
|
+
* conversionDate": "09-11-2023- 18-29-01",
|
|
573
|
+
* xktFiles: [
|
|
574
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
|
|
575
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
|
|
576
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
|
|
577
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
|
|
578
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
|
|
579
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
|
|
580
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
|
|
581
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
|
|
582
|
+
* "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
|
|
583
|
+
* ]
|
|
584
|
+
* }
|
|
585
|
+
* });
|
|
586
|
+
* ````
|
|
587
|
+
*
|
|
520
588
|
* @class XKTLoaderPlugin
|
|
521
589
|
*/
|
|
522
590
|
class XKTLoaderPlugin extends Plugin {
|
|
@@ -786,10 +854,14 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
786
854
|
*
|
|
787
855
|
* @param {*} params Loading parameters.
|
|
788
856
|
* @param {String} [params.id] ID to assign to the root {@link Entity#id}, unique among all components in the Viewer's {@link Scene}, generated automatically by default.
|
|
789
|
-
* @param {String} [params.src] Path to
|
|
857
|
+
* @param {String} [params.src] Path or URL to an *````.xkt````* file, as an alternative to the ````xkt```` parameter.
|
|
790
858
|
* @param {ArrayBuffer} [params.xkt] The *````.xkt````* file data, as an alternative to the ````src```` parameter.
|
|
791
|
-
* @param {String} [params.metaModelSrc] Path to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
|
|
859
|
+
* @param {String} [params.metaModelSrc] Path or URL to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
|
|
792
860
|
* @param {*} [params.metaModelData] JSON model metadata, as an alternative to the ````metaModelSrc```` parameter.
|
|
861
|
+
* @param {String} [params.manifestSrc] Path or URL to a JSON manifest file that provides paths to ````.xkt```` files to load as parts of the model. Use this option to load models that have been split into
|
|
862
|
+
* multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
|
|
863
|
+
* @param {Object} [params.manifest] A JSON manifest object (as an alternative to a path or URL) that provides paths to ````.xkt```` files to load as parts of the model. Use this option to load models that have been split into
|
|
864
|
+
* multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
|
|
793
865
|
* @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
|
|
794
866
|
* @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
795
867
|
* @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
@@ -825,8 +897,8 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
825
897
|
delete params.id;
|
|
826
898
|
}
|
|
827
899
|
|
|
828
|
-
if (!params.src && !params.xkt && !params.manifestSrc) {
|
|
829
|
-
this.error("load() param expected: src, xkt or
|
|
900
|
+
if (!params.src && !params.xkt && !params.manifestSrc && !params.manifest) {
|
|
901
|
+
this.error("load() param expected: src, xkt, manifestSrc or manifestData");
|
|
830
902
|
return sceneModel; // Return new empty model
|
|
831
903
|
}
|
|
832
904
|
|
|
@@ -954,8 +1026,8 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
954
1026
|
} else if (params.xkt) {
|
|
955
1027
|
this._parseModel(params.xkt, params, options, sceneModel, metaModel, manifestCtx);
|
|
956
1028
|
finish();
|
|
957
|
-
} else if (params.manifestSrc) {
|
|
958
|
-
const baseDir = getBaseDirectory(params.manifestSrc)
|
|
1029
|
+
} else if (params.manifestSrc || params.manifest) {
|
|
1030
|
+
const baseDir = params.manifestSrc ? getBaseDirectory(params.manifestSrc) : "";
|
|
959
1031
|
const loadJSONs = (metaDataFiles, done, error) => {
|
|
960
1032
|
let i = 0;
|
|
961
1033
|
const loadNext = () => {
|
|
@@ -975,7 +1047,6 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
975
1047
|
}
|
|
976
1048
|
loadNext();
|
|
977
1049
|
}
|
|
978
|
-
|
|
979
1050
|
const loadXKTs = (xktFiles, done, error) => {
|
|
980
1051
|
let i = 0;
|
|
981
1052
|
const loadNext = () => {
|
|
@@ -991,11 +1062,8 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
991
1062
|
}
|
|
992
1063
|
loadNext();
|
|
993
1064
|
};
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
if (sceneModel.destroyed) {
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
1065
|
+
if (params.manifest) {
|
|
1066
|
+
const manifestData = params.manifest;
|
|
999
1067
|
const xktFiles = manifestData.xktFiles;
|
|
1000
1068
|
if (!xktFiles || xktFiles.length === 0) {
|
|
1001
1069
|
error(`load(): Failed to load model manifest - manifest not valid`);
|
|
@@ -1009,7 +1077,26 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
1009
1077
|
} else {
|
|
1010
1078
|
loadXKTs(xktFiles, finish, error);
|
|
1011
1079
|
}
|
|
1012
|
-
}
|
|
1080
|
+
} else {
|
|
1081
|
+
this._dataSource.getManifest(params.manifestSrc, (manifestData) => {
|
|
1082
|
+
if (sceneModel.destroyed) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
const xktFiles = manifestData.xktFiles;
|
|
1086
|
+
if (!xktFiles || xktFiles.length === 0) {
|
|
1087
|
+
error(`load(): Failed to load model manifest - manifest not valid`);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
const metaModelFiles = manifestData.metaModelFiles;
|
|
1091
|
+
if (metaModelFiles) {
|
|
1092
|
+
loadJSONs(metaModelFiles, () => {
|
|
1093
|
+
loadXKTs(xktFiles, finish, error);
|
|
1094
|
+
}, error);
|
|
1095
|
+
} else {
|
|
1096
|
+
loadXKTs(xktFiles, finish, error);
|
|
1097
|
+
}
|
|
1098
|
+
}, error);
|
|
1099
|
+
}
|
|
1013
1100
|
}
|
|
1014
1101
|
}
|
|
1015
1102
|
|
|
@@ -2654,7 +2654,7 @@ class Scene extends Component {
|
|
|
2654
2654
|
* - it runs maximum once per scene-tick
|
|
2655
2655
|
*
|
|
2656
2656
|
* @param {Function} cb The function to tickify
|
|
2657
|
-
* @returns {Function
|
|
2657
|
+
* @returns {Function}
|
|
2658
2658
|
*/
|
|
2659
2659
|
tickify(cb) {
|
|
2660
2660
|
const cbString = cb.toString();
|