Fixed layout step

This commit is contained in:
Халимов Рустам
2025-12-27 23:06:22 +03:00
parent 8999d1f06a
commit 6c6c859a3b
3 changed files with 169 additions and 233 deletions

View File

@@ -16,17 +16,14 @@ export const calculateParts = (
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 subdiv = splits.subdivisions?.[`${i}-${j}`] || { rows: 1, cols: 1 };
// Вычисляем размер одной "под-ячейки"
// Делим общую ширину на кол-во колонок
const subCellWidth = rawW / subdiv.cols;
const subCellDepth = rawD / subdiv.rows;
@@ -37,7 +34,6 @@ export const calculateParts = (
const subX = rawX + (c * subCellWidth);
const subY = rawY + (r * subCellDepth);
// Применяем Tolerance (зазор) к каждой микро-ячейке
const realWidth = subCellWidth - config.printerTolerance;
const realDepth = subCellDepth - config.printerTolerance;
const realX = subX + (config.printerTolerance / 2);
@@ -45,9 +41,15 @@ export const calculateParts = (
if (realWidth < 5 || realDepth < 5) continue;
// Формируем имя: если ячейка поделена, добавляем индексы (1-1, 1-2...)
let partName = `Ячейка ${i+1}-${j+1}`;
if (subdiv.rows > 1 || subdiv.cols > 1) {
partName += ` (${r+1}-${c+1})`;
}
parts.push({
id: `part-${partCounter}`,
name: `Ячейка ${i+1}-${j+1}` + (subdiv.rows > 1 || subdiv.cols > 1 ? ` (${r+1}x${c+1})` : ''),
name: partName,
width: realWidth,
depth: realDepth,
height: config.drawer.height,
@@ -64,8 +66,7 @@ export const calculateParts = (
return parts;
};
// ... Остальной код (createBinGeometry, exportSTL) остается без изменений ...
// (Копируй функции createRoundedRectShape, createBinGeometry и прочие из предыдущего файла, они не менялись)
// ... Вспомогательные функции генерации геометрии (без изменений) ...
const createRoundedRectShape = (width: number, height: number, radius: number): THREE.Shape => {
const shape = new THREE.Shape();
const x = -width / 2;
@@ -101,9 +102,7 @@ export const createBinGeometry = (
): THREE.BufferGeometry => {
const floorShape = createRoundedRectShape(width, depth, radius);
const floorGeo = new THREE.ExtrudeGeometry(floorShape, {
depth: thickness,
bevelEnabled: false,
curveSegments: 16
depth: thickness, bevelEnabled: false, curveSegments: 16
});
floorGeo.rotateX(-Math.PI / 2);
@@ -119,9 +118,7 @@ export const createBinGeometry = (
const wallHeight = height - thickness;
const wallGeo = new THREE.ExtrudeGeometry(outerShape, {
depth: wallHeight,
bevelEnabled: false,
curveSegments: 16
depth: wallHeight, bevelEnabled: false, curveSegments: 16
});
wallGeo.rotateX(-Math.PI / 2);