Refactor readBrushGeometry and update brush creation logic
This commit is contained in:
@@ -121,7 +121,6 @@ import {
|
|||||||
getRadialPrismFaceIds,
|
getRadialPrismFaceIds,
|
||||||
getRadialPrismVertexIds,
|
getRadialPrismVertexIds,
|
||||||
isBoxBrushVolumeMode,
|
isBoxBrushVolumeMode,
|
||||||
isBoxFaceId,
|
|
||||||
isFaceUvRotationQuarterTurns,
|
isFaceUvRotationQuarterTurns,
|
||||||
normalizeRadialPrismSideCount,
|
normalizeRadialPrismSideCount,
|
||||||
normalizeBrushName,
|
normalizeBrushName,
|
||||||
@@ -2071,7 +2070,9 @@ function readBrushGeometry<T extends { vertices: Record<string, unknown> }>(
|
|||||||
throw new Error(`${label}.vertices must be an object.`);
|
throw new Error(`${label}.vertices must be an object.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraVertexKeys = Object.keys(value.vertices).filter(
|
const vertices = value.vertices;
|
||||||
|
|
||||||
|
const extraVertexKeys = Object.keys(vertices).filter(
|
||||||
(vertexId) => !vertexIds.includes(vertexId as WhiteboxVertexId)
|
(vertexId) => !vertexIds.includes(vertexId as WhiteboxVertexId)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2085,7 +2086,7 @@ function readBrushGeometry<T extends { vertices: Record<string, unknown> }>(
|
|||||||
vertices: Object.fromEntries(
|
vertices: Object.fromEntries(
|
||||||
vertexIds.map((vertexId) => [
|
vertexIds.map((vertexId) => [
|
||||||
vertexId,
|
vertexId,
|
||||||
readVec3(value.vertices[vertexId], `${label}.vertices.${vertexId}`)
|
readVec3(vertices[vertexId], `${label}.vertices.${vertexId}`)
|
||||||
])
|
])
|
||||||
) as T["vertices"]
|
) as T["vertices"]
|
||||||
} as T;
|
} as T;
|
||||||
@@ -2183,14 +2184,14 @@ function readBrushes(
|
|||||||
materials,
|
materials,
|
||||||
allowMissingUvState,
|
allowMissingUvState,
|
||||||
WEDGE_FACE_IDS
|
WEDGE_FACE_IDS
|
||||||
)
|
) as ReturnType<typeof createWedgeBrush>["faces"]
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind === "radialPrism") {
|
if (kind === "radialPrism") {
|
||||||
const sideCount = normalizeRadialPrismSideCount(
|
const sideCount = normalizeRadialPrismSideCount(
|
||||||
expectNumber(brushValue.sideCount, `brushes.${brushId}.sideCount`)
|
expectFiniteNumber(brushValue.sideCount, `brushes.${brushId}.sideCount`)
|
||||||
);
|
);
|
||||||
|
|
||||||
brushes[brushId] = createRadialPrismBrush({
|
brushes[brushId] = createRadialPrismBrush({
|
||||||
@@ -2208,7 +2209,7 @@ function readBrushes(
|
|||||||
materials,
|
materials,
|
||||||
allowMissingUvState,
|
allowMissingUvState,
|
||||||
getRadialPrismFaceIds(sideCount)
|
getRadialPrismFaceIds(sideCount)
|
||||||
)
|
) as ReturnType<typeof createRadialPrismBrush>["faces"]
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user