Skip to content

Kuesa Lights QML Example

Demonstrates the use of the Kuesa API to maniplulate light sources from a glTF2 file.

qt3d-lights-example.png

Loading a glTF2 File and Select the Camera

Kuesa provides the [GLTF2Importer ] element, for loading glTF2 files. This element exists within the [View3D ] element and can be used by setting the [source ] property. The same element also provides the [camera ] property to specify by name what camera to use from the glTF file.

1
2
        source: "file:" + _assetsDir + "/models/lights/lights.gltf"
        camera: "Camera"

Filename: lights-qt3d/main.qml

Manipulate the Lights

Each light is referenced by using an Asset element, with added properties that one wants to adjust. Depending on the light source type, some properties might not exist, hence adjusting them will have no effect.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
            Kuesa.Asset {
                id: lightAsset

                collection: scene3D.lights
                name: modelData

                property real intensity
                property color color

                property real range

                property real innerConeAngle
                property real outerConeAngle
            }

Filename: lights-qt3d/main.qml

Then each of the properties can be referenced and manipulated by GUI elements, for example with a Slider:

1
2
3
4
5
6
7
8
                Slider {
                    id: sliderIntensity

                    from: 0
                    to: 100
                    value: lightAsset.intensity
                    onValueChanged: lightAsset.intensity = value
                }

Filename: lights-qt3d/main.qml


Updated on 2023-07-03 at 11:02:17 +0000