@vitrosoftware/common-ui-ts 1.1.80 → 1.1.82

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.
@@ -1,13 +1,13 @@
1
- import { BIMModel, BIMCommon, BIMAnnotation } from '/resource/bimViewer/js/bim-viewer-models.js';
1
+ import { BIMModel, BIMCommon, BIMAnnotation } from '/resource/bimViewer/js/bim-viewer-models.js?version=v5';
2
2
 
3
3
  import {
4
4
  Viewer, XKTLoaderPlugin, NavCubePlugin, SectionPlanesPlugin, math, BCFViewpointsPlugin, AnnotationsPlugin,
5
5
  ContextMenu, TreeViewPlugin, StoreyViewsPlugin, AngleMeasurementsPlugin, CameraMemento, DistanceMeasurementsPlugin,
6
- GLTFLoaderPlugin, utils
6
+ GLTFLoaderPlugin, utils, FastNavPlugin
7
7
  }
8
- from '/resource/bimViewer/js/xeokit/xeokit-sdk.es.js';
9
- import { VitroTreeViewPlugin } from "/resource/bimViewer/js/xeokit/VitroTreeViewPlugin.js";
10
- import { VitroFastNavPlugin } from "/resource/bimViewer/js/xeokit/VitroFastNavPlugin.js";window.initBimViewer = function(context) {var angleMeasurementsData = [
8
+ from '/resource/bimViewer/js/xeokit/xeokit-sdk.es.js?version=v5';
9
+ import { VitroTreeViewPlugin } from "/resource/bimViewer/js/xeokit/VitroTreeViewPlugin.js?version=v5";
10
+ window.initBimViewer = function(context) {var angleMeasurementsData = [
11
11
 
12
12
  ];
13
13
  var bcfData = {};
@@ -98,6 +98,10 @@ const canvasContextMenu = new ContextMenu({
98
98
  },
99
99
  doAction: function (context) {
100
100
  context.viewer.scene.setObjectsVisible(context.viewer.scene.visibleObjectIds, false);
101
+
102
+ if (context.treeViewPlugin) {
103
+ context.treeViewPlugin.setCheckedAll(false);
104
+ }
101
105
  }
102
106
  },
103
107
  {
@@ -111,6 +115,10 @@ const canvasContextMenu = new ContextMenu({
111
115
  scene.setObjectsVisible(scene.objectIds, true);
112
116
  scene.setObjectsXRayed(scene.xrayedObjectIds, false);
113
117
  scene.setObjectsSelected(scene.selectedObjectIds, false);
118
+
119
+ if (context.treeViewPlugin) {
120
+ context.treeViewPlugin.setCheckedAll(true);
121
+ }
114
122
  }
115
123
  }
116
124
  ],
@@ -133,7 +141,7 @@ const objectContextMenu = new ContextMenu({
133
141
  {
134
142
  getTitle: function (context) { return document.webL10n.get('inspect_properties') },
135
143
  doAction: function (context) {
136
- if(context.entity && context.entity.id) {
144
+ if (context.entity && context.entity.id) {
137
145
  showPropertyInspector(context);
138
146
  }
139
147
  }
@@ -167,7 +175,11 @@ const objectContextMenu = new ContextMenu({
167
175
  doAction: function (context) {
168
176
  const objectId = context.entity.id;
169
177
 
170
- context.treeViewPlugin.showInTree(objectId);
178
+ if (!$('#btnToggleSidebarTreeView').hasClass('toggled')) {
179
+ $('#btnToggleSidebarTreeView').toggleClass('toggled');
180
+ openSidebarTreeView();
181
+ }
182
+ context.treeViewPlugin.showInTree(objectId);
171
183
  }
172
184
  }
173
185
  ],
@@ -327,7 +339,8 @@ viewer.cameraControl.on("rightClick", function (e) {
327
339
  } else {
328
340
 
329
341
  canvasContextMenu.context = { // Must set context before showing menu
330
- viewer: viewer
342
+ viewer: viewer,
343
+ treeViewPlugin: treeView,
331
344
  };
332
345
 
333
346
  canvasContextMenu.show(e.event.pageX, e.event.pageY);
@@ -359,11 +372,10 @@ const sectionPlanes = new SectionPlanesPlugin(viewer, {
359
372
  });
360
373
 
361
374
  //------------------------------------------------------------------------------------------------------------------
362
- // Add a GLTFModelsPlugin - we'll use this to load the model geometry and IFC metadata
375
+ // Add a XKTLoaderPlugin - we'll use this to load the model geometry and IFC metadata
363
376
  //------------------------------------------------------------------------------------------------------------------
364
377
 
365
378
  const xktLoader = new XKTLoaderPlugin(viewer);
366
- const gltfLoader = new GLTFLoaderPlugin(viewer);
367
379
 
368
380
 
369
381
  xktLoader.globalizeObjectIds = false; // For multiple models in TreeView
@@ -436,7 +448,7 @@ function addModelToTreeView() {
436
448
  viewer.scene.canvas.spinner.processes--;
437
449
  };
438
450
 
439
- BIMModel.GetChildList(-1, false, null, callback, error);
451
+ BIMModel.GetChildList("-1", false, null, callback, error);
440
452
  }
441
453
 
442
454
  //------------------------------------------------------------------------------------------------------------------
@@ -499,7 +511,7 @@ function doLoadModel() {
499
511
 
500
512
 
501
513
 
502
- const vitroFastNavPlugin = new VitroFastNavPlugin(viewer, {
514
+ const fastNavPlugin = new FastNavPlugin(viewer, {
503
515
  hideEdges: true, // Don't show edges while we interact (default is true)
504
516
  hideSAO: true, // Don't show ambient shadows while we interact (default is true)
505
517
  hideColorTexture: true, // No color textures while we interact (default is true)
@@ -1645,43 +1657,22 @@ function compareModels(isSideBySide) {
1645
1657
  var modelUrl = compareModelUrl + disableCacheStr;
1646
1658
  var metaModelDataUrl = fileItem.MetaModelDataPath + disableCacheStr;
1647
1659
 
1648
- getJSON(compareModelUrl, metaModelDataUrl, function(data) {
1649
-
1650
- window.model2DataUrl = metaModelDataUrl;
1651
-
1652
- var settings = {
1653
- id: Date.now(),
1654
- src: modelUrl,
1655
- metaModelJSON: data,
1656
- edges: true,
1657
- performance: true,
1658
- position: [0, 0, 0]
1659
- };
1660
-
1661
- if (isSideBySide) {
1662
- settings.position = [-55, 0, 0];
1663
- }
1664
-
1665
- var model2 = undefined;
1666
- if (srcModel.endsWith('.xkt')) {
1667
- model2 = xktLoader.load(settings);
1668
- } else {
1669
- model2 = gltfLoader.load(settings);
1670
- }
1660
+ var settings = {
1661
+ id: Date.now(),
1662
+ src: modelUrl,
1663
+ edges: true,
1664
+ performance: true,
1665
+ position: [0, 0, 0]
1666
+ };
1671
1667
 
1672
- var metaObj = data.metaObjects;
1673
- var result = [];
1674
- for (var id in metaObj) {
1675
- if (!metaObj.hasOwnProperty(id)) continue;
1676
- result[metaObj[id].id] = metaObj[id];
1677
- }
1678
- window.model2 = model2;
1679
- window.model2.customMeta = result;
1668
+ if (isSideBySide) {
1669
+ settings.position = [-55, 0, 0];
1670
+ }
1680
1671
 
1681
- model2.on('loaded', () => {
1682
- viewer.scene.canvas.spinner.processes++;
1683
- doCompareModels(isSideBySide);
1684
- });
1672
+ window.model2 = xktLoader.load(settings);
1673
+ window.model2.on('loaded', () => {
1674
+ viewer.scene.canvas.spinner.processes++;
1675
+ doCompareModels(isSideBySide);
1685
1676
  });
1686
1677
  }
1687
1678
 
@@ -2075,18 +2066,63 @@ function getPickResultModelId(pickResult) {
2075
2066
  }
2076
2067
  }
2077
2068
 
2069
+ function getPropertyValue(property) {
2070
+ if (property.value_bool != null && property.value_bool != undefined) {
2071
+ return property.value_bool;
2072
+ }
2073
+ else if (property.value_int != null && property.value_int != undefined) {
2074
+ return property.value_int;
2075
+ }
2076
+ else if (property.value_text != null && property.value_text != undefined) {
2077
+ return property.value_text;
2078
+ }
2079
+ else if (property.value_real != null && property.value_real != undefined) {
2080
+ return property.value_real;
2081
+ }
2082
+ }
2083
+
2084
+ function convertProperty(data) {
2085
+ let groups = [];
2086
+
2087
+ for (let property of data) {
2088
+ let existingGroups = groups.filter(group => group.name == property.group_name);
2089
+ if (existingGroups.length > 0) {
2090
+ existingGroups[0].properties.push({ name: property.name, value: getPropertyValue(property) });
2091
+ }
2092
+ else {
2093
+ let newGroup = {
2094
+ name: property.group_name,
2095
+ properties: [],
2096
+ };
2097
+ newGroup.properties.push({ name: property.name, value: getPropertyValue(property) });
2098
+
2099
+
2100
+ groups.push(newGroup);
2101
+ }
2102
+ }
2103
+
2104
+ return groups;
2105
+ }
2106
+
2078
2107
  function setPropertyBDSets(id, version) {
2079
2108
  const html = [];
2080
-
2109
+
2081
2110
  html.push('<div class="element-attributes">');
2082
2111
  html.push('</div>');
2083
2112
 
2084
- BIMModel.GetPropertyList(id,
2085
- (propertySets) => {
2086
- addPropertySet(propertySets, html);
2087
- });
2088
-
2113
+ viewer.scene.canvas.spinner.processes++;
2089
2114
 
2115
+ BIMModel.GetPropertyList(id,
2116
+ (data) => {
2117
+ const propertySets = convertProperty(data);
2118
+ addPropertySet(propertySets, html);
2119
+ viewer.scene.canvas.spinner.processes--;
2120
+ },
2121
+ (error) => {
2122
+ viewer.scene.canvas.spinner.processes--;
2123
+ }
2124
+ );
2125
+
2090
2126
  $('#propInspector .prop-inspector-content')[0].innerHTML = html.join("");
2091
2127
  $('.xeokit-accordion-container').accordion({
2092
2128
  collapsible: true,
@@ -2177,104 +2213,10 @@ function initPropertySetsResizable() {
2177
2213
  //
2178
2214
  //------------------------------------------------------------------------------------------------------------------
2179
2215
 
2180
- BIMCommon.GetFileItem = (callback) => {
2181
-
2182
- const item = {
2183
- ModelPath: context.filePath,
2184
- SiteId: context.file.siteId,
2185
- ListId: context.file.listId,
2186
- UniqueId: context.file.id,
2187
- FileVersionList: [],
2188
- Path: context.filePath,
2189
- ...context.file
2190
- };
2191
-
2192
- if (callback) {
2193
- callback(item);
2194
- }
2195
- }
2196
-
2197
- BIMCommon.CreateWebServerUrl = () => {
2198
- return 'http://79.143.70.197/Design';
2199
- };
2200
-
2201
2216
  BIMAnnotation.GetNote = (callback) => {
2202
2217
  callback([]);
2203
2218
  }
2204
2219
 
2205
- BIMModel.GetParentIdList = (elementId, recurse, isGeometry, callback) => {
2206
- context.getParentIdList(elementId).then(res => {
2207
- if (callback) {
2208
- callback(res);
2209
- }
2210
- })
2211
- }
2212
-
2213
- BIMModel.GetPropertyList = (elementId, callback) => {
2214
-
2215
- const getValue = (property) => {
2216
- if (property.ValueBool != null && property.ValueBool != undefined) {
2217
- return property.ValueBool;
2218
- }
2219
- else if (property.ValueInt != null && property.ValueInt != undefined) {
2220
- return property.ValueInt;
2221
- }
2222
- else if (property.ValueText != null && property.ValueText != undefined) {
2223
- return property.ValueText;
2224
- }
2225
- else if (property.ValueReal != null && property.ValueReal != undefined) {
2226
- return property.ValueReal;
2227
- }
2228
- }
2229
-
2230
- context.getPropertyList(elementId).then(res => {
2231
- let groups = [];
2232
-
2233
- for (let property of res) {
2234
- let existingGroups = groups.filter(group => group.name == property.GroupName);
2235
- if (existingGroups.length > 0) {
2236
- existingGroups[0].properties.push({ name: property.Name, value: getValue(property) });
2237
- }
2238
- else {
2239
- let newGroup = {
2240
- name: property.GroupName,
2241
- properties: [],
2242
- };
2243
- newGroup.properties.push({ name: property.Name, value: getValue(property) });
2244
-
2245
-
2246
- groups.push(newGroup);
2247
- }
2248
- }
2249
-
2250
- callback(groups);
2251
- })
2252
- }
2253
-
2254
- BIMModel.GetChildList = (elementId, recurse, isGeometry, callback) => {
2255
- let data = {
2256
- recurse: recurse,
2257
- isGeometry: isGeometry
2258
- }
2259
- context.getChildList(elementId, data).then(res => {
2260
- if (callback) {
2261
- callback(res);
2262
- }
2263
- });
2264
- }
2265
-
2266
- BIMModel.GetChildIdList = (elementId, recurse, isGeometry, callback) => {
2267
- let data = {
2268
- recurse: recurse,
2269
- isGeometry: isGeometry
2270
- };
2271
- context.getChildIdList(elementId, data).then(res => {
2272
- if (callback) {
2273
- callback(res);
2274
- }
2275
- });
2276
- }
2277
-
2278
2220
  function saveNote(pickResult) {
2279
2221
 
2280
2222
  }
@@ -2330,6 +2272,7 @@ function bindBtnToggleCreateNotes() {
2330
2272
  annotationByClick = true;
2331
2273
  } else {
2332
2274
  annotationByClick = false;
2275
+ collapseSidebarIssueDetail();
2333
2276
  }
2334
2277
  });
2335
2278
  }
@@ -2346,14 +2289,18 @@ function bindBtnToggleSidebarNotes() {
2346
2289
  expandSidebarNotes();
2347
2290
  }
2348
2291
  } else {
2349
- $('#navCubeCanvas').css('right', 10);
2350
- $('#sectionPlanesOverviewCanvas').css('right', 10);
2351
- $('.sidebar').hide();
2352
- $('body').removeClass('sidebar-expanded');
2292
+ collapseSidebarNotes();
2353
2293
  }
2354
2294
  });
2355
2295
  }
2356
2296
 
2297
+ function bindSidebarNotesClose() {
2298
+ $('.sidebar-close').on('click', function () {
2299
+ $('#btnToggleSidebarNotes').removeClass('toggled');
2300
+ collapseSidebarNotes();
2301
+ });
2302
+ }
2303
+
2357
2304
  function expandSidebarNotes() {
2358
2305
  hidePropInspector();
2359
2306
  collapseSidebarIssueDetail();
@@ -2448,10 +2395,12 @@ function updatePage(e) {
2448
2395
  }
2449
2396
 
2450
2397
  function goToNoteMarker(issue) {
2451
- var annotation = annotations.annotations[issue.id];
2452
- console.log('annotation', annotation);
2453
- viewer.cameraFlight.flyTo(annotation);
2454
- highlightSidebarNote(issue.id);
2398
+ if (!$('#btnCreateNotes').hasClass('toggled')) {
2399
+ var annotation = annotations.annotations[issue.id];
2400
+ console.log('annotation', annotation);
2401
+ viewer.cameraFlight.flyTo(annotation);
2402
+ highlightSidebarNote(issue.id);
2403
+ }
2455
2404
  }
2456
2405
 
2457
2406
  function onIssueShowMoreClick(issue) {
@@ -2478,6 +2427,7 @@ function onIssueShowMoreClick(issue) {
2478
2427
  }
2479
2428
 
2480
2429
  function collapseSidebarNotes() {
2430
+ $('#sidebarWrap').hide();
2481
2431
  $('#navCubeCanvas').css('right', 10);
2482
2432
  $('#sectionPlanesOverviewCanvas').css('right', 10);
2483
2433
  $('.sidebar').hide();
@@ -2576,6 +2526,33 @@ function createSidebarNotesItemHeader(noteData) {
2576
2526
  function hidePropInspector() {
2577
2527
  $('#propInspector').hide();
2578
2528
  }
2529
+
2530
+ function compareModels(isSideBySide) {
2531
+
2532
+ var version = context.fileVersionList[0];
2533
+
2534
+ var disableCacheStr = getDisableCacheStr();
2535
+ var compareModelUrl = context.getFilePath(context.file.id, version.name);
2536
+ var modelUrl = compareModelUrl + disableCacheStr;
2537
+
2538
+ var settings = {
2539
+ id: Date.now(),
2540
+ src: modelUrl,
2541
+ edges: true,
2542
+ performance: true,
2543
+ position: [0, 0, 0]
2544
+ };
2545
+
2546
+ if (isSideBySide) {
2547
+ settings.position = [-55, 0, 0];
2548
+ }
2549
+
2550
+ window.model2 = xktLoader.load(settings);
2551
+ window.model2.on('loaded', () => {
2552
+ viewer.scene.canvas.spinner.processes++;
2553
+ doCompareModels(isSideBySide);
2554
+ });
2555
+ }
2579
2556
 
2580
2557
  //------------------------------------------------------------------------------------------------------------------
2581
2558
  // Do action wherever we click on an object
@@ -2618,33 +2595,30 @@ viewer.cameraControl.on("picked", (pickResult) => {
2618
2595
 
2619
2596
  window.viewer = viewer;
2620
2597
 
2621
- BIMCommon.GetFileItem(function (res) {
2622
- BIMCommon.FileItem = res;
2598
+ let version = context.fileVersionList.find(x => x.id === context.versionId);
2599
+ let versionStr = version ? version.name : null;
2623
2600
 
2624
- var fileItem = BIMCommon.FileItem;
2601
+ BIMCommon.GetFileItem(context.file.id, versionStr, function (modelId) {
2625
2602
 
2626
- var versionList = BIMCommon.FileItem.FileVersionList;
2627
- if (versionList.length == 0) {
2628
- $('#btnToggleCompare').hide();
2629
- } else {
2630
- $('#btnToggleCompare').show();
2631
- }
2603
+ context.getItem(modelId).then(item => {
2604
+ var filePath = context.getFilePath(item.id);
2605
+ var fileName = context.file.fieldValueMap?.name;
2606
+
2607
+ document.title += " - " + fileName;
2608
+ srcModel = filePath;
2609
+ srcMetaModelData = '';
2610
+ fileVersion = '';
2611
+ fileVersionPath = filePath;
2612
+ hideXeokitSpinner();
2613
+ doLoadModel();
2632
2614
 
2633
- var filePath = fileItem.Path;
2634
- var fileName = context.file.fieldValueMap?.name;
2635
2615
 
2636
- document.title += " - " + fileName;
2616
+ BIMCommon.FileVersion = versionStr;
2617
+ BIMCommon.FileItemId = context.file.id;
2618
+ })
2637
2619
 
2638
- if (fileItem.FileVersion)
2639
- {
2640
- $('#fileVersion').text("[v" + fileItem.FileVersion + "]");
2641
- }
2642
- srcModel = fileItem.ModelPath;
2643
- srcMetaModelData = fileItem.MetaModelDataPath;
2644
- fileVersion = fileItem.FileVersion;
2645
- fileVersionPath = filePath;
2646
- hideXeokitSpinner();
2647
- doLoadModel();
2620
+ }, function () {
2621
+ alert("The file is being processed");
2648
2622
  });
2649
2623
 
2650
2624
  function init() {
@@ -1,7 +1,7 @@
1
1
  async function initHtml() {
2
2
  let htmlContainer = document.getElementsByTagName('html')[0];
3
3
  htmlContainer.dir = 'ltr';
4
- const resp = await fetch('resource/bimViewer/viewer.html?version=v2');
4
+ const resp = await fetch('resource/bimViewer/viewer.html?version=v5');
5
5
  const viewer = await resp.text();
6
6
  let container = document.getElementsByTagName('body')[0];
7
7
  container.insertAdjacentHTML('beforeend', viewer);
@@ -9,15 +9,15 @@ async function initHtml() {
9
9
 
10
10
  async function initPage() {
11
11
  let container = document.getElementsByTagName('head')[0];
12
- container.innerHTML += '<link rel="resource" type="application/l10n" href="resource/bimViewer/locale/locale.js?version=v2">';
13
- container.innerHTML += '<link href="/resource/bimViewer/css/bim-viewer.css?version=v2" rel="stylesheet">';
12
+ container.innerHTML += '<link rel="resource" type="application/l10n" href="resource/bimViewer/locale/locale.js?version=v5">';
13
+ container.innerHTML += '<link href="/resource/bimViewer/css/bim-viewer.css?version=v5" rel="stylesheet">';
14
14
 
15
15
  await initHtml();
16
16
 
17
17
  const script = document.createElement('script');
18
18
  script.type = 'module';
19
19
  script.id = 'bim-viewer';
20
- script.src = 'resource/bimViewer/js/bim-viewer.js?version=v2';
20
+ script.src = 'resource/bimViewer/js/bim-viewer.js?version=v5';
21
21
  document.head.appendChild(script);
22
22
  }
23
23