mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: hull model
This commit is contained in:
1 parent
e1957daa5c
commit
652f36ba6c
4 files changed
+21
-11
No files matched your search
@@ -0,0 +1,3 @@
|
||||
import { fetchTanksFull } from '@blitzkit/core';
|
||||
|
||||
export const awaitableTanksFull = fetchTanksFull();
|
||||
@@ -1,7 +1,10 @@
|
||||
import { asset } from '@blitzkit/core';
|
||||
import { OrbitControls } from '@react-three/drei';
|
||||
import { Canvas, useLoader } from '@react-three/fiber';
|
||||
import { MeshBasicMaterial } from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
import { randInt } from 'three/src/math/MathUtils.js';
|
||||
import { jsxTree } from '../../../../core/blitzkit/jsxTree';
|
||||
|
||||
interface PageProps {
|
||||
id: string;
|
||||
@@ -24,5 +27,14 @@ export function Page({ id }: PageProps) {
|
||||
function Model({ id }: { id: string }) {
|
||||
const gltf = useLoader(GLTFLoader, asset(`/tanks/${id}/collision/hull.glb`));
|
||||
|
||||
return <primitive object={gltf.scene} />;
|
||||
return jsxTree(gltf.scene, {
|
||||
mesh: () => ({
|
||||
material: new MeshBasicMaterial({
|
||||
color: `rgb(${randInt(0, 255)}, ${randInt(0, 255)}, ${randInt(
|
||||
0,
|
||||
255,
|
||||
)})`,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
import type { GetStaticPaths } from 'astro';
|
||||
import { awaitableTanks } from '../../../../core/awaitables/tanks';
|
||||
import { awaitableTanksFull } from '../../../../core/awaitables/tanksFull';
|
||||
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 tanksFull = await awaitableTanksFull;
|
||||
const parentPaths = parentGetStaticPaths();
|
||||
|
||||
return tanks.tanks
|
||||
return tanksFull.tanks
|
||||
.map((tank) =>
|
||||
parentPaths.map((parent) => ({
|
||||
params: { ...parent.params, slug: tank.slug },
|
||||
|
||||
@@ -38,17 +38,12 @@ namespace BlitzKit.CLI.Models
|
||||
ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
|
||||
staticMesh.TryConvert(out var convertedMesh);
|
||||
var lod =
|
||||
convertedMesh.LODs.Find(lod => !lod.SkipLod) ?? throw new Exception("Failed to find lod0");
|
||||
|
||||
int sectionIndex = 0;
|
||||
foreach (var section in lod.Sections.Value)
|
||||
{
|
||||
sectionIndex++;
|
||||
}
|
||||
convertedMesh.LODs.Find(lod => !lod.SkipLod) ?? throw new Exception("Failed to find lod0"); // first non-skippable lod is the highest quality
|
||||
|
||||
MaterialBuilder emptyMaterial = new("empty_material");
|
||||
Dictionary<string, MaterialBuilder> namedMaterials = [];
|
||||
|
||||
int sectionIndex = 0;
|
||||
foreach (var section in lod.Sections.Value)
|
||||
{
|
||||
ConfiguredMeshBuilder meshBuilder = new($"{staticMesh.Name}_section_{sectionIndex}");
|
||||
|
||||
Reference in new issue
Block a user