Reputation: 3963
I want the orbitcontrols to use a selected object as the new target to "move around". I found a center/target attribute, but I'm not sure how to set it to an object I selected.
I tried this:
var controls = this.controls = new THREE.EditorControls(camera, container.dom);
this.orbitControls = new THREE.OrbitControls( camera );
this.orbitControls.damping = 0.5;
this.orbitControls.addEventListener( 'change', SceneManager.animate );
var controls = this.controls = new THREE.OrbitControls(camera, container.dom);
onObjectselected(function(o){
controls.center.fromArray([o.position.x, o.position.y, o.position.z]);
});
controls.addEventListener('change', function () {
thisView.transformControls.update();
thisView.orbitControls.update();
SignalHub.signals.cameraChanged.dispatch(camera);
});
but I don't get any results. I used the threejs editor as a code base.
Upvotes: 0
Views: 2867
Reputation: 3963
well nevermind, i don't want to delete this, so I'll let it up.
I somehow thought the controls would manage the other stuff, but I just had to add the following to the objectSelected callback:
onObjectselected(function(o){
//controls.center.fromArray([o.position.x, o.position.y, o.position.z]);
thisView.orbitControls.center.fromArray([o.position.x, o.position.y, o.position.z]);
});
Upvotes: 1