All examples · Meshes and 3D

Flatwood

What this example shows

A creature rigged and animated by hand, arriving as a single .glb with eleven bones and four movements in it. Three of them go round for ever. The fourth does not, and that is what this example is about. Click the game, then press 1, 2 or 3 to change gait, space to drop it.

A looping movement never needs to report anything: it is always in the middle of itself. A movement that finishes does. setLoop(false) says this one runs to its end and stops there, and onEnd is told once when it arrives, in time to start whatever comes next: a hit, a death, a door opening.

The end is not the only moment worth knowing about. events marks instants inside a movement and onEvent is told as the movement passes them: here, the two instants in each gait where a foot meets the ground. A mark is passed once per lap whatever the frame rate, so a frame long enough to step clean over one still counts it.

Starting