mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: omition
This commit is contained in:
1 parent
d4e16048e9
commit
c9d5b46ae8
2 files changed
+97
-61
No files matched your search
@@ -33,6 +33,7 @@ import { Flag } from '../../../../components/Flag';
|
|||||||
import { ModuleButtons } from '../../../../components/ModuleButton';
|
import { ModuleButtons } from '../../../../components/ModuleButton';
|
||||||
import PageWrapper from '../../../../components/PageWrapper';
|
import PageWrapper from '../../../../components/PageWrapper';
|
||||||
import { asset } from '../../../../core/blitzkrieg/asset';
|
import { asset } from '../../../../core/blitzkrieg/asset';
|
||||||
|
import { resolveJsxTree } from '../../../../core/blitzkrieg/resolveJsxTree';
|
||||||
import {
|
import {
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
@@ -131,32 +132,32 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
</EffectComposer>
|
</EffectComposer>
|
||||||
|
|
||||||
<group ref={model} rotation={[-Math.PI / 2, 0, 0]}>
|
<group ref={model} rotation={[-Math.PI / 2, 0, 0]}>
|
||||||
{Object.entries(gltf.nodes).map(([name, node]) => (
|
{gltf.scene.children[0].children.map((child) => (
|
||||||
<mesh
|
<mesh
|
||||||
visible={
|
visible={
|
||||||
name === 'hull' ||
|
child.name === 'hull' ||
|
||||||
name.startsWith('chassis_track_') ||
|
child.name.startsWith('chassis_track_') ||
|
||||||
name.startsWith('chassis_wheel_') ||
|
child.name.startsWith('chassis_wheel_') ||
|
||||||
(name.startsWith('turret_') &&
|
(child.name.startsWith('turret_') &&
|
||||||
name ===
|
child.name ===
|
||||||
`turret_${turret.model
|
`turret_${turret.model
|
||||||
.toString()
|
.toString()
|
||||||
.padStart(2, '0')}`) ||
|
.padStart(2, '0')}`) ||
|
||||||
(name.startsWith('gun_') &&
|
(child.name.startsWith('gun_') &&
|
||||||
name ===
|
child.name ===
|
||||||
`gun_${gun.model.toString().padStart(2, '0')}`) ||
|
`gun_${gun.model.toString().padStart(2, '0')}`) ||
|
||||||
name ===
|
child.name ===
|
||||||
`gun_${gun.model.toString().padStart(2, '0')}_mask`
|
`gun_${gun.model.toString().padStart(2, '0')}_mask`
|
||||||
}
|
}
|
||||||
name={name}
|
children={resolveJsxTree(child as Mesh)}
|
||||||
key={node.id}
|
key={child.uuid}
|
||||||
castShadow
|
castShadow
|
||||||
receiveShadow
|
receiveShadow
|
||||||
geometry={(node as Mesh).geometry}
|
geometry={(child as Mesh).geometry}
|
||||||
material={(node as Mesh).material}
|
material={(child as Mesh).material}
|
||||||
position={node.position}
|
position={child.position}
|
||||||
rotation={node.rotation}
|
rotation={child.rotation}
|
||||||
scale={node.scale}
|
scale={child.scale}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</group>
|
</group>
|
||||||
@@ -172,6 +173,50 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Theme radius="small">
|
||||||
|
<Flex gap="4">
|
||||||
|
<Flex gap="1">
|
||||||
|
{tank.turrets.map((thisTurret) => {
|
||||||
|
return (
|
||||||
|
<Tooltip content={thisTurret.name}>
|
||||||
|
<Button
|
||||||
|
onClick={() => setTurret(thisTurret)}
|
||||||
|
variant={turret.id === thisTurret.id ? 'solid' : 'soft'}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={asset('icons/modules/turret.webp')}
|
||||||
|
width={32}
|
||||||
|
height={32}
|
||||||
|
/>
|
||||||
|
{TIER_ROMAN_NUMERALS[thisTurret.tier]}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex gap="1">
|
||||||
|
{turret.guns.map((thisGun, index) => {
|
||||||
|
return (
|
||||||
|
<Tooltip content={thisGun.name}>
|
||||||
|
<Button
|
||||||
|
onClick={() => setGun(thisGun)}
|
||||||
|
variant={gun.id === thisGun.id ? 'solid' : 'soft'}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={asset('icons/modules/gun.webp')}
|
||||||
|
width={32}
|
||||||
|
height={32}
|
||||||
|
/>
|
||||||
|
{TIER_ROMAN_NUMERALS[thisGun.tier]}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
</Theme>
|
||||||
|
|
||||||
{mode === 'armor' && (
|
{mode === 'armor' && (
|
||||||
<Card>
|
<Card>
|
||||||
<Flex align="center" justify="between" gap="2">
|
<Flex align="center" justify="between" gap="2">
|
||||||
@@ -396,51 +441,6 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
<Heading size="5" weight="regular">
|
<Heading size="5" weight="regular">
|
||||||
Modules
|
Modules
|
||||||
</Heading>
|
</Heading>
|
||||||
<Theme radius="small">
|
|
||||||
<Flex gap="4">
|
|
||||||
<Flex gap="1">
|
|
||||||
{tank.turrets.map((thisTurret) => {
|
|
||||||
return (
|
|
||||||
<Tooltip content={thisTurret.name}>
|
|
||||||
<Button
|
|
||||||
onClick={() => setTurret(thisTurret)}
|
|
||||||
variant={
|
|
||||||
turret.id === thisTurret.id ? 'solid' : 'soft'
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/images/modules/turret.png"
|
|
||||||
width={32}
|
|
||||||
height={32}
|
|
||||||
/>
|
|
||||||
{TIER_ROMAN_NUMERALS[thisTurret.tier]}
|
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex gap="1">
|
|
||||||
{turret.guns.map((thisGun, index) => {
|
|
||||||
return (
|
|
||||||
<Tooltip content={thisGun.name}>
|
|
||||||
<Button
|
|
||||||
onClick={() => setGun(thisGun)}
|
|
||||||
variant={gun.id === thisGun.id ? 'solid' : 'soft'}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src="/images/modules/gun.png"
|
|
||||||
width={32}
|
|
||||||
height={32}
|
|
||||||
/>
|
|
||||||
{TIER_ROMAN_NUMERALS[thisGun.tier]}
|
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
</Theme>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex gap="2" direction="column">
|
<Flex gap="2" direction="column">
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Mesh, Object3D } from 'three';
|
||||||
|
|
||||||
|
export function resolveJsxTree(parent: Object3D) {
|
||||||
|
return parent.children.map((child) => {
|
||||||
|
if (child.type === 'Mesh') {
|
||||||
|
return (
|
||||||
|
<mesh
|
||||||
|
key={child.uuid}
|
||||||
|
castShadow
|
||||||
|
receiveShadow
|
||||||
|
geometry={(child as Mesh).geometry}
|
||||||
|
material={(child as Mesh).material}
|
||||||
|
position={child.position}
|
||||||
|
rotation={child.rotation}
|
||||||
|
scale={child.scale}
|
||||||
|
children={resolveJsxTree(child)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (child.type === 'Object3D') {
|
||||||
|
return (
|
||||||
|
<group
|
||||||
|
key={child.uuid}
|
||||||
|
position={child.position}
|
||||||
|
rotation={child.rotation}
|
||||||
|
scale={child.scale}
|
||||||
|
children={resolveJsxTree(child)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new TypeError(
|
||||||
|
`Unhandled three jsx type ${child.type} (${child.name})`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in new issue
Block a user