Don't allow the user to move the camera in the benchmarks and reference tests.

Doing this messes up the tests.
This commit is contained in:
Patrick Walton 2018-01-18 17:26:56 -08:00
parent 0720b04591
commit 7a2ad35d7e
10 changed files with 29 additions and 22 deletions

View File

@ -8,8 +8,7 @@
</head>
<body class="pf-unscrollable">
{{>partials/navbar.html isTool=true}}
<canvas id="pf-canvas" class="pf-maximized-canvas pf-draggable" width="400"
height="300"></canvas>
<canvas id="pf-canvas" class="pf-maximized-canvas" width="400" height="300"></canvas>
<svg id="pf-svg" xmlns="http://www.w3.org/2000/svg" width="400" height="300"></svg>
<div class="modal fade" id="pf-benchmark-modal" tabindex="-1" role="dialog"
aria-labelledby="pf-benchmark-label" aria-hidden="false">

View File

@ -8,8 +8,7 @@
</head>
<body class="pf-unscrollable">
{{>partials/navbar.html isTool=true}}
<canvas id="pf-canvas" class="pf-maximized-canvas pf-draggable" width="400"
height="300"></canvas>
<canvas id="pf-canvas" class="pf-maximized-canvas" width="400" height="300"></canvas>
<svg id="pf-svg" xmlns="http://www.w3.org/2000/svg" width="400" height="300"></svg>
<div class="fixed-bottom mb-3 d-flex justify-content-end align-items-end pf-pointer-events-none">
<div id="pf-toolbar">

View File

@ -167,17 +167,17 @@
<div class="col-auto d-flex flex-column">
<div class="row">
<canvas id="pf-reference-canvas"
class="pf-draggable border border-top-0 border-right-0"
class="border border-top-0 border-right-0"
width="250" height="200"></canvas>
</div>
<div class="row">
<canvas id="pf-canvas"
class="pf-draggable pf-no-autoresize border border-top-0 border-right-0"
class="pf-no-autoresize border border-top-0 border-right-0"
width="250" height="200"></canvas>
</div>
<div class="row">
<canvas id="pf-difference-canvas"
class="pf-draggable border border-top-0 border-right-0"
class="border border-top-0 border-right-0"
width="250" height="200"></canvas>
</div>
</div>

View File

@ -8,8 +8,7 @@
</head>
<body class="pf-unscrollable">
{{>partials/navbar.html isDemo=true}}
<canvas id="pf-canvas" class="pf-maximized-canvas pf-draggable" width="400"
height="300"></canvas>
<canvas id="pf-canvas" class="pf-maximized-canvas" width="400" height="300"></canvas>
<svg id="pf-svg" xmlns="http://www.w3.org/2000/svg" width="400" height="300"></svg>
<div class="fixed-bottom mb-3 d-flex justify-content-between align-items-end pf-pointer-events-none">
<div class="rounded invisible container py-1 px-3 ml-3" id="pf-fps-label"></div>

View File

@ -8,8 +8,7 @@
</head>
<body class="pf-unscrollable">
{{>partials/navbar.html isDemo=true}}
<canvas id="pf-canvas" class="pf-maximized-canvas pf-draggable" width="400"
height="300"></canvas>
<canvas id="pf-canvas" class="pf-maximized-canvas" width="400" height="300"></canvas>
<div class="fixed-bottom mb-3 d-flex justify-content-between align-items-end pf-pointer-events-none">
<div class="rounded invisible container py-1 px-3 ml-3" id="pf-fps-label"></div>
<div id="pf-toolbar">

View File

@ -504,7 +504,7 @@ class BenchmarkTextRenderer extends Renderer {
constructor(renderContext: BenchmarkTestView) {
super(renderContext);
this.camera = new OrthographicCamera(renderContext.canvas);
this.camera = new OrthographicCamera(renderContext.canvas, { fixed: true });
this.camera.onPan = () => renderContext.setDirty();
this.camera.onZoom = () => renderContext.setDirty();
}

View File

@ -11,7 +11,7 @@
import * as glmatrix from 'gl-matrix';
import * as _ from 'lodash';
import {EPSILON} from "./utils";
import {EPSILON, unwrapNull} from "./utils";
import {PathfinderView} from "./view";
const PIXELS_PER_LINE: number = 16.0;
@ -46,6 +46,7 @@ const PERSPECTIVE_HITBOX_RADIUS: number = 1.0;
const KEYCODES = ["W", "A", "S", "D"].map(x => x.charCodeAt(0));
export interface OrthographicCameraOptions {
fixed?: boolean;
minScale?: number;
maxScale?: number;
scaleBounds?: boolean;
@ -103,6 +104,7 @@ export class OrthographicCamera extends Camera {
private _bounds: glmatrix.vec4;
private readonly fixed: boolean;
private readonly minScale: number;
private readonly maxScale: number;
private readonly scaleBounds: boolean;
@ -118,6 +120,7 @@ export class OrthographicCamera extends Camera {
if (options == null)
options = {};
this.fixed = !!options.fixed;
this.minScale = _.defaultTo(options.minScale, ORTHOGRAPHIC_DEFAULT_MIN_SCALE);
this.maxScale = _.defaultTo(options.maxScale, ORTHOGRAPHIC_DEFAULT_MAX_SCALE);
this.scaleBounds = !!options.scaleBounds;
@ -127,10 +130,15 @@ export class OrthographicCamera extends Camera {
this._bounds = glmatrix.vec4.create();
this.canvas.addEventListener('wheel', event => this.onWheel(event), false);
this.canvas.addEventListener('mousedown', event => this.onMouseDown(event), false);
this.canvas.addEventListener('mouseup', event => this.onMouseUp(event), false);
this.canvas.addEventListener('mousemove', event => this.onMouseMove(event), false);
if (!this.fixed) {
this.canvas.addEventListener('wheel', event => this.onWheel(event), false);
this.canvas.addEventListener('mousedown', event => this.onMouseDown(event), false);
this.canvas.addEventListener('mouseup', event => this.onMouseUp(event), false);
this.canvas.addEventListener('mousemove', event => this.onMouseMove(event), false);
unwrapNull(this.canvas.classList).add('pf-draggable');
} else {
unwrapNull(this.canvas.classList).remove('pf-draggable');
}
this.onPan = null;
this.onZoom = null;

View File

@ -730,7 +730,7 @@ class ReferenceTestTextRenderer extends Renderer {
constructor(renderContext: ReferenceTestView) {
super(renderContext);
this.camera = new OrthographicCamera(renderContext.canvas);
this.camera = new OrthographicCamera(renderContext.canvas, { fixed: true });
this.camera.onPan = () => renderContext.setDirty();
this.camera.onZoom = () => renderContext.setDirty();
}
@ -835,7 +835,7 @@ class ReferenceTestSVGRenderer extends SVGRenderer {
}
constructor(renderContext: ReferenceTestView) {
super(renderContext, {sizeToFit: false});
super(renderContext, { sizeToFit: false, fixed: true });
}
}

View File

@ -38,6 +38,7 @@ const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
export interface SVGRendererOptions {
sizeToFit?: boolean;
fixed?: boolean;
}
export abstract class SVGRenderer extends Renderer {
@ -92,7 +93,10 @@ export abstract class SVGRenderer extends Renderer {
this.options = options;
this.camera = new OrthographicCamera(this.canvas, { scaleBounds: true });
this.camera = new OrthographicCamera(this.canvas, {
fixed: !!this.options.fixed,
scaleBounds: true,
});
this.camera.onPan = () => this.renderContext.setDirty();
this.camera.onZoom = () => this.renderContext.setDirty();
this.camera.onRotate = () => this.renderContext.setDirty();

View File

@ -609,8 +609,7 @@ export class MCAAStrategy extends XCAAStrategy {
return 'conservative';
}
protected setAAUniforms(renderer: Renderer, uniforms: UniformMap, objectIndex: number):
void {
protected setAAUniforms(renderer: Renderer, uniforms: UniformMap, objectIndex: number): void {
super.setAAUniforms(renderer, uniforms, objectIndex);
const renderContext = renderer.renderContext;