1
This commit is contained in:
+239
-107
@@ -1,28 +1,24 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import { STLExporter } from 'three-stdlib';
|
import { STLExporter, mergeBufferGeometries } from 'three-stdlib';
|
||||||
import { SUBTRACTION, ADDITION, Brush, Evaluator } from 'three-bvh-csg'; // ИСПРАВЛЕНО: ADDITION вместо UNION
|
|
||||||
import { AppConfig, LayoutSplits, GeneratedPart, Partition } from '../types';
|
import { AppConfig, LayoutSplits, GeneratedPart, Partition } from '../types';
|
||||||
|
|
||||||
// --- ВСПОМОГАТЕЛЬНЫЕ ФУНКЦИИ ---
|
// --- ВСПОМОГАТЕЛЬНЫЕ ФУНКЦИИ ---
|
||||||
|
|
||||||
const cleanPoints = (points: number[]) => {
|
// 1. Собираем все перегородки из всех ячеек в один плоский список
|
||||||
const rounded = points.map(p => Math.round(p * 1000) / 1000).sort((a, b) => a - b);
|
|
||||||
return [...new Set(rounded)];
|
|
||||||
};
|
|
||||||
|
|
||||||
const getAllPartitions = (splits: LayoutSplits): Partition[] => {
|
const getAllPartitions = (splits: LayoutSplits): Partition[] => {
|
||||||
if (!splits || !splits.partitions) return [];
|
if (!splits || !splits.partitions) return [];
|
||||||
|
// Проходимся по всем ключам ("0-0", "0-1" и т.д.) и собираем массивы в один
|
||||||
return Object.values(splits.partitions).flat();
|
return Object.values(splits.partitions).flat();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Функция для визуализации "кубиков" ячеек (цветной предпросмотр)
|
|
||||||
export const calculateParts = (config: AppConfig, splits: LayoutSplits): GeneratedPart[] => {
|
export const calculateParts = (config: AppConfig, splits: LayoutSplits): GeneratedPart[] => {
|
||||||
const parts: GeneratedPart[] = [];
|
const parts: GeneratedPart[] = [];
|
||||||
const safeX = Array.isArray(splits?.x) ? splits.x : [];
|
const safeX = Array.isArray(splits?.x) ? splits.x : [];
|
||||||
const safeY = Array.isArray(splits?.y) ? splits.y : [];
|
const safeY = Array.isArray(splits?.y) ? splits.y : [];
|
||||||
|
|
||||||
const uniqueX = cleanPoints([0, ...safeX, 1]);
|
// Уникальные точки реза для визуализации "цветных кубиков"
|
||||||
const uniqueY = cleanPoints([0, ...safeY, 1]);
|
const uniqueX = [0, ...safeX, 1].sort((a, b) => a - b);
|
||||||
|
const uniqueY = [0, ...safeY, 1].sort((a, b) => a - b);
|
||||||
|
|
||||||
let partCounter = 1;
|
let partCounter = 1;
|
||||||
|
|
||||||
@@ -33,6 +29,7 @@ export const calculateParts = (config: AppConfig, splits: LayoutSplits): Generat
|
|||||||
const y1 = uniqueY[j];
|
const y1 = uniqueY[j];
|
||||||
const y2 = uniqueY[j+1];
|
const y2 = uniqueY[j+1];
|
||||||
|
|
||||||
|
// Фильтр микро-ячеек
|
||||||
if (x2 - x1 < 0.001 || y2 - y1 < 0.001) continue;
|
if (x2 - x1 < 0.001 || y2 - y1 < 0.001) continue;
|
||||||
|
|
||||||
const rawW = (x2 - x1) * config.drawer.width;
|
const rawW = (x2 - x1) * config.drawer.width;
|
||||||
@@ -47,7 +44,7 @@ export const calculateParts = (config: AppConfig, splits: LayoutSplits): Generat
|
|||||||
name: `Ячейка ${partCounter}`,
|
name: `Ячейка ${partCounter}`,
|
||||||
width: Math.max(1, rawW - gap * 2),
|
width: Math.max(1, rawW - gap * 2),
|
||||||
depth: Math.max(1, rawD - gap * 2),
|
depth: Math.max(1, rawD - gap * 2),
|
||||||
height: config.drawer.height,
|
height: config.drawer.height - config.wallThickness, // Учитываем пол
|
||||||
x: rawX + gap,
|
x: rawX + gap,
|
||||||
y: rawY + gap,
|
y: rawY + gap,
|
||||||
color: `hsl(${(partCounter * 137.5) % 360}, 70%, 50%)`,
|
color: `hsl(${(partCounter * 137.5) % 360}, 70%, 50%)`,
|
||||||
@@ -59,44 +56,175 @@ export const calculateParts = (config: AppConfig, splits: LayoutSplits): Generat
|
|||||||
return parts;
|
return parts;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- ГЕНЕРАЦИЯ ГЕОМЕТРИИ ЧЕРЕЗ CSG (ВЫЧИТАНИЕ) ---
|
// --- ГЕОМЕТРИЯ ---
|
||||||
|
|
||||||
|
// Создание формы стены с отверстиями (Правильный Winding Order!)
|
||||||
|
const createWallShapeWithHoles = (length: number, height: number, config: AppConfig): THREE.Shape => {
|
||||||
|
const shape = new THREE.Shape();
|
||||||
|
|
||||||
|
// 1. Контур стены (CCW - Против часовой)
|
||||||
|
shape.moveTo(0, 0);
|
||||||
|
shape.lineTo(length, 0);
|
||||||
|
shape.lineTo(length, height);
|
||||||
|
shape.lineTo(0, height);
|
||||||
|
shape.lineTo(0, 0);
|
||||||
|
|
||||||
|
// Если перфорация выключена или стена слишком мала
|
||||||
|
if (!config.perforation?.enabled || length < 15 || height < 15) return shape;
|
||||||
|
|
||||||
|
const { pattern, diameter, spacing } = config.perforation;
|
||||||
|
const step = diameter + Math.max(2, spacing);
|
||||||
|
const margin = 4;
|
||||||
|
|
||||||
|
// Рабочая область
|
||||||
|
const effW = length - margin * 2;
|
||||||
|
const effH = height - margin * 2;
|
||||||
|
|
||||||
|
if (effW <= diameter || effH <= diameter) return shape;
|
||||||
|
|
||||||
|
// Расчет сетки
|
||||||
|
const rowH = pattern === 'circle' ? step : step * 0.866;
|
||||||
|
const cols = Math.floor(effW / step);
|
||||||
|
const rows = Math.floor(effH / rowH);
|
||||||
|
|
||||||
|
const startX = margin + (effW - (cols - 1) * step) / 2;
|
||||||
|
const startY = margin + (effH - (rows - 1) * rowH) / 2;
|
||||||
|
|
||||||
|
for (let j = 0; j < rows; j++) {
|
||||||
|
const isOdd = j % 2 !== 0;
|
||||||
|
const cy = startY + j * rowH;
|
||||||
|
|
||||||
|
for (let i = 0; i < cols; i++) {
|
||||||
|
let cx = startX + i * step;
|
||||||
|
if ((pattern === 'hexagon' || pattern === 'triangle') && isOdd) cx += step / 2;
|
||||||
|
|
||||||
|
// Проверка границ
|
||||||
|
if (cx - diameter/2 < margin || cx + diameter/2 > length - margin ||
|
||||||
|
cy - diameter/2 < margin || cy + diameter/2 > height - margin) continue;
|
||||||
|
|
||||||
|
const hole = new THREE.Path();
|
||||||
|
const r = diameter / 2;
|
||||||
|
|
||||||
|
// 2. Отверстия (CW - По часовой стрелке)
|
||||||
|
// Это критически важно для Three.js, иначе дырки не вырежутся
|
||||||
|
|
||||||
|
if (pattern === 'circle') {
|
||||||
|
hole.absarc(cx, cy, r, 0, Math.PI * 2, true);
|
||||||
|
}
|
||||||
|
else if (pattern === 'hexagon') {
|
||||||
|
for (let k = 0; k < 6; k++) {
|
||||||
|
const angle = (-k * 60 + 90) * Math.PI / 180; // Минус k = CW
|
||||||
|
const px = cx + r * Math.cos(angle);
|
||||||
|
const py = cy + r * Math.sin(angle);
|
||||||
|
if (k === 0) hole.moveTo(px, py); else hole.lineTo(px, py);
|
||||||
|
}
|
||||||
|
hole.closePath();
|
||||||
|
}
|
||||||
|
else if (pattern === 'triangle') {
|
||||||
|
const rot = isOdd ? 180 : 0;
|
||||||
|
for (let k = 0; k < 3; k++) {
|
||||||
|
const angle = (-k * 120 + 90 + rot) * Math.PI / 180;
|
||||||
|
const px = cx + r * Math.cos(angle);
|
||||||
|
const py = cy + r * Math.sin(angle);
|
||||||
|
if (k === 0) hole.moveTo(px, py); else hole.lineTo(px, py);
|
||||||
|
}
|
||||||
|
hole.closePath();
|
||||||
|
}
|
||||||
|
shape.holes.push(hole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shape;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Форма пола (Сплошная)
|
||||||
|
const createFloorShape = (width: number, depth: number, radius: number): THREE.Shape => {
|
||||||
|
const shape = new THREE.Shape();
|
||||||
|
const x = -width / 2;
|
||||||
|
const y = -depth / 2;
|
||||||
|
const r = Math.min(radius, width / 2, depth / 2);
|
||||||
|
|
||||||
|
if (r <= 0.1) {
|
||||||
|
shape.moveTo(x, y);
|
||||||
|
shape.lineTo(x + width, y);
|
||||||
|
shape.lineTo(x + width, y + depth);
|
||||||
|
shape.lineTo(x, y + depth);
|
||||||
|
shape.lineTo(x, y);
|
||||||
|
} else {
|
||||||
|
shape.moveTo(x, y + r);
|
||||||
|
shape.lineTo(x, y + depth - r);
|
||||||
|
shape.quadraticCurveTo(x, y + depth, x + r, y + depth);
|
||||||
|
shape.lineTo(x + width - r, y + depth);
|
||||||
|
shape.quadraticCurveTo(x + width, y + depth, x + width, y + depth - r);
|
||||||
|
shape.lineTo(x + width, y + r);
|
||||||
|
shape.quadraticCurveTo(x + width, y, x + width - r, y);
|
||||||
|
shape.lineTo(x + r, y);
|
||||||
|
shape.quadraticCurveTo(x, y, x, y + r);
|
||||||
|
}
|
||||||
|
return shape;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Форма скругления (Concave fillet)
|
||||||
|
const createFilletShape = (radius: number): THREE.Shape => {
|
||||||
|
const shape = new THREE.Shape();
|
||||||
|
shape.moveTo(0, 0);
|
||||||
|
shape.lineTo(radius, 0);
|
||||||
|
shape.absarc(radius, radius, radius, -Math.PI / 2, -Math.PI, true);
|
||||||
|
shape.lineTo(0, 0);
|
||||||
|
return shape;
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- СБОРКА МОДЕЛИ ---
|
||||||
|
|
||||||
export const createBinGeometry = (
|
export const createBinGeometry = (
|
||||||
width: number, depth: number, height: number, thickness: number, radius: number = 0,
|
width: number, depth: number, height: number, thickness: number, radius: number = 0,
|
||||||
splits: LayoutSplits | Partition[] = [],
|
splits: LayoutSplits | Partition[] = [], // Принимаем весь объект splits
|
||||||
config?: AppConfig
|
config?: AppConfig
|
||||||
): THREE.BufferGeometry => {
|
): THREE.BufferGeometry => {
|
||||||
|
|
||||||
|
const geometries: THREE.BufferGeometry[] = [];
|
||||||
const safeConfig = config || { perforation: { enabled: false } } as AppConfig;
|
const safeConfig = config || { perforation: { enabled: false } } as AppConfig;
|
||||||
const evaluator = new Evaluator();
|
|
||||||
|
|
||||||
// 1. БАЗА (ПОЛ)
|
// 1. ПОЛ
|
||||||
const floorGeo = new THREE.BoxGeometry(width, thickness, depth);
|
const floorShape = createFloorShape(width, depth, radius);
|
||||||
floorGeo.translate(0, thickness / 2, 0);
|
const floorGeo = new THREE.ExtrudeGeometry(floorShape, { depth: thickness, bevelEnabled: false });
|
||||||
let resultBrush = new Brush(floorGeo);
|
floorGeo.rotateX(-Math.PI / 2); // Кладем на пол
|
||||||
resultBrush.updateMatrixWorld();
|
geometries.push(floorGeo);
|
||||||
|
|
||||||
// 2. СТЕНКИ
|
// Внутренние размеры (без учета толщины внешних стен)
|
||||||
const wallH = height - thickness;
|
|
||||||
const innerW = width - 2 * thickness;
|
const innerW = width - 2 * thickness;
|
||||||
const innerD = depth - 2 * thickness;
|
const innerD = depth - 2 * thickness;
|
||||||
|
const wallH = height - thickness;
|
||||||
|
|
||||||
// Функция добавления блока стены (ADDITION)
|
// 2. ВНЕШНИЕ СТЕНКИ
|
||||||
const addWallBlock = (w: number, h: number, d: number, x: number, y: number, z: number) => {
|
// Создаем 2D профили с дырками
|
||||||
const geo = new THREE.BoxGeometry(w, h, d);
|
const shapeFrontBack = createWallShapeWithHoles(innerW, wallH, safeConfig);
|
||||||
geo.translate(x, y, z);
|
const shapeLeftRight = createWallShapeWithHoles(depth, wallH, safeConfig); // Боковые на всю глубину
|
||||||
const wallBrush = new Brush(geo);
|
|
||||||
wallBrush.updateMatrixWorld();
|
|
||||||
resultBrush = evaluator.evaluate(resultBrush, wallBrush, ADDITION); // ИСПРАВЛЕНО ЗДЕСЬ
|
|
||||||
};
|
|
||||||
|
|
||||||
// Внешние стенки
|
// Front (Спереди)
|
||||||
addWallBlock(innerW, wallH, thickness, 0, thickness + wallH/2, depth/2 - thickness/2); // Front
|
const geoF = new THREE.ExtrudeGeometry(shapeFrontBack, { depth: thickness, bevelEnabled: false });
|
||||||
addWallBlock(innerW, wallH, thickness, 0, thickness + wallH/2, -depth/2 + thickness/2); // Back
|
geoF.translate(-innerW/2, thickness, depth/2 - thickness);
|
||||||
addWallBlock(thickness, wallH, depth, -width/2 + thickness/2, thickness + wallH/2, 0); // Left
|
geometries.push(geoF);
|
||||||
addWallBlock(thickness, wallH, depth, width/2 - thickness/2, thickness + wallH/2, 0); // Right
|
|
||||||
|
|
||||||
// Внутренние перегородки
|
// Back (Сзади)
|
||||||
|
const geoB = new THREE.ExtrudeGeometry(shapeFrontBack, { depth: thickness, bevelEnabled: false });
|
||||||
|
geoB.translate(-innerW/2, thickness, -depth/2);
|
||||||
|
geometries.push(geoB);
|
||||||
|
|
||||||
|
// Left (Слева)
|
||||||
|
const geoL = new THREE.ExtrudeGeometry(shapeLeftRight, { depth: thickness, bevelEnabled: false });
|
||||||
|
geoL.rotateY(Math.PI / 2);
|
||||||
|
geoL.translate(-width/2, thickness, -depth/2);
|
||||||
|
geometries.push(geoL);
|
||||||
|
|
||||||
|
// Right (Справа)
|
||||||
|
const geoR = new THREE.ExtrudeGeometry(shapeLeftRight, { depth: thickness, bevelEnabled: false });
|
||||||
|
geoR.rotateY(Math.PI / 2);
|
||||||
|
geoR.translate(width/2 - thickness, thickness, -depth/2);
|
||||||
|
geometries.push(geoR);
|
||||||
|
|
||||||
|
|
||||||
|
// 3. ВНУТРЕННИЕ ПЕРЕГОРОДКИ
|
||||||
|
// Важно: извлекаем плоский массив стенок
|
||||||
let partitions: Partition[] = [];
|
let partitions: Partition[] = [];
|
||||||
if (Array.isArray(splits)) {
|
if (Array.isArray(splits)) {
|
||||||
partitions = splits;
|
partitions = splits;
|
||||||
@@ -107,91 +235,95 @@ export const createBinGeometry = (
|
|||||||
partitions.forEach(p => {
|
partitions.forEach(p => {
|
||||||
const pMin = p.min ?? 0;
|
const pMin = p.min ?? 0;
|
||||||
const pMax = p.max ?? 1;
|
const pMax = p.max ?? 1;
|
||||||
|
|
||||||
|
// Игнорируем ошибки данных
|
||||||
if (pMax - pMin < 0.001) return;
|
if (pMax - pMin < 0.001) return;
|
||||||
|
|
||||||
let w=0, h=p.height, d=0, x=0, z=0;
|
let length = 0;
|
||||||
|
let posX = 0;
|
||||||
|
let posZ = 0;
|
||||||
|
let isVertical = false;
|
||||||
|
|
||||||
if (p.axis === 'x') { // Вертикальная (вдоль Z)
|
// Рассчитываем координаты и размеры
|
||||||
w = thickness;
|
if (p.axis === 'x') {
|
||||||
d = (pMax - pMin) * innerD;
|
// Вертикальная на экране (Вдоль Z)
|
||||||
x = (-innerW/2) + (p.offset * innerW);
|
isVertical = true;
|
||||||
z = (-innerD/2) + (pMin * innerD) + (d / 2);
|
length = (pMax - pMin) * innerD;
|
||||||
} else { // Горизонтальная (вдоль X)
|
// X: центр линии
|
||||||
w = (pMax - pMin) * innerW;
|
posX = (-innerW/2) + (p.offset * innerW);
|
||||||
d = thickness;
|
// Z: начало линии
|
||||||
x = (-innerW/2) + (pMin * innerW) + (w / 2);
|
posZ = (-innerD/2) + (pMin * innerD);
|
||||||
z = (-innerD/2) + (p.offset * innerD);
|
|
||||||
}
|
|
||||||
addWallBlock(w, h, d, x, thickness + h/2, z);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. ПЕРФОРАЦИЯ (ВЫЧИТАНИЕ)
|
|
||||||
if (safeConfig.perforation?.enabled) {
|
|
||||||
const { pattern, diameter, spacing } = safeConfig.perforation;
|
|
||||||
// Цилиндр для вырезания (длинный, чтобы прошел насквозь)
|
|
||||||
const holeGeo = new THREE.CylinderGeometry(diameter/2, diameter/2, thickness * 4, 16);
|
|
||||||
holeGeo.rotateZ(Math.PI / 2); // По умолчанию вдоль X (для боковых стен)
|
|
||||||
|
|
||||||
const step = diameter + Math.max(2, spacing);
|
|
||||||
const margin = 4;
|
|
||||||
|
|
||||||
// Собираем все "сверла" в одну геометрию для скорости
|
|
||||||
const cutters: THREE.BufferGeometry[] = [];
|
|
||||||
|
|
||||||
const generateCutters = (W: number, H: number, startX: number, startY: number, startZ: number, rotateY: boolean) => {
|
|
||||||
const cols = Math.floor((W - margin*2) / step);
|
|
||||||
const rowH = pattern === 'circle' ? step : step * 0.866;
|
|
||||||
const rows = Math.floor((H - margin*2) / rowH);
|
|
||||||
|
|
||||||
const offsetX = (W - cols * step) / 2;
|
|
||||||
const offsetY = (H - rows * rowH) / 2;
|
|
||||||
|
|
||||||
for(let j=0; j<rows; j++) {
|
|
||||||
const isOdd = j % 2 !== 0;
|
|
||||||
for(let i=0; i<cols; i++) {
|
|
||||||
let hx = offsetX + i * step + diameter/2;
|
|
||||||
let hy = offsetY + j * rowH + diameter/2;
|
|
||||||
|
|
||||||
if ((pattern === 'hexagon' || pattern === 'triangle') && isOdd) hx += step/2;
|
|
||||||
|
|
||||||
if (hx > W - margin || hy > H - margin) continue;
|
|
||||||
|
|
||||||
const cutter = holeGeo.clone();
|
|
||||||
|
|
||||||
if (rotateY) {
|
|
||||||
// Для передней/задней стенки (сверлим вдоль Z)
|
|
||||||
cutter.rotateY(Math.PI / 2);
|
|
||||||
cutter.translate(startX + hx, startY + hy, startZ);
|
|
||||||
} else {
|
} else {
|
||||||
// Для боковых стенок (сверлим вдоль X)
|
// Горизонтальная на экране (Вдоль X)
|
||||||
cutter.translate(startX, startY + hy, startZ + hx);
|
isVertical = false;
|
||||||
}
|
length = (pMax - pMin) * innerW;
|
||||||
cutters.push(cutter);
|
// X: начало линии
|
||||||
|
posX = (-innerW/2) + (pMin * innerW);
|
||||||
|
// Z: центр линии
|
||||||
|
posZ = (-innerD/2) + (p.offset * innerD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Создаем стенку с дырками
|
||||||
|
const partShape = createWallShapeWithHoles(length, wallH, safeConfig);
|
||||||
|
const partGeo = new THREE.ExtrudeGeometry(partShape, { depth: thickness, bevelEnabled: false });
|
||||||
|
|
||||||
|
if (isVertical) {
|
||||||
|
// Поворачиваем вдоль Z
|
||||||
|
partGeo.rotateY(Math.PI / 2);
|
||||||
|
// Смещаем: X - половина толщины (для центровки), Y=thick, Z=начало
|
||||||
|
partGeo.translate(posX - thickness/2, thickness, posZ);
|
||||||
|
} else {
|
||||||
|
// Вдоль X
|
||||||
|
// Смещаем: X=начало, Y=thick, Z - половина толщины
|
||||||
|
partGeo.translate(posX, thickness, posZ - thickness/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geometries.push(partGeo);
|
||||||
|
|
||||||
|
// --- СКРУГЛЕНИЯ (FILLETS) ---
|
||||||
|
if (p.rounded && radius > 1) {
|
||||||
|
const fR = Math.min(radius, 5);
|
||||||
|
const fShape = createFilletShape(fR);
|
||||||
|
const h = p.height;
|
||||||
|
|
||||||
|
const addFillet = (fx: number, fz: number, rot: number) => {
|
||||||
|
const geo = new THREE.ExtrudeGeometry(fShape, { depth: h, bevelEnabled: false });
|
||||||
|
geo.rotateX(-Math.PI / 2);
|
||||||
|
geo.rotateY(rot);
|
||||||
|
geo.translate(fx, thickness, fz);
|
||||||
|
geometries.push(geo);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Генерируем отверстия для внешних стен
|
const t = thickness / 2;
|
||||||
generateCutters(innerW, wallH, -innerW/2, thickness, depth/2, true); // Front
|
|
||||||
generateCutters(innerW, wallH, -innerW/2, thickness, -depth/2, true); // Back
|
|
||||||
generateCutters(depth, wallH, -width/2, thickness, -depth/2, false); // Left
|
|
||||||
generateCutters(depth, wallH, width/2, thickness, -depth/2, false); // Right
|
|
||||||
|
|
||||||
// Применяем вычитание (SUBTRACTION)
|
if (isVertical) {
|
||||||
if (cutters.length > 0) {
|
const zStart = posZ;
|
||||||
// Используем функцию слияния из three-stdlib (так как в core three её может не быть в старых версиях)
|
const zEnd = posZ + length;
|
||||||
// Если mergeBufferGeometries не импортирован, убедитесь что он есть в импортах
|
// 4 угла на стыках
|
||||||
const mergedCutters = mergeBufferGeometries(cutters);
|
addFillet(posX - t, zStart, Math.PI);
|
||||||
if (mergedCutters) {
|
addFillet(posX + t, zStart, -Math.PI/2);
|
||||||
const cutterBrush = new Brush(mergedCutters);
|
addFillet(posX - t, zEnd, Math.PI/2);
|
||||||
cutterBrush.updateMatrixWorld();
|
addFillet(posX + t, zEnd, 0);
|
||||||
resultBrush = evaluator.evaluate(resultBrush, cutterBrush, SUBTRACTION);
|
} else {
|
||||||
|
const xStart = posX;
|
||||||
|
const xEnd = posX + length;
|
||||||
|
addFillet(xStart, posZ - t, 0);
|
||||||
|
addFillet(xStart, posZ + t, -Math.PI/2);
|
||||||
|
addFillet(xEnd, posZ - t, Math.PI/2);
|
||||||
|
addFillet(xEnd, posZ + t, Math.PI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const merged = mergeBufferGeometries(geometries);
|
||||||
|
|
||||||
|
// Исправление нормалей (убирает прозрачность)
|
||||||
|
if (merged) {
|
||||||
|
merged.computeVertexNormals();
|
||||||
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Возвращаем результат
|
return new THREE.BoxGeometry(1, 1, 1);
|
||||||
return resultBrush.geometry;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generateSTL = (mesh: THREE.Object3D): Uint8Array | string => {
|
export const generateSTL = (mesh: THREE.Object3D): Uint8Array | string => {
|
||||||
|
|||||||
Reference in New Issue
Block a user