update camera aspect ratios when renderer size updates

beta.r3js.org
-=yb4f310 2018-01-14 15:37:32 +01:00
parent b72854c95b
commit de0cad37ab
2 changed files with 27 additions and 1 deletions

View File

@ -990,7 +990,7 @@ GameLib.Component.prototype.generateNewIds = function() {
this.idToObject[property].id = newId;
this.idToObject[property].name = this.idToObject[property].name.replace(oldId,newId);
// TODO: replace image filenames - but then also copy them server side?
// TODO: replace image filenames - but then also copy them server side?
// if (this.idToObject[property].fileName) {
// this.idToObject[property].fileName = this.idToObject[property].fileName.replace(oldId,newId);
// }

View File

@ -279,20 +279,34 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
if (property === 'width') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.width = trueWidth;
this.canvas.updateInstance('width');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(trueWidth, this.height * this.windowSize.y);
}
if (property === 'height') {
trueWidth = this.width * this.windowSize.x;
trueHeight = this.height * this.windowSize.y;
this.canvas.height = trueHeight;
this.canvas.updateInstance('height');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(this.width * this.windowSize.x, trueHeight);
}
@ -307,6 +321,12 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
this.canvas.updateInstance('width');
this.canvas.updateInstance('height');
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
this.instance.setSize(trueWidth, trueHeight);
}
@ -446,6 +466,12 @@ GameLib.D3.Renderer.prototype.updateInstance = function(property) {
this.canvas.instance.style.left = (this.offset.x * this.windowSize.x) + 'px';
this.canvas.instance.style.top = (this.offset.y * this.windowSize.y) + 'px';
this.camera.aspect = trueWidth / trueHeight;
this.camera.updateInstance('aspect');
this.editCamera.aspect = trueWidth / trueHeight;
this.editCamera.updateInstance('aspect');
}
if (property === 'offset') {