@smarterplan/ngx-smarterplan-core 1.2.11 → 1.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2924,23 +2924,42 @@ class MatterportService {
2924
2924
  // renderer.shadowMap.bias = 0.0001;
2925
2925
  // renderer.shadowMap.type = three.PCFSoftShadowMap;
2926
2926
  // });
2927
- let sensorRadius = 3.5; // Meters
2928
2927
  // Wait until Showcase is actually playing....
2929
2928
  this.sdk.Tag.data.subscribe({
2930
2929
  onAdded: function (index, item, collection) {
2931
2930
  return __awaiter(this, void 0, void 0, function* () {
2932
2931
  let thisOpacity = 0.2;
2933
2932
  this.sdk.Tag.editOpacity(index, thisOpacity);
2934
- const source = yield Promise.all([
2935
- this.sdk.Sensor.createSource(this.sdk.Sensor.SourceType.SPHERE, {
2936
- origin: item.discPosition,
2937
- radius: sensorRadius,
2938
- userData: {
2939
- id: index + '-sphere-source',
2940
- },
2941
- })
2942
- ]);
2943
- const sensor = yield this.sdk.Sensor.createSensor(this.sdk.Sensor.SensorType.CAMERA);
2933
+ let source = null;
2934
+ try {
2935
+ source = yield Promise.all([
2936
+ this.sdk.Sensor.createSource(this.sdk.Sensor.SourceType.SPHERE, {
2937
+ origin: item.anchorPosition,
2938
+ radius: Number(3),
2939
+ userData: {
2940
+ id: index + '-sphere-source',
2941
+ },
2942
+ })
2943
+ ]);
2944
+ }
2945
+ catch (e) {
2946
+ console.log('could not create Sphere sensor');
2947
+ console.error(e);
2948
+ }
2949
+ if (!source) {
2950
+ return;
2951
+ }
2952
+ let sensor = null;
2953
+ try {
2954
+ sensor = yield this.sdk.Sensor.createSensor(this.sdk.Sensor.SensorType.CAMERA);
2955
+ }
2956
+ catch (e) {
2957
+ console.log('could not create Camera sensor');
2958
+ console.error(e);
2959
+ }
2960
+ if (!sensor) {
2961
+ return;
2962
+ }
2944
2963
  sensor.addSource(...source);
2945
2964
  sensor.readings.subscribe({
2946
2965
  onUpdated(source, reading) {
@@ -12014,7 +12033,7 @@ class MatterportImportService {
12014
12033
  this.importingImages = new Subject();
12015
12034
  this.sweepProcessedCount = new Subject();
12016
12035
  this.totalSweepsCount = new Subject();
12017
- this.MAX_SCANS_RELOAD = 100;
12036
+ this.MAX_SCANS_RELOAD = 5;
12018
12037
  }
12019
12038
  get spaceID() {
12020
12039
  return this._spaceID;
@@ -12048,46 +12067,50 @@ class MatterportImportService {
12048
12067
  const element = document.querySelector('#viewer-frame');
12049
12068
  element.append(iframe);
12050
12069
  this.currentFrame = iframe;
12051
- try {
12052
- // @ts-ignore
12053
- this.sdk = yield window.MP_SDK.connect(iframe, 'qn9wsasuy5h2fzrbrn1nzr0id', '3.11');
12054
- // Subscribe to Floor data
12055
- this.sdk.Floor.data.subscribe({
12056
- onCollectionUpdated: function upd(collection) {
12057
- // console.log("Floors", collection);
12058
- this.floors = collection;
12059
- }.bind(this),
12060
- });
12061
- // Subscribe to current Floor
12062
- this.sdk.Floor.current.subscribe(function upd(currentFloor) {
12063
- this.currentFloor = currentFloor;
12064
- }.bind(this));
12065
- // Subscribe to Sweep data
12066
- this.sdk.Sweep.data.subscribe({
12067
- onCollectionUpdated: function upd(collection) {
12068
- console.log('the entire up-to-date collection', collection);
12069
- this.sweeps = collection;
12070
- }.bind(this),
12071
- });
12072
- // remove labels
12073
- yield this.sdk.Settings.update('labels', false);
12074
- let timeoutExpired = false;
12075
- // start timeout
12076
- setTimeout(() => (timeoutExpired = true), 7000);
12077
- yield waitUntil(() => (this.sweeps !== undefined && this.floors !== undefined) ||
12078
- timeoutExpired === true);
12079
- if (timeoutExpired) {
12080
- // we are likely in matterport error case (that we cannot catch!)
12081
- console.log('timeout intitialising Matterport');
12082
- throw new Error('error init Matterport');
12083
- }
12084
- console.log('init done');
12085
- return true;
12086
- }
12087
- catch (e) {
12088
- console.error(e);
12089
- throw new Error('error init Matterport');
12090
- }
12070
+ const showcaseWindow = iframe.contentWindow;
12071
+ return new Promise((res, rej) => {
12072
+ iframe.addEventListener('load', () => __awaiter(this, void 0, void 0, function* () {
12073
+ try {
12074
+ this.sdk = yield showcaseWindow.MP_SDK.connect(iframe, 'qn9wsasuy5h2fzrbrn1nzr0id', '3.11');
12075
+ // Subscribe to Floor data
12076
+ this.sdk.Floor.data.subscribe({
12077
+ onCollectionUpdated: function upd(collection) {
12078
+ // console.log("Floors", collection);
12079
+ this.floors = collection;
12080
+ }.bind(this),
12081
+ });
12082
+ // Subscribe to current Floor
12083
+ this.sdk.Floor.current.subscribe(function upd(currentFloor) {
12084
+ this.currentFloor = currentFloor;
12085
+ }.bind(this));
12086
+ // Subscribe to Sweep data
12087
+ this.sdk.Sweep.data.subscribe({
12088
+ onCollectionUpdated: function upd(collection) {
12089
+ console.log('the entire up-to-date collection', collection);
12090
+ this.sweeps = collection;
12091
+ }.bind(this),
12092
+ });
12093
+ // remove labels
12094
+ yield this.sdk.Settings.update('labels', false);
12095
+ let timeoutExpired = false;
12096
+ // start timeout
12097
+ setTimeout(() => (timeoutExpired = true), 7000);
12098
+ yield waitUntil(() => (this.sweeps !== undefined && this.floors !== undefined) ||
12099
+ timeoutExpired === true);
12100
+ if (timeoutExpired) {
12101
+ // we are likely in matterport error case (that we cannot catch!)
12102
+ console.log('timeout intitialising Matterport');
12103
+ return rej(new Error('error init Matterport'));
12104
+ }
12105
+ console.log('init done');
12106
+ return res(true);
12107
+ }
12108
+ catch (e) {
12109
+ console.error(e);
12110
+ rej(new Error('error init Matterport'));
12111
+ }
12112
+ }));
12113
+ });
12091
12114
  });
12092
12115
  }
12093
12116
  importData(spaceID, surface, reloading = false, node = null) {
@@ -12202,6 +12225,11 @@ class MatterportImportService {
12202
12225
  }
12203
12226
  for (let index = indexScan; index < maxScan; index += 1) {
12204
12227
  if (!this.stop) {
12228
+ yield new Promise((res) => {
12229
+ setTimeout(() => {
12230
+ res(null);
12231
+ }, 1000);
12232
+ });
12205
12233
  yield this.sdk.Sweep.moveTo(scans[index].uuid);
12206
12234
  yield this.sdk.Camera.setRotation({
12207
12235
  x: 0,