mapbox gl 3d模型贴图的贴图实现方式

this.map.on(‘load’, function() {
that.map.addLayer({
‘id’: ‘3d-buildings’,
‘source’: ‘composite’,
‘source-layer’: ‘building’,
‘filter’: [’==’, ‘extrude’, ‘true’],
‘type’: ‘fill-extrusion’,
‘minzoom’: 5,
‘paint’: {
‘fill-extrusion-color’: ‘#0166b6’,
‘fill-extrusion-height’: [“interpolate”,[“linear”],[“zoom”],5, 0,5.05,[“get”, “height”]],
‘fill-extrusion-base’: [“interpolate”,[“linear”],[“zoom”],5, 0,5.05,[“get”, “min_height”]],
‘fill-extrusion-pattern’:“catcat”,
‘fill-extrusion-opacity’: 1
},
})
//楼顶
that.map.addLayer({
“id”: “buildingtop”,
‘type’: ‘fill-extrusion’,
“source”: “composite”,
“minzoom”: 5,
“source-layer”: “building”,
‘paint’: {
‘fill-extrusion-color’: “#32373b”,
‘fill-extrusion-height’: [“interpolate”,[“linear”],[“zoom”],5, 0,5.05,[“get”, “height”]],
‘fill-extrusion-base’: [“interpolate”,[“linear”],[“zoom”],5, 0,5.05,[“get”, “height”]],
‘fill-extrusion-opacity’: 1
}
})
that.map.loadImage(“http://127.0.0.1:8081/img/texture.png”, function (error, image) {
if (error) throw error;
that.map.addImage(“catcat”, image);
})
});
mapbox gl 3d模型贴图的贴图实现方式_第1张图片
亲测可用:但是要注意的是,这个贴图会被平铺,所以你的图片要尽量做的小一点

你可能感兴趣的:(mapbox)