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();
});