File tree Expand file tree Collapse file tree 3 files changed +54
-157
lines changed Expand file tree Collapse file tree 3 files changed +54
-157
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
import { Canvas } from ' @threlte/core' ;
3
3
import Scene from ' ./Scene.svelte' ;
4
4
import { onMount } from ' svelte' ;
5
+ import { useProgress } from ' @threlte/extras' ;
6
+ import { derived } from ' svelte/store' ;
5
7
6
8
let selectedObject = ' ' ;
7
-
8
9
export let role: string ;
9
10
export let materials: { type: boolean ; file_path: string ; title: string }[] = [];
10
11
17
18
selectedObject = materials .find ((material ) => material .type === true )?.file_path || ' ' ;
18
19
}
19
20
});
21
+
22
+ // Use the `useProgress` hook to track loading state
23
+ const { progress } = useProgress ();
24
+
25
+ // A derived store to track if the loading is complete
26
+ const isLoading = derived (progress , ($progress ) => $progress < 1 );
20
27
</script >
21
28
22
29
<div
33
40
</select >
34
41
</div >
35
42
43
+ {#if $isLoading }
44
+ <div class =" loading-overlay" >
45
+ Loading 3D model... {$progress * 100 }%
46
+ </div >
47
+ {/if }
48
+
36
49
<Canvas >
37
50
<Scene {selectedObject } {role } />
38
51
</Canvas >
48
61
padding : 10px ;
49
62
border-radius : 5px ;
50
63
}
64
+
65
+ .loading-overlay {
66
+ position : absolute ;
67
+ top : 0 ;
68
+ left : 0 ;
69
+ width : 100% ;
70
+ height : 100% ;
71
+ display : flex ;
72
+ justify-content : center ;
73
+ align-items : center ;
74
+ background-color : rgba (0 , 0 , 0 , 0.5 );
75
+ color : white ;
76
+ font-size : 1.5rem ;
77
+ z-index : 2000 ;
78
+ }
51
79
</style >
Original file line number Diff line number Diff line change
1
+ let speechSynthesis : SpeechSynthesis ;
2
+ let speechRate = 1.8 ;
3
+
4
+ if ( typeof window !== 'undefined' ) {
5
+ speechSynthesis = window . speechSynthesis ;
6
+ }
7
+
8
+ export function speak ( text : string ) : void {
9
+ if ( ! speechSynthesis ) return ;
10
+ speechSynthesis . cancel ( ) ;
11
+
12
+ const utterance = new SpeechSynthesisUtterance ( text ) ;
13
+ utterance . rate = speechRate ;
14
+ speechSynthesis . speak ( utterance ) ;
15
+ }
16
+
17
+ export function setRate ( rate : number ) : void {
18
+ speechRate = rate ;
19
+ }
20
+
21
+ export function cancel ( ) : void {
22
+ if ( speechSynthesis ) {
23
+ speechSynthesis . cancel ( ) ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments