3DGS模型空间变换
支持对三维场景中加载的3DGS模型进行空间变换,包括模型缩放、旋转和平移。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>3DGS模型空间变换</title>
<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.12.0-beta/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<div id="btn-group">
<button onClick="translateModel()">平移</button>
<button onClick="rotateModel()">旋转</button>
<button onClick="scaleModel()">缩放</button>
</div>
<script>
var map = new mapmost.Map({
style: '<your style url>',
container: 'map',
center: [120.78575270115562, 31.41174980621166],
zoom: 16.9,
bearing: -9.598,
pitch: 52.989,
sky: 'light',
userId:'***', // 授权码
});
let modelGroup;
map.on('load', function () {
// 添加3DGS模型
map.addLayer({
id: 'gs-3d-layer',
type: '3DGS',
url: '<your 3DGS model url>',
coord: [120.73170325959506, 31.305177399153735, 10],
callback: (group) => {
modelGroup = group;
},
});
});
// 平移3DGS模型
function translateModel() {
modelGroup.setTranslate({ x: 50 });
}
// 旋转3DGS模型
function rotateModel() {
modelGroup.setRotation({ x: 90 });
}
// 缩放3DGS模型
function scaleModel() {
modelGroup.setScale({ x: 0.5, y: 0.5, z: 0.5 });
}
</script>
</body>
</html>