2

I am using babylonjs in my project and I have to import meshes with ImportMeshAsync method. This method look like this:

static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
    meshes: AbstractMesh[];
    particleSystems: IParticleSystem[];
    skeletons: Skeleton[];
    animationGroups: AnimationGroup[];
}>;

My case:

        Promise.all(
          tilesArray.map(asset =>
            BABYLON.SceneLoader.ImportMeshAsync(
              "",
              `http://localhost:2050/${asset}/`,
              "model.glb",
              scene,
              handleMeshLoading
            ).then(mesh => {
              mesh.meshes[0].rotate(
                BABYLON.Axis.X,
                Math.PI / 2,
                BABYLON.Space.LOCAL
              );
              return mesh;
            })
          )
        )
          .then(this.handleComplete)
      }

Handling complete:

  handleComplete = (
    meshes: {
      meshes: AbstractMesh[];
      particleSystems: IParticleSystem[];
      skeletons: Skeleton[];
      animationGroups: AnimationGroup[];
    }[]
  ) => {
    this.broadcastService.broadcast(EVENT_TYPE.PROGRESS_BAR_LOADED, true);
    this.model = meshes;
  };

in .then(this.handleComplete) I've got this error:

Argument of type '(meshes: { meshes: AbstractMesh[]; particleSystems: IParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }[]) => void' is not assignable to parameter of type '(value: [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]) => void | PromiseLike<void>'.
  Types of parameters 'meshes' and 'value' are incompatible.
    Type '[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]' is not assignable to type '{ meshes: AbstractMesh[]; particleSystems: IParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }[]'.
      Type '{}' is missing the following properties from type '{ meshes: AbstractMesh[]; particleSystems: IParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }': meshes, particleSystems, skeletons, animationGroupsts(2345)

I don't know why because in handleComplete I declared argument with the same type as ImportMeshAsync. When I use meshes: any[] it's all ok but I should not use any type..

Symlis
  • 101
  • 1
  • 8

0 Answers0