1
This commit is contained in:
@@ -4,11 +4,9 @@ import { AppConfig, LayoutSplits, GeneratedPart, Partition } from '../types';
|
||||
|
||||
export const calculateParts = (config: AppConfig, splits: LayoutSplits): GeneratedPart[] => {
|
||||
const parts: GeneratedPart[] = [];
|
||||
|
||||
// ЗАЩИТА ОТ ОШИБОК ДАННЫХ
|
||||
const safeX = Array.isArray(splits?.x) ? splits.x : [];
|
||||
const safeY = Array.isArray(splits?.y) ? splits.y : [];
|
||||
const safePartitions = splits?.partitions || {};
|
||||
const safeParts = splits?.partitions || {};
|
||||
|
||||
const xPoints = [0, ...[...safeX].sort((a, b) => a - b), 1];
|
||||
const yPoints = [0, ...[...safeY].sort((a, b) => a - b), 1];
|
||||
@@ -17,16 +15,13 @@ export const calculateParts = (config: AppConfig, splits: LayoutSplits): Generat
|
||||
|
||||
for (let i = 0; i < xPoints.length - 1; i++) {
|
||||
for (let j = 0; j < yPoints.length - 1; j++) {
|
||||
|
||||
const rawX = xPoints[i] * config.drawer.width;
|
||||
const rawY = yPoints[j] * config.drawer.depth;
|
||||
const rawW = (xPoints[i + 1] - xPoints[i]) * config.drawer.width;
|
||||
const rawD = (yPoints[j + 1] - yPoints[j]) * config.drawer.depth;
|
||||
|
||||
// Получаем перегородки
|
||||
const internalPartitions = safePartitions[`${i}-${j}`] || [];
|
||||
const internalPartitions = safeParts[`${i}-${j}`] || [];
|
||||
|
||||
// Допуски
|
||||
const realWidth = rawW - config.printerTolerance;
|
||||
const realDepth = rawD - config.printerTolerance;
|
||||
const realX = rawX + (config.printerTolerance / 2);
|
||||
@@ -51,8 +46,6 @@ export const calculateParts = (config: AppConfig, splits: LayoutSplits): Generat
|
||||
return parts;
|
||||
};
|
||||
|
||||
// ... Вспомогательные функции (createBinGeometry, exportSTL) ...
|
||||
// (Они остаются без изменений из прошлого ответа, там всё верно)
|
||||
const createRoundedRectShape = (width: number, height: number, radius: number): THREE.Shape => {
|
||||
const shape = new THREE.Shape();
|
||||
const x = -width / 2;
|
||||
|
||||
Reference in New Issue
Block a user