@@ -8,9 +8,8 @@ import { useProgress } from "@react-three/drei";
8
8
* - a timeout when it reaches > 50%, marked as stuck
9
9
*/
10
10
export const useControlledProgress = ( ) => {
11
- const TIMEOUT = 2000 ; // minimum time to wait before moving to 100
12
- const AFTER_TIME = 100 ; // extra time to prevent bouncing at reaching 100
13
- const STUCK_TIMEOUT = 5500 ; // for safari, when stuck at a value above 50
11
+ const MIN_TIME = 2000 ; // minimum time to wait before moving to 100
12
+ const AFTER_TIME = 300 ; // extra time to prevent bouncing at reaching 100
14
13
15
14
const { progress, total } = useProgress ( ) ;
16
15
@@ -24,7 +23,7 @@ export const useControlledProgress = () => {
24
23
const timeElapsed = newTime . getTime ( ) - startTime . current . getTime ( ) ;
25
24
const diff = Math . min (
26
25
progress - controlledProgress . current ,
27
- timeElapsed < TIMEOUT ? 99 : 100
26
+ timeElapsed < MIN_TIME ? 99 : 100
28
27
) ;
29
28
if ( diff > 0 ) {
30
29
if ( progress === 100 ) {
@@ -41,17 +40,11 @@ export const useControlledProgress = () => {
41
40
} else {
42
41
finished . current = false ;
43
42
controlledProgress . current = progress ;
44
-
45
- // once above 50, skip progress is stuck then skip loading
46
- if ( progress > 50 ) {
47
- setTimeout ( ( ) => {
48
- if ( controlledProgress . current === progress ) {
49
- setSkip ( true ) ;
50
- }
51
- } , STUCK_TIMEOUT ) ;
52
- }
53
43
}
54
44
}
45
+ if ( progress !== 100 ) {
46
+ finished . current = false ;
47
+ }
55
48
} , [ progress ] ) ;
56
49
57
50
// wait TIMEOUT (ms) to check if any objects are waiting to be loaded
@@ -63,7 +56,7 @@ export const useControlledProgress = () => {
63
56
} else if ( counter > 0 ) {
64
57
setSkip ( true ) ;
65
58
} else {
66
- setTimeout ( ( ) => setCounter ( counter + 1 ) , TIMEOUT ) ;
59
+ setTimeout ( ( ) => setCounter ( counter + 1 ) , MIN_TIME ) ;
67
60
}
68
61
} , [ counter ] ) ;
69
62
0 commit comments