Skip to main content

Adding joints

A joint (a mate in the code) connects two connectors and leaves some motion free. The hinge needs two: a revolute joint between the leaves' knuckle connectors, which leaves rotation about the pin axis free, and a fastened joint that locks the pin into the fixed leaf.

The revolute joint

  1. Click Revolute on the toolbar. The mate dialog opens with Type set to Revolute and two empty slots, Connector A and Connector B. While a slot is armed, every part's connectors show in the viewport as small triads.

    Revolute mate dialog

  2. Click the fixed leaf's knuckle triad (at the front end of its middle knuckle). The slot fills with the connector's name and the dialog arms Connector B.

  3. Click the swing leaf's knuckle triad. The joint is solved immediately as a preview: the swing leaf jumps onto the pin axis.

  4. The preview shows the leaf folded flat over the fixed leaf. By default a joint places the two frames face to face, Z against Z, like two faces pressed together; that is the closed hinge. Tick Flip to align the frames instead, and the leaf swings out flat beside the fixed one.

  5. Tick Limits and enter 0 and 180: the hinge swings from open flat to fully closed.

  6. Click Apply. The joint appears in the Joints panel as revolute · Fixed leaf · Swing leaf · 0 – 180°.

The fastened joint

  1. Click Fastened. Pick the fixed leaf's pin connector (the front end of the tube) as A and the pin's shaft connector as B.
  2. The preview shows the pin pointing out of the hinge; tick Flip so the shaft runs into the knuckles. Apply.
The assembled hinge
The code behind it
hinge.assembly.js
import { insert, mate } from 'fluidcad/core';
import { fixedLeaf } from './hinge-leaf-fixed.part.js';
import { swingLeaf } from './hinge-leaf-swing.part.js';
import { pin } from './hinge-pin.part.js';

const fixed = insert(fixedLeaf).grounded();
const swing = insert(swingLeaf).translate(-45, 0, 25);
const hingePin = insert(pin).translate(0, -30, 40);

// Revolute dialog: the two 'knuckle' connectors share the pin axis and the
// swing leaf turns about it. Flip keeps the leaves side by side (without it
// the frames face each other and the leaf lands folded over); the limits
// stop the swing at flat (0°) and fully closed (180°).
mate('revolute', fixed.connectors.knuckle, swing.connectors.knuckle).flip().limits(0, 180);

// Fastened dialog: the pin's head frame is locked to the tube's end frame,
// flipped so the shaft runs into the knuckles rather than away from them.
mate('fastened', fixed.connectors.pin, hingePin.connectors.shaft).flip();

Each dialog wrote one mate() statement. The first argument names the joint type, the next two are the connectors, and the chained methods are the dialog's options: .flip(), .limits(min, max), and (unused here) .rotate(deg) and .offset(x, y, z). The first connector is the driver: options are read in its frame.

Trying the joint

Drag the swing leaf in the viewport (this works in the embedded viewer above too). It rotates about the pin and stops at the limits; the fixed leaf and the pin stay put. Click the joint's row in the Joints panel to highlight both connectors. The row's menu (right-click) offers Edit mate…, Suppress, Delete, Show in source and Animate…, which is the next step.

Next: Applying animation to a joint.