Skip to Content

Swim strokes

Five swimmers switch between breaststroke, backstroke, crawl, treading water and floating.

Loading the take.

Each person is a chain of typed actions from @automovie/motions. This is what an agent writes for the scene; Composing motion explains the parts.

import type { IAutoMovieMotionHumanBody, IAutoMovieMotionHumanPerformance } from "@automovie/interface";
import { HumanChain, HumanObject, HumanPerformance, HumanSport } from "@automovie/motions";
import * as archetypes from "@automovie/archetypes";

const water = archetypes.createPoolWater({ width: 7.5, length: 13 });
const waterAt = { at: { x: 1.2, y: 1.1, z: 0.5 }, yaw: 0 };
const deck_south_1 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_south_1At = { at: { x: -1.3, y: 1.4000000000000001, z: -6 }, yaw: 0 };
const deck_south_2 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_south_2At = { at: { x: 1.2, y: 1.4000000000000001, z: -6 }, yaw: 0 };
const deck_south_3 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_south_3At = { at: { x: 3.7, y: 1.4000000000000001, z: -6 }, yaw: 0 };
const deck_north_1 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_north_1At = { at: { x: -1.3, y: 1.4000000000000001, z: 7 }, yaw: 180 };
const deck_north_2 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_north_2At = { at: { x: 1.2, y: 1.4000000000000001, z: 7 }, yaw: 180 };
const deck_north_3 = archetypes.createPoolEdge({ width: 2.5, freeboard: 0.3, kind: "deckEdge" });
const deck_north_3At = { at: { x: 3.7, y: 1.4000000000000001, z: 7 }, yaw: 180 };

// hed: body f1, at (-1.2, -4.5) m, facing 0°, trained
const hed = HumanChain.subject("hed")
  .registered("breaststroke", { cycles: 6, water: 1.1 })
  .registered("treadWater", { cycles: 3, water: 1.1 })
  .registered("backstroke", { cycles: 3, water: 1.1 });

// ivo: body m1, at (0, 4.5) m, facing 0°, trained
const ivo = HumanChain.subject("ivo")
  .registered("backstroke", { cycles: 6, water: 1.1 })
  .registered("treadWater", { cycles: 2, water: 1.1 })
  .registered("frontCrawl", { cycles: 3, water: 1.1 });

// jul: body f2, at (1.2, -4.5) m, facing 0°, trained
const jul = HumanChain.subject("jul")
  .registered("treadWater", { cycles: 2, water: 1.1 })
  .registered("floating", { cycles: 3, water: 1.1 })
  .registered("treadWater", { cycles: 2, water: 1.1 })
  .registered("breaststroke", { cycles: 4, water: 1.1 });

// kip: body m2, at (2.4, -4.5) m, facing 0°, trained
const kip = HumanChain.subject("kip")
  .registered("frontCrawl", { cycles: 6, water: 1.1 })
  .registered("treadWater", { cycles: 2, water: 1.1 })
  .registered("backstroke", { cycles: 3, water: 1.1 });

// lum: body f1, at (3.6, -4.5) m, facing 0°, trained
const lum = HumanChain.subject("lum")
  .registered("treadWater", { cycles: 3, water: 1.1 })
  .registered("frontCrawl", { cycles: 5, water: 1.1 })
  .registered("treadWater", { cycles: 5, water: 1.1 });

const scene = hed.with(ivo, jul, kip, lum);

// The lexicon's laws this scene's rows perform, registered with the performance.
const laws = [HumanSport.breaststroke, HumanSport.treadWater, HumanSport.backstroke, HumanSport.frontCrawl, HumanSport.floating];

const props = [
  HumanObject.prop("water", water, waterAt),
  HumanObject.prop("deck-south-1", deck_south_1, deck_south_1At),
  HumanObject.prop("deck-south-2", deck_south_2, deck_south_2At),
  HumanObject.prop("deck-south-3", deck_south_3, deck_south_3At),
  HumanObject.prop("deck-north-1", deck_north_1, deck_north_1At),
  HumanObject.prop("deck-north-2", deck_north_2, deck_north_2At),
  HumanObject.prop("deck-north-3", deck_north_3, deck_north_3At),
];

// Each body id's motion body, prepared from the site's measures.
declare const bodies: Record<string, IAutoMovieMotionHumanBody>;

const input: IAutoMovieMotionHumanPerformance.IInput = {
  seed: "swim-strokes",
  performers: [
    { subject: "hed", body: bodies["f1"]!, at: { x: -1.2, y: 0, z: -4.5 }, yaw: 0, proficiency: { level: "trained" } },
    { subject: "ivo", body: bodies["m1"]!, at: { x: 0, y: 0, z: 4.5 }, yaw: 0, proficiency: { level: "trained" } },
    { subject: "jul", body: bodies["f2"]!, at: { x: 1.2, y: 0, z: -4.5 }, yaw: 0, proficiency: { level: "trained" } },
    { subject: "kip", body: bodies["m2"]!, at: { x: 2.4, y: 0, z: -4.5 }, yaw: 0, proficiency: { level: "trained" } },
    { subject: "lum", body: bodies["f1"]!, at: { x: 3.6, y: 0, z: -4.5 }, yaw: 0, proficiency: { level: "trained" } },
  ],
  composition: scene.node,
  props,
  laws,
};
const performance = new HumanPerformance(input);