Qt Quick 3D Physics - Cannon Example | Qt Quick 3D Physics | Qt 6.12.0
Description: Demonstrates how to spawn physical objects.
Keywords: auto-generated

- Qt 6.12
- Qt Quick 3D Physics
- Qt Quick 3D Physics Examples and Tutorials
- Qt Quick 3D Physics - Cannon Example
- Qt Quick 3D Physics | Commercial or GPLv3

# Qt Quick 3D Physics - Cannon Example

     // Copyright (C) 2022 The Qt Company Ltd.
     // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
     import QtQuick
     import QtQuick3D
     import QtQuick3D.Physics

     DynamicRigidBody {
         id: body
         property bool inArea: false
         property real sphereDiameter: 2
         massMode: DynamicRigidBody.CustomDensity
         density: 10

         Model {
             source: "#Sphere"
             scale: Qt.vector3d(1, 1, 1).times(body.sphereDiameter * 0.01)
             materials: PrincipledMaterial {
                 baseColor: "yellow"
             }
         }

         physicsMaterial: PhysicsMaterial {
             restitution: 0.6
             dynamicFriction: 0.5
             staticFriction: 0.5
         }

         collisionShapes: SphereShape {
             diameter: body.sphereDiameter
         }
     }