diff --git a/renin/package.json b/renin/package.json index bd2b98b..3c25c82 100644 --- a/renin/package.json +++ b/renin/package.json @@ -22,6 +22,7 @@ "@types/three": "^0.144.0", "prettier": "^2.7.1", "rollup": "^2.70.2", + "rollup-plugin-base64": "1.0.1", "rollup-plugin-import-css": "^3.0.3", "rollup-plugin-sourcemaps": "^0.6.3", "rollup-plugin-string": "^3.0.0", diff --git a/renin/rollup.config.ts b/renin/rollup.config.ts index 9bf3901..5dec724 100644 --- a/renin/rollup.config.ts +++ b/renin/rollup.config.ts @@ -1,6 +1,7 @@ import typescript from '@rollup/plugin-typescript'; import { string as stringPlugin } from 'rollup-plugin-string'; import css from 'rollup-plugin-import-css'; +import { base64 } from 'rollup-plugin-base64'; export default { treeshake: false, @@ -17,6 +18,7 @@ export default { stringPlugin({ include: '**/*.glsl', }), + base64({ include: '**/*.mp3' }), css(), ], }; diff --git a/renin/src/renin.ts b/renin/src/renin.ts index 16e545c..2a9258a 100644 --- a/renin/src/renin.ts +++ b/renin/src/renin.ts @@ -28,6 +28,7 @@ import { thirdsOverlayTexture } from './ui/thirdsOverlay'; import { performancePanelTexture } from './ui/performancePanelTexture'; import { ColorManagement } from 'three/src/math/ColorManagement'; import { getSetting, setSetting } from './ui/storedSettings'; +import reninSoundUrl from './ui/renin.mp3'; /* otherwise it won't be added to the build */ export * as vite from './ui/vite'; @@ -247,7 +248,16 @@ export class Renin { this.scene.add(this.audioBar.obj); - this.music.setVolume(getSetting('volume')); + const initialVolume = getSetting('volume'); + this.music.setVolume(initialVolume); + + if (!this.options.productionMode && initialVolume) { + (async () => { + const startupSound = new Audio(); + startupSound.autoplay = true; + startupSound.src = 'data:audio/mp3;base64,' + reninSoundUrl; + })(); + } (async () => { const response = await fetch(options.music.src); diff --git a/renin/src/ui/renin.mp3 b/renin/src/ui/renin.mp3 new file mode 100644 index 0000000..0ff87ab Binary files /dev/null and b/renin/src/ui/renin.mp3 differ diff --git a/renin/yarn.lock b/renin/yarn.lock index cc14d04..4ca343e 100644 --- a/renin/yarn.lock +++ b/renin/yarn.lock @@ -163,7 +163,7 @@ "@rollup/pluginutils" "^4.2.1" resolve "^1.22.1" -"@rollup/pluginutils@^3.0.9": +"@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== @@ -494,6 +494,13 @@ resolve@^1.22.1: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +rollup-plugin-base64@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-base64/-/rollup-plugin-base64-1.0.1.tgz#b3529b94d23baeb66e1e3bffd04477fa792985eb" + integrity sha512-IbdX8fjuXO/Op3hYmRPjVo0VwcSenwsQDaDTFdoe+70B5ZGoLMtr96L2yhHXCfxv7HwZVvxZqLsuWj6VwzRt3g== + dependencies: + "@rollup/pluginutils" "^3.1.0" + rollup-plugin-import-css@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/rollup-plugin-import-css/-/rollup-plugin-import-css-3.0.3.tgz#603c96e5ca55a8b1a1fda94221189f3224532fcf"