I have a three js scene which adds OBJ Models via button click. In order to increase interactivity, I want to be able to rotate these objects after they are added to the scene.
Currently, I am using TransformControls when the object gets loaded:
new MTLLoader( manager ) .setPath( 'EQUIPMENT/' ) .load( mtl, function ( materials ) { materials.preload(); new OBJLoader( manager ) .setMaterials( materials ) .setPath( 'EQUIPMENT/' ) .load( obj, function ( object ) { object.scale.set(scale,scale,scale); scene.add( object ); control.attach( object ); //the transform controls scene.add(control); objects.push(object); //pushing them into an array for DragControls });
However I am left with two problems:
-
The Transform Controls only work for the most recently loaded object, which means I can’t go back and rotate an object once I’ve added a new one.
-
The Transform Controls stay at the point where the object was added (i.e. (0,0,0)), so if I drag the object to a new position and then rotate, the object rotates around the point at which it was added.
Ideally I would be able to select an object and then rotate it 90 degrees with a keyboard click while selected. If anyone would be able to guide me to a possible solution to this I’d be very grateful.
Thank You