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([
|
expect(shown).toEqual([
|
||||||
{
|
{
|
||||||
type: 'SketchGroup',
|
type: 'SketchGroup',
|
||||||
|
on: expect.any(Object),
|
||||||
start: {
|
start: {
|
||||||
to: [0, 0],
|
to: [0, 0],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
|
@ -143,6 +143,7 @@ show(mySketch)
|
|||||||
const { root } = await exe(code)
|
const { root } = await exe(code)
|
||||||
expect(root.mySk1).toEqual({
|
expect(root.mySk1).toEqual({
|
||||||
type: 'SketchGroup',
|
type: 'SketchGroup',
|
||||||
|
on: expect.any(Object),
|
||||||
start: {
|
start: {
|
||||||
to: [0, 0],
|
to: [0, 0],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
|
@ -418,6 +418,8 @@ pub struct SketchGroup {
|
|||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
/// The paths in the sketch group.
|
/// The paths in the sketch group.
|
||||||
pub value: Vec<Path>,
|
pub value: Vec<Path>,
|
||||||
|
/// What the sketch is on (can be a plane or a face).
|
||||||
|
pub on: SketchSurface,
|
||||||
/// The starting path.
|
/// The starting path.
|
||||||
pub start: BasePath,
|
pub start: BasePath,
|
||||||
/// The position of the sketch group.
|
/// The position of the sketch group.
|
||||||
@ -437,6 +439,42 @@ pub struct SketchGroup {
|
|||||||
pub meta: Vec<Metadata>,
|
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 struct GetTangentialInfoFromPathsResult {
|
||||||
pub center_or_tangent_point: [f64; 2],
|
pub center_or_tangent_point: [f64; 2],
|
||||||
pub is_center: bool,
|
pub is_center: bool,
|
||||||
|
@ -6,7 +6,7 @@ use schemars::JsonSchema;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{ExtrudeGroup, ExtrudeSurface, ExtrudeTransform, GeoMeta, MemoryItem, Path, SketchGroup},
|
executor::{ExtrudeGroup, ExtrudeSurface, ExtrudeTransform, GeoMeta, MemoryItem, Path, SketchGroup, SketchSurface},
|
||||||
std::Args,
|
std::Args,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,6 +36,13 @@ async fn inner_extrude(length: f64, sketch_group: Box<SketchGroup>, args: Args)
|
|||||||
)
|
)
|
||||||
.await?;
|
.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.
|
// Bring the object to the front of the scene.
|
||||||
// See: https://github.com/KittyCAD/modeling-app/issues/806
|
// See: https://github.com/KittyCAD/modeling-app/issues/806
|
||||||
args.send_modeling_cmd(
|
args.send_modeling_cmd(
|
||||||
|
@ -26,12 +26,10 @@ use crate::{
|
|||||||
engine::EngineManager,
|
engine::EngineManager,
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{
|
executor::{
|
||||||
ExecutorContext, ExtrudeGroup, Geometry, MemoryItem, Metadata, SketchGroup, SketchGroupSet, SourceRange,
|
ExecutorContext, ExtrudeGroup, Geometry, MemoryItem, Metadata, SketchGroup, SketchGroupSet, SketchSurface,
|
||||||
},
|
SourceRange,
|
||||||
std::{
|
|
||||||
kcl_stdlib::KclStdLibFn,
|
|
||||||
sketch::{SketchOnFaceTag, SketchSurface},
|
|
||||||
},
|
},
|
||||||
|
std::{kcl_stdlib::KclStdLibFn, sketch::SketchOnFaceTag},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type StdFn = fn(Args) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<MemoryItem, KclError>>>>;
|
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},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{
|
executor::{
|
||||||
BasePath, ExtrudeGroup, ExtrudeSurface, Face, GeoMeta, MemoryItem, Path, Plane, PlaneType, Point2d, Point3d,
|
BasePath, ExtrudeGroup, ExtrudeSurface, Face, GeoMeta, MemoryItem, Path, Plane, PlaneType, Point2d, Point3d,
|
||||||
Position, Rotation, SketchGroup, SketchGroupSet, SourceRange,
|
Position, Rotation, SketchGroup, SketchGroupSet, SketchSurface, SourceRange,
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
utils::{
|
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.
|
/// Start a sketch on a specific plane or face.
|
||||||
pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
|
pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
|
||||||
let (data, tag): (SketchData, Option<SketchOnFaceTag>) = args.get_data_and_optional_tag()?;
|
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 {
|
let sketch_group = SketchGroup {
|
||||||
id: path_id,
|
id: path_id,
|
||||||
|
on: sketch_surface.clone(),
|
||||||
position: Position([0.0, 0.0, 0.0]),
|
position: Position([0.0, 0.0, 0.0]),
|
||||||
rotation: Rotation([0.0, 0.0, 0.0, 1.0]),
|
rotation: Rotation([0.0, 0.0, 0.0, 1.0]),
|
||||||
x_axis: sketch_surface.x_axis(),
|
x_axis: sketch_surface.x_axis(),
|
||||||
@ -1126,10 +1089,10 @@ async fn inner_close(sketch_group: Box<SketchGroup>, args: Args) -> Result<Box<S
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Exit sketch mode, since if we were in a plane or entity we'd want to disable the sketch mode after.
|
// If we are sketching on a plane we can close the sketch group now.
|
||||||
if sketch_group.entity_id.is_some() {
|
if let SketchSurface::Plane(_) = sketch_group.on {
|
||||||
// We were on a plane, disable the sketch mode.
|
// 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?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ async fn execute_and_snapshot(code: &str) -> Result<image::DynamicImage> {
|
|||||||
// Create the client.
|
// Create the client.
|
||||||
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
||||||
// uncomment to use a local server
|
// 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
|
let ws = client
|
||||||
.modeling()
|
.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