Skip to Content

Driving a nail

A carpenter sets a nail with two taps, drives it with seven blows and lays the hammer down.

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, HumanGestureRows, HumanObject, HumanPerformance, HumanToolRows, HumanUpperRows } from "@automovie/motions";
import * as archetypes from "@automovie/archetypes";

const bench = archetypes.createTable({ kind: "counter" });
const benchAt = { at: { x: 0, y: 0, z: 0.65 }, yaw: 180 };
const hammer = archetypes.createTool({ kind: "hammer" });
const hammerAt = { position: { x: -0.18, y: 0.914, z: 0.42 }, rotation: { x: 0.7071067811865476, y: 0, z: 0, w: 0.7071067811865476 } };

// pat: body f1, at (0, 0.12) m, facing 0°, trained
const pat = HumanChain.subject("pat")
  .act("pickUp", {
      prop: "hammer",
      handle: "grip",
      hand: "right",
      use: { tip: "face", line: "square" },
    })
  .registered("toolHammer", {
      prop: "hammer",
      hand: "right",
      on: {
        kind: "point",
        at: { x: -0.1, y: 0.914, z: 0.4 },
        frame: "world",
      },
      cycles: 2,
    })
  .act("look", {
      target: {
        kind: "point",
        at: { x: -0.1, y: 0.914, z: 0.4 },
        frame: "world",
      },
      seconds: 0.8,
    })
  .registered("toolHammer", {
      prop: "hammer",
      hand: "right",
      on: {
        kind: "point",
        at: { x: -0.1, y: 0.914, z: 0.4 },
        frame: "world",
      },
      cycles: 7,
    })
  .registered("rubOn", {
      target: {
        kind: "point",
        at: { x: -0.1, y: 0.914, z: 0.4 },
        frame: "world",
        normal: { x: 0, y: 1, z: 0 },
      },
      side: "left",
    })
  .registered("toolHammer", {
      prop: "hammer",
      hand: "right",
      on: {
        kind: "point",
        at: { x: -0.1, y: 0.914, z: 0.4 },
        frame: "world",
      },
      cycles: 2,
    })
  .act("putDown", { prop: "hammer", at: { x: -0.18, y: 0.914, z: 0.42 } })
  .registered("gestureRubHands", {});

const scene = pat;

// The lexicon's laws this scene's rows perform, registered with the performance.
const laws = [HumanToolRows.toolHammer, HumanUpperRows.rubOn, HumanGestureRows.gestureRubHands];

const props = [
  HumanObject.prop("bench", bench, benchAt),
  HumanObject.prop("hammer", hammer, hammerAt),
];

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

const input: IAutoMovieMotionHumanPerformance.IInput = {
  seed: "upper-hammer",
  performers: [
    { subject: "pat", body: bodies["f1"]!, at: { x: 0, y: 0, z: 0.12 }, yaw: 0, proficiency: { level: "trained" } },
  ],
  composition: scene.node,
  props,
  laws,
};
const performance = new HumanPerformance(input);