fix: improve text sharpness on zoom with tighter buckets and reliable init

Fix text staying blurry on zoom by ensuring the first setZoomBucket call
always applies (PixiJS v8 defaults to auto-resolution which skipped the
initial bucket=1 assignment), listening on both 'moved' and 'zoomed'
viewport events, and tightening bucket thresholds from 6 to 9 levels.
This commit is contained in:
Hiren Kangad
2026-03-13 11:33:57 +05:30
parent 470693266e
commit f978153a83
3 changed files with 16 additions and 6 deletions
+3
View File
@@ -185,12 +185,15 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
undoRef.current = new UndoManager(scene);
// Zoom-bucket text sharpness — re-rasterize visible text when zoom crosses bucket boundary
// Listen on both 'zoomed' and 'moved' — pixi-viewport may only fire 'moved' for some zoom types
const sharpness = new TextSharpnessManager(viewport, scene);
const onZoomBucketCheck = () => { sharpness.check(); };
viewport.on('zoomed', onZoomBucketCheck);
viewport.on('moved', onZoomBucketCheck);
scene.onItemCreated = (item) => { sharpness.applyToItem(item); };
sharpnessCleanupRef.current = () => {
viewport.off('zoomed', onZoomBucketCheck);
viewport.off('moved', onZoomBucketCheck);
scene.onItemCreated = null;
sharpness.destroy();
};