@smarterplan/ngx-smarterplan-core 1.2.11 → 1.2.12

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.
@@ -2806,22 +2806,41 @@ class MatterportService {
2806
2806
  // renderer.shadowMap.bias = 0.0001;
2807
2807
  // renderer.shadowMap.type = three.PCFSoftShadowMap;
2808
2808
  // });
2809
- let sensorRadius = 3.5; // Meters
2810
2809
  // Wait until Showcase is actually playing....
2811
2810
  this.sdk.Tag.data.subscribe({
2812
2811
  onAdded: async function (index, item, collection) {
2813
2812
  let thisOpacity = 0.2;
2814
2813
  this.sdk.Tag.editOpacity(index, thisOpacity);
2815
- const source = await Promise.all([
2816
- this.sdk.Sensor.createSource(this.sdk.Sensor.SourceType.SPHERE, {
2817
- origin: item.discPosition,
2818
- radius: sensorRadius,
2819
- userData: {
2820
- id: index + '-sphere-source',
2821
- },
2822
- })
2823
- ]);
2824
- const sensor = await this.sdk.Sensor.createSensor(this.sdk.Sensor.SensorType.CAMERA);
2814
+ let source = null;
2815
+ try {
2816
+ source = await Promise.all([
2817
+ this.sdk.Sensor.createSource(this.sdk.Sensor.SourceType.SPHERE, {
2818
+ origin: item.anchorPosition,
2819
+ radius: Number(3),
2820
+ userData: {
2821
+ id: index + '-sphere-source',
2822
+ },
2823
+ })
2824
+ ]);
2825
+ }
2826
+ catch (e) {
2827
+ console.log('could not create Sphere sensor');
2828
+ console.error(e);
2829
+ }
2830
+ if (!source) {
2831
+ return;
2832
+ }
2833
+ let sensor = null;
2834
+ try {
2835
+ sensor = await this.sdk.Sensor.createSensor(this.sdk.Sensor.SensorType.CAMERA);
2836
+ }
2837
+ catch (e) {
2838
+ console.log('could not create Camera sensor');
2839
+ console.error(e);
2840
+ }
2841
+ if (!sensor) {
2842
+ return;
2843
+ }
2825
2844
  sensor.addSource(...source);
2826
2845
  sensor.readings.subscribe({
2827
2846
  onUpdated(source, reading) {
@@ -11359,7 +11378,7 @@ class MatterportImportService {
11359
11378
  this.importingImages = new Subject();
11360
11379
  this.sweepProcessedCount = new Subject();
11361
11380
  this.totalSweepsCount = new Subject();
11362
- this.MAX_SCANS_RELOAD = 100;
11381
+ this.MAX_SCANS_RELOAD = 5;
11363
11382
  }
11364
11383
  get spaceID() {
11365
11384
  return this._spaceID;
@@ -11392,46 +11411,49 @@ class MatterportImportService {
11392
11411
  const element = document.querySelector('#viewer-frame');
11393
11412
  element.append(iframe);
11394
11413
  this.currentFrame = iframe;
11395
- try {
11396
- // @ts-ignore
11397
- this.sdk = await window.MP_SDK.connect(iframe, 'qn9wsasuy5h2fzrbrn1nzr0id', '3.11');
11398
- // Subscribe to Floor data
11399
- this.sdk.Floor.data.subscribe({
11400
- onCollectionUpdated: function upd(collection) {
11401
- // console.log("Floors", collection);
11402
- this.floors = collection;
11403
- }.bind(this),
11404
- });
11405
- // Subscribe to current Floor
11406
- this.sdk.Floor.current.subscribe(function upd(currentFloor) {
11407
- this.currentFloor = currentFloor;
11408
- }.bind(this));
11409
- // Subscribe to Sweep data
11410
- this.sdk.Sweep.data.subscribe({
11411
- onCollectionUpdated: function upd(collection) {
11412
- console.log('the entire up-to-date collection', collection);
11413
- this.sweeps = collection;
11414
- }.bind(this),
11414
+ return new Promise((res, rej) => {
11415
+ iframe.addEventListener('load', async () => {
11416
+ try {
11417
+ this.sdk = await window.MP_SDK.connect(iframe, 'qn9wsasuy5h2fzrbrn1nzr0id', '3.11');
11418
+ // Subscribe to Floor data
11419
+ this.sdk.Floor.data.subscribe({
11420
+ onCollectionUpdated: function upd(collection) {
11421
+ // console.log("Floors", collection);
11422
+ this.floors = collection;
11423
+ }.bind(this),
11424
+ });
11425
+ // Subscribe to current Floor
11426
+ this.sdk.Floor.current.subscribe(function upd(currentFloor) {
11427
+ this.currentFloor = currentFloor;
11428
+ }.bind(this));
11429
+ // Subscribe to Sweep data
11430
+ this.sdk.Sweep.data.subscribe({
11431
+ onCollectionUpdated: function upd(collection) {
11432
+ console.log('the entire up-to-date collection', collection);
11433
+ this.sweeps = collection;
11434
+ }.bind(this),
11435
+ });
11436
+ // remove labels
11437
+ await this.sdk.Settings.update('labels', false);
11438
+ let timeoutExpired = false;
11439
+ // start timeout
11440
+ setTimeout(() => (timeoutExpired = true), 7000);
11441
+ await waitUntil(() => (this.sweeps !== undefined && this.floors !== undefined) ||
11442
+ timeoutExpired === true);
11443
+ if (timeoutExpired) {
11444
+ // we are likely in matterport error case (that we cannot catch!)
11445
+ console.log('timeout intitialising Matterport');
11446
+ return rej(new Error('error init Matterport'));
11447
+ }
11448
+ console.log('init done');
11449
+ return res(true);
11450
+ }
11451
+ catch (e) {
11452
+ console.error(e);
11453
+ rej(new Error('error init Matterport'));
11454
+ }
11415
11455
  });
11416
- // remove labels
11417
- await this.sdk.Settings.update('labels', false);
11418
- let timeoutExpired = false;
11419
- // start timeout
11420
- setTimeout(() => (timeoutExpired = true), 7000);
11421
- await waitUntil(() => (this.sweeps !== undefined && this.floors !== undefined) ||
11422
- timeoutExpired === true);
11423
- if (timeoutExpired) {
11424
- // we are likely in matterport error case (that we cannot catch!)
11425
- console.log('timeout intitialising Matterport');
11426
- throw new Error('error init Matterport');
11427
- }
11428
- console.log('init done');
11429
- return true;
11430
- }
11431
- catch (e) {
11432
- console.error(e);
11433
- throw new Error('error init Matterport');
11434
- }
11456
+ });
11435
11457
  }
11436
11458
  async importData(spaceID, surface, reloading = false, node = null) {
11437
11459
  if (!this.sweeps) {
@@ -11540,6 +11562,11 @@ class MatterportImportService {
11540
11562
  }
11541
11563
  for (let index = indexScan; index < maxScan; index += 1) {
11542
11564
  if (!this.stop) {
11565
+ await new Promise((res) => {
11566
+ setTimeout(() => {
11567
+ res(null);
11568
+ }, 1000);
11569
+ });
11543
11570
  await this.sdk.Sweep.moveTo(scans[index].uuid);
11544
11571
  await this.sdk.Camera.setRotation({
11545
11572
  x: 0,