Skip to content

Commit

Permalink
Update SDK to v3 (#14)
Browse files Browse the repository at this point in the history
* RD-393 (#10)

* Update image links + replace plugin by module (#13)

* Add position indicators models

* Install maptiler sdk 3

* Update 3D layer to sdk 3

* Add example

* Add comments

* Add offset

* Make linter happy

* Refactor mount everest example

* Update examples to sdk v3

* Make biome happy

* Remove break line

* Fix model position issue on projection change animation

---------

Co-authored-by: Jonathan Lurie <[email protected]>

* Make biome happy

* RD-453_telemetry (#12)

* Update image links + replace plugin by module (#13)

* Add position indicators models

* Install maptiler sdk 3

* Update 3D layer to sdk 3

* Add example

* Add comments

* Add offset

* Make linter happy

* Refactor mount everest example

* Update examples to sdk v3

* Make biome happy

* Remove break line

* Add telemetry module registration

* Make registration works for multiple map instances

* Simplify telemetry

* Update sdk to v3.0.0-rc.4

* Fix model position issue on projection change animation

---------

Co-authored-by: Jonathan Lurie <[email protected]>

* RD-492_maplibre-v5.0.0-pre10 (#15)

* Update sdk version

* Update examples

* Bump version

* Fix version

* Update dependencies

* Update demos

* Fix dev mode

* Clean up

---------

Co-authored-by: Jonathan Lurie <[email protected]>
  • Loading branch information
sebstryczek and jonathanlurie authored Jan 7, 2025
1 parent e42cda9 commit 2d04df7
Show file tree
Hide file tree
Showing 22 changed files with 1,690 additions and 1,046 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# MapTiler 3D Models Changelog

## 2.0.0
### Other
- Update with MapTiler SDK v3 (globe)

## 1.0.0
First release 🎉
First release 🎉
1 change: 0 additions & 1 deletion demos/.nojekyll

This file was deleted.

73 changes: 35 additions & 38 deletions demos/flight.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html>

<head>
<title>MapTiler 3D</title>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v2.3.0/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v2.3.0/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>

<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.min.js"></script>

<style>
body {
margin: 0;
Expand All @@ -26,18 +29,15 @@
right: inherit;
left: 15px;
}

</style>
</head>

<body>


<div id="map"></div>

<script>

maptilersdk.config.apiKey = new URLSearchParams(location.search).get("key") ?? alert("Missing URL param with MapTiler API key ?key=XXXXX");
maptilersdk.config.apiKey =
new URLSearchParams(location.search).get("key") ??
alert("Missing URL param with MapTiler API key ?key=XXXXX");

const newYorkCity = [-73.98918779556983, 40.74072950731568];
const capeTown = [18.428021658130994, -33.913973526198134];
Expand All @@ -46,8 +46,7 @@
const ankara = [32.866609260522345, 39.959329480757354];

const map = new maptilersdk.Map({
container: document.getElementById('map'),
// hash: true,
container: document.getElementById("map"),
style: maptilersdk.MapStyle.STREETS.DARK,
zoom: 9,
center: paris,
Expand All @@ -56,6 +55,7 @@
terrain: false,
maptilerLogo: true,
terrainExaggeration: 0.001,
projectionControl: true,
});

(async () => {
Expand All @@ -69,29 +69,25 @@
"horizon-fog-blend": 0.1,
"sky-horizon-blend": 1.0,
"atmosphere-blend": 0.5,
})
});

const layer3D = new maptiler3d.Layer3D("custom-3D-layer");
map.addLayer(layer3D);

// Increasing the intensity of the ambient light
layer3D.setAmbientLight({intensity: 2});
// Increasing the intensity of the ambient light
layer3D.setAmbientLight({ intensity: 2 });

// Adding a point light
layer3D.addPointLight("point-light", {intensity: 30});
layer3D.addPointLight("point-light", { intensity: 30 });

const originalPlaneID = "plane";
await layer3D.addMeshFromURL(
originalPlaneID,
"models/plane_a340.glb",
{
lngLat: paris,
heading: 12,
scale: 5,
altitude: 5000,
altitudeReference: maptiler3d.AltitudeReference.MEAN_SEA_LEVEL,
}
);
await layer3D.addMeshFromURL(originalPlaneID, "models/plane_a340.glb", {
lngLat: paris,
heading: 12,
scale: 5,
altitude: 5000,
altitudeReference: maptiler3d.AltitudeReference.MEAN_SEA_LEVEL,
});

const guiObj = {
play: false,
Expand All @@ -101,17 +97,16 @@

const gui = new lil.GUI({ width: 500 });

gui.add( guiObj, 'tackFlight')
gui.add(guiObj, "tackFlight");

gui.add( guiObj, 'play')
.onChange((play) => {
gui.add(guiObj, "play").onChange((play) => {
if (play) {
playAnimation();
}
});

gui.add( guiObj, 'speed', 0, 0.001);
gui.add(guiObj, "speed", 0, 0.001);

let progress = 0;

function playAnimation() {
Expand All @@ -121,8 +116,12 @@
progress = 0;
}

const position = maptilersdk.math.haversineIntermediateWgs84(paris, ankara, progress);
layer3D.modifyMesh(originalPlaneID, {lngLat: position});
const position = maptilersdk.math.haversineIntermediateWgs84(
paris,
ankara,
progress
);
layer3D.modifyMesh(originalPlaneID, { lngLat: position });

if (guiObj.tackFlight) {
map.setCenter(position);
Expand All @@ -133,10 +132,8 @@
requestAnimationFrame(playAnimation);
}
}


})()

})();
</script>
</body>
</html>

</html>
47 changes: 47 additions & 0 deletions demos/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MapTiler 3D JS</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" />
</head>

<body>
<h1>MapTiler 3D JS Examples</h1>
<ul>
<li>
<a href="flight.html?key=">Flight</a>
</li>
<li>
<a href="mountains.html?key=">Mountains</a>
</li>
<li>
<a href="multi.html?key=">Multi</a>
</li>
<li>
<a href="plane.html?key=">Plane</a>
</li>
<li>
<a href="point_cad_model01.html?key=">Point Cloud - CAD-like view</a>
</li>
<li>
<a href="point_cloud_dundee.html?key=">Point Cloud - Dundee</a>
</li>
<li>
<a href="point_cloud_NMH.html?key=">Point Cloud - NMH</a>
</li>
<li>
<a href="point_cloud_shore.html?key=">Point Cloud - Shore</a>
</li>
</ul>

<script type="module">
document.querySelectorAll("a").forEach((a) => {
a.href += import.meta.env.VITE_API_KEY;
});
</script>
</body>

</html>
Binary file added demos/models/position-indicator--y-up.glb
Binary file not shown.
Binary file added demos/models/position-indicator--z-up.glb
Binary file not shown.
Loading

0 comments on commit 2d04df7

Please sign in to comment.