mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: collision rendering
This commit is contained in:
1 parent
6a91e86b07
commit
f52460e98b
3 files changed
+62
-5
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { asset } from '@blitzkit/core';
|
||||
import { OrbitControls } from '@react-three/drei';
|
||||
import { Canvas, useLoader } from '@react-three/fiber';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
|
||||
interface PageProps {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export function Page({ id }: PageProps) {
|
||||
return (
|
||||
<Canvas
|
||||
style={{
|
||||
width: 640,
|
||||
height: 640,
|
||||
}}
|
||||
>
|
||||
<OrbitControls />
|
||||
<Model id={id} />
|
||||
</Canvas>
|
||||
);
|
||||
}
|
||||
|
||||
function Model({ id }: { id: string }) {
|
||||
const gltf = useLoader(GLTFLoader, asset(`/tanks/${id}/collision/hull.glb`));
|
||||
|
||||
return <primitive object={gltf.scene} />;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import type { GetStaticPaths } from 'astro';
|
||||
import { awaitableTanks } from '../../../../core/awaitables/tanks';
|
||||
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
||||
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
||||
import { Page } from './_index';
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
const tanks = await awaitableTanks;
|
||||
const parentPaths = parentGetStaticPaths();
|
||||
|
||||
return tanks.tanks
|
||||
.map((tank) =>
|
||||
parentPaths.map((parent) => ({
|
||||
params: { ...parent.params, slug: tank.slug },
|
||||
props: { id: tank.id },
|
||||
})),
|
||||
)
|
||||
.flat();
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { id } = Astro.props;
|
||||
---
|
||||
|
||||
<BaseLayout>
|
||||
<Page {id} client:load />
|
||||
</BaseLayout>
|
||||
@@ -15,11 +15,13 @@ const tanks = await awaitableTanks;
|
||||
<ToolLayout tool={tanksTool}>
|
||||
<PageWrapper>
|
||||
{
|
||||
tanks.tanks.map((tank) => (
|
||||
<LinkI18n {locale} href={`/tanks/${tank.slug}`}>
|
||||
{tank.slug} ({tank.id})
|
||||
</LinkI18n>
|
||||
))
|
||||
tanks.tanks
|
||||
.sort((a, b) => a.slug.localeCompare(b.slug))
|
||||
.map((tank) => (
|
||||
<LinkI18n {locale} href={`/tanks/${tank.slug}`}>
|
||||
{tank.slug}
|
||||
</LinkI18n>
|
||||
))
|
||||
}
|
||||
</PageWrapper>
|
||||
</ToolLayout>
|
||||
Reference in new issue
Block a user