Merge branch 'webgl-footer'

This commit is contained in:
Tanner Collin 2021-03-20 22:47:54 +00:00
commit 6a541a8544

View File

@ -45,6 +45,11 @@ export const scene = ({ ref }) => {
scene.add(ship.mesh); scene.add(ship.mesh);
ships.push(ship); ships.push(ship);
window.addEventListener('resize', () => {
camera.updateProjectionMatrix();
renderer.setSize(ref.current.clientWidth, ref.current.clientHeight);
});
const animate = () => { const animate = () => {
const deltaTime = 0.075; const deltaTime = 0.075;
t += deltaTime; t += deltaTime;
@ -73,16 +78,7 @@ export const scene = ({ ref }) => {
ships = ships.filter((s) => !s.kill); ships = ships.filter((s) => !s.kill);
window.addEventListener('resize', onWindowResize);
function onWindowResize() {
console.log(ref.current.clientWidth, ref.current.clientHeight)
camera.updateProjectionMatrix();
renderer.setSize(ref.current.clientWidth, ref.current.clientHeight);
}
requestAnimationFrame(animate); requestAnimationFrame(animate);
renderer.render(scene, camera); renderer.render(scene, camera);
}; };