# raycastAll

### raycastAll

Casts a ray and returns the first object hit. Uses current mouse position if no ray specified.

#### Signature

```typescript
raycastAll(ray?: Ray): Promise<RayObjectHit | null>
```

#### Parameters

<table><thead><tr><th width="106.609375">Parameter</th><th width="130.35546875">Type</th><th width="124.78515625">Required</th><th>Description</th></tr></thead><tbody><tr><td>ray</td><td>Ray</td><td>No</td><td>Custom ray to cast. If omitted, uses current mouse cursor position.</td></tr></tbody></table>

```typescript
type Ray = {
  start: Vector3;
  direction: Vector3;
};
```

#### Returns

`Promise<RayObjectHit | null>` — Hit information or `null` if no intersection.

```typescript
type RayObjectHit = {
  id: string;        // Object UUID
  name: string;      // Object name
  position: Vector3; // World position of hit point
  normal: Vector3;   // Surface normal at hit point
  uv: Vector3;       // UV coordinates (z is always 0)
};
```

#### Usage

```javascript
// Raycast from current mouse position
const hit = await api.raycastAll();
if (hit) {
  console.log("Hit object:", hit.name);
  console.log("Hit position:", hit.position);
}

// Raycast with custom ray
const ray = {
  start: { x: 0, y: -500, z: 100 },
  direction: { x: 0, y: 1, z: 0 }
};
const hit = await api.raycastAll(ray);
```

#### Notes

* Returns **first hit object only**, not an array
* Without ray parameter, uses current mouse cursor position over iframe
* Returns `null` if ray doesn't hit any object


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.vectary.com/api/model-api/api-reference/raycastall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
