mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-16 10:32:08 -05:00
17 lines
597 B
JavaScript
17 lines
597 B
JavaScript
var CameraAspect = pc.createScript('cameraAspect');
|
|
|
|
// initialize code called once per entity
|
|
CameraAspect.prototype.initialize = function() {
|
|
this.currentOrthoHeight = this.entity.camera.orthoHeight;
|
|
};
|
|
|
|
CameraAspect.prototype.update = function(t) {
|
|
var canvas = this.app.graphicsDevice.canvas;
|
|
var aspectRatio = canvas.width / canvas.height;
|
|
var orthoHeight = pc.math.clamp(0.72 / aspectRatio, 1, 2);
|
|
if (orthoHeight !== this.currentOrthoHeight) {
|
|
this.entity.camera.orthoHeight = orthoHeight;
|
|
this.currentOrthoHeight = orthoHeight;
|
|
}
|
|
};
|