As the title says, I want to use OrbitControls as Helper to set my camera.
When I’ve found correct values my idea is to copy the OrbitControls value to camera but I can’t figure it out.
Any tips?
Thank you!
As the title says, I want to use OrbitControls as Helper to set my camera.
When I’ve found correct values my idea is to copy the OrbitControls value to camera but I can’t figure it out.
Any tips?
Thank you!
I’m afraid your question is not clear. When you use OrbitControls
, the camera’s transformation is automatically updated by the controls. There is no need to manually copy values from the controls to the camera.
Hi @Mugen87
Of course you are right, I’ll try to explain me again.
I am using OrbitControls to helping me find the right position, etc for the camera.
When I am satisfied I want to get this values in order to statically set to camera and remove orbit controls but I can’t find them.
Is clearer now?
Sorry for my bad,
L.
You need two sets of data.
Both of these are Vector3 objects. Calling toArray() will return an array of [ x, y, z ].
Hi @rrrr_rrrr,
just to be clear, the OrbitControls.target will be the camera.lookAt?
@liqueflies Yes. three.js/OrbitControls.js at e1ead8c5c2eb2395942f5e7d9af7240befc5d729 · mrdoob/three.js · GitHub
If I get camera.position
value the result is ok.
I am trying to get also target and setting lookAt but unfortunately the result is not the same.
I am getting the value in requestAnimationFrame with controls.target
and copy it into the camera.lookAt(…)
Any help?
When you control your scene, it will be meaningless for you to set the lookat of the camera.
Yep I know, as I said before I want to get the camera settings with controls but don’t want to keep controls
That is, you don’t need to control your scene, but you want your camera to look in a certain direction. Is that so?
That’s correct. But to help find out correct parameter I am using orbit control and when I am satisfied about result to get values and put statically into scene camera
You don’t need to call lookAt().
To apply transformation to camera:
camera.position.set(x,y,z);
OrbitControls.target.set(x,y,z);
OrbitControls.update();
[x,y,z] are World Space coordinates.
You can use “change” event of OrbitControls
and log object’s position and target to console: Edit fiddle - JSFiddle - Code Playground
let controls = new OrbitControls(camera, renderer.domElement);
controls.addEventListener("change", event => {
console.log("target", controls.target)
console.log("position", controls.object.position);
})