Hey I am sorry but I am just so conufsed and I cannot find any resources on the internet that fix my issue, so Iâm going to go more into depth on my issue and hopefully you can help me out.
var currentDesk = new THREE.Object3D();
var currentMonitor = new THREE.Object3D();
var currentKeyboard = new THREE.Object3D();
var currentMousepad = new THREE.Object3D();
var currentMouse = new THREE.Object3D();
var objectsArray = [currentDesk, currentMonitor, currentKeyboard, currentMousepad, currentMouse];
dragControls = new THREE.DragControls(objectsArray, camera, renderer.domElement);
This is how Iâve set up my objects array that gets passed into DragControls, my app is a furniture app so it consists of swapping out furniture. That means that the currentDesk gets changed after the dragControls has been declared, possibly that is an issue? Nevertheless the code above shows how Iâm setting it up.
Iâm not gonna paste the full furniture swapping code, but the part where I change the objectsArray looks like this
objectsArray[indexDictionary[objectType]] = gltf.scenes[0].children[0].parent;
I have used console.log for the gltf.scenes part of the code above to figure out that it is giving me the scene value I want. For the keyboard I am using the console logs this for the object it is being set to, which is the plane if I am not mistaken.
I also realize it has a parent which I have tried setting it equal to as well, when I set it equal to this parent I got an error that says âUncaught TypeError: Cannot read property âlayersâ of nullâ whenever the mouse moved over the canvas (thousands of errors really fast you would imagine). One possible thing that I could be doing wrong here is that the parent is of type Scene, which is not an Object3D or a Group.
It is also important Iâm using a loader like this
loader.load(coordinateDictionaryArr[4], function (gltf) {
The coordinateDictionaryArr[4] just references a filepath, it is a path to a glb file and that is 100% I know that for a fact so donât worry about that being a possible error.
I could also be doing something wrong in how I add the object to the scene, for now I am just using scene.add(gltf.scene); when adding to the scene, maybe I have to add the object directly?
If you want to take a look at the Github (https://github.com/cooperlappenbusch/3DDeskSetup) for loading, the loading function is selectNew3DObject(objectType, objectName, event) , I have tried making groups and I have tried setting Groups / Object3Ds to almost every combination of scenes or children arrays and I have to be missing something here.
It is also important to notice that the current version of the code doesnât break, but it the objects donât move correctly like in the first gif I posted.
Thank you for reading this post, hopefully Iâve provided enough information for you to point me in the right direction.