This commit is contained in:
tresabhi committed 2026-06-13 20:26:43 -05:00
1 parent 028f4230e5
commit c6c0e02fea
3 files changed
+13 -11

No files matched your search

+10 -7
View File
@@ -34,11 +34,11 @@ public class MonoGltf
readonly MaterialBuilder emptyMaterial = new("empty_material"); readonly MaterialBuilder emptyMaterial = new("empty_material");
readonly ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg }; readonly ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
public static readonly Dictionary<string, KnownChannel> knownChannels = new() public static readonly Dictionary<string, KnownChannel[]> knownChannels = new()
{ {
{ "BaseColor", KnownChannel.BaseColor }, { "BaseColor", [KnownChannel.BaseColor] },
{ "Normal", KnownChannel.Normal }, { "Normal", [KnownChannel.Normal] },
{ "RMAO", KnownChannel.MetallicRoughness }, { "RMAO", [KnownChannel.MetallicRoughness, KnownChannel.Occlusion] },
// { "CDE", ?? }, // { "CDE", ?? },
}; };
readonly byte[] stubBytes = File.ReadAllBytes("../game/stub/small.png"); readonly byte[] stubBytes = File.ReadAllBytes("../game/stub/small.png");
@@ -152,7 +152,7 @@ public class MonoGltf
foreach (var parameterTexture in materialData.Parameters.Textures) foreach (var parameterTexture in materialData.Parameters.Textures)
{ {
if (knownChannels.TryGetValue(parameterTexture.Key, out var channel)) if (knownChannels.TryGetValue(parameterTexture.Key, out var channels))
{ {
var texture = parameterTexture.Value; var texture = parameterTexture.Value;
var name = Path.GetFileNameWithoutExtension(texture.GetPathName()); var name = Path.GetFileNameWithoutExtension(texture.GetPathName());
@@ -163,8 +163,11 @@ public class MonoGltf
var uniqueBytes = (byte[])stubBytes.Clone(); var uniqueBytes = (byte[])stubBytes.Clone();
var stubImage = new MemoryImage(uniqueBytes); var stubImage = new MemoryImage(uniqueBytes);
materialBuilder.WithChannelImage(channel, stubImage); foreach (var channel in channels)
materialBuilder.GetChannel(channel).Texture.PrimaryImage.Name = path; {
materialBuilder.WithChannelImage(channel, stubImage);
materialBuilder.GetChannel(channel).Texture.PrimaryImage.Name = path;
}
} }
} }
} }
@@ -18,6 +18,7 @@ export function TankopediaSandbox({ parameters }: TankopediaSandboxProps) {
<div className={styles.sandbox}> <div className={styles.sandbox}>
<Canvas <Canvas
// scene={{ fog: new FogExp2("black", 0.05) }} // scene={{ fog: new FogExp2("black", 0.05) }}
camera={{ fov: 40 }}
shadows shadows
className={styles.canvas} className={styles.canvas}
frameloop="demand" frameloop="demand"
@@ -42,11 +43,11 @@ function Content({ parameters }: TankopediaSandboxProps) {
<primitive object={hull} /> <primitive object={hull} />
</group> </group>
<group position={[0, 0, 5]}> <group position={[19.515463 / 100, 129.6958 / 100, 0.0039617573 / 100]}>
<primitive object={turret} /> <primitive object={turret} />
</group> </group>
<group position={[0, 0, -5]}> <group position={[154.39078 / 100, 178.7401 / 100, 0.11611016 / 100]}>
<primitive object={gun} /> <primitive object={gun} />
</group> </group>
@@ -16,8 +16,6 @@ export function useTankModel(url: string, map: Record<string, boolean>) {
} }
} }
console.log(gltf.nodes);
for (const node of Object.values(gltf.nodes)) { for (const node of Object.values(gltf.nodes)) {
if (node instanceof Mesh) { if (node instanceof Mesh) {
node.castShadow = true; node.castShadow = true;