Skip to content
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

Resize function stretch the canvas instead of resizing #73

Open
MCvin opened this issue Nov 18, 2021 · 1 comment
Open

Resize function stretch the canvas instead of resizing #73

MCvin opened this issue Nov 18, 2021 · 1 comment

Comments

@MCvin
Copy link

MCvin commented Nov 18, 2021

Hi and thanks for this very good development!

I am trying to include three-dxf in a React component and making it responsive. I managed to achieve that by deleting the previous
canvas and rendering a new one but I noticed you wrote a function resize for the renderer:

this.resize = function (width, height) {

I gave it a try since it would save some processing not having to redraw the dxf but I only see the canvas being stretch, it doesn't keep the aspect ratio and when I zoom or move, it goes back to the previous size.
It seems like it doesn't update the camera parameters, but I am really not an expert with three.js

@Leessonomy
Copy link

Leessonomy commented Nov 22, 2021

Hi. If you still need any help

You need to call instance on ThreeDxf.Viewer something like

dxfViewer.renderer.setSize(width, height);

and then update that with

dxfViewer.render(scene, camera)

Plus I think you have to write your resize method / function with eventListener and call this in your component.
You can try doing this with the resize(width, height) function of the dxfViewer. But it looks like you need to listen for the resize event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants