Skip to content

Commit c892339

Browse files
author
DavidQ
committed
Remove hidden Object Vector Studio zoom scale multiplier - PR_26140_050-remove-vector-hidden-zoom-scale
1 parent e7bf169 commit c892339

3 files changed

Lines changed: 42 additions & 26 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PR_26140_050-remove-vector-hidden-zoom-scale
2+
3+
## Summary
4+
- Removed Object Vector Studio V2 hidden VIEWPORT_ZOOM_VIEWBOX_SCALE/viewBoxZoom multiplier.
5+
- Made viewport.zoom 1.0 map directly to 100% by moving the current visual scale into DEFAULT_VIEWPORT dimensions: 3200x2200.
6+
- Preserved the PR_26140_049 initial visual geometry size, pan behavior, reset viewBox, wheel zoom, pointer mapping, and hit-test interactions.
7+
- Left Collision Inspector V2 percent zoom behavior unchanged.
8+
9+
## Validation
10+
- PASS: node --check tools/object-vector-studio-v2/js/ToolStarterApp.js.
11+
- PASS: node --check tests/playwright/tools/WorkspaceManagerV2.spec.mjs.
12+
- PASS: node --check tests/playwright/tools/CollisionInspectorV2.spec.mjs.
13+
- PASS: targeted ES module import validation for Object Vector Studio V2 and Collision Inspector V2 modules.
14+
- PASS: targeted static zoom validation confirmed no VIEWPORT_ZOOM_VIEWBOX_SCALE/viewBoxZoom remains, Object Vector Studio V2 default zoom is 100%, range remains 10% to 1000%, and Collision Inspector V2 remains percent-based.
15+
- PASS: npx playwright test tests/playwright/tools/CollisionInspectorV2.spec.mjs --project=playwright --workers=1 --reporter=list, 4 passed.
16+
- PASS: npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs --project=playwright --workers=1 --reporter=list --grep "shows Object Vector Studio V2 layout shell|creates Object Vector Studio V2 shapes with canvas drawing|edits Object Vector Studio V2 preview shapes|aligns Object Vector Studio V2 selection bounds|expands Object Vector Studio V2 asset authoring controls|drags selected Object Vector Studio V2 shapes|tracks Object Vector Studio V2 dirty state", 7 passed after serial rerun.
17+
- PASS: npm run test:workspace-v2, 58 passed.
18+
- PASS: git diff --check.
19+
- PASS: V8 coverage guardrail lists tools/object-vector-studio-v2/js/ToolStarterApp.js at 94% function coverage and no changed-runtime warnings.
20+
- PASS: no games, samples, or start_of_day files changed.
21+
- SKIPPED: full samples smoke test, per request.
22+
23+
## Notes
24+
- A first focused OVS subset run was invalidated by a Playwright artifact-file race after running two Playwright commands concurrently; the same focused subset passed when rerun serially.
25+
- No sample JSON files were touched.

tests/playwright/tools/WorkspaceManagerV2.spec.mjs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,13 @@ function displayAbsoluteOutputPath(server, relativePath) {
105105

106106
async function objectVectorLogicalClientPoint(page, x, y) {
107107
return page.locator("#objectVectorStudioV2RenderSurface").evaluate((surface, point) => {
108-
const app = window.__objectVectorStudioV2App;
109108
const bounds = surface.getBoundingClientRect();
110-
const viewBoxZoom = app.viewBoxZoom();
111-
const viewWidth = 320 / viewBoxZoom;
112-
const viewHeight = 220 / viewBoxZoom;
109+
const [viewX, viewY, viewWidth, viewHeight] = surface.getAttribute("viewBox").split(/\s+/).map(Number);
113110
const drawingX = point.x * 10;
114111
const drawingY = point.y * 10;
115112
return {
116-
x: bounds.left + ((drawingX - app.viewport.x + viewWidth / 2) / viewWidth) * bounds.width,
117-
y: bounds.top + ((drawingY - app.viewport.y + viewHeight / 2) / viewHeight) * bounds.height
113+
x: bounds.left + ((drawingX - viewX) / viewWidth) * bounds.width,
114+
y: bounds.top + ((drawingY - viewY) / viewHeight) * bounds.height
118115
};
119116
}, { x, y });
120117
}
@@ -3436,8 +3433,9 @@ test.describe("Workspace Manager V2 bootstrap", () => {
34363433
await expect(page.locator("#statusLog")).toHaveValue(/OK Tools mode selected from keyboard: select\./);
34373434

34383435
const zoomSource = await readFile("tools/object-vector-studio-v2/js/ToolStarterApp.js", "utf8");
3439-
expect(zoomSource).toContain("const DEFAULT_VIEWPORT = Object.freeze({ height: 220, width: 320, x: 0, y: 0, zoom: 1.0 });");
3440-
expect(zoomSource).toContain("const VIEWPORT_ZOOM_VIEWBOX_SCALE = 0.1;");
3436+
expect(zoomSource).toContain("const DEFAULT_VIEWPORT = Object.freeze({ height: 2200, width: 3200, x: 0, y: 0, zoom: 1.0 });");
3437+
expect(zoomSource).not.toContain("VIEWPORT_ZOOM_VIEWBOX_SCALE");
3438+
expect(zoomSource).not.toContain("viewBoxZoom");
34413439
expect(zoomSource).toContain("const MAX_ZOOM = 10.0;");
34423440
expect(zoomSource).toContain("const MIN_ZOOM = 0.1;");
34433441
expect(zoomSource).toContain("const ZOOM_STEP = 0.1;");

tools/object-vector-studio-v2/js/ToolStarterApp.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const ANGLE_SNAP_STEP_SESSION_KEY = "object-vector-studio-v2.angleSnapStep";
2727
const GRID_RENDER_SESSION_KEY = "object-vector-studio-v2.gridRender";
2828
const CENTER_ORIGIN_SESSION_KEY = "object-vector-studio-v2.centerOrigin";
2929
const SVG_NS = "http://www.w3.org/2000/svg";
30-
const DEFAULT_VIEWPORT = Object.freeze({ height: 220, width: 320, x: 0, y: 0, zoom: 1.0 });
31-
const VIEWPORT_ZOOM_VIEWBOX_SCALE = 0.1;
30+
const DEFAULT_VIEWPORT = Object.freeze({ height: 2200, width: 3200, x: 0, y: 0, zoom: 1.0 });
3231
const GRID_STEP = 10;
3332
const OBJECT_PREVIEW_DRAWING_SCALE = GRID_STEP;
3433
const MAX_ZOOM = 10.0;
@@ -3348,8 +3347,8 @@ export class ToolStarterApp {
33483347
if (!this.gridRenderEnabled) {
33493348
return;
33503349
}
3351-
const width = DEFAULT_VIEWPORT.width / this.viewBoxZoom();
3352-
const height = DEFAULT_VIEWPORT.height / this.viewBoxZoom();
3350+
const width = DEFAULT_VIEWPORT.width / this.viewport.zoom;
3351+
const height = DEFAULT_VIEWPORT.height / this.viewport.zoom;
33533352
const minX = this.viewport.x - width / 2;
33543353
const maxX = this.viewport.x + width / 2;
33553354
const minY = this.viewport.y - height / 2;
@@ -3599,8 +3598,8 @@ export class ToolStarterApp {
35993598
if (!bounds.width || !bounds.height) {
36003599
return null;
36013600
}
3602-
const viewWidth = DEFAULT_VIEWPORT.width / this.viewBoxZoom();
3603-
const viewHeight = DEFAULT_VIEWPORT.height / this.viewBoxZoom();
3601+
const viewWidth = DEFAULT_VIEWPORT.width / this.viewport.zoom;
3602+
const viewHeight = DEFAULT_VIEWPORT.height / this.viewport.zoom;
36043603
const drawingX = point.x * OBJECT_PREVIEW_DRAWING_SCALE;
36053604
const drawingY = point.y * OBJECT_PREVIEW_DRAWING_SCALE;
36063605
return {
@@ -4542,8 +4541,8 @@ export class ToolStarterApp {
45424541
}
45434542

45444543
updateViewport() {
4545-
const width = DEFAULT_VIEWPORT.width / this.viewBoxZoom();
4546-
const height = DEFAULT_VIEWPORT.height / this.viewBoxZoom();
4544+
const width = DEFAULT_VIEWPORT.width / this.viewport.zoom;
4545+
const height = DEFAULT_VIEWPORT.height / this.viewport.zoom;
45474546
const viewX = this.formatViewportNumber(this.viewport.x - width / 2);
45484547
const viewY = this.formatViewportNumber(this.viewport.y - height / 2);
45494548
this.elements.renderSurface.setAttribute("viewBox", `${viewX} ${viewY} ${this.formatViewportNumber(width)} ${this.formatViewportNumber(height)}`);
@@ -4580,10 +4579,6 @@ export class ToolStarterApp {
45804579
return Math.round(this.viewport.zoom * 100);
45814580
}
45824581

4583-
viewBoxZoom(zoom = this.viewport.zoom) {
4584-
return zoom * VIEWPORT_ZOOM_VIEWBOX_SCALE;
4585-
}
4586-
45874582
zoomViewportByStep(step) {
45884583
const nextZoom = Number((this.viewport.zoom + step).toFixed(3));
45894584
this.zoomViewport(nextZoom);
@@ -4616,9 +4611,8 @@ export class ToolStarterApp {
46164611
return;
46174612
}
46184613
const zoom = this.clampedViewportZoom(nextZoom);
4619-
const viewBoxZoom = this.viewBoxZoom(zoom);
4620-
const viewWidth = DEFAULT_VIEWPORT.width / viewBoxZoom;
4621-
const viewHeight = DEFAULT_VIEWPORT.height / viewBoxZoom;
4614+
const viewWidth = DEFAULT_VIEWPORT.width / zoom;
4615+
const viewHeight = DEFAULT_VIEWPORT.height / zoom;
46224616
this.viewport.zoom = zoom;
46234617
this.viewport.x = Number((anchor.x - (anchor.ratioX - 0.5) * viewWidth).toFixed(6));
46244618
this.viewport.y = Number((anchor.y - (anchor.ratioY - 0.5) * viewHeight).toFixed(6));
@@ -4672,9 +4666,8 @@ export class ToolStarterApp {
46724666
}
46734667
const ratioX = (clientX - bounds.left) / bounds.width;
46744668
const ratioY = (clientY - bounds.top) / bounds.height;
4675-
const viewBoxZoom = this.viewBoxZoom(zoom);
4676-
const viewWidth = DEFAULT_VIEWPORT.width / viewBoxZoom;
4677-
const viewHeight = DEFAULT_VIEWPORT.height / viewBoxZoom;
4669+
const viewWidth = DEFAULT_VIEWPORT.width / zoom;
4670+
const viewHeight = DEFAULT_VIEWPORT.height / zoom;
46784671
return {
46794672
ratioX,
46804673
ratioY,

0 commit comments

Comments
 (0)