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-25 17:33:59 -04:00
| { type : 'Equip rectangle tool' }
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
}
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 17:33:59 -04: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 h 2 D k L M D E B 4 J D p D d p Z F K 5 g 5 A S G l p i f U - s p q B 2 E j D K q A B 3 G S B E i K G y U k F P m o V K D + D w A A M 1 Q A Q C A 3 A w D t F w K + V A r x J A w H Y I I A 2 i k K K Y E E K 0 1 A C T E D G U R I 6 U E G J a i 2 j X v 1 V E 5 g u y h i w b Y C G x 8 K l V L k j U s Z y k G k a W a b g N p B B H g P C I p I J g 3 N 2 B t I e A + Q Z f g R l H K N h M q Z M y r L 6 m r F 1 V E a J j R W j G v 1 V u - J s i u 1 g n U V i h g 9 m V I 4 G + C O g V g r 8 y a V M j p X S e l 9 I G U M w Q f l P z f k m R c 6 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 + V 4 U H I J Z H e p I U z k Y u u b c + 5 J B H l E R e X i 7 l g V i V t J + Z S y Q i x 5 D 7 z E J o R l R l q z H V S K 3 E C S h O W I t W o 1 c 5 l z O m 4 G 6 X g H F 3 S 8 U k A A E a w E E H w a V p L 0 b z w T l Z S E k g h T 7 i W 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 k I o C P q h q h r 2 m C o e H c h 5 T z x V v O t b a + 1 3 y y 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 P D S U o h + y 9 V 1 X 8 G t e N m K T X Y v 6 R a 9 N N r B B 6 A d b K r B 0 g N G O X h D j Y 0 p 1 X Y F s V h a L h p b d U x t b e 2 g V D w b l J u F a K 5 5 r z h k Z o H U O n N n 1 Z m r 3 g S v f K 8 x 0 i Q l O p C R E r t t H h h F D j G Q S 6 X r 4 C 6 B 2 4 1 p r e k 9 t 3 Y I V 6 X R D 1 O p g Q G f N K Q I Q w s c n a Q w w M D Q C n R B a c 0 J o o T C F f Q B m x a 6 N 3 J p F a m v 9 6 G g M l k c a B z i 5 1 s h t S s G o M y n 9 Z k i k B G i e Q c F 9 Q A l f b f V G n 6 s V m t - X i 1 j 7 w C N z i I x S z i 2 x k 5 m B Q f u f I J N 2 q u 3 Z S o J c V g W P P j v u 8 D t i b s P b r T c M n j f H I q 5 s S S O 4 w J h 9 F r F y m l X 1 o J + T z G Y Q i M Q M Y D S v p Z g 8 N m H M u Y 8 1 R Y 0 j D J L O 3 f v N X + h z T m A o u Y e I I U 5 Y V t P W 1 0 7 M u 2 A o u H W A O n F O Q - V q j b H X n M Y U 7 i 5 B F I 1 p G t y z a A h + e f M 5 7 m v M + V h R U + u o V K a x W + d Z g V g L R X g s l c o G F 5 1 D I E H 8 i 9 i i O L a w E v p T y t I W M q W o P v 0 y x G 0 p b k r E m t s Z g c c f Q p x x F l f u J O F G j i Z C O H k b h 6 U x r V i 9 h i Z h j E X 0 N s I a h C b N j a 5 2 M J G E m u r 1 8 L R K C r E + J R 6 F 6 z M B j Z K o 2 9 s h m B x o 2 L R i g U m c S 0 M K C 9 R x j 4 n a m 5 I Y c u A O A E A W y o e V r c R S L A R H I I G l k 1 h l D S O 3 M w J g Y y 2 B G 4 2 4 7 1 i w c Q 6 h 5 S Y D A m 8 3 5 H 5 B a K 0 t 6 K P A m j I D W Y K w J A 7 O B L B f B x S j s i V B 2 d z A k h c B i u - D N y c I R 5 u P Z d d Y T K s h 1 B S 2 Z A a G W R R Q Q z G X K r O W U E 4 W H d 7 N z w n v P J A A D k 6 4 A A V U B 4 H Y L A A g V U I A Q E C B R L 0 z M T d 3 F l f M R E J a D S O S M o s U E s J 5 h J z M K - T I R a F A g 5 1 6 g O x + u j c O 7 N z m M K 9 i y f k u F p o X c s h w U Y i 0 C a H 1 i B e J i 2 w a U K 0 K x j 7 E - Y N D 8 X r V + G z C 7 F k F Q T H U 9 m j S F I O Y H r p a p G S g X y H R f S e E f j x W Z i 8 q S 0 l r m L I W C X V a 9 m X d U 7 O Y Q J u q S k 1 5 r N y A A V a 7 U S Y k P D i b X Y X - Q x d x 4 i 3 C A 6 5 h g R K D t O i W w 8 J a + o n l b e z 1 X U K h B 5 n 9 l 4 u C - 8 A 3 e X 6 v 9 p o S l T m P 8 D z 0 P s f O - b + W I 6 X + R Q R y C 0 E 6 S y B E G y G M c M O o L I V 2 B v Y + J U d m O u d S L 0 c 8 A A e V w C 8 2 7 Q G S q m 8 D n 0 E A Q M 6 U E G Q P Y D Q M t i 3 2 P T 0 h K G D D y G W Q h E d D q D U F h C T A F G w T U F y l b h K F Q 1 v z G w + H 8 A F 3 8 B a R I E o B 6 D m x U j A E E K 5 j y 2 5 h N R + S Z C 4 i O A R B x m h G t D r V E G 9 2 W H P z S B y E h i F B s B H j 4 L r k E O E N 8 A n A 3 0 G B + S F H + W M 3 S R w Q n 1 h A d H g x K D s C U A G h X h c j I G w A f B F V a G n m Z m k O 6 C - S w O 6 Q 8 K 8 P u E E F r k E C M P C n I K e w Q A q G A g D 0 h S W E y H U O D B 6 h K F S H b m U J v w I R l B C O 8 P w F 8 O F R N X X z m 3 M J L 1 A 3 y n + T k G R 0 Y m h C Y K 0 G r F W D s F g h W B q H c M h 1 C J 8 N r n P j 4 B C h 8 N J E L E w M 4 w G X y L C I i M G P 7 B + S z n g V D T e y N G f R v R Y S h F b h B H U G s x y M 5 y 1 y 1 j E R u E u 3 I V C H Q y m w W 0 y k B n z m y F 0 P U D U K y T s G V z m G s x B E s F s x c E m g F w w H g C i C y y g F - w o M E E W D K F y E U C r 3 U C 0 A 2 y K B E A 2 X 2 C 0 C M k O g N H S B c n x D A B + N i M E F B G o K h D G l b m N F A i 8 T F H K E 5 H 2 H S M s H r V y N n w + G R J d T W P L w Y y r z y B r 0 s l x l j E U H A M h G F E l i C Q 8 i 6 A p N a g y G b j G l y l s E 0 E q A z z 0 n p U
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-03-25 17:33:59 -04:00
'Equip rectangle tool' : 'Rectangle' ,
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' ,
} ,
} ,
2024-03-25 17:33:59 -04:00
Rectangle : {
entry : 'set up draft rectangle' ,
} ,
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'
)
} ,
2024-03-25 17:33:59 -04:00
'set up draft rectangle' : ( { sketchDetails } ) = > {
if ( ! sketchDetails ) return
sceneEntitiesManager . setupDraftRectangle (
sketchDetails . sketchPathToNode ,
sketchDetails . zAxis ,
sketchDetails . yAxis ,
sketchDetails . origin ,
)
} ,
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'
} ,
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
}
)