-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from BarthPaleologue/WIP
1.6.1 - Fixed memory leak
- Loading branch information
Showing
9 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |