Not getting transform controls position correctly for every selected object


After selecting an object through raycaster in the scene,I want to show transform controls(gizmo) on that object. But I am getting gizmo somewhere else, how to know pivot point of object inside the scene and set the same pivot point to transform controls. Kindly suggest me something related.

let transformControls = new TransformControls( camera, renderer.domElement );

transformControls.setMode( ‘rotate’ );
scene.add( transformControls );