Merge remote-tracking branches 'origin/sub_laptop_4' and 'origin/sub_laptop_8' into main_laptop_1

This commit is contained in:
2026-10-16 00:16:05 +09:00
9 changed files with 1025 additions and 150 deletions
@@ -1,5 +1,9 @@
/** 등분(DIVIDE)·길이분할(MEASURE) — 객체를 자르지 않고 점만 놓는다 */
/**
* 등분(DIVIDE)·길이분할(MEASURE) — 객체를 자르지 않고 점만 놓는다.
* 오토캐드 물음 차례(337 설계 1-2) · 기본값 없음 · 한 번 뒤 끝 · 블록(B) 없음.
*/
import { toast } from 'react-toastify';
import type { OptionSpec } from '../../commands/prompt';
import {
dividePoints,
measurePoints,
@@ -10,12 +14,21 @@ import { Tool } from '../../tools';
import { pointEntity } from '../factories/entity-factory';
import { createSequenceTool } from '../factories/sequence-tool';
const BLOCK: OptionSpec = { key: 'BLOCK', kw: 'B', en: 'BLOCK', label: '블록' };
export const divideToolStateMachine = createSequenceTool({
tool: Tool.DIVIDE,
helpers: false,
steps: [
{ kind: 'entity', instructions: '등분할 객체를 선택하십시오.' },
{ kind: 'number', instructions: '세그먼트 수를 입력하십시오 <4>.', defaultValue: 4 },
{ kind: 'entity', prompt: { text: '등분할 객체 선택' } },
{
kind: 'number',
prompt: {
text: '세그먼트 수 입력',
absent: [BLOCK],
number: { int: true, min: 2, max: 32767 },
},
},
],
commit: (input) => {
const points = dividePoints(sampleEntityPoints(input.entity(0)), input.number(1));
@@ -31,11 +44,19 @@ export const measureLengthToolStateMachine = createSequenceTool({
tool: Tool.MEASURE_LENGTH,
helpers: false,
steps: [
{ kind: 'entity', instructions: '길이로 분할할 객체를 선택하십시오.' },
{ kind: 'number', instructions: '세그먼트 길이를 입력하십시오 <10>.', defaultValue: 10 },
{ kind: 'entity', prompt: { text: '길이 분할 객체 선택' } },
{
kind: 'number',
prompt: { text: '세그먼트의 길이 지정', absent: [BLOCK], number: { positive: true } },
},
],
commit: (input) => {
const points = measurePoints(sampleEntityPoints(input.entity(0)), input.number(1));
// 누른 자리에 가까운 끝부터 잼(오토캐드)
const path = sampleEntityPoints(input.entity(0));
const pick = input.pick(0);
const nearEnd =
path.length > 1 && path[path.length - 1].distanceTo(pick)[0] < path[0].distanceTo(pick)[0];
const points = measurePoints(nearEnd ? [...path].reverse() : path, input.number(1));
if (!points.length) {
toast.warn('지정한 길이로 나눌 수 없습니다.');
return;