2024-05-24 20:54:42 +10:00
|
|
|
import { PathToNode, VariableDeclarator, parse, recast } from 'lang/wasm'
|
2024-05-30 13:28:29 +10:00
|
|
|
import { Axis, Selection, Selections, updateSelections } from 'lib/selections'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { assign, createMachine } from 'xstate'
|
2024-05-24 20:54:42 +10:00
|
|
|
import {
|
|
|
|
isNodeSafeToReplacePath,
|
|
|
|
getNodePathFromSourceRange,
|
|
|
|
} from 'lang/queryAst'
|
2024-03-28 17:22:11 +11:00
|
|
|
import {
|
|
|
|
kclManager,
|
|
|
|
sceneInfra,
|
|
|
|
sceneEntitiesManager,
|
|
|
|
engineCommandManager,
|
2024-04-19 14:24:40 -07:00
|
|
|
editorManager,
|
2024-03-28 17:22:11 +11:00
|
|
|
} from 'lib/singletons'
|
2023-10-11 13:36:54 +11:00
|
|
|
import {
|
|
|
|
horzVertInfo,
|
|
|
|
applyConstraintHorzVert,
|
|
|
|
} from 'components/Toolbar/HorzVert'
|
|
|
|
import {
|
|
|
|
applyConstraintHorzVertAlign,
|
|
|
|
horzVertDistanceInfo,
|
|
|
|
} from 'components/Toolbar/SetHorzVertDistance'
|
|
|
|
import { angleBetweenInfo } from 'components/Toolbar/SetAngleBetween'
|
2023-12-01 20:18:51 +11:00
|
|
|
import { angleLengthInfo } from 'components/Toolbar/setAngleLength'
|
2023-10-11 13:36:54 +11:00
|
|
|
import {
|
|
|
|
applyConstraintEqualLength,
|
|
|
|
setEqualLengthInfo,
|
|
|
|
} from 'components/Toolbar/EqualLength'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { addStartProfileAt, extrudeSketch } from 'lang/modifyAst'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { getNodeFromPath } from '../lang/queryAst'
|
2023-10-16 08:54:38 +11:00
|
|
|
import {
|
|
|
|
applyConstraintEqualAngle,
|
|
|
|
equalAngleInfo,
|
|
|
|
} from 'components/Toolbar/EqualAngle'
|
|
|
|
import {
|
|
|
|
applyRemoveConstrainingValues,
|
|
|
|
removeConstrainingValuesInfo,
|
|
|
|
} from 'components/Toolbar/RemoveConstrainingValues'
|
|
|
|
import { intersectInfo } from 'components/Toolbar/Intersect'
|
2023-12-01 20:18:51 +11:00
|
|
|
import {
|
|
|
|
absDistanceInfo,
|
|
|
|
applyConstraintAxisAlign,
|
|
|
|
} from 'components/Toolbar/SetAbsDistance'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { Models } from '@kittycad/lib/dist/types/src'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig'
|
2024-03-22 16:55:30 +11:00
|
|
|
import { DefaultPlaneStr } from 'clientSideScene/sceneEntities'
|
2024-03-22 10:23:04 +11:00
|
|
|
import { Vector3 } from 'three'
|
|
|
|
import { quaternionFromUpNForward } from 'clientSideScene/helpers'
|
2024-04-03 19:38:16 +11:00
|
|
|
import { uuidv4 } from 'lib/utils'
|
2024-05-24 20:54:42 +10:00
|
|
|
import { Coords2d } from 'lang/std/sketch'
|
|
|
|
import { deleteSegment } from 'clientSideScene/ClientSideSceneComp'
|
2023-10-11 13:36:54 +11:00
|
|
|
|
|
|
|
export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY'
|
|
|
|
|
|
|
|
export type SetSelections =
|
|
|
|
| {
|
|
|
|
selectionType: 'singleCodeCursor'
|
|
|
|
selection?: Selection
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
selectionType: 'otherSelection'
|
|
|
|
selection: Axis
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
selectionType: 'completeSelection'
|
|
|
|
selection: Selections
|
2024-05-31 11:36:08 +10:00
|
|
|
updatedPathToNode?: PathToNode
|
2023-10-11 13:36:54 +11:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
selectionType: 'mirrorCodeMirrorSelections'
|
|
|
|
selection: Selections
|
|
|
|
}
|
|
|
|
|
2024-04-04 11:07:51 +11:00
|
|
|
export type MouseState =
|
|
|
|
| {
|
|
|
|
type: 'idle'
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'isHovering'
|
|
|
|
on: any
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'isDragging'
|
|
|
|
on: any
|
|
|
|
}
|
2024-05-24 20:54:42 +10:00
|
|
|
| {
|
|
|
|
type: 'timeoutEnd'
|
|
|
|
pathToNodeString: string
|
|
|
|
}
|
2024-04-04 11:07:51 +11:00
|
|
|
|
2024-03-22 10:23:04 +11:00
|
|
|
export interface SketchDetails {
|
|
|
|
sketchPathToNode: PathToNode
|
|
|
|
zAxis: [number, number, number]
|
|
|
|
yAxis: [number, number, number]
|
|
|
|
origin: [number, number, number]
|
|
|
|
}
|
|
|
|
|
2024-05-24 20:54:42 +10:00
|
|
|
export interface SegmentOverlay {
|
|
|
|
windowCoords: Coords2d
|
|
|
|
angle: number
|
|
|
|
group: any
|
|
|
|
pathToNode: PathToNode
|
|
|
|
visible: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SegmentOverlays {
|
|
|
|
[pathToNodeString: string]: SegmentOverlay
|
|
|
|
}
|
|
|
|
|
|
|
|
export type SegmentOverlayPayload =
|
|
|
|
| {
|
|
|
|
type: 'set-one'
|
|
|
|
pathToNodeString: string
|
|
|
|
seg: SegmentOverlay
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'delete-one'
|
|
|
|
pathToNodeString: string
|
|
|
|
}
|
|
|
|
| { type: 'clear' }
|
|
|
|
| {
|
|
|
|
type: 'set-many'
|
|
|
|
overlays: SegmentOverlays
|
|
|
|
}
|
|
|
|
|
2023-10-16 21:20:05 +11:00
|
|
|
export type ModelingMachineEvent =
|
2024-02-19 17:23:03 +11:00
|
|
|
| {
|
|
|
|
type: 'Enter sketch'
|
|
|
|
data?: {
|
|
|
|
forceNewSketch?: boolean
|
|
|
|
}
|
|
|
|
}
|
2024-03-22 10:23:04 +11:00
|
|
|
| { type: 'Sketch On Face' }
|
2023-10-16 21:20:05 +11:00
|
|
|
| {
|
2024-02-11 12:59:00 +11:00
|
|
|
type: 'Select default plane'
|
2024-03-22 10:23:04 +11:00
|
|
|
data: {
|
|
|
|
zAxis: [number, number, number]
|
|
|
|
yAxis: [number, number, number]
|
|
|
|
} & (
|
|
|
|
| {
|
|
|
|
type: 'defaultPlane'
|
|
|
|
plane: DefaultPlaneStr
|
2024-04-22 20:14:06 +10:00
|
|
|
planeId: string
|
2024-03-22 10:23:04 +11:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'extrudeFace'
|
|
|
|
position: [number, number, number]
|
|
|
|
extrudeSegmentPathToNode: PathToNode
|
|
|
|
cap: 'start' | 'end' | 'none'
|
2024-04-22 20:14:06 +10:00
|
|
|
faceId: string
|
2024-03-22 10:23:04 +11:00
|
|
|
}
|
|
|
|
)
|
2023-10-16 21:20:05 +11:00
|
|
|
}
|
2024-05-30 13:28:29 +10:00
|
|
|
| {
|
|
|
|
type: 'Set selection'
|
|
|
|
data: SetSelections
|
|
|
|
}
|
2023-10-16 21:20:05 +11:00
|
|
|
| { type: 'Sketch no face' }
|
|
|
|
| { type: 'Toggle gui mode' }
|
|
|
|
| { type: 'Cancel' }
|
|
|
|
| { type: 'CancelSketch' }
|
2024-02-11 12:59:00 +11:00
|
|
|
| { type: 'Add start point' }
|
2023-10-16 21:20:05 +11:00
|
|
|
| { type: 'Make segment horizontal' }
|
|
|
|
| { type: 'Make segment vertical' }
|
|
|
|
| { type: 'Constrain horizontal distance' }
|
2023-12-01 20:18:51 +11:00
|
|
|
| { type: 'Constrain ABS X' }
|
|
|
|
| { type: 'Constrain ABS Y' }
|
2023-10-16 21:20:05 +11:00
|
|
|
| { type: 'Constrain vertical distance' }
|
|
|
|
| { type: 'Constrain angle' }
|
|
|
|
| { type: 'Constrain perpendicular distance' }
|
|
|
|
| { type: 'Constrain horizontally align' }
|
|
|
|
| { type: 'Constrain vertically align' }
|
2023-12-01 20:18:51 +11:00
|
|
|
| { type: 'Constrain snap to X' }
|
|
|
|
| { type: 'Constrain snap to Y' }
|
2023-10-16 21:20:05 +11:00
|
|
|
| { type: 'Constrain length' }
|
|
|
|
| { type: 'Constrain equal length' }
|
|
|
|
| { type: 'Constrain parallel' }
|
|
|
|
| { type: 'Constrain remove constraints' }
|
2023-10-18 08:03:02 +11:00
|
|
|
| { type: 'Re-execute' }
|
2024-03-04 16:06:43 -05:00
|
|
|
| { type: 'Export'; data: ModelingCommandSchema['Export'] }
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
| { type: 'Extrude'; data?: ModelingCommandSchema['Extrude'] }
|
2024-02-11 12:59:00 +11:00
|
|
|
| { type: 'Equip Line tool' }
|
|
|
|
| { type: 'Equip tangential arc to' }
|
2024-04-19 11:56:21 -04:00
|
|
|
| { type: 'Equip rectangle tool' }
|
|
|
|
| {
|
|
|
|
type: 'Add rectangle origin'
|
|
|
|
data: [x: number, y: number]
|
|
|
|
}
|
2024-02-11 12:59:00 +11:00
|
|
|
| {
|
2024-03-22 10:23:04 +11:00
|
|
|
type: 'done.invoke.animate-to-face' | 'done.invoke.animate-to-sketch'
|
|
|
|
data: SketchDetails
|
2024-02-11 12:59:00 +11:00
|
|
|
}
|
2024-05-24 20:54:42 +10:00
|
|
|
| {
|
|
|
|
type: 'done.invoke.get-convert-to-variable-info'
|
|
|
|
data: PathToNode
|
|
|
|
}
|
2024-04-04 11:07:51 +11:00
|
|
|
| { type: 'Set mouse state'; data: MouseState }
|
2024-05-24 20:54:42 +10:00
|
|
|
| {
|
|
|
|
type: 'Set Segment Overlays'
|
|
|
|
data: SegmentOverlayPayload
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: 'Delete segment'
|
|
|
|
data: PathToNode
|
|
|
|
}
|
2024-05-06 19:28:30 +10:00
|
|
|
| {
|
|
|
|
type: 'code edit during sketch'
|
|
|
|
}
|
2024-05-24 20:54:42 +10:00
|
|
|
| {
|
|
|
|
type: 'Convert to variable'
|
|
|
|
data: {
|
|
|
|
pathToNode: PathToNode
|
|
|
|
variableName: string
|
|
|
|
}
|
|
|
|
}
|
2024-02-11 12:59:00 +11:00
|
|
|
|
|
|
|
export type MoveDesc = { line: number; snippet: string }
|
2023-10-16 21:20:05 +11:00
|
|
|
|
2023-10-11 13:36:54 +11:00
|
|
|
export const modelingMachine = createMachine(
|
|
|
|
{
|
2024-05-30 19:43:35 +10:00
|
|
|
/** @xstate-layout N4IgpgJg5mDOIC5QFkD2EwBsCWA7KAxAMICGuAxlgNoAMAuoqAA6qzYAu2qujIAHogC0AdgCsAZgB04gEyjhADnEA2GgoUAWJQBoQAT0QBGGuICckmoZkbTM42YWKAvk91oMOfAQDKYdgAJYLDByTm5aBiQQFjYwniiBBEFTU2VJYWFxDUNDbPFxCQ1dAwQZO0lDW3EcuQzlBRoNFzd0LDxCXwCAW1QAVyDA9hJ2MAjeGI4ueNBE5JTJVUNNBUNlLQ05YsQsjQWNLVE5Yw0aZXFmkHc2r07-XygusFwAgHkANzAAJ0wSPVgxqITOK8RI0LYIGgXK6eKCSbAQTBgAgAUWeX0CAGs-OQABYA5isSbcEFCGTKYQVMmpLRWHLkor6RAyUy7DRZWR5GimBTKUxQ1owuEIpGokafTHYvGGSIE2JTElJaw0STZRaiNTiNQ0YTgk4ySS2YTKURWeqGcQrZT8jztIWIlF8difXoYfHRQnAhJCUTySTMmiiXmiDSiFbgnLqv08hQpdU2faGa3XWHw+3IvgsT7sN1A+VexXqKNKsq5Fmh8EZQwLMRZY0NGTCENJwXeLHsXHEMiUTCtyU5j15mZGJZpYyNrRasyycNLKs5dQ5TVLUPN2299s4ggAEWCI0CYAeT2z9HGA+J+bBjIhq-wknXHfIrX8kA4-ggvU+7QlG-7cvPQ4Qc0QwqfZjQtMpA32cEWTSDIyhUMl6gUCQb1he8cTvNtcQASWFAhkBILF90PZ5-A+LNsHIEhMF-Ilpn4IxmTnBQZE0I1NBoBtwzyaQaD4uQJAbJQmlcS4BTXLCMPQ3D7QIoighIgIcVQT8AC9uCGGiT0BM96MSKxGwWNRVBNAzyRkcNqirYN5EsM5jB9GRUMwyUXI3GSkSIbhYCdEg8H8ZS1I06i32wHyu1GbTZTohUrGDCwNk1bkslMJYFHBGQzDSAMfT4kNUvNZz0LcnC8K83AfM+PzcDIr5OCozBQvCihIpld0-z0xj6gNQ5kNWbI1A2DKGykQ5sjYuDjRElobVvYrpLK7zfP8gBBAAhbx-AADVoz0AKsZCVXEMRS2qZlMoy0x4qu8kGk40RTEyc5ROhCTXIW+1ysq6r-HWzaAE1dsHBjANY0Q-Q2VYjkDQMLKvTVC2EASTVURx9iKySSpxDziCWqr-LIKBESB-8QaAqQLXA5DFEMYRTAy9UKTkamMkDOnHox97JJxr7lpqxF8HYPEovamL83NY7pGNVRUtkapRAy5QlnSXlsjp-YlHJTmNyxnm8Z+pgvkN3AIEo3ofnFU3msoEnOtB1iVRSM6ThHU4MpWXZhEqGM4P2DQxG13FdcWiq+YClTsHU55qMwPR-Go7AoFwW3YrJfVkOWQpg1OcRwxRv0romhtA3yQOpO5kPvv88j6pjuOE6TlPxYbcw2VYumUbME1w2UORJFDR7uXqZlHGembkyx4PPv1-zYFwEgmH8dhUG2pv9uqKQyQtNRHpYswMsafUIOUE+TMcMoy6nzyZ5queF6XlfAZF3NSf0jeLCNaoMmO44MtyClgznwerTDQawx5iVmmhTGH1r6h3xjVMAABHXoIUBZQCFmvMmzJRr-zpsIAMchjrhkyMqNkJg+IBmlnyF64k5rQIrtPOBBsSBVUwIiLSbUX523NA2CwiElhlENHYcMLIKRKz4oYUM6gd6XxgbjJh-lPhgB6B8fwj4FHPH+M-XSqctALCsCGXumhJE6CvEsaoFhVi2EaPkYyTkaGQMnnIgASmAQQYA+AhF6CMTB+ler9zOMhAoJ8Sw6jMSYcGZDTAFB2ErWmsiGEimQdgReAAZPAYAH6oA4aeDqsUYxpAkCoGwV0sjqHBEocGjNrAQVAaZBJkocbImSYvIY+AjzYBCiw8gD9fFMjiiqLkAZSm1lzuEmMfofQqFOEPAM4DXp0K5o0vCzTegpP8Eo0IhNERZJyTpPJ+YyhiD9MYTQzJ9jqjGSUKwlgVQj3rNgzIDT3J4UfBgZ8psAjvk-Pgb8uI+mASyODXIIYxBrFYnDEo3IFDSCyOaCM1RuTTQgRPeaiT5E1wfmRFhnSABGxNtEHPXocasSx1jiJZOCWQ2oVRjhjLYbkV1L4rQAO5+SUhHKOmkmptMoP4PAAAzVABAIDcDAHCXAbxUBYkkDAdgghAqR2CpgQQgrUAAsyo0FUoCTiPTMI9TIGVsjmGQhC6ovI5BawcaizGrL2XhyCtHRqVteWZLVQQL4nwVKSCYD8dgQrPhdFlX4BVnLlWqtwEKjVmpgUgsXCGVij0MrgQSqcPiBQGxK2ZWy18NdKIhRdRFflkbhWitwOKvAUqZVysEHmhqEao2ErFgBTKVgKjHRWCYcklQuJXjKEoSQjhDiHAlrTex48Wy2pzQEOtBawquuLUKj1nwvWfB9X6gNQaa2zpVWq6NbaGjyGAWITQw0NgVGlpxC0LF1DzNoVA1ydrXx-W2ou0tYqJVVvFTWkguLYCCD4A29VTa9og1bbBXu-FCHlj7akfUuRGj9VkL3J51rJ2Punb9Dar73Weu9b64Ym7g3yt-f+wDe6QPA0SK2ikbJr0FFMAGLQl1VjSFDGBY4jZqETrejrJ9AQX3-TfSKj9lbpXfpDaRwQeggP7rSAUI9D1HkhipacWjjL1ShhjcihZD6+OYcE8JvDa6CP+pUluyTf7pOyco6-JkX8+GfyRifOFygqX9QsLyEJRxjrjpReh-T9rtlupLSJ8tn7xPEcEMFmznCdGHIc0uc0w7YyGAZoGA0MbLCSPYxkbNQX8A7Nwyu-DG7zNRZixRuLRKwPVBhfg7IrEbkxlpgzWmFRkv4LkAQq1PHFmBdfGgoWwmy0VslZFmtQ2cSxdyc22rkijqZRZCAmQnEwklDJIdHOX8VC0ysPlwbTx0E4iMyVkzZXA1RamzN-Zc3qPmoqOm0Mqw2KQqZOChYvctCiPkGCg7ARDafGNqbcg5sWE8qLe60bEXq0hsB8Ds2FtBCFpajd6KoHqNpx6koawvdNubD7SxcGP9QHGljIQ-7-h4dPBB2Dy287IeheM+uwj5Wa3U5NojlhyOGeo6q7NjHTIseFw5Hj4eCs+0ZApCTk+D0roU7Q7xoO6Ty27JRC0pehMOldM+D05eGq6ZpG5P-Gx0S6ZXMQLvQZ1QtDGmc0sS+KvMnL2yertZi9NltKJs71A2SNXFxOVyLIXsr3TjMZI2CSNjDanUCaOQjuMm7MkNhXAHACD+5UIOi0JoGgsjkPTK8Zo-QWmiYx46dNMoJ9Vy7zAyfU-sHT9KAXVGhdI37pxS0jWZkVjpiqM4EhbCBkYwGKvPvsmSAAHIrwAAqoDwOwWABAVoQAgIMFhAO5-PA1SfXYjGYZ54aGscEJ9W5mDwTHpQChR9J6n-4Wf8-F+kBans9HLfAKaHMCYTKLEuQHHKVefBKsGwJWaJM6HkO9RxYqFPNPAFYwVjA4fBaZQ4X-cMTKKQUBI0MkNNMkbIS+aAhvKgJvW7QXQCAMKsGMIZUBalSwBka5JidIIJUBU0GwFQS+AAFS12eE6Uam6Qfjd3WSd12W332COhjwenVF7mglAXSCRkylslOAwMvl6BNhXnCizHQheFwDCzGy-UkBWm8DYMEGUNFUEDUPYA0OTls24XyBhUOEyAKn2AKDUHBFDGVFSEqEGkyCUGOkvlcS2UKzH1r34y-AjigDwCXxXw2RCC9x2VCLwEwWuWyHBgXBWFYmqD4iTTA0cEKU1EMRSC9hjEvnIERDIECD9SRFgOyF2BMh9FNVyCKRnHNAsFOGMF3n1X20V36yDn4zUW4ExWXmxU-F-XtGhzE1h3lXURrkEGXlrRxWGLcX52ILfyOVjUaDN07SVglxKFkEqAqFSBlm+wMVEEp0mLqixTeDmPxSRGZ1MyIxrVOKzGmNQFmKGKuLR1FhIP7QpEsFNXyD2x9C2O2E1ApisRSFYlRjUBOJvgdSVSdVjm0Jh3FRMPUSrlwFDUdU0ljmjVuQeiDBZBMDyEsluQaw1HJB9C8yhI0VqgoganhNGPGxlWRJvlrTqnzTYT0GxPMHOmsGWyWEbHSjMX1TuVYhjDKD
|
2023-10-11 13:36:54 +11:00
|
|
|
id: 'Modeling',
|
|
|
|
|
|
|
|
tsTypes: {} as import('./modelingMachine.typegen').Typegen0,
|
|
|
|
predictableActionArguments: true,
|
|
|
|
preserveActionOrder: true,
|
|
|
|
|
|
|
|
context: {
|
|
|
|
guiMode: 'default',
|
2024-02-11 12:59:00 +11:00
|
|
|
tool: null as Models['SceneToolType_type'] | null,
|
2023-10-11 13:36:54 +11:00
|
|
|
selection: [] as string[],
|
|
|
|
selectionRanges: {
|
|
|
|
otherSelections: [],
|
|
|
|
codeBasedSelections: [],
|
|
|
|
} as Selections,
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails: {
|
|
|
|
sketchPathToNode: [],
|
|
|
|
zAxis: [0, 0, 1],
|
|
|
|
yAxis: [0, 1, 0],
|
|
|
|
origin: [0, 0, 0],
|
|
|
|
} as null | SketchDetails,
|
2023-10-11 13:36:54 +11:00
|
|
|
sketchPlaneId: '' as string,
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchEnginePathId: '' as string,
|
2024-02-11 12:59:00 +11:00
|
|
|
moveDescs: [] as MoveDesc[],
|
2024-04-04 11:07:51 +11:00
|
|
|
mouseState: { type: 'idle' } as MouseState,
|
2024-05-24 20:54:42 +10:00
|
|
|
segmentOverlays: {} as SegmentOverlays,
|
|
|
|
segmentHoverMap: {} as { [pathToNodeString: string]: number },
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
schema: {
|
2023-10-16 21:20:05 +11:00
|
|
|
events: {} as ModelingMachineEvent,
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
states: {
|
|
|
|
idle: {
|
|
|
|
on: {
|
|
|
|
'Enter sketch': [
|
|
|
|
{
|
2024-02-11 12:59:00 +11:00
|
|
|
target: 'animating to existing sketch',
|
2024-02-19 17:23:03 +11:00
|
|
|
cond: 'Selection is on face',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
'Sketch no face',
|
|
|
|
],
|
|
|
|
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
Extrude: {
|
|
|
|
target: 'idle',
|
|
|
|
cond: 'has valid extrude selection',
|
|
|
|
actions: ['AST extrude'],
|
|
|
|
internal: true,
|
|
|
|
},
|
2024-03-04 16:06:43 -05:00
|
|
|
|
|
|
|
Export: {
|
|
|
|
target: 'idle',
|
|
|
|
internal: true,
|
|
|
|
cond: 'Has exportable geometry',
|
|
|
|
actions: 'Engine export',
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-02-19 12:41:36 +11:00
|
|
|
|
|
|
|
entry: 'reset client scene mouse handlers',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
Sketch: {
|
|
|
|
states: {
|
|
|
|
SketchIdle: {
|
|
|
|
on: {
|
|
|
|
'Make segment vertical': {
|
|
|
|
cond: 'Can make selection vertical',
|
2024-05-30 19:43:35 +10:00
|
|
|
target: 'Await constrain vertically',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Make segment horizontal': {
|
|
|
|
cond: 'Can make selection horizontal',
|
2024-05-30 19:43:35 +10:00
|
|
|
target: 'Await constrain horizontally',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain horizontal distance': {
|
|
|
|
target: 'Await horizontal distance info',
|
|
|
|
cond: 'Can constrain horizontal distance',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain vertical distance': {
|
|
|
|
target: 'Await vertical distance info',
|
|
|
|
cond: 'Can constrain vertical distance',
|
|
|
|
},
|
|
|
|
|
2023-12-01 20:18:51 +11:00
|
|
|
'Constrain ABS X': {
|
|
|
|
target: 'Await ABS X info',
|
|
|
|
cond: 'Can constrain ABS X',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain ABS Y': {
|
|
|
|
target: 'Await ABS Y info',
|
|
|
|
cond: 'Can constrain ABS Y',
|
|
|
|
},
|
|
|
|
|
2023-10-11 13:36:54 +11:00
|
|
|
'Constrain angle': {
|
|
|
|
target: 'Await angle info',
|
|
|
|
cond: 'Can constrain angle',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain length': {
|
|
|
|
target: 'Await length info',
|
|
|
|
cond: 'Can constrain length',
|
|
|
|
},
|
|
|
|
|
2023-10-16 08:54:38 +11:00
|
|
|
'Constrain perpendicular distance': {
|
|
|
|
target: 'Await perpendicular distance info',
|
|
|
|
cond: 'Can constrain perpendicular distance',
|
|
|
|
},
|
|
|
|
|
2023-10-11 13:36:54 +11:00
|
|
|
'Constrain horizontally align': {
|
|
|
|
cond: 'Can constrain horizontally align',
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain horizontally align',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain vertically align': {
|
|
|
|
cond: 'Can constrain vertically align',
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain vertically align',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
2023-12-01 20:18:51 +11:00
|
|
|
'Constrain snap to X': {
|
|
|
|
cond: 'Can constrain snap to X',
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain snap to X',
|
2023-12-01 20:18:51 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain snap to Y': {
|
|
|
|
cond: 'Can constrain snap to Y',
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain snap to Y',
|
2023-12-01 20:18:51 +11:00
|
|
|
},
|
|
|
|
|
2023-10-11 13:36:54 +11:00
|
|
|
'Constrain equal length': {
|
|
|
|
cond: 'Can constrain equal length',
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain equal length',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2023-10-16 08:54:38 +11:00
|
|
|
|
|
|
|
'Constrain parallel': {
|
2024-05-30 13:28:29 +10:00
|
|
|
target: 'Await constrain parallel',
|
2023-10-16 08:54:38 +11:00
|
|
|
cond: 'Can canstrain parallel',
|
|
|
|
},
|
|
|
|
|
|
|
|
'Constrain remove constraints': {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
internal: true,
|
|
|
|
cond: 'Can constrain remove constraints',
|
|
|
|
actions: ['Constrain remove constraints'],
|
|
|
|
},
|
2023-10-18 08:03:02 +11:00
|
|
|
|
|
|
|
'Re-execute': {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
internal: true,
|
2024-02-13 07:41:37 +11:00
|
|
|
actions: ['set sketchMetadata from pathToNode'],
|
2023-10-18 08:03:02 +11:00
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
|
2024-02-11 12:59:00 +11:00
|
|
|
'Equip Line tool': 'Line tool',
|
2023-10-11 13:36:54 +11:00
|
|
|
|
2024-02-11 12:59:00 +11:00
|
|
|
'Equip tangential arc to': {
|
|
|
|
target: 'Tangential arc to',
|
|
|
|
cond: 'is editing existing sketch',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-04-19 11:56:21 -04:00
|
|
|
|
|
|
|
'Equip rectangle tool': {
|
|
|
|
target: 'Rectangle tool',
|
|
|
|
cond: 'Sketch is empty',
|
|
|
|
},
|
2024-05-06 19:28:30 +10:00
|
|
|
|
|
|
|
'code edit during sketch': 'clean slate',
|
2024-05-24 20:54:42 +10:00
|
|
|
|
|
|
|
'Convert to variable': {
|
|
|
|
target: 'Await convert to variable',
|
|
|
|
cond: 'Can convert to variable',
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
2024-02-14 05:35:05 +11:00
|
|
|
entry: 'setup client side sketch segments',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Await horizontal distance info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get horizontal info',
|
|
|
|
id: 'get-horizontal-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Await vertical distance info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get vertical info',
|
|
|
|
id: 'get-vertical-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-12-01 20:18:51 +11:00
|
|
|
'Await ABS X info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get ABS X info',
|
|
|
|
id: 'get-abs-x-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Await ABS Y info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get ABS Y info',
|
|
|
|
id: 'get-abs-y-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-10-11 13:36:54 +11:00
|
|
|
'Await angle info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get angle info',
|
|
|
|
id: 'get-angle-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Await length info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get length info',
|
|
|
|
id: 'get-length-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
2023-10-16 08:54:38 +11:00
|
|
|
|
|
|
|
'Await perpendicular distance info': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get perpendicular distance info',
|
|
|
|
id: 'get-perpendicular-distance-info',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
},
|
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
|
|
|
|
'Line tool': {
|
2024-02-20 11:04:42 +11:00
|
|
|
exit: [],
|
2024-02-11 12:59:00 +11:00
|
|
|
|
|
|
|
on: {
|
|
|
|
'Equip tangential arc to': {
|
|
|
|
target: 'Tangential arc to',
|
|
|
|
cond: 'is editing existing sketch',
|
|
|
|
},
|
2024-04-19 11:56:21 -04:00
|
|
|
|
|
|
|
'Equip rectangle tool': {
|
|
|
|
target: 'Rectangle tool',
|
|
|
|
cond: 'Sketch is empty',
|
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
states: {
|
|
|
|
Init: {
|
|
|
|
always: [
|
|
|
|
{
|
|
|
|
target: 'normal',
|
|
|
|
cond: 'is editing existing sketch',
|
|
|
|
actions: 'set up draft line',
|
|
|
|
},
|
|
|
|
'No Points',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2024-04-02 20:20:42 +11:00
|
|
|
normal: {},
|
2024-02-11 12:59:00 +11:00
|
|
|
|
|
|
|
'No Points': {
|
|
|
|
entry: 'setup noPoints onClick listener',
|
|
|
|
|
|
|
|
on: {
|
|
|
|
'Add start point': {
|
|
|
|
target: 'normal',
|
|
|
|
actions: 'set up draft line without teardown',
|
|
|
|
},
|
2024-02-14 05:35:05 +11:00
|
|
|
|
|
|
|
Cancel: '#Modeling.Sketch.undo startSketchOn',
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
initial: 'Init',
|
|
|
|
},
|
|
|
|
|
|
|
|
Init: {
|
|
|
|
always: [
|
|
|
|
{
|
|
|
|
target: 'SketchIdle',
|
|
|
|
cond: 'is editing existing sketch',
|
|
|
|
},
|
|
|
|
'Line tool',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
'Tangential arc to': {
|
|
|
|
entry: 'set up draft arc',
|
|
|
|
|
|
|
|
on: {
|
|
|
|
'Equip Line tool': 'Line tool',
|
|
|
|
},
|
|
|
|
},
|
2024-02-14 05:35:05 +11:00
|
|
|
|
|
|
|
'undo startSketchOn': {
|
|
|
|
invoke: {
|
|
|
|
src: 'AST-undo-startSketchOn',
|
|
|
|
id: 'AST-undo-startSketchOn',
|
|
|
|
onDone: '#Modeling.idle',
|
|
|
|
},
|
|
|
|
},
|
2024-04-19 11:56:21 -04:00
|
|
|
|
|
|
|
'Rectangle tool': {
|
|
|
|
entry: ['listen for rectangle origin'],
|
2024-05-06 19:28:30 +10:00
|
|
|
|
2024-04-19 11:56:21 -04:00
|
|
|
states: {
|
|
|
|
'Awaiting second corner': {},
|
|
|
|
|
|
|
|
'Awaiting origin': {
|
|
|
|
on: {
|
|
|
|
'Add rectangle origin': {
|
|
|
|
target: 'Awaiting second corner',
|
|
|
|
actions: 'set up draft rectangle',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
initial: 'Awaiting origin',
|
|
|
|
},
|
2024-05-06 19:28:30 +10:00
|
|
|
|
|
|
|
'clean slate': {
|
|
|
|
always: 'SketchIdle',
|
|
|
|
},
|
2024-05-24 20:54:42 +10:00
|
|
|
|
|
|
|
'Await convert to variable': {
|
|
|
|
invoke: {
|
|
|
|
src: 'Get convert to variable info',
|
|
|
|
id: 'get-convert-to-variable-info',
|
|
|
|
onError: 'SketchIdle',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set sketchDetails',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-05-30 13:28:29 +10:00
|
|
|
|
2024-05-30 19:43:35 +10:00
|
|
|
'Await constrain horizontally': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-horizontally',
|
|
|
|
id: 'do-constrain-horizontally',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'Await constrain vertically': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-vertically',
|
|
|
|
id: 'do-constrain-vertically',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-05-30 13:28:29 +10:00
|
|
|
'Await constrain horizontally align': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-horizontally-align',
|
|
|
|
id: 'do-constrain-horizontally-align',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'Await constrain vertically align': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-vertically-align',
|
|
|
|
id: 'do-constrain-vertically-align',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'Await constrain snap to X': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-snap-to-x',
|
|
|
|
id: 'do-constrain-snap-to-x',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'Await constrain snap to Y': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-snap-to-y',
|
|
|
|
id: 'do-constrain-snap-to-y',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'Await constrain equal length': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-equal-length',
|
|
|
|
id: 'do-constrain-equal-length',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'Await constrain parallel': {
|
|
|
|
invoke: {
|
|
|
|
src: 'do-constrain-parallel',
|
|
|
|
id: 'do-constrain-parallel',
|
|
|
|
onDone: {
|
|
|
|
target: 'SketchIdle',
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
2024-02-11 12:59:00 +11:00
|
|
|
initial: 'Init',
|
2023-10-11 13:36:54 +11:00
|
|
|
|
|
|
|
on: {
|
|
|
|
CancelSketch: '.SketchIdle',
|
2024-05-24 20:54:42 +10:00
|
|
|
|
|
|
|
'Delete segment': {
|
|
|
|
internal: true,
|
|
|
|
actions: 'Delete segment',
|
|
|
|
},
|
2024-05-06 19:28:30 +10:00
|
|
|
'code edit during sketch': '.clean slate',
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
2024-02-11 12:59:00 +11:00
|
|
|
exit: [
|
|
|
|
'sketch exit execute',
|
|
|
|
'animate after sketch',
|
|
|
|
'tear down client sketch',
|
|
|
|
'remove sketch grid',
|
2024-03-02 08:20:50 +11:00
|
|
|
'engineToClient cam sync direction',
|
2024-05-24 20:54:42 +10:00
|
|
|
'Reset Segment Overlays',
|
2024-02-11 12:59:00 +11:00
|
|
|
],
|
|
|
|
|
2024-04-22 20:14:06 +10:00
|
|
|
entry: [
|
|
|
|
'add axis n grid',
|
|
|
|
'conditionally equip line tool',
|
|
|
|
'clientToEngine cam sync direction',
|
|
|
|
],
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
'Sketch no face': {
|
2024-03-28 17:22:11 +11:00
|
|
|
entry: ['show default planes', 'set selection filter to faces only'],
|
2023-10-11 13:36:54 +11:00
|
|
|
|
2024-03-28 17:22:11 +11:00
|
|
|
exit: ['hide default planes', 'set selection filter to defaults'],
|
2023-10-11 13:36:54 +11:00
|
|
|
on: {
|
|
|
|
'Select default plane': {
|
2024-02-11 12:59:00 +11:00
|
|
|
target: 'animating to plane',
|
|
|
|
actions: ['reset sketch metadata'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'animating to plane': {
|
|
|
|
invoke: {
|
|
|
|
src: 'animate-to-face',
|
|
|
|
id: 'animate-to-face',
|
|
|
|
onDone: {
|
2023-10-11 13:36:54 +11:00
|
|
|
target: 'Sketch',
|
2024-02-11 12:59:00 +11:00
|
|
|
actions: 'set new sketch metadata',
|
|
|
|
},
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
|
|
|
|
'animating to existing sketch': {
|
|
|
|
invoke: [
|
|
|
|
{
|
|
|
|
src: 'animate-to-sketch',
|
|
|
|
id: 'animate-to-sketch',
|
2024-03-22 10:23:04 +11:00
|
|
|
onDone: {
|
|
|
|
target: 'Sketch',
|
|
|
|
actions: 'set new sketch metadata',
|
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
|
|
|
|
initial: 'idle',
|
|
|
|
|
|
|
|
on: {
|
|
|
|
Cancel: {
|
|
|
|
target: 'idle',
|
2023-11-01 17:34:54 -05:00
|
|
|
// TODO what if we're existing extrude equipped, should these actions still be fired?
|
|
|
|
// maybe cancel needs to have a guard for if else logic?
|
2024-02-13 07:41:37 +11:00
|
|
|
actions: ['reset sketch metadata'],
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
|
|
|
|
'Set selection': {
|
|
|
|
internal: true,
|
|
|
|
actions: 'Set selection',
|
|
|
|
},
|
2024-05-06 19:28:30 +10:00
|
|
|
|
2024-04-04 11:07:51 +11:00
|
|
|
'Set mouse state': {
|
|
|
|
internal: true,
|
|
|
|
actions: 'Set mouse state',
|
|
|
|
},
|
2024-05-24 20:54:42 +10:00
|
|
|
'Set Segment Overlays': {
|
|
|
|
internal: true,
|
|
|
|
actions: 'Set Segment Overlays',
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
guards: {
|
2024-03-22 10:23:04 +11:00
|
|
|
'is editing existing sketch': ({ sketchDetails }) => {
|
2024-02-11 12:59:00 +11:00
|
|
|
// should check that the variable declaration is a pipeExpression
|
|
|
|
// and that the pipeExpression contains a "startProfileAt" callExpression
|
2024-03-22 10:23:04 +11:00
|
|
|
if (!sketchDetails?.sketchPathToNode) return false
|
2024-02-11 12:59:00 +11:00
|
|
|
const variableDeclaration = getNodeFromPath<VariableDeclarator>(
|
|
|
|
kclManager.ast,
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails.sketchPathToNode,
|
2024-02-11 12:59:00 +11:00
|
|
|
'VariableDeclarator'
|
|
|
|
).node
|
|
|
|
if (variableDeclaration.type !== 'VariableDeclarator') return false
|
|
|
|
const pipeExpression = variableDeclaration.init
|
|
|
|
if (pipeExpression.type !== 'PipeExpression') return false
|
|
|
|
const hasStartProfileAt = pipeExpression.body.some(
|
|
|
|
(item) =>
|
|
|
|
item.type === 'CallExpression' &&
|
|
|
|
item.callee.name === 'startProfileAt'
|
|
|
|
)
|
|
|
|
return hasStartProfileAt && pipeExpression.body.length > 2
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
'Can make selection horizontal': ({ selectionRanges }) =>
|
|
|
|
horzVertInfo(selectionRanges, 'horizontal').enabled,
|
|
|
|
'Can make selection vertical': ({ selectionRanges }) =>
|
|
|
|
horzVertInfo(selectionRanges, 'vertical').enabled,
|
|
|
|
'Can constrain horizontal distance': ({ selectionRanges }) =>
|
|
|
|
horzVertDistanceInfo({ selectionRanges, constraint: 'setHorzDistance' })
|
|
|
|
.enabled,
|
|
|
|
'Can constrain vertical distance': ({ selectionRanges }) =>
|
|
|
|
horzVertDistanceInfo({ selectionRanges, constraint: 'setVertDistance' })
|
|
|
|
.enabled,
|
2023-12-01 20:18:51 +11:00
|
|
|
'Can constrain ABS X': ({ selectionRanges }) =>
|
|
|
|
absDistanceInfo({ selectionRanges, constraint: 'xAbs' }).enabled,
|
|
|
|
'Can constrain ABS Y': ({ selectionRanges }) =>
|
|
|
|
absDistanceInfo({ selectionRanges, constraint: 'yAbs' }).enabled,
|
2023-10-11 13:36:54 +11:00
|
|
|
'Can constrain angle': ({ selectionRanges }) =>
|
2023-12-01 20:18:51 +11:00
|
|
|
angleBetweenInfo({ selectionRanges }).enabled ||
|
|
|
|
angleLengthInfo({ selectionRanges, angleOrLength: 'setAngle' }).enabled,
|
2023-10-11 13:36:54 +11:00
|
|
|
'Can constrain length': ({ selectionRanges }) =>
|
2023-12-01 20:18:51 +11:00
|
|
|
angleLengthInfo({ selectionRanges }).enabled,
|
2023-10-16 08:54:38 +11:00
|
|
|
'Can constrain perpendicular distance': ({ selectionRanges }) =>
|
|
|
|
intersectInfo({ selectionRanges }).enabled,
|
2023-10-11 13:36:54 +11:00
|
|
|
'Can constrain horizontally align': ({ selectionRanges }) =>
|
|
|
|
horzVertDistanceInfo({ selectionRanges, constraint: 'setHorzDistance' })
|
|
|
|
.enabled,
|
|
|
|
'Can constrain vertically align': ({ selectionRanges }) =>
|
|
|
|
horzVertDistanceInfo({ selectionRanges, constraint: 'setHorzDistance' })
|
|
|
|
.enabled,
|
2023-12-01 20:18:51 +11:00
|
|
|
'Can constrain snap to X': ({ selectionRanges }) =>
|
|
|
|
absDistanceInfo({ selectionRanges, constraint: 'snapToXAxis' }).enabled,
|
|
|
|
'Can constrain snap to Y': ({ selectionRanges }) =>
|
|
|
|
absDistanceInfo({ selectionRanges, constraint: 'snapToYAxis' }).enabled,
|
2023-10-11 13:36:54 +11:00
|
|
|
'Can constrain equal length': ({ selectionRanges }) =>
|
|
|
|
setEqualLengthInfo({ selectionRanges }).enabled,
|
2023-10-16 08:54:38 +11:00
|
|
|
'Can canstrain parallel': ({ selectionRanges }) =>
|
|
|
|
equalAngleInfo({ selectionRanges }).enabled,
|
|
|
|
'Can constrain remove constraints': ({ selectionRanges }) =>
|
|
|
|
removeConstrainingValuesInfo({ selectionRanges }).enabled,
|
2024-05-24 20:54:42 +10:00
|
|
|
'Can convert to variable': (_, { data }) => {
|
|
|
|
if (!data) return false
|
|
|
|
return isNodeSafeToReplacePath(
|
|
|
|
parse(recast(kclManager.ast)),
|
|
|
|
data.pathToNode
|
|
|
|
).isSafe
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
// end guards
|
2023-10-11 13:36:54 +11:00
|
|
|
actions: {
|
2024-03-22 10:23:04 +11:00
|
|
|
'set sketchMetadata from pathToNode': assign(({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails?.sketchPathToNode || !sketchDetails) return {}
|
|
|
|
return {
|
|
|
|
sketchDetails: {
|
|
|
|
...sketchDetails,
|
|
|
|
sketchPathToNode: sketchDetails.sketchPathToNode,
|
|
|
|
},
|
|
|
|
}
|
2023-10-18 08:03:02 +11:00
|
|
|
}),
|
2024-02-17 07:04:24 +11:00
|
|
|
'hide default planes': () => {
|
|
|
|
sceneInfra.removeDefaultPlanes()
|
|
|
|
kclManager.hidePlanes()
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
'reset sketch metadata': assign({
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails: null,
|
2023-10-11 13:36:54 +11:00
|
|
|
sketchEnginePathId: '',
|
|
|
|
sketchPlaneId: '',
|
|
|
|
}),
|
2024-03-22 10:23:04 +11:00
|
|
|
'set new sketch metadata': assign((_, { data }) => ({
|
|
|
|
sketchDetails: data,
|
|
|
|
})),
|
2023-10-16 08:54:38 +11:00
|
|
|
// TODO implement source ranges for all of these constraints
|
|
|
|
// need to make the async like the modal constraints
|
2024-03-22 10:23:04 +11:00
|
|
|
'Constrain remove constraints': ({ selectionRanges, sketchDetails }) => {
|
2023-11-01 07:39:31 -04:00
|
|
|
const { modifiedAst } = applyRemoveConstrainingValues({
|
2023-10-16 08:54:38 +11:00
|
|
|
selectionRanges,
|
2023-10-11 13:36:54 +11:00
|
|
|
})
|
2024-03-22 10:23:04 +11:00
|
|
|
if (!sketchDetails) return
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneEntitiesManager.updateAstAndRejigSketch(
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
2024-02-11 12:59:00 +11:00
|
|
|
)
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-04-19 14:24:40 -07:00
|
|
|
'AST extrude': async (_, event) => {
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
if (!event.data) return
|
|
|
|
const { selection, distance } = event.data
|
2024-02-23 11:24:22 -05:00
|
|
|
let ast = kclManager.ast
|
|
|
|
if (
|
|
|
|
'variableName' in distance &&
|
|
|
|
distance.variableName &&
|
|
|
|
distance.insertIndex !== undefined
|
|
|
|
) {
|
|
|
|
const newBody = [...ast.body]
|
|
|
|
newBody.splice(
|
|
|
|
distance.insertIndex,
|
|
|
|
0,
|
|
|
|
distance.variableDeclarationAst
|
|
|
|
)
|
|
|
|
ast.body = newBody
|
|
|
|
}
|
2023-10-11 13:36:54 +11:00
|
|
|
const pathToNode = getNodePathFromSourceRange(
|
2024-02-23 11:24:22 -05:00
|
|
|
ast,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
selection.codeBasedSelections[0].range
|
2023-10-11 13:36:54 +11:00
|
|
|
)
|
|
|
|
const { modifiedAst, pathToExtrudeArg } = extrudeSketch(
|
2024-02-23 11:24:22 -05:00
|
|
|
ast,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
pathToNode,
|
|
|
|
true,
|
2024-02-23 11:24:22 -05:00
|
|
|
'variableName' in distance
|
|
|
|
? distance.variableIdentifierAst
|
|
|
|
: distance.valueAst
|
2023-10-11 13:36:54 +11:00
|
|
|
)
|
2024-04-19 14:24:40 -07:00
|
|
|
const selections = await kclManager.updateAst(modifiedAst, true, {
|
2023-10-11 13:36:54 +11:00
|
|
|
focusPath: pathToExtrudeArg,
|
|
|
|
})
|
2024-04-19 14:24:40 -07:00
|
|
|
if (selections) {
|
|
|
|
editorManager.selectRange(selections)
|
|
|
|
}
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-02-14 05:35:05 +11:00
|
|
|
'conditionally equip line tool': (_, { type }) => {
|
|
|
|
if (type === 'done.invoke.animate-to-face') {
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneInfra.modelingSend('Equip Line tool')
|
2024-02-14 05:35:05 +11:00
|
|
|
}
|
|
|
|
},
|
2024-03-22 10:23:04 +11:00
|
|
|
'setup client side sketch segments': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
2024-03-25 15:20:43 +11:00
|
|
|
;(async () => {
|
|
|
|
if (Object.keys(sceneEntitiesManager.activeSegments).length > 0) {
|
|
|
|
await sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
|
|
|
}
|
2024-04-03 13:22:56 +11:00
|
|
|
sceneInfra.resetMouseListeners()
|
2024-03-25 15:20:43 +11:00
|
|
|
await sceneEntitiesManager.setupSketch({
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchPathToNode: sketchDetails?.sketchPathToNode || [],
|
|
|
|
forward: sketchDetails.zAxis,
|
|
|
|
up: sketchDetails.yAxis,
|
|
|
|
position: sketchDetails.origin,
|
2024-03-25 15:20:43 +11:00
|
|
|
maybeModdedAst: kclManager.ast,
|
2024-02-11 12:59:00 +11:00
|
|
|
})
|
2024-04-03 13:22:56 +11:00
|
|
|
sceneInfra.resetMouseListeners()
|
|
|
|
sceneEntitiesManager.setupSketchIdleCallbacks({
|
|
|
|
pathToNode: sketchDetails?.sketchPathToNode || [],
|
|
|
|
forward: sketchDetails.zAxis,
|
|
|
|
up: sketchDetails.yAxis,
|
|
|
|
position: sketchDetails.origin,
|
|
|
|
})
|
2024-03-25 15:20:43 +11:00
|
|
|
})()
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
'animate after sketch': () => {
|
2024-04-22 20:14:06 +10:00
|
|
|
engineCommandManager
|
|
|
|
.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
2024-05-03 14:45:39 -07:00
|
|
|
type: 'sketch_mode_disable',
|
2024-04-22 20:14:06 +10:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(async () => {
|
|
|
|
// there doesn't appear to be an animation, but if there was one we could add a wait here
|
2024-05-22 11:19:13 +10:00
|
|
|
|
2024-04-22 20:14:06 +10:00
|
|
|
await engineCommandManager.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'default_camera_set_perspective',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
sceneInfra.camControls.syncDirection = 'engineToClient'
|
2024-05-22 11:19:13 +10:00
|
|
|
await engineCommandManager.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'default_camera_set_perspective',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
const center = { x: 0, y: 0, z: 0 }
|
|
|
|
const camPos = sceneInfra.camControls.camera.position
|
|
|
|
if (camPos.x === 0 && camPos.y === 0) {
|
|
|
|
// looking straight up or down is going to cause issues with the engine
|
|
|
|
// tweaking the center to be a little off center
|
|
|
|
// TODO come up with a proper fix
|
|
|
|
center.y = 0.05
|
|
|
|
}
|
|
|
|
await engineCommandManager.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'default_camera_look_at',
|
|
|
|
center,
|
|
|
|
vantage: sceneInfra.camControls.camera.position,
|
|
|
|
up: { x: 0, y: 0, z: 1 },
|
|
|
|
},
|
|
|
|
})
|
2024-04-22 20:14:06 +10:00
|
|
|
await engineCommandManager.sendSceneCommand({
|
|
|
|
// CameraControls subscribes to default_camera_get_settings response events
|
|
|
|
// firing this at connection ensure the camera's are synced initially
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'default_camera_get_settings',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
2024-02-14 05:35:05 +11:00
|
|
|
'tear down client sketch': () => {
|
2024-02-14 08:03:20 +11:00
|
|
|
if (sceneEntitiesManager.activeSegments) {
|
|
|
|
sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
2024-02-14 05:35:05 +11:00
|
|
|
}
|
|
|
|
},
|
2024-02-14 08:03:20 +11:00
|
|
|
'remove sketch grid': () => sceneEntitiesManager.removeSketchGrid(),
|
2024-03-22 10:23:04 +11:00
|
|
|
'set up draft line': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
2024-03-25 15:20:43 +11:00
|
|
|
sceneEntitiesManager.setUpDraftSegment(
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails.sketchPathToNode,
|
|
|
|
sketchDetails.zAxis,
|
2024-03-25 15:20:43 +11:00
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin,
|
|
|
|
'line'
|
2024-03-22 10:23:04 +11:00
|
|
|
)
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
2024-03-22 10:23:04 +11:00
|
|
|
'set up draft arc': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
2024-03-25 15:20:43 +11:00
|
|
|
sceneEntitiesManager.setUpDraftSegment(
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails.sketchPathToNode,
|
|
|
|
sketchDetails.zAxis,
|
2024-03-25 15:20:43 +11:00
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin,
|
|
|
|
'tangentialArcTo'
|
|
|
|
)
|
|
|
|
},
|
2024-04-19 11:56:21 -04:00
|
|
|
'listen for rectangle origin': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
|
|
|
sceneEntitiesManager.setupRectangleOriginListener()
|
|
|
|
},
|
|
|
|
'set up draft rectangle': ({ sketchDetails }, { data }) => {
|
|
|
|
if (!sketchDetails || !data) return
|
|
|
|
sceneEntitiesManager.setupDraftRectangle(
|
|
|
|
sketchDetails.sketchPathToNode,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
},
|
2024-03-25 15:20:43 +11:00
|
|
|
'set up draft line without teardown': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
|
|
|
sceneEntitiesManager.setUpDraftSegment(
|
|
|
|
sketchDetails.sketchPathToNode,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin,
|
|
|
|
'line',
|
|
|
|
false
|
2024-03-22 10:23:04 +11:00
|
|
|
)
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
'show default planes': () => {
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneInfra.showDefaultPlanes()
|
|
|
|
sceneEntitiesManager.setupDefaultPlaneHover()
|
2024-02-17 07:04:24 +11:00
|
|
|
kclManager.showPlanes()
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
2024-03-22 10:23:04 +11:00
|
|
|
'setup noPoints onClick listener': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneEntitiesManager.createIntersectionPlane()
|
2024-03-22 10:23:04 +11:00
|
|
|
const quaternion = quaternionFromUpNForward(
|
|
|
|
new Vector3(...sketchDetails.yAxis),
|
|
|
|
new Vector3(...sketchDetails.zAxis)
|
|
|
|
)
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneEntitiesManager.intersectionPlane &&
|
|
|
|
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
|
2024-02-11 12:59:00 +11:00
|
|
|
quaternion
|
|
|
|
)
|
2024-03-22 10:23:04 +11:00
|
|
|
sceneEntitiesManager.intersectionPlane &&
|
|
|
|
sceneEntitiesManager.intersectionPlane.position.copy(
|
|
|
|
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
|
|
|
|
)
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneInfra.setCallbacks({
|
2024-02-11 12:59:00 +11:00
|
|
|
onClick: async (args) => {
|
|
|
|
if (!args) return
|
2024-03-03 16:23:16 +11:00
|
|
|
if (args.mouseEvent.which !== 1) return
|
|
|
|
const { intersectionPoint } = args
|
2024-03-22 10:23:04 +11:00
|
|
|
if (!intersectionPoint?.twoD || !sketchDetails?.sketchPathToNode)
|
|
|
|
return
|
2024-02-11 12:59:00 +11:00
|
|
|
const { modifiedAst } = addStartProfileAt(
|
|
|
|
kclManager.ast,
|
2024-03-22 10:23:04 +11:00
|
|
|
sketchDetails.sketchPathToNode,
|
2024-03-03 16:23:16 +11:00
|
|
|
[intersectionPoint.twoD.x, intersectionPoint.twoD.y]
|
2024-02-11 12:59:00 +11:00
|
|
|
)
|
|
|
|
await kclManager.updateAst(modifiedAst, false)
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneEntitiesManager.removeIntersectionPlane()
|
|
|
|
sceneInfra.modelingSend('Add start point')
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
2024-03-22 10:23:04 +11:00
|
|
|
'add axis n grid': ({ sketchDetails }) => {
|
|
|
|
if (!sketchDetails) return
|
|
|
|
sceneEntitiesManager.createSketchAxis(
|
|
|
|
sketchDetails.sketchPathToNode || [],
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
},
|
2024-02-19 12:41:36 +11:00
|
|
|
'reset client scene mouse handlers': () => {
|
|
|
|
// when not in sketch mode we don't need any mouse listeners
|
|
|
|
// (note the orbit controls are always active though)
|
2024-02-20 11:04:42 +11:00
|
|
|
sceneInfra.resetMouseListeners()
|
2024-02-19 12:41:36 +11:00
|
|
|
},
|
2024-03-02 08:20:50 +11:00
|
|
|
'clientToEngine cam sync direction': () => {
|
|
|
|
sceneInfra.camControls.syncDirection = 'clientToEngine'
|
|
|
|
},
|
|
|
|
'engineToClient cam sync direction': () => {
|
|
|
|
sceneInfra.camControls.syncDirection = 'engineToClient'
|
|
|
|
},
|
2024-03-28 17:22:11 +11:00
|
|
|
'set selection filter to faces only': () =>
|
|
|
|
engineCommandManager.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'set_selection_filter',
|
2024-04-22 20:14:06 +10:00
|
|
|
filter: ['face', 'plane'],
|
2024-03-28 17:22:11 +11:00
|
|
|
},
|
|
|
|
}),
|
2024-05-21 05:55:34 +10:00
|
|
|
'set selection filter to defaults': () =>
|
|
|
|
kclManager.defaultSelectionFilter(),
|
2024-05-24 20:54:42 +10:00
|
|
|
'Delete segment': ({ sketchDetails }, { data: pathToNode }) =>
|
|
|
|
deleteSegment({ pathToNode, sketchDetails }),
|
|
|
|
'Reset Segment Overlays': () => sceneEntitiesManager.resetOverlays(),
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
// end actions
|
2024-05-30 13:28:29 +10:00
|
|
|
services: {
|
2024-05-30 19:43:35 +10:00
|
|
|
'do-constrain-horizontally': async ({
|
|
|
|
selectionRanges,
|
|
|
|
sketchDetails,
|
|
|
|
}) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert(
|
|
|
|
selectionRanges,
|
|
|
|
'horizontal',
|
|
|
|
kclManager.ast,
|
|
|
|
kclManager.programMemory
|
|
|
|
)
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails.sketchPathToNode,
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-vertically': async ({ selectionRanges, sketchDetails }) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert(
|
|
|
|
selectionRanges,
|
|
|
|
'vertical',
|
|
|
|
kclManager.ast,
|
|
|
|
kclManager.programMemory
|
|
|
|
)
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
2024-05-30 13:28:29 +10:00
|
|
|
'do-constrain-horizontally-align': async ({
|
|
|
|
selectionRanges,
|
|
|
|
sketchDetails,
|
|
|
|
}) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({
|
|
|
|
selectionRanges,
|
|
|
|
constraint: 'setVertDistance',
|
|
|
|
})
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-vertically-align': async ({
|
|
|
|
selectionRanges,
|
|
|
|
sketchDetails,
|
|
|
|
}) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({
|
|
|
|
selectionRanges,
|
|
|
|
constraint: 'setHorzDistance',
|
|
|
|
})
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-snap-to-x': async ({ selectionRanges, sketchDetails }) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintAxisAlign({
|
|
|
|
selectionRanges,
|
|
|
|
constraint: 'snapToXAxis',
|
|
|
|
})
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-snap-to-y': async ({ selectionRanges, sketchDetails }) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintAxisAlign({
|
|
|
|
selectionRanges,
|
|
|
|
constraint: 'snapToYAxis',
|
|
|
|
})
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-parallel': async ({ selectionRanges, sketchDetails }) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintEqualAngle({
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
if (!sketchDetails) throw new Error('No sketch details')
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
parse(recast(modifiedAst)),
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'do-constrain-equal-length': async ({
|
|
|
|
selectionRanges,
|
|
|
|
sketchDetails,
|
|
|
|
}) => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = applyConstraintEqualLength({
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
if (!sketchDetails) return
|
|
|
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
|
|
|
sketchDetails?.sketchPathToNode || [],
|
|
|
|
modifiedAst,
|
|
|
|
sketchDetails.zAxis,
|
|
|
|
sketchDetails.yAxis,
|
|
|
|
sketchDetails.origin
|
|
|
|
)
|
|
|
|
const updatedSelectionRanges = updateSelections(
|
|
|
|
pathToNodeMap,
|
|
|
|
selectionRanges,
|
|
|
|
parse(recast(modifiedAst))
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: updatedSelectionRanges,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// end services
|
2023-10-11 13:36:54 +11:00
|
|
|
}
|
|
|
|
)
|