Don't allow the user to zoom in so far that we run out of space in the glyph atlas
This commit is contained in:
parent
f68da75c75
commit
65eecbf071
|
@ -130,7 +130,7 @@ class BenchmarkTestView extends PathfinderDemoView {
|
|||
|
||||
this.appController = appController;
|
||||
|
||||
this.camera = new OrthographicCamera(this.canvas);
|
||||
this.camera = new OrthographicCamera(this.canvas, false);
|
||||
this.camera.onPan = () => this.setDirty();
|
||||
this.camera.onZoom = () => this.setDirty();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ const ORTHOGRAPHIC_ZOOM_SPEED: number = 1.0 / 100.0;
|
|||
const ORTHOGRAPHIC_ZOOM_IN_FACTOR: number = 1.2;
|
||||
const ORTHOGRAPHIC_ZOOM_OUT_FACTOR: number = 1.0 / ORTHOGRAPHIC_ZOOM_IN_FACTOR;
|
||||
|
||||
const ORTHOGRAPHIC_MAX_SCALE: number = 10.0;
|
||||
|
||||
const PERSPECTIVE_MOVEMENT_SPEED: number = 10.0;
|
||||
const PERSPECTIVE_ROTATION_SPEED: number = 1.0 / 300.0;
|
||||
|
||||
|
@ -50,9 +52,11 @@ export abstract class Camera {
|
|||
}
|
||||
|
||||
export class OrthographicCamera extends Camera {
|
||||
constructor(canvas: HTMLCanvasElement) {
|
||||
constructor(canvas: HTMLCanvasElement, limitedZoom: boolean) {
|
||||
super(canvas);
|
||||
|
||||
this.limitedZoom = limitedZoom;
|
||||
|
||||
this.translation = glmatrix.vec2.create();
|
||||
this.scale = 1.0;
|
||||
|
||||
|
@ -144,6 +148,8 @@ export class OrthographicCamera extends Camera {
|
|||
glmatrix.vec2.scale(absoluteTranslation, absoluteTranslation, 1.0 / this.scale);
|
||||
|
||||
this.scale *= scale;
|
||||
if (this.limitedZoom && this.scale > ORTHOGRAPHIC_MAX_SCALE)
|
||||
this.scale = ORTHOGRAPHIC_MAX_SCALE;
|
||||
|
||||
glmatrix.vec2.scale(absoluteTranslation, absoluteTranslation, this.scale);
|
||||
glmatrix.vec2.add(this.translation, absoluteTranslation, point);
|
||||
|
@ -171,6 +177,8 @@ export class OrthographicCamera extends Camera {
|
|||
|
||||
translation: glmatrix.vec2;
|
||||
scale: number;
|
||||
|
||||
private readonly limitedZoom: boolean;
|
||||
}
|
||||
|
||||
export class PerspectiveCamera extends Camera {
|
||||
|
|
|
@ -68,7 +68,7 @@ class MeshDebuggerView extends PathfinderView {
|
|||
super();
|
||||
|
||||
this.appController = appController;
|
||||
this.camera = new OrthographicCamera(this.canvas);
|
||||
this.camera = new OrthographicCamera(this.canvas, false);
|
||||
this.scale = 1.0;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class SVGDemoView extends PathfinderDemoView {
|
|||
|
||||
this.appController = appController;
|
||||
|
||||
this.camera = new OrthographicCamera(this.canvas);
|
||||
this.camera = new OrthographicCamera(this.canvas, false);
|
||||
this.camera.onPan = () => this.setDirty();
|
||||
this.camera.onZoom = () => this.setDirty();
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ class TextDemoView extends MonochromePathfinderView {
|
|||
|
||||
this.appController = appController;
|
||||
|
||||
this.camera = new OrthographicCamera(this.canvas);
|
||||
this.camera = new OrthographicCamera(this.canvas, true);
|
||||
this.camera.onPan = () => this.onPan();
|
||||
this.camera.onZoom = () => this.onZoom();
|
||||
|
||||
|
|
Loading…
Reference in New Issue