mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: safer unknown component handling
This commit is contained in:
1 parent
001b0c356f
commit
d0d28baee0
3 files changed
+26
-19
No files matched your search
@@ -26,6 +26,11 @@ export async function buildTankModels(production: boolean) {
|
||||
for (const nationIndex in nations) {
|
||||
const changes: FileChange[] = [];
|
||||
const nation = nations[nationIndex];
|
||||
|
||||
if (['china', 'european', 'france', 'germany', 'japan'].includes(nation)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ScgStream, vertexAttributeVectorSizes } from '../streams/scg';
|
||||
import { VertexAttribute } from '../streams/scpg';
|
||||
import { readDVPLFile } from './readDVPLFile';
|
||||
|
||||
const ERROR_ON_UNKNOWN_COMPONENT = false;
|
||||
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
||||
|
||||
export const vertexAttributeGLTFName: Partial<Record<VertexAttribute, string>> =
|
||||
@@ -164,21 +165,6 @@ export async function extractModel(
|
||||
|
||||
components.forEach((component) => {
|
||||
switch (component['comp.typename']) {
|
||||
case 'ScenarioComponent':
|
||||
case 'LodComponent':
|
||||
case 'DecorItemComponent':
|
||||
case 'NewSlotComponent':
|
||||
case 'StateSwitcherComponent':
|
||||
case 'CustomPropertiesComponent':
|
||||
case 'ActionComponent':
|
||||
case 'ParticleEffectComponent':
|
||||
case 'SlotComponent':
|
||||
case 'MotionComponent':
|
||||
case 'TankElementComponent':
|
||||
case 'SkeletonComponent':
|
||||
case 'AnimationComponent':
|
||||
break;
|
||||
|
||||
case 'TransformComponent': {
|
||||
const translation = new Vector3();
|
||||
const rotation = new Quaternion();
|
||||
@@ -336,10 +322,15 @@ export async function extractModel(
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new TypeError(
|
||||
`Unhandled component type: ${component['comp.typename']}`,
|
||||
);
|
||||
default: {
|
||||
const message = `Unhandled component type: ${component['comp.typename']}`;
|
||||
|
||||
if (ERROR_ON_UNKNOWN_COMPONENT) {
|
||||
throw new Error(message);
|
||||
} else {
|
||||
console.warn(`${message}; skipping...`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -271,6 +271,17 @@ export type Component =
|
||||
animation: bigint;
|
||||
animationTimeScale: number;
|
||||
repeatsCount: number;
|
||||
}
|
||||
| {
|
||||
'comp.typename': 'SkeletonJointBindingComponent';
|
||||
count: number;
|
||||
map: Record<
|
||||
string, // 0000, 0001, ...
|
||||
{
|
||||
Uid: string;
|
||||
jointUid: string;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
interface SceneComponents {
|
||||
|
||||
Reference in new issue
Block a user