diff --git a/packages/core/src/blitzkit/index.ts b/packages/core/src/blitzkit/index.ts index c198ebfbb..367b8a975 100644 --- a/packages/core/src/blitzkit/index.ts +++ b/packages/core/src/blitzkit/index.ts @@ -48,6 +48,7 @@ export * from './metaSortTank'; export * from './romanize'; export * from './tank'; export * from './tankArmor'; +export * from './tankModel'; export * from './tanks'; export * from './tanksFull'; export * from './youtubers'; diff --git a/packages/core/src/blitzkit/tankModel.ts b/packages/core/src/blitzkit/tankModel.ts new file mode 100644 index 000000000..7b483a9fc --- /dev/null +++ b/packages/core/src/blitzkit/tankModel.ts @@ -0,0 +1,7 @@ +import { fetchPB } from '../protobuf'; +import { TankModel } from '../protos'; +import { asset } from './asset'; + +export function fetchTankModel(id: string) { + return fetchPB(asset(`tanks/${id}/model.pb`), TankModel); +} diff --git a/packages/core/src/protos/tank_model.ts b/packages/core/src/protos/tank_model.ts index ec964443e..a65299cc2 100644 --- a/packages/core/src/protos/tank_model.ts +++ b/packages/core/src/protos/tank_model.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; -import { Vector3 } from "./utils"; +import { Vector3, createBaseVector3 } from "./utils"; export const protobufPackage = "blitzkit"; diff --git a/packages/website/src/pages/api/tanks/[id]/model.json.ts b/packages/website/src/pages/api/tanks/[id]/model.json.ts new file mode 100644 index 000000000..9dea8d413 --- /dev/null +++ b/packages/website/src/pages/api/tanks/[id]/model.json.ts @@ -0,0 +1,16 @@ +import { fetchTankModel } from '@blitzkit/core'; +import type { APIRoute } from 'astro'; + +export { getStaticPaths } from './meta.json'; + +/** + * Returns information on the 3D model of the tank. i.e. how to assemble and + * position the meshes. + * + * @param id The tank id. + * @returns JSON. + */ +export const GET: APIRoute<{}, { id: string }> = async ({ params }) => { + const tank = await fetchTankModel(params.id); + return Response.json(tank); +};