Hi everyone,
Help me Pls about Babylonjs animation. I have a file with babylon extension. I want this file to move as animation only in X and Z positions.
BABYLON.SceneLoader.ImportMesh(
"",
"/assets/",
"file.babylon",
scene,
function (meshes) {
let marketCar = scene.getMeshByName("MarketAraba");
meshes[0].position.x = -123;
meshes[0].position.y = 0;
meshes[0].position.z = -21;
meshes[0].scaling.scaleInPlace(10);
const frameRate = 10;
const xSlide = new BABYLON.Animation("xSlide", "position.x", frameRate, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
const keyFrames = [];
keyFrames.push({
frame: 10,
value: 120
});
keyFrames.push({
frame: frameRate,
value: -160
});
keyFrames.push({
frame: 10 * frameRate,
value: 112
});
xSlide.setKeys(keyFrames);
meshes[0].animations.push(xSlide);
scene.beginAnimation(meshes[0], 0, 3 * frameRate, true);
});