KITASENJU DESIGN BLOG

memo, html, javascript, unity

正方形canvasを画面中心に

let ww:number = window.innerWidth;
let hh:number = window.innerHeight;

        let dom = this.renderer.domElement;
        dom.style.position="absolute";
        let stgW:number = 0;
        if(ww>hh){
            stgW=hh;
            dom.style.top="0px";
            dom.style.left = (ww/2-hh/2)+"px";
        }else{
            stgW=ww;
            dom.style.top = (hh/2-ww/2)+"px";
            dom.style.left = "0px";
        }

        this.oCamera.left = -stgW*0.5;
        this.oCamera.right = stgW*0.5;
        this.oCamera.top = stgW*0.5;
        this.oCamera.bottom = -stgW*0.5;
        this.oCamera.updateProjectionMatrix();

        this.renderer.setSize(stgW, stgW);

"FOOTER"