Skip to main content

Load 3DTiles containing KTX 2.0 textures

To support loading tilted model data containing KTX 2.0 textures, the 3DTiles service must have the KHR_texture_basisu extended attribute, and the ktx2ParseUrl parameter and encoding parameter need to be set.

show
   <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Loading 3DTiles containing KTX 2.0 textures</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.16.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.766, 30.04859],
zoom: 15,
pitch: 60,
userId: '***', // Authorization code
});

map.on('load', function () {
const TILESET_URL = "<your 3dtiles url>";
map.addLayer(
{
id: 'tile-3d-layer',
type: "3DTiles",
data: TILESET_URL,
dracoUrl: "http://******/draco/",
ktx2ParseUrl: 'http://******/basis/', // Load the decompression library file address of the KTX 2.0 texture model
encoding:mapmost.ColorSpace.LinearEncoding
}
)
})

function removeLayer() {
map.removeLayer('tile-3d-layer')
}
</script>
</body>
</html>