Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JustADev1024/threejs-car/llms.txt

Use this file to discover all available pages before exploring further.

Dream Car ships with 16 preset SoundHelix tracks and a live URL input that lets you queue any direct MP3 link without touching a line of code. For a permanent playlist change, you only need to edit one array in index.html.

At runtime (no code changes)

The control panel at the bottom of the screen has a text field and an Add button for adding tracks on the fly:
1

Paste a direct MP3 URL

Type or paste a URL that ends in .mp3 into the input labelled βž• Direct MP3 link (from Newgrounds or other site) and click βž• Add.
2

Select the track

The new track appears at the bottom of the track dropdown. Choose it from the list.
3

Press Play

Click 🎡 Play to start playback. If music is already playing, the active track is swapped immediately.
URL validation rules applied by addCustomTrack():
  • The URL must match /\.mp3($|\?)/i β€” it must end in .mp3, optionally followed by a query string such as ?v=2.
  • Duplicate URLs are silently de-duplicated; the existing entry is selected instead.
  • The server hosting the file must send a permissive CORS header (see the warning below).
Once added, custom tracks appear in the dropdown labelled with a truncated version of their URL (first 40 characters followed by …).
CORS is enforced by the browser. If the server hosting your MP3 does not include an Access-Control-Allow-Origin: * (or matching origin) response header, the browser will block the request and playTrack() will throw an error β€” displaying the alert alertPlayError. This is a browser security requirement and cannot be bypassed from client-side code.

Permanently via source

The 16 default tracks are generated from a single expression near the top of the <script> block:
const presetUrls = Array.from({ length: 16 }, (_, i) => 
    `https://www.soundhelix.com/examples/mp3/SoundHelix-Song-${i+1}.mp3`
);
To replace these with your own tracks, change the expression to a plain array:
const presetUrls = [
    'https://example.com/track1.mp3',
    'https://example.com/track2.mp3',
];
The trackList array is built directly from presetUrls on the next line:
let trackList = presetUrls.map((url, idx) => ({ url, isCustom: false, index: idx }));
Every entry in trackList carries { url, isCustom, index }. The isCustom: false flag means the dropdown will label them using the trackPrefix translation key (see the tip below) rather than showing a URL fragment.

Finding CORS-friendly MP3 sources

Not all audio hosts permit cross-origin playback. These sources are known to work well:
SourceNotes
Newgrounds Audio PortalDirect .mp3 links from audio.ngfiles.com include Access-Control-Allow-Origin: * by design.
Freesound.orgPreview links work when the file is served from their CDN with CORS headers enabled. Verify the direct download URL before embedding.
Self-hosted filesAny static file server configured with Access-Control-Allow-Origin: * works without restriction β€” ideal for full control over your playlist.

Audio settings

All tracks β€” both preset and custom β€” are played through the playTrack() function, which creates a standard HTML Audio object:
function playTrack(url) {
    if (currentAudio) {
        currentAudio.pause();
        currentAudio = null;
    }
    currentAudio = new Audio(url);
    currentAudio.loop = true;
    currentAudio.volume = 0.5; // change this value (0.0–1.0)
    currentAudio.play().then(() => {
        musicPlaying = true;
        updateMusicButton();
    }).catch(e => {
        console.error('Play error:', e);
        musicPlaying = false;
        currentAudio = null;
        alert(t('alertPlayError'));
        updateMusicButton();
    });
}
  • loop = true β€” every track repeats indefinitely until stopped.
  • volume = 0.5 β€” set to any value between 0.0 (silent) and 1.0 (full volume). Change the literal in playTrack() to update the default for all tracks.
Changing the track while music is already playing calls stopMusic() followed by playTrack(), so the new volume takes effect immediately for the incoming track.
Track labels in the dropdown are driven by the translations[lang].trackPrefix key β€” 'Track' in English and 'Π’Ρ€Π΅ΠΊ' in Russian. Custom tracks added at runtime bypass this key and instead display a truncated version of their URL (up to 40 characters, prefixed with customTrackPrefix). If you want cleaner labels for custom tracks, assign a customLabel property directly on the track object after pushing it to trackList.

Build docs developers (and LLMs) love