@babylonjs/core 7.11.2 → 7.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/Animations/animatable.d.ts +10 -10
  2. package/Animations/animatable.js +5 -5
  3. package/Animations/animatable.js.map +1 -1
  4. package/Animations/animationGroupMask.d.ts +2 -2
  5. package/Animations/animationGroupMask.js +1 -1
  6. package/Animations/animationGroupMask.js.map +1 -1
  7. package/Animations/easing.d.ts +2 -2
  8. package/Animations/easing.js +1 -1
  9. package/Animations/easing.js.map +1 -1
  10. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +3 -3
  11. package/Behaviors/Meshes/attachToBoxBehavior.js +3 -3
  12. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  13. package/Cameras/Inputs/freeCameraMouseInput.d.ts +2 -2
  14. package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
  15. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  16. package/Cameras/Inputs/freeCameraTouchInput.d.ts +2 -2
  17. package/Cameras/Inputs/freeCameraTouchInput.js +1 -1
  18. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  19. package/Culling/Helper/boundingInfoHelper.d.ts +28 -0
  20. package/Culling/Helper/boundingInfoHelper.js +178 -0
  21. package/Culling/Helper/boundingInfoHelper.js.map +1 -0
  22. package/Culling/Helper/webgl2BoundingHelper.d.ts +22 -0
  23. package/Culling/Helper/webgl2BoundingHelper.js +61 -0
  24. package/Culling/Helper/webgl2BoundingHelper.js.map +1 -0
  25. package/Culling/Octrees/octree.d.ts +2 -2
  26. package/Culling/Octrees/octree.js +1 -1
  27. package/Culling/Octrees/octree.js.map +1 -1
  28. package/Culling/index.d.ts +1 -0
  29. package/Culling/index.js +1 -0
  30. package/Culling/index.js.map +1 -1
  31. package/Culling/ray.d.ts +4 -4
  32. package/Culling/ray.js +2 -2
  33. package/Culling/ray.js.map +1 -1
  34. package/Debug/skeletonViewer.d.ts +6 -6
  35. package/Debug/skeletonViewer.js +3 -3
  36. package/Debug/skeletonViewer.js.map +1 -1
  37. package/DeviceInput/InputDevices/deviceSource.d.ts +2 -2
  38. package/DeviceInput/InputDevices/deviceSource.js +1 -1
  39. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  40. package/Engines/Extensions/engine.transformFeedback.d.ts +5 -0
  41. package/Engines/Extensions/engine.transformFeedback.js +3 -0
  42. package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
  43. package/Engines/abstractEngine.js +2 -2
  44. package/Engines/abstractEngine.js.map +1 -1
  45. package/Engines/nativeEngine.d.ts +7 -0
  46. package/Engines/nativeEngine.js +4 -1
  47. package/Engines/nativeEngine.js.map +1 -1
  48. package/Maths/math.color.d.ts +14 -14
  49. package/Maths/math.color.js +7 -7
  50. package/Maths/math.color.js.map +1 -1
  51. package/Maths/math.isovector.d.ts +4 -4
  52. package/Maths/math.isovector.js +2 -2
  53. package/Maths/math.isovector.js.map +1 -1
  54. package/Maths/math.vector.d.ts +12 -12
  55. package/Maths/math.vector.js +6 -6
  56. package/Maths/math.vector.js.map +1 -1
  57. package/Maths/math.vertexFormat.d.ts +10 -10
  58. package/Maths/math.vertexFormat.js +5 -5
  59. package/Maths/math.vertexFormat.js.map +1 -1
  60. package/Meshes/mesh.d.ts +4 -0
  61. package/Meshes/mesh.js +13 -4
  62. package/Meshes/mesh.js.map +1 -1
  63. package/Misc/observable.d.ts +6 -6
  64. package/Misc/observable.js +4 -4
  65. package/Misc/observable.js.map +1 -1
  66. package/Misc/sceneOptimizer.d.ts +3 -3
  67. package/Misc/sceneOptimizer.js +2 -2
  68. package/Misc/sceneOptimizer.js.map +1 -1
  69. package/Particles/EmitterTypes/coneParticleEmitter.d.ts +2 -2
  70. package/Particles/EmitterTypes/coneParticleEmitter.js +1 -1
  71. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  72. package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +8 -8
  73. package/Particles/EmitterTypes/cylinderParticleEmitter.js +4 -4
  74. package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
  75. package/Particles/EmitterTypes/hemisphericParticleEmitter.d.ts +6 -6
  76. package/Particles/EmitterTypes/hemisphericParticleEmitter.js +3 -3
  77. package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
  78. package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +6 -6
  79. package/Particles/EmitterTypes/sphereParticleEmitter.js +3 -3
  80. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  81. package/Particles/pointsCloudSystem.d.ts +0 -1
  82. package/Particles/pointsCloudSystem.js +0 -1
  83. package/Particles/pointsCloudSystem.js.map +1 -1
  84. package/Shaders/gpuTransform.fragment.d.ts +5 -0
  85. package/Shaders/gpuTransform.fragment.js +11 -0
  86. package/Shaders/gpuTransform.fragment.js.map +1 -0
  87. package/Shaders/gpuTransform.vertex.d.ts +13 -0
  88. package/Shaders/gpuTransform.vertex.js +33 -0
  89. package/Shaders/gpuTransform.vertex.js.map +1 -0
  90. package/XR/features/WebXRBackgroundRemover.d.ts +2 -2
  91. package/XR/features/WebXRBackgroundRemover.js +1 -1
  92. package/XR/features/WebXRBackgroundRemover.js.map +1 -1
  93. package/XR/features/WebXRHitTest.d.ts +2 -2
  94. package/XR/features/WebXRHitTest.js +1 -1
  95. package/XR/features/WebXRHitTest.js.map +1 -1
  96. package/XR/features/WebXRHitTestLegacy.d.ts +2 -2
  97. package/XR/features/WebXRHitTestLegacy.js +1 -1
  98. package/XR/features/WebXRHitTestLegacy.js.map +1 -1
  99. package/XR/features/WebXRRawCameraAccess.js +0 -2
  100. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  101. package/XR/motionController/webXRAbstractMotionController.d.ts +2 -0
  102. package/XR/motionController/webXRAbstractMotionController.js +1 -0
  103. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  104. package/package.json +1 -1
@@ -59,7 +59,7 @@ export declare class Observer<T> {
59
59
  */
60
60
  mask: number;
61
61
  /**
62
- * [scope] Defines the current scope used to restore the JS context
62
+ * [null] Defines the current scope used to restore the JS context
63
63
  */
64
64
  scope: any;
65
65
  /** @internal */
@@ -78,7 +78,7 @@ export declare class Observer<T> {
78
78
  * Creates a new observer
79
79
  * @param callback defines the callback to call when the observer is notified
80
80
  * @param mask defines the mask of the observer (used to filter notifications)
81
- * @param [scope] defines the current scope used to restore the JS context
81
+ * @param scope defines the current scope used to restore the JS context
82
82
  */
83
83
  constructor(
84
84
  /**
@@ -90,7 +90,7 @@ export declare class Observer<T> {
90
90
  */
91
91
  mask: number,
92
92
  /**
93
- * [scope] Defines the current scope used to restore the JS context
93
+ * [null] Defines the current scope used to restore the JS context
94
94
  */
95
95
  scope?: any);
96
96
  /**
@@ -109,7 +109,7 @@ export declare class Observer<T> {
109
109
  */
110
110
  export declare class Observable<T> {
111
111
  /**
112
- * [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.
112
+ * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.
113
113
  * This is helpful to single-state observables like the scene onReady or the dispose observable.
114
114
  */
115
115
  notifyIfTriggered: boolean;
@@ -137,11 +137,11 @@ export declare class Observable<T> {
137
137
  /**
138
138
  * Creates a new observable
139
139
  * @param onObserverAdded defines a callback to call when a new observer is added
140
- * @param [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.
140
+ * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.
141
141
  */
142
142
  constructor(onObserverAdded?: (observer: Observer<T>) => void,
143
143
  /**
144
- * [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.
144
+ * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.
145
145
  * This is helpful to single-state observables like the scene onReady or the dispose observable.
146
146
  */
147
147
  notifyIfTriggered?: boolean);
@@ -36,7 +36,7 @@ export class Observer {
36
36
  * Creates a new observer
37
37
  * @param callback defines the callback to call when the observer is notified
38
38
  * @param mask defines the mask of the observer (used to filter notifications)
39
- * @param [scope] defines the current scope used to restore the JS context
39
+ * @param scope defines the current scope used to restore the JS context
40
40
  */
41
41
  constructor(
42
42
  /**
@@ -48,7 +48,7 @@ export class Observer {
48
48
  */
49
49
  mask,
50
50
  /**
51
- * [scope] Defines the current scope used to restore the JS context
51
+ * [null] Defines the current scope used to restore the JS context
52
52
  */
53
53
  scope = null) {
54
54
  this.callback = callback;
@@ -118,11 +118,11 @@ export class Observable {
118
118
  /**
119
119
  * Creates a new observable
120
120
  * @param onObserverAdded defines a callback to call when a new observer is added
121
- * @param [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.
121
+ * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.
122
122
  */
123
123
  constructor(onObserverAdded,
124
124
  /**
125
- * [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.
125
+ * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.
126
126
  * This is helpful to single-state observables like the scene onReady or the dispose observable.
127
127
  */
128
128
  notifyIfTriggered = false) {
@@ -1 +1 @@
1
- {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/observable.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QAClF,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QACxF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI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,eAAe,CAAC,OAAe,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE;gBACtC,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an Observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<() => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param [scope] defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [scope] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n */\r\n public remove() {\r\n if (this._remove) {\r\n this._remove();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [notifyIfTriggered] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n // attach the remove function to the observer\r\n observer._remove = () => {\r\n this.remove(observer);\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null | undefined): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/observable.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QACl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;OAEG;IACI,sBAAsB;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,MAAM,MAAM,GAAG,IAAI,UAAU,EAAK,CAAC;QAEnC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;QAII;IACG,eAAe,CAAC,OAAe,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE;gBACtC,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an Observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<() => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [null] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n */\r\n public remove() {\r\n if (this._remove) {\r\n this._remove();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n // attach the remove function to the observer\r\n observer._remove = () => {\r\n this.remove(observer);\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null | undefined): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import { Observable } from "./observable";
6
6
  */
7
7
  export declare class SceneOptimization {
8
8
  /**
9
- * Defines the priority of this optimization (0 by default which means first in the list)
9
+ * [0] Defines the priority of this optimization (0 by default which means first in the list)
10
10
  */
11
11
  priority: number;
12
12
  /**
@@ -27,13 +27,13 @@ export declare class SceneOptimization {
27
27
  */
28
28
  constructor(
29
29
  /**
30
- * Defines the priority of this optimization (0 by default which means first in the list)
30
+ * [0] Defines the priority of this optimization (0 by default which means first in the list)
31
31
  */
32
32
  priority?: number);
33
33
  }
34
34
  /**
35
35
  * Defines an optimization used to reduce the size of render target textures
36
- * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer
36
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer
37
37
  */
38
38
  export declare class TextureOptimization extends SceneOptimization {
39
39
  /**
@@ -28,7 +28,7 @@ export class SceneOptimization {
28
28
  */
29
29
  constructor(
30
30
  /**
31
- * Defines the priority of this optimization (0 by default which means first in the list)
31
+ * [0] Defines the priority of this optimization (0 by default which means first in the list)
32
32
  */
33
33
  priority = 0) {
34
34
  this.priority = priority;
@@ -36,7 +36,7 @@ export class SceneOptimization {
36
36
  }
37
37
  /**
38
38
  * Defines an optimization used to reduce the size of render target textures
39
- * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer
39
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer
40
40
  */
41
41
  export class TextureOptimization extends SceneOptimization {
42
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sceneOptimizer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/sceneOptimizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAA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;OAEG;IACI,OAAO;QACV,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACtE;IACL,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,aAAa,CAAC,KAAY,EAAE,OAA+B,EAAE,SAAsB,EAAE,SAAsB;QACrH,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,IAAI,qBAAqB,CAAC,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;QAElH,IAAI,SAAS,EAAE;YACX,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;QAED,IAAI,SAAS,EAAE;YACX,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;QAED,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"./observable\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * Defines the root class used to create scene optimization to use with SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public getDescription(): string {\r\n return \"\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates the SceneOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n constructor(\r\n /**\r\n * Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public priority: number = 0\r\n ) {}\r\n}\r\n\r\n/**\r\n * Defines an optimization used to reduce the size of render target textures\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class TextureOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Reducing render target texture size to \" + this.maximumSize;\r\n }\r\n\r\n /**\r\n * Creates the TextureOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n constructor(\r\n /**\r\n * Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n */\r\n public maximumSize: number = 1024,\r\n /**\r\n * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n public step = 0.5\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n let allDone = true;\r\n for (let index = 0; index < scene.textures.length; index++) {\r\n const texture = scene.textures[index];\r\n\r\n if (!texture.canRescale || (<any>texture).getContext) {\r\n continue;\r\n }\r\n\r\n const currentSize = texture.getSize();\r\n const maxDimension = Math.max(currentSize.width, currentSize.height);\r\n\r\n if (maxDimension > this.maximumSize) {\r\n texture.scale(this.step);\r\n allDone = false;\r\n }\r\n }\r\n\r\n return allDone;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to increase or decrease the rendering resolution\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class HardwareScalingOptimization extends SceneOptimization {\r\n private _currentScale = -1;\r\n private _directionOffset = 1;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Setting hardware scaling level to \" + this._currentScale;\r\n }\r\n\r\n /**\r\n * Creates the HardwareScalingOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumScale defines the maximum scale to use (2 by default)\r\n * @param step defines the step to use between two passes (0.5 by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * Defines the maximum scale to use (2 by default)\r\n */\r\n public maximumScale: number = 2,\r\n /**\r\n * Defines the step to use between two passes (0.5 by default)\r\n */\r\n public step: number = 0.25\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this._currentScale === -1) {\r\n this._currentScale = scene.getEngine().getHardwareScalingLevel();\r\n if (this._currentScale > this.maximumScale) {\r\n this._directionOffset = -1;\r\n }\r\n }\r\n\r\n this._currentScale += this._directionOffset * this.step;\r\n\r\n scene.getEngine().setHardwareScalingLevel(this._currentScale);\r\n\r\n return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to remove shadows\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ShadowsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning shadows on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.shadowsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn post-processes off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class PostProcessesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning post-processes on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.postProcessesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn lens flares off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class LensFlaresOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning lens flares on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.lensFlaresEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization based on user defined callback.\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class CustomOptimization extends SceneOptimization {\r\n /**\r\n * Callback called to apply the custom optimization.\r\n */\r\n public onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;\r\n\r\n /**\r\n * Callback called to get custom description\r\n */\r\n public onGetDescription: () => string;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n if (this.onGetDescription) {\r\n return this.onGetDescription();\r\n }\r\n\r\n return \"Running user defined callback\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this.onApply) {\r\n return this.onApply(scene, optimizer);\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn particles off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ParticlesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning particles on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.particlesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn render targets off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class RenderTargetsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning render targets off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.renderTargetsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to merge meshes with compatible materials\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class MergeMeshesOptimization extends SceneOptimization {\r\n private static _UpdateSelectionTree = false;\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static get UpdateSelectionTree(): boolean {\r\n return MergeMeshesOptimization._UpdateSelectionTree;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static set UpdateSelectionTree(value: boolean) {\r\n MergeMeshesOptimization._UpdateSelectionTree = value;\r\n }\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Merging similar meshes together\";\r\n }\r\n\r\n private _canBeMerged = (abstractMesh: AbstractMesh): boolean => {\r\n if (!(abstractMesh instanceof Mesh)) {\r\n return false;\r\n }\r\n\r\n const mesh = <Mesh>abstractMesh;\r\n\r\n if (mesh.isDisposed()) {\r\n return false;\r\n }\r\n\r\n if (!mesh.isVisible || !mesh.isEnabled()) {\r\n return false;\r\n }\r\n\r\n if (mesh.instances.length > 0) {\r\n return false;\r\n }\r\n\r\n if (mesh.skeleton || mesh.hasLODLevels) {\r\n return false;\r\n }\r\n\r\n if (mesh.getTotalVertices() === 0) {\r\n return false;\r\n }\r\n\r\n return true;\r\n };\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @param updateSelectionTree defines that the selection octree has to be updated (false by default)\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean {\r\n const globalPool = scene.meshes.slice(0);\r\n let globalLength = globalPool.length;\r\n\r\n for (let index = 0; index < globalLength; index++) {\r\n const currentPool: Mesh[] = [];\r\n const current = globalPool[index];\r\n\r\n // Checks\r\n if (!this._canBeMerged(current)) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>current);\r\n\r\n // Find compatible meshes\r\n for (let subIndex = index + 1; subIndex < globalLength; subIndex++) {\r\n const otherMesh = globalPool[subIndex];\r\n\r\n if (!this._canBeMerged(otherMesh)) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.material !== current.material) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.checkCollisions !== current.checkCollisions) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>otherMesh);\r\n globalLength--;\r\n\r\n globalPool.splice(subIndex, 1);\r\n\r\n subIndex--;\r\n }\r\n\r\n if (currentPool.length < 2) {\r\n continue;\r\n }\r\n\r\n // Merge meshes\r\n Mesh.MergeMeshes(currentPool, undefined, true);\r\n }\r\n\r\n // Call the octree system optimization if it is defined.\r\n const sceneAsAny = scene as any;\r\n if (sceneAsAny.createOrUpdateSelectionOctree) {\r\n if (updateSelectionTree != undefined) {\r\n if (updateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n } else if (MergeMeshesOptimization.UpdateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines a list of options used by SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizerOptions {\r\n /**\r\n * Gets the list of optimizations to apply\r\n */\r\n public optimizations: SceneOptimization[] = [];\r\n\r\n /**\r\n * Creates a new list of options used by SceneOptimizer\r\n * @param targetFrameRate defines the target frame rate to reach (60 by default)\r\n * @param trackerDuration defines the interval between two checks (2000ms by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the target frame rate to reach (60 by default)\r\n */\r\n public targetFrameRate: number = 60,\r\n /**\r\n * Defines the interval between two checks (2000ms by default)\r\n */\r\n public trackerDuration: number = 2000\r\n ) {}\r\n\r\n /**\r\n * Add a new optimization\r\n * @param optimization defines the SceneOptimization to add to the list of active optimizations\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addOptimization(optimization: SceneOptimization): SceneOptimizerOptions {\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a new custom optimization\r\n * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)\r\n * @param onGetDescription defines the callback called to get the description attached with the optimization.\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addCustomOptimization(onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean, onGetDescription: () => string, priority: number = 0): SceneOptimizerOptions {\r\n const optimization = new CustomOptimization(priority);\r\n optimization.onApply = onApply;\r\n optimization.onGetDescription = onGetDescription;\r\n\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 1024));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 512));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 2));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 256));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 4));\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * Class used to run optimizations in order to reach a target frame rate\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizer implements IDisposable {\r\n private _isRunning = false;\r\n private _options: SceneOptimizerOptions;\r\n private _scene: Scene;\r\n private _currentPriorityLevel = 0;\r\n private _targetFrameRate = 60;\r\n private _trackerDuration = 2000;\r\n private _currentFrameRate = 0;\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n private _improvementMode = false;\r\n\r\n /**\r\n * Defines an observable called when the optimizer reaches the target frame rate\r\n */\r\n public onSuccessObservable = new Observable<SceneOptimizer>();\r\n /**\r\n * Defines an observable called when the optimizer enables an optimization\r\n */\r\n public onNewOptimizationAppliedObservable = new Observable<SceneOptimization>();\r\n /**\r\n * Defines an observable called when the optimizer is not able to reach the target frame rate\r\n */\r\n public onFailureObservable = new Observable<SceneOptimizer>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the optimizer is in improvement mode\r\n */\r\n public get isInImprovementMode(): boolean {\r\n return this._improvementMode;\r\n }\r\n\r\n public set isInImprovementMode(value: boolean) {\r\n this._improvementMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current priority level (0 at start)\r\n */\r\n public get currentPriorityLevel(): number {\r\n return this._currentPriorityLevel;\r\n }\r\n\r\n /**\r\n * Gets the current frame rate checked by the SceneOptimizer\r\n */\r\n public get currentFrameRate(): number {\r\n return this._currentFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public get targetFrameRate(): number {\r\n return this._targetFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public set targetFrameRate(value: number) {\r\n this._targetFrameRate = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public get trackerDuration(): number {\r\n return this._trackerDuration;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public set trackerDuration(value: number) {\r\n this._trackerDuration = value;\r\n }\r\n\r\n /**\r\n * Gets the list of active optimizations\r\n */\r\n public get optimizations(): SceneOptimization[] {\r\n return this._options.optimizations;\r\n }\r\n\r\n /**\r\n * Creates a new SceneOptimizer\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)\r\n * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)\r\n */\r\n public constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities = true, improvementMode = false) {\r\n if (!options) {\r\n this._options = new SceneOptimizerOptions();\r\n } else {\r\n this._options = options;\r\n }\r\n\r\n if (this._options.targetFrameRate) {\r\n this._targetFrameRate = this._options.targetFrameRate;\r\n }\r\n\r\n if (this._options.trackerDuration) {\r\n this._trackerDuration = this._options.trackerDuration;\r\n }\r\n\r\n if (autoGeneratePriorities) {\r\n let priority = 0;\r\n for (const optim of this._options.optimizations) {\r\n optim.priority = priority++;\r\n }\r\n }\r\n\r\n this._improvementMode = improvementMode;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\r\n this._sceneDisposeObserver = null;\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Stops the current optimizer\r\n */\r\n public stop() {\r\n this._isRunning = false;\r\n }\r\n\r\n /**\r\n * Reset the optimizer to initial step (current priority level = 0)\r\n */\r\n public reset() {\r\n this._currentPriorityLevel = 0;\r\n }\r\n\r\n /**\r\n * Start the optimizer. By default it will try to reach a specific framerate\r\n * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate\r\n */\r\n public start() {\r\n if (this._isRunning) {\r\n return;\r\n }\r\n\r\n this._isRunning = true;\r\n\r\n // Let's wait for the scene to be ready before running our check\r\n this._scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n private _checkCurrentState() {\r\n if (!this._isRunning) {\r\n return;\r\n }\r\n\r\n const scene = this._scene;\r\n const options = this._options;\r\n\r\n this._currentFrameRate = Math.round(scene.getEngine().getFps());\r\n\r\n if ((this._improvementMode && this._currentFrameRate <= this._targetFrameRate) || (!this._improvementMode && this._currentFrameRate >= this._targetFrameRate)) {\r\n this._isRunning = false;\r\n this.onSuccessObservable.notifyObservers(this);\r\n return;\r\n }\r\n\r\n // Apply current level of optimizations\r\n let allDone = true;\r\n let noOptimizationApplied = true;\r\n for (let index = 0; index < options.optimizations.length; index++) {\r\n const optimization = options.optimizations[index];\r\n\r\n if (optimization.priority === this._currentPriorityLevel) {\r\n noOptimizationApplied = false;\r\n allDone = allDone && optimization.apply(scene, this);\r\n this.onNewOptimizationAppliedObservable.notifyObservers(optimization);\r\n }\r\n }\r\n\r\n // If no optimization was applied, this is a failure :(\r\n if (noOptimizationApplied) {\r\n this._isRunning = false;\r\n this.onFailureObservable.notifyObservers(this);\r\n\r\n return;\r\n }\r\n\r\n // If all optimizations were done, move to next level\r\n if (allDone) {\r\n this._currentPriorityLevel++;\r\n }\r\n\r\n // Let's the system running for a specific amount of time before checking FPS\r\n scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this.stop();\r\n this.onSuccessObservable.clear();\r\n this.onFailureObservable.clear();\r\n this.onNewOptimizationAppliedObservable.clear();\r\n if (this._sceneDisposeObserver) {\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to create a SceneOptimizer with one single line of code\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param onSuccess defines a callback to call on success\r\n * @param onFailure defines a callback to call on failure\r\n * @returns the new SceneOptimizer object\r\n */\r\n public static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer {\r\n const optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);\r\n\r\n if (onSuccess) {\r\n optimizer.onSuccessObservable.add(() => {\r\n onSuccess();\r\n });\r\n }\r\n\r\n if (onFailure) {\r\n optimizer.onFailureObservable.add(() => {\r\n onFailure();\r\n });\r\n }\r\n\r\n optimizer.start();\r\n\r\n return optimizer;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sceneOptimizer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/sceneOptimizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,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AAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACtE;IACL,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,aAAa,CAAC,KAAY,EAAE,OAA+B,EAAE,SAAsB,EAAE,SAAsB;QACrH,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,IAAI,qBAAqB,CAAC,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;QAElH,IAAI,SAAS,EAAE;YACX,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;QAED,IAAI,SAAS,EAAE;YACX,SAAS,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACnC,SAAS,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;QAED,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"./observable\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * Defines the root class used to create scene optimization to use with SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public getDescription(): string {\r\n return \"\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates the SceneOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n constructor(\r\n /**\r\n * [0] Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public priority: number = 0\r\n ) {}\r\n}\r\n\r\n/**\r\n * Defines an optimization used to reduce the size of render target textures\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class TextureOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Reducing render target texture size to \" + this.maximumSize;\r\n }\r\n\r\n /**\r\n * Creates the TextureOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n constructor(\r\n /**\r\n * Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter\r\n */\r\n public maximumSize: number = 1024,\r\n /**\r\n * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.\r\n */\r\n public step = 0.5\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n let allDone = true;\r\n for (let index = 0; index < scene.textures.length; index++) {\r\n const texture = scene.textures[index];\r\n\r\n if (!texture.canRescale || (<any>texture).getContext) {\r\n continue;\r\n }\r\n\r\n const currentSize = texture.getSize();\r\n const maxDimension = Math.max(currentSize.width, currentSize.height);\r\n\r\n if (maxDimension > this.maximumSize) {\r\n texture.scale(this.step);\r\n allDone = false;\r\n }\r\n }\r\n\r\n return allDone;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to increase or decrease the rendering resolution\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class HardwareScalingOptimization extends SceneOptimization {\r\n private _currentScale = -1;\r\n private _directionOffset = 1;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Setting hardware scaling level to \" + this._currentScale;\r\n }\r\n\r\n /**\r\n * Creates the HardwareScalingOptimization object\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @param maximumScale defines the maximum scale to use (2 by default)\r\n * @param step defines the step to use between two passes (0.5 by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the priority of this optimization (0 by default which means first in the list)\r\n */\r\n public override priority: number = 0,\r\n /**\r\n * Defines the maximum scale to use (2 by default)\r\n */\r\n public maximumScale: number = 2,\r\n /**\r\n * Defines the step to use between two passes (0.5 by default)\r\n */\r\n public step: number = 0.25\r\n ) {\r\n super(priority);\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this._currentScale === -1) {\r\n this._currentScale = scene.getEngine().getHardwareScalingLevel();\r\n if (this._currentScale > this.maximumScale) {\r\n this._directionOffset = -1;\r\n }\r\n }\r\n\r\n this._currentScale += this._directionOffset * this.step;\r\n\r\n scene.getEngine().setHardwareScalingLevel(this._currentScale);\r\n\r\n return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to remove shadows\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ShadowsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning shadows on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.shadowsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn post-processes off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class PostProcessesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning post-processes on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.postProcessesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn lens flares off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class LensFlaresOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning lens flares on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.lensFlaresEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization based on user defined callback.\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class CustomOptimization extends SceneOptimization {\r\n /**\r\n * Callback called to apply the custom optimization.\r\n */\r\n public onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;\r\n\r\n /**\r\n * Callback called to get custom description\r\n */\r\n public onGetDescription: () => string;\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n if (this.onGetDescription) {\r\n return this.onGetDescription();\r\n }\r\n\r\n return \"Running user defined callback\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n if (this.onApply) {\r\n return this.onApply(scene, optimizer);\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn particles off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class ParticlesOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning particles on/off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.particlesEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to turn render targets off\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class RenderTargetsOptimization extends SceneOptimization {\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Turning render targets off\";\r\n }\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer): boolean {\r\n scene.renderTargetsEnabled = optimizer.isInImprovementMode;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines an optimization used to merge meshes with compatible materials\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class MergeMeshesOptimization extends SceneOptimization {\r\n private static _UpdateSelectionTree = false;\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static get UpdateSelectionTree(): boolean {\r\n return MergeMeshesOptimization._UpdateSelectionTree;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean which defines if optimization octree has to be updated\r\n */\r\n public static set UpdateSelectionTree(value: boolean) {\r\n MergeMeshesOptimization._UpdateSelectionTree = value;\r\n }\r\n\r\n /**\r\n * Gets a string describing the action executed by the current optimization\r\n * @returns description string\r\n */\r\n public override getDescription(): string {\r\n return \"Merging similar meshes together\";\r\n }\r\n\r\n private _canBeMerged = (abstractMesh: AbstractMesh): boolean => {\r\n if (!(abstractMesh instanceof Mesh)) {\r\n return false;\r\n }\r\n\r\n const mesh = <Mesh>abstractMesh;\r\n\r\n if (mesh.isDisposed()) {\r\n return false;\r\n }\r\n\r\n if (!mesh.isVisible || !mesh.isEnabled()) {\r\n return false;\r\n }\r\n\r\n if (mesh.instances.length > 0) {\r\n return false;\r\n }\r\n\r\n if (mesh.skeleton || mesh.hasLODLevels) {\r\n return false;\r\n }\r\n\r\n if (mesh.getTotalVertices() === 0) {\r\n return false;\r\n }\r\n\r\n return true;\r\n };\r\n\r\n /**\r\n * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization\r\n * @param scene defines the current scene where to apply this optimization\r\n * @param optimizer defines the current optimizer\r\n * @param updateSelectionTree defines that the selection octree has to be updated (false by default)\r\n * @returns true if everything that can be done was applied\r\n */\r\n public override apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean {\r\n const globalPool = scene.meshes.slice(0);\r\n let globalLength = globalPool.length;\r\n\r\n for (let index = 0; index < globalLength; index++) {\r\n const currentPool: Mesh[] = [];\r\n const current = globalPool[index];\r\n\r\n // Checks\r\n if (!this._canBeMerged(current)) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>current);\r\n\r\n // Find compatible meshes\r\n for (let subIndex = index + 1; subIndex < globalLength; subIndex++) {\r\n const otherMesh = globalPool[subIndex];\r\n\r\n if (!this._canBeMerged(otherMesh)) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.material !== current.material) {\r\n continue;\r\n }\r\n\r\n if (otherMesh.checkCollisions !== current.checkCollisions) {\r\n continue;\r\n }\r\n\r\n currentPool.push(<Mesh>otherMesh);\r\n globalLength--;\r\n\r\n globalPool.splice(subIndex, 1);\r\n\r\n subIndex--;\r\n }\r\n\r\n if (currentPool.length < 2) {\r\n continue;\r\n }\r\n\r\n // Merge meshes\r\n Mesh.MergeMeshes(currentPool, undefined, true);\r\n }\r\n\r\n // Call the octree system optimization if it is defined.\r\n const sceneAsAny = scene as any;\r\n if (sceneAsAny.createOrUpdateSelectionOctree) {\r\n if (updateSelectionTree != undefined) {\r\n if (updateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n } else if (MergeMeshesOptimization.UpdateSelectionTree) {\r\n sceneAsAny.createOrUpdateSelectionOctree();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Defines a list of options used by SceneOptimizer\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizerOptions {\r\n /**\r\n * Gets the list of optimizations to apply\r\n */\r\n public optimizations: SceneOptimization[] = [];\r\n\r\n /**\r\n * Creates a new list of options used by SceneOptimizer\r\n * @param targetFrameRate defines the target frame rate to reach (60 by default)\r\n * @param trackerDuration defines the interval between two checks (2000ms by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the target frame rate to reach (60 by default)\r\n */\r\n public targetFrameRate: number = 60,\r\n /**\r\n * Defines the interval between two checks (2000ms by default)\r\n */\r\n public trackerDuration: number = 2000\r\n ) {}\r\n\r\n /**\r\n * Add a new optimization\r\n * @param optimization defines the SceneOptimization to add to the list of active optimizations\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addOptimization(optimization: SceneOptimization): SceneOptimizerOptions {\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a new custom optimization\r\n * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)\r\n * @param onGetDescription defines the callback called to get the description attached with the optimization.\r\n * @param priority defines the priority of this optimization (0 by default which means first in the list)\r\n * @returns the current SceneOptimizerOptions\r\n */\r\n public addCustomOptimization(onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean, onGetDescription: () => string, priority: number = 0): SceneOptimizerOptions {\r\n const optimization = new CustomOptimization(priority);\r\n optimization.onApply = onApply;\r\n optimization.onGetDescription = onGetDescription;\r\n\r\n this.optimizations.push(optimization);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 1024));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 512));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 2));\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual\r\n * @param targetFrameRate defines the target frame rate (60 by default)\r\n * @returns a SceneOptimizerOptions object\r\n */\r\n public static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions {\r\n const result = new SceneOptimizerOptions(targetFrameRate);\r\n\r\n let priority = 0;\r\n result.addOptimization(new MergeMeshesOptimization(priority));\r\n result.addOptimization(new ShadowsOptimization(priority));\r\n result.addOptimization(new LensFlaresOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new PostProcessesOptimization(priority));\r\n result.addOptimization(new ParticlesOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new TextureOptimization(priority, 256));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new RenderTargetsOptimization(priority));\r\n\r\n // Next priority\r\n priority++;\r\n result.addOptimization(new HardwareScalingOptimization(priority, 4));\r\n\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n * Class used to run optimizations in order to reach a target frame rate\r\n * @description More details at https://doc.babylonjs.com/features/featuresDeepDive/scene/sceneOptimizer\r\n */\r\nexport class SceneOptimizer implements IDisposable {\r\n private _isRunning = false;\r\n private _options: SceneOptimizerOptions;\r\n private _scene: Scene;\r\n private _currentPriorityLevel = 0;\r\n private _targetFrameRate = 60;\r\n private _trackerDuration = 2000;\r\n private _currentFrameRate = 0;\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n private _improvementMode = false;\r\n\r\n /**\r\n * Defines an observable called when the optimizer reaches the target frame rate\r\n */\r\n public onSuccessObservable = new Observable<SceneOptimizer>();\r\n /**\r\n * Defines an observable called when the optimizer enables an optimization\r\n */\r\n public onNewOptimizationAppliedObservable = new Observable<SceneOptimization>();\r\n /**\r\n * Defines an observable called when the optimizer is not able to reach the target frame rate\r\n */\r\n public onFailureObservable = new Observable<SceneOptimizer>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the optimizer is in improvement mode\r\n */\r\n public get isInImprovementMode(): boolean {\r\n return this._improvementMode;\r\n }\r\n\r\n public set isInImprovementMode(value: boolean) {\r\n this._improvementMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current priority level (0 at start)\r\n */\r\n public get currentPriorityLevel(): number {\r\n return this._currentPriorityLevel;\r\n }\r\n\r\n /**\r\n * Gets the current frame rate checked by the SceneOptimizer\r\n */\r\n public get currentFrameRate(): number {\r\n return this._currentFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public get targetFrameRate(): number {\r\n return this._targetFrameRate;\r\n }\r\n\r\n /**\r\n * Gets or sets the current target frame rate (60 by default)\r\n */\r\n public set targetFrameRate(value: number) {\r\n this._targetFrameRate = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public get trackerDuration(): number {\r\n return this._trackerDuration;\r\n }\r\n\r\n /**\r\n * Gets or sets the current interval between two checks (every 2000ms by default)\r\n */\r\n public set trackerDuration(value: number) {\r\n this._trackerDuration = value;\r\n }\r\n\r\n /**\r\n * Gets the list of active optimizations\r\n */\r\n public get optimizations(): SceneOptimization[] {\r\n return this._options.optimizations;\r\n }\r\n\r\n /**\r\n * Creates a new SceneOptimizer\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)\r\n * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)\r\n */\r\n public constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities = true, improvementMode = false) {\r\n if (!options) {\r\n this._options = new SceneOptimizerOptions();\r\n } else {\r\n this._options = options;\r\n }\r\n\r\n if (this._options.targetFrameRate) {\r\n this._targetFrameRate = this._options.targetFrameRate;\r\n }\r\n\r\n if (this._options.trackerDuration) {\r\n this._trackerDuration = this._options.trackerDuration;\r\n }\r\n\r\n if (autoGeneratePriorities) {\r\n let priority = 0;\r\n for (const optim of this._options.optimizations) {\r\n optim.priority = priority++;\r\n }\r\n }\r\n\r\n this._improvementMode = improvementMode;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\r\n this._sceneDisposeObserver = null;\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Stops the current optimizer\r\n */\r\n public stop() {\r\n this._isRunning = false;\r\n }\r\n\r\n /**\r\n * Reset the optimizer to initial step (current priority level = 0)\r\n */\r\n public reset() {\r\n this._currentPriorityLevel = 0;\r\n }\r\n\r\n /**\r\n * Start the optimizer. By default it will try to reach a specific framerate\r\n * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate\r\n */\r\n public start() {\r\n if (this._isRunning) {\r\n return;\r\n }\r\n\r\n this._isRunning = true;\r\n\r\n // Let's wait for the scene to be ready before running our check\r\n this._scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n private _checkCurrentState() {\r\n if (!this._isRunning) {\r\n return;\r\n }\r\n\r\n const scene = this._scene;\r\n const options = this._options;\r\n\r\n this._currentFrameRate = Math.round(scene.getEngine().getFps());\r\n\r\n if ((this._improvementMode && this._currentFrameRate <= this._targetFrameRate) || (!this._improvementMode && this._currentFrameRate >= this._targetFrameRate)) {\r\n this._isRunning = false;\r\n this.onSuccessObservable.notifyObservers(this);\r\n return;\r\n }\r\n\r\n // Apply current level of optimizations\r\n let allDone = true;\r\n let noOptimizationApplied = true;\r\n for (let index = 0; index < options.optimizations.length; index++) {\r\n const optimization = options.optimizations[index];\r\n\r\n if (optimization.priority === this._currentPriorityLevel) {\r\n noOptimizationApplied = false;\r\n allDone = allDone && optimization.apply(scene, this);\r\n this.onNewOptimizationAppliedObservable.notifyObservers(optimization);\r\n }\r\n }\r\n\r\n // If no optimization was applied, this is a failure :(\r\n if (noOptimizationApplied) {\r\n this._isRunning = false;\r\n this.onFailureObservable.notifyObservers(this);\r\n\r\n return;\r\n }\r\n\r\n // If all optimizations were done, move to next level\r\n if (allDone) {\r\n this._currentPriorityLevel++;\r\n }\r\n\r\n // Let's the system running for a specific amount of time before checking FPS\r\n scene.executeWhenReady(() => {\r\n setTimeout(() => {\r\n this._checkCurrentState();\r\n }, this._trackerDuration);\r\n });\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this.stop();\r\n this.onSuccessObservable.clear();\r\n this.onFailureObservable.clear();\r\n this.onNewOptimizationAppliedObservable.clear();\r\n if (this._sceneDisposeObserver) {\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to create a SceneOptimizer with one single line of code\r\n * @param scene defines the scene to work on\r\n * @param options defines the options to use with the SceneOptimizer\r\n * @param onSuccess defines a callback to call on success\r\n * @param onFailure defines a callback to call on failure\r\n * @returns the new SceneOptimizer object\r\n */\r\n public static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer {\r\n const optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);\r\n\r\n if (onSuccess) {\r\n optimizer.onSuccessObservable.add(() => {\r\n onSuccess();\r\n });\r\n }\r\n\r\n if (onFailure) {\r\n optimizer.onFailureObservable.add(() => {\r\n onFailure();\r\n });\r\n }\r\n\r\n optimizer.start();\r\n\r\n return optimizer;\r\n }\r\n}\r\n"]}
@@ -10,7 +10,7 @@ import type { UniformBuffer } from "../../Materials/uniformBuffer";
10
10
  * The emission direction might be randomized.
11
11
  */
12
12
  export declare class ConeParticleEmitter implements IParticleEmitterType {
13
- /** defines how much to randomize the particle direction [0-1] (default is 0) */
13
+ /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
14
14
  directionRandomizer: number;
15
15
  private _radius;
16
16
  private _angle;
@@ -45,7 +45,7 @@ export declare class ConeParticleEmitter implements IParticleEmitterType {
45
45
  * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
46
46
  */
47
47
  constructor(radius?: number, angle?: number,
48
- /** defines how much to randomize the particle direction [0-1] (default is 0) */
48
+ /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
49
49
  directionRandomizer?: number);
50
50
  /**
51
51
  * Called by the particle System when the direction is computed for the created particle.
@@ -42,7 +42,7 @@ export class ConeParticleEmitter {
42
42
  * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
43
43
  */
44
44
  constructor(radius = 1, angle = Math.PI,
45
- /** defines how much to randomize the particle direction [0-1] (default is 0) */
45
+ /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */
46
46
  directionRandomizer = 0) {
47
47
  this.directionRandomizer = directionRandomizer;
48
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAEO,YAAY;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,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,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n if (isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle._localPosition!).normalize();\r\n } else {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = Scalar.RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = Scalar.RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKjD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAEO,YAAY;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC3D;aAAM;YACH,IAAI,CAAC,OA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CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n if (isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle._localPosition!).normalize();\r\n } else {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randY = Scalar.RandomRange(0, this.directionRandomizer);\r\n const randZ = Scalar.RandomRange(0, this.directionRandomizer);\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = Scalar.RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = Scalar.RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = Scalar.RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = Scalar.RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = Scalar.RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}