跳到主要内容
版本:9.1.0

3DTiles初始加载位置变换

在3DTiles进行初始化加载时,设置倾斜数据的位置变换。

show
   <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>3DTiles初始加载位置变换</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%;
}

</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.1.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
var map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.74449559193792, 31.30775326748954],
zoom: 16,
pitch: 60,
userId: '***', // 授权码
});

map.on('load', function () {
const TILESET_URL = "<your 3dtiles url>";

// 创建初始化的单位矩阵
let matrix = new window.mapmost.Matrix4();
// 添加平移旋转变换
let matrix4 = matrix.translate([0, 0, 200]).rotateX(Math.PI / 2);
map.addLayer(
{
id: 'tile-3d-layer',
type: "3DTiles",
data: TILESET_URL,
transform: matrix4
}
)
})

</script>
</body>
</html>