hack: resizeviewport 4:3 aspect ratio

This commit is contained in:
Geoff Doty 2018-03-08 16:48:05 -05:00
parent a0a489f1c6
commit 21ef146eb0
1 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,18 @@
<script> <script>
var tag = this; var tag = this;
// HACK: temp 3d viewport sizing
var viewport = function() {
function current() {
return window.innerWidth - 540; // 540 is UI elements
}
return {
height: (current() / 4) * 3, //4x3 resolution
width: current()
}
}
tag.on('mount', function() { tag.on('mount', function() {
@ -13,12 +25,12 @@
var app = new pc.Application(canvas, {}); var app = new pc.Application(canvas, {});
app.start(); app.start();
app.setCanvasFillMode(pc.FILLMODE_NONE, 640, 480); app.setCanvasFillMode(pc.FILLMODE_NONE, viewport().width, viewport().height);
app.setCanvasResolution(pc.RESOLUTION_AUTO); app.setCanvasResolution(pc.RESOLUTION_AUTO);
// ensure canvas is resized when window changes size // ensure canvas is resized when window changes size
window.addEventListener('resize', function() { window.addEventListener('resize', function() {
app.resizeCanvas(); app.resizeCanvas(viewport().width,viewport().height);
}); });
// create box entity // create box entity