I am looking to have an interactive scene that has several OBJ models that can be dragged around the scene. I have been using the code on this webpage fo starters : https://www.script-tutorials.com/webgl-with-three-js-lesson-10/
In the example given on that webpage there are several randomly located spheres that you can move with your mouse. Here the spheres are pushed into an array and event handlers are employed. For my scene I have tried to push the OBJ models into the same array, but while the spheres remain interactive my models aren’t moving. I have been using:
loadObjModel: function() {
loader.load('models/bike.obj', function(object) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.position.set(0, -10.7,-20);
var scale = 5;
child.scale.set(scale,scale,scale);
MyGymScene.scene.add(object);
MyGymScene.objects.push(object);
}
} );
},
where objects is the array. I tried pushing the model into the array before adding it to the scene but still the event handlers don’t work on it. If anyone could point out where I’m going wrong I would be so so grateful.