diff --git a/public/test/10369.glb b/public/test/10369.glb index fcd99c91d..ac398e97f 100644 Binary files a/public/test/10369.glb and b/public/test/10369.glb differ diff --git a/scripts/buildAssets.ts b/scripts/buildAssets.ts index aac3f19a9..53e02e967 100644 --- a/scripts/buildAssets.ts +++ b/scripts/buildAssets.ts @@ -593,9 +593,9 @@ if (allTargets || targets?.includes('tankModels')) { // if (id !== 15697) continue; // chieftain TODO: investigate vertices stream over read // if (id !== 24609) continue; // concept 1b - if (id !== 16401) continue; // waffle + // if (id !== 16401) continue; // waffle // if (id !== 7425) continue; // isu 152 - // if (id !== 10369) continue; // mino + if (id !== 10369) continue; // mino // if (id !== 4417) continue; // amx m4 mle // if (id !== 7297) continue; // 60tp // if (id !== 1) continue; // t-34 diff --git a/src/core/blitz/extractModel.ts b/src/core/blitz/extractModel.ts index 6320c0ef1..3e66d901b 100644 --- a/src/core/blitz/extractModel.ts +++ b/src/core/blitz/extractModel.ts @@ -1,4 +1,5 @@ import { Document, Material, Node, Scene } from '@gltf-transform/core'; +import { writeFile } from 'fs/promises'; import { range, times } from 'lodash'; import { dirname } from 'path'; import { @@ -14,9 +15,9 @@ import { ScgStream, vertexAttributeVectorSizes } from '../streams/scg'; import { VertexAttribute } from '../streams/scpg'; import { readDVPLFile } from './readDVPLFile'; -// BigInt.prototype.toJSON = function () { -// return this.toString(); -// }; +BigInt.prototype.toJSON = function () { + return this.toString(); +}; const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23); @@ -58,6 +59,8 @@ export async function extractModel( const buffer = document.createBuffer(); const materials = new Map(); + writeFile('test.sc2.json', JSON.stringify(sc2, null, 2)); + // create materials await Promise.all( sc2['#dataNodes'].map(async (node) => { @@ -208,7 +211,7 @@ export async function extractModel( } case 'RenderComponent': { - let minLODDistanceBatchId: undefined | number = undefined; + let minLODDistanceBatchId: undefined | number; if (component['rc.renderObj']['rb0.lodIndex'] === -1) { minLODDistanceBatchId = 0; @@ -226,6 +229,8 @@ export async function extractModel( let minLODDistance = Infinity; let isFirstMaxFloat = true; + let lodIndexStreak = 0; + let lodIndexStreakIndex: undefined | number = undefined; range(component['rc.renderObj']['ro.batchCount']).forEach( (id) => { @@ -234,8 +239,16 @@ export async function extractModel( const lodDistance = lodList['lc.loddist'][`distance${lodIndex}`]; + if (lodIndexStreakIndex === lodIndex) { + lodIndexStreak++; + } else { + lodIndexStreak = 0; + lodIndexStreakIndex = lodIndex; + } + if ( - lodDistance <= minLODDistance || + lodDistance < minLODDistance || + (lodDistance === minLODDistance && lodIndexStreak > 0) || (lodDistance === MAX_FLOAT32 && isFirstMaxFloat) ) { if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false; @@ -246,6 +259,10 @@ export async function extractModel( ); } + if (hierarchy.name === 'chassis_track_L') { + console.log(minLODDistanceBatchId); + } + const batch = component['rc.renderObj']['ro.batches'][ minLODDistanceBatchId!.toString().padStart(4, '0')