@smarterplan/ngx-smarterplan-core 1.4.21 → 1.4.23

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 (46) hide show
  1. package/esm2022/lib/components/csv-export/csv-export.component.mjs +8 -4
  2. package/esm2022/lib/components/menu-bar/menu-bar.component.mjs +11 -7
  3. package/esm2022/lib/components/splat-viewer/splat-viewer.component.mjs +361 -0
  4. package/esm2022/lib/helpers.service.mjs +34 -1
  5. package/esm2022/lib/ngx-smarterplan-core.module.mjs +14 -5
  6. package/esm2022/lib/services/matterport-object3d.service.mjs +1 -1
  7. package/esm2022/lib/services/matterport-tag.service.mjs +12 -7
  8. package/esm2022/lib/services/models/plan.service.mjs +46 -17
  9. package/esm2022/lib/services/models/ticket.service.mjs +7 -6
  10. package/esm2022/lib/services/obj-to-glb.mjs +649 -0
  11. package/esm2022/lib/services/s3.service.mjs +43 -3
  12. package/esm2022/lib/services/threejs-import.service.mjs +6 -4
  13. package/esm2022/lib/services/threejs.service.mjs +867 -95
  14. package/esm2022/lib/services/utils/matterport-framing.util.mjs +1 -1
  15. package/esm2022/lib/services/viewer.service.mjs +189 -7
  16. package/esm2022/lib/services/zone-drawer.service.mjs +3 -3
  17. package/esm2022/lib/types.service.mjs +1 -1
  18. package/esm2022/public-api.mjs +3 -1
  19. package/fesm2022/smarterplan-ngx-smarterplan-core.mjs +2312 -236
  20. package/fesm2022/smarterplan-ngx-smarterplan-core.mjs.map +1 -1
  21. package/lib/components/csv-export/csv-export.component.d.ts +1 -0
  22. package/lib/components/menu-bar/menu-bar.component.d.ts +1 -0
  23. package/lib/components/splat-viewer/splat-viewer.component.d.ts +98 -0
  24. package/lib/helpers.service.d.ts +28 -0
  25. package/lib/ngx-smarterplan-core.module.d.ts +8 -6
  26. package/lib/services/matterport-tag.service.d.ts +5 -5
  27. package/lib/services/models/plan.service.d.ts +10 -1
  28. package/lib/services/models/ticket.service.d.ts +5 -5
  29. package/lib/services/obj-to-glb.d.ts +66 -0
  30. package/lib/services/s3.service.d.ts +7 -0
  31. package/lib/services/threejs.service.d.ts +336 -16
  32. package/lib/services/viewer.service.d.ts +110 -8
  33. package/package.json +2 -1
  34. package/public-api.d.ts +2 -0
  35. package/src/assets/viewers/splat/chunk-BYLI4YBI.js +17037 -0
  36. package/src/assets/viewers/splat/chunk-LDV6YPMG.js +1 -0
  37. package/src/assets/viewers/splat/chunk-WZ5Z4TU3.js +105719 -0
  38. package/src/assets/viewers/splat/convert-4DRLH77X.js +1 -0
  39. package/src/assets/viewers/splat/convert.html +11 -0
  40. package/src/assets/viewers/splat/converter-SLBB5MHG.js +1 -0
  41. package/src/assets/viewers/splat/index.html +90 -0
  42. package/src/assets/viewers/splat/spz-DEYRea_v-QE6YSGIB.js +5292 -0
  43. package/src/assets/viewers/splat/viewer-W4X3FWQJ.js +2704 -0
  44. package/src/assets/viewers/splat/viewer.css +1096 -0
  45. package/src/assets/viewers/splat/webp.wasm +0 -0
  46. package/src/assets/viewers/splat/worker.mjs +1383 -0
@@ -1,12 +1,14 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Input, Component, InjectionToken, Inject, EventEmitter, isDevMode, Output, Pipe, ViewChild, NgModule } from '@angular/core';
3
- import * as i1 from '@ngx-translate/core';
2
+ import { Injectable, InjectionToken, Inject, EventEmitter, isDevMode, Input, Component, Output, Pipe, ViewChild, HostListener, NgModule } from '@angular/core';
3
+ import * as i1$1 from '@ngx-translate/core';
4
4
  import { TranslateModule } from '@ngx-translate/core';
5
- import { Subject, BehaviorSubject, takeUntil, Observable } from 'rxjs';
5
+ import AdjustIcon from '@iconify/icons-mdi/adjust';
6
+ import CloseCircleOutlineIcon from '@iconify/icons-mdi/close-circle-outline';
6
7
  import * as i1$2 from '@ng-bootstrap/ng-bootstrap';
7
8
  import { NgbDate, NgbModule } from '@ng-bootstrap/ng-bootstrap';
8
- import * as i1$1 from '@angular/router';
9
+ import * as i1 from '@angular/router';
9
10
  import { RouterModule } from '@angular/router';
11
+ import { Subject, BehaviorSubject, takeUntil, Observable } from 'rxjs';
10
12
  import * as THREE from 'three';
11
13
  import { Matrix4, Vector3, Color, Object3D, Euler, PerspectiveCamera, CylinderBufferGeometry, BoxGeometry, MeshBasicMaterial, NormalBlending, BackSide, Mesh, EdgesGeometry, AdditiveBlending, ShaderMaterial, AnimationMixer, VectorKeyframeTrack, InterpolateSmooth, AnimationClip, LoopOnce, Group, PlaneBufferGeometry, CanvasTexture, Texture, LinearFilter, Box3, MathUtils } from 'three';
12
14
  import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
@@ -24,20 +26,25 @@ import { Line2 } from 'three/examples/jsm/lines/Line2';
24
26
  import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry';
25
27
  import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial';
26
28
  import * as FileSaver from 'file-saver';
29
+ import fileDownloadIcon from '@iconify/icons-mdi/file-download-outline';
30
+ import * as i1$3 from '@abhinavakhil/iconify-angular';
31
+ import { IconModule } from '@abhinavakhil/iconify-angular';
27
32
  import levenshtein from 'js-levenshtein';
28
33
  import { GlobalWorkerOptions, getDocument } from 'pdfjs-dist';
29
34
  import panzoom from 'panzoom';
30
35
  import videojs from 'video.js';
36
+ import UserPositionIcon from '@iconify/icons-mdi/human-male';
31
37
  import InformationIcon from '@iconify/icons-mdi/information-outline';
32
38
  import AccidentIcon from '@iconify/icons-mdi/alert';
33
39
  import WordOrderIcon from '@iconify/icons-mdi/account-hard-hat';
34
40
  import ReportingIcon from '@iconify/icons-mdi/file-document-outline';
35
41
  import MaintenanceIcon from '@iconify/icons-mdi/tools';
36
42
  import { first } from 'rxjs/operators';
37
- import * as i1$3 from '@angular/platform-browser';
43
+ import * as i1$4 from '@angular/platform-browser';
38
44
  import { Observable as Observable$1 } from 'rxjs/internal/Observable';
39
45
  import * as i3 from '@angular/forms';
40
46
  import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
47
+ import checkIcon from '@iconify/icons-mdi/check';
41
48
  import * as CryptoJS from 'crypto-js';
42
49
  import { v4 } from 'uuid';
43
50
 
@@ -53,60 +60,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
53
60
  }]
54
61
  }], ctorParameters: () => [] });
55
62
 
56
- class CsvExportComponent {
57
- /** Header of the CSV, titles for each columns */
58
- headers = [];
59
- /** Array of each rows (array of array of string), if it's not set, then the function getRows() will be used */
60
- rowsInput = undefined;
61
- /** Function used to get rows if rowsInput is not set, call each time the user click on the button to generate the CSV file */
62
- getRows = undefined;
63
- /** Title of the file to download */
64
- title = "file";
65
- /** Label for the button to click */
66
- buttonLabel = "Export";
67
- /** Delimiter for the CSV */
68
- delimeter = ";";
69
- async onClickDownload() {
70
- let rows = this.rowsInput;
71
- if (!rows) {
72
- rows = await Promise.resolve(this.getRows());
73
- }
74
- const data = `data:text/csv;charset=utf-8,${this.headers.join(this.delimeter)}\n${rows
75
- .map((row) =>
76
- /** Clean each rows/cells */
77
- row
78
- .map((value) => value
79
- .replace(this.delimeter, " ")
80
- .replace("\n", " ")
81
- .replace("\r", " "))
82
- .join(this.delimeter))
83
- .join("\n")}`;
84
- /** Create a link to download the file */
85
- const link = document.createElement("a");
86
- link.setAttribute("href", encodeURI(data));
87
- link.setAttribute("download", `${this.title}.csv`);
88
- document.body.append(link);
89
- link.click();
90
- link.remove();
91
- }
92
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CsvExportComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
93
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CsvExportComponent, selector: "lib-csv-export", inputs: { headers: "headers", rowsInput: "rowsInput", getRows: "getRows", title: "title", buttonLabel: "buttonLabel" }, ngImport: i0, template: "<span [style.cursor]=\"'pointer'\" (click)=\"onClickDownload()\" class=\"download-csv d-flex\">\r\n <span class=\"iconify\" data-icon=\"mdi:file-download-outline\"></span>\r\n {{ buttonLabel | translate}}\r\n</span>\r\n", styles: [".download-csv{color:var(--smarterplan-primary)}\n"], dependencies: [{ kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
94
- }
95
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CsvExportComponent, decorators: [{
96
- type: Component,
97
- args: [{ selector: 'lib-csv-export', template: "<span [style.cursor]=\"'pointer'\" (click)=\"onClickDownload()\" class=\"download-csv d-flex\">\r\n <span class=\"iconify\" data-icon=\"mdi:file-download-outline\"></span>\r\n {{ buttonLabel | translate}}\r\n</span>\r\n", styles: [".download-csv{color:var(--smarterplan-primary)}\n"] }]
98
- }], propDecorators: { headers: [{
99
- type: Input
100
- }], rowsInput: [{
101
- type: Input
102
- }], getRows: [{
103
- type: Input
104
- }], title: [{
105
- type: Input
106
- }], buttonLabel: [{
107
- type: Input
108
- }] } });
109
-
110
63
  /**
111
64
  * Injection token holding the Matterport SDK application key.
112
65
  * Each consuming app must provide its own value via its environment file
@@ -1095,22 +1048,62 @@ const uploadFileToS3 = async (path, file, objectId) => {
1095
1048
  return result.key;
1096
1049
  });
1097
1050
  };
1051
+ /**
1052
+ * Fetches fresh credentials, and says in the console how long the ones held had left: when an
1053
+ * upload is refused, this is what tells why.
1054
+ */
1055
+ const renewCredentials = async () => {
1056
+ try {
1057
+ const held = await Auth.currentCredentials();
1058
+ const left = held?.expiration ? new Date(held.expiration).getTime() - Date.now() : 0;
1059
+ console.info(`[upload] credentials held expire in ${Math.round(left / 60000)} min, fetching new ones`);
1060
+ // What Amplify itself does on signing in. Nobody signs in here through a federated provider,
1061
+ // whose stored sign-in this would also drop.
1062
+ await Auth.Credentials.clear();
1063
+ await Auth.currentCredentials();
1064
+ }
1065
+ catch (error) {
1066
+ // The upload will say what is wrong, if anything is.
1067
+ console.warn("[upload] could not renew the credentials:", error);
1068
+ }
1069
+ };
1070
+ const isExpiredTokenError = (error) => /ExpiredToken|token has expired/i.test(`${error?.name ?? ""} ${error?.Code ?? ""} ${error?.message ?? error ?? ""}`);
1098
1071
  /**
1099
1072
  * Uploads a file, reporting progress as a 0-1 fraction.
1100
1073
  *
1101
1074
  * uploadFileToS3 above swallows progress, which is fine for a photo and unusable for a 3D model:
1102
1075
  * these run to hundreds of megabytes, and an upload with no feedback is indistinguishable from a
1103
1076
  * frozen page. Returns the stored key, which is what gets saved on the record.
1077
+ *
1078
+ * A large file is sent in parts, each signed when it is sent. Left to itself, Storage.put signs
1079
+ * them all with whatever credentials Amplify last handed the S3 provider, for any call - credentials
1080
+ * that last an hour at most, and an upload of a few gigabytes takes longer: every part after they
1081
+ * expire is refused with "The provided token has expired", and fetching new ones does not help, the
1082
+ * upload never asks for them. Passing no credentials at all makes it ask Amplify for them part by
1083
+ * part, and Amplify renews them as they age. Should they run out anyway, it starts once more.
1104
1084
  */
1105
1085
  const uploadFileToS3WithProgress = async (path, file, onProgress) => {
1106
- return Storage.put(path + file.name, file, {
1086
+ const put = () => Storage.put(path + file.name, file, {
1107
1087
  contentType: file.type || "application/octet-stream",
1088
+ // Present and empty, so that it replaces the provider's own; see above.
1089
+ credentials: undefined,
1108
1090
  progressCallback(progress) {
1109
1091
  if (onProgress && progress.total > 0) {
1110
1092
  onProgress(progress.loaded / progress.total);
1111
1093
  }
1112
1094
  },
1113
1095
  }).then((result) => result.key);
1096
+ try {
1097
+ return await put();
1098
+ }
1099
+ catch (error) {
1100
+ if (!isExpiredTokenError(error)) {
1101
+ throw error;
1102
+ }
1103
+ console.warn("[upload] refused, the token had expired; starting again with new credentials", error);
1104
+ await renewCredentials();
1105
+ return put();
1106
+ }
1114
1107
  };
1115
1108
  const getSignedImageUrlForEquipment = async (equip) => {
1116
1109
  if (!equip.photo) {
@@ -2073,7 +2066,7 @@ class BaseUserService {
2073
2066
  getSpModule() {
2074
2067
  return this.spModule;
2075
2068
  }
2076
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BaseUserService, deps: [{ token: ProfileService }, { token: MissionService }, { token: PropertyService }, { token: i1$1.Router }, { token: i11.Location }, { token: i0.NgZone }, { token: i1.TranslateService }, { token: 'SPModule' }], target: i0.ɵɵFactoryTarget.Injectable });
2069
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BaseUserService, deps: [{ token: ProfileService }, { token: MissionService }, { token: PropertyService }, { token: i1.Router }, { token: i11.Location }, { token: i0.NgZone }, { token: i1$1.TranslateService }, { token: 'SPModule' }], target: i0.ɵɵFactoryTarget.Injectable });
2077
2070
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BaseUserService, providedIn: "root" });
2078
2071
  }
2079
2072
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BaseUserService, decorators: [{
@@ -2081,7 +2074,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
2081
2074
  args: [{
2082
2075
  providedIn: "root",
2083
2076
  }]
2084
- }], ctorParameters: () => [{ type: ProfileService }, { type: MissionService }, { type: PropertyService }, { type: i1$1.Router }, { type: i11.Location }, { type: i0.NgZone }, { type: i1.TranslateService }, { type: SpModule, decorators: [{
2077
+ }], ctorParameters: () => [{ type: ProfileService }, { type: MissionService }, { type: PropertyService }, { type: i1.Router }, { type: i11.Location }, { type: i0.NgZone }, { type: i1$1.TranslateService }, { type: SpModule, decorators: [{
2085
2078
  type: Inject,
2086
2079
  args: ['SPModule']
2087
2080
  }] }] });
@@ -2636,7 +2629,7 @@ class MatterportMeasurementService {
2636
2629
  getVisibility() {
2637
2630
  return this.visibility;
2638
2631
  }
2639
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportMeasurementService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2632
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportMeasurementService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2640
2633
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportMeasurementService, providedIn: 'root' });
2641
2634
  }
2642
2635
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportMeasurementService, decorators: [{
@@ -2644,7 +2637,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
2644
2637
  args: [{
2645
2638
  providedIn: 'root',
2646
2639
  }]
2647
- }], ctorParameters: () => [{ type: i1$1.Router }] });
2640
+ }], ctorParameters: () => [{ type: i1.Router }] });
2648
2641
 
2649
2642
  class MatterportNavigationService {
2650
2643
  sweepCollection = null;
@@ -4648,11 +4641,11 @@ class MatterportTagService {
4648
4641
  * floor and room context. Must be called after each sweep, floor or mode change.
4649
4642
  *
4650
4643
  * Rules:
4651
- * - DOLLHOUSE / FLOORPLAN → all tags hidden (opacity 0).
4652
- * - INSIDE → only tags whose sweep belongs to the current floor are shown;
4653
- * proximity-based opacity is applied via computeTagOpacity().
4654
- * Tags on other floors are hidden (opacity 0).
4655
- * - TRANSITIONING → no change (skip update to avoid flickering).
4644
+ * - A tag shows when its sweep is on the floor being displayed, in every mode. Tags on
4645
+ * other floors are hidden (opacity 0) and cannot be opened.
4646
+ * - While all floors are displayed - the usual state of DOLLHOUSE and FLOORPLAN - every
4647
+ * tag shows.
4648
+ * - A tag with no sweep belongs to no floor and always shows.
4656
4649
  *
4657
4650
  * @param sdk Matterport SDK instance.
4658
4651
  * @param poseCamera Current camera pose.
@@ -4664,7 +4657,12 @@ class MatterportTagService {
4664
4657
  if (!sdk || this.dictionnaryTags.size === 0)
4665
4658
  return;
4666
4659
  const isInteriorMode = currentCameraMode === CameraMode.INSIDE;
4667
- const currentFloorId = currentFloorSequence !== null ? currentFloorSequence.toString() : null;
4660
+ // The SDK reports sequence -1 while all floors are displayed, which is the dollhouse's and the
4661
+ // floor plan's normal state. That is "no floor in particular", not a floor that no tag is on:
4662
+ // read as a floor id, it matched nothing and hid every tag that has a sweep.
4663
+ const currentFloorId = currentFloorSequence !== null && currentFloorSequence >= 0
4664
+ ? currentFloorSequence.toString()
4665
+ : null;
4668
4666
  const promises = [];
4669
4667
  for (const [tagId, mattertagData] of this.dictionnaryTags) {
4670
4668
  if (tagId === mattertagToFollow)
@@ -6688,7 +6686,7 @@ class MatterportService {
6688
6686
  floorSequence: data.floorInfo?.sequence ?? (typeof data.floor === 'number' ? data.floor : null),
6689
6687
  };
6690
6688
  }
6691
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportService, deps: [{ token: 'config' }, { token: MATTERPORT_SDK_KEY }, { token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: BaseVisibilityService }, { token: i0.NgZone }, { token: MatterportMeasurementService }, { token: MatterportNavigationService }, { token: MatterportPointerService }, { token: MatterportObject3DService }, { token: MatterportTagService }], target: i0.ɵɵFactoryTarget.Injectable });
6689
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportService, deps: [{ token: 'config' }, { token: MATTERPORT_SDK_KEY }, { token: i1.Router }, { token: i1.ActivatedRoute }, { token: BaseVisibilityService }, { token: i0.NgZone }, { token: MatterportMeasurementService }, { token: MatterportNavigationService }, { token: MatterportPointerService }, { token: MatterportObject3DService }, { token: MatterportTagService }], target: i0.ɵɵFactoryTarget.Injectable });
6692
6690
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportService, providedIn: 'root' });
6693
6691
  }
6694
6692
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportService, decorators: [{
@@ -6702,7 +6700,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
6702
6700
  }] }, { type: undefined, decorators: [{
6703
6701
  type: Inject,
6704
6702
  args: [MATTERPORT_SDK_KEY]
6705
- }] }, { type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: BaseVisibilityService }, { type: i0.NgZone }, { type: MatterportMeasurementService }, { type: MatterportNavigationService }, { type: MatterportPointerService }, { type: MatterportObject3DService }, { type: MatterportTagService }] });
6703
+ }] }, { type: i1.Router }, { type: i1.ActivatedRoute }, { type: BaseVisibilityService }, { type: i0.NgZone }, { type: MatterportMeasurementService }, { type: MatterportNavigationService }, { type: MatterportPointerService }, { type: MatterportObject3DService }, { type: MatterportTagService }] });
6706
6704
 
6707
6705
  /**
6708
6706
  * Builds an orthonormal frame from three points, or null when they are (nearly) collinear.
@@ -6824,6 +6822,15 @@ function solveReducedAlignment(pairs, up) {
6824
6822
  scale,
6825
6823
  };
6826
6824
  }
6825
+ /**
6826
+ * The 3D viewers' background where there is nothing to draw, unless the app sets its own as
6827
+ * --smarterplan-viewer-background: the SmarterPlan app's light blue, from the POC.
6828
+ */
6829
+ const VIEWER_BACKGROUND = '#e0f7ff';
6830
+ /** The 3D viewers' background as the app sets it, where the element is. */
6831
+ function viewerBackground(element) {
6832
+ return getComputedStyle(element).getPropertyValue('--smarterplan-viewer-background').trim() || VIEWER_BACKGROUND;
6833
+ }
6827
6834
  class ThreeJsService {
6828
6835
  ngZone;
6829
6836
  scene;
@@ -6842,6 +6849,17 @@ class ThreeJsService {
6842
6849
  objectClicked$ = new Subject();
6843
6850
  /** Emits when the user clicks a tag, mirroring Matterport's tag click. */
6844
6851
  tagClicked$ = new Subject();
6852
+ /**
6853
+ * Emits the tag the camera is sent to (goToTag): for a viewer drawing the model elsewhere, the
6854
+ * splat viewer, to point it out.
6855
+ */
6856
+ tagFocused$ = new Subject();
6857
+ /**
6858
+ * Emits when the tags change - added, moved, removed, filtered, calibrated differently - at most
6859
+ * once per turn of the event loop, however many changed in it.
6860
+ */
6861
+ tagsChanged$ = new Subject();
6862
+ tagsChangeQueued = false;
6845
6863
  /** Emits a tag's label while the pointer is over it, and null when it leaves. */
6846
6864
  tagHovered$ = new Subject();
6847
6865
  // Tags live under the model rather than the scene, so the centering and scaling applied when the
@@ -6851,6 +6869,22 @@ class ThreeJsService {
6851
6869
  canvasResizeObserver;
6852
6870
  /** Aborts the in-flight model download. Parsing cannot be interrupted, only not started. */
6853
6871
  loadAbortController;
6872
+ /**
6873
+ * Which load is the wanted one. Every load takes the next number as it starts, and anything that
6874
+ * makes it unwanted - another load, the scene being rebuilt, the viewer closing - moves the
6875
+ * number on.
6876
+ *
6877
+ * Aborting the download is not enough to stop a load. A model read from the cache has no
6878
+ * download to abort, and one that has finished downloading still has seconds of work ahead of it
6879
+ * before it reaches the screen. A load that finds the number has moved on drops what it has.
6880
+ */
6881
+ loadGeneration = 0;
6882
+ /** Whether the wanted load is still on its way, so abandoning it can say that it stopped. */
6883
+ loadInProgress = false;
6884
+ /** Whether a scene is up: started by init() and not yet taken down by destroy(). */
6885
+ live = false;
6886
+ /** Takes off each listener init() put on the canvas. */
6887
+ canvasListeners = [];
6854
6888
  // The loaded base model, kept so tag placement can raycast against its geometry.
6855
6889
  modelRoot;
6856
6890
  /** True while the next click on the model places a tag instead of orbiting. */
@@ -6872,6 +6906,12 @@ class ThreeJsService {
6872
6906
  * placed in this one are told from those that came from elsewhere.
6873
6907
  */
6874
6908
  currentCaptureID = null;
6909
+ /**
6910
+ * Whether the visit on screen is the only one the site has. A tag records the visit it was placed
6911
+ * in, but some do not - placed before that was recorded, or in the development model. With
6912
+ * another visit around, such a tag is taken to come from it. With none, it can only be this one's.
6913
+ */
6914
+ soleVisit = false;
6875
6915
  /**
6876
6916
  * The model's surface as a grid: every cell some part of the surface passes through.
6877
6917
  *
@@ -6916,6 +6956,17 @@ class ThreeJsService {
6916
6956
  modelUp = 'y';
6917
6957
  /** While measuring: how many points and each segment's length. Null when it is abandoned. */
6918
6958
  measurementProgress$ = new Subject();
6959
+ /**
6960
+ * True when a measurement starts taking clicks, false when it stops - finished or abandoned. For a
6961
+ * viewer drawing the model elsewhere, which takes the clicks itself; see addMeasurePointAtModelPoint.
6962
+ */
6963
+ measuringChanged$ = new Subject();
6964
+ /**
6965
+ * A measurement - under way or finished - was taken off the model. For a viewer drawing it
6966
+ * elsewhere, the splat viewer: a finished one stays drawn while its form is open, which
6967
+ * measurementProgress$ does not say the end of.
6968
+ */
6969
+ measurementCleared$ = new Subject();
6919
6970
  /**
6920
6971
  * Layer carrying the model alone, so the depth pick can render it without the tags.
6921
6972
  *
@@ -6923,8 +6974,18 @@ class ThreeJsService {
6923
6974
  * their parent passed, so marking the model's own meshes is enough - no re-parenting.
6924
6975
  */
6925
6976
  static PICK_LAYER = 1;
6977
+ /** How large a tag is drawn, in CSS pixels. About what Matterport draws its own at. */
6978
+ static TAG_SCREEN_PX = 28;
6926
6979
  /** The app's highlight colour, so a measurement reads as the active thing on screen. */
6927
6980
  static MEASURE_COLOR = '#FFB103';
6981
+ /** Green for the points of a calibration that are settled, as opposed to the one in hand. */
6982
+ static CALIBRATION_DONE_COLOR = '#1E9E5A';
6983
+ /** Size on screen of the numbered pin left where a tag was matched: a little under a tag's. */
6984
+ static CALIBRATION_PIN_PX = 24;
6985
+ /** How long a mark just dropped takes to settle to its size, in milliseconds. */
6986
+ static CONFIRM_PULSE_MS = 350;
6987
+ /** How many matched tags a calibration takes. Three settle everything there is to settle. */
6988
+ static CALIBRATION_PAIRS = 3;
6928
6989
  /** Cache Storage bucket holding downloaded models, and how many to keep. */
6929
6990
  static MODEL_CACHE = 'smarterplan-3d-models';
6930
6991
  static MODEL_CACHE_SIZE = 3;
@@ -6939,12 +7000,36 @@ class ThreeJsService {
6939
7000
  /** Translucent marker shown under the cursor while placing. */
6940
7001
  placementPreview;
6941
7002
  aligning = false;
7003
+ /**
7004
+ * True from the moment the calibration panel opens, before the walkthrough is armed: the tags
7005
+ * from elsewhere are all on show, as they are while calibrating, so that what there is to
7006
+ * calibrate with can be seen while reading what calibrating involves.
7007
+ */
7008
+ revealingCalibrationTags = false;
6942
7009
  alignmentPairs = [];
6943
7010
  alignmentSource = null;
6944
7011
  /** The tag `alignmentSource` was read from, kept so the same tag is not matched twice. */
6945
7012
  alignmentSourceTagId;
7013
+ /**
7014
+ * Everything drawn for the calibration under way: a numbered pin where each tag was matched, a
7015
+ * line from the pin to its tag, and a ring round the tag being matched.
7016
+ *
7017
+ * A sibling of the tag group rather than a child of it. The points clicked are where the tags are
7018
+ * to end up, in the frame the calibration maps onto (see pickAlignmentTarget) - not in the tags'
7019
+ * own frame, which is the one about to change.
7020
+ */
7021
+ calibrationGroup = new THREE.Group();
7022
+ /** Marks still settling after being dropped, advanced by the render loop. */
7023
+ pulses = [];
6946
7024
  /** Drives the alignment walkthrough's UI: how many pairs are done and what it wants next. */
6947
7025
  alignmentProgress$ = new Subject();
7026
+ /**
7027
+ * Emits when a click during calibration did nothing, with what it was expected to land on.
7028
+ *
7029
+ * A click that changes nothing looks the same as a click that was not received. This lets the
7030
+ * panel point at what it is waiting for instead.
7031
+ */
7032
+ alignmentClickIgnored$ = new Subject();
6948
7033
  /** In-flight camera move started by goToTag, advanced by the render loop. */
6949
7034
  cameraTween = null;
6950
7035
  /** Emits true while a heavy OBJ file is being parsed (in a worker, when available), false once done. */
@@ -7056,15 +7141,30 @@ class ThreeJsService {
7056
7141
  // by then, so the model being abandoned would be handed to the scene built below.
7057
7142
  // - The tag group, which is a field and keeps its sprites. They would be re-parented under the
7058
7143
  // new model and show the previous visit's tags on it.
7144
+ // Usually destroy() ran before this and there is nothing left to stop. When it did not, the
7145
+ // scene before would carry on beside the one started below: its render loop drawing every
7146
+ // frame as well, its model still on the graphics card, its listeners answering every click a
7147
+ // second time.
7148
+ if (this.live) {
7149
+ this.destroy();
7150
+ }
7059
7151
  this.discardCurrentLoad();
7060
7152
  this.clearTags();
7061
7153
  this.measuring = false;
7062
7154
  this.clearMeasurement();
7155
+ // A calibration left half-done belongs to the scene it was started in: its points mean nothing
7156
+ // in the next one, and left armed it would take that scene's first clicks for itself.
7157
+ this.aligning = false;
7158
+ this.revealingCalibrationTags = false;
7159
+ this.soleVisit = false;
7160
+ this.alignmentPairs = [];
7161
+ this.clearAlignmentSource();
7162
+ this.clearCalibrationMarks();
7163
+ this.pulses = [];
7063
7164
  this.cameraTween = null;
7064
- this.modelRoot = undefined;
7065
7165
  // 1. Setup Scene
7066
7166
  this.scene = new THREE.Scene();
7067
- this.scene.background = new THREE.Color(0xe0f7ff); // from POC
7167
+ this.scene.background = new THREE.Color(viewerBackground(canvas));
7068
7168
  // 2. Setup Camera
7069
7169
  this.camera = new THREE.PerspectiveCamera(75, canvas.clientWidth / canvas.clientHeight, 0.1, 10000);
7070
7170
  this.camera.position.set(0, 5, 10); // will be overridden later if passed
@@ -7109,7 +7209,14 @@ class ThreeJsService {
7109
7209
  // A light only contributes while it is part of the scene graph, and this one hangs off the camera.
7110
7210
  this.scene.add(this.camera);
7111
7211
  // 5. Setup Controls (from POC)
7112
- this.controls = new OrbitControls(this.camera, this.renderer.domElement);
7212
+ //
7213
+ // Created outside Angular's zone, as is the pointer-move listener further down. The controls
7214
+ // listen to every pointer move and wheel tick, and inside the zone each of those events had
7215
+ // Angular re-check the whole page - dozens of times a second while the camera is dragged,
7216
+ // competing with the frames being drawn - for a change that only ever concerns the canvas.
7217
+ this.ngZone.runOutsideAngular(() => {
7218
+ this.controls = new OrbitControls(this.camera, this.renderer.domElement);
7219
+ });
7113
7220
  this.controls.rotateSpeed = 1.0;
7114
7221
  this.controls.dampingFactor = 0.1;
7115
7222
  this.controls.enableDamping = true;
@@ -7133,9 +7240,18 @@ class ThreeJsService {
7133
7240
  }, 250);
7134
7241
  }
7135
7242
  });
7136
- // Interaction Event Listeners on canvas
7137
- canvas.addEventListener('click', this.onMouseClick.bind(this), false);
7138
- canvas.addEventListener('mousemove', this.onMouseMove.bind(this), false);
7243
+ // Interaction Event Listeners on canvas. Kept so that destroy() can take them off again: the
7244
+ // same canvas is used again when one 3D model is swapped for another, and a second set of
7245
+ // listeners would answer every click twice.
7246
+ const listen = (type, handler) => {
7247
+ canvas.addEventListener(type, handler, false);
7248
+ this.canvasListeners.push(() => canvas.removeEventListener(type, handler, false));
7249
+ };
7250
+ // A click changes what the page shows - a panel opens, a point is recorded - so Angular has to
7251
+ // hear of it, wherever init() itself was called from.
7252
+ listen('click', (event) => this.ngZone.run(() => this.onMouseClick(event)));
7253
+ // Moving the pointer does not: it moves the ghost and the tooltip, both drawn here.
7254
+ this.ngZone.runOutsideAngular(() => listen('mousemove', (event) => this.onMouseMove(event)));
7139
7255
  // Escape backs out of placement and calibration. On the window rather than the canvas, which
7140
7256
  // would need focus the user has no reason to have given it - they are aiming with the mouse.
7141
7257
  // Removed first because this service is a singleton: init() runs again for every canvas, and
@@ -7148,6 +7264,7 @@ class ThreeJsService {
7148
7264
  this.pickCamera = undefined;
7149
7265
  window.addEventListener('keydown', this.onKeyDown);
7150
7266
  // 6. Start the render loop
7267
+ this.live = true;
7151
7268
  this.ngZone.runOutsideAngular(() => {
7152
7269
  this.animate();
7153
7270
  });
@@ -7184,33 +7301,25 @@ class ThreeJsService {
7184
7301
  }
7185
7302
  // Lets gltfpack/gltf-transform output using EXT_meshopt_compression load without extra setup.
7186
7303
  loader.setMeshoptDecoder(MeshoptDecoder);
7187
- this.modelLoading$.next(true);
7304
+ const wanted = this.beginLoad();
7188
7305
  this.modelLoadProgress$.next(0);
7189
7306
  // Order matters: normals must exist before anisotropy, and the Phong conversion has to run
7190
7307
  // before side/flatShading are touched so those settings land on the materials we keep.
7191
7308
  const onLoaded = (gltf) => {
7309
+ if (!wanted()) {
7310
+ // Built for a request that has since been replaced or abandoned. It was never on screen;
7311
+ // what it holds is freed here because nothing else ever will.
7312
+ this.disposeModel(gltf.scene);
7313
+ return;
7314
+ }
7192
7315
  this.convertToPhongMaterials(gltf.scene);
7193
7316
  this.forceDoubleSidedMaterials(gltf.scene);
7194
7317
  this.ensureVertexNormals(gltf.scene);
7195
7318
  this.tuneTextureSampling(gltf.scene);
7196
7319
  this.placeLoadedObjectInScene(gltf.scene, cameraPosition, rotation, up);
7197
- this.modelLoading$.next(false);
7198
- };
7199
- const onError = (error) => {
7200
- // Cancelling is a decision, not a failure: clear the overlay without an error in the console.
7201
- if (error?.name === 'AbortError') {
7202
- // Only a cancel of the load that is still current came from the user; anything else is this
7203
- // load having been superseded or discarded.
7204
- if (this.loadAbortController?.signal.aborted) {
7205
- this.modelLoadCancelled$.next();
7206
- }
7207
- }
7208
- else {
7209
- console.error('Error loading GLTF model:', error);
7210
- }
7211
- this.modelLoading$.next(false);
7212
- this.modelLoadProgress$.next(null);
7320
+ this.endLoad();
7213
7321
  };
7322
+ const onError = (error) => this.loadFailed(wanted, error, 'GLTF model');
7214
7323
  // GLTFLoader decodes embedded images with createImageBitmap when the browser offers it, and on
7215
7324
  // large texture atlases that path returns visibly corrupt data - scattered white blocks across
7216
7325
  // the model. The exact same bytes decoded through an HTMLImageElement, which is what the .obj
@@ -7228,7 +7337,8 @@ class ThreeJsService {
7228
7337
  .then((buffer) => {
7229
7338
  // parse() cannot be interrupted, so a cancel that lands during the paint yield has to be
7230
7339
  // caught here - the last moment before the main thread is committed for several seconds.
7231
- if (this.loadAbortController?.signal.aborted) {
7340
+ // The same goes for a load nobody is waiting for any more.
7341
+ if (!wanted() || this.loadAbortController?.signal.aborted) {
7232
7342
  throw new DOMException('Model load cancelled', 'AbortError');
7233
7343
  }
7234
7344
  const globalScope = globalThis;
@@ -7243,6 +7353,28 @@ class ThreeJsService {
7243
7353
  })
7244
7354
  .catch(onError);
7245
7355
  }
7356
+ /** Ends a load that failed, unless another load has replaced it in the meantime. */
7357
+ loadFailed(wanted, error, what) {
7358
+ if (!wanted()) {
7359
+ // Whatever replaced this load owns the loading indicator now; ending it from here would
7360
+ // switch the indicator off while that one is still on its way.
7361
+ return;
7362
+ }
7363
+ this.loadInProgress = false;
7364
+ // Cancelling is a decision, not a failure: clear the overlay without an error in the console.
7365
+ if (error?.name === 'AbortError') {
7366
+ // Only a cancel of the load that is still current came from the user; anything else is this
7367
+ // load having been superseded or discarded.
7368
+ if (this.loadAbortController?.signal.aborted) {
7369
+ this.modelLoadCancelled$.next();
7370
+ }
7371
+ }
7372
+ else {
7373
+ console.error(`Error loading ${what}:`, error);
7374
+ }
7375
+ this.modelLoading$.next(false);
7376
+ this.modelLoadProgress$.next(null);
7377
+ }
7246
7378
  /**
7247
7379
  * Stops the model download in progress, if any.
7248
7380
  *
@@ -7261,8 +7393,30 @@ class ThreeJsService {
7261
7393
  * scene is not something the person asked for, so it must not surface as "loading cancelled".
7262
7394
  */
7263
7395
  discardCurrentLoad() {
7396
+ this.loadGeneration += 1;
7264
7397
  this.loadAbortController?.abort();
7265
7398
  this.loadAbortController = undefined;
7399
+ if (this.loadInProgress) {
7400
+ this.loadInProgress = false;
7401
+ this.modelLoading$.next(false);
7402
+ this.modelLoadProgress$.next(null);
7403
+ }
7404
+ }
7405
+ /**
7406
+ * Starts a load, replacing whichever was under way, and returns the question it has to keep
7407
+ * asking: is it still the one that is wanted?
7408
+ */
7409
+ beginLoad() {
7410
+ this.loadGeneration += 1;
7411
+ const generation = this.loadGeneration;
7412
+ this.loadInProgress = true;
7413
+ this.modelLoading$.next(true);
7414
+ return () => generation === this.loadGeneration;
7415
+ }
7416
+ /** Marks the wanted load as over, whichever way it ended. */
7417
+ endLoad() {
7418
+ this.loadInProgress = false;
7419
+ this.modelLoading$.next(false);
7266
7420
  }
7267
7421
  /**
7268
7422
  * Resolves once the browser has painted at least one frame.
@@ -7293,6 +7447,11 @@ class ThreeJsService {
7293
7447
  this.loadAbortController = new AbortController();
7294
7448
  const { signal } = this.loadAbortController;
7295
7449
  const cached = await this.readModelFromCache(cacheKey);
7450
+ if (signal.aborted) {
7451
+ // Replaced or abandoned while the cache was being read. With nothing being downloaded, this
7452
+ // is the only place a load served from the cache can find that out.
7453
+ throw new DOMException('Model load cancelled', 'AbortError');
7454
+ }
7296
7455
  if (cached) {
7297
7456
  this.modelLoadProgress$.next(1);
7298
7457
  return cached;
@@ -7633,12 +7792,25 @@ class ThreeJsService {
7633
7792
  const basePath = mtlUrl.substring(0, mtlUrl.lastIndexOf('/') + 1);
7634
7793
  mtlLoader.setPath(basePath);
7635
7794
  const mtlFileName = mtlUrl.substring(mtlUrl.lastIndexOf('/') + 1);
7636
- this.modelLoading$.next(true);
7795
+ // These loaders cannot be interrupted, so a load that is no longer wanted runs to its end and
7796
+ // is dropped there - see loadGeneration.
7797
+ const wanted = this.beginLoad();
7798
+ const finish = () => {
7799
+ if (wanted()) {
7800
+ this.endLoad();
7801
+ }
7802
+ };
7637
7803
  mtlLoader.load(mtlFileName, (materials) => {
7804
+ if (!wanted()) {
7805
+ return;
7806
+ }
7638
7807
  materials.preload();
7639
7808
  if (this.objParserWorker) {
7640
7809
  this.requestObjParseInWorker(objUrl)
7641
7810
  .then((meshes) => {
7811
+ if (!wanted()) {
7812
+ return;
7813
+ }
7642
7814
  const group = new THREE.Group();
7643
7815
  meshes.forEach((meshData) => {
7644
7816
  group.add(this.meshFromParsedData(meshData, materials));
@@ -7648,25 +7820,42 @@ class ThreeJsService {
7648
7820
  .catch((error) => {
7649
7821
  console.error('Error parsing OBJ model in worker:', error);
7650
7822
  })
7651
- .finally(() => this.modelLoading$.next(false));
7823
+ .finally(finish);
7652
7824
  return;
7653
7825
  }
7654
7826
  const objLoader = new OBJLoader();
7655
7827
  objLoader.setMaterials(materials);
7656
7828
  objLoader.load(objUrl, (object) => {
7829
+ if (!wanted()) {
7830
+ this.disposeModel(object);
7831
+ return;
7832
+ }
7657
7833
  this.placeLoadedObjectInScene(object, cameraPosition, rotation);
7658
- this.modelLoading$.next(false);
7834
+ finish();
7659
7835
  }, undefined, (error) => {
7660
7836
  console.error('Error loading OBJ model:', error);
7661
- this.modelLoading$.next(false);
7837
+ finish();
7662
7838
  });
7663
7839
  }, undefined, (error) => {
7664
7840
  console.error('Error loading MTL file:', error);
7665
- this.modelLoading$.next(false);
7841
+ finish();
7666
7842
  });
7667
7843
  }
7668
7844
  /** Centers, scales and adds a loaded object to the scene, then frames the camera on it. */
7669
7845
  placeLoadedObjectInScene(object, cameraPosition, rotation, up) {
7846
+ // A scene shows one model. Whatever was there is taken out and freed first, or the two would be
7847
+ // drawn through each other, every frame, for as long as the viewer stays open.
7848
+ if (this.modelRoot) {
7849
+ // Points being clicked for a calibration or a measurement were clicked on the model that is
7850
+ // about to go; they say nothing about the one arriving.
7851
+ if (this.aligning) {
7852
+ this.cancelTagAlignment();
7853
+ }
7854
+ if (this.measuring) {
7855
+ this.cancelMeasuring();
7856
+ }
7857
+ }
7858
+ this.removeModel();
7670
7859
  const box = new THREE.Box3().setFromObject(object);
7671
7860
  const center = box.getCenter(new THREE.Vector3());
7672
7861
  const size = box.getSize(new THREE.Vector3());
@@ -7703,8 +7892,9 @@ class ThreeJsService {
7703
7892
  group.add(centered);
7704
7893
  group.scale.setScalar(scale);
7705
7894
  this.scene.add(group);
7706
- // Tags registered before the model finished loading were sized against the old scale.
7707
- this.tagSprites.forEach((sprite) => this.scaleTagForModel(sprite));
7895
+ this.scene.updateMatrixWorld(true);
7896
+ // Markers registered before the model finished loading were sized against the old scale.
7897
+ this.refreshScreenSizes();
7708
7898
  this.adjustClippingPlanes((size.length() / 2) * scale);
7709
7899
  if (cameraPosition) {
7710
7900
  this.camera.position.set(cameraPosition.x, cameraPosition.y, cameraPosition.z);
@@ -7720,16 +7910,25 @@ class ThreeJsService {
7720
7910
  * not clear enough to act on.
7721
7911
  *
7722
7912
  * Models arrive in two conventions: Y up (glTF, and what this viewer assumes) and Z up (most CAD
7723
- * and scanning exports). A Z-up model loads lying on its side. Two independent cues say which
7724
- * axis is the vertical one, and both have to agree before anything is turned:
7913
+ * and scanning exports). A Z-up model loads lying on its side. Three independent cues say which
7914
+ * axis is the vertical one:
7725
7915
  *
7726
7916
  * - Surface area. Floors and ceilings all face along the vertical, while walls are shared out
7727
7917
  * between the two horizontal axes, so the vertical usually collects the most area.
7728
7918
  * - Extent. A building is normally wider than it is tall, so the vertical is its shortest side.
7919
+ * - Openness. A capture made from outside has ground and roofs but nothing underneath them, so
7920
+ * along the vertical nearly all of its surface faces one way; walls face both ways evenly.
7729
7921
  *
7730
- * Either alone is wrong often enough to matter - a long corridor has more wall than floor, a
7731
- * tower is taller than it is wide - and turning a model that was fine is worse than leaving one
7732
- * that was not. A model that already has Y as its vertical is never touched.
7922
+ * Each is wrong often enough on its own - a long corridor has more wall than floor, a tower is
7923
+ * taller than it is wide - so a cue only counts when its answer is clear-cut, and the model is
7924
+ * turned when the clear answers agree. It used to take area and extent agreeing with each other,
7925
+ * which failed on exactly the models that need this most: in a whole building or a city block
7926
+ * there is as much wall as floor, the area cue comes out a three-way tie, and a model 130 m wide
7927
+ * and 34 m tall with 86% of its surface facing one way was left lying on its side.
7928
+ *
7929
+ * Turning a model that was fine is worse than leaving one that was not: when the clear answers
7930
+ * contradict each other, or there is none, nothing is turned. A model that already has Y as its
7931
+ * vertical is never touched.
7733
7932
  */
7734
7933
  detectModelUp(object, size) {
7735
7934
  const axes = ['x', 'y', 'z'];
@@ -7744,6 +7943,7 @@ class ThreeJsService {
7744
7943
  }
7745
7944
  });
7746
7945
  if (triangleCount === 0) {
7946
+ // Nothing with faces to weigh: the convention.
7747
7947
  return 'y';
7748
7948
  }
7749
7949
  // A sample is plenty to see where the area lies, and keeps this cheap on models with millions
@@ -7774,16 +7974,45 @@ class ThreeJsService {
7774
7974
  }
7775
7975
  });
7776
7976
  const total = { x: area.x[0] + area.x[1], y: area.y[0] + area.y[1], z: area.z[0] + area.z[1] };
7777
- const byArea = axes.reduce((best, axis) => (total[axis] > total[best] ? axis : best), 'y');
7778
- const byExtent = axes.reduce((best, axis) => (size[axis] < size[best] ? axis : best), 'y');
7779
- if (byArea === 'y' || byArea !== byExtent || total[byArea] < 1.25 * total.y) {
7977
+ const extent = { x: size.x, y: size.y, z: size.z };
7978
+ // How one-sided the surface is along each axis: 0 when it faces both ways evenly, 1 when it
7979
+ // all faces the same way.
7980
+ const lopsided = { x: 0, y: 0, z: 0 };
7981
+ axes.forEach((axis) => {
7982
+ lopsided[axis] = total[axis] > 0 ? Math.abs(area[axis][0] - area[axis][1]) / total[axis] : 0;
7983
+ });
7984
+ /** The axes ordered by a measure, largest first. */
7985
+ const ranked = (measure) => [...axes].sort((first, second) => measure[second] - measure[first]);
7986
+ const [mostArea, nextArea] = ranked(total);
7987
+ const [, middleExtent, shortest] = ranked(extent);
7988
+ const [mostOpen, nextOpen] = ranked(lopsided);
7989
+ // What each cue says, when it says it clearly; null when it has no clear answer.
7990
+ const areaSays = total[mostArea] >= 1.25 * total[nextArea] ? mostArea : null;
7991
+ const extentSays = extent[middleExtent] >= 1.5 * extent[shortest] ? shortest : null;
7992
+ const opennessSays = lopsided[mostOpen] >= 0.5
7993
+ && lopsided[mostOpen] >= 2 * lopsided[nextOpen]
7994
+ // Not on the strength of a few stray triangles: the surface along that axis has to matter.
7995
+ && total[mostOpen] >= 0.25 * total[mostArea]
7996
+ ? mostOpen
7997
+ : null;
7998
+ const clear = [areaSays, extentSays, opennessSays].filter((axis) => axis !== null);
7999
+ let vertical = 'y';
8000
+ if (clear.length > 0) {
8001
+ // Clear answers that contradict each other are no answer.
8002
+ vertical = clear.every((axis) => axis === clear[0]) ? clear[0] : 'y';
8003
+ }
8004
+ else if (mostArea === shortest && total[mostArea] >= 1.25 * total.y) {
8005
+ // Nothing clear-cut, but area and extent lean the same way and away from Y.
8006
+ vertical = mostArea;
8007
+ }
8008
+ if (vertical === 'y') {
7780
8009
  return 'y';
7781
8010
  }
7782
8011
  // Which way along that axis is up. Roofs and ground make an outdoor model face mostly upward,
7783
8012
  // which settles it; indoors floors and ceilings balance out, and the convention - positive is
7784
8013
  // up - is the better guess.
7785
- const [positive, negative] = area[byArea];
7786
- const up = `${negative > 0.65 * (positive + negative) ? '-' : ''}${byArea}`;
8014
+ const [positive, negative] = area[vertical];
8015
+ const up = `${negative > 0.65 * (positive + negative) ? '-' : ''}${vertical}`;
7787
8016
  console.info(`ThreeJsService: this model's vertical axis looks like ${up}, not y - standing it upright.`);
7788
8017
  return up;
7789
8018
  }
@@ -7833,6 +8062,7 @@ class ThreeJsService {
7833
8062
  this.camera.updateProjectionMatrix();
7834
8063
  this.renderer.setSize(width, height);
7835
8064
  this.updateMeasureLineResolution();
8065
+ this.refreshScreenSizes();
7836
8066
  });
7837
8067
  this.canvasResizeObserver.observe(container);
7838
8068
  }
@@ -7843,6 +8073,34 @@ class ThreeJsService {
7843
8073
  * only has to supply the matching spot on the model. No new records are written; nothing is
7844
8074
  * applied until solveAlignmentFromPairs() succeeds.
7845
8075
  */
8076
+ /**
8077
+ * Shows every tag that came from elsewhere, whether or not it lands on the model, without arming
8078
+ * anything: clicks still do what they always do.
8079
+ *
8080
+ * Calibrating shows them too, and ending a calibration - saved or abandoned - puts them back
8081
+ * under the usual rule, so this only ever has to be switched on.
8082
+ */
8083
+ revealCalibrationTags(revealed = true) {
8084
+ this.revealingCalibrationTags = revealed;
8085
+ this.refreshTagVisibility();
8086
+ // Another viewer showing the tags shows these as well now; see showsCalibrationTags.
8087
+ this.announceTagsChanged();
8088
+ }
8089
+ /**
8090
+ * Whether the tags a calibration works with are on show - while one is under way, or its panel
8091
+ * open - including those that do not land on the model. For another viewer showing the tags,
8092
+ * which otherwise leaves out the ones from elsewhere until the model is calibrated.
8093
+ */
8094
+ showsCalibrationTags() {
8095
+ return this.aligning || this.revealingCalibrationTags;
8096
+ }
8097
+ /** Says a tag was clicked in a viewer drawing the model elsewhere, as a click on it here would. */
8098
+ clickTag(elementId) {
8099
+ const sprite = this.tagSprites.get(elementId);
8100
+ if (sprite) {
8101
+ this.tagClicked$.next({ elementId, poiType: sprite.userData.poiType ?? null });
8102
+ }
8103
+ }
7846
8104
  startTagAlignment() {
7847
8105
  // One pointer mode at a time, the same rule startMeasuring() applies the other way round.
7848
8106
  if (this.measuring) {
@@ -7850,27 +8108,28 @@ class ThreeJsService {
7850
8108
  }
7851
8109
  this.aligning = true;
7852
8110
  this.alignmentPairs = [];
7853
- this.alignmentSource = null;
8111
+ this.clearAlignmentSource();
7854
8112
  // While calibrating, the tags from elsewhere are all shown - including the ones off the model,
7855
8113
  // which are exactly the ones a calibration is for.
7856
8114
  this.refreshTagVisibility();
7857
8115
  if (this.renderer) {
7858
8116
  this.renderer.domElement.style.cursor = 'crosshair';
7859
8117
  }
7860
- this.alignmentProgress$.next({ pairs: 0, awaiting: 'tag' });
8118
+ this.alignmentChanged();
8119
+ this.announceTagsChanged();
7861
8120
  }
7862
8121
  cancelTagAlignment() {
7863
8122
  const wasAligning = this.aligning;
7864
8123
  this.aligning = false;
8124
+ this.revealingCalibrationTags = false;
7865
8125
  this.alignmentPairs = [];
7866
- this.alignmentSource = null;
7867
- this.pendingPreviewEvent = null;
7868
- this.removePlacementPreview();
8126
+ this.clearAlignmentSource();
7869
8127
  this.refreshTagVisibility();
7870
8128
  if (this.renderer) {
7871
8129
  this.renderer.domElement.style.cursor = 'default';
7872
8130
  }
7873
- this.alignmentProgress$.next({ pairs: 0, awaiting: null });
8131
+ this.alignmentChanged();
8132
+ this.announceTagsChanged();
7874
8133
  if (wasAligning) {
7875
8134
  this.alignmentCancelled$.next();
7876
8135
  }
@@ -7918,11 +8177,10 @@ class ThreeJsService {
7918
8177
  // Out of calibrating mode first: applying the result re-decides which tags show, and from here
7919
8178
  // on that is the ones on the model again, not all of them.
7920
8179
  this.aligning = false;
8180
+ this.revealingCalibrationTags = false;
7921
8181
  this.applyAlignmentKeepingOwnTags(alignment);
7922
- this.pendingPreviewEvent = null;
7923
- this.removePlacementPreview();
7924
8182
  this.renderer.domElement.style.cursor = 'default';
7925
- this.alignmentProgress$.next({ pairs: this.alignmentPairs.length, awaiting: null });
8183
+ this.alignmentChanged();
7926
8184
  return alignment;
7927
8185
  }
7928
8186
  /**
@@ -7981,7 +8239,8 @@ class ThreeJsService {
7981
8239
  */
7982
8240
  selectAlignmentTag(elementId) {
7983
8241
  const sprite = this.tagSprites.get(elementId);
7984
- if (!this.aligning || this.alignmentSource || !sprite || !this.calibrationCandidates().includes(sprite)) {
8242
+ if (!this.aligning || this.alignmentSource || !this.canMatchAnotherTag()
8243
+ || !sprite || !this.calibrationCandidates().includes(sprite)) {
7985
8244
  return false;
7986
8245
  }
7987
8246
  this.setAlignmentSource(sprite);
@@ -7993,18 +8252,28 @@ class ThreeJsService {
7993
8252
  const stored = sprite.position;
7994
8253
  this.alignmentSource = { x: stored.x, y: stored.y, z: stored.z };
7995
8254
  this.alignmentSourceTagId = sprite.name;
7996
- this.alignmentProgress$.next({
7997
- pairs: this.alignmentPairs.length,
7998
- awaiting: 'point',
7999
- tagId: sprite.name,
8000
- });
8255
+ this.alignmentChanged('tag');
8256
+ }
8257
+ clearAlignmentSource() {
8258
+ this.alignmentSource = null;
8259
+ this.alignmentSourceTagId = undefined;
8260
+ }
8261
+ /** Whether the calibration still has room for a pair and a tag to make it from. */
8262
+ canMatchAnotherTag() {
8263
+ return this.alignmentPairs.length < ThreeJsService.CALIBRATION_PAIRS
8264
+ && this.calibrationCandidates().length > 0;
8001
8265
  }
8002
8266
  /** Handles a click while the alignment walkthrough is running. */
8003
8267
  handleAlignmentClick(event) {
8004
8268
  if (!this.alignmentSource) {
8005
8269
  // First half of a pair: which tag are we talking about?
8270
+ if (!this.canMatchAnotherTag()) {
8271
+ // Nothing left to match: what remains is to save, or to take a pair back.
8272
+ return;
8273
+ }
8006
8274
  const hit = this.raycaster.intersectObjects(this.calibrationCandidates(), false)[0];
8007
8275
  if (!hit) {
8276
+ this.alignmentClickIgnored$.next('tag');
8008
8277
  return;
8009
8278
  }
8010
8279
  this.setAlignmentSource(hit.object);
@@ -8013,18 +8282,220 @@ class ThreeJsService {
8013
8282
  // Second half: where that tag actually belongs on the model.
8014
8283
  const target = this.pickAlignmentTarget(event);
8015
8284
  if (!target) {
8285
+ this.alignmentClickIgnored$.next('point');
8016
8286
  return;
8017
8287
  }
8018
8288
  this.alignmentPairs.push({ tagId: this.alignmentSourceTagId, source: this.alignmentSource, target });
8019
- this.alignmentSource = null;
8020
- // The ghost belongs to the click that just happened; the next half is a click on a tag.
8289
+ this.clearAlignmentSource();
8290
+ this.alignmentChanged('point');
8291
+ }
8292
+ /**
8293
+ * Records where the tag being matched really is, from a spot another viewer picked on the model -
8294
+ * the splat viewer - in the model's own coordinates: the frame pickAlignmentTarget measures a
8295
+ * click in, as placeTagAtModelPoint takes it. False when no tag is waiting for its spot.
8296
+ */
8297
+ matchAlignmentTagAtModelPoint(point) {
8298
+ if (!this.aligning || !this.alignmentSource) {
8299
+ return false;
8300
+ }
8301
+ this.alignmentPairs.push({
8302
+ tagId: this.alignmentSourceTagId,
8303
+ source: this.alignmentSource,
8304
+ target: { x: point.x, y: point.y, z: point.z },
8305
+ });
8306
+ this.clearAlignmentSource();
8307
+ this.alignmentChanged('point');
8308
+ return true;
8309
+ }
8310
+ /**
8311
+ * Takes back the last thing done in the calibration under way: the choice of tag while its place
8312
+ * on the model is being asked for, the last matched pair otherwise.
8313
+ *
8314
+ * One step at a time, so a click made by mistake costs that click and not the whole calibration.
8315
+ * Returns false when there is nothing to take back.
8316
+ */
8317
+ undoAlignmentStep() {
8318
+ if (!this.aligning) {
8319
+ return false;
8320
+ }
8321
+ if (this.alignmentSource) {
8322
+ this.clearAlignmentSource();
8323
+ }
8324
+ else if (this.alignmentPairs.length > 0) {
8325
+ this.alignmentPairs.pop();
8326
+ }
8327
+ else {
8328
+ return false;
8329
+ }
8330
+ this.alignmentChanged();
8331
+ return true;
8332
+ }
8333
+ /**
8334
+ * Removes one matched pair, whichever it is, putting its tag back on offer.
8335
+ *
8336
+ * For the point noticed to be wrong only after others were matched: taking steps back one by one
8337
+ * to reach it would throw away the good ones made since.
8338
+ */
8339
+ removeAlignmentPair(index) {
8340
+ if (!this.aligning || !Number.isInteger(index) || index < 0 || index >= this.alignmentPairs.length) {
8341
+ return false;
8342
+ }
8343
+ this.alignmentPairs.splice(index, 1);
8344
+ this.alignmentChanged();
8345
+ return true;
8346
+ }
8347
+ /** The tags matched so far in the calibration under way, in the order they are numbered in. */
8348
+ getAlignmentPairs() {
8349
+ return this.alignmentPairs.map((pair) => {
8350
+ const sprite = this.tagSprites.get(pair.tagId);
8351
+ return {
8352
+ tagId: pair.tagId,
8353
+ label: sprite?.userData.label ?? null,
8354
+ poiType: sprite?.userData.poiType ?? null,
8355
+ target: { ...pair.target },
8356
+ };
8357
+ });
8358
+ }
8359
+ /**
8360
+ * Brings the scene and the panel in line with the calibration's state, after anything changed it.
8361
+ *
8362
+ * `dropped` names the mark the change put down, if it put one down, so that it can be shown
8363
+ * arriving: that movement is what tells someone their click was taken.
8364
+ */
8365
+ alignmentChanged(dropped) {
8366
+ // The ghost previews the pin about to be dropped, number included, so it is never carried over
8367
+ // from one state to the next; the next pointer move draws the right one.
8021
8368
  this.pendingPreviewEvent = null;
8022
8369
  this.removePlacementPreview();
8370
+ if (this.aligning && this.renderer) {
8371
+ this.renderer.domElement.style.cursor = 'crosshair';
8372
+ }
8373
+ this.redrawCalibrationMarks(dropped);
8374
+ let awaiting = null;
8375
+ if (this.aligning) {
8376
+ if (this.alignmentSource) {
8377
+ awaiting = 'point';
8378
+ }
8379
+ else if (this.canMatchAnotherTag()) {
8380
+ // Otherwise done at three, or sooner when there are no more tags to match: fewer pairs
8381
+ // still calibrate, only less completely.
8382
+ awaiting = 'tag';
8383
+ }
8384
+ }
8023
8385
  this.alignmentProgress$.next({
8024
8386
  pairs: this.alignmentPairs.length,
8025
- // Done at three, or sooner when there are no more tags to match: fewer pairs still calibrate,
8026
- // only less completely.
8027
- awaiting: this.alignmentPairs.length >= 3 || this.calibrationCandidates().length === 0 ? null : 'tag',
8387
+ awaiting,
8388
+ tagId: awaiting === 'point' ? this.alignmentSourceTagId : undefined,
8389
+ matched: this.getAlignmentPairs(),
8390
+ });
8391
+ }
8392
+ /**
8393
+ * Draws the calibration as it stands: what has been matched, and what is being matched.
8394
+ *
8395
+ * Redrawn whole on every change rather than patched. There are at most three pairs, and undoing
8396
+ * or removing one renumbers the others.
8397
+ */
8398
+ redrawCalibrationMarks(dropped) {
8399
+ this.clearCalibrationMarks();
8400
+ if (!this.aligning) {
8401
+ return;
8402
+ }
8403
+ const frame = this.tagGroup.parent ?? this.scene;
8404
+ if (this.calibrationGroup.parent !== frame) {
8405
+ frame.add(this.calibrationGroup);
8406
+ }
8407
+ this.tagGroup.updateMatrix();
8408
+ // Where a tag is drawn at the moment, in the frame the marks are drawn in.
8409
+ const drawnAt = (stored) => new THREE.Vector3(stored.x, stored.y, stored.z).applyMatrix4(this.tagGroup.matrix);
8410
+ this.alignmentPairs.forEach((pair, index) => {
8411
+ const target = new THREE.Vector3(pair.target.x, pair.target.y, pair.target.z);
8412
+ // From where the tag is to where it was said to belong: the correction, made visible.
8413
+ const link = this.createMeasureLine(drawnAt(pair.source), target, ThreeJsService.CALIBRATION_DONE_COLOR, 2);
8414
+ link.material.opacity = 0.75;
8415
+ // The same green as the pin it leads to; see createCalibrationMark.
8416
+ link.material.color.convertSRGBToLinear();
8417
+ link.material.toneMapped = false;
8418
+ // Behind the tags: it sets off from the middle of one, and should come out from under its
8419
+ // icon rather than run across it.
8420
+ link.renderOrder = 997;
8421
+ this.calibrationGroup.add(link);
8422
+ const pin = this.createCalibrationMark(this.createNumberedTexture(index + 1, ThreeJsService.CALIBRATION_DONE_COLOR), 1001);
8423
+ pin.position.copy(target);
8424
+ this.calibrationGroup.add(pin);
8425
+ this.setScreenSize(pin, ThreeJsService.CALIBRATION_PIN_PX);
8426
+ if (dropped === 'point' && index === this.alignmentPairs.length - 1) {
8427
+ this.pulse(pin);
8428
+ }
8429
+ // Its tag is spoken for; it stays in view to show what the pin refers to, but stands back.
8430
+ const matched = this.tagSprites.get(pair.tagId);
8431
+ if (matched) {
8432
+ matched.material.opacity = 0.4;
8433
+ }
8434
+ });
8435
+ if (this.alignmentSource) {
8436
+ const ring = this.createCalibrationMark(this.createRingTexture(ThreeJsService.MEASURE_COLOR), 998);
8437
+ ring.position.copy(drawnAt(this.alignmentSource));
8438
+ this.calibrationGroup.add(ring);
8439
+ this.setScreenSize(ring, ThreeJsService.TAG_SCREEN_PX * 1.6);
8440
+ if (dropped === 'tag') {
8441
+ this.pulse(ring);
8442
+ }
8443
+ }
8444
+ }
8445
+ /** Removes everything drawn for a calibration, and gives the tags it dimmed their look back. */
8446
+ clearCalibrationMarks() {
8447
+ [...this.calibrationGroup.children].forEach((child) => {
8448
+ this.calibrationGroup.remove(child);
8449
+ child.geometry?.dispose?.();
8450
+ child.material?.map?.dispose?.();
8451
+ child.material?.dispose?.();
8452
+ });
8453
+ this.tagSprites.forEach((sprite) => {
8454
+ sprite.material.opacity = 1;
8455
+ });
8456
+ }
8457
+ /**
8458
+ * A calibration mark: a fixed size on screen and showing through the model, as the tags do, and
8459
+ * drawn in the colours it was painted in.
8460
+ *
8461
+ * The renderer's tone mapping and output conversion are there for the model's lighting. Put
8462
+ * through them a mark comes out pale - the amber nearer to cream - and a mark that has to be
8463
+ * picked out against a photograph of a building is the last thing that should be.
8464
+ */
8465
+ createCalibrationMark(map, renderOrder) {
8466
+ // Says the canvas holds sRGB, which it does, so the output conversion gives it back unchanged.
8467
+ if ('colorSpace' in map) {
8468
+ map.colorSpace = 'srgb'; // THREE.SRGBColorSpace, r152+
8469
+ }
8470
+ else {
8471
+ map.encoding = 3001; // THREE.sRGBEncoding
8472
+ }
8473
+ const mark = new THREE.Sprite(new THREE.SpriteMaterial({
8474
+ map, depthTest: false, transparent: true, sizeAttenuation: false, toneMapped: false,
8475
+ }));
8476
+ mark.renderOrder = renderOrder;
8477
+ return mark;
8478
+ }
8479
+ /** Shows a mark arriving: it starts oversized and settles. */
8480
+ pulse(sprite) {
8481
+ this.pulses.push({ sprite, startedAt: performance.now() });
8482
+ }
8483
+ stepPulses() {
8484
+ if (this.pulses.length === 0) {
8485
+ return;
8486
+ }
8487
+ const now = performance.now();
8488
+ this.pulses = this.pulses.filter(({ sprite, startedAt }) => {
8489
+ const size = sprite.userData.screenSize;
8490
+ if (!sprite.parent || !size) {
8491
+ // Redrawn or cleared in the meantime.
8492
+ return false;
8493
+ }
8494
+ const progress = Math.min(1, (now - startedAt) / ThreeJsService.CONFIRM_PULSE_MS);
8495
+ this.setScreenSize(sprite, size[0], size[1]);
8496
+ // Eased out, so most of the settling happens while the eye is still on the click.
8497
+ sprite.scale.multiplyScalar(1 + 0.9 * (1 - progress) ** 2);
8498
+ return progress < 1;
8028
8499
  });
8029
8500
  }
8030
8501
  /**
@@ -8049,6 +8520,7 @@ class ThreeJsService {
8049
8520
  if (this.renderer) {
8050
8521
  this.renderer.domElement.style.cursor = 'crosshair';
8051
8522
  }
8523
+ this.measuringChanged$.next(true);
8052
8524
  this.measurementProgress$.next({ points: 0, distances: [] });
8053
8525
  }
8054
8526
  /**
@@ -8069,8 +8541,10 @@ class ThreeJsService {
8069
8541
  this.renderer.domElement.style.cursor = 'default';
8070
8542
  }
8071
8543
  if (wasMeasuring) {
8544
+ this.measuringChanged$.next(false);
8072
8545
  this.measurementProgress$.next(null);
8073
8546
  }
8547
+ this.measurementCleared$.next();
8074
8548
  }
8075
8549
  /**
8076
8550
  * Ends the measurement and returns it, or null when there are not yet two points to measure
@@ -8079,11 +8553,12 @@ class ThreeJsService {
8079
8553
  * The drawing stays on the model so it is still visible while the person names the measurement;
8080
8554
  * cancelMeasuring() takes it away afterwards.
8081
8555
  */
8082
- finishMeasuring() {
8556
+ finishMeasuring(screenshot) {
8083
8557
  if (!this.measuring || this.measurePoints.length < 2) {
8084
8558
  return null;
8085
8559
  }
8086
8560
  this.measuring = false;
8561
+ this.measuringChanged$.next(false);
8087
8562
  this.pendingPreviewEvent = null;
8088
8563
  this.removePlacementPreview();
8089
8564
  this.updateMeasureRubberBand(null);
@@ -8091,17 +8566,39 @@ class ThreeJsService {
8091
8566
  this.lastMeasurement = {
8092
8567
  points: this.measurePoints.map((point) => ({ x: point.x, y: point.y, z: point.z })),
8093
8568
  distances: this.measureDistances(),
8094
- screenshot: this.captureMeasurementScreenshot(),
8569
+ // From the viewer the model is drawn in, when it is not this scene: the splat viewer.
8570
+ screenshot: screenshot ?? this.captureMeasurementScreenshot(),
8095
8571
  };
8096
8572
  return this.lastMeasurement;
8097
8573
  }
8098
- isMeasuring() {
8099
- return this.measuring;
8100
- }
8101
- /** The measurement finishMeasuring() last produced, for the form that saves it. */
8102
- getLastMeasurement() {
8103
- return this.lastMeasurement;
8104
- }
8574
+ /**
8575
+ * Adds a point to the measurement under way from a spot another viewer picked on the model - the
8576
+ * splat viewer - in the model's own coordinates. Into the frame the measurement is kept in, the
8577
+ * tags', through the calibration, as placeTagAtModelPoint does. False when not measuring.
8578
+ */
8579
+ addMeasurePointAtModelPoint(point) {
8580
+ if (!this.measuring) {
8581
+ return false;
8582
+ }
8583
+ this.tagGroup.updateMatrix();
8584
+ this.addMeasurePoint(new THREE.Vector3(point.x, point.y, point.z).applyMatrix4(this.tagGroup.matrix.clone().invert()));
8585
+ return true;
8586
+ }
8587
+ /** The measurement's points, under way or finished, in the model's own coordinates: for a viewer drawing it elsewhere. */
8588
+ getMeasurePointsInModelFrame() {
8589
+ this.tagGroup.updateMatrix();
8590
+ return this.measurePoints.map((point) => {
8591
+ const { x, y, z } = point.clone().applyMatrix4(this.tagGroup.matrix);
8592
+ return { x, y, z };
8593
+ });
8594
+ }
8595
+ isMeasuring() {
8596
+ return this.measuring;
8597
+ }
8598
+ /** The measurement finishMeasuring() last produced, for the form that saves it. */
8599
+ getLastMeasurement() {
8600
+ return this.lastMeasurement;
8601
+ }
8105
8602
  /** Metres between consecutive points. Tag space is in metres, so no conversion is involved. */
8106
8603
  measureDistances() {
8107
8604
  const distances = [];
@@ -8123,10 +8620,10 @@ class ThreeJsService {
8123
8620
  // anything sized in metres would cover the very thing being measured.
8124
8621
  sizeAttenuation: false,
8125
8622
  }));
8126
- marker.scale.set(0.022, 0.022, 1);
8127
8623
  marker.position.copy(point);
8128
8624
  marker.renderOrder = 1001;
8129
8625
  this.measureGroup.add(marker);
8626
+ this.setScreenSize(marker, 12);
8130
8627
  if (previous) {
8131
8628
  this.measureGroup.add(this.createMeasureLine(previous, point));
8132
8629
  const distance = Math.round(previous.distanceTo(point) * 100) / 100;
@@ -8136,10 +8633,10 @@ class ThreeJsService {
8136
8633
  transparent: true,
8137
8634
  sizeAttenuation: false,
8138
8635
  }));
8139
- label.scale.set(0.15, 0.05, 1);
8140
8636
  label.position.copy(previous).add(point).multiplyScalar(0.5);
8141
8637
  label.renderOrder = 1002;
8142
8638
  this.measureGroup.add(label);
8639
+ this.setScreenSize(label, 84, 28);
8143
8640
  }
8144
8641
  this.measurementProgress$.next({
8145
8642
  points: this.measurePoints.length,
@@ -8152,12 +8649,12 @@ class ThreeJsService {
8152
8649
  * WebGL's own lines are one pixel wide whatever is asked for, which all but disappears over a
8153
8650
  * photographic texture. This kind is drawn as screen-facing geometry, so the width holds.
8154
8651
  */
8155
- createMeasureLine(from, to) {
8652
+ createMeasureLine(from, to, color = ThreeJsService.MEASURE_COLOR, width = 3) {
8156
8653
  const geometry = new LineGeometry();
8157
8654
  geometry.setPositions([from.x, from.y, from.z, to.x, to.y, to.z]);
8158
8655
  const material = new LineMaterial({
8159
- color: new THREE.Color(ThreeJsService.MEASURE_COLOR).getHex(),
8160
- linewidth: 3,
8656
+ color: new THREE.Color(color).getHex(),
8657
+ linewidth: width,
8161
8658
  depthTest: false,
8162
8659
  transparent: true,
8163
8660
  });
@@ -8173,7 +8670,7 @@ class ThreeJsService {
8173
8670
  return;
8174
8671
  }
8175
8672
  const size = this.renderer.getSize(new THREE.Vector2());
8176
- this.measureGroup.children.forEach((child) => {
8673
+ [...this.measureGroup.children, ...this.calibrationGroup.children].forEach((child) => {
8177
8674
  if (child.material?.resolution) {
8178
8675
  child.material.resolution.set(size.x, size.y);
8179
8676
  }
@@ -8259,6 +8756,12 @@ class ThreeJsService {
8259
8756
  });
8260
8757
  return canvas.toDataURL('image/jpeg', 0.85);
8261
8758
  }
8759
+ /**
8760
+ * True when tag placement is armed, false when it ends - placed or abandoned. For a viewer drawing
8761
+ * the model instead of this scene, the splat viewer, which picks the spot itself; see
8762
+ * placeTagAtModelPoint.
8763
+ */
8764
+ placementChanged$ = new Subject();
8262
8765
  /** Arms tag placement: the next click on the model drops a tag instead of being ignored. */
8263
8766
  startTagPlacement(poiType = null) {
8264
8767
  this.placingTag = true;
@@ -8267,9 +8770,40 @@ class ThreeJsService {
8267
8770
  if (this.renderer) {
8268
8771
  this.renderer.domElement.style.cursor = 'crosshair';
8269
8772
  }
8773
+ this.placementChanged$.next(true);
8774
+ }
8775
+ /**
8776
+ * Places the armed tag at a spot another viewer picked on the model - the splat viewer - given
8777
+ * in the model's own coordinates, as a click on the model in this scene would. Into the frame tag
8778
+ * coordinates are stored in, through the calibration, as pickPlacementOnModel does.
8779
+ */
8780
+ placeTagAtModelPoint(point, normal = null) {
8781
+ if (!this.placingTag) {
8782
+ return null;
8783
+ }
8784
+ this.tagGroup.updateMatrix();
8785
+ const position = new THREE.Vector3(point.x, point.y, point.z).applyMatrix4(this.tagGroup.matrix.clone().invert());
8786
+ // Turned only: the calibration's scale changes no direction.
8787
+ const facing = normal
8788
+ ? new THREE.Vector3(normal.x, normal.y, normal.z).applyQuaternion(this.tagGroup.quaternion.clone().invert()).normalize()
8789
+ : new THREE.Vector3(0, 1, 0);
8790
+ const placement = {
8791
+ position: { x: position.x, y: position.y, z: position.z },
8792
+ normal: { x: facing.x, y: facing.y, z: facing.z },
8793
+ poiType: this.placementPoiType,
8794
+ };
8795
+ this.pendingTagPlacement = placement;
8796
+ this.placingTag = false;
8797
+ this.removePlacementPreview();
8798
+ this.placementChanged$.next(false);
8799
+ this.tagPlaced$.next(placement);
8800
+ return placement;
8270
8801
  }
8271
8802
  /** Leaves placement mode without placing anything. */
8272
8803
  cancelTagPlacement() {
8804
+ if (this.placingTag) {
8805
+ this.placementChanged$.next(false);
8806
+ }
8273
8807
  this.placingTag = false;
8274
8808
  this.pendingTagPlacement = null;
8275
8809
  this.pendingPreviewEvent = null;
@@ -8294,15 +8828,20 @@ class ThreeJsService {
8294
8828
  }
8295
8829
  this.renderer.domElement.style.cursor = 'crosshair';
8296
8830
  if (!this.placementPreview) {
8297
- this.placementPreview = new THREE.Sprite(new THREE.SpriteMaterial({
8298
- map: this.createTagTexture('#9E9E9E'),
8299
- depthTest: false,
8300
- transparent: true,
8301
- opacity: 0.6,
8302
- }));
8831
+ // While calibrating, the ghost is the pin the click will leave, number and all: what is
8832
+ // under the pointer is what stays there.
8833
+ this.placementPreview = this.aligning
8834
+ ? this.createCalibrationMark(this.createNumberedTexture(this.alignmentPairs.length + 1, ThreeJsService.CALIBRATION_DONE_COLOR), 999)
8835
+ : new THREE.Sprite(new THREE.SpriteMaterial({
8836
+ map: this.createTagTexture('#9E9E9E'),
8837
+ depthTest: false,
8838
+ transparent: true,
8839
+ sizeAttenuation: false,
8840
+ }));
8303
8841
  this.placementPreview.renderOrder = 999;
8842
+ this.placementPreview.material.opacity = 0.6;
8304
8843
  this.tagGroup.add(this.placementPreview);
8305
- this.scaleTagForModel(this.placementPreview);
8844
+ this.setScreenSize(this.placementPreview, this.aligning ? ThreeJsService.CALIBRATION_PIN_PX : ThreeJsService.TAG_SCREEN_PX);
8306
8845
  }
8307
8846
  this.placementPreview.position.copy(position);
8308
8847
  this.updateMeasureRubberBand(position);
@@ -8409,6 +8948,16 @@ class ThreeJsService {
8409
8948
  setVisibleTagTypes(types) {
8410
8949
  this.visibleTagTypes = types;
8411
8950
  this.tagSprites.forEach((sprite) => this.applyTagVisibility(sprite));
8951
+ this.announceTagsChanged();
8952
+ }
8953
+ /** Says whether the visit on screen is the site's only one; see soleVisit. */
8954
+ setSoleVisit(sole) {
8955
+ this.soleVisit = sole;
8956
+ this.tagSprites.forEach((sprite) => {
8957
+ this.parentTag(sprite);
8958
+ this.applyTagVisibility(sprite);
8959
+ });
8960
+ this.announceTagsChanged();
8412
8961
  }
8413
8962
  /** Says which capture is on screen, so the tags placed in it can be told from the rest. */
8414
8963
  setCurrentCapture(captureID) {
@@ -8417,6 +8966,7 @@ class ThreeJsService {
8417
8966
  this.parentTag(sprite);
8418
8967
  this.applyTagVisibility(sprite);
8419
8968
  });
8969
+ this.announceTagsChanged();
8420
8970
  }
8421
8971
  /** Every tag registered in the scene, shown or not. */
8422
8972
  getTags() {
@@ -8492,8 +9042,8 @@ class ThreeJsService {
8492
9042
  }
8493
9043
  /** Whether the tag was placed in the visit on screen. */
8494
9044
  isOwnedByVisit(sprite) {
8495
- return !!sprite.userData.originCaptureID
8496
- && sprite.userData.originCaptureID === this.currentCaptureID;
9045
+ const origin = sprite.userData.originCaptureID;
9046
+ return origin ? origin === this.currentCaptureID : this.soleVisit;
8497
9047
  }
8498
9048
  /**
8499
9049
  * A tag shows when its type is not filtered out and it belongs on this model.
@@ -8522,8 +9072,9 @@ class ThreeJsService {
8522
9072
  if (sprite.userData.frame === 'model') {
8523
9073
  return false;
8524
9074
  }
8525
- // Calibrating is matching tags to where they belong, so they all have to be on offer.
8526
- if (this.aligning) {
9075
+ // Calibrating is matching tags to where they belong, so they all have to be on offer - from
9076
+ // the moment the panel opens, not only once the first click is being waited for.
9077
+ if (this.aligning || this.revealingCalibrationTags) {
8527
9078
  return true;
8528
9079
  }
8529
9080
  return this.isOnModel(sprite);
@@ -8661,6 +9212,9 @@ class ThreeJsService {
8661
9212
  */
8662
9213
  goToTag(elementId) {
8663
9214
  const sprite = this.tagSprites.get(elementId);
9215
+ if (sprite) {
9216
+ this.tagFocused$.next(elementId);
9217
+ }
8664
9218
  if (!sprite || !this.camera) {
8665
9219
  return;
8666
9220
  }
@@ -8782,10 +9336,11 @@ class ThreeJsService {
8782
9336
  this.tagGroup.rotation.set(rotation?.x ?? 0, rotation?.y ?? 0, rotation?.z ?? 0);
8783
9337
  this.tagGroup.scale.setScalar(scale ?? 1);
8784
9338
  this.tagGroup.updateMatrix();
8785
- // Tag size is derived from the world scale it inherits, which this call just changed - and so
8786
- // is which tags land on the model.
8787
- this.tagSprites.forEach((sprite) => this.scaleTagForModel(sprite));
9339
+ // Marker sizes are worked back from the scale they inherit, which this call just changed - and
9340
+ // so is which tags land on the model.
9341
+ this.refreshScreenSizes();
8788
9342
  this.refreshTagVisibility();
9343
+ this.announceTagsChanged();
8789
9344
  }
8790
9345
  /**
8791
9346
  * Adds a tag, or moves/restyles the one already registered for this element.
@@ -8802,22 +9357,29 @@ class ThreeJsService {
8802
9357
  existing.userData.label = tag.label ?? existing.userData.label;
8803
9358
  existing.userData.originCaptureID = tag.originCaptureID ?? existing.userData.originCaptureID;
8804
9359
  existing.userData.frame = tag.frame ?? existing.userData.frame;
9360
+ existing.userData.iconUrl = tag.iconUrl ?? existing.userData.iconUrl;
9361
+ existing.userData.normal = tag.normal ?? existing.userData.normal;
8805
9362
  this.parentTag(existing);
8806
9363
  this.applyTagVisibility(existing);
9364
+ this.announceTagsChanged();
8807
9365
  return;
8808
9366
  }
8809
9367
  const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
8810
9368
  map: this.createTagTexture(tag.color),
8811
9369
  // Tags read as UI rather than geometry, so they stay visible through the model instead of
8812
- // being occluded by whatever wall happens to be between them and the camera.
9370
+ // being occluded by whatever wall happens to be between them and the camera - and, for
9371
+ // the same reason, keep one size on screen rather than a size in the model.
8813
9372
  depthTest: false,
8814
9373
  transparent: true,
9374
+ sizeAttenuation: false,
8815
9375
  }));
8816
9376
  sprite.name = tag.id;
8817
9377
  sprite.userData.poiType = tag.poiType ?? null;
8818
9378
  sprite.userData.label = tag.label ?? null;
8819
9379
  sprite.userData.originCaptureID = tag.originCaptureID ?? null;
8820
9380
  sprite.userData.frame = tag.frame ?? null;
9381
+ sprite.userData.iconUrl = tag.iconUrl ?? null;
9382
+ sprite.userData.normal = tag.normal ?? null;
8821
9383
  sprite.position.set(tag.position.x, tag.position.y, tag.position.z);
8822
9384
  sprite.renderOrder = 999;
8823
9385
  this.parentTag(sprite);
@@ -8827,6 +9389,52 @@ class ThreeJsService {
8827
9389
  if (tag.iconUrl) {
8828
9390
  this.applyTagIcon(sprite, tag.iconUrl);
8829
9391
  }
9392
+ this.announceTagsChanged();
9393
+ }
9394
+ /**
9395
+ * The tags another viewer should show, and the calibration they are drawn under.
9396
+ *
9397
+ * The same ones this scene would offer, short of the test against the model's surface, which needs
9398
+ * the model here: the type filter applies, and a tag placed in another model before it was
9399
+ * calibrated is left out, its coordinates meaning nothing in this one.
9400
+ */
9401
+ getTagSnapshot() {
9402
+ const tags = [];
9403
+ this.tagSprites.forEach((sprite) => {
9404
+ const owned = this.isOwnedByVisit(sprite);
9405
+ const typeAllowed = this.visibleTagTypes === null || this.visibleTagTypes.includes(sprite.userData.poiType);
9406
+ if (!typeAllowed || (sprite.userData.frame === 'model' && !owned)) {
9407
+ return;
9408
+ }
9409
+ tags.push({
9410
+ id: sprite.name,
9411
+ position: { x: sprite.position.x, y: sprite.position.y, z: sprite.position.z },
9412
+ label: sprite.userData.label ?? null,
9413
+ poiType: sprite.userData.poiType ?? null,
9414
+ iconUrl: sprite.userData.iconUrl ?? null,
9415
+ inModelFrame: sprite.userData.frame === 'model' && owned,
9416
+ normal: sprite.userData.normal ?? null,
9417
+ });
9418
+ });
9419
+ const group = this.tagGroup;
9420
+ return {
9421
+ tags,
9422
+ alignment: {
9423
+ translation: { x: group.position.x, y: group.position.y, z: group.position.z },
9424
+ rotation: { x: group.rotation.x, y: group.rotation.y, z: group.rotation.z },
9425
+ scale: group.scale.x,
9426
+ },
9427
+ };
9428
+ }
9429
+ announceTagsChanged() {
9430
+ if (this.tagsChangeQueued) {
9431
+ return;
9432
+ }
9433
+ this.tagsChangeQueued = true;
9434
+ queueMicrotask(() => {
9435
+ this.tagsChangeQueued = false;
9436
+ this.tagsChanged$.next();
9437
+ });
8830
9438
  }
8831
9439
  /** Removes the tag registered for an element, if there is one. */
8832
9440
  removeTag(elementId) {
@@ -8838,6 +9446,7 @@ class ThreeJsService {
8838
9446
  sprite.material.map?.dispose();
8839
9447
  sprite.material.dispose();
8840
9448
  this.tagSprites.delete(elementId);
9449
+ this.announceTagsChanged();
8841
9450
  }
8842
9451
  /** Removes every tag from the scene. */
8843
9452
  clearTags() {
@@ -8867,18 +9476,78 @@ class ThreeJsService {
8867
9476
  context.stroke();
8868
9477
  return new THREE.CanvasTexture(canvas);
8869
9478
  }
9479
+ /** The default marker with a number on it: the nth point of a calibration. */
9480
+ createNumberedTexture(number, color) {
9481
+ const texture = this.createTagTexture(color);
9482
+ const canvas = texture.image;
9483
+ const context = canvas.getContext('2d');
9484
+ context.fillStyle = '#FFFFFF';
9485
+ context.font = 'bold 76px sans-serif';
9486
+ context.textAlign = 'center';
9487
+ context.textBaseline = 'middle';
9488
+ context.fillText(String(number), canvas.width / 2, canvas.height / 2 + 5);
9489
+ return texture;
9490
+ }
9491
+ /** A ring with nothing in the middle, to go round a tag and leave it showing. */
9492
+ createRingTexture(color) {
9493
+ const size = 128;
9494
+ const canvas = document.createElement('canvas');
9495
+ canvas.width = size;
9496
+ canvas.height = size;
9497
+ const context = canvas.getContext('2d');
9498
+ // White under the colour, a little wider, for the same reason the tags have a white edge.
9499
+ context.beginPath();
9500
+ context.arc(size / 2, size / 2, size / 2 - 10, 0, Math.PI * 2);
9501
+ context.lineWidth = 16;
9502
+ context.strokeStyle = '#FFFFFF';
9503
+ context.stroke();
9504
+ context.lineWidth = 10;
9505
+ context.strokeStyle = color;
9506
+ context.stroke();
9507
+ return new THREE.CanvasTexture(canvas);
9508
+ }
8870
9509
  /**
8871
- * Sizes a tag relative to the model.
9510
+ * Gives a tag its size: the same number of pixels on screen whatever the model.
8872
9511
  *
8873
- * A sprite inherits the model's scale and the alignment's, so a fixed size would come out tiny on
8874
- * a large model and huge on a small one. Dividing by the group's world scale keeps tags the same
8875
- * size on screen whatever the model's units are.
9512
+ * It used to be a fixed fraction of the model instead. That reads fine on a room, but on a model
9513
+ * the size of a city block it is a tag several metres across, which fills the view as soon as
9514
+ * the camera moves in to look at anything.
8876
9515
  */
8877
9516
  scaleTagForModel(sprite) {
8878
- // Its own parent's scale: tags in the model's coordinates do not inherit the calibration's.
8879
- const worldScale = (sprite.parent ?? this.tagGroup).getWorldScale(new THREE.Vector3()).x || 1;
8880
- const size = 0.4 / worldScale;
8881
- sprite.scale.set(size, size, 1);
9517
+ this.setScreenSize(sprite, ThreeJsService.TAG_SCREEN_PX);
9518
+ }
9519
+ /**
9520
+ * Fixes a sprite's size on screen, in CSS pixels.
9521
+ *
9522
+ * The sprite must be drawn without size attenuation, which makes its size a proportion of the
9523
+ * viewport instead of something that shrinks with distance. Its scale is then worked back from
9524
+ * the pixels wanted, the viewport's height and the scale it inherits from its parents - the
9525
+ * model's normalisation and, for tags, the calibration - so none of those show in the result.
9526
+ * The size asked for is kept on the sprite, so it can be worked out again when any of them changes.
9527
+ */
9528
+ setScreenSize(sprite, widthPx, heightPx = widthPx) {
9529
+ sprite.userData.screenSize = [widthPx, heightPx];
9530
+ const inherited = (sprite.parent ?? this.tagGroup).getWorldScale(new THREE.Vector3()).x || 1;
9531
+ const perPixel = this.worldUnitsPerPixel() / inherited;
9532
+ sprite.scale.set(widthPx * perPixel, heightPx * perPixel, 1);
9533
+ }
9534
+ /** What one screen pixel is worth in the scale of a sprite drawn without size attenuation. */
9535
+ worldUnitsPerPixel() {
9536
+ const height = this.renderer?.getSize?.(new THREE.Vector2()).y || 800;
9537
+ const fieldOfView = THREE.MathUtils.degToRad(this.camera?.fov ?? 75);
9538
+ return (2 * Math.tan(fieldOfView / 2)) / height;
9539
+ }
9540
+ /** Re-applies every marker's on-screen size: the viewport, the model or the calibration changed. */
9541
+ refreshScreenSizes() {
9542
+ const resize = (object) => {
9543
+ if (object?.userData?.screenSize) {
9544
+ this.setScreenSize(object, object.userData.screenSize[0], object.userData.screenSize[1]);
9545
+ }
9546
+ };
9547
+ this.tagSprites.forEach(resize);
9548
+ this.measureGroup.children.forEach(resize);
9549
+ this.calibrationGroup.children.forEach(resize);
9550
+ resize(this.placementPreview);
8882
9551
  }
8883
9552
  /**
8884
9553
  * Adds secondary interactive objects (e.g., POIs, sensors) to the scene.
@@ -8992,6 +9661,7 @@ class ThreeJsService {
8992
9661
  this.placingTag = false;
8993
9662
  this.removePlacementPreview();
8994
9663
  this.renderer.domElement.style.cursor = 'default';
9664
+ this.placementChanged$.next(false);
8995
9665
  this.tagPlaced$.next(placement);
8996
9666
  }
8997
9667
  return;
@@ -9019,12 +9689,19 @@ class ThreeJsService {
9019
9689
  }
9020
9690
  }
9021
9691
  /**
9022
- * Escape cancels whatever the pointer is currently committed to.
9692
+ * Escape cancels whatever the pointer is currently committed to. While calibrating, the undo keys
9693
+ * take back one step of it instead of all of it.
9023
9694
  *
9024
9695
  * Emits through the same subjects the explicit Cancel buttons use, so the UI driving them follows
9025
9696
  * along instead of being left showing a mode that is no longer armed.
9026
9697
  */
9027
9698
  onKeyDown = (event) => {
9699
+ if (this.aligning && this.isUndoKey(event)) {
9700
+ if (this.undoAlignmentStep()) {
9701
+ event.preventDefault();
9702
+ }
9703
+ return;
9704
+ }
9028
9705
  if (event.key !== 'Escape') {
9029
9706
  return;
9030
9707
  }
@@ -9041,9 +9718,22 @@ class ThreeJsService {
9041
9718
  this.cancelTagAlignment();
9042
9719
  }
9043
9720
  };
9721
+ /**
9722
+ * Ctrl+Z (Cmd+Z on a Mac) or Backspace, unless typed into a field - where they mean something
9723
+ * else, to whatever the field is.
9724
+ */
9725
+ isUndoKey(event) {
9726
+ const target = event.target;
9727
+ if (target?.isContentEditable || ['INPUT', 'TEXTAREA'].includes(target?.tagName ?? '')) {
9728
+ return false;
9729
+ }
9730
+ return event.key === 'Backspace'
9731
+ || ((event.ctrlKey || event.metaKey) && !event.shiftKey && event.key.toLowerCase() === 'z');
9732
+ }
9044
9733
  animate = () => {
9045
9734
  this.animationFrameId = requestAnimationFrame(this.animate);
9046
9735
  this.stepCameraTween();
9736
+ this.stepPulses();
9047
9737
  this.controls.update();
9048
9738
  // One pick per frame, against the pointer's latest position - see onMouseMove.
9049
9739
  if (this.pendingPreviewEvent) {
@@ -9053,11 +9743,84 @@ class ThreeJsService {
9053
9743
  }
9054
9744
  this.renderer.render(this.scene, this.camera);
9055
9745
  };
9056
- destroy() {
9746
+ /**
9747
+ * Stops drawing the scene, or starts again. For while another viewer covers it - the splat viewer
9748
+ * - where it would otherwise go on drawing, unseen, every frame, on the graphics card the other
9749
+ * viewer needs. The scene keeps its tags and calibration all the same.
9750
+ */
9751
+ setRenderingPaused(paused) {
9752
+ if (paused) {
9753
+ this.stopRendering();
9754
+ }
9755
+ else if (this.live && !this.animationFrameId) {
9756
+ this.ngZone.runOutsideAngular(() => this.animate());
9757
+ }
9758
+ }
9759
+ /** Stops the render loop, if one is running. */
9760
+ stopRendering() {
9057
9761
  if (this.animationFrameId) {
9058
9762
  cancelAnimationFrame(this.animationFrameId);
9763
+ this.animationFrameId = 0;
9059
9764
  }
9765
+ }
9766
+ /**
9767
+ * Takes the model out of the scene and frees what it holds on the graphics card.
9768
+ *
9769
+ * The tags are kept. They hang from the model's group so as to share its frame, and are moved out
9770
+ * of it first: they belong to the visit, not to the file that was drawn under them.
9771
+ */
9772
+ removeModel() {
9773
+ const group = this.modelGroup;
9774
+ const model = this.modelRoot;
9775
+ this.modelGroup = undefined;
9776
+ this.modelRoot = undefined;
9777
+ this.surfaceCells = null;
9778
+ this.modelWorldRadius = 0;
9779
+ [this.tagGroup, this.modelTagGroup, this.calibrationGroup].forEach((kept) => kept.parent?.remove(kept));
9780
+ group?.parent?.remove(group);
9781
+ if (model) {
9782
+ this.disposeModel(model);
9783
+ }
9784
+ }
9785
+ /**
9786
+ * Frees a model's geometry, materials and textures.
9787
+ *
9788
+ * Dropping the last reference to a model does not do this. What it uploaded stays on the graphics
9789
+ * card until the page is closed - hundreds of megabytes for a captured building - and on a
9790
+ * machine whose graphics memory is shared with the rest of the system, everything slows down
9791
+ * long before anything fails.
9792
+ */
9793
+ disposeModel(model) {
9794
+ const freed = new Set();
9795
+ const free = (resource) => {
9796
+ if (resource && typeof resource.dispose === 'function' && !freed.has(resource)) {
9797
+ freed.add(resource);
9798
+ resource.dispose();
9799
+ }
9800
+ };
9801
+ model.traverse((child) => {
9802
+ free(child.geometry);
9803
+ const materials = Array.isArray(child.material) ? child.material : [child.material];
9804
+ materials.forEach((material) => {
9805
+ if (!material) {
9806
+ return;
9807
+ }
9808
+ // Whichever slots this kind of material has: map, normalMap, emissiveMap...
9809
+ Object.values(material).forEach((value) => {
9810
+ if (value?.isTexture) {
9811
+ free(value);
9812
+ }
9813
+ });
9814
+ free(material);
9815
+ });
9816
+ });
9817
+ }
9818
+ destroy() {
9819
+ this.live = false;
9820
+ this.stopRendering();
9060
9821
  window.removeEventListener('keydown', this.onKeyDown);
9822
+ this.canvasListeners.forEach((remove) => remove());
9823
+ this.canvasListeners = [];
9061
9824
  if (this.canvasResizeObserver) {
9062
9825
  this.canvasResizeObserver.disconnect();
9063
9826
  this.canvasResizeObserver = undefined;
@@ -9066,6 +9829,13 @@ class ThreeJsService {
9066
9829
  this.clearTags();
9067
9830
  this.measuring = false;
9068
9831
  this.clearMeasurement();
9832
+ this.clearCalibrationMarks();
9833
+ this.pulses = [];
9834
+ // While the renderer is still there to hand the memory back through.
9835
+ this.removeModel();
9836
+ // They were in the scene that is going. Kept, the next scene would go on testing every pointer
9837
+ // move against objects nobody can see, and would skip loading them again as "already there".
9838
+ this.clickableObjects = [];
9069
9839
  if (this.renderer) {
9070
9840
  this.renderer.dispose();
9071
9841
  }
@@ -9551,6 +10321,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9551
10321
  /* eslint-disable camelcase */
9552
10322
  /* eslint-disable no-underscore-dangle */
9553
10323
  /* eslint-disable class-methods-use-this */
10324
+ /**
10325
+ * What a Gaussian splat file is named with, when it is a .ply: the content is what tells it from
10326
+ * another .ply, and the key is all a visit stores (see isGaussianSplatPly).
10327
+ */
10328
+ const GAUSSIAN_SPLAT_PLY_SUFFIX = '.splat.ply';
10329
+ /**
10330
+ * Whether a 3D model file holds Gaussian splats, which the Three.js viewer cannot draw: .spz,
10331
+ * .splat, .ksplat, SuperSplat's .sog, a .ply named with GAUSSIAN_SPLAT_PLY_SUFFIX, or the
10332
+ * lod-meta.json of a Streamed SOG - SuperSplat's levels of detail, in pieces beside it.
10333
+ */
10334
+ function isGaussianSplatFile(name) {
10335
+ return /\.(spz|splat|ksplat|sog|splat\.ply)($|\?)/i.test(name ?? '') || isStreamedSplatFile(name);
10336
+ }
10337
+ /**
10338
+ * Whether a .ply holds Gaussian splats: what splat tools export carries, for each splat, its colour
10339
+ * as spherical harmonics (f_dc_0...) and its size (scale_0...). Only the header is read.
10340
+ */
10341
+ async function isGaussianSplatPly(file) {
10342
+ const start = await file.slice(0, 64 * 1024).text();
10343
+ const end = start.indexOf('end_header');
10344
+ if (!start.startsWith('ply') || end < 0) {
10345
+ return false;
10346
+ }
10347
+ const properties = start.slice(0, end).split(/\r?\n/)
10348
+ .map((line) => line.trim().split(/\s+/))
10349
+ .filter((words) => words[0] === 'property')
10350
+ .map((words) => words[words.length - 1]);
10351
+ return properties.includes('f_dc_0') && properties.includes('scale_0');
10352
+ }
10353
+ /** Whether a 3D model file is the lod-meta.json of a Streamed SOG; see isGaussianSplatFile. */
10354
+ function isStreamedSplatFile(name) {
10355
+ return /(^|\/)lod-meta\.json($|\?)/i.test(name ?? '');
10356
+ }
9554
10357
  class ViewerService {
9555
10358
  sdkKey;
9556
10359
  config;
@@ -9827,15 +10630,35 @@ class ViewerService {
9827
10630
  if (![position?.x, position?.y, position?.z].every((value) => typeof value === 'number')) {
9828
10631
  return;
9829
10632
  }
10633
+ // A tag is its position; the icon is how it is dressed. One that cannot be fetched - a
10634
+ // signature that expired, a file gone from the bucket - must not cost the tag itself.
10635
+ let iconUrl;
10636
+ try {
10637
+ iconUrl = await this.resolveTagIconUrl(poi);
10638
+ }
10639
+ catch (error) {
10640
+ console.warn(`ViewerService: no icon for the tag of element ${object.id}, using the default one.`, error);
10641
+ iconUrl = this.defaultTagIconUrl(poi.type);
10642
+ }
9830
10643
  const origin = getThreeJsPoiOrigin(poi);
10644
+ // Matterport's stem, kept with the POI by both viewers that place tags.
10645
+ let normal = null;
10646
+ try {
10647
+ const stored = poi.metadata ? JSON.parse(poi.metadata)?.normal : null;
10648
+ normal = [stored?.x, stored?.y, stored?.z].every((value) => typeof value === 'number') ? stored : null;
10649
+ }
10650
+ catch {
10651
+ normal = null;
10652
+ }
9831
10653
  this.threeJsService.upsertTag({
9832
10654
  id: object.id,
9833
10655
  position,
9834
10656
  poiType: poi.type,
9835
10657
  label: object.name ?? object.title ?? null,
9836
- iconUrl: await this.resolveTagIconUrl(poi),
10658
+ iconUrl,
9837
10659
  originCaptureID: origin?.captureID ?? null,
9838
10660
  frame: origin?.frame ?? null,
10661
+ normal,
9839
10662
  });
9840
10663
  }
9841
10664
  /**
@@ -9953,6 +10776,40 @@ class ViewerService {
9953
10776
  this.threeJsService.goToTag(elementId);
9954
10777
  }
9955
10778
  }
10779
+ /** The tag the Three.js camera is sent to, for the splat viewer to point out; see goToThreeJsTag. */
10780
+ get threeJsTagFocused$() {
10781
+ return this.threeJsService.tagFocused$;
10782
+ }
10783
+ /** A tag clicked in the splat viewer, said as threeJsTagClicked$ says one clicked in the scene. */
10784
+ clickThreeJsTag(elementId) {
10785
+ if (this.checkMode('threejs')) {
10786
+ this.threeJsService.clickTag(elementId);
10787
+ }
10788
+ }
10789
+ /** Whether the visit's 3D model has a calibration, from its capture's metadata. */
10790
+ isThreeJsCalibrated() {
10791
+ return this.threeJsCalibrated;
10792
+ }
10793
+ /** Whether the tags a calibration works with are on show; see ThreeJsService.showsCalibrationTags. */
10794
+ isThreeJsShowingCalibrationTags() {
10795
+ return this.checkMode('threejs') && this.threeJsService.showsCalibrationTags();
10796
+ }
10797
+ /** Whether a calibration is under way in the Three.js scene. */
10798
+ isThreeJsAligningTags() {
10799
+ return this.checkMode('threejs') && this.threeJsService.isAligningTags();
10800
+ }
10801
+ /** Whether a measurement is taking clicks in the Three.js scene. */
10802
+ isThreeJsMeasuring() {
10803
+ return this.checkMode('threejs') && this.threeJsService.isMeasuring();
10804
+ }
10805
+ /** True when a measurement starts taking clicks, false when it stops; see ThreeJsService.measuringChanged$. */
10806
+ get threeJsMeasuringChanged$() {
10807
+ return this.threeJsService.measuringChanged$;
10808
+ }
10809
+ /** Says a click in the splat viewer was of no use to the calibration, as one in the scene would. */
10810
+ ignoreThreeJsAlignmentClick(expected) {
10811
+ this.threeJsService.alignmentClickIgnored$.next(expected);
10812
+ }
9956
10813
  /** Shows only tags of the given POI types; null clears the filter. */
9957
10814
  setVisibleThreeJsTagTypes(types) {
9958
10815
  if (this.checkMode('threejs')) {
@@ -9975,6 +10832,24 @@ class ViewerService {
9975
10832
  this.threeJsService.cancelTagAlignment();
9976
10833
  }
9977
10834
  }
10835
+ /**
10836
+ * Says whether the 3D model on screen is the site's only visit. Then there is nowhere else for a
10837
+ * tag to have come from, and the tags that do not record where they were placed are its own.
10838
+ */
10839
+ setThreeJsSoleVisit(sole) {
10840
+ if (this.checkMode('threejs')) {
10841
+ this.threeJsService.setSoleVisit(sole);
10842
+ }
10843
+ }
10844
+ /**
10845
+ * Shows the tags a calibration would work with, including those hidden for not landing on the
10846
+ * model, before anything is armed. Cancelling or saving the calibration hides them again.
10847
+ */
10848
+ revealThreeJsCalibrationTags() {
10849
+ if (this.checkMode('threejs')) {
10850
+ this.threeJsService.revealCalibrationTags(true);
10851
+ }
10852
+ }
9978
10853
  get threeJsAlignmentProgress$() {
9979
10854
  return this.threeJsService.alignmentProgress$;
9980
10855
  }
@@ -10149,17 +11024,35 @@ class ViewerService {
10149
11024
  get threeJsMeasurementProgress$() {
10150
11025
  return this.threeJsService.measurementProgress$;
10151
11026
  }
10152
- /** Ends the Three.js measurement in progress, or returns null when it has fewer than two points. */
10153
- finishThreeJsMeasurement() {
11027
+ /**
11028
+ * Ends the Three.js measurement in progress, or returns null when it has fewer than two points.
11029
+ * `screenshot` is the picture of it, when the model is drawn by another viewer than the scene.
11030
+ */
11031
+ finishThreeJsMeasurement(screenshot) {
10154
11032
  if (!this.checkMode('threejs')) {
10155
11033
  return null;
10156
11034
  }
10157
- const measurement = this.threeJsService.finishMeasuring();
11035
+ const measurement = this.threeJsService.finishMeasuring(screenshot);
10158
11036
  if (measurement) {
10159
11037
  this.toolboxStates.mesure.stat = false;
10160
11038
  }
10161
11039
  return measurement;
10162
11040
  }
11041
+ /** A measurement was taken off the model, finished or not; see ThreeJsService.measurementCleared$. */
11042
+ get threeJsMeasurementCleared$() {
11043
+ return this.threeJsService.measurementCleared$;
11044
+ }
11045
+ /**
11046
+ * Adds a point to the measurement under way, picked on the model in another viewer - the splat
11047
+ * viewer - in the model's own coordinates. False when no measurement is under way.
11048
+ */
11049
+ addThreeJsMeasurePointAtModelPoint(point) {
11050
+ return this.checkMode('threejs') && this.threeJsService.addMeasurePointAtModelPoint(point);
11051
+ }
11052
+ /** The points of the measurement on the model, in the model's own coordinates, for another viewer to draw. */
11053
+ getThreeJsMeasurePointsInModelFrame() {
11054
+ return this.checkMode('threejs') ? this.threeJsService.getMeasurePointsInModelFrame() : [];
11055
+ }
10163
11056
  /** The measurement last finished in the Three.js viewer, for the form that saves it. */
10164
11057
  getThreeJsLastMeasurement() {
10165
11058
  return this.checkMode('threejs') ? this.threeJsService.getLastMeasurement() : null;
@@ -10221,6 +11114,24 @@ class ViewerService {
10221
11114
  selectThreeJsAlignmentTag(elementId) {
10222
11115
  return this.checkMode('threejs') && this.threeJsService.selectAlignmentTag(elementId);
10223
11116
  }
11117
+ /**
11118
+ * Gives the tag being matched in the calibration under way its real place, picked on the model in
11119
+ * another viewer - the splat viewer - in the model's own coordinates. False when no tag was waiting.
11120
+ */
11121
+ matchThreeJsAlignmentTagAtModelPoint(point) {
11122
+ return this.checkMode('threejs') && this.threeJsService.matchAlignmentTagAtModelPoint(point);
11123
+ }
11124
+ /**
11125
+ * Takes back the last step of the calibration under way: the tag just chosen, or else the last
11126
+ * pair matched. False when there was nothing to take back.
11127
+ */
11128
+ undoThreeJsAlignmentStep() {
11129
+ return this.checkMode('threejs') && this.threeJsService.undoAlignmentStep();
11130
+ }
11131
+ /** Removes one matched pair of the calibration under way, by its place in the list. */
11132
+ removeThreeJsAlignmentPair(index) {
11133
+ return this.checkMode('threejs') && this.threeJsService.removeAlignmentPair(index);
11134
+ }
10224
11135
  /** How far the visible tags sit from the 3D model, in model radii. Null without both. */
10225
11136
  getThreeJsTagDistanceFromModel() {
10226
11137
  return this.checkMode('threejs') ? this.threeJsService.getTagDistanceFromModel() : null;
@@ -10295,6 +11206,11 @@ class ViewerService {
10295
11206
  position: placement.position,
10296
11207
  poiType: updatedPoi?.type ?? poi.type,
10297
11208
  iconUrl: updatedPoi?.tagIcon ? await getSignedFile(updatedPoi.tagIcon) : null,
11209
+ normal: placement.normal,
11210
+ // As it is stored (see buildThreeJsPoiMetadata): placed in this model, and in its own
11211
+ // coordinates while it is not calibrated - so that it shows as the model's own straight away.
11212
+ ...(this.currentCaptureID ? { originCaptureID: this.currentCaptureID } : {}),
11213
+ ...(this.currentCaptureID && !this.threeJsCalibrated ? { frame: 'model' } : {}),
10298
11214
  });
10299
11215
  this.threeJsService.cancelTagPlacement();
10300
11216
  return updatedPoi;
@@ -10309,7 +11225,7 @@ class ViewerService {
10309
11225
  *
10310
11226
  * Returns null when there is no pending placement, which is the normal case in Matterport mode.
10311
11227
  */
10312
- async createPoiForThreeJsPlacement(element, poiType) {
11228
+ async createPoiForThreeJsPlacement(element, poiType, extra = {}) {
10313
11229
  if (!this.checkMode('threejs')) {
10314
11230
  return null;
10315
11231
  }
@@ -10321,6 +11237,8 @@ class ViewerService {
10321
11237
  // sweep - the floor plan most visibly, which only draws tags whose sweep belongs to it.
10322
11238
  const matterportSweepID = await this.findNearestSweepForThreeJs(placement.position);
10323
11239
  const poi = await this.poiService.createPOIForSpaceID({
11240
+ // What a form asked for besides the place - the museum's, say - under what the placement says.
11241
+ ...extra,
10324
11242
  coordinate: JSON.stringify(placement.position),
10325
11243
  type: poiType,
10326
11244
  elementID: element.id,
@@ -10342,6 +11260,35 @@ class ViewerService {
10342
11260
  get threeJsAlignmentCancelled$() {
10343
11261
  return this.threeJsService.alignmentCancelled$;
10344
11262
  }
11263
+ /** Emits when the Three.js tags change; see getThreeJsTagSnapshot. */
11264
+ get threeJsTagsChanged$() {
11265
+ return this.threeJsService.tagsChanged$;
11266
+ }
11267
+ /** The tags, and their calibration, as a viewer drawing the scene elsewhere needs them. */
11268
+ getThreeJsTagSnapshot() {
11269
+ return this.threeJsService.getTagSnapshot();
11270
+ }
11271
+ /** Stops drawing the Three.js scene while another viewer covers it, or starts again. */
11272
+ setThreeJsRenderingPaused(paused) {
11273
+ this.threeJsService.setRenderingPaused(paused);
11274
+ }
11275
+ /** Emits when a click during calibration landed on nothing it could use: a tag, or the model. */
11276
+ get threeJsAlignmentClickIgnored$() {
11277
+ return this.threeJsService.alignmentClickIgnored$;
11278
+ }
11279
+ /** Emits when Three.js tag placement is armed (true) and when it ends (false). */
11280
+ get threeJsPlacementChanged$() {
11281
+ return this.threeJsService.placementChanged$;
11282
+ }
11283
+ /**
11284
+ * Completes an armed Three.js tag placement at a spot the splat viewer picked, in the model's own
11285
+ * coordinates: the creation form then opens as for a click in the Three.js scene.
11286
+ */
11287
+ placeThreeJsTagAtModelPoint(point, normal = null) {
11288
+ if (this.checkMode('threejs')) {
11289
+ this.threeJsService.placeTagAtModelPoint(point, normal);
11290
+ }
11291
+ }
10345
11292
  /** Leaves Three.js tag placement mode without placing anything. */
10346
11293
  cancelThreeJsTagPlacement() {
10347
11294
  if (this.checkMode('threejs')) {
@@ -10492,7 +11439,12 @@ class ViewerService {
10492
11439
  }
10493
11440
  }
10494
11441
  async initMatterportSdk(spaceID, model3D, tagService, module = SpModule.IMMO) {
10495
- this.isLoaded = false;
11442
+ // A Three.js visit is announced as loaded by initThreeJs, and when one visit is swapped for
11443
+ // another that has already happened by the time this runs. Clearing the flag here left the
11444
+ // rest of the page believing no viewer was up - "show in 3D" greyed out on every panel.
11445
+ if (!this.checkMode('threejs')) {
11446
+ this.isLoaded = false;
11447
+ }
10496
11448
  this.matterportService.currentSpaceID = spaceID;
10497
11449
  if (this.matterportService.sdk) {
10498
11450
  await this.clearAll();
@@ -10591,13 +11543,13 @@ class ModalSwitchVisitComponent {
10591
11543
  queryParams: { model3D: this.model3D },
10592
11544
  });
10593
11545
  }
10594
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ModalSwitchVisitComponent, deps: [{ token: i1$2.NgbActiveModal }, { token: i1$1.Router }, { token: ViewerService }], target: i0.ɵɵFactoryTarget.Component });
10595
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ModalSwitchVisitComponent, selector: "lib-modal-switch-visit", inputs: { content: "content", model3D: "model3D", spaceID: "spaceID", dataToMove: "dataToMove" }, ngImport: i0, template: "<div class=\"modal-container\">\r\n <p>{{content}}</p>\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"switchVisit()\">{{'Yes, switch visit' | translate }}</button>\r\n <button class=\"btn btn-outline-primary rounded-pill\"(click)=\"activeModal.close()\">{{'No, stay here' | translate }}</button>\r\n</div>\r\n", styles: [".modal-container{margin:10px}button{margin-right:8px}\n"], dependencies: [{ kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
11546
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ModalSwitchVisitComponent, deps: [{ token: i1$2.NgbActiveModal }, { token: i1.Router }, { token: ViewerService }], target: i0.ɵɵFactoryTarget.Component });
11547
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ModalSwitchVisitComponent, selector: "lib-modal-switch-visit", inputs: { content: "content", model3D: "model3D", spaceID: "spaceID", dataToMove: "dataToMove" }, ngImport: i0, template: "<div class=\"modal-container\">\r\n <p>{{content}}</p>\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"switchVisit()\">{{'Yes, switch visit' | translate }}</button>\r\n <button class=\"btn btn-outline-primary rounded-pill\"(click)=\"activeModal.close()\">{{'No, stay here' | translate }}</button>\r\n</div>\r\n", styles: [".modal-container{margin:10px}button{margin-right:8px}\n"], dependencies: [{ kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
10596
11548
  }
10597
11549
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ModalSwitchVisitComponent, decorators: [{
10598
11550
  type: Component,
10599
11551
  args: [{ selector: 'lib-modal-switch-visit', template: "<div class=\"modal-container\">\r\n <p>{{content}}</p>\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"switchVisit()\">{{'Yes, switch visit' | translate }}</button>\r\n <button class=\"btn btn-outline-primary rounded-pill\"(click)=\"activeModal.close()\">{{'No, stay here' | translate }}</button>\r\n</div>\r\n", styles: [".modal-container{margin:10px}button{margin-right:8px}\n"] }]
10600
- }], ctorParameters: () => [{ type: i1$2.NgbActiveModal }, { type: i1$1.Router }, { type: ViewerService }], propDecorators: { content: [{
11552
+ }], ctorParameters: () => [{ type: i1$2.NgbActiveModal }, { type: i1.Router }, { type: ViewerService }], propDecorators: { content: [{
10601
11553
  type: Input
10602
11554
  }], model3D: [{
10603
11555
  type: Input
@@ -11147,6 +12099,92 @@ function pointToString(point) {
11147
12099
  const z = point.z.toFixed(3);
11148
12100
  return `{ x: ${x}, y: ${y}, z: ${z} }`;
11149
12101
  }
12102
+ /**
12103
+ * Icon data of an @iconify/icons-* import. Those packages are CommonJS: imported from a library
12104
+ * bundle, the default import can be the whole module, with the data under `default`.
12105
+ */
12106
+ function iconData(icon) {
12107
+ return icon.default ?? icon;
12108
+ }
12109
+ /**
12110
+ * Bundled icons for the markers drawn on plans. The iconify API no longer serves the
12111
+ * `prefix:name.svg` URLs they used to be loaded from, which left the markers blank.
12112
+ */
12113
+ const PLAN_ICONS = {
12114
+ adjust: iconData(AdjustIcon),
12115
+ closeCircleOutline: iconData(CloseCircleOutlineIcon),
12116
+ };
12117
+ /** Encodes an SVG as a data URL; parentheses are escaped so it also works in an unquoted url(). */
12118
+ function svgToDataUrl(svg) {
12119
+ const encoded = encodeURIComponent(svg).replace(/\(/g, "%28").replace(/\)/g, "%29");
12120
+ return `data:image/svg+xml;charset=utf-8,${encoded}`;
12121
+ }
12122
+ /**
12123
+ * Renders a bundled iconify icon as a data URL, without any request to the iconify API.
12124
+ * @param size width and height in px, needed where the intrinsic size is read (canvas drawing)
12125
+ */
12126
+ function iconToDataUrl(icon, color = "currentColor", size = 17) {
12127
+ const data = iconData(icon);
12128
+ const width = data.width ?? 24;
12129
+ const height = data.height ?? 24;
12130
+ const body = data.body.replace(/currentColor/g, color);
12131
+ return svgToDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${width} ${height}">${body}</svg>`);
12132
+ }
12133
+
12134
+ class CsvExportComponent {
12135
+ fileDownloadIcon = iconData(fileDownloadIcon);
12136
+ /** Header of the CSV, titles for each columns */
12137
+ headers = [];
12138
+ /** Array of each rows (array of array of string), if it's not set, then the function getRows() will be used */
12139
+ rowsInput = undefined;
12140
+ /** Function used to get rows if rowsInput is not set, call each time the user click on the button to generate the CSV file */
12141
+ getRows = undefined;
12142
+ /** Title of the file to download */
12143
+ title = "file";
12144
+ /** Label for the button to click */
12145
+ buttonLabel = "Export";
12146
+ /** Delimiter for the CSV */
12147
+ delimeter = ";";
12148
+ async onClickDownload() {
12149
+ let rows = this.rowsInput;
12150
+ if (!rows) {
12151
+ rows = await Promise.resolve(this.getRows());
12152
+ }
12153
+ const data = `data:text/csv;charset=utf-8,${this.headers.join(this.delimeter)}\n${rows
12154
+ .map((row) =>
12155
+ /** Clean each rows/cells */
12156
+ row
12157
+ .map((value) => value
12158
+ .replace(this.delimeter, " ")
12159
+ .replace("\n", " ")
12160
+ .replace("\r", " "))
12161
+ .join(this.delimeter))
12162
+ .join("\n")}`;
12163
+ /** Create a link to download the file */
12164
+ const link = document.createElement("a");
12165
+ link.setAttribute("href", encodeURI(data));
12166
+ link.setAttribute("download", `${this.title}.csv`);
12167
+ document.body.append(link);
12168
+ link.click();
12169
+ link.remove();
12170
+ }
12171
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CsvExportComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
12172
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CsvExportComponent, selector: "lib-csv-export", inputs: { headers: "headers", rowsInput: "rowsInput", getRows: "getRows", title: "title", buttonLabel: "buttonLabel" }, ngImport: i0, template: "<span [style.cursor]=\"'pointer'\" (click)=\"onClickDownload()\" class=\"download-csv d-flex\">\n <span class=\"iconify\" [icIcon]=\"fileDownloadIcon\"></span>\n {{ buttonLabel | translate}}\n</span>\n", styles: [".download-csv{color:var(--smarterplan-primary)}\n"], dependencies: [{ kind: "directive", type: i1$3.IconDirective, selector: "ic-icon,[icIcon]", inputs: ["icIcon", "icon", "color", "inline", "box", "size", "width", "height", "align", "hFlip", "vFlip", "flip", "rotate"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
12173
+ }
12174
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CsvExportComponent, decorators: [{
12175
+ type: Component,
12176
+ args: [{ selector: 'lib-csv-export', template: "<span [style.cursor]=\"'pointer'\" (click)=\"onClickDownload()\" class=\"download-csv d-flex\">\n <span class=\"iconify\" [icIcon]=\"fileDownloadIcon\"></span>\n {{ buttonLabel | translate}}\n</span>\n", styles: [".download-csv{color:var(--smarterplan-primary)}\n"] }]
12177
+ }], propDecorators: { headers: [{
12178
+ type: Input
12179
+ }], rowsInput: [{
12180
+ type: Input
12181
+ }], getRows: [{
12182
+ type: Input
12183
+ }], title: [{
12184
+ type: Input
12185
+ }], buttonLabel: [{
12186
+ type: Input
12187
+ }] } });
11150
12188
 
11151
12189
  /* eslint-disable no-case-declarations */
11152
12190
  /* eslint-disable no-await-in-loop */
@@ -11817,7 +12855,7 @@ function getCoefficientsForImage(img, rectangle) {
11817
12855
  return { coeffX, coeffY };
11818
12856
  }
11819
12857
  function styleButton(button) {
11820
- button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
12858
+ button.style.backgroundImage = `url("${iconToDataUrl(PLAN_ICONS.adjust, "green")}")`;
11821
12859
  button.style.backgroundColor = "transparent";
11822
12860
  button.style.position = "absolute";
11823
12861
  button.style.border = "none";
@@ -12125,7 +13163,7 @@ class ContentService {
12125
13163
  this.modalReference.componentInstance.navigateToSlide(slide);
12126
13164
  }
12127
13165
  }
12128
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentService, deps: [{ token: i1$2.NgbModal }, { token: i1$1.Router }, { token: CommentService }], target: i0.ɵɵFactoryTarget.Injectable });
13166
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentService, deps: [{ token: i1$2.NgbModal }, { token: i1.Router }, { token: CommentService }], target: i0.ɵɵFactoryTarget.Injectable });
12129
13167
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentService, providedIn: "root" });
12130
13168
  }
12131
13169
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ContentService, decorators: [{
@@ -12133,7 +13171,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
12133
13171
  args: [{
12134
13172
  providedIn: "root",
12135
13173
  }]
12136
- }], ctorParameters: () => [{ type: i1$2.NgbModal }, { type: i1$1.Router }, { type: CommentService }] });
13174
+ }], ctorParameters: () => [{ type: i1$2.NgbModal }, { type: i1.Router }, { type: CommentService }] });
12137
13175
 
12138
13176
  /* eslint-disable func-names */
12139
13177
  /* eslint-disable class-methods-use-this */
@@ -12145,6 +13183,7 @@ class PlanService {
12145
13183
  matterportService;
12146
13184
  visibilityService;
12147
13185
  contentService;
13186
+ translate;
12148
13187
  chosenPlan;
12149
13188
  currentPlan;
12150
13189
  currentSweep;
@@ -12155,6 +13194,8 @@ class PlanService {
12155
13194
  panzoom;
12156
13195
  isReady = false;
12157
13196
  userPositionBtn;
13197
+ /** Side of the current position marker, in px before scaling (tags are 10px). */
13198
+ userPositionSize = 16;
12158
13199
  coeffPlanX;
12159
13200
  coeffPlanY;
12160
13201
  calibrationPlan;
@@ -12174,7 +13215,7 @@ class PlanService {
12174
13215
  // tagService: BaseTagService,
12175
13216
  viewerService, router, matterportService,
12176
13217
  // private config: AppConfig,
12177
- visibilityService, contentService) {
13218
+ visibilityService, contentService, translate) {
12178
13219
  this.zoneService = zoneService;
12179
13220
  this.navigationService = navigationService;
12180
13221
  this.viewerService = viewerService;
@@ -12182,6 +13223,7 @@ class PlanService {
12182
13223
  this.matterportService = matterportService;
12183
13224
  this.visibilityService = visibilityService;
12184
13225
  this.contentService = contentService;
13226
+ this.translate = translate;
12185
13227
  this.API = apiInjected;
12186
13228
  this.matterportService.currentCameraPose.subscribe((pose) => {
12187
13229
  this.updateRotation(pose.rotation.y);
@@ -12416,6 +13458,7 @@ class PlanService {
12416
13458
  }
12417
13459
  this.styleButton(button, tagIconImage, sizeButton);
12418
13460
  button.id = element.id;
13461
+ this.clearBtn([element.id]);
12419
13462
  this.planDivContent.append(button);
12420
13463
  let x;
12421
13464
  let y;
@@ -12477,15 +13520,21 @@ class PlanService {
12477
13520
  this.userPositionBtn = document.createElement('button');
12478
13521
  this.userPositionBtn.id = 'currentPosition';
12479
13522
  this.planDivContent.append(this.userPositionBtn);
12480
- this.userPositionBtn.title = 'You are here';
12481
- this.styleButton(this.userPositionBtn, 'https://api.iconify.design/bx:bxs-user-circle.svg?color=green&height=17&width=17', sizeButton);
13523
+ this.userPositionBtn.title = this.translate.instant('You are here');
13524
+ this.styleButton(this.userPositionBtn, this.getUserPositionIcon(), sizeButton);
13525
+ // Drawn above the tags and larger than them, so it is never hidden among them
13526
+ this.userPositionBtn.style.width = `${this.userPositionSize}px`;
13527
+ this.userPositionBtn.style.height = `${this.userPositionSize}px`;
13528
+ this.userPositionBtn.style.zIndex = '1';
13529
+ this.userPositionBtn.style.filter = 'drop-shadow(0 0 2px rgba(0, 0, 0, 0.6))';
12482
13530
  }
13531
+ // Center of the marker on the plan
12483
13532
  let x;
12484
13533
  let y;
12485
13534
  if (this.calibrationPlan.new) {
12486
13535
  const position2D = this.transformPosition3DForNewCalibration(position);
12487
- x = position2D.x / position2D.coeffX - 5;
12488
- y = position2D.y / position2D.coeffY - 5;
13536
+ x = position2D.x / position2D.coeffX;
13537
+ y = position2D.y / position2D.coeffY;
12489
13538
  }
12490
13539
  else {
12491
13540
  x =
@@ -12497,12 +13546,27 @@ class PlanService {
12497
13546
  position.z * this.calibrationPlan.y) /
12498
13547
  this.coeffPlanY;
12499
13548
  }
12500
- this.userPositionBtn.style.top = `${y}px`;
12501
- this.userPositionBtn.style.left = `${x}px`;
12502
- this.moveOnPoint({ x: x + 5, y: y + 5 });
13549
+ const half = this.userPositionSize / 2;
13550
+ this.userPositionBtn.style.top = `${y - half}px`;
13551
+ this.userPositionBtn.style.left = `${x - half}px`;
13552
+ this.moveOnPoint({ x, y });
12503
13553
  }
12504
13554
  }
12505
13555
  }
13556
+ /**
13557
+ * Builds the current position marker from the bundled mdi icon (no network request),
13558
+ * as a white figure on a disc of the application's primary color.
13559
+ */
13560
+ getUserPositionIcon() {
13561
+ const color = getComputedStyle(document.documentElement)
13562
+ .getPropertyValue('--smarterplan-primary')
13563
+ .replace(/\s+/g, '') || '#53b6bb';
13564
+ const figure = iconData(UserPositionIcon).body.replace(/currentColor/g, '#fff');
13565
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">` +
13566
+ `<circle cx="12" cy="12" r="11" fill="${color}" stroke="#fff" stroke-width="1.5"/>` +
13567
+ `<g transform="translate(2.4 2.4) scale(0.8)">${figure}</g></svg>`;
13568
+ return svgToDataUrl(svg);
13569
+ }
12506
13570
  /**
12507
13571
  * Center the view of the plan on coordinates
12508
13572
  * @param coordinate Coordinate on the plan
@@ -12737,9 +13801,9 @@ class PlanService {
12737
13801
  });
12738
13802
  }
12739
13803
  clearBtn(idList) {
13804
+ // Every copy, not only the first: overlapping draws used to stack duplicates
12740
13805
  for (const id of idList) {
12741
- const button = document.getElementById(id);
12742
- if (button) {
13806
+ for (const button of Array.from((this.planDivContent ?? document).querySelectorAll(`button[id="${id}"]`))) {
12743
13807
  button.remove();
12744
13808
  }
12745
13809
  }
@@ -12764,9 +13828,9 @@ class PlanService {
12764
13828
  //For saving the rotation and adding scale
12765
13829
  let rotationRegex = /(rotate\(-?\d*\.?\d+deg\))/g;
12766
13830
  let rotationMatch = currentValue.style[property].match(rotationRegex);
12767
- if (rotationMatch.length > 0) {
12768
- currentValue.style[property] = `${values[i]} ${rotationMatch[0]}`;
12769
- }
13831
+ currentValue.style[property] = rotationMatch
13832
+ ? `${values[i]} ${rotationMatch[0]}`
13833
+ : values[i];
12770
13834
  }
12771
13835
  else {
12772
13836
  currentValue.style[property] = values[i];
@@ -12877,6 +13941,7 @@ class PlanService {
12877
13941
  const button = document.createElement('button');
12878
13942
  this.styleButton(button, cached.tagIcon, sizeButton);
12879
13943
  button.id = cached.elementID;
13944
+ this.clearBtn([cached.elementID]);
12880
13945
  this.planDivContent.append(button);
12881
13946
  if (this.calibrationPlan.new) {
12882
13947
  const newCoeffX = this.coeffPlanX /
@@ -12926,7 +13991,7 @@ class PlanService {
12926
13991
  // console.log(x, y);
12927
13992
  return { x, y, coeffX: newCoeffX, coeffY: newCoeffY };
12928
13993
  }
12929
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PlanService, deps: [{ token: 'currentAPIService' }, { token: ZoneService }, { token: NavigationService }, { token: ViewerService }, { token: i1$1.Router }, { token: MatterportService }, { token: BaseVisibilityService }, { token: ContentService }], target: i0.ɵɵFactoryTarget.Injectable });
13994
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PlanService, deps: [{ token: 'currentAPIService' }, { token: ZoneService }, { token: NavigationService }, { token: ViewerService }, { token: i1.Router }, { token: MatterportService }, { token: BaseVisibilityService }, { token: ContentService }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
12930
13995
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PlanService, providedIn: 'root' });
12931
13996
  }
12932
13997
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PlanService, decorators: [{
@@ -12937,7 +14002,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
12937
14002
  }], ctorParameters: () => [{ type: undefined, decorators: [{
12938
14003
  type: Inject,
12939
14004
  args: ['currentAPIService']
12940
- }] }, { type: ZoneService }, { type: NavigationService }, { type: ViewerService }, { type: i1$1.Router }, { type: MatterportService }, { type: BaseVisibilityService }, { type: ContentService }] });
14005
+ }] }, { type: ZoneService }, { type: NavigationService }, { type: ViewerService }, { type: i1.Router }, { type: MatterportService }, { type: BaseVisibilityService }, { type: ContentService }, { type: i1$1.TranslateService }] });
12941
14006
 
12942
14007
  /* eslint-disable class-methods-use-this */
12943
14008
  /* eslint-disable no-restricted-syntax */
@@ -13342,7 +14407,7 @@ class EventService {
13342
14407
  meta.type = this.translate.instant(meta.type);
13343
14408
  return meta;
13344
14409
  }
13345
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventService, deps: [{ token: 'currentAPIService' }, { token: BaseUserService }, { token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
14410
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventService, deps: [{ token: 'currentAPIService' }, { token: BaseUserService }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
13346
14411
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventService, providedIn: "root" });
13347
14412
  }
13348
14413
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventService, decorators: [{
@@ -13353,7 +14418,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
13353
14418
  }], ctorParameters: () => [{ type: undefined, decorators: [{
13354
14419
  type: Inject,
13355
14420
  args: ['currentAPIService']
13356
- }] }, { type: BaseUserService }, { type: i1.TranslateService }] });
14421
+ }] }, { type: BaseUserService }, { type: i1$1.TranslateService }] });
13357
14422
 
13358
14423
  class AffectationService {
13359
14424
  API;
@@ -13646,7 +14711,7 @@ class NavigatorService {
13646
14711
  }
13647
14712
  // }
13648
14713
  }
13649
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigatorService, deps: [{ token: MatterportService }, { token: ViewerService }, { token: ZoneService }, { token: BaseUserService }, { token: ZoneChangeService }, { token: i1$1.Router }, { token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
14714
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigatorService, deps: [{ token: MatterportService }, { token: ViewerService }, { token: ZoneService }, { token: BaseUserService }, { token: ZoneChangeService }, { token: i1.Router }, { token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
13650
14715
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigatorService, providedIn: 'root' });
13651
14716
  }
13652
14717
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigatorService, decorators: [{
@@ -13654,7 +14719,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
13654
14719
  args: [{
13655
14720
  providedIn: 'root',
13656
14721
  }]
13657
- }], ctorParameters: () => [{ type: MatterportService }, { type: ViewerService }, { type: ZoneService }, { type: BaseUserService }, { type: ZoneChangeService }, { type: i1$1.Router }, { type: i1$1.ActivatedRoute }] });
14722
+ }], ctorParameters: () => [{ type: MatterportService }, { type: ViewerService }, { type: ZoneService }, { type: BaseUserService }, { type: ZoneChangeService }, { type: i1.Router }, { type: i1.ActivatedRoute }] });
13658
14723
 
13659
14724
  /* eslint-disable class-methods-use-this */
13660
14725
  class InterventionService {
@@ -13915,11 +14980,11 @@ class TicketsService extends BaseObjectService {
13915
14980
  spaceSubscription;
13916
14981
  dateFilter;
13917
14982
  ticketTypeFilter;
13918
- reportingIcon = ReportingIcon;
13919
- maintenanceIcon = MaintenanceIcon;
13920
- workorderIcon = WordOrderIcon;
13921
- informationIcon = InformationIcon;
13922
- accidentIcon = AccidentIcon;
14983
+ reportingIcon = iconData(ReportingIcon);
14984
+ maintenanceIcon = iconData(MaintenanceIcon);
14985
+ workorderIcon = iconData(WordOrderIcon);
14986
+ informationIcon = iconData(InformationIcon);
14987
+ accidentIcon = iconData(AccidentIcon);
13923
14988
  updateDone = new Subject();
13924
14989
  updating = new Subject();
13925
14990
  API;
@@ -15315,7 +16380,7 @@ class SearchBarComponent {
15315
16380
  this.searchEvent.emit(results);
15316
16381
  }
15317
16382
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SearchBarComponent, deps: [{ token: SearchService }], target: i0.ɵɵFactoryTarget.Component });
15318
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SearchBarComponent, selector: "lib-search-bar", inputs: { searchable: "searchable", objectType: "objectType" }, outputs: { searchEvent: "searchEvent" }, ngImport: i0, template: "<div class=\"col-md-8 searchbar\">\r\n <div class=\"row depend\">\r\n <div class=\"col-md-5\">\r\n <input id=\"searchbar\" type=\"text\" class=\"form-control\" placeholder=\"keyword\" />\r\n </div>\r\n <div class=\"col-md-5\">\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onSubmit()\">{{ 'Search' |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n</div>", styles: [".searchbar{margin-bottom:10px}\n"], dependencies: [{ kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
16383
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SearchBarComponent, selector: "lib-search-bar", inputs: { searchable: "searchable", objectType: "objectType" }, outputs: { searchEvent: "searchEvent" }, ngImport: i0, template: "<div class=\"col-md-8 searchbar\">\r\n <div class=\"row depend\">\r\n <div class=\"col-md-5\">\r\n <input id=\"searchbar\" type=\"text\" class=\"form-control\" placeholder=\"keyword\" />\r\n </div>\r\n <div class=\"col-md-5\">\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onSubmit()\">{{ 'Search' |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n</div>", styles: [".searchbar{margin-bottom:10px}\n"], dependencies: [{ kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
15319
16384
  }
15320
16385
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SearchBarComponent, decorators: [{
15321
16386
  type: Component,
@@ -15381,7 +16446,7 @@ class DurationToStringPipe {
15381
16446
  });
15382
16447
  return dateObserver;
15383
16448
  }
15384
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DurationToStringPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
16449
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DurationToStringPipe, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
15385
16450
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: DurationToStringPipe, name: "durationToString" });
15386
16451
  }
15387
16452
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DurationToStringPipe, decorators: [{
@@ -15389,7 +16454,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
15389
16454
  args: [{
15390
16455
  name: 'durationToString'
15391
16456
  }]
15392
- }], ctorParameters: () => [{ type: i1.TranslateService }] });
16457
+ }], ctorParameters: () => [{ type: i1$1.TranslateService }] });
15393
16458
 
15394
16459
  class HashtagService {
15395
16460
  currentSpaceID;
@@ -15507,7 +16572,7 @@ class SafeUrlPipe {
15507
16572
  transform(url) {
15508
16573
  return this.sanitizer.bypassSecurityTrustResourceUrl(url);
15509
16574
  }
15510
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SafeUrlPipe, deps: [{ token: i1$3.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
16575
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SafeUrlPipe, deps: [{ token: i1$4.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
15511
16576
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: SafeUrlPipe, name: "safeUrl" });
15512
16577
  }
15513
16578
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SafeUrlPipe, decorators: [{
@@ -15515,7 +16580,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
15515
16580
  args: [{
15516
16581
  name: 'safeUrl'
15517
16582
  }]
15518
- }], ctorParameters: () => [{ type: i1$3.DomSanitizer }] });
16583
+ }], ctorParameters: () => [{ type: i1$4.DomSanitizer }] });
15519
16584
 
15520
16585
  class TimeDateToLocalStringPipe {
15521
16586
  translate;
@@ -15603,7 +16668,7 @@ class TimeDateToLocalStringPipe {
15603
16668
  });
15604
16669
  return dateObserver;
15605
16670
  }
15606
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TimeDateToLocalStringPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
16671
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TimeDateToLocalStringPipe, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
15607
16672
  static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: TimeDateToLocalStringPipe, name: "timeDateString" });
15608
16673
  }
15609
16674
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TimeDateToLocalStringPipe, decorators: [{
@@ -15611,7 +16676,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
15611
16676
  args: [{
15612
16677
  name: 'timeDateString'
15613
16678
  }]
15614
- }], ctorParameters: () => [{ type: i1.TranslateService }] });
16679
+ }], ctorParameters: () => [{ type: i1$1.TranslateService }] });
15615
16680
 
15616
16681
  class UsernameFromIdPipe {
15617
16682
  userService;
@@ -15829,7 +16894,7 @@ class SupportModalComponent {
15829
16894
  }
15830
16895
  }
15831
16896
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SupportModalComponent, deps: [{ token: SupportService }, { token: i1$2.NgbActiveModal }, { token: i3.UntypedFormBuilder }, { token: BaseUserService }, { token: ValidatorsService }], target: i0.ɵɵFactoryTarget.Component });
15832
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SupportModalComponent, selector: "app-support-modal", ngImport: i0, template: "<div class=\"modal-header\">\r\n <h5 class=\"modal-title\" translate=\"Help\"></h5>\r\n</div>\r\n<div class=\"modal-body\">\r\n <div class=\"support-loader-container\">\r\n <lib-loader *ngIf=\"loading\"></lib-loader>\r\n </div>\r\n <form (ngSubmit)=\"onSubmit()\" [formGroup]=\"supportForm\" style=\"margin-top:1rem;\" *ngIf=\"!loading && status==='new'\">\r\n <div>\r\n <label>{{'Title' | translate}} *</label>\r\n <div>\r\n <input type=\"text\" class=\"form-control\" formControlName=\"title\" data-testid=\"new-support-title\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['title'])}\"\r\n maxlength=\"255\">\r\n </div>\r\n <div class=\"invalid-feedback\">\r\n <span data-testid=\"new-support-title-invalid\" [translate]=\"validatorsService.getError(supportForm.controls['title'])\"\r\n *ngIf=\" validatorsService.isControlError(supportForm.controls['title'])\"></span>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!currentUser\">\r\n <label>{{'Email' | translate}} *</label>\r\n <div>\r\n <input type=\"email\" class=\"form-control\" formControlName=\"email\" data-testid=\"new-support-email\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['email'])}\"\r\n maxlength=\"255\">\r\n </div>\r\n <div class=\"invalid-feedback\">\r\n <span data-testid=\"new-support-email-invalid\" [translate]=\"validatorsService.getError(supportForm.controls['email'])\"\r\n *ngIf=\" validatorsService.isControlError(supportForm.controls['email'])\"></span>\r\n </div>\r\n </div>\r\n <div>\r\n <label>{{'Description' | translate}} *</label>\r\n <div>\r\n <textarea formControlName=\"description\" class=\"form-control\"\r\n data-testid=\"new-support-description\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['description'])}\"></textarea>\r\n </div>\r\n <div class=\"invalid-feedback\" >\r\n <span data-testid=\"new-support-description-invalid\" [translate]=\" validatorsService.getError(supportForm.controls['description'])\"\r\n *ngIf=\"validatorsService.isControlError(supportForm.controls['description'])\"></span>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n <div *ngIf=\"status ==='send'\" translate=\"Your request has been registered\" data-testid=\"new-support-send-info\">\r\n </div>\r\n <div *ngIf=\"status ==='error'\" translate=\"An error has occurred, please renew your request\"\r\n data-testid=\"new-support-error-info\">\r\n\r\n </div>\r\n</div>\r\n<div class=\"modal-footer\">\r\n <button type=\"button\" class=\"btn rounded-pill btn-museum\" data-dismiss=\"modal\" translate=\"Close\" (click)=\"onClose()\"\r\n data-testid=\"new-support-close-btn\"></button>\r\n <button *ngIf=\"!loading && status==='new'\" type=\"button\" class=\"btn rounded-pill btn-museum\" translate=\"Submit\"\r\n (click)=\"onSubmit()\" [disabled]=\"!supportForm.valid\" data-testid=\"new-support-submit-btn\"></button>\r\n</div>", styles: [".support-loader-container{width:88px;margin:auto}.invalid-feedback{height:16px}\n"], dependencies: [{ kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.TranslateDirective, selector: "[translate],[ngx-translate]", inputs: ["translate", "translateParams"] }, { kind: "component", type: LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
16897
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SupportModalComponent, selector: "app-support-modal", ngImport: i0, template: "<div class=\"modal-header\">\r\n <h5 class=\"modal-title\" translate=\"Help\"></h5>\r\n</div>\r\n<div class=\"modal-body\">\r\n <div class=\"support-loader-container\">\r\n <lib-loader *ngIf=\"loading\"></lib-loader>\r\n </div>\r\n <form (ngSubmit)=\"onSubmit()\" [formGroup]=\"supportForm\" style=\"margin-top:1rem;\" *ngIf=\"!loading && status==='new'\">\r\n <div>\r\n <label>{{'Title' | translate}} *</label>\r\n <div>\r\n <input type=\"text\" class=\"form-control\" formControlName=\"title\" data-testid=\"new-support-title\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['title'])}\"\r\n maxlength=\"255\">\r\n </div>\r\n <div class=\"invalid-feedback\">\r\n <span data-testid=\"new-support-title-invalid\" [translate]=\"validatorsService.getError(supportForm.controls['title'])\"\r\n *ngIf=\" validatorsService.isControlError(supportForm.controls['title'])\"></span>\r\n </div>\r\n </div>\r\n <div *ngIf=\"!currentUser\">\r\n <label>{{'Email' | translate}} *</label>\r\n <div>\r\n <input type=\"email\" class=\"form-control\" formControlName=\"email\" data-testid=\"new-support-email\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['email'])}\"\r\n maxlength=\"255\">\r\n </div>\r\n <div class=\"invalid-feedback\">\r\n <span data-testid=\"new-support-email-invalid\" [translate]=\"validatorsService.getError(supportForm.controls['email'])\"\r\n *ngIf=\" validatorsService.isControlError(supportForm.controls['email'])\"></span>\r\n </div>\r\n </div>\r\n <div>\r\n <label>{{'Description' | translate}} *</label>\r\n <div>\r\n <textarea formControlName=\"description\" class=\"form-control\"\r\n data-testid=\"new-support-description\"\r\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(supportForm.controls['description'])}\"></textarea>\r\n </div>\r\n <div class=\"invalid-feedback\" >\r\n <span data-testid=\"new-support-description-invalid\" [translate]=\" validatorsService.getError(supportForm.controls['description'])\"\r\n *ngIf=\"validatorsService.isControlError(supportForm.controls['description'])\"></span>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n <div *ngIf=\"status ==='send'\" translate=\"Your request has been registered\" data-testid=\"new-support-send-info\">\r\n </div>\r\n <div *ngIf=\"status ==='error'\" translate=\"An error has occurred, please renew your request\"\r\n data-testid=\"new-support-error-info\">\r\n\r\n </div>\r\n</div>\r\n<div class=\"modal-footer\">\r\n <button type=\"button\" class=\"btn rounded-pill btn-museum\" data-dismiss=\"modal\" translate=\"Close\" (click)=\"onClose()\"\r\n data-testid=\"new-support-close-btn\"></button>\r\n <button *ngIf=\"!loading && status==='new'\" type=\"button\" class=\"btn rounded-pill btn-museum\" translate=\"Submit\"\r\n (click)=\"onSubmit()\" [disabled]=\"!supportForm.valid\" data-testid=\"new-support-submit-btn\"></button>\r\n</div>", styles: [".support-loader-container{width:88px;margin:auto}.invalid-feedback{height:16px}\n"], dependencies: [{ kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.TranslateDirective, selector: "[translate],[ngx-translate]", inputs: ["translate", "translateParams"] }, { kind: "component", type: LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
15833
16898
  }
15834
16899
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SupportModalComponent, decorators: [{
15835
16900
  type: Component,
@@ -15866,7 +16931,7 @@ class LocaleService {
15866
16931
  const currentLang = this.translate.getCurrentLang() || this.translate.getFallbackLang() || "fr";
15867
16932
  return currentLang.replace(/^[_-]+/, '').substring(0, 2);
15868
16933
  }
15869
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocaleService, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
16934
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocaleService, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
15870
16935
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocaleService, providedIn: "root" });
15871
16936
  }
15872
16937
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocaleService, decorators: [{
@@ -15874,7 +16939,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
15874
16939
  args: [{
15875
16940
  providedIn: "root",
15876
16941
  }]
15877
- }], ctorParameters: () => [{ type: i1.TranslateService }] });
16942
+ }], ctorParameters: () => [{ type: i1$1.TranslateService }] });
15878
16943
 
15879
16944
  /* eslint-disable class-methods-use-this */
15880
16945
  var CacheKeys;
@@ -17272,8 +18337,8 @@ class NavigationBarComponent {
17272
18337
  onHideClick() {
17273
18338
  this.baseVisibilityService.isChangePositionVisible.next(false);
17274
18339
  }
17275
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigationBarComponent, deps: [{ token: 'currentAwsKinesisAnalyticsService' }, { token: i1$1.Router }, { token: SpaceService }, { token: BaseUserService }, { token: ZoneService }, { token: VisitService }, { token: ViewerService }, { token: NavigatorService }, { token: ZoneChangeService }, { token: BaseVisibilityService }], target: i0.ɵɵFactoryTarget.Component });
17276
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: NavigationBarComponent, selector: "lib-navigation-bar", viewQueries: [{ propertyName: "navbarSelectMenu", first: true, predicate: ["navbarSelectMenu"], descendants: true }], ngImport: i0, template: "<nav class=\"navbar navbar-expand-md navbar-dark navbar-inverse second-nav\">\r\n <div class=\"d-flex w-100\">\r\n <div #navbarSelectMenu class=\"w-100\" id=\"nav-item-container-blue\">\r\n <div class=\"d-flex flex-column flex-md-row p-1 mt-2\">\r\n <select class=\"form-control flex-fill flex-lg-fill-unset location select-menu\"\r\n [(ngModel)]=\"selectedLocation\" (ngModelChange)=\"onLocationClick()\">\r\n <option [ngValue]=\"null\" selected>{{ 'Location' | translate }}</option>\r\n <option *ngFor=\"let loc of locations; index as index\" [ngValue]=\"loc\"> {{ loc.name }}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu\" (change)=\"onVisitClick($event)\"\r\n *ngIf=\"visitsPerSpace && visitsPerSpace.length > 1\">\r\n <option value=\"default\" selected disabled hidden>{{'Visit' | translate}}</option>\r\n <option *ngFor=\"let visit of visitsPerSpace; index as index\" value=\"{{index}}\">{{ visit.name}}\r\n </option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset floor select-menu\" [(ngModel)]=\"selectedFloor\"\r\n (ngModelChange)=\"onFloorClick()\">\r\n <option [ngValue]=\"null\" selected>{{'Floor' | translate}}</option>\r\n <option *ngFor=\"let floor of floorsPerSpace\" [ngValue]=\"floor\">{{ floor.name}}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu zone\" [(ngModel)]=\"selectedZone\"\r\n (ngModelChange)=\"onZoneClick()\">\r\n <option [ngValue]=\"null\" selected>{{'Zone' | translate}}</option>\r\n <option *ngFor=\"let zone of zonesPerFloor\" [ngValue]=\"zone\"><span\r\n *ngIf=\"zone.code_ref\">{{zone.code_ref}}_</span>{{zone.name}}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu\" [(ngModel)]=\"selectedChildZone\"\r\n *ngIf=\"childrenZones && childrenZones.length>0\" (ngModelChange)=\"onChildZoneClick()\">\r\n <option [ngValue]=\"null\" selected disabled>{{'Zone' | translate}}</option>\r\n <option *ngFor=\"let zone of childrenZones\" [ngValue]=\"zone\">{{ zone.name}}</option>\r\n </select>\r\n <button (click)=\"goTo()\"\r\n class=\"btn btn-outline-primary rounded-pill mx-2 w-md-fit-content h-md-fit-content align-self-md-center btn-3d d-none d-lg-block\"\r\n [disabled]=\"!selectedLocation || !selectedModel3d || !canGo()\">\r\n <i class=\"icon-go-to-3d d-inline-block\"></i> {{'3D visit' | translate}}\r\n </button>\r\n </div>\r\n <div class=\"row align-items-center justify-content-center ml-0 p-1\" *ngIf=\"showLocation()\">\r\n <p class=\"fw-bold lh-base align-middle text-center\">\r\n {{ showLocation() }}\r\n </p>\r\n </div>\r\n <div class=\"row align-items-center justify-content-center ml-0 p-1 d-block d-lg-none\">\r\n <button (click)=\"goTo()\"\r\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center btn-3d\"\r\n [disabled]=\"!selectedLocation || !selectedModel3d || !canGo()\">\r\n <i class=\"icon-go-to-3d d-inline-block\"></i> {{'3D visit' | translate}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</nav>", styles: [":host{position:sticky;top:0;height:123px}.navbar{z-index:200;padding:.4rem 1rem}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0}@media (min-width: 992px){.flex-lg-fill-unset{flex:unset!important}}.form-control{width:100%;min-width:80px;max-width:18%}.location{width:auto;max-width:35%}.floor,.zone{width:auto;max-width:30%}button{color:#fff;padding:5px 10px;font-size:1.1em}.navbar-toggler{margin-right:1em}.select-menu{max-width:inherit}.btn-3d .icon-go-to-3d{width:30px;height:30px;background:url('data:image/svg+xml,<?xml version=\"1.0\" encoding=\"utf-8\"?>%0D%0A<!-- Generator: Adobe Illustrator 25.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->%0D%0A<svg version=\"1.1\" id=\"Calque_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"%0D%0A%09 viewBox=\"0 0 60 60\" style=\"enable-background:new 0 0 60 60;\" xml:space=\"preserve\">%0D%0A<style type=\"text/css\">%0D%0A%09.st0{fill:%23565656;}%0D%0A<\\/style>%0D%0A<g>%0D%0A%09<path class=\"st0\" d=\"M43.9,32.1V17.7c0-0.4-0.2-0.7-0.5-0.9l-12.8-8c-0.2-0.1-0.4-0.2-0.6-0.2c-0.2,0-0.4,0.1-0.6,0.2l-12.8,8%0D%0A%09%09c-0.3,0.2-0.5,0.5-0.5,0.9v14.4c0,0.4,0.2,0.7,0.5,0.9l12.8,8c0.3,0.2,0.8,0.2,1.1,0l12.8-8C43.7,32.8,43.9,32.5,43.9,32.1z%0D%0A%09%09 M28.9,38.2l-10.7-6.7v-12l10.7,6.7V38.2z M30,24.4l-10.8-6.8L30,10.9l10.8,6.8L30,24.4z M41.8,31.5l-10.7,6.7v-12l10.7-6.7V31.5z\"%0D%0A%09%09/>%0D%0A%09<path class=\"st0\" d=\"M56.1,29.3l-10.3-6.8v2l1.4,1v0l0.8,0.5l0,0l7,4.8c0.3,0.2,0.4,0.5,0.4,0.8c0,0.3-0.2,0.6-0.4,0.8l-6.8,4.7%0D%0A%09%09l0,0l-0.9,0.7v0l-2.9,2v0l-13.8,9.6c-0.3,0.2-0.8,0.2-1.1,0l-14.2-9.8l-2.6-1.8v0L5,32.4c-0.3-0.2-0.4-0.5-0.4-0.8%0D%0A%09%09c0-0.3,0.2-0.6,0.4-0.8l0,0l7.3-5l0,0l0.5-0.3v0l1.4-1v-2L3.9,29.3c-0.8,0.5-1.2,1.4-1.2,2.4c0,0.9,0.5,1.8,1.2,2.4l8.8,6.1v0%0D%0A%09%09l4.5,3.1l11.2,7.7c1,0.7,2.3,0.7,3.3,0l13.7-9.5l1.9-1.3v0l8.8-6.1c0.8-0.5,1.2-1.4,1.2-2.4S56.9,29.8,56.1,29.3z\"/>%0D%0A</g>%0D%0A</svg>%0D%0A');border:none;vertical-align:middle;fill:var(--smarterplan-primary)}.btn-3d:hover:enabled .icon-go-to-3d{background:url('data:image/svg+xml,<?xml version=\"1.0\" encoding=\"utf-8\"?>%0D%0A<!-- Generator: Adobe Illustrator 25.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->%0D%0A<svg version=\"1.1\" id=\"Calque_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"%0D%0A%09 viewBox=\"0 0 60 60\" style=\"enable-background:new 0 0 60 60;\" xml:space=\"preserve\">%0D%0A<style type=\"text/css\">%0D%0A%09.st0{fill:%23FFFFFF;}%0D%0A<\\/style>%0D%0A<g>%0D%0A%09<path class=\"st0\" d=\"M43.9,32.1V17.7c0-0.4-0.2-0.7-0.5-0.9l-12.8-8c-0.2-0.1-0.4-0.2-0.6-0.2c-0.2,0-0.4,0.1-0.6,0.2l-12.8,8%0D%0A%09%09c-0.3,0.2-0.5,0.5-0.5,0.9v14.4c0,0.4,0.2,0.7,0.5,0.9l12.8,8c0.3,0.2,0.8,0.2,1.1,0l12.8-8C43.7,32.8,43.9,32.5,43.9,32.1z%0D%0A%09%09 M28.9,38.2l-10.7-6.7v-12l10.7,6.7V38.2z M30,24.4l-10.8-6.8L30,10.9l10.8,6.8L30,24.4z M41.8,31.5l-10.7,6.7v-12l10.7-6.7V31.5z\"%0D%0A%09%09/>%0D%0A%09<path class=\"st0\" d=\"M56.1,29.3l-10.3-6.8v2l1.4,1v0l0.8,0.5l0,0l7,4.8c0.3,0.2,0.4,0.5,0.4,0.8c0,0.3-0.2,0.6-0.4,0.8l-6.8,4.7%0D%0A%09%09l0,0l-0.9,0.7v0l-2.9,2v0l-13.8,9.6c-0.3,0.2-0.8,0.2-1.1,0l-14.2-9.8l-2.6-1.8v0L5,32.4c-0.3-0.2-0.4-0.5-0.4-0.8%0D%0A%09%09c0-0.3,0.2-0.6,0.4-0.8l0,0l7.3-5l0,0l0.5-0.3v0l1.4-1v-2L3.9,29.3c-0.8,0.5-1.2,1.4-1.2,2.4c0,0.9,0.5,1.8,1.2,2.4l8.8,6.1v0%0D%0A%09%09l4.5,3.1l11.2,7.7c1,0.7,2.3,0.7,3.3,0l13.7-9.5l1.9-1.3v0l8.8-6.1c0.8-0.5,1.2-1.4,1.2-2.4S56.9,29.8,56.1,29.3z\"/>%0D%0A</g>%0D%0A</svg>%0D%0A')}.btn-3d[disabled]:hover .icon-go-to-3d{fill:var(--smarterplan-primary)}.outer_circle{background-color:#ebebeb;border-radius:50%;width:32px;height:32px;padding:1px}@media (max-width: 767px){.navbar{padding:.2rem .5rem}.form-control,.location,.floor,.zone{max-width:100%;margin-bottom:15px}input,select{margin-right:0;margin-bottom:15px}}\n"], dependencies: [{ kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }] });
18340
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigationBarComponent, deps: [{ token: 'currentAwsKinesisAnalyticsService' }, { token: i1.Router }, { token: SpaceService }, { token: BaseUserService }, { token: ZoneService }, { token: VisitService }, { token: ViewerService }, { token: NavigatorService }, { token: ZoneChangeService }, { token: BaseVisibilityService }], target: i0.ɵɵFactoryTarget.Component });
18341
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: NavigationBarComponent, selector: "lib-navigation-bar", viewQueries: [{ propertyName: "navbarSelectMenu", first: true, predicate: ["navbarSelectMenu"], descendants: true }], ngImport: i0, template: "<nav class=\"navbar navbar-expand-md navbar-dark navbar-inverse second-nav\">\r\n <div class=\"d-flex w-100\">\r\n <div #navbarSelectMenu class=\"w-100\" id=\"nav-item-container-blue\">\r\n <div class=\"d-flex flex-column flex-md-row p-1 mt-2\">\r\n <select class=\"form-control flex-fill flex-lg-fill-unset location select-menu\"\r\n [(ngModel)]=\"selectedLocation\" (ngModelChange)=\"onLocationClick()\">\r\n <option [ngValue]=\"null\" selected>{{ 'Location' | translate }}</option>\r\n <option *ngFor=\"let loc of locations; index as index\" [ngValue]=\"loc\"> {{ loc.name }}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu\" (change)=\"onVisitClick($event)\"\r\n *ngIf=\"visitsPerSpace && visitsPerSpace.length > 1\">\r\n <option value=\"default\" selected disabled hidden>{{'Visit' | translate}}</option>\r\n <option *ngFor=\"let visit of visitsPerSpace; index as index\" value=\"{{index}}\">{{ visit.name}}\r\n </option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset floor select-menu\" [(ngModel)]=\"selectedFloor\"\r\n (ngModelChange)=\"onFloorClick()\">\r\n <option [ngValue]=\"null\" selected>{{'Floor' | translate}}</option>\r\n <option *ngFor=\"let floor of floorsPerSpace\" [ngValue]=\"floor\">{{ floor.name}}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu zone\" [(ngModel)]=\"selectedZone\"\r\n (ngModelChange)=\"onZoneClick()\">\r\n <option [ngValue]=\"null\" selected>{{'Zone' | translate}}</option>\r\n <option *ngFor=\"let zone of zonesPerFloor\" [ngValue]=\"zone\"><span\r\n *ngIf=\"zone.code_ref\">{{zone.code_ref}}_</span>{{zone.name}}</option>\r\n </select>\r\n <select class=\"form-control flex-fill flex-lg-fill-unset select-menu\" [(ngModel)]=\"selectedChildZone\"\r\n *ngIf=\"childrenZones && childrenZones.length>0\" (ngModelChange)=\"onChildZoneClick()\">\r\n <option [ngValue]=\"null\" selected disabled>{{'Zone' | translate}}</option>\r\n <option *ngFor=\"let zone of childrenZones\" [ngValue]=\"zone\">{{ zone.name}}</option>\r\n </select>\r\n <button (click)=\"goTo()\"\r\n class=\"btn btn-outline-primary rounded-pill mx-2 w-md-fit-content h-md-fit-content align-self-md-center btn-3d d-none d-lg-block\"\r\n [disabled]=\"!selectedLocation || !selectedModel3d || !canGo()\">\r\n <i class=\"icon-go-to-3d d-inline-block\"></i> {{'3D visit' | translate}}\r\n </button>\r\n </div>\r\n <div class=\"row align-items-center justify-content-center ml-0 p-1\" *ngIf=\"showLocation()\">\r\n <p class=\"fw-bold lh-base align-middle text-center\">\r\n {{ showLocation() }}\r\n </p>\r\n </div>\r\n <div class=\"row align-items-center justify-content-center ml-0 p-1 d-block d-lg-none\">\r\n <button (click)=\"goTo()\"\r\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center btn-3d\"\r\n [disabled]=\"!selectedLocation || !selectedModel3d || !canGo()\">\r\n <i class=\"icon-go-to-3d d-inline-block\"></i> {{'3D visit' | translate}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</nav>", styles: [":host{position:sticky;top:0;height:123px}.navbar{z-index:200;padding:.4rem 1rem}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0}@media (min-width: 992px){.flex-lg-fill-unset{flex:unset!important}}.form-control{width:100%;min-width:80px;max-width:18%}.location{width:auto;max-width:35%}.floor,.zone{width:auto;max-width:30%}button{color:#fff;padding:5px 10px;font-size:1.1em}.navbar-toggler{margin-right:1em}.select-menu{max-width:inherit}.btn-3d .icon-go-to-3d{width:30px;height:30px;background:url('data:image/svg+xml,<?xml version=\"1.0\" encoding=\"utf-8\"?>%0D%0A<!-- Generator: Adobe Illustrator 25.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->%0D%0A<svg version=\"1.1\" id=\"Calque_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"%0D%0A%09 viewBox=\"0 0 60 60\" style=\"enable-background:new 0 0 60 60;\" xml:space=\"preserve\">%0D%0A<style type=\"text/css\">%0D%0A%09.st0{fill:%23565656;}%0D%0A<\\/style>%0D%0A<g>%0D%0A%09<path class=\"st0\" d=\"M43.9,32.1V17.7c0-0.4-0.2-0.7-0.5-0.9l-12.8-8c-0.2-0.1-0.4-0.2-0.6-0.2c-0.2,0-0.4,0.1-0.6,0.2l-12.8,8%0D%0A%09%09c-0.3,0.2-0.5,0.5-0.5,0.9v14.4c0,0.4,0.2,0.7,0.5,0.9l12.8,8c0.3,0.2,0.8,0.2,1.1,0l12.8-8C43.7,32.8,43.9,32.5,43.9,32.1z%0D%0A%09%09 M28.9,38.2l-10.7-6.7v-12l10.7,6.7V38.2z M30,24.4l-10.8-6.8L30,10.9l10.8,6.8L30,24.4z M41.8,31.5l-10.7,6.7v-12l10.7-6.7V31.5z\"%0D%0A%09%09/>%0D%0A%09<path class=\"st0\" d=\"M56.1,29.3l-10.3-6.8v2l1.4,1v0l0.8,0.5l0,0l7,4.8c0.3,0.2,0.4,0.5,0.4,0.8c0,0.3-0.2,0.6-0.4,0.8l-6.8,4.7%0D%0A%09%09l0,0l-0.9,0.7v0l-2.9,2v0l-13.8,9.6c-0.3,0.2-0.8,0.2-1.1,0l-14.2-9.8l-2.6-1.8v0L5,32.4c-0.3-0.2-0.4-0.5-0.4-0.8%0D%0A%09%09c0-0.3,0.2-0.6,0.4-0.8l0,0l7.3-5l0,0l0.5-0.3v0l1.4-1v-2L3.9,29.3c-0.8,0.5-1.2,1.4-1.2,2.4c0,0.9,0.5,1.8,1.2,2.4l8.8,6.1v0%0D%0A%09%09l4.5,3.1l11.2,7.7c1,0.7,2.3,0.7,3.3,0l13.7-9.5l1.9-1.3v0l8.8-6.1c0.8-0.5,1.2-1.4,1.2-2.4S56.9,29.8,56.1,29.3z\"/>%0D%0A</g>%0D%0A</svg>%0D%0A');border:none;vertical-align:middle;fill:var(--smarterplan-primary)}.btn-3d:hover:enabled .icon-go-to-3d{background:url('data:image/svg+xml,<?xml version=\"1.0\" encoding=\"utf-8\"?>%0D%0A<!-- Generator: Adobe Illustrator 25.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->%0D%0A<svg version=\"1.1\" id=\"Calque_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"%0D%0A%09 viewBox=\"0 0 60 60\" style=\"enable-background:new 0 0 60 60;\" xml:space=\"preserve\">%0D%0A<style type=\"text/css\">%0D%0A%09.st0{fill:%23FFFFFF;}%0D%0A<\\/style>%0D%0A<g>%0D%0A%09<path class=\"st0\" d=\"M43.9,32.1V17.7c0-0.4-0.2-0.7-0.5-0.9l-12.8-8c-0.2-0.1-0.4-0.2-0.6-0.2c-0.2,0-0.4,0.1-0.6,0.2l-12.8,8%0D%0A%09%09c-0.3,0.2-0.5,0.5-0.5,0.9v14.4c0,0.4,0.2,0.7,0.5,0.9l12.8,8c0.3,0.2,0.8,0.2,1.1,0l12.8-8C43.7,32.8,43.9,32.5,43.9,32.1z%0D%0A%09%09 M28.9,38.2l-10.7-6.7v-12l10.7,6.7V38.2z M30,24.4l-10.8-6.8L30,10.9l10.8,6.8L30,24.4z M41.8,31.5l-10.7,6.7v-12l10.7-6.7V31.5z\"%0D%0A%09%09/>%0D%0A%09<path class=\"st0\" d=\"M56.1,29.3l-10.3-6.8v2l1.4,1v0l0.8,0.5l0,0l7,4.8c0.3,0.2,0.4,0.5,0.4,0.8c0,0.3-0.2,0.6-0.4,0.8l-6.8,4.7%0D%0A%09%09l0,0l-0.9,0.7v0l-2.9,2v0l-13.8,9.6c-0.3,0.2-0.8,0.2-1.1,0l-14.2-9.8l-2.6-1.8v0L5,32.4c-0.3-0.2-0.4-0.5-0.4-0.8%0D%0A%09%09c0-0.3,0.2-0.6,0.4-0.8l0,0l7.3-5l0,0l0.5-0.3v0l1.4-1v-2L3.9,29.3c-0.8,0.5-1.2,1.4-1.2,2.4c0,0.9,0.5,1.8,1.2,2.4l8.8,6.1v0%0D%0A%09%09l4.5,3.1l11.2,7.7c1,0.7,2.3,0.7,3.3,0l13.7-9.5l1.9-1.3v0l8.8-6.1c0.8-0.5,1.2-1.4,1.2-2.4S56.9,29.8,56.1,29.3z\"/>%0D%0A</g>%0D%0A</svg>%0D%0A')}.btn-3d[disabled]:hover .icon-go-to-3d{fill:var(--smarterplan-primary)}.outer_circle{background-color:#ebebeb;border-radius:50%;width:32px;height:32px;padding:1px}@media (max-width: 767px){.navbar{padding:.2rem .5rem}.form-control,.location,.floor,.zone{max-width:100%;margin-bottom:15px}input,select{margin-right:0;margin-bottom:15px}}\n"], dependencies: [{ kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
17277
18342
  }
17278
18343
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NavigationBarComponent, decorators: [{
17279
18344
  type: Component,
@@ -17281,7 +18346,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
17281
18346
  }], ctorParameters: () => [{ type: undefined, decorators: [{
17282
18347
  type: Inject,
17283
18348
  args: ['currentAwsKinesisAnalyticsService']
17284
- }] }, { type: i1$1.Router }, { type: SpaceService }, { type: BaseUserService }, { type: ZoneService }, { type: VisitService }, { type: ViewerService }, { type: NavigatorService }, { type: ZoneChangeService }, { type: BaseVisibilityService }], propDecorators: { navbarSelectMenu: [{
18349
+ }] }, { type: i1.Router }, { type: SpaceService }, { type: BaseUserService }, { type: ZoneService }, { type: VisitService }, { type: ViewerService }, { type: NavigatorService }, { type: ZoneChangeService }, { type: BaseVisibilityService }], propDecorators: { navbarSelectMenu: [{
17285
18350
  type: ViewChild,
17286
18351
  args: ['navbarSelectMenu']
17287
18352
  }] } });
@@ -17325,6 +18390,7 @@ class MenuBarComponent {
17325
18390
  formatter;
17326
18391
  filterService;
17327
18392
  cacheService;
18393
+ checkIcon = iconData(checkIcon);
17328
18394
  user;
17329
18395
  mission;
17330
18396
  isCollapsed = true;
@@ -17545,14 +18611,366 @@ class MenuBarComponent {
17545
18611
  localStorage.setItem('endDate', endDate.getTime().toString());
17546
18612
  }
17547
18613
  }
17548
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MenuBarComponent, deps: [{ token: i1$1.Router }, { token: LocaleService }, { token: BaseUserService }, { token: NavigatorService }, { token: SupportService }, { token: BaseVisibilityService }, { token: i1$2.NgbCalendar }, { token: i1$2.NgbDateParserFormatter }, { token: FilterService }, { token: AmplifyCacheService }], target: i0.ɵɵFactoryTarget.Component });
17549
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: MenuBarComponent, selector: "lib-menu-bar", inputs: { cacheName: "cacheName" }, ngImport: i0, template: "<div id=\"menu-bar\">\r\n <div *ngIf=\"!isVisitor\">\r\n <nav class=\"navbar navbar-expand-md navbar-light p-0\">\r\n <div class=\"container-fluid\" *ngIf=\"isVisible\">\r\n <div class=\"navbar-brand order-md-0\" [routerLink]=\"['/dashboard']\">\r\n <img alt=\"SmarterPlan\" src=\"../assets/images/logos/logo-immo.png\">\r\n </div>\r\n <div class=\"ms-auto nav-item dropdown profile_pic-container order-md-2\">\r\n <div class=\"profile_pic dropdown-toggle\" data-testid=\"dropdown-menu-button\" data-bs-toggle=\"dropdown\">\r\n <lib-avatar></lib-avatar>\r\n </div>\r\n <div class=\"dropdown-menu dropdown-menu-right\">\r\n <p *ngIf=\"user && mission\" class=\"p-2\">\r\n <span class=\"username\">{{ user.displayName }}</span><br />\r\n <span class=\"user-role\">{{ mission.role }}</span><br />\r\n <span class=\"org\">{{ mission.organisation ? mission.organisation.name : \"No organisation\" |\r\n translate}}</span>\r\n </p>\r\n <div class=\"dropdown-divider\"></div>\r\n <!-- <a class=\"dropdown-item\" routerLink=\"/debug\" *ngIf=\"isManager\">Debug</a> -->\r\n <a class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</a>\r\n <a class=\"dropdown-item\" routerLink=\"/dashboard\">{{'Data management' | translate}}</a>\r\n <a class=\"dropdown-item\" data-testid=\"user-management-btn\" routerLink=\"/admin\" *ngIf=\"isManager\">\r\n {{'Users management' | translate}}</a>\r\n <a class=\"dropdown-item\" routerLink=\"/profile\">\r\n {{'Profile' | translate}}</a>\r\n <div class=\"dropdown-divider\"></div>\r\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\r\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n <button class=\"navbar-toggler order-md-1\" (click)=\"navbarCollapse.toggle()\" type=\"button\"\r\n [attr.aria-expanded]=\"!isCollapsed\" aria-controls=\"navbar-collapse\">\r\n <span class=\"navbar-toggler-icon\"></span>\r\n </button>\r\n <div class=\"navbar-collapse order-md-1\" #navbarCollapse=\"ngbCollapse\" [(ngbCollapse)]=\"isCollapsed\"\r\n [animation]=\"false\">\r\n <form\r\n class=\"form-inline m-0 mt-2 form-container d-flex justify-content-start align-items-start align-items-md-center flex-column flex-md-row flex-nowrap filters-menu-block\">\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\r\n <input class=\"form-control search-button m-1\" placeholder=\"keyword\" id=\"mainSearchBar\" type=\"text\">\r\n <button class=\"btn btn-outline-primary rounded-pill m-1 w-fit-content h-fit-content align-self-md-center\"\r\n (click)=\"onSubmit()\">{{'Search' |\r\n translate}}</button>\r\n </div>\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\r\n <div class=\"input-group date-selector m-1\">\r\n <input #dpFromDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpFromDate\"\r\n [value]=\"fromDate | formatDateNumberToDigits\"\r\n (input)=\"fromDate = validateInput(fromDate, dpFromDate.value)\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n <input name=\"datepicker\" class=\"form-control visually-hidden\" ngbDatepicker #datepicker=\"ngbDatepicker\"\r\n [autoClose]=\"'outside'\" (dateSelect)=\"onDateSelection($event)\" [displayMonths]=\"2\" [dayTemplate]=\"t\"\r\n outsideDays=\"hidden\" [startDate]=\"fromDate || calendar.getToday()\" [container]=\"'body'\" tabindex=\"-1\">\r\n <ng-template #t let-date let-focused=\"focused\">\r\n <span class=\"custom-day\" [class.focused]=\"focused\" [class.range]=\"isRange(date)\"\r\n [class.faded]=\"isHovered(date) || isInside(date)\" (mouseenter)=\"hoveredDate = date\"\r\n (mouseleave)=\"hoveredDate = null\">\r\n {{ date.day }}\r\n </span>\r\n </ng-template>\r\n <span class=\"ms-1 p-2\">{{'to' | translate}}</span>\r\n <div class=\"input-group date-selector m-1\">\r\n <input #dpToDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpToDate\"\r\n [value]=\"toDate | formatDateNumberToDigits\" (input)=\"toDate = validateInput(toDate, dpToDate.value)\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-1 justify-content-evenly\">\r\n <button\r\n class=\"btn btn-primary rounded-pill ms-1 w-25 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n type=\"button\" (click)=\"onApply()\" *ngIf=\"!isDateFilterApplied || dateChanged\">\r\n {{'Apply' | translate}}\r\n </button>\r\n <span\r\n class=\"appliedText ms-1 py-2 align-self-md-center pb-md-0 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n *ngIf=\"isDateFilterApplied && !dateChanged\">\r\n <span class=\"iconify\" data-icon=\"ion:checkmark\" data-width=\"15\" data-height=\"15\"></span>\r\n {{\"Applied\" | translate}}\r\n </span>\r\n <button\r\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n type=\"button\" (click)=\"onClearDates()\">{{'Clear'\r\n |\r\n translate}}</button>\r\n <div\r\n class=\"change-position-button align-self-end pb-2 align-self-md-center mx-2 pb-md-0 flex-nowrap w-25 w-md-fit-content h-md-fit-content\">\r\n <input type=\"checkbox\" class=\"btn-check\" id=\"btn-check-outlined\" autocomplete=\"off\">\r\n <label class=\"link-primary cursor-pointer text-decoration-underline\" (click)=\"onChangePositionClick()\"\r\n for=\"btn-check-outlined\">{{\r\n (isChangePositionVisible ? \"Close\" : \"Move to\") | translate }}</label>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </nav>\r\n <lib-navigation-bar *ngIf=\"isVisible && isChangePositionVisible\"></lib-navigation-bar>\r\n </div>\r\n <div *ngIf=\"isVisitor && isVisible\">\r\n <div class=\"visitor-div\">\r\n <div class=\"logo-container\" data-testid=\"dropdown-menu-button\">\r\n <img class=\"img-logo\" alt=\"SmarterPlanLogo\" src=\"../assets/images/logos/logo-reserve.png\">\r\n </div>\r\n <div class=\"avatar-container-menu\">\r\n <div class=\"profile_pic dropdown-toggle cursor-pointer\" data-bs-toggle=\"dropdown\">\r\n <lib-avatar></lib-avatar>\r\n </div>\r\n <div class=\"dropdown-menu dropdown-menu-right\">\r\n <button class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</button>\r\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\r\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: ["#menu-bar{position:sticky;top:0;z-index:200}.navbar{z-index:200}.navbar-brand{padding-top:5px;padding-bottom:5px;cursor:pointer}.navbar-brand img{height:70px}.profile_pic{border-radius:50%;height:45px;width:45px;margin:8px;border:.2px solid rgb(150,150,150)}.navbar-nav .profile-pic-container .dropdown-menu{position:absolute}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}.profile_pic.dropdown-toggle:after{display:none}.navbar-light{border-bottom:1px solid var(--smarterplan-primary);background-color:#fff}.navbar form{width:100%;margin:0;padding:0}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0;width:auto}button{padding:5px 10px}button:disabled,button[disabled]{color:#c04f4f}.navbar-toggler{margin-right:1em}.icon{height:40px;width:40px;color:var(--smarterplan-primary)}.search-button-container{width:auto;align-items:stretch;justify-items:start}.search-button-container .search-button{width:auto;border-radius:1rem!important}.visitor-div{background-color:var(--smarterplan-primary);height:60px;display:flex;justify-content:space-between}.profile_pic-container{margin-right:1em}.logo-container,.img-logo{height:100%}.change-position-button{margin-left:2rem}.change-position-button label,.change-position-button .btn-check:checked,.change-position-button .btn-check:focus,.change-position-button .btn-outline-primary,.change-position-button .btn{box-shadow:none!important;outline:0}.change-position-button label{border-radius:16px}.change-position-button .btn-check:checked+.btn{background-color:var(--smarterplan-primary);color:#fff!important}.filters-menu-block{width:auto}@media (min-width: 1200px){.navbar-brand img{height:100px}.profile_pic{height:60px;width:60px;margin:15px}}@media (min-width: 992px) and (max-width: 1199.98px){.navbar-brand img{height:80px}.profile_pic{height:50px;width:50px;margin:12px}}@media (min-width: 768px) and (max-width: 991.98px){.navbar-brand img{height:60px}.profile_pic{height:40px;width:40px;margin:10px}}@media (max-width: 767.98px){.navbar-brand img{height:50px}.profile_pic{height:30px;width:30px;margin:8px}.search-button-container,.filters-menu-block{width:100%}}.form-container{margin:.5rem 0}.navbar-collapse.show{display:flex;padding-bottom:.5rem}.hidden{width:0;margin:0;border:none;padding:0}.custom-day{text-align:center;padding:.185rem .25rem;display:inline-block;height:2rem;width:2rem}.custom-day.focused{background-color:#e6e6e6}.custom-day.range,.custom-day:hover{background-color:var(--smarterplan-primary-lighter);color:#fff}.custom-day.faded{background-color:var(--smarterplan-primary-transparent)}.calendar{height:100%}.appliedText,.appliedText span{color:var(--smarterplan-primary)}@media (max-width: 767px){.form-inline{flex-direction:column}}.hidden{opacity:0}.date-selector{flex-wrap:nowrap}.date-selector input{min-width:80px;margin:0}@media (min-width: 768px){.w-md-fit-content{width:fit-content!important}.h-md-content{height:fit-content!important}}\n"], dependencies: [{ kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i1$2.NgbCollapse, selector: "[ngbCollapse]", inputs: ["animation", "ngbCollapse", "horizontal"], outputs: ["ngbCollapseChange", "shown", "hidden"], exportAs: ["ngbCollapse"] }, { kind: "directive", type: i1$2.NgbInputDatepicker, selector: "input[ngbDatepicker]", inputs: ["autoClose", "contentTemplate", "datepickerClass", "dayTemplate", "dayTemplateData", "displayMonths", "firstDayOfWeek", "footerTemplate", "markDisabled", "minDate", "maxDate", "navigation", "outsideDays", "placement", "popperOptions", "restoreFocus", "showWeekNumbers", "startDate", "container", "positionTarget", "weekdays", "disabled"], outputs: ["dateSelect", "navigate", "closed"], exportAs: ["ngbDatepicker"] }, { kind: "component", type: AvatarComponent, selector: "lib-avatar", inputs: ["size", "userID"] }, { kind: "component", type: NavigationBarComponent, selector: "lib-navigation-bar" }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }, { kind: "pipe", type: FormatDateNumberToDigitsPipe, name: "formatDateNumberToDigits" }] });
18614
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MenuBarComponent, deps: [{ token: i1.Router }, { token: LocaleService }, { token: BaseUserService }, { token: NavigatorService }, { token: SupportService }, { token: BaseVisibilityService }, { token: i1$2.NgbCalendar }, { token: i1$2.NgbDateParserFormatter }, { token: FilterService }, { token: AmplifyCacheService }], target: i0.ɵɵFactoryTarget.Component });
18615
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: MenuBarComponent, selector: "lib-menu-bar", inputs: { cacheName: "cacheName" }, ngImport: i0, template: "<div id=\"menu-bar\">\n <div *ngIf=\"!isVisitor\">\n <nav class=\"navbar navbar-expand-md navbar-light p-0\">\n <div class=\"container-fluid\" *ngIf=\"isVisible\">\n <div class=\"navbar-brand order-md-0\" [routerLink]=\"['/dashboard']\">\n <img alt=\"SmarterPlan\" src=\"../assets/images/logos/logo-immo.png\">\n </div>\n <div class=\"ms-auto nav-item dropdown profile_pic-container order-md-2\">\n <div class=\"profile_pic dropdown-toggle\" data-testid=\"dropdown-menu-button\" data-bs-toggle=\"dropdown\">\n <lib-avatar></lib-avatar>\n </div>\n <div class=\"dropdown-menu dropdown-menu-right\">\n <p *ngIf=\"user && mission\" class=\"p-2\">\n <span class=\"username\">{{ user.displayName }}</span><br />\n <span class=\"user-role\">{{ mission.role }}</span><br />\n <span class=\"org\">{{ mission.organisation ? mission.organisation.name : \"No organisation\" |\n translate}}</span>\n </p>\n <div class=\"dropdown-divider\"></div>\n <!-- <a class=\"dropdown-item\" routerLink=\"/debug\" *ngIf=\"isManager\">Debug</a> -->\n <a class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</a>\n <a class=\"dropdown-item\" routerLink=\"/dashboard\">{{'Data management' | translate}}</a>\n <a class=\"dropdown-item\" data-testid=\"user-management-btn\" routerLink=\"/admin\" *ngIf=\"isManager\">\n {{'Users management' | translate}}</a>\n <a class=\"dropdown-item\" routerLink=\"/profile\">\n {{'Profile' | translate}}</a>\n <div class=\"dropdown-divider\"></div>\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\n translate}}</button>\n </div>\n </div>\n <button class=\"navbar-toggler order-md-1\" (click)=\"navbarCollapse.toggle()\" type=\"button\"\n [attr.aria-expanded]=\"!isCollapsed\" aria-controls=\"navbar-collapse\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n <div class=\"navbar-collapse order-md-1\" #navbarCollapse=\"ngbCollapse\" [(ngbCollapse)]=\"isCollapsed\"\n [animation]=\"false\">\n <form\n class=\"form-inline m-0 mt-2 form-container d-flex justify-content-start align-items-start align-items-md-center flex-column flex-md-row flex-nowrap filters-menu-block\">\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\n <input class=\"form-control search-button m-1\" placeholder=\"keyword\" id=\"mainSearchBar\" type=\"text\">\n <button class=\"btn btn-outline-primary rounded-pill m-1 w-fit-content h-fit-content align-self-md-center\"\n (click)=\"onSubmit()\">{{'Search' |\n translate}}</button>\n </div>\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\n <div class=\"input-group date-selector m-1\">\n <input #dpFromDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpFromDate\"\n [value]=\"fromDate | formatDateNumberToDigits\"\n (input)=\"fromDate = validateInput(fromDate, dpFromDate.value)\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n <input name=\"datepicker\" class=\"form-control visually-hidden\" ngbDatepicker #datepicker=\"ngbDatepicker\"\n [autoClose]=\"'outside'\" (dateSelect)=\"onDateSelection($event)\" [displayMonths]=\"2\" [dayTemplate]=\"t\"\n outsideDays=\"hidden\" [startDate]=\"fromDate || calendar.getToday()\" [container]=\"'body'\" tabindex=\"-1\">\n <ng-template #t let-date let-focused=\"focused\">\n <span class=\"custom-day\" [class.focused]=\"focused\" [class.range]=\"isRange(date)\"\n [class.faded]=\"isHovered(date) || isInside(date)\" (mouseenter)=\"hoveredDate = date\"\n (mouseleave)=\"hoveredDate = null\">\n {{ date.day }}\n </span>\n </ng-template>\n <span class=\"ms-1 p-2\">{{'to' | translate}}</span>\n <div class=\"input-group date-selector m-1\">\n <input #dpToDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpToDate\"\n [value]=\"toDate | formatDateNumberToDigits\" (input)=\"toDate = validateInput(toDate, dpToDate.value)\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n </div>\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-1 justify-content-evenly\">\n <button\n class=\"btn btn-primary rounded-pill ms-1 w-25 w-md-fit-content h-md-fit-content align-self-md-center\"\n type=\"button\" (click)=\"onApply()\" *ngIf=\"!isDateFilterApplied || dateChanged\">\n {{'Apply' | translate}}\n </button>\n <span\n class=\"appliedText ms-1 py-2 align-self-md-center pb-md-0 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\n *ngIf=\"isDateFilterApplied && !dateChanged\">\n <span class=\"iconify\" [icIcon]=\"checkIcon\" width=\"15\" height=\"15\"></span>\n {{\"Applied\" | translate}}\n </span>\n <button\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\n type=\"button\" (click)=\"onClearDates()\">{{'Clear'\n |\n translate}}</button>\n <div\n class=\"change-position-button align-self-end pb-2 align-self-md-center mx-2 pb-md-0 flex-nowrap w-25 w-md-fit-content h-md-fit-content\">\n <input type=\"checkbox\" class=\"btn-check\" id=\"btn-check-outlined\" autocomplete=\"off\">\n <label class=\"link-primary cursor-pointer text-decoration-underline\" (click)=\"onChangePositionClick()\"\n for=\"btn-check-outlined\">{{\n (isChangePositionVisible ? \"Close\" : \"Move to\") | translate }}</label>\n </div>\n </div>\n </form>\n </div>\n </div>\n </nav>\n <lib-navigation-bar *ngIf=\"isVisible && isChangePositionVisible\"></lib-navigation-bar>\n </div>\n <div *ngIf=\"isVisitor && isVisible\">\n <div class=\"visitor-div\">\n <div class=\"logo-container\" data-testid=\"dropdown-menu-button\">\n <img class=\"img-logo\" alt=\"SmarterPlanLogo\" src=\"../assets/images/logos/logo-reserve.png\">\n </div>\n <div class=\"avatar-container-menu\">\n <div class=\"profile_pic dropdown-toggle cursor-pointer\" data-bs-toggle=\"dropdown\">\n <lib-avatar></lib-avatar>\n </div>\n <div class=\"dropdown-menu dropdown-menu-right\">\n <button class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</button>\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\n translate}}</button>\n </div>\n </div>\n </div>\n </div>\n</div>", styles: ["#menu-bar{position:sticky;top:0;z-index:200}.navbar{z-index:200}.navbar-brand{padding-top:5px;padding-bottom:5px;cursor:pointer}.navbar-brand img{height:70px}.profile_pic{border-radius:50%;height:45px;width:45px;margin:8px;border:.2px solid rgb(150,150,150)}.navbar-nav .profile-pic-container .dropdown-menu{position:absolute}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}.profile_pic.dropdown-toggle:after{display:none}.navbar-light{border-bottom:1px solid var(--smarterplan-primary);background-color:#fff}.navbar form{width:100%;margin:0;padding:0}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0;width:auto}button{padding:5px 10px}button:disabled,button[disabled]{color:#c04f4f}.navbar-toggler{margin-right:1em}.icon{height:40px;width:40px;color:var(--smarterplan-primary)}.search-button-container{width:auto;align-items:stretch;justify-items:start}.search-button-container .search-button{width:auto;border-radius:1rem!important}.visitor-div{background-color:var(--smarterplan-primary);height:60px;display:flex;justify-content:space-between}.profile_pic-container{margin-right:1em}.logo-container,.img-logo{height:100%}.change-position-button{margin-left:2rem}.change-position-button label,.change-position-button .btn-check:checked,.change-position-button .btn-check:focus,.change-position-button .btn-outline-primary,.change-position-button .btn{box-shadow:none!important;outline:0}.change-position-button label{border-radius:16px}.change-position-button .btn-check:checked+.btn{background-color:var(--smarterplan-primary);color:#fff!important}.filters-menu-block{width:auto}@media (min-width: 1200px){.navbar-brand img{height:100px}.profile_pic{height:60px;width:60px;margin:15px}}@media (min-width: 992px) and (max-width: 1199.98px){.navbar-brand img{height:80px}.profile_pic{height:50px;width:50px;margin:12px}}@media (min-width: 768px) and (max-width: 991.98px){.navbar-brand img{height:60px}.profile_pic{height:40px;width:40px;margin:10px}}@media (max-width: 767.98px){.navbar-brand img{height:50px}.profile_pic{height:30px;width:30px;margin:8px}.search-button-container,.filters-menu-block{width:100%}}.form-container{margin:.5rem 0}.navbar-collapse.show{display:flex;padding-bottom:.5rem}.hidden{width:0;margin:0;border:none;padding:0}.custom-day{text-align:center;padding:.185rem .25rem;display:inline-block;height:2rem;width:2rem}.custom-day.focused{background-color:#e6e6e6}.custom-day.range,.custom-day:hover{background-color:var(--smarterplan-primary-lighter);color:#fff}.custom-day.faded{background-color:var(--smarterplan-primary-transparent)}.calendar{height:100%}.appliedText,.appliedText span{color:var(--smarterplan-primary)}@media (max-width: 767px){.form-inline{flex-direction:column}}.hidden{opacity:0}.date-selector{flex-wrap:nowrap}.date-selector input{min-width:80px;margin:0}@media (min-width: 768px){.w-md-fit-content{width:fit-content!important}.h-md-content{height:fit-content!important}}\n"], dependencies: [{ kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i1$2.NgbCollapse, selector: "[ngbCollapse]", inputs: ["animation", "ngbCollapse", "horizontal"], outputs: ["ngbCollapseChange", "shown", "hidden"], exportAs: ["ngbCollapse"] }, { kind: "directive", type: i1$2.NgbInputDatepicker, selector: "input[ngbDatepicker]", inputs: ["autoClose", "contentTemplate", "datepickerClass", "dayTemplate", "dayTemplateData", "displayMonths", "firstDayOfWeek", "footerTemplate", "markDisabled", "minDate", "maxDate", "navigation", "outsideDays", "placement", "popperOptions", "restoreFocus", "showWeekNumbers", "startDate", "container", "positionTarget", "weekdays", "disabled"], outputs: ["dateSelect", "navigate", "closed"], exportAs: ["ngbDatepicker"] }, { kind: "directive", type: i1$3.IconDirective, selector: "ic-icon,[icIcon]", inputs: ["icIcon", "icon", "color", "inline", "box", "size", "width", "height", "align", "hFlip", "vFlip", "flip", "rotate"] }, { kind: "component", type: AvatarComponent, selector: "lib-avatar", inputs: ["size", "userID"] }, { kind: "component", type: NavigationBarComponent, selector: "lib-navigation-bar" }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }, { kind: "pipe", type: FormatDateNumberToDigitsPipe, name: "formatDateNumberToDigits" }] });
17550
18616
  }
17551
18617
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MenuBarComponent, decorators: [{
17552
18618
  type: Component,
17553
- args: [{ selector: 'lib-menu-bar', template: "<div id=\"menu-bar\">\r\n <div *ngIf=\"!isVisitor\">\r\n <nav class=\"navbar navbar-expand-md navbar-light p-0\">\r\n <div class=\"container-fluid\" *ngIf=\"isVisible\">\r\n <div class=\"navbar-brand order-md-0\" [routerLink]=\"['/dashboard']\">\r\n <img alt=\"SmarterPlan\" src=\"../assets/images/logos/logo-immo.png\">\r\n </div>\r\n <div class=\"ms-auto nav-item dropdown profile_pic-container order-md-2\">\r\n <div class=\"profile_pic dropdown-toggle\" data-testid=\"dropdown-menu-button\" data-bs-toggle=\"dropdown\">\r\n <lib-avatar></lib-avatar>\r\n </div>\r\n <div class=\"dropdown-menu dropdown-menu-right\">\r\n <p *ngIf=\"user && mission\" class=\"p-2\">\r\n <span class=\"username\">{{ user.displayName }}</span><br />\r\n <span class=\"user-role\">{{ mission.role }}</span><br />\r\n <span class=\"org\">{{ mission.organisation ? mission.organisation.name : \"No organisation\" |\r\n translate}}</span>\r\n </p>\r\n <div class=\"dropdown-divider\"></div>\r\n <!-- <a class=\"dropdown-item\" routerLink=\"/debug\" *ngIf=\"isManager\">Debug</a> -->\r\n <a class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</a>\r\n <a class=\"dropdown-item\" routerLink=\"/dashboard\">{{'Data management' | translate}}</a>\r\n <a class=\"dropdown-item\" data-testid=\"user-management-btn\" routerLink=\"/admin\" *ngIf=\"isManager\">\r\n {{'Users management' | translate}}</a>\r\n <a class=\"dropdown-item\" routerLink=\"/profile\">\r\n {{'Profile' | translate}}</a>\r\n <div class=\"dropdown-divider\"></div>\r\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\r\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n <button class=\"navbar-toggler order-md-1\" (click)=\"navbarCollapse.toggle()\" type=\"button\"\r\n [attr.aria-expanded]=\"!isCollapsed\" aria-controls=\"navbar-collapse\">\r\n <span class=\"navbar-toggler-icon\"></span>\r\n </button>\r\n <div class=\"navbar-collapse order-md-1\" #navbarCollapse=\"ngbCollapse\" [(ngbCollapse)]=\"isCollapsed\"\r\n [animation]=\"false\">\r\n <form\r\n class=\"form-inline m-0 mt-2 form-container d-flex justify-content-start align-items-start align-items-md-center flex-column flex-md-row flex-nowrap filters-menu-block\">\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\r\n <input class=\"form-control search-button m-1\" placeholder=\"keyword\" id=\"mainSearchBar\" type=\"text\">\r\n <button class=\"btn btn-outline-primary rounded-pill m-1 w-fit-content h-fit-content align-self-md-center\"\r\n (click)=\"onSubmit()\">{{'Search' |\r\n translate}}</button>\r\n </div>\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\r\n <div class=\"input-group date-selector m-1\">\r\n <input #dpFromDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpFromDate\"\r\n [value]=\"fromDate | formatDateNumberToDigits\"\r\n (input)=\"fromDate = validateInput(fromDate, dpFromDate.value)\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n <input name=\"datepicker\" class=\"form-control visually-hidden\" ngbDatepicker #datepicker=\"ngbDatepicker\"\r\n [autoClose]=\"'outside'\" (dateSelect)=\"onDateSelection($event)\" [displayMonths]=\"2\" [dayTemplate]=\"t\"\r\n outsideDays=\"hidden\" [startDate]=\"fromDate || calendar.getToday()\" [container]=\"'body'\" tabindex=\"-1\">\r\n <ng-template #t let-date let-focused=\"focused\">\r\n <span class=\"custom-day\" [class.focused]=\"focused\" [class.range]=\"isRange(date)\"\r\n [class.faded]=\"isHovered(date) || isInside(date)\" (mouseenter)=\"hoveredDate = date\"\r\n (mouseleave)=\"hoveredDate = null\">\r\n {{ date.day }}\r\n </span>\r\n </ng-template>\r\n <span class=\"ms-1 p-2\">{{'to' | translate}}</span>\r\n <div class=\"input-group date-selector m-1\">\r\n <input #dpToDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpToDate\"\r\n [value]=\"toDate | formatDateNumberToDigits\" (input)=\"toDate = validateInput(toDate, dpToDate.value)\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-1 justify-content-evenly\">\r\n <button\r\n class=\"btn btn-primary rounded-pill ms-1 w-25 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n type=\"button\" (click)=\"onApply()\" *ngIf=\"!isDateFilterApplied || dateChanged\">\r\n {{'Apply' | translate}}\r\n </button>\r\n <span\r\n class=\"appliedText ms-1 py-2 align-self-md-center pb-md-0 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n *ngIf=\"isDateFilterApplied && !dateChanged\">\r\n <span class=\"iconify\" data-icon=\"ion:checkmark\" data-width=\"15\" data-height=\"15\"></span>\r\n {{\"Applied\" | translate}}\r\n </span>\r\n <button\r\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\r\n type=\"button\" (click)=\"onClearDates()\">{{'Clear'\r\n |\r\n translate}}</button>\r\n <div\r\n class=\"change-position-button align-self-end pb-2 align-self-md-center mx-2 pb-md-0 flex-nowrap w-25 w-md-fit-content h-md-fit-content\">\r\n <input type=\"checkbox\" class=\"btn-check\" id=\"btn-check-outlined\" autocomplete=\"off\">\r\n <label class=\"link-primary cursor-pointer text-decoration-underline\" (click)=\"onChangePositionClick()\"\r\n for=\"btn-check-outlined\">{{\r\n (isChangePositionVisible ? \"Close\" : \"Move to\") | translate }}</label>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </nav>\r\n <lib-navigation-bar *ngIf=\"isVisible && isChangePositionVisible\"></lib-navigation-bar>\r\n </div>\r\n <div *ngIf=\"isVisitor && isVisible\">\r\n <div class=\"visitor-div\">\r\n <div class=\"logo-container\" data-testid=\"dropdown-menu-button\">\r\n <img class=\"img-logo\" alt=\"SmarterPlanLogo\" src=\"../assets/images/logos/logo-reserve.png\">\r\n </div>\r\n <div class=\"avatar-container-menu\">\r\n <div class=\"profile_pic dropdown-toggle cursor-pointer\" data-bs-toggle=\"dropdown\">\r\n <lib-avatar></lib-avatar>\r\n </div>\r\n <div class=\"dropdown-menu dropdown-menu-right\">\r\n <button class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</button>\r\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\r\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>", styles: ["#menu-bar{position:sticky;top:0;z-index:200}.navbar{z-index:200}.navbar-brand{padding-top:5px;padding-bottom:5px;cursor:pointer}.navbar-brand img{height:70px}.profile_pic{border-radius:50%;height:45px;width:45px;margin:8px;border:.2px solid rgb(150,150,150)}.navbar-nav .profile-pic-container .dropdown-menu{position:absolute}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}.profile_pic.dropdown-toggle:after{display:none}.navbar-light{border-bottom:1px solid var(--smarterplan-primary);background-color:#fff}.navbar form{width:100%;margin:0;padding:0}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0;width:auto}button{padding:5px 10px}button:disabled,button[disabled]{color:#c04f4f}.navbar-toggler{margin-right:1em}.icon{height:40px;width:40px;color:var(--smarterplan-primary)}.search-button-container{width:auto;align-items:stretch;justify-items:start}.search-button-container .search-button{width:auto;border-radius:1rem!important}.visitor-div{background-color:var(--smarterplan-primary);height:60px;display:flex;justify-content:space-between}.profile_pic-container{margin-right:1em}.logo-container,.img-logo{height:100%}.change-position-button{margin-left:2rem}.change-position-button label,.change-position-button .btn-check:checked,.change-position-button .btn-check:focus,.change-position-button .btn-outline-primary,.change-position-button .btn{box-shadow:none!important;outline:0}.change-position-button label{border-radius:16px}.change-position-button .btn-check:checked+.btn{background-color:var(--smarterplan-primary);color:#fff!important}.filters-menu-block{width:auto}@media (min-width: 1200px){.navbar-brand img{height:100px}.profile_pic{height:60px;width:60px;margin:15px}}@media (min-width: 992px) and (max-width: 1199.98px){.navbar-brand img{height:80px}.profile_pic{height:50px;width:50px;margin:12px}}@media (min-width: 768px) and (max-width: 991.98px){.navbar-brand img{height:60px}.profile_pic{height:40px;width:40px;margin:10px}}@media (max-width: 767.98px){.navbar-brand img{height:50px}.profile_pic{height:30px;width:30px;margin:8px}.search-button-container,.filters-menu-block{width:100%}}.form-container{margin:.5rem 0}.navbar-collapse.show{display:flex;padding-bottom:.5rem}.hidden{width:0;margin:0;border:none;padding:0}.custom-day{text-align:center;padding:.185rem .25rem;display:inline-block;height:2rem;width:2rem}.custom-day.focused{background-color:#e6e6e6}.custom-day.range,.custom-day:hover{background-color:var(--smarterplan-primary-lighter);color:#fff}.custom-day.faded{background-color:var(--smarterplan-primary-transparent)}.calendar{height:100%}.appliedText,.appliedText span{color:var(--smarterplan-primary)}@media (max-width: 767px){.form-inline{flex-direction:column}}.hidden{opacity:0}.date-selector{flex-wrap:nowrap}.date-selector input{min-width:80px;margin:0}@media (min-width: 768px){.w-md-fit-content{width:fit-content!important}.h-md-content{height:fit-content!important}}\n"] }]
17554
- }], ctorParameters: () => [{ type: i1$1.Router }, { type: LocaleService }, { type: BaseUserService }, { type: NavigatorService }, { type: SupportService }, { type: BaseVisibilityService }, { type: i1$2.NgbCalendar }, { type: i1$2.NgbDateParserFormatter }, { type: FilterService }, { type: AmplifyCacheService }], propDecorators: { cacheName: [{
18619
+ args: [{ selector: 'lib-menu-bar', template: "<div id=\"menu-bar\">\n <div *ngIf=\"!isVisitor\">\n <nav class=\"navbar navbar-expand-md navbar-light p-0\">\n <div class=\"container-fluid\" *ngIf=\"isVisible\">\n <div class=\"navbar-brand order-md-0\" [routerLink]=\"['/dashboard']\">\n <img alt=\"SmarterPlan\" src=\"../assets/images/logos/logo-immo.png\">\n </div>\n <div class=\"ms-auto nav-item dropdown profile_pic-container order-md-2\">\n <div class=\"profile_pic dropdown-toggle\" data-testid=\"dropdown-menu-button\" data-bs-toggle=\"dropdown\">\n <lib-avatar></lib-avatar>\n </div>\n <div class=\"dropdown-menu dropdown-menu-right\">\n <p *ngIf=\"user && mission\" class=\"p-2\">\n <span class=\"username\">{{ user.displayName }}</span><br />\n <span class=\"user-role\">{{ mission.role }}</span><br />\n <span class=\"org\">{{ mission.organisation ? mission.organisation.name : \"No organisation\" |\n translate}}</span>\n </p>\n <div class=\"dropdown-divider\"></div>\n <!-- <a class=\"dropdown-item\" routerLink=\"/debug\" *ngIf=\"isManager\">Debug</a> -->\n <a class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</a>\n <a class=\"dropdown-item\" routerLink=\"/dashboard\">{{'Data management' | translate}}</a>\n <a class=\"dropdown-item\" data-testid=\"user-management-btn\" routerLink=\"/admin\" *ngIf=\"isManager\">\n {{'Users management' | translate}}</a>\n <a class=\"dropdown-item\" routerLink=\"/profile\">\n {{'Profile' | translate}}</a>\n <div class=\"dropdown-divider\"></div>\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\n translate}}</button>\n </div>\n </div>\n <button class=\"navbar-toggler order-md-1\" (click)=\"navbarCollapse.toggle()\" type=\"button\"\n [attr.aria-expanded]=\"!isCollapsed\" aria-controls=\"navbar-collapse\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n <div class=\"navbar-collapse order-md-1\" #navbarCollapse=\"ngbCollapse\" [(ngbCollapse)]=\"isCollapsed\"\n [animation]=\"false\">\n <form\n class=\"form-inline m-0 mt-2 form-container d-flex justify-content-start align-items-start align-items-md-center flex-column flex-md-row flex-nowrap filters-menu-block\">\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\n <input class=\"form-control search-button m-1\" placeholder=\"keyword\" id=\"mainSearchBar\" type=\"text\">\n <button class=\"btn btn-outline-primary rounded-pill m-1 w-fit-content h-fit-content align-self-md-center\"\n (click)=\"onSubmit()\">{{'Search' |\n translate}}</button>\n </div>\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-0\">\n <div class=\"input-group date-selector m-1\">\n <input #dpFromDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpFromDate\"\n [value]=\"fromDate | formatDateNumberToDigits\"\n (input)=\"fromDate = validateInput(fromDate, dpFromDate.value)\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n <input name=\"datepicker\" class=\"form-control visually-hidden\" ngbDatepicker #datepicker=\"ngbDatepicker\"\n [autoClose]=\"'outside'\" (dateSelect)=\"onDateSelection($event)\" [displayMonths]=\"2\" [dayTemplate]=\"t\"\n outsideDays=\"hidden\" [startDate]=\"fromDate || calendar.getToday()\" [container]=\"'body'\" tabindex=\"-1\">\n <ng-template #t let-date let-focused=\"focused\">\n <span class=\"custom-day\" [class.focused]=\"focused\" [class.range]=\"isRange(date)\"\n [class.faded]=\"isHovered(date) || isInside(date)\" (mouseenter)=\"hoveredDate = date\"\n (mouseleave)=\"hoveredDate = null\">\n {{ date.day }}\n </span>\n </ng-template>\n <span class=\"ms-1 p-2\">{{'to' | translate}}</span>\n <div class=\"input-group date-selector m-1\">\n <input #dpToDate class=\"form-control\" placeholder=\"dd/MM/yyyy\" name=\"dpToDate\"\n [value]=\"toDate | formatDateNumberToDigits\" (input)=\"toDate = validateInput(toDate, dpToDate.value)\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"datepicker.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n </div>\n <div class=\"input-group search-button-container d-flex flex-row flex-nowrap p-0 m-1 justify-content-evenly\">\n <button\n class=\"btn btn-primary rounded-pill ms-1 w-25 w-md-fit-content h-md-fit-content align-self-md-center\"\n type=\"button\" (click)=\"onApply()\" *ngIf=\"!isDateFilterApplied || dateChanged\">\n {{'Apply' | translate}}\n </button>\n <span\n class=\"appliedText ms-1 py-2 align-self-md-center pb-md-0 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\n *ngIf=\"isDateFilterApplied && !dateChanged\">\n <span class=\"iconify\" [icIcon]=\"checkIcon\" width=\"15\" height=\"15\"></span>\n {{\"Applied\" | translate}}\n </span>\n <button\n class=\"btn btn-outline-primary rounded-pill w-25 mx-2 w-md-fit-content h-md-fit-content align-self-md-center\"\n type=\"button\" (click)=\"onClearDates()\">{{'Clear'\n |\n translate}}</button>\n <div\n class=\"change-position-button align-self-end pb-2 align-self-md-center mx-2 pb-md-0 flex-nowrap w-25 w-md-fit-content h-md-fit-content\">\n <input type=\"checkbox\" class=\"btn-check\" id=\"btn-check-outlined\" autocomplete=\"off\">\n <label class=\"link-primary cursor-pointer text-decoration-underline\" (click)=\"onChangePositionClick()\"\n for=\"btn-check-outlined\">{{\n (isChangePositionVisible ? \"Close\" : \"Move to\") | translate }}</label>\n </div>\n </div>\n </form>\n </div>\n </div>\n </nav>\n <lib-navigation-bar *ngIf=\"isVisible && isChangePositionVisible\"></lib-navigation-bar>\n </div>\n <div *ngIf=\"isVisitor && isVisible\">\n <div class=\"visitor-div\">\n <div class=\"logo-container\" data-testid=\"dropdown-menu-button\">\n <img class=\"img-logo\" alt=\"SmarterPlanLogo\" src=\"../assets/images/logos/logo-reserve.png\">\n </div>\n <div class=\"avatar-container-menu\">\n <div class=\"profile_pic dropdown-toggle cursor-pointer\" data-bs-toggle=\"dropdown\">\n <lib-avatar></lib-avatar>\n </div>\n <div class=\"dropdown-menu dropdown-menu-right\">\n <button class=\"dropdown-item\" (click)=\"localeService.modal()\">{{'Language' | translate}}</button>\n <button class=\"dropdown-item\" (click)=\"openSupportForm()\">{{\"Help\" | translate}}</button>\n <button data-testid=\"logout-auth-btn\" class=\"dropdown-item\" (click)=\"signOut()\">{{\"Logout\" |\n translate}}</button>\n </div>\n </div>\n </div>\n </div>\n</div>", styles: ["#menu-bar{position:sticky;top:0;z-index:200}.navbar{z-index:200}.navbar-brand{padding-top:5px;padding-bottom:5px;cursor:pointer}.navbar-brand img{height:70px}.profile_pic{border-radius:50%;height:45px;width:45px;margin:8px;border:.2px solid rgb(150,150,150)}.navbar-nav .profile-pic-container .dropdown-menu{position:absolute}.navbar.second-nav{z-index:199;background-color:var(--smarterplan-primary)}.profile_pic.dropdown-toggle:after{display:none}.navbar-light{border-bottom:1px solid var(--smarterplan-primary);background-color:#fff}.navbar form{width:100%;margin:0;padding:0}input,select{margin-right:15px}.select{background:transparent;border:none;color:#fff;margin:6px 20px 0;width:auto}button{padding:5px 10px}button:disabled,button[disabled]{color:#c04f4f}.navbar-toggler{margin-right:1em}.icon{height:40px;width:40px;color:var(--smarterplan-primary)}.search-button-container{width:auto;align-items:stretch;justify-items:start}.search-button-container .search-button{width:auto;border-radius:1rem!important}.visitor-div{background-color:var(--smarterplan-primary);height:60px;display:flex;justify-content:space-between}.profile_pic-container{margin-right:1em}.logo-container,.img-logo{height:100%}.change-position-button{margin-left:2rem}.change-position-button label,.change-position-button .btn-check:checked,.change-position-button .btn-check:focus,.change-position-button .btn-outline-primary,.change-position-button .btn{box-shadow:none!important;outline:0}.change-position-button label{border-radius:16px}.change-position-button .btn-check:checked+.btn{background-color:var(--smarterplan-primary);color:#fff!important}.filters-menu-block{width:auto}@media (min-width: 1200px){.navbar-brand img{height:100px}.profile_pic{height:60px;width:60px;margin:15px}}@media (min-width: 992px) and (max-width: 1199.98px){.navbar-brand img{height:80px}.profile_pic{height:50px;width:50px;margin:12px}}@media (min-width: 768px) and (max-width: 991.98px){.navbar-brand img{height:60px}.profile_pic{height:40px;width:40px;margin:10px}}@media (max-width: 767.98px){.navbar-brand img{height:50px}.profile_pic{height:30px;width:30px;margin:8px}.search-button-container,.filters-menu-block{width:100%}}.form-container{margin:.5rem 0}.navbar-collapse.show{display:flex;padding-bottom:.5rem}.hidden{width:0;margin:0;border:none;padding:0}.custom-day{text-align:center;padding:.185rem .25rem;display:inline-block;height:2rem;width:2rem}.custom-day.focused{background-color:#e6e6e6}.custom-day.range,.custom-day:hover{background-color:var(--smarterplan-primary-lighter);color:#fff}.custom-day.faded{background-color:var(--smarterplan-primary-transparent)}.calendar{height:100%}.appliedText,.appliedText span{color:var(--smarterplan-primary)}@media (max-width: 767px){.form-inline{flex-direction:column}}.hidden{opacity:0}.date-selector{flex-wrap:nowrap}.date-selector input{min-width:80px;margin:0}@media (min-width: 768px){.w-md-fit-content{width:fit-content!important}.h-md-content{height:fit-content!important}}\n"] }]
18620
+ }], ctorParameters: () => [{ type: i1.Router }, { type: LocaleService }, { type: BaseUserService }, { type: NavigatorService }, { type: SupportService }, { type: BaseVisibilityService }, { type: i1$2.NgbCalendar }, { type: i1$2.NgbDateParserFormatter }, { type: FilterService }, { type: AmplifyCacheService }], propDecorators: { cacheName: [{
18621
+ type: Input
18622
+ }] } });
18623
+
18624
+ /**
18625
+ * Gaussian splats, drawn by SuperSplat's viewer (PlayCanvas) in an iframe, as Matterport's showcase
18626
+ * is: the page built from projects/splat-viewer, which each app serves from assets/viewers/splat.
18627
+ *
18628
+ * The visit's Three.js scene stays underneath, unseen, holding the tags, their calibration and the
18629
+ * measurement, as it does for a model it draws itself; this hands the viewer what the scene holds,
18630
+ * and turns what is clicked in it into what a click in the scene does - through ViewerService, so
18631
+ * that whatever drives the scene (the add buttons, the calibration panel, the measuring tool, the
18632
+ * tag lists) drives this as well. Tags clicked come out of ViewerService.threeJsTagClicked$, as
18633
+ * clicks in the scene do.
18634
+ *
18635
+ * What it says of loading is for the app's own loading overlay; see the outputs.
18636
+ */
18637
+ class SplatViewerComponent {
18638
+ viewerService;
18639
+ host;
18640
+ sanitizer;
18641
+ translate;
18642
+ /** The model: the S3 key - or assets/ path - of a splat file, or of a Streamed SOG's lod-meta.json. */
18643
+ modelKey = null;
18644
+ /** Which of the model's axes is up, from its capture's placement; null for the viewer's own idea. */
18645
+ up = null;
18646
+ /** How far loading has got, from 0 to 1, or null when the size is not known. 0 when it starts. */
18647
+ loadProgress = new EventEmitter();
18648
+ loaded = new EventEmitter();
18649
+ loadFailed = new EventEmitter();
18650
+ /** Said whenever the mode changes, the viewer's own buttons included. */
18651
+ modeChange = new EventEmitter();
18652
+ frame;
18653
+ /**
18654
+ * The viewer's page, made once, in ngOnInit: a new object, even for the same address, would make
18655
+ * Angular set the iframe's src again, which loads the viewer afresh with nothing in it.
18656
+ */
18657
+ page;
18658
+ /** Whether the page has said it is ready; it says so again each time it starts over. */
18659
+ ready = false;
18660
+ /** The model handed to the page, so the same one is not downloaded twice. */
18661
+ loadedKey = null;
18662
+ /** Set by cancelLoad: the page, starting over empty, waits to be asked again (reload). */
18663
+ cancelled = false;
18664
+ /** Whether the page was last asked to take a click for a calibration. */
18665
+ pickingForCalibration = false;
18666
+ /** The calibration under way, as ViewerService last said. */
18667
+ alignment = null;
18668
+ /** Each segment's length of the measurement on the model, as ViewerService last said. */
18669
+ measureDistances = [];
18670
+ /** The last lod-meta.json handed to the page, as a link of this page's own. */
18671
+ streamedMeta = null;
18672
+ /** Pictures asked of the page, by the number they were asked with, until it answers. */
18673
+ snapshots = new Map();
18674
+ snapshotCount = 0;
18675
+ destroyed$ = new Subject();
18676
+ constructor(viewerService, host, sanitizer, translate) {
18677
+ this.viewerService = viewerService;
18678
+ this.host = host;
18679
+ this.sanitizer = sanitizer;
18680
+ this.translate = translate;
18681
+ }
18682
+ ngOnInit() {
18683
+ // In the app's language, which the viewer's controls speak, and in its colours, as this element's
18684
+ // styles take them from the app's - by now in the page, where they reach it.
18685
+ const style = getComputedStyle(this.host.nativeElement);
18686
+ const query = new URLSearchParams({
18687
+ lang: this.translate.currentLang || 'en',
18688
+ accent: style.color,
18689
+ background: style.backgroundColor,
18690
+ });
18691
+ this.page = this.sanitizer.bypassSecurityTrustResourceUrl(`assets/viewers/splat/index.html?${query}`);
18692
+ // The Three.js scene underneath has nothing to draw while this covers it, and the splat viewer
18693
+ // needs all the graphics card there is.
18694
+ this.viewerService.setThreeJsRenderingPaused(true);
18695
+ const on = (source, next) => source.pipe(takeUntil(this.destroyed$)).subscribe(next);
18696
+ on(this.viewerService.threeJsTagsChanged$, () => this.postTags());
18697
+ // Placing a tag starts from the add buttons, the same in every viewer; the page picks the spot
18698
+ // and says where ('picked').
18699
+ on(this.viewerService.threeJsPlacementChanged$, (placing) => this.post({ type: 'placing', on: placing }));
18700
+ on(this.viewerService.threeJsAlignmentProgress$, (progress) => {
18701
+ this.alignment = progress;
18702
+ this.postCalibration();
18703
+ });
18704
+ on(this.viewerService.threeJsAlignmentCancelled$, () => {
18705
+ this.alignment = null;
18706
+ this.postCalibration();
18707
+ });
18708
+ on(this.viewerService.threeJsMeasuringChanged$, (measuring) => this.post({ type: 'measuring', on: measuring }));
18709
+ on(this.viewerService.threeJsMeasurementProgress$, (progress) => {
18710
+ this.measureDistances = progress?.distances ?? [];
18711
+ this.postMeasurement(!!progress);
18712
+ });
18713
+ // A finished measurement stays drawn while its form is open; this is when it goes.
18714
+ on(this.viewerService.threeJsMeasurementCleared$, () => {
18715
+ this.measureDistances = [];
18716
+ this.postMeasurement(false);
18717
+ });
18718
+ // The camera sent to a tag, from a list: the page points it out.
18719
+ on(this.viewerService.threeJsTagFocused$, (id) => this.post({ type: 'goToTag', id }));
18720
+ }
18721
+ ngOnChanges(changes) {
18722
+ if (changes['modelKey'] && this.ready && !this.cancelled) {
18723
+ void this.load();
18724
+ }
18725
+ }
18726
+ ngOnDestroy() {
18727
+ this.destroyed$.next();
18728
+ this.destroyed$.complete();
18729
+ this.viewerService.setThreeJsRenderingPaused(false);
18730
+ if (this.streamedMeta) {
18731
+ URL.revokeObjectURL(this.streamedMeta);
18732
+ }
18733
+ this.snapshots.forEach((resolve) => resolve(null));
18734
+ this.snapshots.clear();
18735
+ }
18736
+ /** Stops the model loading; nothing is loaded again until reload(). */
18737
+ cancelLoad() {
18738
+ this.cancelled = true;
18739
+ this.loadedKey = null;
18740
+ this.post({ type: 'cancel-load' });
18741
+ }
18742
+ /** Loads the model again, after cancelLoad. */
18743
+ reload() {
18744
+ this.cancelled = false;
18745
+ this.loadedKey = null;
18746
+ if (this.ready) {
18747
+ void this.load();
18748
+ }
18749
+ }
18750
+ setMode(mode) {
18751
+ this.post({ type: 'mode', mode });
18752
+ }
18753
+ /**
18754
+ * The scene as it is on screen, with the measurement drawn on it and no tags, as a JPEG data URL;
18755
+ * null when there is no scene to take, or the page does not answer within ten seconds.
18756
+ */
18757
+ snapshot() {
18758
+ const id = ++this.snapshotCount;
18759
+ return new Promise((resolve) => {
18760
+ this.snapshots.set(id, resolve);
18761
+ this.post({ type: 'snapshot', id });
18762
+ setTimeout(() => {
18763
+ if (this.snapshots.delete(id)) {
18764
+ resolve(null);
18765
+ }
18766
+ }, 10000);
18767
+ });
18768
+ }
18769
+ /** What the page says: that it is ready, how loading goes, what was clicked in it. */
18770
+ onMessage(event) {
18771
+ // Only this component's page, served from this same origin.
18772
+ if (event.source !== this.frame?.nativeElement.contentWindow || event.origin !== window.location.origin) {
18773
+ return;
18774
+ }
18775
+ const message = event.data;
18776
+ const aligning = this.viewerService.isThreeJsAligningTags();
18777
+ switch (message?.type) {
18778
+ case 'ready':
18779
+ // A new page, with nothing loaded or armed in it: the first, or the viewer starting over
18780
+ // for the next model or after a cancelled load.
18781
+ this.ready = true;
18782
+ this.loadedKey = null;
18783
+ this.pickingForCalibration = false;
18784
+ if (!this.cancelled) {
18785
+ void this.load();
18786
+ }
18787
+ this.postTags();
18788
+ this.postCalibration();
18789
+ this.post({ type: 'measuring', on: this.viewerService.isThreeJsMeasuring() });
18790
+ this.postMeasurement(this.viewerService.getThreeJsMeasurePointsInModelFrame().length > 0);
18791
+ break;
18792
+ case 'progress':
18793
+ this.loadProgress.emit(message.fraction ?? null);
18794
+ break;
18795
+ case 'loaded':
18796
+ this.loaded.emit();
18797
+ break;
18798
+ case 'error':
18799
+ console.error('Splat viewer:', message.message);
18800
+ this.loadFailed.emit(String(message.message ?? ''));
18801
+ break;
18802
+ case 'mode':
18803
+ this.modeChange.emit(message.mode);
18804
+ break;
18805
+ case 'picked':
18806
+ if (aligning && this.alignment?.awaiting === 'point') {
18807
+ // Where the tag being matched really is, as a click on the model in the scene would say.
18808
+ if (!this.viewerService.matchThreeJsAlignmentTagAtModelPoint(message.position)) {
18809
+ this.viewerService.ignoreThreeJsAlignmentClick('point');
18810
+ }
18811
+ break;
18812
+ }
18813
+ // As a click on the model in the scene: the app opens the creation form from threeJsTagPlaced$.
18814
+ this.viewerService.placeThreeJsTagAtModelPoint(message.position, message.normal ?? null);
18815
+ break;
18816
+ case 'placing-cancelled':
18817
+ // Escape, as in the scene: it ends a measurement or a calibration as it ends placing a tag.
18818
+ if (this.viewerService.isThreeJsMeasuring()) {
18819
+ this.viewerService.action_toolbox_cancel_mesure();
18820
+ }
18821
+ else if (aligning) {
18822
+ this.viewerService.cancelThreeJsTagAlignment();
18823
+ }
18824
+ else {
18825
+ this.viewerService.cancelThreeJsTagPlacement();
18826
+ }
18827
+ break;
18828
+ case 'calibration-undo':
18829
+ // Ctrl+Z or Backspace in the page, as in the scene.
18830
+ this.viewerService.undoThreeJsAlignmentStep();
18831
+ break;
18832
+ case 'measure-point':
18833
+ this.viewerService.addThreeJsMeasurePointAtModelPoint(message.position);
18834
+ break;
18835
+ case 'tagClick':
18836
+ if (aligning) {
18837
+ // Calibrating: a tag clicked is the one to match, as in the scene, and opens nothing.
18838
+ if (this.alignment?.awaiting !== 'tag' || !this.viewerService.selectThreeJsAlignmentTag(message.id)) {
18839
+ this.viewerService.ignoreThreeJsAlignmentClick('tag');
18840
+ }
18841
+ break;
18842
+ }
18843
+ this.viewerService.clickThreeJsTag(message.id);
18844
+ break;
18845
+ case 'snapshot':
18846
+ this.snapshots.get(message.id)?.(message.image ?? null);
18847
+ this.snapshots.delete(message.id);
18848
+ break;
18849
+ case 'sign': {
18850
+ // A piece of the Streamed SOG open, by its name beside lod-meta.json.
18851
+ const key = this.loadedKey;
18852
+ const folder = key ? key.slice(0, key.lastIndexOf('/') + 1) : '';
18853
+ const file = String(message.file ?? '');
18854
+ const allowed = key && isStreamedSplatFile(key) && /^[\w.-]+$/.test(file);
18855
+ (allowed ? getSignedFile(folder + file) : Promise.resolve(null)).then((url) => {
18856
+ this.post({ type: 'signed', id: message.id, url });
18857
+ });
18858
+ break;
18859
+ }
18860
+ default:
18861
+ break;
18862
+ }
18863
+ }
18864
+ async load() {
18865
+ const key = this.modelKey;
18866
+ if (!key || key === this.loadedKey) {
18867
+ return;
18868
+ }
18869
+ this.loadedKey = key;
18870
+ this.loadProgress.emit(0);
18871
+ let url = key.startsWith('assets/') ? key : await getSignedFile(key);
18872
+ if (url && isStreamedSplatFile(key)) {
18873
+ url = await this.streamedEntry(url);
18874
+ }
18875
+ if (this.loadedKey !== key) {
18876
+ // Another model was asked for, or the load cancelled, while the link was being signed.
18877
+ return;
18878
+ }
18879
+ this.post({ type: 'load', url, fileName: key.split('/').pop(), up: this.up });
18880
+ }
18881
+ /**
18882
+ * The lod-meta.json of a Streamed SOG, with its pieces named so that the page asks for each of
18883
+ * them when it needs it ('sign').
18884
+ *
18885
+ * The pieces sit beside lod-meta.json in S3 and are named relative to it, which a signed link -
18886
+ * its signature in the query - does not survive. And they are fetched while the visit lasts, as the
18887
+ * camera reaches them, long after any link signed up front has run out.
18888
+ */
18889
+ async streamedEntry(signedMeta) {
18890
+ const meta = await (await fetch(signedMeta)).json();
18891
+ meta.filenames = (meta.filenames ?? []).map((name) => `https://splat.invalid/${name}`);
18892
+ if (this.streamedMeta) {
18893
+ URL.revokeObjectURL(this.streamedMeta);
18894
+ }
18895
+ this.streamedMeta = URL.createObjectURL(new Blob([JSON.stringify(meta)], { type: 'application/json' }));
18896
+ return this.streamedMeta;
18897
+ }
18898
+ postTags() {
18899
+ const { tags, alignment } = this.viewerService.getThreeJsTagSnapshot();
18900
+ // Tags placed elsewhere - in Matterport, in another model - are in that place's coordinates,
18901
+ // and only a calibration says where they are in this one. Without it they float off the model
18902
+ // and seem to slide as the camera moves: they are left out until it is calibrated. A
18903
+ // calibration under way, or its panel open, shows them all: they are what it matches.
18904
+ const all = this.viewerService.isThreeJsCalibrated() || this.viewerService.isThreeJsShowingCalibrationTags();
18905
+ const shown = all ? tags : tags.filter((tag) => tag.inModelFrame);
18906
+ this.post({
18907
+ type: 'tags',
18908
+ tags: shown.map(({ id, position, label, iconUrl, inModelFrame, normal }) => ({ id, position, label, iconUrl, inModelFrame, normal })),
18909
+ alignment,
18910
+ });
18911
+ }
18912
+ /**
18913
+ * The calibration under way, for the page to draw - the pins dropped, the tag being matched - and,
18914
+ * while the place of a tag is asked for, to take the click on the model that says where ('picked').
18915
+ */
18916
+ postCalibration() {
18917
+ const on = this.viewerService.isThreeJsAligningTags() && !!this.alignment;
18918
+ const awaiting = on ? this.alignment.awaiting : null;
18919
+ this.post({
18920
+ type: 'calibration',
18921
+ calibration: on
18922
+ ? {
18923
+ selected: awaiting === 'point' ? this.alignment.tagId ?? null : null,
18924
+ pairs: this.alignment.matched.map(({ tagId, target }) => ({ tagId, target })),
18925
+ }
18926
+ : null,
18927
+ });
18928
+ const picking = awaiting === 'point';
18929
+ // Only when it changes: placing a tag uses the same click, and is not to be switched off here.
18930
+ if (picking !== this.pickingForCalibration) {
18931
+ this.pickingForCalibration = picking;
18932
+ this.post({ type: 'placing', on: picking });
18933
+ }
18934
+ }
18935
+ /** The measurement for the page to draw - its points, each segment's length - or nothing. */
18936
+ postMeasurement(drawn) {
18937
+ this.post({
18938
+ type: 'measurement',
18939
+ measurement: drawn
18940
+ ? { points: this.viewerService.getThreeJsMeasurePointsInModelFrame(), distances: this.measureDistances }
18941
+ : null,
18942
+ });
18943
+ }
18944
+ post(command) {
18945
+ const page = this.frame?.nativeElement.contentWindow;
18946
+ if (page && this.ready) {
18947
+ page.postMessage(command, window.location.origin);
18948
+ }
18949
+ }
18950
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SplatViewerComponent, deps: [{ token: ViewerService }, { token: i0.ElementRef }, { token: i1$4.DomSanitizer }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
18951
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SplatViewerComponent, selector: "lib-splat-viewer", inputs: { modelKey: "modelKey", up: "up" }, outputs: { loadProgress: "loadProgress", loaded: "loaded", loadFailed: "loadFailed", modeChange: "modeChange" }, host: { listeners: { "window:message": "onMessage($event)" } }, viewQueries: [{ propertyName: "frame", first: true, predicate: ["frame"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: '<iframe #frame [src]="page" title="3D" allow="fullscreen; xr-spatial-tracking" allowfullscreen></iframe>', isInline: true, styles: [":host{display:block;color:var(--smarterplan-primary, rgb(83, 182, 187));background-color:var(--smarterplan-viewer-background, #e0f7ff)}iframe{display:block;width:100%;height:100%;border:0}\n"] });
18952
+ }
18953
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SplatViewerComponent, decorators: [{
18954
+ type: Component,
18955
+ args: [{ selector: 'lib-splat-viewer', template: '<iframe #frame [src]="page" title="3D" allow="fullscreen; xr-spatial-tracking" allowfullscreen></iframe>', styles: [":host{display:block;color:var(--smarterplan-primary, rgb(83, 182, 187));background-color:var(--smarterplan-viewer-background, #e0f7ff)}iframe{display:block;width:100%;height:100%;border:0}\n"] }]
18956
+ }], ctorParameters: () => [{ type: ViewerService }, { type: i0.ElementRef }, { type: i1$4.DomSanitizer }, { type: i1$1.TranslateService }], propDecorators: { modelKey: [{
18957
+ type: Input
18958
+ }], up: [{
17555
18959
  type: Input
18960
+ }], loadProgress: [{
18961
+ type: Output
18962
+ }], loaded: [{
18963
+ type: Output
18964
+ }], loadFailed: [{
18965
+ type: Output
18966
+ }], modeChange: [{
18967
+ type: Output
18968
+ }], frame: [{
18969
+ type: ViewChild,
18970
+ args: ['frame', { static: true }]
18971
+ }], onMessage: [{
18972
+ type: HostListener,
18973
+ args: ['window:message', ['$event']]
17556
18974
  }] } });
17557
18975
 
17558
18976
  class NgxSmarterplanCoreModule {
@@ -17581,11 +18999,13 @@ class NgxSmarterplanCoreModule {
17581
18999
  NavigationBarComponent,
17582
19000
  LoaderComponent,
17583
19001
  SupportModalComponent,
17584
- FormatDateNumberToDigitsPipe], imports: [FormsModule,
19002
+ FormatDateNumberToDigitsPipe,
19003
+ SplatViewerComponent], imports: [FormsModule,
17585
19004
  ReactiveFormsModule,
17586
19005
  CommonModule,
17587
19006
  RouterModule,
17588
- NgbModule, i1.TranslateModule], exports: [CsvExportComponent,
19007
+ NgbModule,
19008
+ IconModule, i1$1.TranslateModule], exports: [CsvExportComponent,
17589
19009
  SearchBarComponent,
17590
19010
  TimeDateToLocalStringPipe,
17591
19011
  SafeUrlPipe,
@@ -17595,12 +19015,14 @@ class NgxSmarterplanCoreModule {
17595
19015
  MenuBarComponent,
17596
19016
  LoaderComponent,
17597
19017
  SupportModalComponent,
17598
- AvatarComponent] });
19018
+ AvatarComponent,
19019
+ SplatViewerComponent] });
17599
19020
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgxSmarterplanCoreModule, imports: [FormsModule,
17600
19021
  ReactiveFormsModule,
17601
19022
  CommonModule,
17602
19023
  RouterModule,
17603
19024
  NgbModule,
19025
+ IconModule,
17604
19026
  TranslateModule.forChild({
17605
19027
  extend: true
17606
19028
  })] });
@@ -17622,7 +19044,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
17622
19044
  NavigationBarComponent,
17623
19045
  LoaderComponent,
17624
19046
  SupportModalComponent,
17625
- FormatDateNumberToDigitsPipe
19047
+ FormatDateNumberToDigitsPipe,
19048
+ SplatViewerComponent
17626
19049
  ],
17627
19050
  imports: [
17628
19051
  FormsModule,
@@ -17630,6 +19053,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
17630
19053
  CommonModule,
17631
19054
  RouterModule,
17632
19055
  NgbModule,
19056
+ IconModule,
17633
19057
  TranslateModule.forChild({
17634
19058
  extend: true
17635
19059
  })
@@ -17646,6 +19070,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
17646
19070
  LoaderComponent,
17647
19071
  SupportModalComponent,
17648
19072
  AvatarComponent,
19073
+ SplatViewerComponent,
17649
19074
  ]
17650
19075
  }]
17651
19076
  }] });
@@ -18302,7 +19727,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
18302
19727
  }] }, { type: NavigationService }, { type: ZoneService }, { type: ViewerService }, { type: LayerService }, { type: BaseUserService }, { type: PlanService }] });
18303
19728
 
18304
19729
  /** File extensions the Three.js viewer can load as a base model. */
18305
- const SUPPORTED_MODEL_EXTENSIONS = ['.glb', '.gltf'];
19730
+ // The splat formats open in the splat viewer, which runs in an iframe.
19731
+ const SUPPORTED_MODEL_EXTENSIONS = ['.glb', '.gltf', '.splat.ply', '.spz', '.splat', '.ksplat', '.sog', 'lod-meta.json'];
18306
19732
  class ThreeJsImportService {
18307
19733
  navigationService;
18308
19734
  zoneService;
@@ -18332,11 +19758,12 @@ class ThreeJsImportService {
18332
19758
  */
18333
19759
  validateModelKey(key) {
18334
19760
  if (!key || !key.trim()) {
18335
- return 'A 3D model file (.glb) is required for a Three.js visit.';
19761
+ return 'A 3D model file is required.';
18336
19762
  }
18337
19763
  const trimmed = key.trim();
18338
19764
  if (!SUPPORTED_MODEL_EXTENSIONS.some((extension) => trimmed.toLowerCase().endsWith(extension))) {
18339
- return `The 3D model must be a ${SUPPORTED_MODEL_EXTENSIONS.join(' or ')} file.`;
19765
+ const listed = SUPPORTED_MODEL_EXTENSIONS.slice(0, -1).join(', ');
19766
+ return `The 3D model must be a ${listed} or ${SUPPORTED_MODEL_EXTENSIONS[SUPPORTED_MODEL_EXTENSIONS.length - 1]} file.`;
18340
19767
  }
18341
19768
  // A full https:// URL is a signed link that expires; the stored value has to be the key itself
18342
19769
  // so a fresh URL can be signed on every visit.
@@ -18442,6 +19869,655 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
18442
19869
  }]
18443
19870
  }], ctorParameters: () => [{ type: NavigationService }, { type: ZoneService }, { type: LayerService }, { type: BaseUserService }, { type: PlanService }] });
18444
19871
 
19872
+ /**
19873
+ * Converts an .obj model, with its .mtl and textures, into the .glb the Three.js viewer loads - in
19874
+ * the browser, as the model is added, with nothing to install.
19875
+ *
19876
+ * It does what obj2gltf did in converte-modelo.sh, and the reason is the same. An .obj lists every
19877
+ * corner of every triangle; loaded as it is, a captured model's 2.6 million distinct vertices become
19878
+ * 12.6 million, one per corner. Here each position and texture coordinate pair becomes one vertex,
19879
+ * shared by every triangle that uses it, so what reaches the graphics card is the 2.6 million.
19880
+ *
19881
+ * Textures go in as they are, their bytes untouched: a JPEG re-encoded would lose quality and gain
19882
+ * nothing. Normals are only written when the .obj has them; without, the viewer works them out as
19883
+ * it loads the model. The axes are left as the .obj has them - the viewer finds which way is up.
19884
+ *
19885
+ * The .obj is read as a stream, so a file of hundreds of megabytes is never held whole.
19886
+ */
19887
+ /** Whether a set of files holds an .obj model to convert. */
19888
+ function hasObjModel(files) {
19889
+ return files.some((file) => /\.obj$/i.test(file.name));
19890
+ }
19891
+ /**
19892
+ * Converts the .obj among `files` into a .glb, using the .mtl and the images found with it.
19893
+ */
19894
+ async function convertObjToGlb(files, options = {}) {
19895
+ const objs = files.filter((file) => /\.obj$/i.test(file.name));
19896
+ if (objs.length !== 1) {
19897
+ throw new Error(objs.length === 0 ? 'No .obj file was given.' : 'Give one .obj file at a time.');
19898
+ }
19899
+ const obj = objs[0];
19900
+ const byName = new Map(files.map((file) => [baseName(file.name).toLowerCase(), file]));
19901
+ // The .obj's own reading is most of the time; the rest is shared out over what follows.
19902
+ const parsed = await readObj(obj.stream(), obj.size, {
19903
+ ...options,
19904
+ onProgress: (fraction) => options.onProgress?.(fraction * 0.85),
19905
+ });
19906
+ if (parsed.triangleCount === 0) {
19907
+ throw new Error(`${obj.name} has no faces.`);
19908
+ }
19909
+ // Materials: from the .mtl files the .obj names, or failing that any .mtl given with it.
19910
+ const named = parsed.materialLibraries.map((library) => byName.get(baseName(library).toLowerCase())).filter(Boolean);
19911
+ const libraries = named.length > 0 ? named : files.filter((file) => /\.mtl$/i.test(file.name));
19912
+ const materials = new Map();
19913
+ for (const library of libraries) {
19914
+ parseMtl(await library.text()).forEach((material) => materials.set(material.name, material));
19915
+ }
19916
+ await pause(options.signal);
19917
+ const breaks = new Breaks(options.signal, options.onProgress);
19918
+ const geometry = await indexGeometry(parsed, breaks);
19919
+ options.onProgress?.(0.95);
19920
+ await pause(options.signal);
19921
+ const missing = new Set();
19922
+ const glb = await writeGlb(parsed, geometry, materials, byName, missing, obj.name, breaks);
19923
+ options.onProgress?.(1);
19924
+ return {
19925
+ file: new File([glb], obj.name.replace(/\.obj$/i, '') + '.glb', { type: 'model/gltf-binary' }),
19926
+ vertices: geometry.vertexCount,
19927
+ triangles: parsed.triangleCount,
19928
+ materials: parsed.groups.length,
19929
+ missingTextures: [...missing],
19930
+ };
19931
+ }
19932
+ /** The file name without its folders, which is how an .mtl or a texture is looked up. */
19933
+ function baseName(path) {
19934
+ return path.trim().replace(/^"|"$/g, '').split(/[\\/]/).pop() ?? path;
19935
+ }
19936
+ /** Lets the page draw and answer for a moment, and stops here if the conversion was cancelled. */
19937
+ async function pause(signal) {
19938
+ if (signal?.aborted) {
19939
+ throw new DOMException('Model conversion cancelled', 'AbortError');
19940
+ }
19941
+ await new Promise((resolve) => setTimeout(resolve, 0));
19942
+ }
19943
+ /**
19944
+ * Stops a long loop now and then so the page can draw and answer clicks. Checked only every few
19945
+ * thousand turns of the loop: waiting on a promise every turn would cost more than the loop.
19946
+ */
19947
+ class Breaks {
19948
+ signal;
19949
+ onProgress;
19950
+ last = performance.now();
19951
+ constructor(signal, onProgress) {
19952
+ this.signal = signal;
19953
+ this.onProgress = onProgress;
19954
+ }
19955
+ /** Whether this turn of the loop should stop for a moment. Synchronous: it is asked every turn. */
19956
+ due(turn) {
19957
+ return (turn & 0x3fff) === 0 && performance.now() - this.last > 40;
19958
+ }
19959
+ /** Stops for a moment, reporting how far the conversion has got. */
19960
+ async take(fraction) {
19961
+ this.onProgress?.(fraction);
19962
+ await pause(this.signal);
19963
+ this.last = performance.now();
19964
+ }
19965
+ }
19966
+ /** A growable typed array: an .obj does not say up front how many of anything it holds. */
19967
+ class Growable {
19968
+ data;
19969
+ length = 0;
19970
+ constructor(data) {
19971
+ this.data = data;
19972
+ }
19973
+ push(value) {
19974
+ if (this.length === this.data.length) {
19975
+ const bigger = new this.data.constructor(this.data.length * 2);
19976
+ bigger.set(this.data);
19977
+ this.data = bigger;
19978
+ }
19979
+ this.data[this.length] = value;
19980
+ this.length += 1;
19981
+ }
19982
+ view() {
19983
+ return this.data.subarray(0, this.length);
19984
+ }
19985
+ }
19986
+ /**
19987
+ * Reads an .obj from a stream of its bytes: positions, texture coordinates, normals, and triangles
19988
+ * grouped by material. Polygons are split into triangles; negative indices, counting back from the
19989
+ * end, are resolved; anything else (objects, groups, smoothing) is skipped.
19990
+ */
19991
+ async function readObj(stream, size, options = {}) {
19992
+ const parser = new ObjParser();
19993
+ const reader = stream.getReader();
19994
+ let read = 0;
19995
+ let lastBreak = performance.now();
19996
+ try {
19997
+ for (;;) {
19998
+ if (options.signal?.aborted) {
19999
+ throw new DOMException('Model conversion cancelled', 'AbortError');
20000
+ }
20001
+ const { done, value } = await reader.read();
20002
+ if (done) {
20003
+ break;
20004
+ }
20005
+ parser.push(value);
20006
+ read += value.length;
20007
+ if (performance.now() - lastBreak > 40) {
20008
+ options.onProgress?.(size > 0 ? Math.min(read / size, 1) : 0);
20009
+ await new Promise((resolve) => setTimeout(resolve, 0));
20010
+ lastBreak = performance.now();
20011
+ }
20012
+ }
20013
+ }
20014
+ finally {
20015
+ reader.cancel().catch(() => undefined);
20016
+ }
20017
+ parser.end();
20018
+ options.onProgress?.(1);
20019
+ return parser.result();
20020
+ }
20021
+ /**
20022
+ * Line by line, straight from the bytes. Building a string for each of the millions of lines of a
20023
+ * captured model would be most of the work; this reads the numbers off the bytes instead.
20024
+ */
20025
+ class ObjParser {
20026
+ positions = new Growable(new Float64Array(1 << 16));
20027
+ uvs = new Growable(new Float64Array(1 << 16));
20028
+ normals = new Growable(new Float64Array(1 << 16));
20029
+ groups = [];
20030
+ groupByMaterial = new Map();
20031
+ current = null;
20032
+ materialLibraries = [];
20033
+ triangleCount = 0;
20034
+ /** The bytes of the line being read, kept across chunks. */
20035
+ line = new Uint8Array(256);
20036
+ lineLength = 0;
20037
+ // The corners of the face being read, as position/texture/normal indices.
20038
+ face = new Int32Array(3 * 64);
20039
+ push(bytes) {
20040
+ for (let index = 0; index < bytes.length; index += 1) {
20041
+ const byte = bytes[index];
20042
+ if (byte === 10) {
20043
+ this.readLine();
20044
+ this.lineLength = 0;
20045
+ }
20046
+ else {
20047
+ if (this.lineLength === this.line.length) {
20048
+ const longer = new Uint8Array(this.line.length * 2);
20049
+ longer.set(this.line);
20050
+ this.line = longer;
20051
+ }
20052
+ this.line[this.lineLength] = byte;
20053
+ this.lineLength += 1;
20054
+ }
20055
+ }
20056
+ }
20057
+ end() {
20058
+ this.readLine();
20059
+ this.lineLength = 0;
20060
+ }
20061
+ result() {
20062
+ return {
20063
+ positions: this.positions.view(),
20064
+ uvs: this.uvs.view(),
20065
+ normals: this.normals.view(),
20066
+ groups: this.groups.filter((group) => group.corners.length > 0),
20067
+ materialLibraries: this.materialLibraries,
20068
+ triangleCount: this.triangleCount,
20069
+ };
20070
+ }
20071
+ readLine() {
20072
+ const line = this.line;
20073
+ const length = this.lineLength;
20074
+ let at = 0;
20075
+ while (at < length && (line[at] === 32 || line[at] === 9)) {
20076
+ at += 1;
20077
+ }
20078
+ if (at + 1 >= length) {
20079
+ return;
20080
+ }
20081
+ const first = line[at];
20082
+ const second = line[at + 1];
20083
+ if (first === 118 && (second === 32 || second === 9)) {
20084
+ // v x y z
20085
+ this.readNumbers(at + 2, 3, this.positions);
20086
+ }
20087
+ else if (first === 118 && second === 116) {
20088
+ // vt u v
20089
+ this.readNumbers(at + 3, 2, this.uvs);
20090
+ }
20091
+ else if (first === 118 && second === 110) {
20092
+ // vn x y z
20093
+ this.readNumbers(at + 3, 3, this.normals);
20094
+ }
20095
+ else if (first === 102 && (second === 32 || second === 9)) {
20096
+ this.readFace(at + 2);
20097
+ }
20098
+ else if (this.startsWith(at, 'usemtl')) {
20099
+ this.useMaterial(this.restOfLine(at + 6));
20100
+ }
20101
+ else if (this.startsWith(at, 'mtllib')) {
20102
+ this.materialLibraries.push(...this.restOfLine(at + 6).split(/\s+(?=\S+\.mtl\b)/i).filter(Boolean));
20103
+ }
20104
+ }
20105
+ startsWith(at, word) {
20106
+ for (let index = 0; index < word.length; index += 1) {
20107
+ if (this.line[at + index] !== word.charCodeAt(index)) {
20108
+ return false;
20109
+ }
20110
+ }
20111
+ const after = this.line[at + word.length];
20112
+ return after === 32 || after === 9;
20113
+ }
20114
+ restOfLine(at) {
20115
+ let end = this.lineLength;
20116
+ while (end > at && (this.line[end - 1] === 13 || this.line[end - 1] === 32 || this.line[end - 1] === 9)) {
20117
+ end -= 1;
20118
+ }
20119
+ return new TextDecoder().decode(this.line.subarray(at, end)).trim();
20120
+ }
20121
+ useMaterial(name) {
20122
+ let group = this.groupByMaterial.get(name);
20123
+ if (!group) {
20124
+ group = { material: name, corners: new Growable(new Int32Array(1 << 12)) };
20125
+ this.groupByMaterial.set(name, group);
20126
+ this.groups.push(group);
20127
+ }
20128
+ this.current = group;
20129
+ }
20130
+ /** Reads up to `count` numbers from `at` onwards into `target`, padding a short line with 0. */
20131
+ readNumbers(at, count, target) {
20132
+ let read = 0;
20133
+ let position = at;
20134
+ while (read < count) {
20135
+ const [value, next] = this.readNumber(position);
20136
+ if (next === position) {
20137
+ break;
20138
+ }
20139
+ target.push(value);
20140
+ read += 1;
20141
+ position = next;
20142
+ }
20143
+ for (; read < count; read += 1) {
20144
+ target.push(0);
20145
+ }
20146
+ }
20147
+ /** Reads one number starting at or after `at`; returns it and where it ended. */
20148
+ readNumber(at) {
20149
+ const line = this.line;
20150
+ const length = this.lineLength;
20151
+ let index = at;
20152
+ while (index < length && (line[index] === 32 || line[index] === 9 || line[index] === 13)) {
20153
+ index += 1;
20154
+ }
20155
+ const start = index;
20156
+ let negative = false;
20157
+ if (line[index] === 45 || line[index] === 43) {
20158
+ negative = line[index] === 45;
20159
+ index += 1;
20160
+ }
20161
+ let whole = 0;
20162
+ let fraction = 0;
20163
+ let scale = 1;
20164
+ let digits = 0;
20165
+ while (index < length && line[index] >= 48 && line[index] <= 57) {
20166
+ whole = whole * 10 + (line[index] - 48);
20167
+ index += 1;
20168
+ digits += 1;
20169
+ }
20170
+ if (line[index] === 46) {
20171
+ index += 1;
20172
+ while (index < length && line[index] >= 48 && line[index] <= 57) {
20173
+ fraction = fraction * 10 + (line[index] - 48);
20174
+ scale *= 10;
20175
+ index += 1;
20176
+ digits += 1;
20177
+ }
20178
+ }
20179
+ if (digits === 0) {
20180
+ return [0, at];
20181
+ }
20182
+ let value = whole + fraction / scale;
20183
+ if (line[index] === 101 || line[index] === 69) {
20184
+ index += 1;
20185
+ let negativeExponent = false;
20186
+ if (line[index] === 45 || line[index] === 43) {
20187
+ negativeExponent = line[index] === 45;
20188
+ index += 1;
20189
+ }
20190
+ let exponent = 0;
20191
+ while (index < length && line[index] >= 48 && line[index] <= 57) {
20192
+ exponent = exponent * 10 + (line[index] - 48);
20193
+ index += 1;
20194
+ }
20195
+ value *= 10 ** (negativeExponent ? -exponent : exponent);
20196
+ }
20197
+ return [negative ? -value : value, index === start ? at : index];
20198
+ }
20199
+ /** f v/vt/vn ... - any of the three forms, any number of corners, split into a fan. */
20200
+ readFace(at) {
20201
+ const line = this.line;
20202
+ const length = this.lineLength;
20203
+ let corners = 0;
20204
+ let index = at;
20205
+ while (index < length) {
20206
+ while (index < length && (line[index] === 32 || line[index] === 9 || line[index] === 13)) {
20207
+ index += 1;
20208
+ }
20209
+ if (index >= length) {
20210
+ break;
20211
+ }
20212
+ // One corner: up to three integers separated by '/', any of the last two possibly empty.
20213
+ const values = [0, 0, 0];
20214
+ for (let slot = 0; slot < 3; slot += 1) {
20215
+ let negative = false;
20216
+ if (line[index] === 45) {
20217
+ negative = true;
20218
+ index += 1;
20219
+ }
20220
+ let value = 0;
20221
+ let digits = 0;
20222
+ while (index < length && line[index] >= 48 && line[index] <= 57) {
20223
+ value = value * 10 + (line[index] - 48);
20224
+ index += 1;
20225
+ digits += 1;
20226
+ }
20227
+ values[slot] = digits === 0 ? 0 : negative ? -value : value;
20228
+ if (line[index] !== 47) {
20229
+ break;
20230
+ }
20231
+ index += 1;
20232
+ }
20233
+ if (corners < 64 && values[0] !== 0) {
20234
+ // To zero-based indices, counting a negative one back from what has been read so far; -1
20235
+ // means "none" for the texture and normal.
20236
+ this.face[corners * 3] = this.resolve(values[0], this.positions.length / 3);
20237
+ this.face[corners * 3 + 1] = values[1] === 0 ? -1 : this.resolve(values[1], this.uvs.length / 2);
20238
+ this.face[corners * 3 + 2] = values[2] === 0 ? -1 : this.resolve(values[2], this.normals.length / 3);
20239
+ corners += 1;
20240
+ }
20241
+ // Skip to the next separator, past anything unexpected in this token.
20242
+ while (index < length && line[index] !== 32 && line[index] !== 9) {
20243
+ index += 1;
20244
+ }
20245
+ }
20246
+ if (corners < 3) {
20247
+ return;
20248
+ }
20249
+ if (!this.current) {
20250
+ this.useMaterial(null);
20251
+ }
20252
+ const target = this.current.corners;
20253
+ for (let corner = 1; corner + 1 < corners; corner += 1) {
20254
+ for (const which of [0, corner, corner + 1]) {
20255
+ target.push(this.face[which * 3]);
20256
+ target.push(this.face[which * 3 + 1]);
20257
+ target.push(this.face[which * 3 + 2]);
20258
+ }
20259
+ this.triangleCount += 1;
20260
+ }
20261
+ }
20262
+ resolve(index, count) {
20263
+ return index > 0 ? index - 1 : count + index;
20264
+ }
20265
+ }
20266
+ /**
20267
+ * Turns corners into shared vertices: one vertex per distinct position, texture and normal triple.
20268
+ *
20269
+ * Corners are grouped by position first, and the few corners that share a position are compared
20270
+ * with one another. That needs no table of every triple ever seen - which, over millions of
20271
+ * corners, would cost far more memory than the model itself.
20272
+ */
20273
+ async function indexGeometry(parsed, breaks) {
20274
+ const positionCount = parsed.positions.length / 3;
20275
+ const groups = parsed.groups.map((group) => group.corners.view());
20276
+ const cornerCount = groups.reduce((sum, corners) => sum + corners.length / 3, 0);
20277
+ // Every corner, numbered across all groups, listed under its position.
20278
+ const perPosition = new Int32Array(positionCount + 1);
20279
+ groups.forEach((corners) => {
20280
+ for (let at = 0; at < corners.length; at += 3) {
20281
+ perPosition[corners[at] + 1] += 1;
20282
+ }
20283
+ });
20284
+ for (let position = 0; position < positionCount; position += 1) {
20285
+ perPosition[position + 1] += perPosition[position];
20286
+ }
20287
+ const filled = perPosition.slice(0, positionCount);
20288
+ const byPosition = new Int32Array(cornerCount);
20289
+ const cornerStart = [];
20290
+ let numbered = 0;
20291
+ groups.forEach((corners) => {
20292
+ cornerStart.push(numbered);
20293
+ for (let at = 0; at < corners.length; at += 3) {
20294
+ byPosition[filled[corners[at]]] = numbered;
20295
+ filled[corners[at]] += 1;
20296
+ numbered += 1;
20297
+ }
20298
+ });
20299
+ // Which group each corner is in, so its triple can be read back where it already is rather than
20300
+ // from a copy of every corner.
20301
+ const groupOf = new Uint16Array(cornerCount);
20302
+ groups.forEach((corners, group) => groupOf.fill(group, cornerStart[group], cornerStart[group] + corners.length / 3));
20303
+ const vertexOfCorner = new Uint32Array(cornerCount);
20304
+ const sources = new Growable(new Int32Array(Math.max(16, positionCount * 3 * 1.3) | 0));
20305
+ let vertexCount = 0;
20306
+ for (let position = 0; position < positionCount; position += 1) {
20307
+ if (breaks.due(position)) {
20308
+ await breaks.take(0.85 + 0.07 * (position / positionCount));
20309
+ }
20310
+ const first = vertexCount;
20311
+ for (let at = perPosition[position]; at < perPosition[position + 1]; at += 1) {
20312
+ const corner = byPosition[at];
20313
+ const group = groupOf[corner];
20314
+ const triple = (corner - cornerStart[group]) * 3;
20315
+ const uv = groups[group][triple + 1];
20316
+ const normal = groups[group][triple + 2];
20317
+ let found = -1;
20318
+ for (let vertex = first; vertex < vertexCount; vertex += 1) {
20319
+ if (sources.data[vertex * 3 + 1] === uv && sources.data[vertex * 3 + 2] === normal) {
20320
+ found = vertex;
20321
+ break;
20322
+ }
20323
+ }
20324
+ if (found < 0) {
20325
+ found = vertexCount;
20326
+ sources.push(position);
20327
+ sources.push(uv);
20328
+ sources.push(normal);
20329
+ vertexCount += 1;
20330
+ }
20331
+ vertexOfCorner[corner] = found;
20332
+ }
20333
+ }
20334
+ return {
20335
+ vertexCount,
20336
+ sources: sources.view(),
20337
+ indices: groups.map((corners, group) => vertexOfCorner.slice(cornerStart[group], cornerStart[group] + corners.length / 3)),
20338
+ };
20339
+ }
20340
+ /** The parts of an .mtl that matter here: the colour, the opacity and the colour texture. */
20341
+ function parseMtl(text) {
20342
+ const materials = [];
20343
+ let current = null;
20344
+ text.split(/\r?\n/).forEach((raw) => {
20345
+ const line = raw.trim();
20346
+ const [keyword, ...rest] = line.split(/\s+/);
20347
+ if (keyword === 'newmtl') {
20348
+ current = { name: rest.join(' '), colour: [1, 1, 1], opacity: 1, texture: null };
20349
+ materials.push(current);
20350
+ }
20351
+ else if (!current) {
20352
+ return;
20353
+ }
20354
+ else if (keyword === 'Kd' && rest.length >= 3) {
20355
+ current.colour = [Number(rest[0]), Number(rest[1]), Number(rest[2])];
20356
+ }
20357
+ else if (keyword === 'd' && rest.length >= 1) {
20358
+ current.opacity = Number(rest[0]);
20359
+ }
20360
+ else if (keyword === 'map_Kd' && rest.length >= 1) {
20361
+ // Options (-s 1 1 1, -o ..., -bm 0.5) come before the file name, which is what is left.
20362
+ current.texture = rest[rest.length - 1];
20363
+ }
20364
+ });
20365
+ return materials;
20366
+ }
20367
+ /**
20368
+ * Writes the .glb. The binary part is assembled from the arrays and the texture files as they are,
20369
+ * into a Blob - so the textures are never read into memory, nor the whole file built in one buffer.
20370
+ */
20371
+ async function writeGlb(parsed, geometry, materials, files, missing, name, breaks) {
20372
+ const { vertexCount, sources } = geometry;
20373
+ const hasUv = parsed.uvs.length > 0 && hasAny(sources, 1);
20374
+ const hasNormals = parsed.normals.length > 0 && hasAny(sources, 2);
20375
+ const positions = new Float32Array(vertexCount * 3);
20376
+ const min = [Infinity, Infinity, Infinity];
20377
+ const max = [-Infinity, -Infinity, -Infinity];
20378
+ const uvs = hasUv ? new Float32Array(vertexCount * 2) : null;
20379
+ const normals = hasNormals ? new Float32Array(vertexCount * 3) : null;
20380
+ for (let vertex = 0; vertex < vertexCount; vertex += 1) {
20381
+ if (breaks.due(vertex)) {
20382
+ await breaks.take(0.95 + 0.04 * (vertex / vertexCount));
20383
+ }
20384
+ const position = sources[vertex * 3];
20385
+ for (let axis = 0; axis < 3; axis += 1) {
20386
+ const value = parsed.positions[position * 3 + axis];
20387
+ positions[vertex * 3 + axis] = value;
20388
+ min[axis] = Math.min(min[axis], Math.fround(value));
20389
+ max[axis] = Math.max(max[axis], Math.fround(value));
20390
+ }
20391
+ if (uvs) {
20392
+ const uv = sources[vertex * 3 + 1];
20393
+ // An .obj counts v up from the bottom of the image, glTF down from the top.
20394
+ uvs[vertex * 2] = uv >= 0 ? parsed.uvs[uv * 2] : 0;
20395
+ uvs[vertex * 2 + 1] = uv >= 0 ? 1 - parsed.uvs[uv * 2 + 1] : 0;
20396
+ }
20397
+ if (normals) {
20398
+ const normal = sources[vertex * 3 + 2];
20399
+ for (let axis = 0; axis < 3; axis += 1) {
20400
+ normals[vertex * 3 + axis] = normal >= 0 ? parsed.normals[normal * 3 + axis] : 0;
20401
+ }
20402
+ }
20403
+ }
20404
+ const parts = [];
20405
+ const bufferViews = [];
20406
+ let byteLength = 0;
20407
+ const addView = (part, size, target) => {
20408
+ const padding = (4 - (byteLength % 4)) % 4;
20409
+ if (padding) {
20410
+ parts.push(new Uint8Array(padding));
20411
+ byteLength += padding;
20412
+ }
20413
+ parts.push(part);
20414
+ bufferViews.push({ buffer: 0, byteOffset: byteLength, byteLength: size, ...(target ? { target } : {}) });
20415
+ byteLength += size;
20416
+ return bufferViews.length - 1;
20417
+ };
20418
+ const accessors = [];
20419
+ const addAccessor = (data, type, count, extra = {}, target) => {
20420
+ const view = addView(data, data.byteLength, target);
20421
+ accessors.push({ bufferView: view, componentType: data instanceof Float32Array ? 5126 : 5125, count, type, ...extra });
20422
+ return accessors.length - 1;
20423
+ };
20424
+ const attributes = {
20425
+ POSITION: addAccessor(positions, 'VEC3', vertexCount, { min, max }, 34962),
20426
+ };
20427
+ if (normals) {
20428
+ attributes['NORMAL'] = addAccessor(normals, 'VEC3', vertexCount, {}, 34962);
20429
+ }
20430
+ if (uvs) {
20431
+ attributes['TEXCOORD_0'] = addAccessor(uvs, 'VEC2', vertexCount, {}, 34962);
20432
+ }
20433
+ // Materials, each texture file stored once however many materials use it.
20434
+ const images = [];
20435
+ const textures = [];
20436
+ const textureOf = new Map();
20437
+ const textureIndex = (fileName) => {
20438
+ const key = baseName(fileName).toLowerCase();
20439
+ if (textureOf.has(key)) {
20440
+ return textureOf.get(key);
20441
+ }
20442
+ const file = files.get(key);
20443
+ if (!file) {
20444
+ missing.add(baseName(fileName));
20445
+ return null;
20446
+ }
20447
+ const mimeType = /\.png$/i.test(file.name) ? 'image/png' : 'image/jpeg';
20448
+ images.push({ bufferView: addView(file, file.size), mimeType, name: baseName(file.name) });
20449
+ textures.push({ source: images.length - 1, sampler: 0 });
20450
+ textureOf.set(key, textures.length - 1);
20451
+ return textures.length - 1;
20452
+ };
20453
+ const gltfMaterials = [];
20454
+ const primitives = parsed.groups.map((group, index) => {
20455
+ const material = group.material !== null ? materials.get(group.material) : undefined;
20456
+ const texture = material?.texture ? textureIndex(material.texture) : null;
20457
+ gltfMaterials.push({
20458
+ name: group.material ?? 'default',
20459
+ pbrMetallicRoughness: {
20460
+ ...(texture !== null ? { baseColorTexture: { index: texture } } : {}),
20461
+ baseColorFactor: texture !== null ? [1, 1, 1, material?.opacity ?? 1] : [...(material?.colour ?? [0.8, 0.8, 0.8]), material?.opacity ?? 1],
20462
+ metallicFactor: 0,
20463
+ roughnessFactor: 1,
20464
+ },
20465
+ ...(material && material.opacity < 1 ? { alphaMode: 'BLEND' } : {}),
20466
+ });
20467
+ const triangles = geometry.indices[index];
20468
+ return {
20469
+ attributes,
20470
+ indices: addAccessor(triangles, 'SCALAR', triangles.length, {}, 34963),
20471
+ material: gltfMaterials.length - 1,
20472
+ };
20473
+ });
20474
+ const json = {
20475
+ asset: { version: '2.0', generator: 'SmarterPlan obj-to-glb' },
20476
+ scene: 0,
20477
+ scenes: [{ nodes: [0] }],
20478
+ nodes: [{ mesh: 0, name: name.replace(/\.obj$/i, '') }],
20479
+ meshes: [{ primitives }],
20480
+ materials: gltfMaterials,
20481
+ ...(textures.length ? {
20482
+ textures,
20483
+ images,
20484
+ // Linear filtering with mipmaps, repeating: what a captured model's atlas expects.
20485
+ samplers: [{ magFilter: 9729, minFilter: 9987, wrapS: 10497, wrapT: 10497 }],
20486
+ } : {}),
20487
+ accessors,
20488
+ bufferViews,
20489
+ buffers: [{ byteLength }],
20490
+ };
20491
+ let jsonBytes = new TextEncoder().encode(JSON.stringify(json));
20492
+ const jsonPadding = (4 - (jsonBytes.length % 4)) % 4;
20493
+ if (jsonPadding) {
20494
+ const padded = new Uint8Array(jsonBytes.length + jsonPadding).fill(32);
20495
+ padded.set(jsonBytes);
20496
+ jsonBytes = padded;
20497
+ }
20498
+ const binPadding = (4 - (byteLength % 4)) % 4;
20499
+ const binLength = byteLength + binPadding;
20500
+ const header = new DataView(new ArrayBuffer(12 + 8));
20501
+ header.setUint32(0, 0x46546c67, true); // "glTF"
20502
+ header.setUint32(4, 2, true);
20503
+ header.setUint32(8, 12 + 8 + jsonBytes.length + 8 + binLength, true);
20504
+ header.setUint32(12, jsonBytes.length, true);
20505
+ header.setUint32(16, 0x4e4f534a, true); // "JSON"
20506
+ const binHeader = new DataView(new ArrayBuffer(8));
20507
+ binHeader.setUint32(0, binLength, true);
20508
+ binHeader.setUint32(4, 0x004e4942, true); // "BIN"
20509
+ return new Blob([header, jsonBytes, binHeader, ...parts, new Uint8Array(binPadding)]);
20510
+ }
20511
+ /** Whether any vertex uses the given slot of its source triple (texture or normal). */
20512
+ function hasAny(sources, slot) {
20513
+ for (let at = slot; at < sources.length; at += 3) {
20514
+ if (sources[at] >= 0) {
20515
+ return true;
20516
+ }
20517
+ }
20518
+ return false;
20519
+ }
20520
+
18445
20521
  // matterport-transform.util.ts
18446
20522
  /**
18447
20523
  * Computes the rigid transform (Y-axis rotation + translation) between two
@@ -21276,13 +23352,13 @@ class MatterportTagCopyService {
21276
23352
  this.setStepLog('done', this.translate.instant('matterportCopy.recalibrateSummary', result));
21277
23353
  return result;
21278
23354
  }
21279
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportTagCopyService, deps: [{ token: NavigationService }, { token: BaseUserService }, { token: PoiService }, { token: TicketsService }, { token: EquipmentService }, { token: Object3DService }, { token: FeatureService }, { token: MeasurementService }, { token: CommentService }, { token: HashtagService }, { token: MissionService }, { token: OperationService }, { token: DomainService }, { token: i1.TranslateService }, { token: ZoneService }], target: i0.ɵɵFactoryTarget.Injectable });
23355
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportTagCopyService, deps: [{ token: NavigationService }, { token: BaseUserService }, { token: PoiService }, { token: TicketsService }, { token: EquipmentService }, { token: Object3DService }, { token: FeatureService }, { token: MeasurementService }, { token: CommentService }, { token: HashtagService }, { token: MissionService }, { token: OperationService }, { token: DomainService }, { token: i1$1.TranslateService }, { token: ZoneService }], target: i0.ɵɵFactoryTarget.Injectable });
21280
23356
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportTagCopyService, providedIn: 'root' });
21281
23357
  }
21282
23358
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MatterportTagCopyService, decorators: [{
21283
23359
  type: Injectable,
21284
23360
  args: [{ providedIn: 'root' }]
21285
- }], ctorParameters: () => [{ type: NavigationService }, { type: BaseUserService }, { type: PoiService }, { type: TicketsService }, { type: EquipmentService }, { type: Object3DService }, { type: FeatureService }, { type: MeasurementService }, { type: CommentService }, { type: HashtagService }, { type: MissionService }, { type: OperationService }, { type: DomainService }, { type: i1.TranslateService }, { type: ZoneService }] });
23361
+ }], ctorParameters: () => [{ type: NavigationService }, { type: BaseUserService }, { type: PoiService }, { type: TicketsService }, { type: EquipmentService }, { type: Object3DService }, { type: FeatureService }, { type: MeasurementService }, { type: CommentService }, { type: HashtagService }, { type: MissionService }, { type: OperationService }, { type: DomainService }, { type: i1$1.TranslateService }, { type: ZoneService }] });
21286
23362
 
21287
23363
  /* eslint-disable class-methods-use-this */
21288
23364
  class OrganisationService {
@@ -21416,5 +23492,5 @@ function floatValidator() {
21416
23492
  * Generated bundle index. Do not edit.
21417
23493
  */
21418
23494
 
21419
- export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, HashtagFromIdPipe, HashtagService, InterventionService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MATTERPORT_SDK_KEY, MatterportImportService, MatterportService, MatterportTagCopyService, MatterportViewType, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, StatusEquipment, SupportModalComponent, SupportService, SweepLocatorService, THREEJS_MODEL_UP_OPTIONS, TagAction, TemplateService, ThreeJsImportService, ThreeJsService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, applyRigidTransformToDirection, applyRigidTransformToPoint, applyRigidTransformToYRotationDeg, arraysContainSameElements, checkElementById, computeRigidTransform, convertTimestampToLocalZone, copyFileInS3, copyFileInS3ViaDownload, dateHasExpired, dateTimeToLocalString, deleteFromS3, distance, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getCurrentLang, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getThreeJsPoiOrigin, getVisitUrl, isEmptyObject, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, parseThreeJsPlacement, poiTypeToString, pointToString, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, solveThreeJsAlignment, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, textValidator, translateDatePeriod, uploadBase64Image, uploadBase64ImageWithRetry, uploadFileToS3, uploadFileToS3WithProgress, uploadJsonToS3, validEmail, wait, waitUntil };
23495
+ export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, GAUSSIAN_SPLAT_PLY_SUFFIX, HashtagFromIdPipe, HashtagService, InterventionService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MATTERPORT_SDK_KEY, MatterportImportService, MatterportService, MatterportTagCopyService, MatterportViewType, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PLAN_ICONS, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, SplatViewerComponent, StatusEquipment, SupportModalComponent, SupportService, SweepLocatorService, THREEJS_MODEL_UP_OPTIONS, TagAction, TemplateService, ThreeJsImportService, ThreeJsService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, VIEWER_BACKGROUND, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, applyRigidTransformToDirection, applyRigidTransformToPoint, applyRigidTransformToYRotationDeg, arraysContainSameElements, checkElementById, computeRigidTransform, convertObjToGlb, convertTimestampToLocalZone, copyFileInS3, copyFileInS3ViaDownload, dateHasExpired, dateTimeToLocalString, deleteFromS3, distance, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getCurrentLang, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getThreeJsPoiOrigin, getVisitUrl, hasObjModel, iconData, iconToDataUrl, isEmptyObject, isGaussianSplatFile, isGaussianSplatPly, isStreamedSplatFile, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, parseThreeJsPlacement, poiTypeToString, pointToString, readObj, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, solveThreeJsAlignment, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, svgToDataUrl, textValidator, translateDatePeriod, uploadBase64Image, uploadBase64ImageWithRetry, uploadFileToS3, uploadFileToS3WithProgress, uploadJsonToS3, validEmail, wait, waitUntil };
21420
23496
  //# sourceMappingURL=smarterplan-ngx-smarterplan-core.mjs.map