فهرست منبع

doc and whatsnew

Raanan Weber 5 سال پیش
والد
کامیت
45cca3f75b
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 1 0
      dist/preview release/what's new.md
  2. 12 3
      src/Misc/timer.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -27,6 +27,7 @@
 - Added support in `ShadowGenerator` for fast fake soft transparent shadows ([Popov72](https://github.com/Popov72))
 - Added `boundingBoxRenderer.onBeforeBoxRenderingObservable` and `boundingBoxRenderer.onAfterBoxRenderingObservable` ([Deltakosh](https://github.com/deltakosh))
 - Added initial code for user facing DeviceSourceManager ([PolygonalSun](https://github.com/PolygonalSun))
+- Added a Simple and advanced timer, based on observables ([RaananW](https://github.com/RaananW))
 
 ### Engine
 

+ 12 - 3
src/Misc/timer.ts

@@ -69,17 +69,26 @@ export interface ITimerData<T> {
  * The current state of the timer
  */
 export enum TimerState {
+    /**
+     * Timer initialized, not yet started
+     */
     INIT,
+    /**
+     * Timer started and counting
+     */
     STARTED,
+    /**
+     * Timer ended (whether aborted or time reached)
+     */
     ENDED
 }
 
 /**
  * A simple version of the timer. Will take options and start the timer immediately after calling it
  *
- * @param options options to initialize this timer
+ * @param options options with which to initialize this timer
  */
-export const SetAndStartTimer = (options: ITimerOptions<any>): Nullable<Observer<any>> => {
+export function SetAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>> {
     let timer = 0;
     const startTime = Date.now();
     options.observableParameters = options.observableParameters ?? {};
@@ -103,7 +112,7 @@ export const SetAndStartTimer = (options: ITimerOptions<any>): Nullable<Observer
         }
     }, options.observableParameters.mask, options.observableParameters.insertFirst, options.observableParameters.scope);
     return observer;
-};
+}
 
 /**
  * An advanced implementation of a timer class