From 4c57cea22d4d39d110936212d5f62264e35206fc Mon Sep 17 00:00:00 2001 From: lee-at-zoo-corp Date: Thu, 3 Apr 2025 17:31:51 -0400 Subject: [PATCH] Fix zoom to fit being frigged --- e2e/playwright/boolean.spec.ts | 3 +++ src/machines/engineStreamMachine.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/e2e/playwright/boolean.spec.ts b/e2e/playwright/boolean.spec.ts index 1598fadb0..3b493bb8f 100644 --- a/e2e/playwright/boolean.spec.ts +++ b/e2e/playwright/boolean.spec.ts @@ -75,6 +75,7 @@ test.describe('Point and click for boolean workflows', () => { // Select first object in the scene, expect there to be a pixel diff from the selection color change await clickFirstObject({ pixelDiff: 50 }) + await page.waitForTimeout(1000) // For subtract, we need to proceed to the next step before selecting the second object if (operationName !== 'subtract') { @@ -85,6 +86,8 @@ test.describe('Point and click for boolean workflows', () => { // Select second object await clickSecondObject({ pixelDiff: 50 }) + await page.waitForTimeout(1000) + // Confirm the operation in the command bar await cmdBar.progressCmdBar() diff --git a/src/machines/engineStreamMachine.ts b/src/machines/engineStreamMachine.ts index 69c2b7a67..36da9cc6a 100644 --- a/src/machines/engineStreamMachine.ts +++ b/src/machines/engineStreamMachine.ts @@ -5,6 +5,7 @@ import { rustContext, sceneInfra, } from '@src/lib/singletons' +import { uuidv4 } from '@src/lib/utils' import type { MutableRefObject } from 'react' import type { ActorRefFrom } from 'xstate' import { assign, fromPromise, setup } from 'xstate' @@ -120,6 +121,19 @@ export const engineStreamMachine = setup({ .catch(console.warn) await kclManager.executeCode() + + if (params.zoomToFit) { + 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 + animated: false, // don't animate the zoom for now + }, + }) + } } ), [EngineStreamTransition.Pause]: fromPromise(