2

Was wondering if it's possible to translate, rotate, scale a model after it has been loaded to the scene. Also im looking a better way to use the loaded, since I have multiple models that I want to add in my program, but I do not want to call `loaded.load(...); every time.

Here is what I use:

var loader = new THREE.GLTFLoader();

loader.load( 'models/model_environment/scene.gltf', 
    function ( gltf ) {

        cube_Geometry = new THREE.BoxGeometry(10,10,10);
        cube_Material = new THREE.MeshNormalMaterial();
        cube_Mesh = new THREE.Mesh(cube_Geometry, cube_Material);
        cube_Mesh.position.set(0,5,0);
        canvas_Scene.add(cube_Mesh);
        canvas_Scene.add(gltf.scene);
        modelsLoaded = true;
    }, 
    undefined, 
    function ( error ) {
        console.error( error );
    } 
);

Notice that the model that has been loaded is below 0 on Y Axis (Ground):

enter image description here

Loizos Vasileiou
  • 674
  • 10
  • 37
  • Do I have to change something within the .bin and/or .gltf files? Never worked with those before... – Loizos Vasileiou Jan 31 '19 at 12:10
  • 1
    Where you add `gltf.scene` to the scene, if you first declare that as a variable, you can use the position, rotation,scale api. `let model = gltf.scene; model.position.y = 5; ...`. If you wanted granular control over each mesh in the gltf model, you would need to traverse through gltf.scene and define each model and manipulate as you wish. As for loading multiple models, you will need to call loader.load recursively, to load each model. The THREE.LoadingManager may help you manage it. – danlong Jan 31 '19 at 13:15
  • Great. Thanks for your answer. I'll let you know if it works for me. – Loizos Vasileiou Jan 31 '19 at 14:03
  • Kind of in a rush with uni thesis. Might get back to you after a year – Loizos Vasileiou Feb 01 '19 at 03:10

0 Answers0