Circle function and UI tool (#3860)

* circle

* fix another example

* fix bad comment

* toPoint fix

* cargo fmt

* resolve most of the tests

* fix last test

* missed circle in bracket

* remove console error

* fmt

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* trigger ci

* remove three dot menu for circle

* make sure circle can be extruded

* fix up after merge

* add extrude test for circle

* clean up

* typo

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)"

This reverts commit 03f8eeb542.

* update docs again

* cmd bar test serialisation improvements

* tiny clean up

* fix after: Replace kittycad crate with kittycad-modeling-cmds

* fmt

* rename fix

* Update src/lib/toolbar.ts

Co-authored-by: Frank Noirot <frank@zoo.dev>

* add another error to list

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* image updates

* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)"

This reverts commit 505bb20bea.

* update markdown

* skip un reproducable windows test failure

* rust review

* leave issue todo comment

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Frank Noirot <frank@zoo.dev>
This commit is contained in:
Kurt Hutten
2024-09-23 22:42:51 +10:00
committed by GitHub
parent 7848d63177
commit f1b0e40388
122 changed files with 22670 additions and 512 deletions

View File

@ -41,7 +41,7 @@ import {
canSweepSelection,
handleSelectionBatch,
isSelectionLastLine,
isRangeInbetweenCharacters,
isRangeBetweenCharacters,
isSketchPipe,
updateSelections,
} from 'lib/selections'
@ -50,8 +50,7 @@ import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance'
import useStateMachineCommands from 'hooks/useStateMachineCommands'
import { modelingMachineCommandConfig } from 'lib/commandBarConfigs/modelingCommandConfig'
import {
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
SEGMENT_BODIES,
getParentGroup,
getSketchOrientationDetails,
} from 'clientSideScene/sceneEntities'
@ -168,10 +167,7 @@ export const ModelingMachineProvider = ({
if (event.type !== 'Set mouse state') return {}
const nextSegmentHoverMap = () => {
if (event.data.type === 'isHovering') {
const parent = getParentGroup(event.data.on, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
])
const parent = getParentGroup(event.data.on, SEGMENT_BODIES)
const pathToNode = parent?.userData?.pathToNode
const pathToNodeString = JSON.stringify(pathToNode)
if (!parent || !pathToNode) return context.segmentHoverMap
@ -187,10 +183,10 @@ export const ModelingMachineProvider = ({
event.data.type === 'idle' &&
context.mouseState.type === 'isHovering'
) {
const mouseOnParent = getParentGroup(context.mouseState.on, [
STRAIGHT_SEGMENT,
TANGENTIAL_ARC_TO_SEGMENT,
])
const mouseOnParent = getParentGroup(
context.mouseState.on,
SEGMENT_BODIES
)
if (!mouseOnParent || !mouseOnParent?.userData?.pathToNode)
return context.segmentHoverMap
const pathToNodeString = JSON.stringify(
@ -204,8 +200,8 @@ export const ModelingMachineProvider = ({
pathToNodeString,
},
})
// overlay timeout
}, 800) as unknown as number
// overlay timeout is 1s
}, 1000) as unknown as number
return {
...context.segmentHoverMap,
[pathToNodeString]: timeoutId,
@ -495,43 +491,21 @@ export const ModelingMachineProvider = ({
},
},
guards: {
'has valid extrude selection': ({ context: { selectionRanges } }) => {
'has valid sweep selection': ({ context: { selectionRanges } }) => {
// A user can begin extruding if they either have 1+ faces selected or nothing selected
// TODO: I believe this guard only allows for extruding a single face at a time
const isPipe = isSketchPipe(selectionRanges)
if (
const hasNoSelection =
selectionRanges.codeBasedSelections.length === 0 ||
isRangeInbetweenCharacters(selectionRanges) ||
isRangeBetweenCharacters(selectionRanges) ||
isSelectionLastLine(selectionRanges, codeManager.code)
) {
if (hasNoSelection) {
// they have no selection, we should enable the button
// so they can select the face through the cmdbar
// BUT only if there's extrudable geometry
if (doesSceneHaveSweepableSketch(kclManager.ast)) return true
return false
return doesSceneHaveSweepableSketch(kclManager.ast)
}
if (!isPipe) return false
return canSweepSelection(selectionRanges)
},
'has valid revolve selection': ({ context: { selectionRanges } }) => {
// A user can begin extruding if they either have 1+ faces selected or nothing selected
// TODO: I believe this guard only allows for extruding a single face at a time
const isPipe = isSketchPipe(selectionRanges)
if (
selectionRanges.codeBasedSelections.length === 0 ||
isRangeInbetweenCharacters(selectionRanges) ||
isSelectionLastLine(selectionRanges, codeManager.code)
) {
// they have no selection, we should enable the button
// so they can select the face through the cmdbar
// BUT only if there's extrudable geometry
if (doesSceneHaveSweepableSketch(kclManager.ast)) return true
return false
}
if (!isPipe) return false
if (!isSketchPipe(selectionRanges)) return false
return canSweepSelection(selectionRanges)
},