Revision control

Copy as Markdown

// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example joints
\ingroup quick3dphysics-examples
\title Qt Quick 3D Physics - Joints Example
\examplecategory {3D}
\brief Demonstrates using joints in a physics scene.
\image joints-example.png
This example demonstrates using the joints available in Quick 3D Physics.
Most joint types (\l{DistanceJoint}, \l{PrismaticJoint}, \l{RevoluteJoint},
and \l{SphericalJoint}) inherit from \l{FlexibleJoint} to support soft constraints
via stiffness and damping. Additionally, \l{D6Joint} provides fully configurable
6-degrees-of-freedom constraints, while \l{FixedJoint} completely locks all degrees
of freedom.
The scene is a typical scene with a PhysicsWorld, a View3D with a
PerspectiveCamera and a DirectionalLight:
\snippet joints/main.qml full
There is a StaticRigidBody with a PlaneShape to act as the floor. There are
several custom QML objects (Rope, SoftRope, Spring, Prismatic, and Revolute)
demonstrating different joint configurations.
\snippet joints/main.qml joints
The Rope object is a series of capsules and a sphere that are connected
with \l{SphericalJoint}{spherical joints} for the capsules and a
\l{FixedJoint}{fixed joint} for the sphere.
\snippet joints/Rope.qml full
The SoftRope object demonstrates how \l{FlexibleJoint}{flexible joints} use
stiffness and damping properties to create spring-like soft connections.
\snippet joints/SoftRope.qml full
The Spring object shows how to use \l{D6Joint} to constrain motion across 6 degrees
of freedom with custom linear and angular spring parameters.
\snippet joints/Spring.qml full
The Prismatic object consists of two bars locked in a
\l{PrismaticJoint}{prismatic joint} along the x-axis of both of them.
With this joint the smaller rod can move freely along this x-axis until it
reaches its \l{PrismaticJoint::upperLimit}{upper} and
\l{PrismaticJoint::lowerLimit}{lower} constraint limit.
\snippet joints/Prismatic.qml full
The Revolute object consists of two bars rotated by 90 degrees and locked
in a \l{RevoluteJoint}{revolute joint}.
\snippet joints/Revolute.qml full
Going back to the main scene there is a FrameAnimation object that rotates
the kinematic \l{PrismaticJoint}{prismatic} and \l{RevoluteJoint}{revolute}
joints.
\snippet joints/main.qml animation
With all these moving parts we can see how the different joints interact in
a physics scene.
*/