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 属性定义了生成实例的颜色变化范围。类型为颜色。默认值为空,即颜色为白色。
例如,设置colorModel 属性可以只选择饱和色。
另请参阅 position,rotation,scale 和customData 。
colorModel : enumeration |
该属性控制如何解释颜色范围。
实例颜色是在由from和to颜色决定的范围内逐个组件生成的。颜色模型决定了这些组件的定义方式。
常量 | 说明 |
---|---|
RandomInstancing.RGB | 根据 RGB 颜色模型,分量为红、绿、蓝和 alpha。 |
RandomInstancing.HSV | 根据HSV Color Model 颜色模型,组成部分为色相、饱和度、数值和 alpha。 |
RandomInstancing.HSL | 根据HSL Color Model ,色相、饱和度、明度和 alpha 是色彩的组成部分。 |
例如,以下颜色范围
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 |
gridSpacing : vector3d |
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 |
旋转属性定义了生成实例的旋转范围。类型为vector3d ,对应欧拉旋转向量[xRotation, yRotation, zRotation]
。默认值为空,不会应用任何旋转。
另请参阅 position,color,scale, 和customData 。
scale : InstanceRange |
缩放属性定义生成实例的缩放限制。类型为vector3d 。将InstanceRange.proportional 设置为true
可实现统一缩放。默认值为空,不会应用任何缩放。
另请参阅 position,color,rotation, scale 和customData 。
© 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.