diff --git a/scripts/buildAssets.ts b/scripts/buildAssets.ts index a13ef239c..daf093d6e 100644 --- a/scripts/buildAssets.ts +++ b/scripts/buildAssets.ts @@ -518,7 +518,7 @@ if (allTargets || targets?.includes('tankModels')) { const nationVehicleId = tank.id; const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1; - if (id !== 6225) continue; + if (id !== 15697) continue; console.log(`Building model ${id} @ ${nation}/${tankIndex}`); const parameters = await readYAMLDVPL( diff --git a/src/core/blitz/SCPGStream.ts b/src/core/blitz/SCPGStream.ts index bfbe7dc2a..024ed78f3 100644 --- a/src/core/blitz/SCPGStream.ts +++ b/src/core/blitz/SCPGStream.ts @@ -116,7 +116,7 @@ interface PolygonGroupRaw { vertexFormat: number; vertices: Buffer; } -type BlitzkriegVertex = { type: VertexAttribute; value: number[] }[]; +type BlitzkriegVertex = { attribute: VertexAttribute; value: number[] }[]; interface BlitzkriegPolygonGroup { id: bigint; vertices: BlitzkriegVertex[]; @@ -273,12 +273,20 @@ export class SCPGStream { ).filter((type) => type !== null); for (let index = 0; index < polygonGroupRaw.vertexCount; index++) { - vertices[index] = vertexFormat.map((type) => ({ - type, - value: verticesStream.consumeVectorN( - vertexAttributeVectorSizes[type], - ), - })); + // TODO: ISSUE + vertices[index] = vertexFormat.map((attribute) => { + console.log( + VertexAttribute[attribute], + vertexAttributeVectorSizes[attribute], + ); + + return { + attribute, + value: verticesStream.consumeVectorN( + vertexAttributeVectorSizes[attribute], + ), + }; + }); } return { @@ -549,8 +557,6 @@ export class SCPGStream { ), ); - console.log(textures); - if (textures.baseRMMap) { material.setMetallicRoughnessTexture( document @@ -635,8 +641,13 @@ export class SCPGStream { (index) => hierarchy.components[index.toString().padStart(4, '0')], ); - components.forEach((component, componentIndex) => { + components.forEach((component) => { switch (component['comp.typename']) { + case 'LodComponent': + break; + case 'SlotComponent': + break; + case 'TransformComponent': { const translation = new Vector3(); const rotation = new Quaternion(); @@ -715,19 +726,21 @@ export class SCPGStream { ); } - const indexedVertexTypes: VertexAttribute[] = []; + const indexedVertexAttributes: VertexAttribute[] = []; const unpackedVertices: Partial< Record > = {}; polygonGroup.vertices.forEach((vertex) => { vertex.map((vertexItem) => { - if (!(vertexItem.type in unpackedVertices)) { - unpackedVertices[vertexItem.type] = []; - indexedVertexTypes.push(vertexItem.type); + if (!(vertexItem.attribute in unpackedVertices)) { + unpackedVertices[vertexItem.attribute] = []; + indexedVertexAttributes.push(vertexItem.attribute); } - unpackedVertices[vertexItem.type]!.push(...vertexItem.value); + unpackedVertices[vertexItem.attribute]!.push( + ...vertexItem.value, + ); }); }); @@ -749,18 +762,20 @@ export class SCPGStream { .setIndices(indexAccessor) .setMaterial(material); - indexedVertexTypes.forEach((type) => { - if (!(type in vertexAttributeGLTFName)) return; + indexedVertexAttributes.forEach((attribute) => { + if (!(attribute in vertexAttributeGLTFName)) return; - const vertexSize = vertexAttributeVectorSizes[type]; + const vertexSize = vertexAttributeVectorSizes[attribute]; - if (!primitive.getAttribute(vertexAttributeGLTFName[type]!)) { + if ( + !primitive.getAttribute(vertexAttributeGLTFName[attribute]!) + ) { primitive.setAttribute( - vertexAttributeGLTFName[type]!, + vertexAttributeGLTFName[attribute]!, document .createAccessor() .setType(vertexSize === 1 ? 'SCALAR' : `VEC${vertexSize}`) - .setArray(new Float32Array(unpackedVertices[type]!)) + .setArray(new Float32Array(unpackedVertices[attribute]!)) .setBuffer(buffer), ); } @@ -775,10 +790,10 @@ export class SCPGStream { break; } - // default: - // throw new TypeError( - // `Unhandled component type: ${component['comp.typename']}`, - // ); + default: + throw new TypeError( + `Unhandled component type: ${component['comp.typename']}`, + ); } }); diff --git a/src/core/blitzkrieg/toJpg.ts b/src/core/blitzkrieg/toJpg.ts index bc9a76728..696b6bdf7 100644 --- a/src/core/blitzkrieg/toJpg.ts +++ b/src/core/blitzkrieg/toJpg.ts @@ -39,8 +39,6 @@ export async function toJpg( mergedOptions.invert ? `-diff ${input},DIFFINVERT,255` : '' } -d ${output}`; - console.log(command); - await mkdir('temp/toJpg', { recursive: true }); await writeFile(`temp/toJpg/${id}.${mergedOptions.format}`, inputBuffer); await execPromise(command);