<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Scene/pixelCast(from:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation5SceneC9pixelCast4from2toAA05PixelE3HitVSgs5SIMD3VySfG_ALtYaKF"
  },
  "title" : "pixelCast(from:to:)"
}
-->

# pixelCast(from:to:)

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

```
@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

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

## Discussion

The method ignores entities that lack a [`ModelComponent`](/documentation/RealityKit/ModelComponent) with a valid
mesh.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)