camera breaks on extrude zoom to fit (#3276)
This commit is contained in:
@ -2,7 +2,7 @@ import { Program, SourceRange } from 'lang/wasm'
|
|||||||
import { VITE_KC_API_WS_MODELING_URL } from 'env'
|
import { VITE_KC_API_WS_MODELING_URL } from 'env'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { exportSave } from 'lib/exportSave'
|
import { exportSave } from 'lib/exportSave'
|
||||||
import { deferExecution, uuidv4 } from 'lib/utils'
|
import { deferExecution, isOverlap, uuidv4 } from 'lib/utils'
|
||||||
import { Themes, getThemeColorForEngine, getOppositeTheme } from 'lib/theme'
|
import { Themes, getThemeColorForEngine, getOppositeTheme } from 'lib/theme'
|
||||||
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
import {
|
import {
|
||||||
@ -1899,15 +1899,10 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
range: SourceRange,
|
range: SourceRange,
|
||||||
commandTypeToTarget: string
|
commandTypeToTarget: string
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
const values = Object.entries(this.artifactGraph)
|
for (const [artifactId, artifact] of this.artifactGraph) {
|
||||||
for (const [id, data] of values) {
|
if ('codeRef' in artifact && isOverlap(range, artifact.codeRef.range)) {
|
||||||
// // Our range selection seems to just select the cursor position, so either
|
if (commandTypeToTarget === artifact.type) return artifactId
|
||||||
// // of these can be right...
|
}
|
||||||
if (
|
|
||||||
(data.range[0] === range[0] || data.range[1] === range[1]) &&
|
|
||||||
data.type === commandTypeToTarget
|
|
||||||
)
|
|
||||||
return id
|
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import EditorManager from 'editor/manager'
|
|||||||
import { KclManager } from 'lang/KclSingleton'
|
import { KclManager } from 'lang/KclSingleton'
|
||||||
import CodeManager from 'lang/codeManager'
|
import CodeManager from 'lang/codeManager'
|
||||||
import { EngineCommandManager } from 'lang/std/engineConnection'
|
import { EngineCommandManager } from 'lang/std/engineConnection'
|
||||||
|
import { uuidv4 } from './utils'
|
||||||
|
|
||||||
export const codeManager = new CodeManager()
|
export const codeManager = new CodeManager()
|
||||||
|
|
||||||
@ -40,4 +41,14 @@ if (typeof window !== 'undefined') {
|
|||||||
;(window as any).enableFillet = () => {
|
;(window as any).enableFillet = () => {
|
||||||
;(window as any)._enableFillet = true
|
;(window as any)._enableFillet = true
|
||||||
}
|
}
|
||||||
|
;(window as any).zoomToFit = () =>
|
||||||
|
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.2, // padding around the objects
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -1101,11 +1101,13 @@ export const modelingMachine = createMachine(
|
|||||||
store.videoElement?.pause()
|
store.videoElement?.pause()
|
||||||
const updatedAst = await kclManager.updateAst(modifiedAst, true, {
|
const updatedAst = await kclManager.updateAst(modifiedAst, true, {
|
||||||
focusPath: pathToExtrudeArg,
|
focusPath: pathToExtrudeArg,
|
||||||
zoomToFit: true,
|
// commented out as a part of https://github.com/KittyCAD/modeling-app/issues/3270
|
||||||
zoomOnRangeAndType: {
|
// looking to add back in the future
|
||||||
range: selection.codeBasedSelections[0].range,
|
// zoomToFit: true,
|
||||||
type: 'start_path',
|
// zoomOnRangeAndType: {
|
||||||
},
|
// range: selection.codeBasedSelections[0].range,
|
||||||
|
// type: 'path',
|
||||||
|
// },
|
||||||
})
|
})
|
||||||
if (!engineCommandManager.engineConnection?.idleMode) {
|
if (!engineCommandManager.engineConnection?.idleMode) {
|
||||||
store.videoElement?.play().catch((e) => {
|
store.videoElement?.play().catch((e) => {
|
||||||
|
Reference in New Issue
Block a user