用于在 3D 场景中,投射光线的抽象基类。 更多...
import 语句: | import Qt3D.Render 2.5 |
实例化: | QAbstractRayCaster |
AbstractRayCaster is an abstract base class for casting rays into a 3d scene. AbstractRayCaster can not be directly instantiated, but rather through its subclasses. QAbstractRayCaster specifies common properties for all ray casters, such as run mode and layer handling, while leaving the actual ray casting details to the subclasses.
Ray castings differs from picking (using ObjectPicker ) in that it does not require mouse events to trigger.
By default, the instances of AbstractRayCaster are disabled. When enabled, the specified ray will be tested for intersecting objects at every frame. The AbstractRayCaster.hits property will be updated with the results of the ray casting, even if no objects are found.
The Qt3D.Render::PickingSettings can be used to control the ray casting, such as which primitives are tested and how the results are returned.
Furthermore, Qt3D.Render::Layer components can be used to control how entities, or entity sub-graphs, react to ray casting.
Note: components derived from AbstractRayCaster should not be shared amount multiple entities.
另请参阅 Qt3D.Render::RayCaster , Qt3D.Render::ScreenRayCaster , Qt3D.Render::ObjectPicker , Qt3D.Render::PickingSettings ,和 Qt3D.Render::NoPicking .
filterMode : enumeration |
Holds the filter mode specifying the entities to select for ray casting tests.
默认值为
AbstractRayCaster.AcceptMatchingLayers
.
常量 | 描述 |
---|---|
AcceptAnyMatchingLayers
|
Accept entities that reference one or more 层 objects added to this AbstractRayCaster . This is the default |
AcceptAllMatchingLayers
|
Accept entities that reference all the 层 objects added to this AbstractRayCaster |
DiscardAnyMatchingLayers
|
Discard entities that reference one or more 层 objects added to this AbstractRayCaster |
DiscardAllMatchingLayers
|
Discard entities that reference all 层 objects added to this AbstractRayCaster |
[read-only] hits : array |
Holds the results of last ray casting test as an array of javascript objects. The fields defined on the objects are defined below.
{ 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) }
Note that even if successive tests return the exact same results (or empty results), a change notification will be emitted at every test.
runMode : enumeration |
Holds the run mode controlling how often ray casting tests are performed.
常量 | 描述 |
---|---|
Continuous
|
Ray casting is performed at every frame as long as the component is enabled. |
SingleShot
|
Ray casting is done once then the component disables itself. This is the default |