-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArtifactGraph reThink (PART 3) #3140
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
dope integration tests are working 28c6cec |
39d7ec9
to
1b5dff6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dude crazy work here I'm so excited
| EdgeCutEdge | ||
| solid2D | ||
|
||
export type ArtifactGraph = Map<string, Artifact> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my new branch, I'm thinking about adding this to help communicate what should be an ID into this map.
export type ArtifactGraph = Map<string, Artifact> | |
export type ArtifactId = string | |
export type ArtifactGraph = Map<ArtifactId, Artifact> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was going to say that commandId
might be better, but that's only true for plan, path, segment, but not extrude walls caps, other edges. I think I used commandId
for naming in a few places where I should probably do a rename to artifactId
Related to #3062
I've made a start on the refactor, but for the time being I've set up tests for the artifactMap, which by their nature are integration tests because the artifactMap is tied to websocket commands, it works locally, but want to trouble shoot CI now, rather than pulling my hair out at the end.
Gonna slap in the read me here too
Artifact Graph
What it does
The artifact graph's primary role is to map geometry artifacts in the 3d-scene/engine, to the code/AST such that when the engine sends the FE an id of some piece of geometry (say because the user clicked on something) then we know both what it is, and how it relates to the user's code.
Relating it to a user's code is important because this is how we drive our AST-mods, say a user clicks a segment and wants to constrain it horizontally, because of the artifact graph we know that their selection was in fact a specific
line(...)
callExpression, and now we're able to transform this toxLine(...)
in order to constrain it.How to reason about the graph
Here is what roughly what the artifact graph looks like
The best way to read this is starting with the plane at the bottom and going upwards, as this is roughly the command order (which the graph is based on).
Here's an explanation:
startSketchOn
, command:enable_sketch_mode
)startProfileAt
, command:start_path
)line
, command:extend_path
) must refer back to the path.extrude
, command:extrude
) it much refer to the path.The above is probably enough to give more examples of how the graph is used.
line(...)
call expression in the code.line(...)
andextrude(...)
and highlight them both.Other things to point out is that a new path can be created directly on a wall-face, i.e. this is sketch on face, and more than one path can point to the same plane, that is multiple profiles on the same plane.
Generated Graphs
The image above is hand drawn for grokablitiy, but it's useful to look at a real graph, take this bit of geometry
In
src/lang/std/artifactGraph.test.ts
we generate the graph for itIt's definitely harder to read, if you start at roughly the bottom center of the page and find the node
plane-0
and visually traverse from there you can see it has the same structure, plane is connected to a path, which is connected to multiple segments and an extrusion etc.Generating the graph here serves a couple of purposes
We'll need to add more sample code to
src/lang/std/artifactGraph.test.ts
to generate more graphs, to test more kcl API as the app continues development.