You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main.ts
+39-10Lines changed: 39 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,10 @@ import { UnrealBloomPass } from "three/examples/jsm/postprocessing/UnrealBloomPa
12
12
// Set up the scene
13
13
constscene=newTHREE.Scene();
14
14
15
-
// Create atmospheric space background
15
+
/**
16
+
* Creates an atmospheric space background mesh with a gradient and subtle noise effects to simulate a nebula-like space atmosphere, including sparse distant stars.
17
+
* @returns A THREE.Mesh representing the space background.
18
+
*/
16
19
functioncreateSpaceBackground(){
17
20
// Create background geometry - a large sphere that encompasses the scene
letmusicFadeTimeout: number|null=null;// Track fade timeout for cleanup
506
523
507
-
// Load and decode the background music
524
+
/**
525
+
* Loads and decodes the background music file, storing it in the music buffer.
526
+
* Logs an error to the console if loading fails.
527
+
*/
508
528
asyncfunctionloadBackgroundMusic(){
509
529
if(!audioContext)return;
510
530
@@ -517,7 +537,9 @@ async function loadBackgroundMusic() {
517
537
}
518
538
}
519
539
520
-
// Start playing background music
540
+
/**
541
+
* Starts playing the background music if not already playing. Handles fade-in, looping, and restarts music if it ends unexpectedly while the game is running.
0 commit comments