no camera sketch on face (#1412)
* no camera sketch on face Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * new screenshots Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commite839d7101f
. * Revert "fixes" This reverts commit3df8b63e3a
. * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
15696
docs/kcl/std.json
15696
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
2915
docs/kcl/std.md
2915
docs/kcl/std.md
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@ show(mySketch001)`
|
||||
expect(shown).toEqual([
|
||||
{
|
||||
type: 'SketchGroup',
|
||||
on: expect.any(Object),
|
||||
start: {
|
||||
to: [0, 0],
|
||||
from: [0, 0],
|
||||
|
@ -143,6 +143,7 @@ show(mySketch)
|
||||
const { root } = await exe(code)
|
||||
expect(root.mySk1).toEqual({
|
||||
type: 'SketchGroup',
|
||||
on: expect.any(Object),
|
||||
start: {
|
||||
to: [0, 0],
|
||||
from: [0, 0],
|
||||
|
@ -418,6 +418,8 @@ pub struct SketchGroup {
|
||||
pub id: uuid::Uuid,
|
||||
/// The paths in the sketch group.
|
||||
pub value: Vec<Path>,
|
||||
/// What the sketch is on (can be a plane or a face).
|
||||
pub on: SketchSurface,
|
||||
/// The starting path.
|
||||
pub start: BasePath,
|
||||
/// The position of the sketch group.
|
||||
@ -437,6 +439,42 @@ pub struct SketchGroup {
|
||||
pub meta: Vec<Metadata>,
|
||||
}
|
||||
|
||||
/// A sketch group type.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub enum SketchSurface {
|
||||
Plane(Box<Plane>),
|
||||
Face(Box<Face>),
|
||||
}
|
||||
|
||||
impl SketchSurface {
|
||||
pub fn id(&self) -> uuid::Uuid {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.id,
|
||||
SketchSurface::Face(face) => face.id,
|
||||
}
|
||||
}
|
||||
pub fn x_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.x_axis.clone(),
|
||||
SketchSurface::Face(face) => face.x_axis.clone(),
|
||||
}
|
||||
}
|
||||
pub fn y_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.y_axis.clone(),
|
||||
SketchSurface::Face(face) => face.y_axis.clone(),
|
||||
}
|
||||
}
|
||||
pub fn z_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.z_axis.clone(),
|
||||
SketchSurface::Face(face) => face.z_axis.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GetTangentialInfoFromPathsResult {
|
||||
pub center_or_tangent_point: [f64; 2],
|
||||
pub is_center: bool,
|
||||
|
@ -6,7 +6,7 @@ use schemars::JsonSchema;
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{ExtrudeGroup, ExtrudeSurface, ExtrudeTransform, GeoMeta, MemoryItem, Path, SketchGroup},
|
||||
executor::{ExtrudeGroup, ExtrudeSurface, ExtrudeTransform, GeoMeta, MemoryItem, Path, SketchGroup, SketchSurface},
|
||||
std::Args,
|
||||
};
|
||||
|
||||
@ -36,6 +36,13 @@ async fn inner_extrude(length: f64, sketch_group: Box<SketchGroup>, args: Args)
|
||||
)
|
||||
.await?;
|
||||
|
||||
// We need to do this after extrude for sketch on face.
|
||||
if let SketchSurface::Face(_) = sketch_group.on {
|
||||
// Disable the sketch mode.
|
||||
args.send_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
|
||||
.await?;
|
||||
}
|
||||
|
||||
// Bring the object to the front of the scene.
|
||||
// See: https://github.com/KittyCAD/modeling-app/issues/806
|
||||
args.send_modeling_cmd(
|
||||
|
@ -26,12 +26,10 @@ use crate::{
|
||||
engine::EngineManager,
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{
|
||||
ExecutorContext, ExtrudeGroup, Geometry, MemoryItem, Metadata, SketchGroup, SketchGroupSet, SourceRange,
|
||||
},
|
||||
std::{
|
||||
kcl_stdlib::KclStdLibFn,
|
||||
sketch::{SketchOnFaceTag, SketchSurface},
|
||||
ExecutorContext, ExtrudeGroup, Geometry, MemoryItem, Metadata, SketchGroup, SketchGroupSet, SketchSurface,
|
||||
SourceRange,
|
||||
},
|
||||
std::{kcl_stdlib::KclStdLibFn, sketch::SketchOnFaceTag},
|
||||
};
|
||||
|
||||
pub type StdFn = fn(Args) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<MemoryItem, KclError>>>>;
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
executor::{
|
||||
BasePath, ExtrudeGroup, ExtrudeSurface, Face, GeoMeta, MemoryItem, Path, Plane, PlaneType, Point2d, Point3d,
|
||||
Position, Rotation, SketchGroup, SketchGroupSet, SourceRange,
|
||||
Position, Rotation, SketchGroup, SketchGroupSet, SketchSurface, SourceRange,
|
||||
},
|
||||
std::{
|
||||
utils::{
|
||||
@ -774,44 +774,6 @@ impl From<PlaneData> for Plane {
|
||||
}
|
||||
}
|
||||
|
||||
/// A plane or a face.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase", untagged)]
|
||||
pub enum SketchSurface {
|
||||
/// A plane.
|
||||
Plane(Box<Plane>),
|
||||
/// A face.
|
||||
Face(Box<Face>),
|
||||
}
|
||||
|
||||
impl SketchSurface {
|
||||
pub fn id(&self) -> uuid::Uuid {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.id,
|
||||
SketchSurface::Face(face) => face.id,
|
||||
}
|
||||
}
|
||||
pub fn x_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.x_axis.clone(),
|
||||
SketchSurface::Face(face) => face.x_axis.clone(),
|
||||
}
|
||||
}
|
||||
pub fn y_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.y_axis.clone(),
|
||||
SketchSurface::Face(face) => face.y_axis.clone(),
|
||||
}
|
||||
}
|
||||
pub fn z_axis(&self) -> Point3d {
|
||||
match self {
|
||||
SketchSurface::Plane(plane) => plane.z_axis.clone(),
|
||||
SketchSurface::Face(face) => face.z_axis.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start a sketch on a specific plane or face.
|
||||
pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
|
||||
let (data, tag): (SketchData, Option<SketchOnFaceTag>) = args.get_data_and_optional_tag()?;
|
||||
@ -1086,6 +1048,7 @@ async fn inner_start_profile_at(
|
||||
|
||||
let sketch_group = SketchGroup {
|
||||
id: path_id,
|
||||
on: sketch_surface.clone(),
|
||||
position: Position([0.0, 0.0, 0.0]),
|
||||
rotation: Rotation([0.0, 0.0, 0.0, 1.0]),
|
||||
x_axis: sketch_surface.x_axis(),
|
||||
@ -1126,10 +1089,10 @@ async fn inner_close(sketch_group: Box<SketchGroup>, args: Args) -> Result<Box<S
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Exit sketch mode, since if we were in a plane or entity we'd want to disable the sketch mode after.
|
||||
if sketch_group.entity_id.is_some() {
|
||||
// If we are sketching on a plane we can close the sketch group now.
|
||||
if let SketchSurface::Plane(_) = sketch_group.on {
|
||||
// We were on a plane, disable the sketch mode.
|
||||
args.send_modeling_cmd(uuid::Uuid::new_v4(), ModelingCmd::SketchModeDisable {})
|
||||
args.send_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ async fn execute_and_snapshot(code: &str) -> Result<image::DynamicImage> {
|
||||
// Create the client.
|
||||
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
||||
// uncomment to use a local server
|
||||
// client.set_base_url("http://your-local-server:8080/");
|
||||
//client.set_base_url("http://system76-pc:8080/");
|
||||
|
||||
let ws = client
|
||||
.modeling()
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 82 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 80 KiB |
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 80 KiB |
Reference in New Issue
Block a user