LookAtNode QML Type

自动保持指向另一个节点的辅助节点。更多

Import Statement: import QtQuick3D.Helpers
Since: Qt 6.4
Inherits:

Node

属性

详细说明

此辅助器实现了一个节点的自动旋转,使其始终指向一个指定的节点。旋转只发生在 X 轴和 Y 轴上。

例如,以下代码段使圆柱体始终指向立方体。

View3D {
    anchors.fill: parent
    camera: camera

    PerspectiveCamera {
        id: camera
    }

    DirectionalLight {}

    LookAtNode {
        target: cube

        Model {
            id: cylinder
            source: "#Cone"
            eulerRotation.x: -90
            materials: [
                PrincipledMaterial {}
            ]
        }
    }

    Model {
        id: cube
        position: Qt.vector3d(300, 300, 0);
        source: "#Cube"
        materials: [ PrincipledMaterial {} ]
    }
}

属性文档

target : Node

指定要查看的目标节点。默认值为null


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.