feat: rename to attribute

This commit is contained in:
TrèsAbhi committed 2023-12-24 19:02:47 -06:00
1 parent 99fb44633e
commit 15a8e53e22
3 files changed
+41 -28

No files matched your search

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