dkushner / three-editor-controls

Modularized editor controls for three.js.
MIT License
6 stars 0 forks source link

Does not scroll to position. Only to center. #1

Open etiennepinchon opened 7 years ago

etiennepinchon commented 7 years ago

Hello! I love your script, it is used by the inspectror of Aframe.io. Only problem, scrolling does not zoom on a specific target but rather on the vector3 [0, 0, 0].

Any way to fix it?

dkushner commented 7 years ago

Hey @etiennepinchon, sorry for the late response. I will look into this immediately. Glad to know you're finding it useful!

dkushner commented 7 years ago

So after having taken a look at the behaviour, it looks like the camera will in fact zoom relative to the "center" variable. While this does automatically start at the origin, if I pan around by right clicking and dragging, it moves the center around as expected and will zoom into this new location. If you'd like the camera to center itself on a particular object, use something like this:

const controls = new THREE.EditorControls(camera, renderer.domElement)
controls.focus(target, true)

In this case, target is any scene object that has defined geometry and the second boolean argument tells the controls to frame the object, meaning it will adjust the zoom distance and position to make that object roughly fill the screen.

Let me know if this solves your issue!

etiennepinchon commented 7 years ago

Hey! Thank you for taking the time to look at it!

Yes I ended up keeping controls.focus ;) I wish it could behave like most 3D editors (like Cinema 4D) where you point at a location with your mouse and the zoom will actually focus on the 3D points calculated by the mouse position .. somehow haha! It would feels more flexible.

What do you think?

dkushner commented 7 years ago

@etiennepinchon: Yeah, I know exactly what you're describing. Definitely makes navigation a bit more intuitive in most cases. Let me look into doing this when I get a moment.

By the way, I absolutely love that site! Excellent work bringing VR to the web in an accessible way.

etiennepinchon commented 7 years ago

Thank you!

Today I was working on a big 3D object (a 3D scene exported to AFrame) and the problem it me again! Since the only focus point is the center, it was hard to reach/zoom on some parts of that object without the need to add other objects to zoom at those specific locations.

Anyway.. haha hope this problem will find its solution!