fix: render live V2X vehicles in Cesium preview

This commit is contained in:
2026-08-25 12:57:35 +08:00
parent bc845444bb
commit 25cf82e7c7
23 changed files with 198 additions and 58 deletions

View File

@@ -12,8 +12,12 @@ const VEHICLE_IDS = [
"truck_a03_001",
];
const LIBRARY_ROOT = path.resolve(__dirname, "..", "..", "assets", "models", "custom", "lowpoly_cars");
const V2X_LIBRARY_ROOT = path.resolve(__dirname, "..", "..", "assets", "models", "v2x-vehicles");
const TEXTURE_NAME = "color_512x512.jpg";
const REVERSED_MODEL_IDS = new Set(["truck_a03_001"]);
// These are the dashboard's published vehicle assets. OBU rendering uses
// 11.glb in CrossCars/index.vue; target vehicles use `${type}${subType}.glb`.
const V2X_VEHICLE_MODEL_NAMES = ["11.glb", "12.glb", "13.glb", "14.glb", "15.glb", "16.glb", "17.glb", "31.glb", "221.glb", "222.glb"];
function writePreviewVehicleLibrary(outDir, fileStem) {
const textureOutput = `${fileStem}-vehicle-texture.jpg`;
@@ -46,4 +50,21 @@ function writePreviewVehicleLibrary(outDir, fileStem) {
});
}
module.exports = { VEHICLE_IDS, REVERSED_MODEL_IDS, writePreviewVehicleLibrary };
function writePreviewV2xVehicleLibrary(outDir) {
const targetDir = path.join(outDir, "v2x-vehicles");
fs.mkdirSync(targetDir, { recursive: true });
for (const modelName of V2X_VEHICLE_MODEL_NAMES) {
const source = path.join(V2X_LIBRARY_ROOT, modelName);
if (!fs.existsSync(source)) throw new Error(`V2X vehicle model not found: ${source}`);
fs.copyFileSync(source, path.join(targetDir, modelName));
}
return V2X_VEHICLE_MODEL_NAMES.map((modelName) => `v2x-vehicles/${modelName}`);
}
module.exports = {
VEHICLE_IDS,
REVERSED_MODEL_IDS,
V2X_VEHICLE_MODEL_NAMES,
writePreviewVehicleLibrary,
writePreviewV2xVehicleLibrary,
};