The Babylon.js framework comes with a collection of distinct actions. You'll find actions that can play a sound, stop a sound, interpolate a property of an object, set a value of an object property, and so on.
The only entities that can handle ActionManager
are the scene and the meshes in the scene. Each Babylon.js mesh has its own action manager reference. To enable actions on a mesh, just create a new reference to the mesh, as follows:
myMesh.actionManager = new BABYLON.ActionManager(scene);
The ActionManager
constructor takes only the scene as a parameter.
Let's create your first action in a scene composed of a box and a plane. The action must change the box's position on the y axis from 0
to 6
when the user left-clicks on the box. The only thing to do is to call the .registerAction
function on ActionManager
of the box, as shown in the following:
myMesh.actionManager = new BABYLON.ActionManager(scene); myMesh.actionManager.registerAction...