69 | {/if}
70 |
--------------------------------------------------------------------------------
/applications/web/src/components/Sketch.svelte:
--------------------------------------------------------------------------------
1 |
46 |
47 | {#if editing}
48 |
61 | {:else}
62 |
74 | {/if}
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Notes.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 | - Do I need a formal state machine for the UI, with a diagram of all the states and transitions?
4 | - After messages modify the state, if a get_representation() fails, I'm gonna need great error handling so that the user knows exactly what in the history is broken and how they need to fix it
5 | - When specifying a face to extrude, simple indices aren't sufficient because the number of faces will change, and they are sorted by size. This will cause weird jumps. What heuristics should be used to prevent jumping? Maybe use the face that has the most points in common with the original face?
6 | - Extrusions of two adjacent faces should probably merge together into a single solid. Should this happen before the extrusion by merging faces or after by merging solids? Also setting merge scope will be important: need to distinguish between "new", "add", and "remove".
7 |
8 | # UI Ideas
9 |
10 | Constant: can _always_ zoom, pan, rotate
11 |
12 | Default (no special interaction)
13 |
14 | Create new Step/Edit existing Step: dropdown in left window, looks like a form. Form inputs might be:
15 |
16 | - Set name
17 | - Select a plane (for sketch to live on)
18 | - Select a vector (to extrude in)
19 | - Select a point (to extrude to)
20 | - Select face(s) (to extrude, or extrude to)
21 | - Select a solid (merge scope)
22 | - Choose an option: add/new/remove
23 | - Choose a direction: forward/reverse
24 |
25 | When editing an extrusion: have an arrow that you can drag which controls the length
26 |
27 | When editing a sketch, there's mini state machines for each kind of feature. Hotkeys to trigger:
28 |
29 | - New Circle:
30 | - place center point (smart snapping to sensible points)
31 | - drag to set initial radius, which is not a constraint (smart snapping)
32 | - New Line Segment
33 | - place first point (smart snapping)
34 | - place second point (smart snapping)
35 | - New Rectangle:
36 | - Center point or lower left, upper right?
37 | - place first point (smart snapping)
38 | - place second point (smart snapping)
39 | - Round Corner:
40 | - Select corner(s)
41 | - Input to set radius
42 | - Constraint placing:
43 | - enter "contraint mode"
44 | - click on a line, assume length constraint
45 | - mouse switches to showing where to place the constraint
46 | - after placing it, brings up text box that allows you to enter precise dimensions
47 |
48 | Qs:
49 |
50 | - Should I keep a history of sketch steps?
51 | - How do I show how unsatisfied the constraints are in a sketch?
52 |
--------------------------------------------------------------------------------
/applications/web/src/components/Circle.svelte:
--------------------------------------------------------------------------------
1 |
33 |
34 |
35 | ref.computeLineDistances()} />
36 | {
40 | ref.computeLineDistances()
41 | }}
42 | />
43 | {
47 | ref.computeLineDistances()
48 | }}
49 | on:pointerover={() => {
50 | if ($sketchTool === "select") {
51 | hovered = true
52 | $currentlyMousedOver = [...$currentlyMousedOver, {type, id}]
53 | // log("$currentlyMousedOver", $currentlyMousedOver)
54 | }
55 | }}
56 | on:pointerout={() => {
57 | if ($sketchTool === "select") {
58 | hovered = false
59 | $currentlyMousedOver = $currentlyMousedOver.filter(item => !(item.id === id && item.type === type))
60 | }
61 | }}
62 | />
63 |
64 |
--------------------------------------------------------------------------------
/packages/cadmium/src/test.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 |
3 | #[test]
4 | fn my_test() {
5 | Project::new("Test Project");
6 | }
7 |
8 | #[test]
9 | fn secondary_extrusion_simple() {
10 | let mut p = Project::new("Test Project");
11 | let mut wb = p.workbenches.get_mut(0).unwrap();
12 | wb.add_sketch_to_plane("Sketch 1", "Plane-0");
13 | let mut s = wb.get_sketch_mut("Sketch 1").unwrap();
14 | let ll = s.add_point(2.0, 2.0);
15 | let lr = s.add_point(42.0, 2.0);
16 | let ul = s.add_point(2.0, 42.0);
17 | let ur = s.add_point(42.0, 42.0);
18 | s.add_segment(ll, lr);
19 | s.add_segment(lr, ur);
20 | s.add_segment(ur, ul);
21 | s.add_segment(ul, ll);
22 |
23 | let extrusion = Extrusion::new(
24 | "Sketch-0".to_owned(),
25 | vec![0],
26 | 25.0,
27 | 0.0,
28 | Direction::Normal,
29 | ExtrusionMode::New,
30 | );
31 | wb.add_extrusion("Ext1", extrusion);
32 |
33 | let s2_id = wb.add_sketch_to_solid_face("Sketch-2", "Ext1:0", Vector3::new(0.0, 0.0, 1.0));
34 | let mut s2 = wb.get_sketch_mut("Sketch-2").unwrap();
35 |
36 | // smaller
37 | let ll = s2.add_point(12.0, 12.0);
38 | let lr = s2.add_point(32.0, 12.0);
39 | let ul = s2.add_point(12.0, 32.0);
40 | let ur = s2.add_point(32.0, 32.0);
41 | // bigger!
42 | // let ll = s2.add_point(-10.0, -10.0);
43 | // let lr = s2.add_point(50.0, -10.0);
44 | // let ul = s2.add_point(-10.0, 50.0);
45 | // let ur = s2.add_point(50.0, 50.0);
46 | s2.add_segment(ll, lr);
47 | s2.add_segment(lr, ur);
48 | s2.add_segment(ur, ul);
49 | s2.add_segment(ul, ll);
50 |
51 | // println!("S2: {:?}", s2);
52 |
53 | let extrusion2 = Extrusion::new(
54 | s2_id.to_owned(),
55 | vec![0],
56 | 25.0,
57 | 0.0,
58 | Direction::Normal,
59 | ExtrusionMode::Add(vec!["Ext1:0".to_string()]),
60 | );
61 | wb.add_extrusion("Ext2", extrusion2);
62 |
63 | let realization = p.get_realization(0, 1000);
64 | let solids = realization.solids;
65 |
66 | let num_solids = solids.len();
67 | println!("Num Solids: {:?}", num_solids);
68 | assert!(num_solids == 1);
69 |
70 | let final_solid = &solids["Ext1:0"];
71 | let mut mesh = final_solid.truck_solid.triangulation(0.02).to_polygon();
72 | mesh.put_together_same_attrs();
73 | let file = std::fs::File::create("secondary_extrusion.obj").unwrap();
74 | obj::write(&mesh, file).unwrap();
75 |
76 | let as_json = serde_json::to_string(&p).unwrap();
77 | let file = std::fs::File::create("secondary_extrusion.json").unwrap();
78 | // println!("As json: {}", as_json);
79 | serde_json::to_writer(file, &p).unwrap();
80 | }
81 |
--------------------------------------------------------------------------------
/applications/web/src/components/Solid.svelte:
--------------------------------------------------------------------------------
1 |
52 |
53 |
54 |
55 |
56 |
57 | {#each truck_faces as truck_face, i (i)}
58 |
70 | {/each}
71 |
72 |
--------------------------------------------------------------------------------
/applications/web/src/components/MainDisplay.svelte:
--------------------------------------------------------------------------------
1 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
{
59 | if ($selectingFor.length > 0) {
60 | // If the user is selecting shapes, then click events on the 3D screen
61 | // should not steal focus away from form inputs
62 | e.preventDefault()
63 | }
64 | }}
65 | >
66 |
69 |
81 | {#each Object.keys(solids) as name (name)}
82 |
83 | {/each}
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/packages/cadmium/src/test_inputs/points_on_lines.cadmium:
--------------------------------------------------------------------------------
1 | {"name":"First Project","assemblies":[],"workbenches":[{"name":"Workbench 1","history":[{"name":"Origin","unique_id":"Point-0","suppressed":false,"data":{"type":"Point","point":{"x":0.0,"y":0.0,"z":0.0,"hidden":false}}},{"name":"Top","unique_id":"Plane-0","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":1.0,"y":0.0,"z":0.0},"secondary":{"x":0.0,"y":1.0,"z":0.0},"tertiary":{"x":0.0,"y":0.0,"z":1.0}},"width":100.0,"height":100.0}},{"name":"Front","unique_id":"Plane-1","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":1.0,"y":0.0,"z":0.0},"secondary":{"x":0.0,"y":0.0,"z":1.0},"tertiary":{"x":0.0,"y":-1.0,"z":0.0}},"width":100.0,"height":100.0}},{"name":"Right","unique_id":"Plane-2","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":0.0,"y":1.0,"z":0.0},"secondary":{"x":0.0,"y":0.0,"z":1.0},"tertiary":{"x":1.0,"y":0.0,"z":0.0}},"width":100.0,"height":100.0}},{"name":"Sketch 1","unique_id":"Sketch-0","suppressed":false,"data":{"type":"Sketch","plane_id":"Plane-0","width":1.25,"height":0.75,"sketch":{"points":{"4":{"x":-73.5234375,"y":38.3,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"8":{"x":73.47656250000001,"y":8.100000000000001,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"2":{"x":-25.7234375,"y":38.3,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"1":{"x":-73.5234375,"y":-24.50000000000001,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"6":{"x":33.27656250000001,"y":38.3,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"3":{"x":-25.723437500000003,"y":-24.50000000000001,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"9":{"x":73.47656250000001,"y":38.3,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"5":{"x":33.27656250000002,"y":-7.699999999999995,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"7":{"x":-25.7234375,"y":-7.699999999999996,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false},"10":{"x":33.27656250000001,"y":8.100000000000001,"m":1.0,"dx":0.0,"dy":0.0,"fx":0.0,"fy":0.0,"fixed":false,"hidden":false}},"highest_point_id":10,"line_segments":{"7":{"start":5,"end":6},"11":{"start":8,"end":9},"9":{"start":6,"end":10},"2":{"start":4,"end":2},"4":{"start":3,"end":1},"10":{"start":10,"end":8},"1":{"start":1,"end":4},"3":{"start":2,"end":3},"5":{"start":2,"end":7},"12":{"start":9,"end":6},"6":{"start":7,"end":5},"8":{"start":6,"end":2}},"highest_line_segment_id":12,"circles":{},"highest_circle_id":0,"arcs":{},"highest_arc_id":0,"constraints":{},"highest_constraint_id":0}}}],"step_counters":{"Point":1,"Plane":3,"Extrusion":0,"Sketch":1}},{"name":"Workbench 2","history":[{"name":"Origin","unique_id":"Point-0","suppressed":false,"data":{"type":"Point","point":{"x":0.0,"y":0.0,"z":0.0,"hidden":false}}},{"name":"Top","unique_id":"Plane-0","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":1.0,"y":0.0,"z":0.0},"secondary":{"x":0.0,"y":1.0,"z":0.0},"tertiary":{"x":0.0,"y":0.0,"z":1.0}},"width":100.0,"height":100.0}},{"name":"Front","unique_id":"Plane-1","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":1.0,"y":0.0,"z":0.0},"secondary":{"x":0.0,"y":0.0,"z":1.0},"tertiary":{"x":0.0,"y":-1.0,"z":0.0}},"width":100.0,"height":100.0}},{"name":"Right","unique_id":"Plane-2","suppressed":false,"data":{"type":"Plane","plane":{"origin":{"x":0.0,"y":0.0,"z":0.0,"hidden":false},"primary":{"x":0.0,"y":1.0,"z":0.0},"secondary":{"x":0.0,"y":0.0,"z":1.0},"tertiary":{"x":1.0,"y":0.0,"z":0.0}},"width":100.0,"height":100.0}}],"step_counters":{"Plane":3,"Extrusion":0,"Sketch":0,"Point":1}}]}
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Elastic License 2.0
2 |
3 | URL: https://www.elastic.co/licensing/elastic-license
4 |
5 | ## Acceptance
6 |
7 | By using the software, you agree to all of the terms and conditions below.
8 |
9 | ## Copyright License
10 |
11 | The licensor grants you a non-exclusive, royalty-free, worldwide,
12 | non-sublicensable, non-transferable license to use, copy, distribute, make
13 | available, and prepare derivative works of the software, in each case subject to
14 | the limitations and conditions below.
15 |
16 | ## Limitations
17 |
18 | You may not provide the software to third parties as a hosted or managed
19 | service, where the service provides users with access to any substantial set of
20 | the features or functionality of the software.
21 |
22 | You may not move, change, disable, or circumvent the license key functionality
23 | in the software, and you may not remove or obscure any functionality in the
24 | software that is protected by the license key.
25 |
26 | You may not alter, remove, or obscure any licensing, copyright, or other notices
27 | of the licensor in the software. Any use of the licensor’s trademarks is subject
28 | to applicable law.
29 |
30 | ## Patents
31 |
32 | The licensor grants you a license, under any patent claims the licensor can
33 | license, or becomes able to license, to make, have made, use, sell, offer for
34 | sale, import and have imported the software, in each case subject to the
35 | limitations and conditions in this license. This license does not cover any
36 | patent claims that you cause to be infringed by modifications or additions to
37 | the software. If you or your company make any written claim that the software
38 | infringes or contributes to infringement of any patent, your patent license for
39 | the software granted under these terms ends immediately. If your company makes
40 | such a claim, your patent license ends immediately for work on behalf of your
41 | company.
42 |
43 | ## Notices
44 |
45 | You must ensure that anyone who gets a copy of any part of the software from you
46 | also gets a copy of these terms.
47 |
48 | If you modify the software, you must include in any modified copies of the
49 | software prominent notices stating that you have modified the software.
50 |
51 | ## No Other Rights
52 |
53 | These terms do not imply any licenses other than those expressly granted in
54 | these terms.
55 |
56 | ## Termination
57 |
58 | If you use the software in violation of these terms, such use is not licensed,
59 | and your licenses will automatically terminate. If the licensor provides you
60 | with a notice of your violation, and you cease all violation of this license no
61 | later than 30 days after you receive that notice, your licenses will be
62 | reinstated retroactively. However, if you violate these terms after such
63 | reinstatement, any additional violation of these terms will cause your licenses
64 | to terminate automatically and permanently.
65 |
66 | ## No Liability
67 |
68 | *As far as the law allows, the software comes as is, without any warranty or
69 | condition, and the licensor will not be liable to you for any damages arising
70 | out of these terms or the use or nature of the software, under any kind of
71 | legal claim.*
72 |
73 | ## Definitions
74 |
75 | The **licensor** is the entity offering these terms, and the **software** is the
76 | software the licensor makes available under these terms, including any portion
77 | of it.
78 |
79 | **you** refers to the individual or entity agreeing to these terms.
80 |
81 | **your company** is any legal entity, sole proprietorship, or other kind of
82 | organization that you work for, plus all organizations that have control over,
83 | are under the control of, or are under common control with that
84 | organization. **control** means ownership of substantially all the assets of an
85 | entity, or the power to direct its management and policies by vote, contract, or
86 | otherwise. Control can be direct or indirect.
87 |
88 | **your licenses** are all the licenses granted to you for the software under
89 | these terms.
90 |
91 | **use** means anything you do with the software requiring one of your licenses.
92 |
93 | **trademark** means trademarks, service marks, and similar rights.
--------------------------------------------------------------------------------
/applications/web/public/actions/part.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
86 |
--------------------------------------------------------------------------------
/applications/web/src/components/SolidItem.svelte:
--------------------------------------------------------------------------------
1 |
71 |
72 |
73 |