diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index 3f151d041..b8c2f233b 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -618,19 +618,19 @@ test.describe('Sketch tests', () => { await u.closeDebugPanel() await click00r(30, 0) - codeStr += ` |> startProfileAt([1.53, 0], %)` + codeStr += ` |> startProfileAt([2.03, 0], %)` await expect(u.codeLocator).toHaveText(codeStr) await click00r(30, 0) - codeStr += ` |> line([1.53, 0], %)` + codeStr += ` |> line([2.04, 0], %)` await expect(u.codeLocator).toHaveText(codeStr) await click00r(0, 30) - codeStr += ` |> line([0, -1.53], %)` + codeStr += ` |> line([0, -2.03], %)` await expect(u.codeLocator).toHaveText(codeStr) await click00r(-30, 0) - codeStr += ` |> line([-1.53, 0], %)` + codeStr += ` |> line([-2.04, 0], %)` await expect(u.codeLocator).toHaveText(codeStr) await click00r(undefined, undefined) diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png index 528668a0d..5cbfcc202 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-win32.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-win32.png index 2b9f77ef3..f8b7efa88 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-win32.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-win32.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png index f1f99a00b..7b9ba39f5 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-win32.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-win32.png index c8134ff25..c7b742e48 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-win32.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-win32.png differ diff --git a/e2e/playwright/testing-selections.spec.ts b/e2e/playwright/testing-selections.spec.ts index ce779b0e1..059741f61 100644 --- a/e2e/playwright/testing-selections.spec.ts +++ b/e2e/playwright/testing-selections.spec.ts @@ -31,6 +31,8 @@ test.describe('Testing selections', () => { const xAxisClick = () => page.mouse.click(700, 253).then(() => page.waitForTimeout(100)) + const xAxisClickAfterExitingSketch = () => + page.mouse.click(639, 278).then(() => page.waitForTimeout(100)) const emptySpaceHover = () => test.step('Hover over empty space', async () => { await page.mouse.move(700, 143, { steps: 5 }) @@ -44,9 +46,13 @@ test.describe('Testing selections', () => { ) }) const topHorzSegmentClick = () => - page.mouse.click(709, 290).then(() => page.waitForTimeout(100)) + page.mouse + .click(startXPx, 500 - PUR * 20) + .then(() => page.waitForTimeout(100)) const bottomHorzSegmentClick = () => - page.mouse.click(767, 396).then(() => page.waitForTimeout(100)) + page.mouse + .click(startXPx + PUR * 10, 500 - PUR * 10) + .then(() => page.waitForTimeout(100)) await u.clearCommandLogs() await expect( @@ -196,6 +202,8 @@ test.describe('Testing selections', () => { // select a line, this verifies that sketches in the scene can be selected outside of sketch mode await topHorzSegmentClick() + await xAxisClickAfterExitingSketch() + await page.waitForTimeout(100) await emptySpaceHover() // enter sketch again @@ -425,7 +433,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02) |> line([0, 20.03], %) |> line([62.61, 0], %, $seg03) |> lineTo([profileStartX(%), profileStartY(%)], %) - |> close(%) + |> close(%) ` ) }, KCL_DEFAULT_LENGTH) @@ -1014,7 +1022,7 @@ const extrude001 = extrude(50, sketch001) |> line([4.95, -8], %) |> line([-20.38, -10.12], %) |> line([-15.79, 17.08], %) - + fn yohey = (pos) => { const sketch004 = startSketchOn('XZ') ${extrudeAndEditBlockedInFunction} @@ -1024,7 +1032,7 @@ const extrude001 = extrude(50, sketch001) |> line([-15.79, 17.08], %) return '' } - + yohey([15.79, -34.6]) ` ) diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index fd14ae387..4a1e63633 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -31,6 +31,7 @@ import { reportRejection } from 'lib/trap' const ORTHOGRAPHIC_CAMERA_SIZE = 20 const FRAMES_TO_ANIMATE_IN = 30 +const ORTHOGRAPHIC_MAGIC_FOV = 4 const tempQuaternion = new Quaternion() // just used for maths @@ -84,7 +85,7 @@ export class CameraControls { pendingPan: Vector2 | null = null interactionGuards: MouseGuard = cameraMouseDragGuards.KittyCAD isFovAnimationInProgress = false - fovBeforeOrtho = 45 + perspectiveFovBeforeOrtho = 45 get isPerspective() { return this.camera instanceof PerspectiveCamera } @@ -398,7 +399,7 @@ export class CameraControls { const zoomFudgeFactor = 2280 distance = zoomFudgeFactor / (this.camera.zoom * 45) } - const panSpeed = (distance / 1000 / 45) * this.fovBeforeOrtho + const panSpeed = (distance / 1000 / 45) * this.perspectiveFovBeforeOrtho this.pendingPan.x += -deltaMove.x * panSpeed this.pendingPan.y += deltaMove.y * panSpeed } @@ -516,19 +517,15 @@ export class CameraControls { _usePerspectiveCamera = () => { const { x: px, y: py, z: pz } = this.camera.position const { x: qx, y: qy, z: qz, w: qw } = this.camera.quaternion - const zoom = this.camera.zoom this.camera = this.createPerspectiveCamera() this.camera.position.set(px, py, pz) this.camera.quaternion.set(qx, qy, qz, qw) - const zoomFudgeFactor = 2280 - const distance = zoomFudgeFactor / (zoom * this.lastPerspectiveFov) const direction = new Vector3().subVectors( this.camera.position, this.target ) direction.normalize() - this.camera.position.copy(this.target).addScaledVector(direction, distance) } usePerspectiveCamera = async (forceSend = false) => { this._usePerspectiveCamera() @@ -980,9 +977,9 @@ export class CameraControls { ) this.isFovAnimationInProgress = true let currentFov = this.lastPerspectiveFov - this.fovBeforeOrtho = currentFov + this.perspectiveFovBeforeOrtho = currentFov - const targetFov = 4 + const targetFov = ORTHOGRAPHIC_MAGIC_FOV const fovAnimationStep = (currentFov - targetFov) / FRAMES_TO_ANIMATE_IN let frameWaitOnFinish = 10 @@ -1018,9 +1015,9 @@ export class CameraControls { ) } this.isFovAnimationInProgress = true - const targetFov = this.fovBeforeOrtho // Target FOV for perspective - this.lastPerspectiveFov = 4 - let currentFov = 4 + const targetFov = this.perspectiveFovBeforeOrtho // Target FOV for perspective + this.lastPerspectiveFov = ORTHOGRAPHIC_MAGIC_FOV + let currentFov = ORTHOGRAPHIC_MAGIC_FOV const initialCameraUp = this.camera.up.clone() // eslint-disable-next-line @typescript-eslint/no-floating-promises this.usePerspectiveCamera() @@ -1056,9 +1053,8 @@ export class CameraControls { ) } this.isFovAnimationInProgress = true - const targetFov = this.fovBeforeOrtho // Target FOV for perspective - this.lastPerspectiveFov = 4 - let currentFov = 4 + const targetFov = this.perspectiveFovBeforeOrtho // Target FOV for perspective + let currentFov = ORTHOGRAPHIC_MAGIC_FOV const initialCameraUp = this.camera.up.clone() // eslint-disable-next-line @typescript-eslint/no-floating-promises this.usePerspectiveCamera()