zoom to fit on between projects tauri fix (#2504)

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* triiger

* make better

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* empty

* fix tests

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:
Jess Frazelle
2024-05-24 12:32:15 -07:00
committed by GitHub
parent 1db3e1b5e4
commit 4cb6ceb043
12 changed files with 79 additions and 53 deletions

View File

@ -12,7 +12,7 @@ import { loadAndValidateSettings } from './settings/settingsUtils'
import makeUrlPathRelative from './makeUrlPathRelative'
import { sep } from '@tauri-apps/api/path'
import { readTextFile } from '@tauri-apps/plugin-fs'
import { codeManager, engineCommandManager, kclManager } from 'lib/singletons'
import { codeManager, kclManager } from 'lib/singletons'
import { fileSystemManager } from 'lang/std/fileSystemManager'
import {
getProjectInfo,
@ -20,7 +20,6 @@ import {
listProjects,
} from './tauri'
import { createSettings } from './settings/initialSettings'
import { uuidv4 } from './utils'
// The root loader simply resolves the settings and any errors that
// occurred during the settings load
@ -105,23 +104,8 @@ export const fileLoader: LoaderFunction = async ({
// the file system and not the editor.
codeManager.updateCurrentFilePath(current_file_path)
codeManager.updateCodeStateEditor(code)
kclManager.executeCode(true)
await engineCommandManager.sendSceneCommand({
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: {
type: 'zoom_to_fit',
object_ids: [], // leave empty to zoom to all objects
padding: 0.1, // padding around the objects
},
})
// make sure client camera syncs after zoom to fit since zoom to fit doesn't return camera settings
// TODO: https://github.com/KittyCAD/engine/issues/2098
await engineCommandManager.sendSceneCommand({
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: { type: 'default_camera_get_settings' },
})
// We don't want to call await on execute code since we don't want to block the UI
kclManager.executeCode(true, true)
// Set the file system manager to the project path
// So that WASM gets an updated path for operations