Hi,
I am using the v3d.SimplePreloader template to load a cube. Inside runCode() I tried the following code to animate (simple translation) the cube. The animation is not playing. Refer the attached blender file.
function runCode(app) {
let cubeObject = app.scene.getObjectByName("Cube");
const mixer = new v3d.AnimationMixer(cubeObject);
const action = v3d.SceneUtils.getAnimationActionByName(app, 'CubeAction');
if (action) {
// Set the action to play only once
action.setLoop(v3d.LoopOnce);
// Play the animation
action.play();
}
function update() {
requestAnimationFrame(update);
const delta = app.clock.getDelta();
mixer.update(delta);
// Render the scene
app.renderer.render(app.scene, app.camera);
}
// Start the animation update loop
update();
}
-
This topic was modified 1 year, 5 months ago by ps.