-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Large screen canvas overflow #125
Comments
I tried on 2056x1329 and I can't reproduce the issue. Anyway to reproduce this without having to buy a new monitor 😄 ? Tested on Chrome, Safari and Firefox (Mac). |
Are you able to overscale your browser? As in increase it larger than your browser by dragging it outside of the bounds of the screen then scaling up again? I've narrowed this down further last night, and again this morning. MapLibre has an options value called maxCanvasSize. By default it maxes out at 4096x4096, which seems to explain the issues here. I have it working on initial load by setting an "effective DPR" in const MAX_CANVAS_SIZE = 4096;
const effectiveDpr = Math.min(
window.devicePixelRatio,
MAX_CANVAS_SIZE / Math.max(canvas.width, canvas.height)
);
// Calculate the scale factor
const scaleFactor = canvas.width / canvas.clientWidth;
const root = createRoot(canvas);
root.configure({
events,
...props,
frameloop: "never",
gl: {
context: gl,
autoClear: false,
antialias: true,
...props?.gl,
},
onCreated: (state) => {
state.gl.forceContextLoss = () => {};
// Apply the scale factor to the camera
state.camera.scale.setScalar(scaleFactor);
},
camera: {
matrixAutoUpdate: false,
near: 0,
},
size: {
width: canvas.clientWidth,
height: canvas.clientHeight,
top: canvas.offsetTop,
left: canvas.offsetLeft,
updateStyle: false,
...props?.size,
},
dpr: effectiveDpr,
}); The issues occur now only on resize - albeit I'm sure there is likely a better approach to the initialization as well. I've made attempts at implementing the same approach with the One optimization I'd like to include in my app is adaptive DPR which seems tied to this same set of configuration, but isn't working at this time. It would be extremely valuable to be able to regress the DPR of the Three.js scene when framerates drop or for particular devices. |
Quick follow up: you can actually test this very easily by adding |
If you have a solution already for this, PRs are welcomed, @essejmclean 😄. Thanks! |
Problem description:
On large screens/browser windows, the canvas and map while in NOT overlay mode "disconnect" causing models to appear to float while the map is consistently restricted to of approximately 2045x1364.
This is visible at the story here: https://rodrigohamuy.github.io/react-three-map/?story=canvas--maplibre
This is something we can recreate in our own project; however, has never an issue in when overlay mode is activated.
Can confirm the issue occurs in:
I have not been able to recreate this issue by zooming out, only by viewing in larger browser windows.
The text was updated successfully, but these errors were encountered: