fix sketch mode scale issue (#6107)

* fix sketch mode scale issue

* fmt

* Fix snapshot tests in kurt-5621-scale-issue (#6111)

* Change test function to share units with settings (#6114)

* Change test function to share units with settings

* Consolidate to the same module

---------

Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
This commit is contained in:
Kurt Hutten
2025-04-03 07:31:18 +11:00
committed by GitHub
parent 2a56155587
commit 60bc38559b
33 changed files with 149 additions and 61 deletions

View File

@ -985,12 +985,13 @@ sketch001 = startSketchOn(XZ)
test( test(
'Can undo a sketch modification with ctrl+z', 'Can undo a sketch modification with ctrl+z',
{ tag: ['@skipWin'] }, { tag: ['@skipWin'] },
async ({ page, homePage }) => { async ({ page, homePage, editor }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
@ -1080,41 +1081,45 @@ sketch001 = startSketchOn(XZ)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArcTo([27.6, -3.05], %) |> tangentialArcTo([27.6, -3.05], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
// Hit undo // Hit undo
await page.keyboard.down('Control') await page.keyboard.down('Control')
await page.keyboard.press('KeyZ') await page.keyboard.press('KeyZ')
await page.keyboard.up('Control') await page.keyboard.up('Control')
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`) |> extrude(length = 5)`,
{ shouldNormalise: true }
)
// Hit undo again. // Hit undo again.
await page.keyboard.down('Control') await page.keyboard.down('Control')
await page.keyboard.press('KeyZ') await page.keyboard.press('KeyZ')
await page.keyboard.up('Control') await page.keyboard.up('Control')
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
// Hit undo again. // Hit undo again.
await page.keyboard.down('Control') await page.keyboard.down('Control')
@ -1122,13 +1127,15 @@ sketch001 = startSketchOn(XZ)
await page.keyboard.up('Control') await page.keyboard.up('Control')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`) |> extrude(length = 5)`,
{ shouldNormalise: true }
)
} }
) )

View File

@ -10,6 +10,9 @@ import {
openPane, openPane,
} from '@e2e/playwright/test-utils' } from '@e2e/playwright/test-utils'
import { expect } from '@e2e/playwright/zoo-test' import { expect } from '@e2e/playwright/zoo-test'
import { type baseUnitLabels } from '@src/lib/settings/settingsTypes'
type LengthUnitLabel = (typeof baseUnitLabels)[keyof typeof baseUnitLabels]
export class ToolbarFixture { export class ToolbarFixture {
public page: Page public page: Page
@ -236,6 +239,12 @@ export class ToolbarFixture {
async checkIfFeatureTreePaneIsOpen() { async checkIfFeatureTreePaneIsOpen() {
return this.checkIfPaneIsOpen(this.featureTreeId) return this.checkIfPaneIsOpen(this.featureTreeId)
} }
async selectUnit(unit: LengthUnitLabel) {
await this.page.getByTestId('units-menu').click()
const optionLocator = this.page.getByRole('button', { name: unit })
await expect(optionLocator).toBeVisible()
await optionLocator.click()
}
/** /**
* Get a specific operation button from the Feature Tree pane. * Get a specific operation button from the Feature Tree pane.

View File

@ -798,6 +798,74 @@ plane002 = offsetPlane(XZ, offset = -2 * x)`
await page.getByTestId('custom-cmd-send-button').click() await page.getByTestId('custom-cmd-send-button').click()
} }
) )
test('scale other than default works with sketch mode', async ({
page,
homePage,
toolbar,
editor,
scene,
}) => {
await test.step('Load the washer code', async () => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`@settings(defaultLengthUnit = in)
innerDiameter = 0.203
outerDiameter = 0.438
thicknessMax = 0.038
thicknessMin = 0.024
washerSketch = startSketchOn(XY)
|> circle(center = [0, 0], radius = outerDiameter / 2)
washer = extrude(washerSketch, length = thicknessMax)`
)
})
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
})
const [circleCenterClick] = scene.makeMouseHelpers(650, 300)
const [circleRadiusClick] = scene.makeMouseHelpers(800, 320)
const [washerFaceClick] = scene.makeMouseHelpers(657, 286)
await page.waitForTimeout(100)
await test.step('Start sketching on the washer face', async () => {
await toolbar.startSketchPlaneSelection()
await washerFaceClick()
await page.waitForTimeout(600) // engine animation
await toolbar.expectToolbarMode.toBe('sketching')
})
await test.step('Draw a circle and verify code', async () => {
// select circle tool
await expect
.poll(async () => {
await toolbar.circleBtn.click()
return toolbar.circleBtn.getAttribute('aria-pressed')
})
.toBe('true')
await page.waitForTimeout(100)
await circleCenterClick()
// this number will be different if the scale is not set correctly for inches
await editor.expectEditor.toContain(
'circle(sketch001, center = [0.06, -0.06]'
)
await circleRadiusClick()
await editor.expectEditor.toContain(
'circle(sketch001, center = [0.06, -0.06], radius = 0.18'
)
})
await test.step('Exit sketch mode', async () => {
await toolbar.exitSketch()
await toolbar.expectToolbarMode.toBe('modeling')
await toolbar.selectUnit('Yards')
await editor.expectEditor.toContain('@settings(defaultLengthUnit = yd)')
})
})
}) })
async function clickExportButton(page: Page) { async function clickExportButton(page: Page) {

View File

@ -479,7 +479,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> circle(center = [4.61, -5.01], radius = 8)` |> circle(center = [4.61, -5.01], radius = 8)`
) )
}) })
@ -564,12 +565,14 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
test('Can edit a sketch that has been extruded in the same pipe', async ({ test('Can edit a sketch that has been extruded in the same pipe', async ({
page, page,
homePage, homePage,
editor,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
@ -654,26 +657,29 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([7.12, -12.68], %) |> startProfileAt([7.12, -12.68], %)
|> line(end = [12.68, -1.09]) |> line(end = [12.68, -1.09])
|> tangentialArcTo([24.89, 0.68], %) |> tangentialArcTo([24.89, 0.68], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
}) })
test('Can edit a sketch that has been revolved in the same pipe', async ({ test('Can edit a sketch that has been revolved in the same pipe', async ({
page, page,
homePage, homePage,
scene, scene,
editor,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
@ -758,14 +764,16 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([6.44, -12.07], %) |> startProfileAt([6.44, -12.07], %)
|> line(end = [14.72, 1.97]) |> line(end = [14.72, 1.97])
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
|> line(end = [1.97, 2.06]) |> line(end = [1.97, 2.06])
|> close() |> close()
|> revolve(axis = "X")`) |> revolve(axis = "X")`,
{ shouldNormalise: true }
)
}) })
test('Can add multiple sketches', async ({ page, homePage }) => { test('Can add multiple sketches', async ({ page, homePage }) => {
const u = await getUtils(page) const u = await getUtils(page)

View File

@ -455,7 +455,7 @@ test(
await page.waitForTimeout(700) // TODO detect animation ending, or disable animation await page.waitForTimeout(700) // TODO detect animation ending, or disable animation
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` code += `profile001 = startProfileAt([182.59, -246.32], sketch001)`
await expect(page.locator('.cm-content')).toHaveText(code) await expect(page.locator('.cm-content')).toHaveText(code)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -473,7 +473,7 @@ test(
await page.waitForTimeout(500) await page.waitForTimeout(500)
code += ` code += `
|> xLine(length = 7.25)` |> xLine(length = 184.3)`
await expect(page.locator('.cm-content')).toHaveText(code) await expect(page.locator('.cm-content')).toHaveText(code)
await page await page
@ -631,7 +631,7 @@ test(
mask: [page.getByTestId('model-state-indicator')], mask: [page.getByTestId('model-state-indicator')],
}) })
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`sketch001 = startSketchOn(XZ)profile001 = circle(sketch001, center = [14.44, -2.44], radius = 1)` `sketch001 = startSketchOn(XZ)profile001 = circle(sketch001, center = [366.89, -62.01], radius = 1)`
) )
} }
) )
@ -668,7 +668,7 @@ test.describe(
const startXPx = 600 const startXPx = 600
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` code += `profile001 = startProfileAt([182.59, -246.32], sketch001)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -676,7 +676,7 @@ test.describe(
await page.waitForTimeout(100) await page.waitForTimeout(100)
code += ` code += `
|> xLine(length = 7.25)` |> xLine(length = 184.3)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page await page
@ -691,7 +691,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += ` code += `
|> tangentialArcTo([21.7, -2.44], %)` |> tangentialArcTo([551.2, -62.01], %)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
// click tangential arc tool again to unequip it // click tangential arc tool again to unequip it

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -29,5 +29,5 @@
} }
} }
], ],
"kcl_version": "0.2.54" "kcl_version": "0.2.57"
} }

View File

@ -123,7 +123,6 @@ export class SceneInfra {
readonly camControls: CameraControls readonly camControls: CameraControls
private readonly fov = 45 private readonly fov = 45
isFovAnimationInProgress = false isFovAnimationInProgress = false
_baseUnit: BaseUnit = 'mm'
_baseUnitMultiplier = 1 _baseUnitMultiplier = 1
_theme: Themes = Themes.System _theme: Themes = Themes.System
readonly extraSegmentTexture: Texture readonly extraSegmentTexture: Texture
@ -154,7 +153,6 @@ export class SceneInfra {
this.selected = null // following selections between callbacks being set is too tricky this.selected = null // following selections between callbacks being set is too tricky
} }
set baseUnit(unit: BaseUnit) { set baseUnit(unit: BaseUnit) {
this._baseUnit = unit
this._baseUnitMultiplier = baseUnitTomm(unit) this._baseUnitMultiplier = baseUnitTomm(unit)
this.scene.scale.set( this.scene.scale.set(
this._baseUnitMultiplier, this._baseUnitMultiplier,

View File

@ -26,6 +26,7 @@ export function UnitsMenu() {
{({ close }) => ( {({ close }) => (
<> <>
<Popover.Button <Popover.Button
data-testid="units-menu"
className={`flex items-center gap-2 px-3 py-1 className={`flex items-center gap-2 px-3 py-1
text-xs text-primary bg-chalkboard-10/70 dark:bg-chalkboard-100/80 backdrop-blur-sm text-xs text-primary bg-chalkboard-10/70 dark:bg-chalkboard-100/80 backdrop-blur-sm
border !border-primary/50 rounded-full`} border !border-primary/50 rounded-full`}

View File

@ -4,6 +4,7 @@ import type {
ModelingCmdReq_type, ModelingCmdReq_type,
} from '@kittycad/lib/dist/types/src/models' } from '@kittycad/lib/dist/types/src/models'
import type { KclValue } from '@rust/kcl-lib/bindings/KclValue'
import type { Node } from '@rust/kcl-lib/bindings/Node' import type { Node } from '@rust/kcl-lib/bindings/Node'
import type { Operation } from '@rust/kcl-lib/bindings/Operation' import type { Operation } from '@rust/kcl-lib/bindings/Operation'
@ -19,7 +20,6 @@ import { topLevelRange } from '@src/lang/util'
import type { import type {
ArtifactGraph, ArtifactGraph,
ExecState, ExecState,
KclValue,
PathToNode, PathToNode,
Program, Program,
SourceRange, SourceRange,
@ -34,11 +34,17 @@ import {
} from '@src/lang/wasm' } from '@src/lang/wasm'
import type { ArtifactIndex } from '@src/lib/artifactIndex' import type { ArtifactIndex } from '@src/lib/artifactIndex'
import { buildArtifactIndex } from '@src/lib/artifactIndex' import { buildArtifactIndex } from '@src/lib/artifactIndex'
import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from '@src/lib/constants' import {
DEFAULT_DEFAULT_LENGTH_UNIT,
EXECUTE_AST_INTERRUPT_ERROR_MESSAGE,
} from '@src/lib/constants'
import { markOnce } from '@src/lib/performance' import { markOnce } from '@src/lib/performance'
import type { Selections } from '@src/lib/selections' import type { Selections } from '@src/lib/selections'
import { handleSelectionBatch } from '@src/lib/selections' import { handleSelectionBatch } from '@src/lib/selections'
import type { KclSettingsAnnotation } from '@src/lib/settings/settingsTypes' import type {
BaseUnit,
KclSettingsAnnotation,
} from '@src/lib/settings/settingsTypes'
import { jsAppSettings } from '@src/lib/settings/settingsUtils' import { jsAppSettings } from '@src/lib/settings/settingsUtils'
import { import {
codeManager, codeManager,
@ -110,6 +116,7 @@ export class KclManager {
private _diagnosticsCallback: (errors: Diagnostic[]) => void = () => {} private _diagnosticsCallback: (errors: Diagnostic[]) => void = () => {}
private _wasmInitFailedCallback: (arg: boolean) => void = () => {} private _wasmInitFailedCallback: (arg: boolean) => void = () => {}
private _executeCallback: () => void = () => {} private _executeCallback: () => void = () => {}
sceneInfraBaseUnitMultiplierSetter: (unit: BaseUnit) => void = () => {}
get ast() { get ast() {
return this._ast return this._ast
@ -780,6 +787,9 @@ export class KclManager {
set fileSettings(settings: KclSettingsAnnotation) { set fileSettings(settings: KclSettingsAnnotation) {
this._fileSettings = settings this._fileSettings = settings
this.sceneInfraBaseUnitMultiplierSetter(
settings?.defaultLengthUnit || DEFAULT_DEFAULT_LENGTH_UNIT
)
} }
} }

View File

@ -7,6 +7,7 @@ import { uuidv4 } from '@src/lib/utils'
import { SceneEntities } from '@src/clientSideScene/sceneEntities' import { SceneEntities } from '@src/clientSideScene/sceneEntities'
import { SceneInfra } from '@src/clientSideScene/sceneInfra' import { SceneInfra } from '@src/clientSideScene/sceneInfra'
import type { BaseUnit } from '@src/lib/settings/settingsTypes'
export const codeManager = new CodeManager() export const codeManager = new CodeManager()
@ -28,6 +29,9 @@ engineCommandManager.kclManager = kclManager
export const sceneInfra = new SceneInfra(engineCommandManager) export const sceneInfra = new SceneInfra(engineCommandManager)
engineCommandManager.camControlsCameraChange = sceneInfra.onCameraChange engineCommandManager.camControlsCameraChange = sceneInfra.onCameraChange
kclManager.sceneInfraBaseUnitMultiplierSetter = (unit: BaseUnit) => {
sceneInfra.baseUnit = unit
}
// This needs to be after sceneInfra and engineCommandManager are is created. // This needs to be after sceneInfra and engineCommandManager are is created.
export const editorManager = new EditorManager() export const editorManager = new EditorManager()

View File

@ -174,14 +174,6 @@ export const settingsMachine = setup({
}), }),
}, },
actions: { actions: {
setClientSideSceneUnits: ({ context, event }) => {
const newBaseUnit =
event.type === 'set.modeling.defaultUnit'
? (event.data.value as BaseUnit)
: context.modeling.defaultUnit.current
if (!sceneInfra) return
sceneInfra.baseUnit = newBaseUnit
},
setEngineTheme: ({ context }) => { setEngineTheme: ({ context }) => {
if (engineCommandManager && context.app.theme.current) { if (engineCommandManager && context.app.theme.current) {
engineCommandManager engineCommandManager
@ -372,7 +364,7 @@ export const settingsMachine = setup({
], ],
states: { states: {
idle: { idle: {
entry: ['setThemeClass', 'setClientSideSceneUnits', 'sendThemeToWatcher'], entry: ['setThemeClass', 'sendThemeToWatcher'],
on: { on: {
'*': { '*': {
@ -415,12 +407,7 @@ export const settingsMachine = setup({
'set.modeling.defaultUnit': { 'set.modeling.defaultUnit': {
target: 'persisting settings', target: 'persisting settings',
actions: [ actions: ['setSettingAtLevel', 'toastSuccess', 'Execute AST'],
'setSettingAtLevel',
'toastSuccess',
'setClientSideSceneUnits',
'Execute AST',
],
}, },
'set.app.theme': { 'set.app.theme': {
@ -474,7 +461,6 @@ export const settingsMachine = setup({
'resetSettings', 'resetSettings',
'setThemeClass', 'setThemeClass',
'setEngineTheme', 'setEngineTheme',
'setClientSideSceneUnits',
'setThemeColor', 'setThemeColor',
'Execute AST', 'Execute AST',
'setClientTheme', 'setClientTheme',
@ -488,7 +474,6 @@ export const settingsMachine = setup({
'setAllSettings', 'setAllSettings',
'setThemeClass', 'setThemeClass',
'setEngineTheme', 'setEngineTheme',
'setClientSideSceneUnits',
'setThemeColor', 'setThemeColor',
'Execute AST', 'Execute AST',
'setClientTheme', 'setClientTheme',
@ -549,7 +534,6 @@ export const settingsMachine = setup({
'setAllSettings', 'setAllSettings',
'setThemeClass', 'setThemeClass',
'setEngineTheme', 'setEngineTheme',
'setClientSideSceneUnits',
'setThemeColor', 'setThemeColor',
'setClientTheme', 'setClientTheme',
'setAllowOrbitInSketchMode', 'setAllowOrbitInSketchMode',
@ -579,7 +563,6 @@ export const settingsMachine = setup({
'setAllSettings', 'setAllSettings',
'setThemeClass', 'setThemeClass',
'setEngineTheme', 'setEngineTheme',
'setClientSideSceneUnits',
'setThemeColor', 'setThemeColor',
'Execute AST', 'Execute AST',
'setClientTheme', 'setClientTheme',