Skip to content

Commit

Permalink
Merge pull request #23 from 2gis/TILES-5477-dontwaitall-and-addModels…
Browse files Browse the repository at this point in the history
…Partially

TILES-5477 bug with dontWaitAll and addModelsPartially
  • Loading branch information
myshov authored Jul 6, 2023
2 parents 36c599e + 010b5eb commit 70f6090
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@2gis/mapgl-gltf",
"version": "1.2.0",
"version": "1.2.1",
"description": "Plugin for the rendering glTF models with MapGL",
"main": "dist/bundle.js",
"typings": "dist/types/index.d.ts",
Expand Down
14 changes: 8 additions & 6 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class GltfPlugin extends Evented<GltfPluginEventTable> {
public async addModelsPartially(modelOptions: ModelOptions[], ids: Id[]) {
await this.waitForPluginInit;

const loadedModels = this.startModelLoading(modelOptions);
const loadedModels = this.startModelLoading(modelOptions, ids);

return Promise.all(loadedModels).then(() => {
if (this.options.modelsLoadStrategy === 'waitAll') {
Expand Down Expand Up @@ -314,15 +314,17 @@ export class GltfPlugin extends Evented<GltfPluginEventTable> {
});
}

private startModelLoading(modelOptions: ModelOptions[]) {
private startModelLoading(modelOptions: ModelOptions[], ids?: Id[]) {
return modelOptions.map((options) => {
return this.loader.loadModel(options).then(() => {
if (this.options.modelsLoadStrategy === 'dontWaitAll') {
if (options.linkedIds) {
this.map.setHiddenObjects(options.linkedIds);
if (ids === undefined || ids.includes(options.modelId)) {
if (options.linkedIds) {
this.map.setHiddenObjects(options.linkedIds);
}
this.addModelFromCache(options.modelId);
this.map.triggerRerender();
}
this.addModelFromCache(options.modelId);
this.map.triggerRerender();
}
});
});
Expand Down

0 comments on commit 70f6090

Please sign in to comment.