@hkdigital/lib-core 0.4.59 → 0.4.60
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.
|
@@ -64,11 +64,24 @@ export default class SceneBase {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
let percentageLoaded;
|
|
68
|
+
if (totalSize > 0) {
|
|
69
|
+
// Byte-based progress
|
|
70
|
+
percentageLoaded = Math.round((totalBytesLoaded / totalSize) * 100);
|
|
71
|
+
} else if (numberOfSources > 0) {
|
|
72
|
+
// Source-based progress
|
|
73
|
+
percentageLoaded = Math.round((sourcesLoaded / numberOfSources) * 100);
|
|
74
|
+
} else {
|
|
75
|
+
// No sources to load
|
|
76
|
+
percentageLoaded = 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
return {
|
|
68
80
|
totalBytesLoaded,
|
|
69
81
|
totalSize,
|
|
70
82
|
sourcesLoaded,
|
|
71
|
-
numberOfSources
|
|
83
|
+
numberOfSources,
|
|
84
|
+
percentageLoaded
|
|
72
85
|
};
|
|
73
86
|
});
|
|
74
87
|
|
|
@@ -201,7 +214,7 @@ export default class SceneBase {
|
|
|
201
214
|
// Set up progress tracking with polling
|
|
202
215
|
if (onProgress) {
|
|
203
216
|
progressIntervalId = setInterval(() => {
|
|
204
|
-
if (!isAborted) {
|
|
217
|
+
if (!isAborted && this.state === STATE_LOADING) {
|
|
205
218
|
const currentProgress = this.progress;
|
|
206
219
|
lastSentProgress = currentProgress;
|
|
207
220
|
onProgress(currentProgress);
|
|
@@ -234,17 +247,16 @@ export default class SceneBase {
|
|
|
234
247
|
}
|
|
235
248
|
|
|
236
249
|
if (progressIntervalId) {
|
|
250
|
+
clearInterval(progressIntervalId);
|
|
251
|
+
progressIntervalId = null;
|
|
252
|
+
|
|
237
253
|
if (onProgress) {
|
|
238
254
|
const finalProgress = this.progress;
|
|
239
|
-
//
|
|
240
|
-
if (
|
|
241
|
-
finalProgress.sourcesLoaded !== lastSentProgress.sourcesLoaded ||
|
|
242
|
-
finalProgress.totalBytesLoaded !== lastSentProgress.totalBytesLoaded) {
|
|
255
|
+
// Always send final progress when loading completes
|
|
256
|
+
if (this.loaded) {
|
|
243
257
|
onProgress(finalProgress);
|
|
244
258
|
}
|
|
245
259
|
}
|
|
246
|
-
clearInterval(progressIntervalId);
|
|
247
|
-
progressIntervalId = null;
|
|
248
260
|
}
|
|
249
261
|
|
|
250
262
|
if (isAborted || this.state === STATE_ABORTED) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @property {number} totalSize - Total size across all sources
|
|
5
5
|
* @property {number} sourcesLoaded - Number of sources fully loaded
|
|
6
6
|
* @property {number} numberOfSources - Total number of sources
|
|
7
|
+
* @property {number} percentageLoaded - Loading percentage (0-100)
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
export default {};
|