-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove animation canvas entirely | move to animation package (#…
…1457) Description --- - most of the work was done in the new ~~[`tari-tower` repo](https://github.com/tari-labs/tari-tower)~~ [`@tari-project/tari-tower` repo](https://github.com/tari-project/tari-tower) - implemented typescript, and converted Classes to modules where i could - fixed type errors - added load/remove tower functions which are exported along with `setAnimationState` and `setAnimationProperties` - built and published as a lib - added [`@tari-project/tari-tower`](https://www.npmjs.com/package/@tari-project/tari-tower) package - removed old webgl build files - updated imports - added extra toggle loading state flag (to help in `useMiningUiStateMachine.ts`) - updated workflows so we can use the package Motivation and Context --- - toggling visual mode previously just hid the canvas, this removes the element entirely + frees up some gpu after removing the WEBGL renderer How Has This Been Tested? --- https://github.com/user-attachments/assets/c9b92155-1edb-4070-95c8-6834a863158a https://github.com/user-attachments/assets/9b9b5c95-73a8-437e-ac1e-052498341f1b https://github.com/user-attachments/assets/2fd12be6-ac7f-45bd-a48c-253a8036a750 What process can a PR reviewer use to test or verify this change? --- - run with visual mode on vs off and see GPU stats Breaking Changes --- - ~~yes, after this is merged you will need to install `@tari-labs/tari-tower` for local development~~ - nope, just `npm ci` after it's merged :3 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced an enhanced visual mode with improved loading indicators and smoother animation transitions powered by an external graphics module. - **Refactor** - Streamlined the page layout by removing embedded graphics initialization code and redundant elements, resulting in more efficient loading and clearer error feedback. - **Style** - Updated styling for key visual elements with revised identifiers to ensure a consistent and polished interface. - **Bug Fixes** - Improved error handling for WebGL support notifications and visual mode toggling. - **Chores** - Updated dependency versions for improved performance and stability. - Removed outdated licensing documentation for texture assets. - Removed unused TypeScript declarations and related files to clean up the codebase. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Brian Pearce <[email protected]>
- Loading branch information
1 parent
39ad3bd
commit 333aa88
Showing
28 changed files
with
265 additions
and
5,057 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 |
---|---|---|
@@ -1 +0,0 @@ | ||
./public/assets/glApp.js | ||
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,33 +1,57 @@ | ||
import { useAppStateStore } from '@app/store/appStateStore'; | ||
import { useMiningStore } from '@app/store/useMiningStore'; | ||
import { setAnimationState } from '@app/visuals'; | ||
import { useEffect } from 'react'; | ||
import { setAnimationState, animationStatus } from '@tari-project/tari-tower'; | ||
import { useMiningMetricsStore } from '@app/store/useMiningMetricsStore.ts'; | ||
import { useAppConfigStore } from '@app/store/useAppConfigStore.ts'; | ||
|
||
export const useUiMiningStateMachine = () => { | ||
const isMiningInitiated = useMiningStore((s) => s.miningInitiated); | ||
const isChangingMode = useMiningStore((s) => s.isChangingMode); | ||
const cpuIsMining = useMiningMetricsStore((s) => s.cpu_mining_status.is_mining); | ||
const gpuIsMining = useMiningMetricsStore((s) => s.gpu_mining_status.is_mining); | ||
const setupComplete = useAppStateStore((s) => s.setupComplete); | ||
const visualMode = useAppConfigStore((s) => s.visual_mode); | ||
const visualModeToggleLoading = useAppConfigStore((s) => s.visualModeToggleLoading); | ||
const isMining = cpuIsMining || gpuIsMining; | ||
|
||
const statusIndex = window?.glApp?.stateManager?.statusIndex; | ||
const indexTrigger = animationStatus; | ||
|
||
useEffect(() => { | ||
const status = window?.glApp?.stateManager?.status; | ||
const notStarted = !status || status == 'not-started' || status == 'stop'; | ||
let isLatestEffect = true; | ||
if (!visualMode || visualModeToggleLoading) return; | ||
const notStarted = !animationStatus || animationStatus == 'not-started'; | ||
if (isMining && notStarted) { | ||
setAnimationState('start'); | ||
// Debounce animation state changes | ||
const timer = setTimeout(() => { | ||
if (isLatestEffect) { | ||
setAnimationState('start'); | ||
} | ||
}, 300); | ||
return () => { | ||
clearTimeout(timer); | ||
isLatestEffect = false; | ||
}; | ||
} | ||
}, [statusIndex, isMining]); | ||
}, [indexTrigger, isMining, visualMode, visualModeToggleLoading]); | ||
|
||
useEffect(() => { | ||
const notStopped = window?.glApp?.stateManager?.status !== 'not-started'; | ||
let isLatestEffect = true; | ||
if (!visualMode || visualModeToggleLoading) return; | ||
const notStopped = animationStatus !== 'not-started'; | ||
const preventStop = !setupComplete || isMiningInitiated || isChangingMode; | ||
const shouldStop = !isMining && notStopped && !preventStop; | ||
if (shouldStop) { | ||
setAnimationState('stop'); | ||
// Debounce animation state changes | ||
const timer = setTimeout(() => { | ||
if (isLatestEffect) { | ||
setAnimationState('stop'); | ||
} | ||
}, 300); | ||
return () => { | ||
clearTimeout(timer); | ||
isLatestEffect = false; | ||
}; | ||
} | ||
}, [statusIndex, setupComplete, isMiningInitiated, isMining, isChangingMode]); | ||
}, [indexTrigger, setupComplete, isMiningInitiated, isMining, isChangingMode, visualMode, visualModeToggleLoading]); | ||
}; |
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
Oops, something went wrong.