mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +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 { asset } from '@blitzkit/core';
|
||||||
import { OrbitControls } from '@react-three/drei';
|
import { OrbitControls } from '@react-three/drei';
|
||||||
import { Canvas, useLoader } from '@react-three/fiber';
|
import { Canvas, useLoader } from '@react-three/fiber';
|
||||||
|
import { MeshBasicMaterial } from 'three';
|
||||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||||
|
import { randInt } from 'three/src/math/MathUtils.js';
|
||||||
|
import { jsxTree } from '../../../../core/blitzkit/jsxTree';
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -24,5 +27,14 @@ export function Page({ id }: PageProps) {
|
|||||||
function Model({ id }: { id: string }) {
|
function Model({ id }: { id: string }) {
|
||||||
const gltf = useLoader(GLTFLoader, asset(`/tanks/${id}/collision/hull.glb`));
|
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 type { GetStaticPaths } from 'astro';
|
||||||
import { awaitableTanks } from '../../../../core/awaitables/tanks';
|
import { awaitableTanksFull } from '../../../../core/awaitables/tanksFull';
|
||||||
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
||||||
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
||||||
import { Page } from './_index';
|
import { Page } from './_index';
|
||||||
|
|
||||||
export const getStaticPaths = (async () => {
|
export const getStaticPaths = (async () => {
|
||||||
const tanks = await awaitableTanks;
|
const tanksFull = await awaitableTanksFull;
|
||||||
const parentPaths = parentGetStaticPaths();
|
const parentPaths = parentGetStaticPaths();
|
||||||
|
|
||||||
return tanks.tanks
|
return tanksFull.tanks
|
||||||
.map((tank) =>
|
.map((tank) =>
|
||||||
parentPaths.map((parent) => ({
|
parentPaths.map((parent) => ({
|
||||||
params: { ...parent.params, slug: tank.slug },
|
params: { ...parent.params, slug: tank.slug },
|
||||||
|
|||||||
@@ -38,17 +38,12 @@ namespace BlitzKit.CLI.Models
|
|||||||
ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
|
ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
|
||||||
staticMesh.TryConvert(out var convertedMesh);
|
staticMesh.TryConvert(out var convertedMesh);
|
||||||
var lod =
|
var lod =
|
||||||
convertedMesh.LODs.Find(lod => !lod.SkipLod) ?? throw new Exception("Failed to find lod0");
|
convertedMesh.LODs.Find(lod => !lod.SkipLod) ?? throw new Exception("Failed to find lod0"); // first non-skippable lod is the highest quality
|
||||||
|
|
||||||
int sectionIndex = 0;
|
|
||||||
foreach (var section in lod.Sections.Value)
|
|
||||||
{
|
|
||||||
sectionIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialBuilder emptyMaterial = new("empty_material");
|
MaterialBuilder emptyMaterial = new("empty_material");
|
||||||
Dictionary<string, MaterialBuilder> namedMaterials = [];
|
Dictionary<string, MaterialBuilder> namedMaterials = [];
|
||||||
|
|
||||||
|
int sectionIndex = 0;
|
||||||
foreach (var section in lod.Sections.Value)
|
foreach (var section in lod.Sections.Value)
|
||||||
{
|
{
|
||||||
ConfiguredMeshBuilder meshBuilder = new($"{staticMesh.Name}_section_{sectionIndex}");
|
ConfiguredMeshBuilder meshBuilder = new($"{staticMesh.Name}_section_{sectionIndex}");
|
||||||
|
|||||||
Reference in new issue
Block a user