fix: adjustRendererSize

This commit is contained in:
Nebel 2020-12-29 16:42:09 +09:00
parent e8d8f5bb1b
commit 025a9c511b

View file

@ -91,7 +91,8 @@ function adjustPanelSize() {
} }
} }
function adjustCanvasSize() { function adjustRendererSize() {
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = canvas.clientWidth / canvas.clientHeight; camera.aspect = canvas.clientWidth / canvas.clientHeight;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
adjustPanelSize(); adjustPanelSize();
@ -103,11 +104,10 @@ function setup() {
scene.clear(); scene.clear();
scene.add(...panels); scene.add(...panels);
camera.position.z = 1; camera.position.z = 1;
adjustCanvasSize(); adjustRendererSize();
} }
function main() { function main() {
renderer.setSize(window.innerWidth, window.innerHeight);
Object.assign(canvas.style, { width: "100%", height: "100%" }); Object.assign(canvas.style, { width: "100%", height: "100%" });
root.addEventListener("keydown", handleKeydown); root.addEventListener("keydown", handleKeydown);
root.addEventListener("touchstart", handleTouchmove, { passive: false }); root.addEventListener("touchstart", handleTouchmove, { passive: false });
@ -125,7 +125,7 @@ function main() {
} }
root.appendChild(canvas); root.appendChild(canvas);
Object.assign(root.style, { overflow: "hidden", overscrollBehavior: "none" }); Object.assign(root.style, { overflow: "hidden", overscrollBehavior: "none" });
window.addEventListener("resize", adjustCanvasSize); window.addEventListener("resize", adjustRendererSize);
setup(); setup();
} }