Skip to content

Commit 84063bb

Browse files
ibesoragithub-actions[bot]
authored andcommitted
Allow updating *-occlusion-opacity properties (internal-6010)
GitOrigin-RevId: 50a9223bc077a50487d4286c3ec6f47b704ecdcb
1 parent 0e7c709 commit 84063bb

File tree

6 files changed

+106
-6
lines changed

6 files changed

+106
-6
lines changed

src/render/draw_symbol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function drawLayerSymbols(
389389
return;
390390
}
391391

392-
if (!layer.hasInitialOcclusionOpacityProperties) {
392+
if (!layer.hasOcclusionOpacityProperties) {
393393
// Occlusion against terrain only
394394
if (painter.terrain) {
395395
defines.push('DEPTH_D24');

src/render/painter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ class Painter {
797797
} else if (layer.type === 'building') {
798798
buildingLayer = layer;
799799
} else if (layer.type === 'symbol') {
800-
if (layer.hasInitialOcclusionOpacityProperties) {
800+
if (layer.hasOcclusionOpacityProperties) {
801801
layersRequireFinalDepth = true;
802802
} else {
803803
layersRequireTerrainDepth = true;

src/style/style.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,15 +1141,15 @@ class Style extends Evented<MapEvents> {
11411141
const l1 = mergedLayers[layerName1];
11421142
const l2 = mergedLayers[layerName2];
11431143

1144-
if ((l1 as SymbolStyleLayer).hasInitialOcclusionOpacityProperties) {
1144+
if ((l1 as SymbolStyleLayer).hasOcclusionOpacityProperties) {
11451145
if (l2.is3D(!!this.terrain)) {
11461146
return 1;
11471147
}
11481148
return 0;
11491149
}
11501150

11511151
if (l1.is3D(!!this.terrain)) {
1152-
if ((l2 as SymbolStyleLayer).hasInitialOcclusionOpacityProperties) {
1152+
if ((l2 as SymbolStyleLayer).hasOcclusionOpacityProperties) {
11531153
return -1;
11541154
}
11551155
return 0;

src/style/style_layer/symbol_style_layer.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,18 @@ class SymbolStyleLayer extends StyleLayer {
7777
_brightnessMin: number;
7878
_brightnessMax: number;
7979

80-
hasInitialOcclusionOpacityProperties: boolean;
80+
hasOcclusionOpacityProperties: boolean;
8181

8282
constructor(layer: LayerSpecification, scope: string, lut: LUT | null, options?: ConfigOptions | null) {
8383
super(layer, getProperties(), scope, lut, options, layer.layout ? layer.layout['icon-image-use-theme'] : null);
8484
this._colorAdjustmentMatrix = mat4.identity([] as unknown as mat4);
85-
this.hasInitialOcclusionOpacityProperties = (layer.paint !== undefined) && (('icon-occlusion-opacity' in layer.paint) || ('text-occlusion-opacity' in layer.paint));
85+
this.hasOcclusionOpacityProperties = (layer.paint !== undefined) && (('icon-occlusion-opacity' in layer.paint) || ('text-occlusion-opacity' in layer.paint));
86+
}
87+
88+
override _handleSpecialPaintPropertyUpdate(name: string) {
89+
if (name === 'icon-occlusion-opacity' || name === 'text-occlusion-opacity') {
90+
this.hasOcclusionOpacityProperties = true;
91+
}
8692
}
8793

8894
override recalculate(parameters: EvaluationParameters, availableImages: ImageId[]) {
30.3 KB
Loading
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"height": 100,
6+
"width": 200,
7+
"operations": [
8+
[
9+
"waitFrameReady",
10+
30
11+
],
12+
[
13+
"setPaintProperty",
14+
"symbols",
15+
"icon-occlusion-opacity",
16+
0.6
17+
],
18+
[
19+
"waitFrameReady",
20+
100
21+
]
22+
]
23+
}
24+
},
25+
"center": [
26+
-113.32694547094238,
27+
35.93455626259847
28+
],
29+
"zoom": 12.2,
30+
"pitch": 60,
31+
"bearing": -20,
32+
"terrain": {
33+
"source": "rgbterrain"
34+
},
35+
"sources": {
36+
"rgbterrain": {
37+
"type": "raster-dem",
38+
"tiles": [
39+
"local://tiles/{z}-{x}-{y}.terrain.png"
40+
],
41+
"maxzoom": 12,
42+
"tileSize": 256
43+
},
44+
"satellite": {
45+
"type": "raster",
46+
"tiles": [
47+
"local://tiles/{z}-{x}-{y}.satellite.png"
48+
],
49+
"maxzoom": 17,
50+
"tileSize": 256
51+
},
52+
"geojson": {
53+
"type": "geojson",
54+
"data": {
55+
"type": "MultiPoint",
56+
"coordinates": [
57+
[
58+
-113.32599,
59+
35.93355626259847
60+
],
61+
[
62+
-113.33341462261518,
63+
35.9294218694216
64+
],
65+
[
66+
-113.3220882006336,
67+
35.9418831745696
68+
]
69+
]
70+
}
71+
}
72+
},
73+
"sprite": "local://sprites/sprite",
74+
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
75+
"layers": [
76+
{
77+
"id": "raster",
78+
"type": "raster",
79+
"source": "satellite",
80+
"paint": {
81+
"raster-fade-duration": 0
82+
}
83+
},
84+
{
85+
"id": "symbols",
86+
"type": "symbol",
87+
"source": "geojson",
88+
"layout": {
89+
"icon-image": "bar-12",
90+
"symbol-placement": "point"
91+
}
92+
}
93+
]
94+
}

0 commit comments

Comments
 (0)