Skip to content

Commit

Permalink
Added minZoom and maxZoom options
Browse files Browse the repository at this point in the history
  • Loading branch information
alxart committed Jul 4, 2024
1 parent e891e6f commit 2cfe1e7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ async function start() {
color: '#FFF3F3',
},
groundCoveringColor: 'rgba(0, 0, 0, 0.8)',
minZoom: 15,
maxZoom: 20,
});

(window as any).gltfPlugin = plugin;
Expand Down
2 changes: 2 additions & 0 deletions src/defaultOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ export const defaultOptions: Required<PluginOptions> = {
},
groundCoveringColor: '#F8F8EBCC',
zIndex: 0,
minZoom: -Infinity,
maxZoom: Infinity,
};
4 changes: 2 additions & 2 deletions src/labelGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class LabelGroups {
text,
userData,
image: image === 'default' ? labelGroupDefaults.image ?? DEFAULT_IMAGE : image,
minZoom,
maxZoom,
minZoom: minZoom ?? this.options.minZoom,
maxZoom: maxZoom ?? this.options.maxZoom,
color: fontColor ?? labelGroupDefaults.fontColor ?? DEFAULT_FONT_COLOR,
fontSize: fontSize ?? labelGroupDefaults.fontSize ?? DEFAULT_FONT_SIZE,
relativeAnchor: [0.5, 1],
Expand Down
2 changes: 2 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export class GltfPlugin extends Evented<GltfPluginEventTable> {
},
disableAnimation: true,
zIndex: this.options.zIndex,
minZoom: options.minZoom ?? this.options.minZoom,
maxZoom: options.maxZoom ?? this.options.maxZoom,
});

const model: Model = {
Expand Down
6 changes: 6 additions & 0 deletions src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export interface PluginOptions {
* on the map so that user could manage draw order of the plugin and these objects.
*/
zIndex?: number;

minZoom?: number;
maxZoom?: number;
}

/**
Expand Down Expand Up @@ -159,6 +162,9 @@ export interface ModelOptions {
* Interactivity of a model. The model isn't interactive by default.
*/
interactive?: boolean;

minZoom?: number;
maxZoom?: number;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/utils/realtyScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function getBuildingModelOptions(building: BuildingOptionsInternal): Mode
scale: building.scale,
linkedIds: building.linkedIds,
interactive: building.interactive,
minZoom: building.minZoom,
maxZoom: building.maxZoom,
};
}

Expand All @@ -35,6 +37,8 @@ export function getFloorModelOptions({
scale: buildingOptions.scale,
linkedIds: buildingOptions.linkedIds,
interactive: buildingOptions.interactive,
minZoom: buildingOptions.minZoom,
maxZoom: buildingOptions.maxZoom,
};
}

Expand Down

0 comments on commit 2cfe1e7

Please sign in to comment.