The model which loaded from file was seperated when moving in ThreeJS?

41 Views Asked by At

I used ThreeJS to load the 3D model, but when I moved it, it did not move the whole model, it moved separately. How to fix this problem?!!!

Future < three.Object3D > loadObjWithMtl(String mtlPathFolder, String mtlNameFile, String objPathFile) async {
    var manager = three.LoadingManager();
    var mtlLoader = three_jsm.MTLLoader(manager);
    mtlLoader.setPath(mtlPathFolder);
    var materials = await mtlLoader.loadAsync(mtlNameFile);
    await materials.preload();
    var loaderObj = three_jsm.OBJLoader(null);
    loaderObj.setMaterials(materials);
    final three.Object3D result = await loaderObj.loadAsync(objPathFile);
    result.traverse((obj) {});
    return result;
}

Future < three.Object3D > createTable() async {
    tableObject = await loadObjWithMtl('assets/models/ban/', 'ban.mtl', 'assets/models/ban/ban.obj');
    tableObject.userData = {
        'draggable': true,
        'name': 'TABLE',
        'castShadow': true,
        'receiveShadow': true
    };
    return tableObject;
}
0

There are 0 best solutions below