Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3d-style/data/bucket/model_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class ModelBucket implements Bucket {
): string {
const layer = this.layers[0];
const modelIdProperty = layer.layout.get('model-id');
const modelAllowDensityReductionProperty = layer.layout.get('model-allow-density-reduction');
assert(modelIdProperty);

const modelId = modelIdProperty.evaluate(evaluationFeature, {}, this.canonical);
Expand Down Expand Up @@ -479,7 +480,7 @@ class ModelBucket implements Bucket {
continue; // Clip on tile borders to prevent duplicates
}
// reduce density
if (this.lookupDim !== 0) {
if (this.lookupDim !== 0 && modelAllowDensityReductionProperty) {
const tileToLookup = (this.lookupDim - 1.0) / EXTENT;
const lookupIndex = this.lookupDim * ((point.y * tileToLookup) | 0) + (point.x * tileToLookup) | 0;
if (this.lookup) {
Expand Down
2 changes: 2 additions & 0 deletions 3d-style/style/style_layer/model_style_layer_properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import type {StylePropertySpecification} from '../../../src/style-spec/style-spe
export type LayoutProps = {
"visibility": DataConstantProperty<"visible" | "none">;
"model-id": DataDrivenProperty<string>;
"model-allow-density-reduction": DataConstantProperty<boolean>;
};
let layout: Properties<LayoutProps>;
export const getLayoutProperties = (): Properties<LayoutProps> => layout || (layout = new Properties({
"visibility": new DataConstantProperty(styleSpec["layout_model"]["visibility"]),
"model-id": new DataDrivenProperty(styleSpec["layout_model"]["model-id"]),
"model-allow-density-reduction": new DataConstantProperty(styleSpec["layout_model"]["model-allow-density-reduction"]),
}));

export type PaintProps = {
Expand Down
15 changes: 15 additions & 0 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,21 @@
"vector"
]
}]
},
"model-allow-density-reduction": {
"type": "boolean",
"default": true,
"transition": false,
"experimental": true,
"doc": "If true, the models will be reduced in density based on the zoom level. This is useful for large datasets that may be slow to render.",
"sdk-support": {
"basic functionality": {
"js": "0.10.0",
"android": "2.0.1",
"ios": "2.0.0"
}
},
"property-type": "data-constant"
}
},
"layout_clip": {
Expand Down
6 changes: 5 additions & 1 deletion src/style-spec/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,11 @@ export type ModelLayerSpecification = {
"filter"?: FilterSpecification,
"layout"?: {
"visibility"?: "visible" | "none" | ExpressionSpecification,
"model-id"?: DataDrivenPropertyValueSpecification<string>
"model-id"?: DataDrivenPropertyValueSpecification<string>,
/**
* @experimental This property is experimental and subject to change in future versions.
*/
"model-allow-density-reduction"?: boolean
},
"paint"?: {
"model-opacity"?: DataDrivenPropertyValueSpecification<number>,
Expand Down
Loading
Loading