BREAKING: Change tangential arc to keyword args (#6266)

* Change tangentialArc, tangentialArcTo, and tangentialArcToRelative to keyword args

* Change tangentialArc offset to angle and convert to kw arg calls

* Fix lints

* Fix sketch errors and all unit tests passing

* Fix tangentialArcTo calls in KCL samples

* Update tangentialArc in samples

* Update sim test output

* Fix formatting

* Fix mistake in merge

* Fix gear rack sample

* Update output after more samples fixes

* Update gear rack output

* Add end label to docs snippet

* Fix to not add endAbsolute for an arc with radius or angle arguments

* Update docs outputs

* Fix formatting

* Fix executor tests

* Fix formatting

* Fix bench input files

* Fix spelling

* Improve error messages

---------

Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
This commit is contained in:
Jonathan Tran
2025-04-11 14:17:20 -04:00
committed by GitHub
parent 66f95d25f6
commit 319c60d4fa
129 changed files with 13063 additions and 17144 deletions

View File

@ -95,7 +95,7 @@ import {
} from '@src/clientSideScene/segments'
import type EditorManager from '@src/editor/manager'
import type CodeManager from '@src/lang/codeManager'
import { ARG_END_ABSOLUTE } from '@src/lang/constants'
import { ARG_END, ARG_END_ABSOLUTE } from '@src/lang/constants'
import {
createArrayExpression,
createCallExpressionStdLib,
@ -164,7 +164,7 @@ import type {
SketchTool,
} from '@src/machines/modelingMachine'
type DraftSegment = 'line' | 'tangentialArcTo'
type DraftSegment = 'line' | 'tangentialArc'
type Vec3Array = [number, number, number]
@ -235,7 +235,7 @@ export class SceneEntities {
segment.userData.prevSegment &&
segment.userData.type === TANGENTIAL_ARC_TO_SEGMENT
) {
update = segmentUtils.tangentialArcTo.update
update = segmentUtils.tangentialArc.update
}
if (
segment.userData &&
@ -758,7 +758,7 @@ export class SceneEntities {
const initSegment =
segment.type === 'TangentialArcTo'
? segmentUtils.tangentialArcTo.init
? segmentUtils.tangentialArc.init
: segment.type === 'Circle'
? segmentUtils.circle.init
: segment.type === 'Arc'
@ -903,7 +903,7 @@ export class SceneEntities {
forward: [number, number, number],
up: [number, number, number],
origin: [number, number, number],
segmentName: 'line' | 'tangentialArcTo' = 'line',
segmentName: 'line' | 'tangentialArc' = 'line',
shouldTearDown = true
) => {
const _ast = structuredClone(this.kclManager.ast)
@ -999,10 +999,9 @@ export class SceneEntities {
variables: this.kclManager.variables,
pathToNode: sketchEntryNodePath,
expressions: [
segmentName === 'tangentialArcTo'
? createCallExpressionStdLib('tangentialArcTo', [
originCoords,
createPipeSubstitution(),
segmentName === 'tangentialArc'
? createCallExpressionStdLibKw('tangentialArc', null, [
createLabeledArg(ARG_END_ABSOLUTE, originCoords),
])
: createCallExpressionStdLibKw('line', null, [
createLabeledArg(ARG_END_ABSOLUTE, originCoords),
@ -1048,11 +1047,10 @@ export class SceneEntities {
// This might need to become its own function if we want more
// case-based logic for different segment types
if (
(lastSegment.type === 'TangentialArcTo' &&
segmentName !== 'line') ||
segmentName === 'tangentialArcTo'
(lastSegment.type === 'TangentialArc' && segmentName !== 'line') ||
segmentName === 'tangentialArc'
) {
resolvedFunctionName = 'tangentialArcTo'
resolvedFunctionName = 'tangentialArc'
} else if (isHorizontal) {
// If the angle between is 0 or 180 degrees (+/- the snapping angle), make the line an xLine
resolvedFunctionName = 'xLine'
@ -3003,7 +3001,7 @@ export class SceneEntities {
}
let update: SegmentUtils['update'] | null = null
if (type === TANGENTIAL_ARC_TO_SEGMENT) {
update = segmentUtils.tangentialArcTo.update
update = segmentUtils.tangentialArc.update
} else if (type === STRAIGHT_SEGMENT) {
update = segmentUtils.straight.update
} else if (
@ -3182,7 +3180,7 @@ export class SceneEntities {
if (parent.name === STRAIGHT_SEGMENT) {
update = segmentUtils.straight.update
} else if (parent.name === TANGENTIAL_ARC_TO_SEGMENT) {
update = segmentUtils.tangentialArcTo.update
update = segmentUtils.tangentialArc.update
input = {
type: 'arc-segment',
from: parent.userData.from,
@ -3259,7 +3257,7 @@ export class SceneEntities {
if (parent.name === STRAIGHT_SEGMENT) {
update = segmentUtils.straight.update
} else if (parent.name === TANGENTIAL_ARC_TO_SEGMENT) {
update = segmentUtils.tangentialArcTo.update
update = segmentUtils.tangentialArc.update
input = {
type: 'arc-segment',
from: parent.userData.from,
@ -3533,17 +3531,19 @@ function prepareTruncatedAst(
if (draftSegment === 'line') {
newSegment = createCallExpressionStdLibKw('line', null, [
createLabeledArg(
'end',
ARG_END,
createArrayExpression([createLiteral(0), createLiteral(0)])
),
])
} else {
newSegment = createCallExpressionStdLib('tangentialArcTo', [
createArrayExpression([
createLiteral(lastSeg.to[0]),
createLiteral(lastSeg.to[1]),
]),
createPipeSubstitution(),
newSegment = createCallExpressionStdLibKw('tangentialArc', null, [
createLabeledArg(
ARG_END_ABSOLUTE,
createArrayExpression([
createLiteral(lastSeg.to[0]),
createLiteral(lastSeg.to[1]),
])
),
])
}
;(