> For the complete documentation index, see [llms.txt](https://help.vectary.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.vectary.com/api/model-api/api-reference/raycastobject.md).

# raycastObject

### raycastObject

Casts a ray against a specific object. Uses current mouse position if no ray specified.

#### Signature

```typescript
raycastObject(name: string, ray?: Ray): Promise<RayObjectHit | null>
```

#### Parameters

<table><thead><tr><th width="155.421875">Parameter</th><th width="145.87890625">Type</th><th width="148.48828125">Required</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>string</td><td>Yes</td><td>Object name to test</td></tr><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 specific object from mouse position
const hit = await api.raycastObject("Chair");
if (hit) {
  console.log("Hit at:", 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.raycastObject("Chair", ray);
```

#### Notes

* Tests only the specified object, ignores others
* Ray parameter is **optional** (uses mouse position if omitted)
* Returns `null` if ray doesn't hit the object
* Useful for detecting clicks on specific objects


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
