feat: things?

This commit is contained in:
TrèsAbhi committed 2024-02-19 18:45:43 -06:00
1 parent b883f5b9e2
commit ca030688cb
8 files changed
+83 -57

No files matched your search

+2
View File
@@ -29,6 +29,8 @@ export async function tankArmors(production: boolean) {
const id = toUniqueId(nation, tank.id); const id = toUniqueId(nation, tank.id);
if (id !== 12913) return;
console.log(`Building armor ${id} @ ${nation}/${tankKey}`); console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
const model = await extractArmor(DATA, `${nation}-${tankKey}`); const model = await extractArmor(DATA, `${nation}-${tankKey}`);
+1
View File
@@ -47,6 +47,7 @@ export async function tankIcons(production: boolean) {
const nationVehicleId = tank.id; const nationVehicleId = tank.id;
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1; const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
if (12913 !== id) return;
const parameters = await readYAMLDVPL<TankParameters>( const parameters = await readYAMLDVPL<TankParameters>(
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`, `${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`,
); );
+10 -5
View File
@@ -5,6 +5,7 @@ import { extractModel } from '../../src/core/blitz/extractModel';
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL'; import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { toUniqueId } from '../../src/core/blitz/toUniqueId'; import { toUniqueId } from '../../src/core/blitz/toUniqueId';
import { FileChange } from '../../src/core/blitzkrieg/commitMultipleFiles';
import { AssetCommit } from '../../src/core/github/assetCommit'; import { AssetCommit } from '../../src/core/github/assetCommit';
import { DATA, POI } from './constants'; import { DATA, POI } from './constants';
import { VehicleDefinitionList } from './definitions'; import { VehicleDefinitionList } from './definitions';
@@ -24,6 +25,7 @@ export async function tankModels(production: boolean) {
for (const nationIndex in nations) { for (const nationIndex in nations) {
const nation = nations[nationIndex]; const nation = nations[nationIndex];
const changes: FileChange[] = [];
const assetCommit = new AssetCommit(`tank models ${nation}`, production); const assetCommit = new AssetCommit(`tank models ${nation}`, production);
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`,
@@ -56,14 +58,17 @@ export async function tankModels(production: boolean) {
baseColor, baseColor,
); );
assetCommit.add( changes.push({
`3d/tanks/models/${id}.glb`, path: `3d/tanks/models/${id}.glb`,
Buffer.from(await nodeIO.writeBinary(model)).toString('base64'), content: Buffer.from(await nodeIO.writeBinary(model)).toString(
'base64', 'base64',
); ),
encoding: 'base64',
});
}), }),
); );
assetCommit.push(); assetCommit.push();
// await commitAssets(`tank models ${nation}`, changes, production);
} }
} }
+65 -47
View File
@@ -1,5 +1,5 @@
import { Document, Material, Node, Scene } from '@gltf-transform/core'; import { Document, Material, Node, Scene } from '@gltf-transform/core';
import { range, times } from 'lodash'; import { times } from 'lodash';
import { dirname } from 'path'; import { dirname } from 'path';
import { import {
Matrix4, Matrix4,
@@ -221,59 +221,77 @@ export async function extractModel(
} }
case 'RenderComponent': { case 'RenderComponent': {
let minLODDistanceBatchId: undefined | number; // let minLODDistanceBatchId: undefined | number;
if (component['rc.renderObj']['rb0.lodIndex'] === -1) { // if (component['rc.renderObj']['rb0.lodIndex'] === -1) {
minLODDistanceBatchId = 0; // minLODDistanceBatchId = 0;
} else { // } else {
const lodList = components.find( // const lodList = components.find(
(component) => component['comp.typename'] === 'LodComponent', // (component) => component['comp.typename'] === 'LodComponent',
); // );
if ( // if (
lodList === undefined || // lodList === undefined ||
lodList['comp.typename'] !== 'LodComponent' // type annotation hack // lodList['comp.typename'] !== 'LodComponent' // type annotation hack
) { // ) {
throw new SyntaxError('Missing LodComponent'); // throw new SyntaxError('Missing LodComponent');
} // }
let minLODDistance = Infinity; // let minLODDistance = Infinity;
let isFirstMaxFloat = true; // let isFirstMaxFloat = true;
let lodIndexStreak = 0; // let lodIndexStreak = 0;
let lodIndexStreakIndex: undefined | number = undefined; // let lodIndexStreakIndex: undefined | number = undefined;
range(component['rc.renderObj']['ro.batchCount']).forEach( // range(component['rc.renderObj']['ro.batchCount']).forEach(
(id) => { // (id) => {
const lodIndex = // const lodIndex =
component['rc.renderObj'][`rb${id}.lodIndex`]; // component['rc.renderObj'][`rb${id}.lodIndex`];
const lodDistance = // const lodDistance =
lodList['lc.loddist'][`distance${lodIndex}`]; // lodList['lc.loddist'][`distance${lodIndex}`];
if (lodIndexStreakIndex === lodIndex) { // if (lodIndexStreakIndex === lodIndex) {
lodIndexStreak++; // lodIndexStreak++;
} else { // } else {
lodIndexStreak = 0; // lodIndexStreak = 0;
lodIndexStreakIndex = lodIndex; // lodIndexStreakIndex = lodIndex;
} // }
if ( // if (
lodDistance < minLODDistance || // lodDistance < minLODDistance ||
(lodDistance === minLODDistance && lodIndexStreak > 0) || // (lodDistance === minLODDistance && lodIndexStreak > 0) ||
(lodDistance === MAX_FLOAT32 && isFirstMaxFloat) // (lodDistance === MAX_FLOAT32 && isFirstMaxFloat)
) { // ) {
if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false; // if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false;
minLODDistance = lodDistance; // minLODDistance = lodDistance;
minLODDistanceBatchId = id; // minLODDistanceBatchId = id;
} // }
}, // },
); // );
} // }
const batch = let batch = component['rc.renderObj']['ro.batches']['0000'];
component['rc.renderObj']['ro.batches'][ let polygonGroup = scg.get(batch['rb.datasource'])!;
minLODDistanceBatchId!.toString().padStart(4, '0')
]; Object.values(component['rc.renderObj']['ro.batches']).forEach(
const polygonGroup = scg.get(batch['rb.datasource']); (thisBatch) => {
const thisPolygonGroup = scg.get(thisBatch['rb.datasource']);
if (
thisPolygonGroup &&
thisPolygonGroup.vertices.length >
polygonGroup.vertices.length
) {
batch = thisBatch;
polygonGroup = thisPolygonGroup;
}
},
);
// const batch =
// component['rc.renderObj']['ro.batches'][
// minLODDistanceBatchId!.toString().padStart(4, '0')
// ];
// const polygonGroup = scg.get(batch['rb.datasource']);
if (!polygonGroup) { if (!polygonGroup) {
console.warn( console.warn(
+2
View File
@@ -7,6 +7,8 @@ export async function commitAssets(
) { ) {
console.log(`Committing ${message}...`); console.log(`Committing ${message}...`);
if (changes.length === 0) return;
await commitMultipleFiles( await commitMultipleFiles(
'tresabhi', 'tresabhi',
'blitzkrieg-assets', 'blitzkrieg-assets',
+1 -1
View File
@@ -40,6 +40,6 @@ export const createBlob = throttle(
} }
} }
}, },
1000, (5000 / (60 * 60 * 1000)) * 0.95, // 5% less than max rate
{ trailing: true }, { trailing: true },
); );
@@ -25,5 +25,3 @@ export interface EquipmentDefinitions {
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>( export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
asset('definitions/equipment.cdon.lz4'), asset('definitions/equipment.cdon.lz4'),
); );
equipmentDefinitions.then(console.log);
+2 -2
View File
@@ -212,7 +212,7 @@ export class CdonWriteStream extends WriteStream {
object: CdonValue, object: CdonValue,
stringTable: Map<string, number>, stringTable: Map<string, number>,
) { ) {
if (object === null || object === undefined) { if (object === null) {
this.uint8(ValueType.Null); this.uint8(ValueType.Null);
} else if (typeof object === 'boolean') { } else if (typeof object === 'boolean') {
this.uint8(ValueType.Boolean); this.uint8(ValueType.Boolean);
@@ -289,7 +289,7 @@ export class CdonWriteStream extends WriteStream {
object.forEach((value) => object.forEach((value) =>
this.value(fastStringFormat, value, stringTable), this.value(fastStringFormat, value, stringTable),
); );
} else { } else if (object !== undefined) {
const entries = Object.entries(object); const entries = Object.entries(object);
this.uint8(ValueType.Object); this.uint8(ValueType.Object);