# How to move a glb mesh

**URL:** <https://forum.babylonjs.com/t/how-to-move-a-glb-mesh/4291>\
**Category:** Questions\
**Created:** [July 4, 2019, 5:53pm UTC](https://forum.babylonjs.com/t/how-to-move-a-glb-mesh/4291 "2019-07-04T17:53:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amir\_N](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/amir_n/32/1900_2.png) [@Amir\_N](https://forum.babylonjs.com/u/Amir_N)\
**Post date:** [July 4, 2019, 5:53pm UTC](https://forum.babylonjs.com/t/how-to-move-a-glb-mesh/4291/1 "2019-07-04T17:53:16Z")

</div>

Hi, I’m trying to import a glb file in the scene then I would like to move it 1 unit every 1 second.  
But I don’t have access to this mesh, and I get the undefined error.

This is my code:

```
        var cup;

        var createScene = function(){

        var scene = new BABYLON.Scene(engine);
        var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 0, new BABYLON.Vector3(0, 
        0, 0), scene);

        BABYLON.SceneLoader.ImportMesh("", "model/", "108.glb", scene, function (meshes) {
            scene.createDefaultCameraOrLight(true, true, true);
            cup = meshes[0];
        });

        scene.createDefaultLight();
        console.log(cup);
        scene.clearColor = new BABYLON.Color4(0,0,0,0.0000000000000001);
        scene.ambientColor = new BABYLON.Color3(1, 1, 1);

        return scene;

    };
    //even fom here I don't have access
    console.log(scene.meshes[0].position);
    var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
    var scene = createScene();

    engine.runRenderLoop(function () {
        scene.render();
    });
```

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 4, 2019, 6:24pm UTC](https://forum.babylonjs.com/t/how-to-move-a-glb-mesh/4291/2 "2019-07-04T18:24:58Z")

</div>

Welcome to the forum,

you need to do it in the callback exactly like you would so in a c++ lambdas, except you do not have to define what to capture.

You could for instance the line after cup = meshes[0] put the following code:

scene.beforeRender = () =\> {  
cup.position.y += 0.001; // for example  
}

You could else globally wait for cup being available before starting to move it.

Another cool way would be to use ImportMeshAsync and await it to be sur that cup is available the method after.

---

<div class="post-metadata">

**Author:** ![Amir\_N](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/amir_n/32/1900_2.png) [@Amir\_N](https://forum.babylonjs.com/u/Amir_N)\
**Post date:** [July 4, 2019, 6:31pm UTC](https://forum.babylonjs.com/t/how-to-move-a-glb-mesh/4291/3 "2019-07-04T18:31:33Z")

</div>

Thanks for prompt reply. It works! 😊
