@@ -4,7 +4,7 @@ titleSuffix: Microsoft Azure Maps
4
4
description : How to add a custom WebGL layer to a map using the Azure Maps Web SDK.
5
5
author : stevemunk
6
6
ms.author : v-munksteve
7
- ms.date : 09/23 /2022
7
+ ms.date : 10/17 /2022
8
8
ms.topic : how-to
9
9
ms.service : azure-maps
10
10
services : azure-maps
@@ -117,10 +117,10 @@ map.layers.add(new atlas.layer.WebGLLayer("layerId",
117
117
118
118
This sample renders a triangle on the map using a WebGL layer.
119
119
120
- <!-- ------------------ Insert example here ----------------------------------->
121
-
122
120
![ A screenshot showing a triangle rendered on a map, using a WebGL layer.] ( ./media/how-to-webgl-custom-layer/triangle.png )
123
121
122
+ For a fully functional sample with source code, see [ Simple 2D WebGL layer] [ Simple 2D WebGL layer ] in the Azure Maps Samples.
123
+
124
124
The map's camera matrix is used to project spherical Mercator point to
125
125
gl coordinates. Mercator point \[ 0, 0\] represents the top left corner
126
126
of the Mercator world and \[ 1, 1\] represents the bottom right corner.
@@ -141,17 +141,16 @@ to load a [glTF][glTF] file and render it on the map using [three.js][threejs].
141
141
You need to add the following script files.
142
142
143
143
``` html
144
- <
script src =
" https://unpkg.com/[email protected] /build/three.min.js" ></
script >
145
-
146
- <
script src =
" https://unpkg.com/[email protected] /examples/js/loaders/GLTFLoader.js" ></
script >
144
+ <script src =" https://unpkg.com/three@latest/build/three.min.js" ></script >
145
+ <script src =" https://unpkg.com/three@latest/examples/js/loaders/GLTFLoader.js" ></script >
147
146
```
148
147
149
148
This sample renders an animated 3D parrot on the map.
150
149
151
- <!-- ------------------ Insert example here ----------------------------------->
152
-
153
150
![ A screenshot showing an an animated 3D parrot on the map.] ( ./media/how-to-webgl-custom-layer/3d-parrot.gif )
154
151
152
+ For a fully functional sample with source code, see [ Three custom WebGL layer] [ Three custom WebGL layer ] in the Azure Maps Samples.
153
+
155
154
The ` onAdd ` function loads a ` .glb ` file into memory and instantiates
156
155
three.js objects such as Camera, Scene, Light, and a ` THREE.WebGLRenderer ` .
157
156
@@ -165,6 +164,27 @@ a single frame by calling `map.triggerRepaint()` in the `render` function.
165
164
> - To enable anti-aliasing simply set ` antialias ` to ` true ` as
166
165
one of the style options while creating the map.
167
166
167
+ ## Render a 3D model using babylon.js
168
+
169
+ [ Babylon.js] [ babylonjs ] is one of the world's leading WebGL-based graphics engines. The following example shows how to load a GLTF file and render it on the map using babylon.js.
170
+
171
+ You need to add the following script files.
172
+
173
+ ``` html
174
+ <script src =" https://cdn.babylonjs.com/babylon.js" ></script >
175
+ <script src =" https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js" ></script >
176
+ ```
177
+
178
+ This sample renders a satellite tower on the map.
179
+
180
+ The ` onAdd ` function instantiates a BABYLON engine and a scene. It then loads a ` .gltf ` file using BABYLON.SceneLoader.
181
+
182
+ The ` render ` function calculates the projection matrix of the camera and renders the model to the scene.
183
+
184
+ ![ A screenshot showing an example of rendering a 3D model using babylon.js.] ( ./media/how-to-webgl-custom-layer/render-3d-model.png )
185
+
186
+ For a fully functional sample with source code, see [ Babylon custom WebGL layer] [ Babylon custom WebGL layer ] in the Azure Maps Samples.
187
+
168
188
## Render a deck.gl layer
169
189
170
190
A WebGL layer can be used to render layers from the [ deck.gl] [ deckgl ]
@@ -175,7 +195,7 @@ within a certain time range.
175
195
You need to add the following script file.
176
196
177
197
``` html
178
- <script src =" https://unpkg.com/deck.gl@8.8.9 /dist.min.js" ></script >
198
+ <script src =" https://unpkg.com/deck.gl@latest /dist.min.js" ></script >
179
199
```
180
200
181
201
Define a layer class that extends ` atlas.layer.WebGLLayer ` .
@@ -215,6 +235,8 @@ This sample renders an arc-layer google the [deck.gl][deckgl] library.
215
235
216
236

217
237
238
+ For a fully functional sample with source code, see [Deck GL custom WebGL layer][Deck GL custom WebGL layer] in the Azure Maps Samples.
239
+
218
240
## Next steps
219
241
220
242
Learn more about the classes and methods used in this article:
@@ -236,7 +258,12 @@ Learn more about the classes and methods used in this article:
236
258
[deckgl]: https://deck.gl/
237
259
[glTF]: https://www.khronos.org/gltf/
238
260
[OpenGL ES]: https://www.khronos.org/opengles/
261
+ [babylonjs]: https://www.babylonjs.com/
239
262
[WebGLLayer]: /javascript/api/azure-maps-control/atlas.layer.webgllayer
240
263
[WebGLLayerOptions]: /javascript/api/azure-maps-control/atlas.webgllayeroptions
241
264
[WebGLRenderer interface]: /javascript/api/azure-maps-control/atlas.webglrenderer
242
265
[MercatorPoint]: /javascript/api/azure-maps-control/atlas.data.mercatorpoint
266
+ [Simple 2D WebGL layer]: https://samples.azuremaps.com/?sample=simple-2d-webgl-layer
267
+ [Deck GL custom WebGL layer]: https://samples.azuremaps.com/?sample=deck-gl-custom-webgl-layer
268
+ [Three custom WebGL layer]: https://samples.azuremaps.com/?sample=three-custom-webgl-layer
269
+ [Babylon custom WebGL layer]: https://samples.azuremaps.com/?sample=babylon-custom-webgl-layer
0 commit comments