跳到主要内容
版本:9.2.0

移除三维模型特效

移除三维模型特效。

show
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8"/>
<title>移除三维模型特效</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<style>
body {
margin: 0;
padding: 0;
}

#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}

#btn-group {
position: absolute;
top: 20px;
left: 20px;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.2.0/mapmost-webgl-min.js"></script>
</head>

<body>
<div id="map"></div>
<div id="btn-group">
<button onclick="setEffect(true)">添加特效</button>
<button onclick="setEffect(false)">移除特效</button>
</div>
<script>
let map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.71755968678801, 31.32662823446909],
zoom: 15,
pitch: 60,
bearing: 0,
userId: '***', // 授权码,
env3D:{
envMap:"../hdr/WhiteBG_Ref_1K.hdr",
exposure: 0.9,
}
});

map.on('load', function () {

let models_obj = ["../example_data/sz_buildings.glb"].map(item => ({
type: 'glb',
url: item
}));

let options = {
id: 'model_id',
type: 'model',
models: models_obj,
project: "3857",
center: [120.71755968678801, 31.32662823446909, 0],
callback: function (group, layer) {
modelGroup = group;
modelLayer = layer;
}
};
map.addLayer(options);
})

function setEffect(isAdd) {
if (isAdd) {
modelLayer.addModelEffect(modelGroup, [
{
type: "gradient",
startColor: "#83afff",
endColor: "#FFFFFF",
percent: 0.2
}
, {
type: "flow",
speed: 1,
color: "#339bf6",
percent: 0.05
}
])
} else {
modelLayer.removeModelEffect(modelGroup)
}
}

</script>
</body>

</html>