mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: loading number
This commit is contained in:
1 parent
a32ee2a344
commit
019514b699
3 files changed
+37
-16
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { blackA } from '@radix-ui/colors';
|
import { blackA } from '@radix-ui/colors';
|
||||||
import { Flex } from '@radix-ui/themes';
|
import { Flex, Text } from '@radix-ui/themes';
|
||||||
import { PuffLoader } from 'react-spinners';
|
import { PuffLoader } from 'react-spinners';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
@@ -8,11 +8,26 @@ const NAV_HEIGHT = 52.65;
|
|||||||
interface LoaderProps {
|
interface LoaderProps {
|
||||||
naked?: boolean;
|
naked?: boolean;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
progress?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Loader({ naked, color }: LoaderProps) {
|
export function Loader({ naked, color, progress }: LoaderProps) {
|
||||||
const animation = (
|
const animation = (
|
||||||
<PuffLoader color={color ?? theme.colors.solidBackground} />
|
<div style={{ position: 'relative' }}>
|
||||||
|
{progress !== undefined && (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: '50%',
|
||||||
|
top: '50%',
|
||||||
|
transform: 'translate(calc(-50% + 4px), calc(-50% + 4px))',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{Math.round(progress * 100)}%
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<PuffLoader color={color ?? theme.colors.solidBackground} />
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (naked) return animation;
|
if (naked) return animation;
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
import { Card, Flex, Tabs, Theme } from '@radix-ui/themes';
|
import { Card, Flex, Tabs, Theme } from '@radix-ui/themes';
|
||||||
import { Html } from '@react-three/drei';
|
|
||||||
import { Canvas } from '@react-three/fiber';
|
import { Canvas } from '@react-three/fiber';
|
||||||
import { Suspense, use, useEffect, useRef, useState } from 'react';
|
import { Suspense, use, useEffect, useRef, useState } from 'react';
|
||||||
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
||||||
import { Pose, poseEvent } from '../../../../../../core/blitzkrieg/pose';
|
import { Pose, poseEvent } from '../../../../../../core/blitzkrieg/pose';
|
||||||
import { theme } from '../../../../../../stitches.config';
|
|
||||||
import {
|
import {
|
||||||
TankopediaMode,
|
TankopediaMode,
|
||||||
mutateTankopediaTemporary,
|
mutateTankopediaTemporary,
|
||||||
useTankopediaTemporary,
|
useTankopediaTemporary,
|
||||||
} from '../../../../../../stores/tankopedia';
|
} from '../../../../../../stores/tankopedia';
|
||||||
import { Loader } from '../../../../components/Loader';
|
|
||||||
import { Duel } from '../../page';
|
import { Duel } from '../../page';
|
||||||
import { Controls } from '../Control';
|
import { Controls } from '../Control';
|
||||||
import { Lighting } from '../Lighting';
|
import { Lighting } from '../Lighting';
|
||||||
import { QuickEquipments } from '../QuickEquipments';
|
import { QuickEquipments } from '../QuickEquipments';
|
||||||
import { RotationInputs } from '../RotationInputs';
|
import { RotationInputs } from '../RotationInputs';
|
||||||
import { SceneProps } from '../SceneProps';
|
import { SceneProps } from '../SceneProps';
|
||||||
|
import { ModelLoader } from './components/ModelLoader';
|
||||||
import { Options } from './components/Options';
|
import { Options } from './components/Options';
|
||||||
import { TankArmor } from './components/TankArmor';
|
import { TankArmor } from './components/TankArmor';
|
||||||
import { TankModel } from './components/TankModel';
|
import { TankModel } from './components/TankModel';
|
||||||
@@ -164,16 +162,7 @@ export function TankSandbox({ duel }: TankSandboxProps) {
|
|||||||
<SceneProps />
|
<SceneProps />
|
||||||
<Lighting duel={duel} />
|
<Lighting duel={duel} />
|
||||||
|
|
||||||
<Suspense
|
<Suspense fallback={<ModelLoader />}>
|
||||||
fallback={
|
|
||||||
<Html center position={[0, 1.5, 0]}>
|
|
||||||
<Loader
|
|
||||||
naked
|
|
||||||
color={theme.colors.textHighContrast_purple}
|
|
||||||
/>
|
|
||||||
</Html>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<TankModel duel={duel} />
|
<TankModel duel={duel} />
|
||||||
<TankArmor duel={duel} />
|
<TankArmor duel={duel} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Html, useProgress } from '@react-three/drei';
|
||||||
|
import { theme } from '../../../../../../../stitches.config';
|
||||||
|
import { Loader } from '../../../../../components/Loader';
|
||||||
|
|
||||||
|
export function ModelLoader() {
|
||||||
|
const { progress } = useProgress();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Html center position={[0, 1.5, 0]}>
|
||||||
|
<Loader
|
||||||
|
naked
|
||||||
|
color={theme.colors.textHighContrast_purple}
|
||||||
|
progress={progress / 100}
|
||||||
|
/>
|
||||||
|
</Html>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user