mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: instant model loading
This commit is contained in:
1 parent
db4c207708
commit
11e75e48ce
2 files changed
+45
-24
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
||||||
import { Box, Button, Flex, Heading, Text } from '@radix-ui/themes';
|
import { Box, Button, Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Suspense } from 'react';
|
import { Suspense, useEffect, useState } from 'react';
|
||||||
import { classIcons } from '../../../../../../components/ClassIcon';
|
import { classIcons } from '../../../../../../components/ClassIcon';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
|
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
|
||||||
@@ -20,6 +20,11 @@ export function HeroSection({ id }: { id: number }) {
|
|||||||
: [protagonist.id, antagonist.id];
|
: [protagonist.id, antagonist.id];
|
||||||
const isFullScreen = useFullScreen();
|
const isFullScreen = useFullScreen();
|
||||||
const Icon = classIcons[protagonist.class];
|
const Icon = classIcons[protagonist.class];
|
||||||
|
const [dummyLoader, setDummyLoader] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDummyLoader(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@@ -49,20 +54,24 @@ export function HeroSection({ id }: { id: number }) {
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Heading
|
<Flex gap="4">
|
||||||
size={{ initial: '8', md: '9' }}
|
<Heading size={{ initial: '8', md: '9' }}>
|
||||||
align={{ initial: 'center', md: 'left' }}
|
<Icon style={{ width: '0.75em', height: '0.75em' }} />{' '}
|
||||||
color={
|
</Heading>
|
||||||
protagonist.treeType === 'collector'
|
<Heading
|
||||||
? 'blue'
|
size={{ initial: '8', md: '9' }}
|
||||||
: protagonist.treeType === 'premium'
|
align={{ initial: 'center', md: 'left' }}
|
||||||
? 'amber'
|
color={
|
||||||
: undefined
|
protagonist.treeType === 'collector'
|
||||||
}
|
? 'blue'
|
||||||
>
|
: protagonist.treeType === 'premium'
|
||||||
<Icon style={{ width: '0.75em', height: '0.75em' }} />{' '}
|
? 'amber'
|
||||||
{protagonist.name}
|
: undefined
|
||||||
</Heading>
|
}
|
||||||
|
>
|
||||||
|
{protagonist.name}
|
||||||
|
</Heading>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
<Text color="gray" ml={{ initial: '0', md: '9' }}>
|
<Text color="gray" ml={{ initial: '0', md: '9' }}>
|
||||||
Tier {TIER_ROMAN_NUMERALS[protagonist.tier]}{' '}
|
Tier {TIER_ROMAN_NUMERALS[protagonist.tier]}{' '}
|
||||||
@@ -73,7 +82,6 @@ export function HeroSection({ id }: { id: number }) {
|
|||||||
}{' '}
|
}{' '}
|
||||||
{strings.common.tank_class_short[protagonist.class]}
|
{strings.common.tank_class_short[protagonist.class]}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Flex gap="4" ml={{ initial: '0', md: '9' }} mt="-1">
|
<Flex gap="4" ml={{ initial: '0', md: '9' }} mt="-1">
|
||||||
<Link href="/tools/tankopedia">
|
<Link href="/tools/tankopedia">
|
||||||
<Button variant="ghost" size="1" ml="-1">
|
<Button variant="ghost" size="1" ml="-1">
|
||||||
@@ -108,7 +116,19 @@ export function HeroSection({ id }: { id: number }) {
|
|||||||
>
|
>
|
||||||
<Box width="100%" height="100%" position="absolute">
|
<Box width="100%" height="100%" position="absolute">
|
||||||
<Box width="100%" height="100%">
|
<Box width="100%" height="100%">
|
||||||
<Suspense fallback={<TankSandboxLoader id={id} />}>
|
<TankSandboxLoader
|
||||||
|
id={id}
|
||||||
|
display={dummyLoader ? 'flex' : 'none'}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<TankSandboxLoader
|
||||||
|
id={id}
|
||||||
|
display={dummyLoader ? 'none' : 'flex'}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
<TankSandbox />
|
<TankSandbox />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import { Flex, Progress } from '@radix-ui/themes';
|
import { Flex, FlexProps, Progress } from '@radix-ui/themes';
|
||||||
import { useProgress } from '@react-three/drei';
|
import { useProgress } from '@react-three/drei';
|
||||||
import { tankIcon } from '../../../../../../core/blitzkit/tankIcon';
|
import { tankIcon } from '../../../../../../core/blitzkit/tankIcon';
|
||||||
|
|
||||||
export function TankSandboxLoader({ id }: { id: number }) {
|
type TankSandboxLoaderProps = Omit<FlexProps, 'id'> & {
|
||||||
|
id: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function TankSandboxLoader({ id, ...props }: TankSandboxLoaderProps) {
|
||||||
const data = useProgress();
|
const data = useProgress();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex width="100%" height="100%" align="center" justify="center">
|
<Flex width="100%" height="100%" align="center" justify="center" {...props}>
|
||||||
<img
|
<img src={tankIcon(id)} style={{ height: '60%', filter: 'blur(4px)' }} />
|
||||||
src={tankIcon(id)}
|
|
||||||
style={{ height: '60%', filter: 'blur(4px) grayscale(1)' }}
|
|
||||||
/>
|
|
||||||
<Progress
|
<Progress
|
||||||
size="3"
|
size="3"
|
||||||
value={data.progress}
|
value={data.progress}
|
||||||
|
|||||||
Reference in new issue
Block a user