Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I add a light to my Scene3D?
Forum Updated to NodeBB v4.3 + New Features

How can I add a light to my Scene3D?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3d 2.0qml
3 Posts 3 Posters 1.8k Views 2 Watching
  • 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.
  • ArasA Offline
    ArasA Offline
    Aras
    wrote on last edited by
    #1

    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?

    kshegunovK 1 Reply Last reply
    0
    • ArasA Aras

      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?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      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
      0
      • NeoswN Offline
        NeoswN Offline
        Neosw
        wrote on last edited by Neosw
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved