mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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) {
|
for (const nationIndex in nations) {
|
||||||
const changes: FileChange[] = [];
|
const changes: FileChange[] = [];
|
||||||
const nation = nations[nationIndex];
|
const nation = nations[nationIndex];
|
||||||
|
|
||||||
|
if (['china', 'european', 'france', 'germany', 'japan'].includes(nation)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { ScgStream, vertexAttributeVectorSizes } from '../streams/scg';
|
|||||||
import { VertexAttribute } from '../streams/scpg';
|
import { VertexAttribute } from '../streams/scpg';
|
||||||
import { readDVPLFile } from './readDVPLFile';
|
import { readDVPLFile } from './readDVPLFile';
|
||||||
|
|
||||||
|
const ERROR_ON_UNKNOWN_COMPONENT = false;
|
||||||
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
||||||
|
|
||||||
export const vertexAttributeGLTFName: Partial<Record<VertexAttribute, string>> =
|
export const vertexAttributeGLTFName: Partial<Record<VertexAttribute, string>> =
|
||||||
@@ -164,21 +165,6 @@ export async function extractModel(
|
|||||||
|
|
||||||
components.forEach((component) => {
|
components.forEach((component) => {
|
||||||
switch (component['comp.typename']) {
|
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': {
|
case 'TransformComponent': {
|
||||||
const translation = new Vector3();
|
const translation = new Vector3();
|
||||||
const rotation = new Quaternion();
|
const rotation = new Quaternion();
|
||||||
@@ -336,10 +322,15 @@ export async function extractModel(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
throw new TypeError(
|
const message = `Unhandled component type: ${component['comp.typename']}`;
|
||||||
`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;
|
animation: bigint;
|
||||||
animationTimeScale: number;
|
animationTimeScale: number;
|
||||||
repeatsCount: number;
|
repeatsCount: number;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
'comp.typename': 'SkeletonJointBindingComponent';
|
||||||
|
count: number;
|
||||||
|
map: Record<
|
||||||
|
string, // 0000, 0001, ...
|
||||||
|
{
|
||||||
|
Uid: string;
|
||||||
|
jointUid: string;
|
||||||
|
}
|
||||||
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SceneComponents {
|
interface SceneComponents {
|
||||||
|
|||||||
Reference in new issue
Block a user