2024-02-11 12:59:00 +11:00
import { PathToNode , VariableDeclarator } from 'lang/wasm'
2024-03-22 10:23:04 +11:00
import { Axis , Selection , Selections } from 'lib/selections'
2023-10-11 13:36:54 +11:00
import { assign , createMachine } from 'xstate'
2024-01-31 10:17:24 +01:00
import { getNodePathFromSourceRange } from 'lang/queryAst'
2024-03-22 16:55:30 +11:00
import { kclManager , sceneInfra , sceneEntitiesManager } 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'
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
}
| {
selectionType : 'mirrorCodeMirrorSelections'
selection : Selections
}
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 ]
}
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
}
| {
type : 'extrudeFace'
position : [ number , number , number ]
extrudeSegmentPathToNode : PathToNode
cap : 'start' | 'end' | 'none'
}
)
2023-10-16 21:20:05 +11:00
}
2024-02-11 12:59:00 +11: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-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
}
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-03-25 15:20:43 +11:00
/ * * @ x s t a t e - l a y o u t N 4 I g p g J g 5 m D O I C 5 Q F k D 2 E w B s C W A 7 K A x A M I C G u A x l g N o A M A u o q A A 6 q z Y A u 2 q u j I A H o g C 0 A d g C s A Z g B 0 4 g E y j h A D n E A 2 G g o U A W J Q B o Q A T 0 Q B G G u I C c k m o Z k b T M 4 2 Y W K A v k 9 1 o M O f A Q D K Y d g A J Y L D B y T m 5 a B i Q Q F j Y w n i i B B F t p G h l x D R p h G g 1 Z U R l h X Q M E c R L D S V F 5 U w V 8 4 X E K 8 R c 3 d C w 8 K E l s C E w w H z 9 A 4 N C u X A j e G I 5 B 3 k T B L W F J D W V 5 h V S Z Z T r l B U K j S 1 F Z i U r D e W V D a s a Q d x b 8 d s 7 u g F F c d j A A J 0 C A a z 9 y A A t h q N G 4 i a F l m Z W Z S m Z R a K y G Q z K Y Q a D Y I G S m D S z d K y D S G c Q 0 K r A k 5 n T x t D p d A i 3 e 5 P W C v d g f K i G S L M V h j b h - B C C a w 0 W a Q r Z q d G L A r 6 R A Z G S S W z C Z S i I E K N F i 5 T Y 5 q 4 y 4 E 6 5 8 d g P A C u G C + N N i 4 w S Q g q M 3 h N F E w N E G l E Y t h E N E L J k C j W p l M F p s G l R U o 8 r V l N z 4 L A e 7 D V 0 V p v y 1 j K t C k k V u Z M j s D p N s O E w j K U I k c x N q W h o m d 5 z a 3 j J H 2 I Z E o m E z b 0 + 9 B G f s 1 o E S E O t k m M 0 K 0 a h M p l k Z q O Z U r Y r R l g U J r T M o L 5 P e k j 7 H w A k l c e g E g l 0 B u F i 9 9 S - S A 4 Z o W U d W s T S L l s o z Z l z N k Z P r G 0 a 5 F 2 e 6 6 h w P z 6 O C c g S K 8 + l A A L Z g O 7 + A B u j 0 4 5 B I m B 9 P z L - C M e F W 2 q T Q h U 0 Z M z V R K R 0 R o V J 6 n y J Q N F P C 5 z 0 H L N 3 i v b o b z v I J H 2 f A J 3 l Q B 5 s A A L 2 4 d h v 1 - e d 4 n L Q D o U k V R r X 1 C F 8 i h G Q z X E C F y m N L J I U 4 - U 8 m Q j N 0 L Q w t M O I b h Y E V E g 8 H 8 Q j i L I u 5 v 3 8 C B s C k 3 M w C o j U F 1 o h A r C N C w N D S D F E N M I 5 1 h 5 O E z G U C w K g t b J R D M t E h N E - t X J H M c i E k 6 T Z P f L 1 s C - T A V L U i i K E 0 2 d 1 T p G i A L 0 5 Z g z t K 0 R V B Y x N H Y y z w 1 q c p r C O D Q Y 2 E Z Y j R c 1 D L 0 8 7 y H h k 3 B - A A Q Q A I W 8 f w A A 0 t K i h k r C 7 J E x E M G x O P h N J Y X h A y 7 S h R Y 4 N M W o G l c U 5 p T P E S S o J L z c C k 8 r Z N q + q A E 1 m v 9 X S 2 u 2 a w 7 G U O R 9 m F A 7 Y U 5 Y N 8 r s t l H E d I r Z v Q 8 S F q W i r - D I K A u k 2 - 8 K 2 R a Q l B A + Q x W E U x + o t X V 1 z y g 1 A b G 2 7 C 3 c j D S s W n z K q 6 f B 2 C L a l f W 0 6 K v v E G Y V A N D E 0 T S f Z + s O c 7 g V R Q H H S U K F o b c u b u k e x H - C Y R 4 W d w V T y C V T A S C e V T 1 L C j 6 d J i q w r V m W 0 e o y I 5 V C 3 d K x U R W M q j G - L H V y 1 N J p x G a Y f p i S E e W y r 5 N I 8 j v 0 w P Q X p w K A h g i j G W s X Z Z + S 7 T Q u 3 S I 0 a B W M 0 k p D O 1 Q P y s Q V g m p o X R Q u 6 x P h p 7 f I - A L j d N 7 9 s A t w W s b o 8 w c i t Q G k r M E U z Q O 7 Y T T G z F q i q W p a Y + W G H r K 5 7 Y F w E g m H 8 d h U E a + P W s 4 q R l n E R Y F D G 6 o z H 6 v c Q z k e Z 5 n 1 R x w y L i 9 7 t D p m K 6 r m u 6 4 2 q 2 - y F r 6 0 Q s I V O J j H H j B h d K u p m I 0 h 8 c p c 5 h y E e S - H v X - D A A B H J V l O R q B U Y b 2 3 G 3 K b f A a y P I J G 5 I o l 3 R J E T F g - V j q m G P t r R m Z 8 m A 8 2 N t Q O e 1 F G 7 5 A s O G F Y + x G w U 0 3 l - R s M w T C c U O L a T I a g 1 Y B 3 T L D E + 8 0 y 6 y Q e G A B 8 q B 3 z + H I K Q u 4 s A H 7 b W s M G Q 4 1 g D R W l R C a c Q Z o l B l E s M C f c O R O Q H W A W P A k A A l M A g g w B 8 B C E q e 4 j D h Z 1 C k G i V Q + k d Q G l h C C G y j k 1 4 m i s G Z b I o i Q 5 y i v t g a u A A Z P A Y B p 6 o B - N A z G r V 2 4 6 J K K C W 0 C Z 1 C w i U N n T I e 0 5 C J g h M Y - s 4 l r h m O r q F G A d x s D K R 5 u Q a e i j E j 7 W D K 3 A 0 W D - r K O b J Y S Q Y F V D p M d K C Y + V U A D u M k C J E U N k p I K f N Q q U H 8 H g A A Z q g A g E B u B g H a L g V 8 q B X i S B g O w Q Q B t F I U U w I I B p q A E m I G M o i f J G Q x p m C V t w 9 K q J z B d l D F g 2 w E N C k l I 4 H J c p g z l L V I 0 n U 3 A j S C C P A e E R S Q T B u b s E a Q 8 B 8 P S - D 9 N 2 U b Y Z o z x l W X 1 N W L q q I 0 T G i t G N f q r d + T Z F d r B O o r F D C b N K W + C O g V g r 8 1 q a M 5 p r T 2 m d O 6 b 0 w Q f l P z f h G c c s Z D i b a 6 S J v y N E i h 7 B Q k M I K f q V o p C O H f n Y U o + U o X b K x Z H K p I V D l I r O R c q 5 J A b l E X u R i 1 l g V c W N P e c S y Q i x 5 D 7 z E J o a l R l q z H V S K 3 E C S h m U B F W o 1 I 5 J y W m 4 D a X g N F b S M U k A A E a w E E H w U V + L 0 b z w T l Z S E 2 S D q w X D L s C y R R 4 Q H W r B k V E o J Z A H U L u r a a Q c Y b F O h Z q h q 2 q m n c o e J c 6 5 t z B W P N N e a y 1 b y C V b R i k T G Y Q j 1 B 1 F M P q L Q - U z I 2 T q N a C Q G 9 o R A M D Y H Y S I a t k a r q v 4 N a k b k V 6 t R V 0 o 1 i a z W C D 0 F a 8 V W D p A a M c v C H G x p T q u y z Y r C 0 X D 8 3 q u q g 2 p t X K H j n J j b y - l d y H l 9 K T d 2 3 t a b P o T N X v A l e + V 5 j p E h K d S E i J X b a J d a S m Q s 7 X p d G b b q - V H T 2 0 b s E A + q R q a b U w I D J m l I E J w W O T t I Y Y G B o B T o g t O a E 0 U J h D 3 v w I + x d y 7 Y 1 8 v j e + z 9 O 6 f 2 O L - Z x c 6 2 Q 2 p W D U G Z T + E y R S A j R P I O C + o A S z t v q j J 9 K K D V v o x X R 9 4 m G S z Y a J Z x b Y y c z A o P 3 P k E m 7 V X a M p U E u K w t H n x 3 3 e M 2 6 N K G 1 0 J r 6 a x 9 j c 5 O M Z v 7 c Y E w + i 1 i 5 T S u 6 0 E - J 5 j M I R G I G M B p Z 0 s w e G z D m X M e b w p q T Y p F z 6 2 3 o s e Z Z 6 z A V b M P E E A c s K K n I r p s S X b A U X D r A H T i n I f q 1 R t j r z m M K d x c h - Z T W r U Q 0 N 2 z 3 P P h s 9 z X m H K w q y a X T y u N A r 3 0 Z f Z p 5 7 L P n c u U H 8 9 b Q L E z g t e x R O F t Y k X 0 p 5 W k L G O L w H 3 5 J Y 1 s G t y V i 9 W 2 M w O O P o U 4 4 j i v 3 E n Q j R x M h H D y A s 9 1 Y 1 q x e w x M w x i d 6 q 2 E N Q o N m x t c 7 G E j C T X V 6 + F o l B V i f E 3 d C 8 J k x k R P s M w s F 1 C K x l k U J W S I c a O C y C C Y + u 3 h u S G H L g D g B B J s q E l S k 2 b C I 5 B A 0 s m s M o a R 2 4 P Z x o D N I P 3 r F - Y B 0 D y k W H C U Z v y P y C 0 V o L 2 E e B N G Q G s w V g S H W c C W C + D k v b Z E r 9 - b m B J C 4 A F d + U b k 4 Q g T a u 3 a 6 w m V Z D q C l s y A 0 L 3 E C g h m M u V W c s o K Q q 2 7 2 B n a O m e S A A H J 1 w A A q o D w O w W A B A q o Q A g I E C i X p m a a 7 u O K + Y i I 8 0 G k c k Z R Y o J Y T z C T m Y V + m Q c 0 K F R 0 N p X q v - A a 6 1 z r 0 g Y V 7 H Y 7 q 3 p T Q u 5 Z B A o x F o E 0 b r E C 8 T F t g 0 o V o V j H w x + w Y H P P W r 8 N m F 2 L I K h q N R 7 N G k K Q c w h T L F B c s J 0 c v N Z u T T 8 D q k H G c c V m Y p K v N e a 5 i y F g l 1 I v Z l s l O z m E C b q k p q - 9 e L g A F R O 1 E m J D w 4 m 1 w 5 - 0 b n w e 9 1 w g O u Y Y E S g 7 T o l s P C I v q J J U X v 3 J Y Y 0 3 Y R 8 1 r c h P - A p 3 p + z 6 a a E p U 5 j - C M 9 Q H Y 8 3 j p f 6 K E c h a E 6 l k E Q 2 R j O G O o L I V 2 U v Y + J U d m O u d S L 0 c 8 A A e V w B b R f U N U k C q m 8 D H 0 E D A J a U E E g P Y B g M t i X 2 u z 0 h K G D D y F q C c k d D q D U F h C T A F G w T U F y l b h K D g 1 P 1 h n 8 F Z 3 8 H q R I E o B 6 H G x U j A H Y K 5 g C F 5 T 1 X e S Z C 4 i O A R C R y 0 C h B s F E A d 2 W H 3 z S B y E h i F B s B H h Y L r n Y M 4 N 8 A n A X 0 G H e S F C + R 0 w k D m W y E O F h A d A g x K D s C U A G h X h c j I G w A f D 5 V a G n m Z m 5 j 1 X g J c z a X s M c P u E E F r k E A 0 P C j w L t Q q G A l d x B S W E y F k O S S s B K F S H b m h H U D s M B x 8 O c N r l c L I G 6 C 0 L G y 5 1 0 M z z - X y i + T k C h 0 Y m h E o K 0 G r F W D s F g h W B q G S I c K c P w B c J k R C m c N J E L A 8 K Y 2 6 W 8 L 5 S k X 8 P a P 7 H e S z n g X 9 S q H 2 E U L 0 0 Q F w w Y i h F b h B C e 1 y n d x O F Z w w H g C i D 6 y g E b x D 0 E E W D K F y E U H z 3 U C 0 E W y E E W E l T 3 B Y i F F d j y G H w I R l H x D A C 2 O X 0 E F B C I K h F m U 0 B N F y i 8 T F H K E 5 H u 1 i M s E r T u J r w + C e P w P m J z 0 o 3 z z y E L x h w Y j t E h h M E h D a k b C C Q 8 i 6 H B L t S 6 h M E 9 m h G R 0 + M B l j z 0 k p T u 1 R G M j 9 j z 1 6 y D T P 2 L j S z K Q U h e X s 0 5 T x S x K c T W F m B m U U F j B q F S E B W S G d h g k d 3 y F l x B N
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 [ ] ,
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 : {
'Set selection' : {
target : 'idle' ,
internal : true ,
actions : 'Set selection' ,
} ,
'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 : {
'Set selection' : {
target : 'SketchIdle' ,
internal : true ,
actions : 'Set selection' ,
} ,
'Make segment vertical' : {
cond : 'Can make selection vertical' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Make selection vertical' ] ,
} ,
'Make segment horizontal' : {
target : 'SketchIdle' ,
internal : true ,
cond : 'Can make selection horizontal' ,
actions : [ 'Make selection horizontal' ] ,
} ,
'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' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain horizontally align' ] ,
} ,
'Constrain vertically align' : {
cond : 'Can constrain vertically align' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain vertically align' ] ,
} ,
2023-12-01 20:18:51 +11:00
'Constrain snap to X' : {
cond : 'Can constrain snap to X' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain snap to X' ] ,
} ,
'Constrain snap to Y' : {
cond : 'Can constrain snap to Y' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain snap to Y' ] ,
} ,
2023-10-11 13:36:54 +11:00
'Constrain equal length' : {
cond : 'Can constrain equal length' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain equal length' ] ,
} ,
2023-10-16 08:54:38 +11:00
'Constrain parallel' : {
target : 'SketchIdle' ,
internal : true ,
cond : 'Can canstrain parallel' ,
actions : [ 'Constrain 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-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 : {
'Set selection' : {
target : 'Line tool' ,
description : ` This is just here to stop one of the higher level "Set selections" firing when we are just trying to set the IDE code without triggering a full engine-execute ` ,
internal : true ,
} ,
'Equip tangential arc to' : {
target : 'Tangential arc to' ,
cond : 'is editing existing sketch' ,
} ,
} ,
states : {
Init : {
always : [
{
target : 'normal' ,
cond : 'is editing existing sketch' ,
actions : 'set up draft line' ,
} ,
'No Points' ,
] ,
} ,
normal : {
on : {
'Set selection' : {
target : 'normal' ,
internal : true ,
} ,
} ,
} ,
'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 : {
'Set selection' : {
target : 'Tangential arc to' ,
internal : true ,
} ,
'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' ,
} ,
} ,
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-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-02-11 12:59:00 +11:00
] ,
2024-02-14 05:35:05 +11:00
entry : [ 'add axis n grid' , 'conditionally equip line tool' ] ,
2023-10-11 13:36:54 +11:00
} ,
'Sketch no face' : {
entry : 'show default planes' ,
exit : 'hide default planes' ,
on : {
'Select default plane' : {
2024-02-11 12:59:00 +11:00
target : 'animating to plane' ,
actions : [ 'reset sketch metadata' ] ,
} ,
2024-03-22 10:23:04 +11:00
'Set selection' : {
target : 'Sketch no face' ,
internal : true ,
} ,
2024-02-11 12:59:00 +11:00
} ,
} ,
'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' ,
} ,
} ,
on : {
'Set selection' : {
target : 'animating to plane' ,
internal : true ,
2023-10-11 13:36:54 +11:00
} ,
} ,
2024-03-02 08:20:50 +11:00
entry : 'clientToEngine cam sync direction' ,
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
} ,
] ,
2024-03-02 08:20:50 +11:00
entry : 'clientToEngine cam sync direction' ,
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' : {
target : '#Modeling' ,
internal : true ,
actions : 'Set selection' ,
} ,
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 ,
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
'Make selection horizontal' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'horizontal' ,
kclManager . ast ,
kclManager . programMemory
)
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-03-22 10:23:04 +11:00
'Make selection vertical' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'vertical' ,
kclManager . ast ,
kclManager . programMemory
)
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-03-22 10:23:04 +11:00
'Constrain horizontally align' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setVertDistance' ,
} )
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-03-22 10:23:04 +11:00
'Constrain vertically align' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setHorzDistance' ,
} )
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-03-22 10:23:04 +11:00
'Constrain snap to X' : ( { selectionRanges , sketchDetails } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToXAxis' ,
} )
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-12-01 20:18:51 +11:00
} ,
2024-03-22 10:23:04 +11:00
'Constrain snap to Y' : ( { selectionRanges , sketchDetails } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToYAxis' ,
} )
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-12-01 20:18:51 +11:00
} ,
2024-03-22 10:23:04 +11:00
'Constrain equal length' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualLength ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
} )
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-16 08:54:38 +11:00
} ,
2024-03-22 10:23:04 +11:00
'Constrain parallel' : ( { selectionRanges , sketchDetails } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualAngle ( {
2023-10-16 08:54:38 +11:00
selectionRanges ,
} )
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-16 08:54:38 +11:00
} ,
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
} ,
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
'AST extrude' : ( _ , event ) = > {
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
)
// TODO not handling focusPath correctly I think
2024-02-11 12:59:00 +11:00
kclManager . updateAst ( modifiedAst , true , {
2023-10-11 13:36:54 +11:00
focusPath : pathToExtrudeArg ,
} )
} ,
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 } )
}
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-03-25 15:20:43 +11:00
sceneEntitiesManager . setupSketchIdleCallbacks (
sketchDetails ? . sketchPathToNode || [ ]
)
} ) ( )
2024-02-11 12:59:00 +11:00
} ,
'animate after sketch' : ( ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . animateAfterSketch ( )
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'
)
} ,
'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'
} ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
// end actions
2023-10-11 13:36:54 +11:00
}
)