99
1010import { WindLayerOptions , WindData , WindDataAtLonLat } from './types' ;
1111import { WindParticleSystem } from './windParticleSystem' ;
12+ import { deepMerge } from './utils' ;
1213
1314export * from './types' ;
1415
@@ -308,13 +309,17 @@ export class WindLayer {
308309 */
309310 updateOptions ( options : Partial < WindLayerOptions > ) : void {
310311 if ( this . _isDestroyed ) return ;
311- this . options = { ... this . options , ... options } ;
312+ this . options = deepMerge ( options , this . options ) ;
312313 this . particleSystem . changeOptions ( options ) ;
313314 this . viewer . scene . requestRender ( ) ;
314315 // Dispatch options change event
315316 this . dispatchEvent ( 'optionsChange' , this . options ) ;
316317 }
317318
319+ /**
320+ * Zoom to the wind data bounds.
321+ * @param {number } [duration=0] - The duration of the zoom animation.
322+ */
318323 zoomTo ( duration : number = 0 ) : void {
319324 if ( this . windData . bounds ) {
320325 const rectangle = Rectangle . fromDegrees (
@@ -330,24 +335,37 @@ export class WindLayer {
330335 }
331336 }
332337
338+ /**
339+ * Add the wind layer to the scene.
340+ */
333341 add ( ) : void {
334342 this . primitives = this . particleSystem . getPrimitives ( ) ;
335343 this . primitives . forEach ( primitive => {
336344 this . scene . primitives . add ( primitive ) ;
337345 } ) ;
338346 }
339347
348+ /**
349+ * Remove the wind layer from the scene.
350+ */
340351 remove ( ) : void {
341352 this . primitives . forEach ( primitive => {
342353 this . scene . primitives . remove ( primitive ) ;
343354 } ) ;
344355 this . primitives = [ ] ;
345356 }
346357
358+ /**
359+ * Check if the wind layer is destroyed.
360+ * @returns {boolean } - True if the wind layer is destroyed, otherwise false.
361+ */
347362 isDestroyed ( ) : boolean {
348363 return this . _isDestroyed ;
349364 }
350365
366+ /**
367+ * Destroy the wind layer and release all resources.
368+ */
351369 destroy ( ) : void {
352370 this . remove ( ) ;
353371 this . removeEventListeners ( ) ;
@@ -364,13 +382,23 @@ export class WindLayer {
364382 } ) ;
365383 }
366384
385+ /**
386+ * Add an event listener for the specified event type.
387+ * @param {WindLayerEventType } type - The type of event to listen for.
388+ * @param {WindLayerEventCallback } callback - The callback function to execute when the event occurs.
389+ */
367390 addEventListener ( type : WindLayerEventType , callback : WindLayerEventCallback ) {
368391 if ( ! this . eventListeners . has ( type ) ) {
369392 this . eventListeners . set ( type , new Set ( ) ) ;
370393 }
371394 this . eventListeners . get ( type ) ?. add ( callback ) ;
372395 }
373396
397+ /**
398+ * Remove an event listener for the specified event type.
399+ * @param {WindLayerEventType } type - The type of event to remove.
400+ * @param {WindLayerEventCallback } callback - The callback function to remove.
401+ */
374402 removeEventListener ( type : WindLayerEventType , callback : WindLayerEventCallback ) {
375403 this . eventListeners . get ( type ) ?. delete ( callback ) ;
376404 }
0 commit comments