LevelOfDetail QML Type

LevelOfDetail 提供了一种根据实体在屏幕上的大小来控制渲染实体复杂度的方法。更多

Import Statement: import Qt3D.Render 2.9
In C++: QLevelOfDetail
Inherits:

Component3D

Status: Deprecated

属性

详细描述

LevelOfDetail 可用于根据与观察者的距离或在屏幕上的大小来控制实体的表现形式。

为了提高渲染性能,可以使用较少的几何或纹理细节来渲染非常小的物体。

该组件是通过指定阈值来控制的,阈值被理解为与摄像机的距离或屏幕尺寸。

当视角发生变化时,currentIndex 属性将发生变化,以反映范围数组中的匹配值。

例如,currentIndex 属性可用于启用或禁用实体、更改EntityLoader 中的来源或材质。

LevelOfDetail 组件不可在多个实体之间共享。

import Qt3D.Core 2.0
import Qt3D.Render 2.0

Entity {
    id: root

    // Scene
    Camera { id: mainCamera }

    LevelOfDetail {
        id: lod
        camera: mainCamera
        thresholds: [20, 35, 50, 65]
        thresholdType: LevelOfDetail.DistanceToCameraThreshold
    }

    GeometryRenderer {
        id: mesh
        view: CylinderMesh {
            property var sliceValues: [20, 10, 6, 4]
            slices: sliceValues[lod.currentIndex]
        }
    }

    Entity {
        id: renderableEntity
        components: [ mesh, lod ]
    }
}

属性文档

ThresholdType : enumeration

指定如何解释阈值中的值

  • 距离摄像机阈值 实体到所选摄像机的距离
  • ProjectedScreenPixelSizeThreshold 从所选摄像机看到的实体在屏幕上投影时的大小,用屏幕空间中边界正方形边上的像素数表示。

另请参阅 Qt3DRender::QLevelOfDetail::ThresholdType


camera : Camera

保存用于计算实际距离或屏幕尺寸的摄像机 id。


currentIndex : int

范围数组中与当前摄像机距离或屏幕尺寸相匹配的索引。


thresholdType : int

指定如何解释范围值。


thresholds : QList<qreal>

以浮点数表示的范围值数组。应首先指定最详细的表示值。

如果LevelOfDetail::thresholdType 设置为LevelOfDetail.DistanceToCameraThreshold,则应按摄像机空间坐标升序指定值。

如果LevelOfDetail::thresholdType 设置为LevelOfDetail.ProjectedScreenPixelSizeThreshold,则应按屏幕空间像素降序指定值。


volumeOverride : int

指定用于评估距离或屏幕尺寸的物体。

默认值是以实体的本地原点为中心、半径为 1 的球体。这个代理体积用于计算到摄像机的距离或屏幕投影的大小。

如果该值为空,则使用实体的边界体积。必须注意的是,这个边界体永远不会失效。

另请参阅 Qt3DRender::QLevelOfDetailBoundingSphere


© 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.