You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Size of scene, we can fixed (unit px)constsize={width: 800,height: 600,};// Size of scene, we can get full view (unit 100%)constsizeOfViewport={width: window.innerWidth,height: window.innerHeight,};
1 số vấn đề cần quan tâm: padding-margin & Position
Handle resize: Khi render lần đầu, scence fixed kích thước và khi resize browser, hàm render không được chạy lại => lỗi
window.addEventListener("resize",()=>{// console.log("window resizing");// When resizing:// 1. We update the width & height of scencesize.width=window.innerWidth;size.height=window.innerHeight;// 2. Update the camera ratiocamera.aspect=size.width/size.height;camera.updateProjectionMatrix();// 3. Update rendererrenderer.setSize(size.width,size.height);});