Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RD-453_telemetry #12

Merged
merged 18 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demos/flight.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
4 changes: 2 additions & 2 deletions demos/mountains.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://mrdoob.github.io/stats.js/build/stats.min.js"></script>

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

<script>
Expand Down
4 changes: 2 additions & 2 deletions demos/multi.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
101 changes: 60 additions & 41 deletions demos/plane.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<html>

<head>
<title>MapTiler 3D Models</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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down Expand Up @@ -45,12 +46,11 @@
z-index: 2;
backdrop-filter: blur(10px);
}

</style>
</head>

<body>


<div id="map"></div>
<div id="info">
Expand Down Expand Up @@ -94,17 +94,18 @@
map.addLayer(layer3D);

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

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


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

// Adding a mesh of a plane.

const guiObj = {
projection: "mercator",
heading: 0,
scale: 1,
altitude: 3000,
Expand All @@ -115,7 +116,7 @@
layer3D.removeMesh(originalPlaneID);
},
}

const originalPlaneID = "plane";
await layer3D.addMeshFromURL(
originalPlaneID,
Expand All @@ -135,48 +136,66 @@
map.on("mousemove", (e) => {
if (!planeCanMove) return;

layer3D.modifyMesh(originalPlaneID, {lngLat: e.lngLat})
layer3D.modifyMesh(originalPlaneID, { lngLat: e.lngLat })
});

map.on("click", (e) => {
planeCanMove = !planeCanMove;
});

gui.add( guiObj, 'heading', 0, 360, 0.1 )
.onChange((heading) => {
layer3D.modifyMesh(originalPlaneID, {heading});
});

gui.add( guiObj, 'scale', 0.01, 5, 0.01 )
.onChange((scale) => {
layer3D.modifyMesh(originalPlaneID, {scale});
});

gui.add( guiObj, 'altitude', 0, 10000, 1 )
.onChange((altitude) => {
layer3D.modifyMesh(originalPlaneID, {altitude});
});

gui.add( guiObj, 'opacity', 0, 1)
.onChange((opacity) => {
layer3D.modifyMesh(originalPlaneID, {opacity});
});


gui.add( guiObj, 'altitudeReference', ["MEAN_SEA_LEVEL", "GROUND"])
.onChange((altRef) => {
layer3D.modifyMesh(originalPlaneID, {altitudeReference: maptiler3d.AltitudeReference[altRef]});
});

gui.add( guiObj, "wireframe" )
.onChange((wireframe) => {
layer3D.modifyMesh(originalPlaneID, {wireframe});
});

gui.add( guiObj, "removePlane" );
gui
.add(guiObj, 'projection', ["mercator", "globe"])
.onChange((projection) => {
switch (projection) {
case "mercator":
map.enableMercatorProjection(true);
break;

case "globe":
map.enableGlobeProjection(true);
break;

default:
throw new Error("Unsupported projection");
}
});

gui.add(guiObj, 'heading', 0, 360, 0.1)
.onChange((heading) => {
layer3D.modifyMesh(originalPlaneID, { heading });
});

gui.add(guiObj, 'scale', 0.01, 1000, 0.01)
.onChange((scale) => {
layer3D.modifyMesh(originalPlaneID, { scale });
});

gui.add(guiObj, 'altitude', 0, 10000, 1)
.onChange((altitude) => {
layer3D.modifyMesh(originalPlaneID, { altitude });
});

gui.add(guiObj, 'opacity', 0, 1)
.onChange((opacity) => {
layer3D.modifyMesh(originalPlaneID, { opacity });
});


gui.add(guiObj, 'altitudeReference', ["MEAN_SEA_LEVEL", "GROUND"])
.onChange((altRef) => {
layer3D.modifyMesh(originalPlaneID, { altitudeReference: maptiler3d.AltitudeReference[altRef] });
});

gui.add(guiObj, "wireframe")
.onChange((wireframe) => {
layer3D.modifyMesh(originalPlaneID, { wireframe });
});

gui.add(guiObj, "removePlane");

})()

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

</html>
4 changes: 2 additions & 2 deletions demos/point_cad_model01.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
4 changes: 2 additions & 2 deletions demos/point_cloud_NMH.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
4 changes: 2 additions & 2 deletions demos/point_cloud_dundee.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
4 changes: 2 additions & 2 deletions demos/point_cloud_shore.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<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/v3.0.0-rc.2/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.2/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v3.0.0-rc.4/maptiler-sdk.css" rel="stylesheet" />
<script src="../build/maptiler-3d.umd.js"></script>
<style>
body {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>MapTiler 3D JS Examples</h1>
<a href="demos/multi.html?key=">Multi</a>
</li>
<li>
<a href="demos/plane.html?key=">Terrain</a>
<a href="demos/plane.html?key=">Plain</a>
</li>
<li>
<a href="demos/point_cad_model01.html?key=">Point Cloud - CAD-like view</a>
Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"vite-plugin-dts": "^4.1.0"
},
"dependencies": {
"@maptiler/sdk": "^3.0.0-rc.2",
"@maptiler/sdk": "^3.0.0-rc.4",
"lru-cache": "^11.0.1",
"three": "^0.168.0"
}
Expand Down
20 changes: 15 additions & 5 deletions src/Layer3D.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { getVersion, LngLat } from "@maptiler/sdk";
import type { LngLatLike, CustomLayerInterface, CustomRenderMethodInput, Map as MapSDK } from "@maptiler/sdk";
import {
type CustomLayerInterface,
type Map as MapSDK,
type LngLatLike,
type CustomRenderMethodInput,
LngLat,
getVersion,
} from "@maptiler/sdk";

import packagejson from "../package.json";

import {
Camera,
Expand Down Expand Up @@ -257,6 +265,8 @@ export class Layer3D implements CustomLayerInterface {
* Automatically called when the layer is added. (should not be called manually)
*/
onAdd?(map: MapSDK, gl: WebGL2RenderingContext): void {
map.telemetry.registerModule(packagejson.name, packagejson.version);

this.map = map;

this.renderer = new WebGLRenderer({
Expand Down Expand Up @@ -305,9 +315,9 @@ export class Layer3D implements CustomLayerInterface {
return;
}

if ([0, 1].includes(options.defaultProjectionData.projectionTransition) === false) {
return;
}
if ([0, 1].includes(options.defaultProjectionData.projectionTransition) === false) {
return;
}

const mapCenter = this.map.getCenter();

Expand Down
Loading