Skip to content

Zoom on a specific element #106

Answered by vagran
hesengineering asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, nice finding! Thanks!
I will fix it in master now. Before the next release, you can use this workaround in your code:

import * as three from "three"
...

const bounds = this.dxfViewer.GetBounds()
const origin = this.dxfViewer.GetOrigin()
const center = {x: (bounds.maxX + bounds.minX) / 2 - origin.x + 100,
                y: (bounds.maxY + bounds.minY) / 2 - origin.y + 100}
this.dxfViewer.SetView(center, 200)
//////////// Temporal workaround until fixed in SetView()
this.dxfViewer.controls.target = new three.Vector3(
   this.dxfViewer.camera.position.x, this.dxfViewer.camera.position.y, 0)
this.dxfViewer.controls.update()
///////////
this.dxfViewer.Render()

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@kuket15
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@vagran
Comment options

Answer selected by hesengineering
@kuket15
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants