---
title: "pixelCast(from:to:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/scene/pixelcast(from:to:)"
---

# pixelCast(from:to:)

Performs a ray cast against all the geometry in the scene for a ray between two end points.

## Declaration

```swift
@MainActor @preconcurrency func pixelCast(from startPosition: SIMD3<Float>, to endPosition: SIMD3<Float>) async throws -> PixelCastHit?
```

## Parameters

- `startPosition`: The start position of the ray relative to the scene.
- `endPosition`: The end position of the ray relative to the scene.

## Return Value

Return Value A PixelCastHit. The hit indicates where the ray, starting at startPosition and ending at endPosition, hit a particular entity in the scene.

## Discussion

Discussion The method ignores entities that lack a ModelComponent with a valid mesh.

## See Also

### Detecting intersections

- [raycast(origin:direction:length:query:mask:relativeTo:)](realitykit/scene/raycast(origin:direction:length:query:mask:relativeto:).md)
- [raycast(from:to:query:mask:relativeTo:)](realitykit/scene/raycast(from:to:query:mask:relativeto:).md)
- [convexCast(convexShape:fromPosition:fromOrientation:toPosition:toOrientation:query:mask:relativeTo:)](realitykit/scene/convexcast(convexshape:fromposition:fromorientation:toposition:toorientation:query:mask:relativeto:).md)
- [pixelCast(origin:direction:length:)](realitykit/scene/pixelcast(origin:direction:length:).md)
