File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -374,8 +374,7 @@ class View extends THREE.EventDispatcher {
374374 this . scene . add ( layer . object3d ) ;
375375 }
376376
377- Promise . all ( layer . _promises ) . then ( ( ) => {
378- layer . _resolve ( ) ;
377+ layer . startup ( ) . then ( ( ) => {
379378 this . notifyChange ( parentLayer || layer , false ) ;
380379 if ( ! this . _frameRequesters [ MAIN_LOOP_EVENTS . UPDATE_END ] ||
381380 ! this . _frameRequesters [ MAIN_LOOP_EVENTS . UPDATE_END ] . includes ( this . _allLayersAreReadyCallback ) ) {
@@ -385,7 +384,7 @@ class View extends THREE.EventDispatcher {
385384 type : VIEW_EVENTS . LAYER_ADDED ,
386385 layerId : layer . id ,
387386 } ) ;
388- } , layer . _reject ) ;
387+ } ) ;
389388
390389 return layer . whenReady ;
391390 }
Original file line number Diff line number Diff line change @@ -179,6 +179,21 @@ class Layer extends THREE.EventDispatcher {
179179 return resolve ;
180180 }
181181
182+ /**
183+ * The startup stage is the first stage of the layer lifecycle. It is called
184+ * internally when the layer is added to the view.
185+ * @param {View } context - the context the layer has been added to.
186+ * @returns {Promise<void> }
187+ */
188+ async startup ( /* context */ ) {
189+ try {
190+ await Promise . all ( this . _promises ) ;
191+ this . _resolve ( ) ;
192+ } catch ( error ) {
193+ this . _reject ( error ) ;
194+ }
195+ }
196+
182197 /**
183198 * Defines a property for this layer, with a default value and a callback
184199 * executed when the property changes.
You can’t perform that action at this time.
0 commit comments