RandomInstancing QML Type
生成一个随机的实例化表。更多...
| Import Statement: | import QtQuick3D.Helpers |
| Since: | Qt 6.2 |
| Inherits: |
属性
- color : InstanceRange
- colorModel : enumeration
- customData : InstanceRange
- gridSpacing : vector3d
(since 6.9) - instanceCount : int
- position : InstanceRange
- randomSeed : int
- rotation : InstanceRange
- scale : InstanceRange
详细说明
RandomInstancing 类型提供了一种简便的方法,可在定义的边界内生成大量随机实例。实例的数量由instanceCount 属性定义。边界由以下属性定义:position 、scale 、rotation 、color 以及customData 。
另请参阅 InstanceList 。
属性文档
color : InstanceRange
color 属性定义了生成的实例的颜色变化范围。其类型为 color。默认值为空,此时颜色为白色。
例如,设置colorModel 属性可仅选择饱和度较高的颜色。
另请参阅 position 、rotation 、scale 以及customData 。
colorModel : enumeration
此属性控制颜色范围的解释方式。
实例颜色是在由“起始色 ”和“结束色”确定的范围内,按组件逐个生成的。颜色模型决定了这些组件的定义方式。
| 常量 | 描述 |
|---|---|
RandomInstancing.RGB | 根据 RGB 颜色模型,这些分量分别为红色、绿色、蓝色和透明度。 |
RandomInstancing.HSV | 根据HSV Color Model ,这些分量为色相、饱和度、明度和透明度。 |
RandomInstancing.HSL | 根据HSL Color Model ,这些分量为色相、饱和度、明度和透明度。 |
例如,以下颜色范围
color: InstanceRange {
from: Qt.hsva(0, 0.1, 0.8, 1)
to: Qt.hsva(1, 0.3, 1, 1)
}在使用HSV 颜色模型时会生成全套的柔和色,但在使用RGB 颜色模型时则只会生成各种粉色调。
默认值为RandomInstancing.RGB
另请参阅 RandomInstancing::color 。
customData : InstanceRange
customData 属性定义了生成的实例的自定义数据变化范围。其类型为vector4d 。默认值为空,这将导致生成的数据为[0, 0, 0, 0] 。
另请参阅 position 、color 、rotation 以及scale 。
gridSpacing : vector3d [since 6.9]
gridSpacing 属性定义了实例之间的最小间距,以确保它们不会重叠。每个位置之间的间距至少为gridSpacing 中指定的值。
如果指定的 `gridSpacing ` 无法容纳所需的实例数量,则 `instanceCount ` 属性将被调整为能够无重叠放置的实例数量。
注意:gridSpacing 属性 仅影响实例的位置。对实例应用的旋转和缩放操作不会被间距算法考虑在内。
默认值为[0, 0, 0] ,这不会对重叠的实例施加任何限制。
该属性在 Qt 6.9 中引入。
另请参阅 position 。
instanceCount : int
instanceCount 属性指定要生成的实例数量。更改此值将重新生成整个表。
另请参阅 randomSeed 。
position : InstanceRange
position 属性定义了生成的实例的几何边界。其默认值为空,这将导致生成的位置为[0, 0, 0] 。
另请参阅 color 、rotation 、scale 以及customData 。
randomSeed : int
此属性定义了随机数生成器的种子。将其设置为与 -1 不同的值,可确保实例表在每次生成时内容保持一致。请注意,添加或修改属性可能会导致生成的表完全不同。
默认值为 -1,这会导致表格在每次生成时都获得一个新的随机值。
rotation : InstanceRange
rotation 属性定义了生成的实例的旋转范围。其类型为vector3d ,对应于欧拉旋转向量[xRotation, yRotation, zRotation] 。默认值为空,表示不进行旋转。
另请参阅 position 、color 、scale 以及customData 。
scale : InstanceRange
scale 属性定义了生成的实例的缩放范围。其类型为vector3d 。若要进行均匀缩放,请将InstanceRange.proportional 设置为true 。默认值为空,表示不进行缩放。
另请参阅 position 、color 、rotation 以及customData 。
© 2026 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.