diff --git a/src/app/tools/tankopedia/[id]/page.tsx b/src/app/tools/tankopedia/[id]/page.tsx index 302fbf22f..3837d6587 100644 --- a/src/app/tools/tankopedia/[id]/page.tsx +++ b/src/app/tools/tankopedia/[id]/page.tsx @@ -33,6 +33,7 @@ import { Flag } from '../../../../components/Flag'; import { ModuleButtons } from '../../../../components/ModuleButton'; import PageWrapper from '../../../../components/PageWrapper'; import { asset } from '../../../../core/blitzkrieg/asset'; +import { resolveJsxTree } from '../../../../core/blitzkrieg/resolveJsxTree'; import { TIER_ROMAN_NUMERALS, tankDefinitions, @@ -131,32 +132,32 @@ export default function Page({ params }: { params: { id: string } }) { - {Object.entries(gltf.nodes).map(([name, node]) => ( + {gltf.scene.children[0].children.map((child) => ( ))} @@ -172,6 +173,50 @@ export default function Page({ params }: { params: { id: string } }) { + + + + {tank.turrets.map((thisTurret) => { + return ( + + + + ); + })} + + + + {turret.guns.map((thisGun, index) => { + return ( + + + + ); + })} + + + + {mode === 'armor' && ( @@ -396,51 +441,6 @@ export default function Page({ params }: { params: { id: string } }) { Modules - - - - {tank.turrets.map((thisTurret) => { - return ( - - - - ); - })} - - - - {turret.guns.map((thisGun, index) => { - return ( - - - - ); - })} - - - diff --git a/src/core/blitzkrieg/resolveJsxTree.tsx b/src/core/blitzkrieg/resolveJsxTree.tsx new file mode 100644 index 000000000..c4800d64d --- /dev/null +++ b/src/core/blitzkrieg/resolveJsxTree.tsx @@ -0,0 +1,36 @@ +import { Mesh, Object3D } from 'three'; + +export function resolveJsxTree(parent: Object3D) { + return parent.children.map((child) => { + if (child.type === 'Mesh') { + return ( + + ); + } + if (child.type === 'Object3D') { + return ( + + ); + } + + throw new TypeError( + `Unhandled three jsx type ${child.type} (${child.name})`, + ); + }); +}