Skip to main content

Animation

So far we have seen how we can set the shape and geometry of 3D objects based on IoT parameters. In this example, we use the built-in animation capabilities to create a rotating windmill on a 3D map. The direction of the windmill and rotation speed are based on real-time weather parameters.

Solids

The axis of the rotor is created by a cylinder and a sphere, which are rotated 90 degrees along the X-axis. The blade is created by a cone with a bottom diameter of 2 and a top diameter of 0.5. The cone is scaled to simulate a flat rotor blade and it has a variable rotation defined by parameter angle.

The windmill pole is created by a cone and the rotor is attached to the top, together with a box and a flashlight. The rotor is placed inside an animation block which rotates the part along the Y-axis in a number of seconds. The parameter seconds is calculated from the parameter windspeed and the parameter direction is used to rotate the whole part.

Topics

We can now link a topic to control the animation defined in the GLTF model created by the solid. The animations are named sequentially animation_1, animation_2, etc. The topic windmill.A01.B.animation contains the name of the animation and the sibling topic speed defines the speed multiplier for the animation. For example, if 0.5 the animation of the rotor rotates at 50% of the speed defined in the solid.

windmill.A01.A.geometry = Windmill.gltf
windmill.A01.B.geometry = Windmill.gltf
windmill.A01.B.animation = animation_1
windmill.A01.B.speed = 2
windmill.A01.B.rotation = 0,0,90

Instead of setting the speed manually, you can also enter a JavaScript expression that sets the speed depending on the actual wind speed obtained via a connector to OpenWeather. For example, the expression below sets the speed of the rotor to 10% of the wind speed with a maximum of 5.

windmill.A01.B.speed = Math.max(weather.amsterdam.windspeed/10, 5)

Model

A model is created by including the topics for the dike and the two windmills. If you click on the windmill you can edit the value of the topics to control the direction and speed of the rotor.

The chart below shows how the topics and subtopics are linked to the nodes in the GLTF model.

Explanation

A GLTF model contains a scene with a 3D object and a list of animations. Each animation has a name and associated data such as a list of times and transformations (keyframes) and a parameter timeScale. In this example, we set the timeScale variable of the animation with a name defined in the .animation. The timeScale value is set by defining a sibling topic speed. When the speed is 1 the animation runs at the original speed.