Skip to content
Open
Show file tree
Hide file tree
Changes from 164 commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
d65eb43
add snapToGrid to settings
andrewvarga Jul 24, 2025
a7cc802
snap to default unit
andrewvarga Jul 24, 2025
7b6c5db
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Jul 24, 2025
3f10524
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Jul 25, 2025
181579e
resolve circular deps
andrewvarga Jul 25, 2025
8c99440
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Jul 28, 2025
a0aa376
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Jul 28, 2025
22ab0bb
Update snapshots
github-actions[bot] Jul 28, 2025
6c5f503
Update snapshots
github-actions[bot] Jul 28, 2025
a297ec2
merge from main
andrewvarga Jul 31, 2025
32bf879
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 4, 2025
d26b4e0
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 4, 2025
dcf202e
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 4, 2025
fb56e74
add new settings for grid, grid snapping
andrewvarga Aug 5, 2025
98c8e25
move fixed_size_grid to grid settings
andrewvarga Aug 5, 2025
5c8f7bf
fmt
andrewvarga Aug 5, 2025
c4c6cbc
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 6, 2025
bf25267
disable settings based on other settings via new isEnabled()
andrewvarga Aug 6, 2025
31f97b4
remove dead code
andrewvarga Aug 6, 2025
8759cd8
wip infinite grid
andrewvarga Aug 6, 2025
21ac79f
cleanups
andrewvarga Aug 7, 2025
e688196
Update snapshots
github-actions[bot] Aug 7, 2025
72accc5
grid updates
andrewvarga Aug 7, 2025
db8372c
merge remote
andrewvarga Aug 7, 2025
a1a4cc9
grid panning fix, cleanups
andrewvarga Aug 7, 2025
84cb1d7
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 7, 2025
2aea239
sceneInfra Grid is not actually used
andrewvarga Aug 7, 2025
4ada50a
add snaps per minor
andrewvarga Aug 7, 2025
a17cc8b
fmt
andrewvarga Aug 7, 2025
1f9043f
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 7, 2025
25ead2c
Update snapshots
github-actions[bot] Aug 7, 2025
cc5ba4a
Update snapshots
github-actions[bot] Aug 7, 2025
88d5765
Update snapshots
github-actions[bot] Aug 7, 2025
582cf91
Update snapshots
github-actions[bot] Aug 7, 2025
54f9461
Update snapshots
github-actions[bot] Aug 7, 2025
665c4c2
snapToGrid fixes
andrewvarga Aug 8, 2025
e12d6b2
Update snapshots
github-actions[bot] Aug 8, 2025
60c4dd3
Update snapshots
github-actions[bot] Aug 8, 2025
8763be4
Update snapshots
github-actions[bot] Aug 8, 2025
804c46e
add snapToGrid to context menu
andrewvarga Aug 8, 2025
797b4d7
add shortcut to disable snap
andrewvarga Aug 8, 2025
f8b05dc
enable hotkey
andrewvarga Aug 8, 2025
d7eea35
merge from remote
andrewvarga Aug 8, 2025
8f0e092
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 8, 2025
278fe20
grid color
andrewvarga Aug 8, 2025
6b1c07f
Update snapshots
github-actions[bot] Aug 8, 2025
6393d41
add threshold for grid rendering not to become too small
andrewvarga Aug 8, 2025
a4c376d
grid colors based on theme
andrewvarga Aug 8, 2025
1ea8baa
merge remote
andrewvarga Aug 8, 2025
7fa22f5
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 8, 2025
a39bad1
Update snapshots
github-actions[bot] Aug 8, 2025
a770af9
tmp non fixed grid
andrewvarga Aug 9, 2025
887421e
Add real scale unit to UnitsMenu in sketch mode, grid cleanups
andrewvarga Aug 10, 2025
c5f6a2e
merge from remote
andrewvarga Aug 10, 2025
a3be6f6
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 10, 2025
38464b9
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 11, 2025
42cff53
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 13, 2025
c1d18a0
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 13, 2025
a9923a0
merge from main
andrewvarga Aug 14, 2025
6d9a934
Update snapshots
github-actions[bot] Aug 14, 2025
9c169af
fix UnitsMenu to use current baseUnit
andrewvarga Aug 14, 2025
feef0d8
merge from remote
andrewvarga Aug 14, 2025
2f37393
GridRenderer fixes: base unit
andrewvarga Aug 14, 2025
7fe9f95
more cleanups
andrewvarga Aug 14, 2025
87fe7d0
merge from remote
andrewvarga Aug 15, 2025
3ef153e
type cleanup
andrewvarga Aug 15, 2025
137a416
cleanups
andrewvarga Aug 15, 2025
feb8021
Update snapshots
github-actions[bot] Aug 15, 2025
dd64f07
wip baseunit fix
andrewvarga Aug 15, 2025
fc89237
fmt
andrewvarga Aug 15, 2025
de5982b
merge remote
andrewvarga Aug 15, 2025
bd4ae29
Update snapshots
github-actions[bot] Aug 15, 2025
e8e2d5c
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 16, 2025
b37210a
UnitsMenu initial update fixed
andrewvarga Aug 16, 2025
9b06d28
Update snapshots
github-actions[bot] Aug 16, 2025
5f1292d
Update snapshots
github-actions[bot] Aug 16, 2025
cefa7cd
Update snapshots
github-actions[bot] Aug 16, 2025
f3fa5b6
fmt
andrewvarga Aug 17, 2025
9fe7147
cleanups around InfiniteGridRenderer
andrewvarga Aug 17, 2025
1a38db3
fix initial grid render using incorrect camera
andrewvarga Aug 17, 2025
37666d4
merge remote
andrewvarga Aug 17, 2025
720d723
cleanup lineOffset calculation math
andrewvarga Aug 18, 2025
6e18816
lineCount fix
andrewvarga Aug 18, 2025
0ae8e31
simplify InfiniteGrid shader: bunch of uniforms not needed anymore
andrewvarga Aug 18, 2025
702bf65
count fix
andrewvarga Aug 18, 2025
4c777fb
fmt
andrewvarga Aug 18, 2025
5d47006
introduce Signal instead of manual subscription in camerachange
andrewvarga Aug 18, 2025
433ee48
update UnitsMenu when baseunit changes
andrewvarga Aug 18, 2025
e96334f
update grid if baseunit changes
andrewvarga Aug 18, 2025
de6ae1c
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 18, 2025
81366f2
update from remote
andrewvarga Aug 19, 2025
bfddd26
Update snapshots
github-actions[bot] Aug 19, 2025
90800af
detect canvas resize instead of window resize in sceneEntities
andrewvarga Aug 19, 2025
1e0ca35
fmt
andrewvarga Aug 19, 2025
697abca
clippy
andrewvarga Aug 19, 2025
dd19416
merge from remote
andrewvarga Aug 19, 2025
120ea64
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 19, 2025
77e47ee
cargo
andrewvarga Aug 19, 2025
f3f393e
regenerate docs
andrewvarga Aug 19, 2025
e105db2
no need for sceneInfra to listen to window 'resize' anymore, since Cl…
andrewvarga Aug 19, 2025
5111641
dont save grid settings if they are defaults
andrewvarga Aug 19, 2025
4f359e5
ViewControlMenu case
andrewvarga Aug 19, 2025
9d01490
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 19, 2025
2c170e0
merge main
andrewvarga Aug 21, 2025
06d1069
Update snapshots
github-actions[bot] Aug 21, 2025
613dfb9
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 21, 2025
e1cc113
merge remote
andrewvarga Aug 21, 2025
cc0f718
use ndc conversion in InfiniteGridRenderer's lineGap
andrewvarga Aug 21, 2025
0a6714a
fix InfiniteGridRenderer to work on any axis plane
andrewvarga Aug 21, 2025
f12a606
merge remote
andrewvarga Aug 21, 2025
b98db1e
Update snapshots
github-actions[bot] Aug 21, 2025
5b65a7f
draft point should have fixed scale
andrewvarga Aug 21, 2025
7384b6c
just use orthoFactor
andrewvarga Aug 21, 2025
091c408
show draft point indicator for first line point when snapToGrid is en…
andrewvarga Aug 22, 2025
e7eb039
merge from main
andrewvarga Aug 22, 2025
e9fcd5f
merge remote
andrewvarga Aug 22, 2025
c02f295
Update snapshots
github-actions[bot] Aug 22, 2025
88f9356
Update snapshots
github-actions[bot] Aug 22, 2025
2022e7d
fix dpr handling for grid thresholds
andrewvarga Aug 22, 2025
850fffb
merge from main
andrewvarga Aug 22, 2025
aa710ca
revert dpr for a better fix
andrewvarga Aug 22, 2025
380066a
rename onWindowResize -> onCanvasResized
andrewvarga Aug 22, 2025
8fd11f3
handle dpr change
andrewvarga Aug 22, 2025
340af65
fix draftpoint scale for other baseunits
andrewvarga Aug 22, 2025
e487d67
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 22, 2025
7f5227d
merge main
andrewvarga Aug 25, 2025
bbb0c06
Update snapshots
github-actions[bot] Aug 25, 2025
c5e12e5
Update snapshots
github-actions[bot] Aug 25, 2025
5fbad61
majorgridspacing and minorgridspermajor should be available in both f…
andrewvarga Aug 25, 2025
319b379
fix usage of majorGridSpacing
andrewvarga Aug 25, 2025
44e3c0e
merge main
andrewvarga Aug 26, 2025
99e46bc
move sceneInfra._baseUnitMultipler behind public getter
andrewvarga Aug 26, 2025
f7a4ada
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 26, 2025
38e3d4e
merge main
andrewvarga Aug 26, 2025
9dd0967
Update snapshots
github-actions[bot] Aug 26, 2025
00237ea
Merge branch 'main' into andrewvarga/1502/add-snap-to-grid-to-sketch-…
andrewvarga Aug 27, 2025
d669634
fix test to refer to line tool in a unique way (new settings options …
andrewvarga Aug 27, 2025
726c4c1
add min option to settings numbers
andrewvarga Aug 27, 2025
832d4e1
merge main
andrewvarga Aug 28, 2025
900da94
Update snapshots
github-actions[bot] Aug 28, 2025
f9958d5
Update snapshots
github-actions[bot] Aug 28, 2025
5de0ccd
fix snap grid related project settings not able to override user leve…
andrewvarga Aug 28, 2025
c62d77c
merge remote
andrewvarga Aug 28, 2025
4e07547
fix revert to default button not updating number input
andrewvarga Aug 28, 2025
7fb5897
same fix for text input
andrewvarga Aug 29, 2025
401a257
same fix for text input
andrewvarga Aug 29, 2025
cac9896
merge main
andrewvarga Aug 29, 2025
443a99d
Update snapshots
github-actions[bot] Aug 29, 2025
1e50fa4
clippy
andrewvarga Aug 29, 2025
db30fe4
Update snapshots
github-actions[bot] Aug 29, 2025
1afda7d
enable snap to grid for rectangles
andrewvarga Aug 29, 2025
d34e78f
merge remote
andrewvarga Aug 29, 2025
35dcef1
merge main
andrewvarga Aug 31, 2025
53f643a
Update snapshots
github-actions[bot] Aug 31, 2025
2f630ec
remove some code duplication
andrewvarga Aug 31, 2025
adafab7
circle origin snap
andrewvarga Aug 31, 2025
b0f737d
enable snap for circles
andrewvarga Aug 31, 2025
a20e28f
merge remote
andrewvarga Aug 31, 2025
f1262d3
fix circular deps
andrewvarga Aug 31, 2025
62b0a89
Update snapshots
github-actions[bot] Aug 31, 2025
9f114c5
Update Changing theme in sketch mode test after grids are rendered be…
andrewvarga Sep 1, 2025
e00b483
remove comments
andrewvarga Sep 1, 2025
0f267ea
use log instead of while loop
andrewvarga Sep 1, 2025
6c56b73
InfiniteGrid: snap to half pixels to avoid line flickering
andrewvarga Sep 1, 2025
312fadd
typos
andrewvarga Sep 2, 2025
a54b9a8
introduce getGridScaleFactor so it can be reused for snapping based o…
andrewvarga Sep 2, 2025
8c0d90d
snap to grid based on current grid zoom level
andrewvarga Sep 2, 2025
c6547ab
more consistent grid scaling when zooming in
andrewvarga Sep 2, 2025
2b505d2
merge main
andrewvarga Sep 2, 2025
7f8a486
lint
andrewvarga Sep 2, 2025
4c1cb93
update settings docs
andrewvarga Sep 2, 2025
98785be
Update snapshots
github-actions[bot] Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/kcl-lang/settings/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,41 @@ Highlight edges of 3D objects?
Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.


**Default:** None

##### fixed_size_grid

When enabled, the grid will use a fixed size based on your selected units rather than automatically scaling with zoom level.


**Default:** None

##### snap_to_grid

Whether or not to snap to the scale grid in sketching mode.


**Default:** None

##### major_grid_spacing

The space between major grid lines, specified in the current unit


**Default:** None

##### minor_grids_per_major

Specifies how many minor grid lines to have per major grid line.


**Default:** None

##### snaps_per_minor

The number of snaps to have between minor grid lines. 1 means snapping to the minor grid lines.


**Default:** None


Expand Down
42 changes: 35 additions & 7 deletions docs/kcl-lang/settings/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ Allow orbiting in sketch mode.
Whether to show the debug panel, which lets you see various states of the app to aid in development.


**Default:** None

##### fixed_size_grid

If true, the grid cells will be fixed-size, where the width is your default length unit. If false, the grid will get larger as you zoom out, and smaller as you zoom in.


**Default:** None


Expand Down Expand Up @@ -164,6 +157,41 @@ Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
Whether or not to show a scale grid in the 3D modeling view


**Default:** None

##### fixed_size_grid

When enabled, the grid will use a fixed size based on your selected units rather than automatically scaling with zoom level. If true, the grid cells will be fixed-size, where the width is your default length unit. If false, the grid will get larger as you zoom out, and smaller as you zoom in.


**Default:** None

##### snap_to_grid

Whether or not to snap to the scale grid in sketching mode.


**Default:** None

##### major_grid_spacing

The space between major grid lines, specified in the current unit


**Default:** None

##### minor_grids_per_major

Specifies ow many minor grid lines to have per major grid line.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small typo in the documentation: "Specifies ow many minor grid lines" should be "Specifies how many minor grid lines". This affects the user-facing documentation and should be corrected for clarity.

Suggested change
Specifies ow many minor grid lines to have per major grid line.
Specifies how many minor grid lines to have per major grid line.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.



**Default:** None

##### snaps_per_minor

The number of snaps to have between minor grid lines. 1 means snapping to the minor grid lines.


**Default:** None


Expand Down
2 changes: 1 addition & 1 deletion e2e/playwright/command-bar-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ test.describe('Command bar tests', () => {
name: 'rectangle Corner rectangle',
})
const lineToolCommand = page.getByRole('option', {
name: 'Line',
name: 'line Line Start drawing',
})
const lineToolButton = page.getByRole('button', {
name: 'line Line',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion e2e/playwright/storageStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ export const TEST_SETTINGS: DeepPartial<Settings> = {
},
onboarding_status: 'dismissed',
show_debug_panel: true,
fixed_size_grid: false,
},
modeling: {
enable_ssao: false,
base_unit: 'in',
mouse_controls: 'zoo',
camera_projection: 'perspective',
// Tests were written before this setting existed.
// It's true by default because it's a good user experience, but
// these tests require it to be false.
fixed_size_grid: false,
},
project: {
default_project_name: 'untitled',
Expand Down
4 changes: 0 additions & 4 deletions e2e/playwright/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,6 @@ export async function setup(
},
...TEST_SETTINGS.project,
onboarding_status: 'dismissed',
// Tests were written before this setting existed.
// It's true by default because it's a good user experience, but
// these tests require it to be false.
fixed_size_grid: false,
},
project: {
...TEST_SETTINGS.project,
Expand Down
4 changes: 2 additions & 2 deletions e2e/playwright/testing-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,8 @@ test.describe(
const lineToolButton = page.getByTestId('line')
const segmentOverlays = page.getByTestId('segment-overlay')
const sketchOriginLocation = { x: 600, y: 250 }
const darkThemeSegmentColor: [number, number, number] = [215, 215, 215]
const lightThemeSegmentColor: [number, number, number] = [90, 90, 90]
const darkThemeSegmentColor: [number, number, number] = [249, 249, 249]
const lightThemeSegmentColor: [number, number, number] = [28, 28, 28]

await test.step(`Get into sketch mode`, async () => {
await page.mouse.click(700, 200)
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/kcl-lib/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl From<crate::settings::types::Settings> for ExecutorSettings {
replay: None,
project_directory: None,
current_file: None,
fixed_size_grid: settings.app.fixed_size_grid,
fixed_size_grid: settings.modeling.fixed_size_grid,
}
}
}
Expand Down
40 changes: 20 additions & 20 deletions rust/kcl-lib/src/settings/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Settings {
}

/// Application wide settings.
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
#[ts(export)]
#[serde(rename_all = "snake_case")]
pub struct AppSettings {
Expand Down Expand Up @@ -94,10 +94,6 @@ pub struct AppSettings {
/// of the app to aid in development.
#[serde(default, skip_serializing_if = "is_default")]
pub show_debug_panel: bool,
/// If true, the grid cells will be fixed-size, where the width is your default length unit.
/// If false, the grid will get larger as you zoom out, and smaller as you zoom in.
#[serde(default = "make_it_so", skip_serializing_if = "is_true")]
pub fixed_size_grid: bool,
}

/// Default to true.
Expand All @@ -109,20 +105,6 @@ fn is_true(b: &bool) -> bool {
*b
}

impl Default for AppSettings {
fn default() -> Self {
Self {
appearance: Default::default(),
onboarding_status: Default::default(),
dismiss_web_banner: Default::default(),
stream_idle_mode: Default::default(),
allow_orbit_in_sketch_mode: Default::default(),
show_debug_panel: Default::default(),
fixed_size_grid: make_it_so(),
}
}
}

fn deserialize_stream_idle_mode<'de, D>(deserializer: D) -> Result<Option<u32>, D::Error>
where
D: Deserializer<'de>,
Expand Down Expand Up @@ -270,7 +252,7 @@ impl From<AppTheme> for kittycad::types::Color {
}

/// Settings that affect the behavior while modeling.
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Eq, Validate)]
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
#[serde(rename_all = "snake_case")]
#[ts(export)]
pub struct ModelingSettings {
Expand Down Expand Up @@ -301,6 +283,23 @@ pub struct ModelingSettings {
/// Whether or not to show a scale grid in the 3D modeling view
#[serde(default, skip_serializing_if = "is_default")]
pub show_scale_grid: bool,
/// When enabled, the grid will use a fixed size based on your selected units rather than automatically scaling with zoom level.
/// If true, the grid cells will be fixed-size, where the width is your default length unit.
/// If false, the grid will get larger as you zoom out, and smaller as you zoom in.
#[serde(default = "make_it_so", skip_serializing_if = "is_true")]
pub fixed_size_grid: bool,
/// Whether or not to snap to the scale grid in sketching mode.
#[serde(default, skip_serializing_if = "is_default")]
pub snap_to_grid: bool,
/// The space between major grid lines, specified in the current unit
#[serde(default, skip_serializing_if = "is_default")]
pub major_grid_spacing: f64,
/// Specifies ow many minor grid lines to have per major grid line.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the field description for minor_grids_per_major. It should read "Specifies how many minor grid lines" instead of "Specifies ow many minor grid lines".

Suggested change
/// Specifies ow many minor grid lines to have per major grid line.
/// Specifies how many minor grid lines to have per major grid line.

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

#[serde(default, skip_serializing_if = "is_default")]
pub minor_grids_per_major: f64,
/// The number of snaps to have between minor grid lines. 1 means snapping to the minor grid lines.
#[serde(default, skip_serializing_if = "is_default")]
pub snaps_per_minor: f64,
}

#[derive(Debug, Copy, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Eq)]
Expand Down Expand Up @@ -681,6 +680,7 @@ text_wrapping = true"#;
base_unit: UnitLength::In,
mouse_controls: MouseControlType::Zoo,
camera_projection: CameraProjectionType::Perspective,
fixed_size_grid: true,
..Default::default()
},
project: ProjectSettings {
Expand Down
22 changes: 21 additions & 1 deletion rust/kcl-lib/src/settings/types/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub struct ProjectAppearanceSettings {
}

/// Project specific settings that affect the behavior while modeling.
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Eq, Validate)]
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
#[serde(rename_all = "snake_case")]
#[ts(export)]
pub struct ProjectModelingSettings {
Expand All @@ -133,6 +133,21 @@ pub struct ProjectModelingSettings {
/// Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
#[serde(default, skip_serializing_if = "is_default")]
pub enable_ssao: DefaultTrue,
/// When enabled, the grid will use a fixed size based on your selected units rather than automatically scaling with zoom level.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub fixed_size_grid: Option<bool>,
/// Whether or not to snap to the scale grid in sketching mode.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub snap_to_grid: Option<bool>,
/// The space between major grid lines, specified in the current unit
#[serde(default, skip_serializing_if = "Option::is_none")]
pub major_grid_spacing: Option<f64>,
/// Specifies how many minor grid lines to have per major grid line.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub minor_grids_per_major: Option<f64>,
/// The number of snaps to have between minor grid lines. 1 means snapping to the minor grid lines.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub snaps_per_minor: Option<f64>,
}

fn named_view_point_version_one() -> f64 {
Expand Down Expand Up @@ -331,6 +346,11 @@ color = 1567.4"#;
base_unit: UnitLength::Yd,
highlight_edges: Default::default(),
enable_ssao: true.into(),
snap_to_grid: None,
major_grid_spacing: None,
minor_grids_per_major: None,
snaps_per_minor: None,
fixed_size_grid: None,
},
text_editor: TextEditorSettings {
text_wrapping: false.into(),
Expand Down
14 changes: 4 additions & 10 deletions src/clientSideScene/CameraControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
} from '@src/lib/utils'
import { deg2Rad } from '@src/lib/utils2d'
import { degToRad } from 'three/src/math/MathUtils'
import { Signal } from '@src/lib/signal'

const ORTHOGRAPHIC_CAMERA_SIZE = 20
const FRAMES_TO_ANIMATE_IN = 30
Expand Down Expand Up @@ -426,15 +427,8 @@ export class CameraControls {
setIsCamMovingCallback(cb: (isMoving: boolean, isTween: boolean) => void) {
this._isCamMovingCallback = cb
}
private _camChangeCallbacks: { [key: string]: () => void } = {}
subscribeToCamChange(cb: () => void) {
const cbId = uuidv4()
this._camChangeCallbacks[cbId] = cb
const unsubscribe = () => {
delete this._camChangeCallbacks[cbId]
}
return unsubscribe
}

public readonly cameraChange = new Signal()

onWindowResize = () => {
if (this.camera instanceof PerspectiveCamera) {
Expand Down Expand Up @@ -1509,7 +1503,7 @@ export class CameraControls {
})
}
this.deferReactUpdate(this.reactCameraProperties)
Object.values(this._camChangeCallbacks).forEach((cb) => cb())
this.cameraChange.dispatch()
}
getInteractionType = (
event: PointerEvent | WheelEvent | MouseEvent
Expand Down
22 changes: 20 additions & 2 deletions src/clientSideScene/ClientSideSceneComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const ClientSideScene = ({
const canvas = canvasRef.current
canvas.appendChild(sceneInfra.renderer.domElement)
canvas.appendChild(sceneInfra.labelRenderer.domElement)
sceneInfra.onWindowResize()
sceneInfra.onCanvasResized()
sceneInfra.animate()
canvas.addEventListener(
'mousemove',
Expand Down Expand Up @@ -135,13 +135,31 @@ export const ClientSideScene = ({
useEffect(() => {
const canvas = canvasRef.current
if (!canvas) return

// Detect canvas size changes
const observer = new ResizeObserver(() => {
sceneInfra.onWindowResize()
sceneInfra.onCanvasResized()
sceneInfra.camControls.onWindowResize()
})
observer.observe(canvas)

// Detect dpr changes
let media = window.matchMedia(
`(resolution: ${window.devicePixelRatio}dppx)`
)
function handleChange() {
media.removeEventListener('change', handleChange)
media = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
media.addEventListener('change', handleChange)

sceneInfra.onCanvasResized()
sceneInfra.camControls.onWindowResize()
}
media.addEventListener('change', handleChange)

return () => {
observer.disconnect()
media.removeEventListener('change', handleChange)
}
}, [])

Expand Down
Loading
Loading