Compare commits

..

1 Commits

Author SHA1 Message Date
b2a2c487e1 WIP: Test relative line segments 2023-09-20 12:26:41 -05:00
4 changed files with 44 additions and 43 deletions

View File

@ -57,7 +57,7 @@
"zustand": "^4.1.4"
},
"scripts": {
"start": "BROWSER=none vite",
"start": "vite",
"build": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source \"$HOME/.cargo/env\" && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y && yarn build:wasm && vite build",
"build:local": "vite build",
"build:both": "vite build",

View File

@ -220,6 +220,20 @@ dependencies = [
"num-traits",
]
[[package]]
name = "bigdecimal"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "454bca3db10617b88b566f205ed190aedb0e0e6dd4cad61d3988a72e8c5594cb"
dependencies = [
"autocfg",
"libm",
"num-bigint",
"num-integer",
"num-traits",
"serde",
]
[[package]]
name = "bincode"
version = "1.3.3"
@ -1316,10 +1330,12 @@ dependencies = [
[[package]]
name = "kittycad"
version = "0.2.25"
source = "git+https://github.com/KittyCAD/kittycad.rs?branch=achalmers/relative-path-segments#4aa3cf1ed0b817e21b1676e3618e192a5acf3ed7"
dependencies = [
"anyhow",
"async-trait",
"base64 0.21.4",
"bigdecimal 0.4.1",
"bytes",
"chrono",
"data-encoding",
@ -1381,6 +1397,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "libm"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@ -2311,7 +2333,8 @@ version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c"
dependencies = [
"bigdecimal",
"bigdecimal 0.3.1",
"bigdecimal 0.4.1",
"bytes",
"chrono",
"dyn-clone",

View File

@ -11,8 +11,7 @@ crate-type = ["cdylib"]
bson = { version = "2.7.0", features = ["uuid-1", "chrono"] }
gloo-utils = "0.2.0"
kcl-lib = { path = "kcl" }
#kittycad = { version = "0.2.25", default-features = false, features = ["js"] }
kittycad = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "achalmers/relative-path-segments" }
kittycad = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "achalmers/relative-path-segments", default-features = false, features = ["js"] }
serde_json = "1.0.107"
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
wasm-bindgen = "0.2.87"
@ -21,7 +20,6 @@ wasm-bindgen-futures = "0.4.37"
[dev-dependencies]
anyhow = "1"
image = "0.24.7"
#kittycad = "0.2.25"
kittycad = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "achalmers/relative-path-segments" }
pretty_assertions = "1.4.0"
reqwest = { version = "0.11.20", default-features = false }

View File

@ -67,7 +67,6 @@ fn inner_line_to(
y: to[1],
z: 0.0,
},
relative: false,
},
},
)?;
@ -202,7 +201,6 @@ fn inner_line(data: LineData, sketch_group: Box<SketchGroup>, args: &mut Args) -
LineData::Point(to) => *to,
};
let delta = inner_args;
let to = [from.x + inner_args[0], from.y + inner_args[1]];
let id = uuid::Uuid::new_v4();
@ -213,11 +211,10 @@ fn inner_line(data: LineData, sketch_group: Box<SketchGroup>, args: &mut Args) -
path: sketch_group.id,
segment: kittycad::types::PathSegment::Line {
end: Point3D {
x: delta[0],
y: delta[1],
x: to[0],
y: to[1],
z: 0.0,
},
relative: true
},
},
)?;
@ -352,17 +349,9 @@ fn inner_angled_line(
AngledLineData::AngleWithTag { angle, length, .. } => (*angle, *length),
AngledLineData::AngleAndLength(angle_and_length) => (angle_and_length[0], angle_and_length[1]),
};
//double check me on this one - mike
let delta: [f64; 2] = [
length * f64::cos(angle.to_radians()),
length * f64::sin(angle.to_radians()),
];
let relative = true;
let to: [f64; 2] = [
from.x + delta[0],
from.y + delta[1],
from.x + length * f64::cos(angle.to_radians()),
from.y + length * f64::sin(angle.to_radians()),
];
let id = uuid::Uuid::new_v4();
@ -389,11 +378,10 @@ fn inner_angled_line(
path: sketch_group.id,
segment: kittycad::types::PathSegment::Line {
end: Point3D {
x: delta[0],
y: delta[1],
x: to[0],
y: to[1],
z: 0.0,
},
relative: relative,
},
},
)?;
@ -844,14 +832,9 @@ fn inner_arc(data: ArcData, sketch_group: Box<SketchGroup>, args: &mut Args) ->
angle_end: angle_end.degrees(),
center: center.into(),
radius,
relative: false,
},
},
)?;
// TODO: Dont do this (move path pen) - mike
// lets review what the needs are here and see if any existing arc endpoints can accomplish this
// Move the path pen to the end of the arc.
// Since that is where we want to draw the next path.
// TODO: the engine should automatically move the pen to the end of the arc.
@ -944,8 +927,6 @@ fn inner_bezier_curve(
BezierData::Points { to, control1, control2 } => (to, control1, control2),
};
let relative = true;
let delta = to;
let to = [from.x + to[0], from.y + to[1]];
let id = uuid::Uuid::new_v4();
@ -956,21 +937,20 @@ fn inner_bezier_curve(
path: sketch_group.id,
segment: kittycad::types::PathSegment::Bezier {
control1: Point3D {
x: control1[0],
y: control1[1],
x: from.x + control1[0],
y: from.y + control1[1],
z: 0.0,
},
control2: Point3D {
x: control2[0],
y: control2[1],
x: from.x + control2[0],
y: from.y + control2[1],
z: 0.0,
},
end: Point3D {
x: delta[0],
y: delta[1],
x: to[0],
y: to[1],
z: 0.0,
},
relative: relative
},
},
)?;