Answer the question
In order to leave comments, you need to log in
How to Zoom objects in the scene and not Gizmo (as in 3DS Max) in Three.js?
Gizmo is a control that binds to a specific reference point on an object. For Gizmo you can drag, rotate and scale an object (direct analogy with 3DSM, Maya and the like)
There are two scenes on one there are objects (cubes, balls ...) on the other Gizmo objects (more precisely, one more and is not required).
How to make objects in both scenes behave as usual when changing the position (transfer, rotation, Zoom...) of the camera, with the only difference that the approach and removal of the camera did not affect the objects of the second scene, i.e. Gizmo objects ?
In other words, so that the Gizmo doesn't Scale or Zoom
--------------------
updateWorld: function(){
this.orbitCameraControl.update(); // обновляем контроллер камеры(OrbitControls.js)
this.renderer.clear();
this.renderer.render(this.sceneObject, this.camera); // рендерим сцену с объектами
this.renderer.clear(false, true, false);
this.renderer.render(this.sceneGizmo, this.camera); // рендерим сцену с Gizmo
}
Answer the question
In order to leave comments, you need to log in
Helped with solving the problem - @trushka
solution from @trushka :
do the same with one camera and bare Gizmo depending on the distance to it. Well, let's say
var base=1000 is the distance to the camera at which Gizmo does not grin.
Then when the camera moves, if s is the distance to the viewpoint:
Gizmo.scale.x=Gizmo.scale.y=Gizmo.scale.z=s/ base;
var v1 = this.camera.position.clone();
var v2 = Gizmo.position.clone();
var len = v1.sub(v2).length();
var v = new THREE.Vector3(1,1,1);
v.multiplyScalar(len/1039); // 1039 - расстояние от камеры до точки просмотра
Gizmo.applyMatrix(obj.mLocal.clone().scale(v));
var cameraPos = this.world.camera.position.clone();
var gizmoPos = E.select.mLocal.getPosition().clone();
cameraPos.sub( ( cameraPos.clone().sub( gizmoPos ) ).normalize().multiplyScalar( 1000 ) );
So you need to do two cameras, initially with the same coordinates, then initialize your OrbitControl for each, then set noZoom=true for the one that controls the 2nd camera, and then render each scene with its own camera
like:
control1= new THREE.OrbitControls( camera1 );
control2 = new THREE.OrbitControls( camera2);
control2.noZoom=true;
....................................
updateWorld: function(){
control1.update(); control2.update(); // обновляем контроллеры камер(OrbitControls.js)
this.renderer.clear();
this.renderer.render(this.sceneObject, this.camera1); // рендерим сцену с объектами
this.renderer.clear(false, true, false);
this.renderer.render(this.sceneGizmo, this.camera2); // рендерим сцену с Gizmo
}
In theory, it should work)))
@trushka , everything seems to be well selected
object, Gizmo appears:
doing Zoom, everything is fine:
but now when moving the viewpoint there are distortions:
distortions also occur when zooming from certain camera positions:
it didn’t work (((maybe I did something wrong?
did it like this:
var v1 = this.camera.position.clone();
var v2 = this.orbitControl.target.clone();
var len = v1.sub(v2).length();
var v = new THREE.Vector3(1,1,1);
v.multiplyScalar(len/1039); // 1039 - расстояние от камеры до точки просмотра
Gizmo.applyMatrix(obj.mLocal.clone().scale(v));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question