mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: optimized assets
This commit is contained in:
1 parent
00244846cb
commit
7669c2d76b
13 files changed
+75
-78
No files matched your search
@@ -25,5 +25,5 @@ export async function circleFlags(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('circle flags', changes, production);
|
||||
commitAssets('circle flags', changes, production);
|
||||
}
|
||||
@@ -89,5 +89,5 @@ export async function buildConsumableIcons(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('consumable icons', changes, production);
|
||||
commitAssets('consumable icons', changes, production);
|
||||
}
|
||||
@@ -675,7 +675,7 @@ export async function buildDefinitions(production: boolean) {
|
||||
});
|
||||
});
|
||||
|
||||
await commitAssets(
|
||||
commitAssets(
|
||||
'definitions',
|
||||
[
|
||||
{
|
||||
|
||||
@@ -88,5 +88,5 @@ export async function equipmentIcons(production: boolean) {
|
||||
),
|
||||
);
|
||||
|
||||
await commitAssets('equipment icons', changes, production);
|
||||
commitAssets('equipment icons', changes, production);
|
||||
}
|
||||
@@ -22,42 +22,42 @@ const production = argv.includes('--production');
|
||||
|
||||
if (!targets && !allTargets) throw new Error('No target(s) specified');
|
||||
|
||||
if (allTargets || targets?.includes('definitions')) {
|
||||
await buildDefinitions(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('tankIcons')) {
|
||||
await buildTankIcons(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('scratchedFlags')) {
|
||||
await buildScratchedFlags(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('circleFlags')) {
|
||||
await circleFlags(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('tankModels')) {
|
||||
await buildTankModels(production);
|
||||
}
|
||||
|
||||
// no need to await the rest... I have enough ram
|
||||
if (allTargets || targets?.includes('tankArmor')) {
|
||||
buildTankArmors(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('definitions')) {
|
||||
buildDefinitions(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('tankIcons')) {
|
||||
buildTankIcons(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('scratchedFlags')) {
|
||||
buildScratchedFlags(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('circleFlags')) {
|
||||
circleFlags(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('shellIcons')) {
|
||||
await buildShellIcons(production);
|
||||
buildShellIcons(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('moduleIcons')) {
|
||||
await buildModuleIcons(production);
|
||||
buildModuleIcons(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('tankArmor')) {
|
||||
await buildTankArmors(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('equipmentIcons')) {
|
||||
await equipmentIcons(production);
|
||||
equipmentIcons(production);
|
||||
}
|
||||
|
||||
if (allTargets || targets?.includes('consumableIcons')) {
|
||||
await buildConsumableIcons(production);
|
||||
buildConsumableIcons(production);
|
||||
}
|
||||
@@ -28,5 +28,5 @@ export async function buildModuleIcons(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('module icons', changes, production);
|
||||
commitAssets('module icons', changes, production);
|
||||
}
|
||||
@@ -27,5 +27,5 @@ export async function buildScratchedFlags(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('scratched flags', changes, production);
|
||||
commitAssets('scratched flags', changes, production);
|
||||
}
|
||||
@@ -45,5 +45,5 @@ export async function buildShellIcons(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('shell icons', changes, production);
|
||||
commitAssets('shell icons', changes, production);
|
||||
}
|
||||
@@ -19,8 +19,6 @@ export async function buildTankArmors(production: boolean) {
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'germany') return;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
@@ -47,5 +45,5 @@ export async function buildTankArmors(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('tank armor', changes, production);
|
||||
commitAssets('tank armor', changes, production);
|
||||
}
|
||||
@@ -65,5 +65,5 @@ export async function buildTankIcons(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('tank icons', changes, production);
|
||||
commitAssets('tank icons', changes, production);
|
||||
}
|
||||
@@ -18,56 +18,53 @@ interface VehicleCustomization {
|
||||
export async function buildTankModels(production: boolean) {
|
||||
console.log('Building tank models...');
|
||||
|
||||
const changes: FileChange[] = [];
|
||||
const nodeIO = new NodeIO();
|
||||
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then(
|
||||
(nations) => nations.filter((nation) => nation !== 'common'),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'germany') return;
|
||||
for (const nationIndex in nations) {
|
||||
const changes: FileChange[] = [];
|
||||
const nation = nations[nationIndex];
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
const customization = await readXMLDVPL<{ root: VehicleCustomization }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/customization.xml.dvpl`,
|
||||
);
|
||||
const baseColor = customization.root.armorColor
|
||||
.split(' ')
|
||||
.slice(0, 3)
|
||||
.map(Number)
|
||||
.map((channel) => channel / 255) as Vector3Tuple;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
const customization = await readXMLDVPL<{ root: VehicleCustomization }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/customization.xml.dvpl`,
|
||||
);
|
||||
const baseColor = customization.root.armorColor
|
||||
.split(' ')
|
||||
.slice(0, 3)
|
||||
.map(Number)
|
||||
.map((channel) => channel / 255) as Vector3Tuple;
|
||||
await Promise.all(
|
||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||
if (tankKey.includes('tutorial_bot')) return;
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||
if (tankKey.includes('tutorial_bot')) return;
|
||||
const id = toUniqueId(nation, tank.id);
|
||||
|
||||
const id = toUniqueId(nation, tank.id);
|
||||
console.log(`Building model ${id} @ ${nation}/${tankKey}`);
|
||||
|
||||
console.log(`Building model ${id} @ ${nation}/${tankKey}`);
|
||||
const parameters = await readYAMLDVPL<TankParameters>(
|
||||
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`,
|
||||
);
|
||||
const model = await extractModel(
|
||||
DATA,
|
||||
parameters.resourcesPath.blitzModelPath.replace(/\.sc2$/, ''),
|
||||
baseColor,
|
||||
);
|
||||
|
||||
const parameters = await readYAMLDVPL<TankParameters>(
|
||||
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`,
|
||||
);
|
||||
const model = await extractModel(
|
||||
DATA,
|
||||
parameters.resourcesPath.blitzModelPath.replace(/\.sc2$/, ''),
|
||||
baseColor,
|
||||
);
|
||||
changes.push({
|
||||
path: `3d/tanks/models/${id}.glb`,
|
||||
encoding: 'base64',
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
||||
'base64',
|
||||
),
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
changes.push({
|
||||
path: `3d/tanks/models/${id}.glb`,
|
||||
encoding: 'base64',
|
||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
||||
'base64',
|
||||
),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
await commitAssets('tank models', changes, production);
|
||||
await commitAssets(`tank models ${nation}`, changes, production);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user