Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How can I add a light to my Scene3D?

    General and Desktop
    qt3d 2.0 qml
    3
    3
    1194
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Aras
      Aras last edited by

      I looked in the docs for Light, but there are no details there. Does anyone know how I could add a light to my Scene3D and what parameters are available for it?

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @Aras last edited by

        Hi,
        It's from QAbstractLight's decendatns:

        http://doc.qt.io/qt-5/qml-qt3d-render-directionallight.html
        http://doc.qt.io/qt-5/qml-qt3d-render-pointlight.html
        http://doc.qt.io/qt-5/qml-qt3d-render-spotlight.html

        My advice is to follow the C++ docs where the class hierarchy is clearly visible. It's not straightforward with the QML docs.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 0
        • Neosw
          Neosw last edited by Neosw

          Hi,
          You can add a light with the following code (for example):

          Entity {
            id: root
            ...
            Entity {
                id: lightEntity
                components: [
          	  DirectionalLight{
          	      color: Qt.rgba(1, 1, 1, 1.0)
          	      intensity: 0,5
          	      enabled: true
          	  },
          	  Transform{
          		position: Qt.vector3d(5,5,5)
          	    }
                 ]
            }
          }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post