dabuchera
dabuchera

Reputation: 79

Viewer setThemingColor Promise

Is there a possiblity to make setThemingColor async and give a Promise back? Since it itarates over different arrays of objects i should know when the coloring is finished

    await asyncForEach(inputsSameLot, async (input) => {
            // console.log(input);
            var name = '';
            if (input.objectPath.indexOf('/')) {
              name = input.objectPath.split('/')[input.objectPath.split('/').length - 1];
            }
            else {
              name = input.objectPath;
            }
            // // Rot
            // var redColor = new THREE.Vector4(1, 0, 0, 1);
            let dbId = this.viewerComponent.viewer.search(name, (idArray) => {
                  this.viewerComponent.viewer.setThemingColor(idArray[0], color);
              // new Promise(resolve);
              // Wenn iterator gleich die Länge ist dass alle Objekte wieder zeigen
              // if (inputsSameLot.length === iterator) {
              //   console.log(inputsSameLot.length + ' ' + iterator);

              // }
              // if (index === 5 && inputsSameLot.length === iterator) {
              //   $('.spinner').hide();
              //   this.viewerComponent.viewer.showAll();
              // }
            }, (err) => {
              this.messageService.add({ key: 'warning', severity: 'error', summary: 'Error', detail: 'Something with COLORING went wrong: ' + err });
            }, ['name']);
          });

Thanks

Upvotes: 0

Views: 314

Answers (1)

Petr Broz
Petr Broz

Reputation: 9934

Internally, the setThemingColor method isn't doing a lot of work - it just iterates over objects under the given dbid (if the recursive flag is set), it updates the single color value in an internal array, and flags geometries of the dbid as "dirty". After the synchronous call to this method returns, you know that all objects have been colored, so there's really no need in waiting for an asynchronous signal that the operation completed.

Upvotes: 1

Related Questions