@@ -123,9 +123,9 @@ There is a few differences though:
123
123
called to update the layer each time the rendering loop is called. For now
124
124
let's simply put ` itowns.FeatureProcessing.update ` and don't touch this
125
125
method.
126
- - the third parameter is ` convert ` , that is more interesting to us. It is the
127
- method that will tell how to use the data to convert it to meshes, and do
128
- other operations on it .
126
+ - ` Convert ` method to convert ` FeatureCollection ` to ` THREE.Mesh ` .
127
+ - the third parameter is ` Style ` , that is more interesting to us. It is the
128
+ Object that will tell how to use the data to stylize the meshes .
129
129
130
130
Trying this code will result in... nothing visually ! The data was processed and
131
131
displayed, but it is hidden under the elevation layer. If we remove the
@@ -137,7 +137,7 @@ have indeed been added. So let's place the data on the elevation layer !
137
137
## Placing the data on the ground
138
138
139
139
To achieve the positionning relative to the elevation layer, we will need to add
140
- a parameter to the ` convert ` property: ` altitude ` , a method that will help us.
140
+ a parameter to the ` Style ` property: ` base_altitude ` , a method that will help us.
141
141
142
142
``` js
143
143
function setAltitude (properties ) {
@@ -153,8 +153,11 @@ var geometrySource = new itowns.WFSSource({
153
153
var geometryLayer = new itowns.GeometryLayer (' Buildings' , new itowns.THREE.Group (), {
154
154
source: geometrySource,
155
155
update: itowns .FeatureProcessing .update ,
156
- convert: itowns .Feature2Mesh .convert ({
157
- altitude: setAltitude
156
+ convert: itowns .Feature2Mesh .convert (),
157
+ style: new itowns.Style ({
158
+ fill: {
159
+ base_altitude: setAltitude,
160
+ }
158
161
}),
159
162
zoom: { min: 14 },
160
163
});
@@ -207,8 +210,8 @@ But now we can't see completely our buildings again. What can we do about that
207
210
208
211
## Extruding the data
209
212
210
- Like the altitude, the volume of a building can be changed using the ` extrude `
211
- parameter of the ` convert ` property.
213
+ Like the altitude, the volume of a building can be changed using the ` extrusion_height `
214
+ parameter of the ` Style ` property.
212
215
213
216
``` js
214
217
function setExtrusion (properties ) {
@@ -224,9 +227,12 @@ var geometrySource = new itowns.WFSSource({
224
227
var geometryLayer = new itowns.GeometryLayer (' Buildings' , new itowns.THREE.Group (), {
225
228
source: geometrySource,
226
229
update: itowns .FeatureProcessing .update ,
227
- convert: itowns .Feature2Mesh .convert ({
228
- altitude: setAltitude,
229
- extrude: setExtrusion,
230
+ convert: itowns .Feature2Mesh .convert (),
231
+ style: new itowns.Style ({
232
+ fill: {
233
+ base_altitude: setAltitude,
234
+ extrusion_height: setExtrusion,
235
+ }
230
236
}),
231
237
zoom: { min: 14 },
232
238
});
@@ -245,7 +251,7 @@ nice view of our buildings:
245
251
246
252
We are not yet touching the color of the buildings. This results in every
247
253
building being randomly colored at each time. To solve this, as we did before,
248
- we can add a ` color ` parameter to the ` convert ` property.
254
+ we can add a ` color ` parameter to the ` Style ` property.
249
255
250
256
``` js
251
257
function setColor (properties ) {
@@ -261,10 +267,13 @@ var geometrySource = new itowns.WFSSource({
261
267
var geometryLayer = new itowns.GeometryLayer (' Buildings' , new itowns.THREE.Group (), {
262
268
source: geometrySource,
263
269
update: itowns .FeatureProcessing .update ,
264
- convert: itowns .Feature2Mesh .convert ({
265
- altitude: setAltitude,
266
- extrude: setExtrusion,
267
- color: setColor
270
+ convert: itowns .Feature2Mesh .convert (),
271
+ style: new itowns.Style ({
272
+ fill: {
273
+ color: setColor
274
+ base_altitude: setAltitude,
275
+ extrusion_height: setExtrusion,
276
+ },
268
277
}),
269
278
zoom: { min: 14 },
270
279
});
@@ -381,10 +390,13 @@ layer on a globe, and change some things on this layer. Here is the final code:
381
390
var geometryLayer = new itowns.GeometryLayer (' Buildings' , new itowns.THREE.Group (), {
382
391
source: geometrySource,
383
392
update: itowns .FeatureProcessing .update ,
384
- convert: itowns .Feature2Mesh .convert ({
385
- altitude: setAltitude,
386
- extrude: setExtrusion,
387
- color: setColor
393
+ convert: itowns .Feature2Mesh .convert (),
394
+ style: new itowns.Style ({
395
+ fill: {
396
+ color: setColor
397
+ base_altitude: setAltitude,
398
+ extrusion_height: setExtrusion,
399
+ },
388
400
}),
389
401
zoom: { min: 14 },
390
402
});
0 commit comments