> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-ko/sdk7/3d/special-types.md).

# 특수 유형

Vector, Quaternion 등을 포함해 어떤 특수 유형이 있는지 알아봅니다.

## Vector3

Decentraland는 *vector3*  데이터를 사용해 경로, 공간상의 점, 방향을 나타냅니다. 벡터는 회전 방향을 정의할 때도 사용할 수 있으며, *쿼터니언*을 더 쉽게 사용할 수 있는 대안입니다. Vector3 객체에는 다음 각 축의 숫자 값이 포함됩니다. *x*, *y*, *z* 축.

```ts
const myVector: Vector3 = { x: 8, y: 1, z: 8 }
```

&#x20;`Vector3`  네임스페이스에는 대부분의 벡터 수학 연산을 직접 처리하지 않아도 되도록 호출할 수 있는 유용한 메서드가 여러 개 포함되어 있습니다. Vector3.를 입력하면 `Vector3.` VS Studio에 사용할 수 있는 모든 함수가 드롭다운으로 표시됩니다.

다음은 벡터의 몇 가지 기본 연산에 대한 구문을 보여 주는 코드입니다.

```ts
// 벡터 객체 생성
let myVector = Vector3.create(3, 1, 5)

// 벡터 객체를 생성하는 다른 구문
let myOtherVector: Vector3 = { x: 8, y: 1, z: 8 }

// 값 중 하나를 수정합니다
myVector.x = 5

// Vector3 네임스페이스의 함수를 호출합니다.
// 다음 함수는 모두 매개변수로 Vector3 객체를 전달해야 합니다.

let normalizedVector = Vector3.normalize(myVector)

let distance = Vector3.distance(myVector, myOtherVector)

let midPoint = Vector3.lerp(myVector, myOtherVector, 0.5)
```

Vector3 객체는 여러 컴포넌트의 필드에서 자주 필요합니다. 예를 들어, `Transform` 컴포넌트에는 `Vector3` 값이 포함됩니다 *위치* 및 *스케일* 에 해당하는 엔터티의 값입니다.

다음을 만들려면 [사용자 지정 컴포넌트](https://docs.decentraland.org/creator/content-creator-ko/sdk7/architecture/custom-components.md) Vector3 값이 필요한 매개변수의 타입은 다음과 같이 설정합니다. `Schemas.Vector3`.

{% hint style="warning" %}
**📔 참고**: `Vector3` 다음을 통해 가져와야 합니다.

> `import { Vector3 } from "@dcl/sdk/math"`

자세한 내용은 [가져오기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/getting-started/coding-scenes.md#imports) 에서 쉽게 처리하는 방법을 확인하세요.
{% endhint %}

### 방향 벡터를 간편하게 작성하는 방법

일반 벡터를 정의할 때 사용할 수 있는 간편한 방법은 다음과 같습니다.

* `Vector3.Zero()` 을 반환합니다. *(0, 0, 0)*
* `Vector3.Up()` 반환합니다 *(0, 1, 0)*
* `Vector3.Down()` 반환합니다 *(0, -1, 0)*
* `Vector3.Left()` 반환합니다 *(-1, 0, 0)*
* `Vector3.Right()` 반환합니다 *(1, 0, 0)*
* `Vector3.Forward()` 반환합니다 *(0, 0, 1)*
* `Vector3.Backward()` 를 반환합니다 *(0, 0, -1)*

## 쿼터니언

쿼터니언은 Transform 컴포넌트의 회전 정보를 저장하는 데 사용됩니다. 쿼터니언은 -1과 1 사이의 숫자 네 개로 구성됩니다. *x*, *y*, *z*, *w*.

```ts
const myQuaternion: Quaternion = { x: 0, y: 0, z: 0, w: 1 }
```

쿼터니언은 다음과 다릅니다 [*오일러* 각도](https://en.wikipedia.org/wiki/Euler_angles), 더 일반적인 *x*, *y* 및 *z* 대부분의 사람에게 익숙한 0부터 360까지의 숫자를 사용하는 표기법입니다. 엔진은 모든 회전을 쿼터니언으로 표현하므로, 가능한 한 오일러 각도로 변환하거나 오일러 각도에서 변환하는 계산은 피하는 것이 좋습니다.

The `Quaternion` 네임스페이스에는 여러 수학 연산을 직접 처리하지 않아도 되도록 호출할 수 있는 유용한 메서드가 여럿 있습니다.  `Quaternion.`을 입력하면 VS Studio에서 사용할 수 있는 모든 함수가 드롭다운으로 표시됩니다.

아래는 쿼터니언의 몇 가지 기본 연산에 사용하는 구문을 보여 주는 코드입니다.

```ts
// 쿼터니언 객체 생성
let myQuaternion = Quaternion.create(0, 0, 0, 1)

// 값 중 하나를 수정합니다
myQuaternion.x = 1

// 쿼터니언 네임스페이스의 함수 호출
let midPoint = Quaternion.slerp(myQuaternion1, myQuaternion2, 0.5)

// 한 방향을 향하던 상태에서 다른 방향을 향하도록 회전하는 데 필요한 값을 가져옵니다,
// 두 개의 방향 Vector3 값 전달
let rotation = Quaternion.fromToRotation(Vector3.Forward(), Vector3.Up())
```

오일러 각도로 생각하는 것이 훨씬 쉽기 때문에 SDK에는 쿼터니언과 오일러 각도를 서로 변환하는 함수가 포함되어 있습니다.

{% hint style="info" %}
**💡 팁**: 매 틱마다 실행되는 시스템 내 반복 로직에서 이러한 변환을 실행하지 마세요. 비용이 많이 들 수 있습니다. 이러한 변환은 새 엔티티의 회전을 설정하는 것과 같은 일회성 작업에 주로 유용합니다.
{% endhint %}

```ts
// 오일러 각도에서 쿼터니언으로
let myQuaternion = Quaternion.fromEulerDegrees(90, 0, 0)

// 쿼터니언에서 오일러 각도로
let myEuler = Quaternion.toEulerAngles(myQuaternion)
```

컴포넌트의 필드에는 쿼터니언 객체가 필요한 경우가 많습니다. 예를 들어, `Transform` 컴포넌트에는 `Quaternion` 엔티티의 회전 값이 포함됩니다.

다음과 같은 [사용자 지정 컴포넌트](https://docs.decentraland.org/creator/content-creator-ko/sdk7/architecture/custom-components.md) 를 만들려면 Quaternion 값이 필요한 매개변수의 유형을 `Schemas.Quaternion`.

{% hint style="warning" %}
**📔 참고**: `Quaternion` 은 다음을 통해 가져와야 합니다.

> `import { Quaternion } from "@dcl/sdk/math"`

자세한 내용은 [가져오기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/getting-started/coding-scenes.md#imports) 에서 쉽게 처리하는 방법을 확인하세요.
{% endhint %}

## 스칼라

스칼라는 숫자에 불과합니다. 따라서 데이터를 저장하기 위해 `Scalar` 객체를 인스턴스화하는 것은 별 의미가 없습니다. 숫자로도 똑같이 할 수 있기 때문입니다. 하지만 `Scalar` 네임스페이스의 함수는 숫자에 사용할 수 있는 여러 유용한 함수를 제공합니다( *Vector3* 네임스페이스의 함수와 비슷합니다).

```ts
// Scalar 클래스의 함수 호출
let random = Scalar.randomRange(1, 100)

let midPoint = Scalar.lerp(number1, number2, 0.5)

let clampedValue = Scalar.clamp(myInput, 0, 100)
```

{% hint style="warning" %}
**📔 참고**: `Scalar` 은 다음을 통해 가져와야 합니다.

> `import { Scalar } from "@dcl/sdk/math"`

자세한 내용은 [가져오기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/getting-started/coding-scenes.md#imports) 에서 쉽게 처리하는 방법을 확인하세요.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-ko/sdk7/3d/special-types.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
