<!--
{
  "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(origin:direction:length:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation5SceneC9pixelCast6origin9direction6lengthAA05PixelE3HitVSgs5SIMD3VySfG_AMSftYaKF"
  },
  "title" : "pixelCast(origin:direction:length:)"
}
-->

# pixelCast(origin:direction:length:)

Performs a ray cast against all the geometry in the scene for a ray of
a given origin, direction, and length.

```
@MainActor @preconcurrency func pixelCast(origin: SIMD3<Float>, direction: SIMD3<Float>, length: Float = 100) async throws -> PixelCastHit?
```

## Parameters

`origin`

The origin of the ray relative to the scene.

`direction`

The direction of the ray relative to the scene.

`length`

The length of the ray relative to the scene.

## Return Value

A `PixelCastHit`. The hit indicates where the ray, starting
at a given point and traveling in a given direction, 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)