@hkdigital/lib-core 0.4.63 → 0.4.64
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.
|
@@ -45,6 +45,9 @@ export default class SceneBase {
|
|
|
45
45
|
/** @type {((progress:SceneLoadingProgress)=>void)[]} */
|
|
46
46
|
#preloadListeners = [];
|
|
47
47
|
|
|
48
|
+
/** @type {SceneLoadingProgress|null} */
|
|
49
|
+
#lastReportedProgress = null;
|
|
50
|
+
|
|
48
51
|
/** @type {SceneLoadingProgress} */
|
|
49
52
|
progress = $derived.by(() => {
|
|
50
53
|
let totalSize = 0;
|
|
@@ -137,11 +140,24 @@ export default class SceneBase {
|
|
|
137
140
|
} // end constructor
|
|
138
141
|
|
|
139
142
|
/**
|
|
140
|
-
* Call preload progress listeners
|
|
143
|
+
* Call preload progress listeners (with deduplication)
|
|
141
144
|
*
|
|
142
145
|
* @param {SceneLoadingProgress} progress
|
|
143
146
|
*/
|
|
144
147
|
#updatePreloadProgressListeners(progress) {
|
|
148
|
+
// Skip if progress hasn't actually changed
|
|
149
|
+
if (this.#lastReportedProgress &&
|
|
150
|
+
this.#lastReportedProgress.totalBytesLoaded === progress.totalBytesLoaded &&
|
|
151
|
+
this.#lastReportedProgress.totalSize === progress.totalSize &&
|
|
152
|
+
this.#lastReportedProgress.sourcesLoaded === progress.sourcesLoaded &&
|
|
153
|
+
this.#lastReportedProgress.numberOfSources === progress.numberOfSources &&
|
|
154
|
+
this.#lastReportedProgress.percentageLoaded === progress.percentageLoaded) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Update last reported progress
|
|
159
|
+
this.#lastReportedProgress = { ...progress };
|
|
160
|
+
|
|
145
161
|
for (const fn of this.#preloadListeners) {
|
|
146
162
|
try {
|
|
147
163
|
fn(progress);
|