AbstractRayCaster QML Type
抽象基类,用于在 3D 场景中进行光线投射。更多
Import Statement: | import Qt3D.Render 2.9 |
In C++: | QAbstractRayCaster |
Status: | Deprecated |
属性
- filterMode : enumeration
- hits : array
- runMode : enumeration
详细说明
AbstractRayCaster 是一个抽象基类,用于将光线投射到 3D 场景中。AbstractRayCaster 不能直接实例化,而是通过其子类实现。QAbstractRayCaster 为所有光线投射器指定了运行模式和图层处理等通用属性,而将实际的光线投射细节留给了子类。
光线投射不同于拾取(使用ObjectPicker ),因为它不需要鼠标事件来触发。
默认情况下,AbstractRayCaster 的实例是禁用的。启用后,将在每一帧测试指定射线是否与对象相交。即使没有找到对象,AbstractRayCaster.hits 属性也会根据射线投射的结果进行更新。
Qt3D.Render::PickingSettings 可用于控制光线投射,例如测试哪些基元以及如何返回结果。
此外,Qt3D.Render::Layer 组件可用于控制实体或实体子图对光线投射的反应。
注意:从 AbstractRayCaster 派生的组件不应与多个实体共享。
另请参阅 Qt3D.Render::RayCaster,Qt3D.Render::ScreenRayCaster,Qt3D.Render::ObjectPicker,Qt3D.Render::PickingSettings 和Qt3D.Render::NoPicking 。
属性文档
filterMode : enumeration |
持有过滤模式,指定选择用于光线投射测试的实体。
默认值为AbstractRayCaster.AcceptMatchingLayers
。
常量 | 说明 |
---|---|
AcceptAnyMatchingLayers | 接受引用添加到此AbstractRayCaster 的一个或多个Layer 对象的实体。这是默认值 |
AcceptAllMatchingLayers | 接受引用添加到此对象的所有Layer 对象的实体。AbstractRayCaster |
DiscardAnyMatchingLayers | 丢弃引用一个或多个添加到此的Layer 对象的实体AbstractRayCaster |
DiscardAllMatchingLayers | 丢弃引用添加到此对象中的所有Layer 对象的实体AbstractRayCaster |
hits : array |
以 javascript 对象数组的形式保存上次光线投射测试的结果。对象上定义的字段如下。
{ type // enum value of RayCasterHit.HitType entity // entity that was intersected distance // distance from ray origin to intersection localIntersection.x: // coordinate of intersection in the entity's coordinate system localIntersection.y localIntersection.z worldIntersection.x // coordinate of intersection in the model's coordinate system worldIntersection.y worldIntersection.z primitiveIndex // index of the primitive (triangle, line, point) that was intersected; // (undefined if the picking mode is set to bounding volume) vertex1Index // index of the first point of the triangle or line that was intersected // (undefined if the picking mode is set to bounding volume or points) vertex2Index // index of the second point of the triangle or line that was intersected // (undefined if the picking mode is set to bounding volume or points) vertex3Index // index of the second point of the triangle that was intersected // (undefined if the picking mode is set to bounding volume, points or lines) }
请注意,即使连续几次测试都返回完全相同的结果(或空结果),每次测试都会发出更改通知。
runMode : enumeration |
保持运行模式,控制光线投射测试的执行频率。
常量 | 说明 |
---|---|
Continuous | 只要组件处于启用状态,每帧都会执行光线投射。 |
SingleShot | 如果只进行一次射线投射,则组件会自动关闭。这是默认的 |
© 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.