diff --git a/.github/workflows/tauri-release.yml b/.github/workflows/tauri-release.yml new file mode 100644 index 000000000..38335f968 --- /dev/null +++ b/.github/workflows/tauri-release.yml @@ -0,0 +1,47 @@ +name: 'tauri build and release' + +# This will trigger the action on each push to the `release` branch. +on: + push: + branches: + - main + +jobs: + publish-tauri: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-20.04, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-20.04' + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf + + - name: install frontend dependencies + run: pnpm install + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tagName: __VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version + releaseName: 'Cosmos Journeyer __VERSION__' + releaseBody: 'The new version of Cosmos Journeyer is online at https://barthpaleologue.github.io/CosmosJourneyer/ You can also install the app built using Tauri.' + releaseDraft: true + prerelease: false \ No newline at end of file diff --git a/README.md b/README.md index 601666f3b..ae3288d5b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Cosmos Journeyer can be built as a desktop application using Tauri! First you will need a bazillion dependencies, here is a list of some of them if you are using a Debian base OS: ```bash -sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev libsoup2.4-dev libjavascriptcoregtk-4.0-dev librsvg2-dev +sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev libsoup2.4-dev libjavascriptcoregtk-4.0-dev librsvg2-dev libwebkit2gtk-4.0-dev libappindicator3-dev patchelf ``` Then you can build the application with `pnpm tauri build`. diff --git a/package.json b/package.json index 431e123da..65e5695ab 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1" }, - "version": "1.6.0", + "version": "1.6.1", "description": "CosmosJourneyer", "name": "cosmos-journeyer", "scripts": { diff --git a/src/ts/spaceship/spaceship.ts b/src/ts/spaceship/spaceship.ts index a8b81ff81..211cfbd05 100644 --- a/src/ts/spaceship/spaceship.ts +++ b/src/ts/spaceship/spaceship.ts @@ -357,7 +357,6 @@ export class Spaceship implements Transformable { if (currentForwardSpeed < this.warpDrive.getWarpSpeed()) { this.acceleratingWarpDriveSound.setTargetVolume(1); this.deceleratingWarpDriveSound.setTargetVolume(0); - console.log(this.acceleratingWarpDriveSound.sound.getVolume()); } else { this.deceleratingWarpDriveSound.setTargetVolume(1); this.acceleratingWarpDriveSound.setTargetVolume(0); diff --git a/src/ts/starSystem/starSystemView.ts b/src/ts/starSystem/starSystemView.ts index 4da77b422..3de9a0cf4 100644 --- a/src/ts/starSystem/starSystemView.ts +++ b/src/ts/starSystem/starSystemView.ts @@ -46,6 +46,7 @@ import { getRotationQuaternion, setRotationQuaternion } from "../uberCore/transf import { Observable } from "@babylonjs/core/Misc/observable"; import { NeutronStar } from "../stellarObjects/neutronStar/neutronStar"; import { View } from "../utils/view"; +import { syncCamera } from "../utils/cameraSyncing"; export class StarSystemView implements View { private readonly helmetOverlay: HelmetOverlay; @@ -375,7 +376,7 @@ export class StarSystemView implements View { public render() { this.scene.render(); - this.ui.syncCamera(this.scene.getActiveCamera()); + syncCamera(this.scene.getActiveCamera(), this.ui.camera); this.ui.scene.render(); } diff --git a/src/ts/starmap/starMap.ts b/src/ts/starmap/starMap.ts index 94dce4fd1..f3ffb2272 100644 --- a/src/ts/starmap/starMap.ts +++ b/src/ts/starmap/starMap.ts @@ -51,6 +51,7 @@ import { SystemSeed } from "../utils/systemSeed"; import { NeutronStarModel } from "../stellarObjects/neutronStar/neutronStarModel"; import { View } from "../utils/view"; import { Assets } from "../assets"; +import { syncCamera } from "../utils/cameraSyncing"; export class StarMap implements View { readonly scene: Scene; @@ -552,7 +553,7 @@ export class StarMap implements View { public render() { this.scene.render(); - this.starMapUI.syncCamera(this.controls.getActiveCamera()); + syncCamera(this.controls.getActiveCamera(), this.starMapUI.uiCamera); this.starMapUI.scene.render(); } diff --git a/src/ts/starmap/starMapUI.ts b/src/ts/starmap/starMapUI.ts index 45fbc430b..db783cd33 100644 --- a/src/ts/starmap/starMapUI.ts +++ b/src/ts/starmap/starMapUI.ts @@ -190,15 +190,4 @@ export class StarMapUI { this.namePlate.text = name; this.descriptionPanel.text = text; } - - public syncCamera(camera: Camera) { - this.uiCamera.position = camera.globalPosition; - this.uiCamera.rotationQuaternion = camera.absoluteRotation; - this.uiCamera.onViewMatrixChangedObservable.add(() => { - this.uiCamera.getViewMatrix().copyFrom(camera.getViewMatrix()) - }) - this.uiCamera.fov = camera.fov; - this.uiCamera.minZ = camera.minZ; - this.uiCamera.maxZ = camera.maxZ; - } } diff --git a/src/ts/ui/systemUI.ts b/src/ts/ui/systemUI.ts index 8fef79182..3c6f72504 100644 --- a/src/ts/ui/systemUI.ts +++ b/src/ts/ui/systemUI.ts @@ -87,17 +87,6 @@ export class SystemUI { this.target = object; } - public syncCamera(camera: Camera) { - this.camera.position = camera.globalPosition; - this.camera.rotationQuaternion = camera.absoluteRotation; - this.camera.onViewMatrixChangedObservable.add(() => { - this.camera.getViewMatrix().copyFrom(camera.getViewMatrix()) - }) - this.camera.fov = camera.fov; - this.camera.minZ = camera.minZ; - this.camera.maxZ = camera.maxZ; - } - getTarget() { return this.target; } diff --git a/src/ts/utils/cameraSyncing.ts b/src/ts/utils/cameraSyncing.ts new file mode 100644 index 000000000..030611862 --- /dev/null +++ b/src/ts/utils/cameraSyncing.ts @@ -0,0 +1,28 @@ +import { Camera } from "@babylonjs/core/Cameras/camera"; +import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera"; + +/** + * From a given source camera, computes its position and rotation in world space and applies it to the target camera + * @param sourceCamera The camera to copy the position and rotation from + * @param targetCamera the camera to apply the position and rotation to + * @see https://forum.babylonjs.com/t/gui-linkwithmesh-not-behaving-properly-using-right-handed-system/48089/8 + */ +export function syncCamera(sourceCamera: Camera, targetCamera: FreeCamera) { + targetCamera.position = sourceCamera.globalPosition; + targetCamera.rotationQuaternion = sourceCamera.absoluteRotation; + + targetCamera.fov = sourceCamera.fov; + targetCamera.minZ = sourceCamera.minZ; + targetCamera.maxZ = sourceCamera.maxZ; + + // this is necessary to ensure the view matrix is overwritten + const observer = targetCamera.onViewMatrixChangedObservable.addOnce(() => { + targetCamera.getViewMatrix().copyFrom(sourceCamera.getViewMatrix()); + }); + + // if the camera stay stills, the view matrix is never updated, hence the number of observers keeps growing + // to avoid memory leaks, we remove the observer after the next render + targetCamera.getScene().onAfterRenderObservable.addOnce(() => { + targetCamera.onViewMatrixChangedObservable.remove(observer); + }); +}