Up to date

This page is up to date for Godot `4.2`. If you still find outdated information, please open an issue.

# Vector3¶

## 属性¶

 float x `0.0` float y `0.0` float z `0.0`

## 构造函数¶

 Vector3 Vector3 ( ) Vector3 Vector3 ( Vector3 from ) Vector3 Vector3 ( Vector3i from ) Vector3 Vector3 ( float x, float y, float z )

## 方法¶

 Vector3 abs ( ) const float angle_to ( Vector3 to ) const Vector3 bezier_derivative ( Vector3 control_1, Vector3 control_2, Vector3 end, float t ) const Vector3 bezier_interpolate ( Vector3 control_1, Vector3 control_2, Vector3 end, float t ) const Vector3 bounce ( Vector3 n ) const Vector3 ceil ( ) const Vector3 clamp ( Vector3 min, Vector3 max ) const Vector3 cross ( Vector3 with ) const Vector3 cubic_interpolate ( Vector3 b, Vector3 pre_a, Vector3 post_b, float weight ) const Vector3 cubic_interpolate_in_time ( Vector3 b, Vector3 pre_a, Vector3 post_b, float weight, float b_t, float pre_a_t, float post_b_t ) const Vector3 direction_to ( Vector3 to ) const float distance_squared_to ( Vector3 to ) const float distance_to ( Vector3 to ) const float dot ( Vector3 with ) const Vector3 floor ( ) const Vector3 inverse ( ) const bool is_equal_approx ( Vector3 to ) const bool is_finite ( ) const bool is_normalized ( ) const bool is_zero_approx ( ) const float length ( ) const float length_squared ( ) const Vector3 lerp ( Vector3 to, float weight ) const Vector3 limit_length ( float length=1.0 ) const int max_axis_index ( ) const int min_axis_index ( ) const Vector3 move_toward ( Vector3 to, float delta ) const Vector3 normalized ( ) const Vector3 octahedron_decode ( Vector2 uv ) static Vector2 octahedron_encode ( ) const Basis outer ( Vector3 with ) const Vector3 posmod ( float mod ) const Vector3 posmodv ( Vector3 modv ) const Vector3 project ( Vector3 b ) const Vector3 reflect ( Vector3 n ) const Vector3 rotated ( Vector3 axis, float angle ) const Vector3 round ( ) const Vector3 sign ( ) const float signed_angle_to ( Vector3 to, Vector3 axis ) const Vector3 slerp ( Vector3 to, float weight ) const Vector3 slide ( Vector3 n ) const Vector3 snapped ( Vector3 step ) const

## 操作符¶

 bool operator != ( Vector3 right ) Vector3 operator * ( Basis right ) Vector3 operator * ( Quaternion right ) Vector3 operator * ( Transform3D right ) Vector3 operator * ( Vector3 right ) Vector3 operator * ( float right ) Vector3 operator * ( int right ) Vector3 operator + ( Vector3 right ) Vector3 operator - ( Vector3 right ) Vector3 operator / ( Vector3 right ) Vector3 operator / ( float right ) Vector3 operator / ( int right ) bool operator < ( Vector3 right ) bool operator <= ( Vector3 right ) bool operator == ( Vector3 right ) bool operator > ( Vector3 right ) bool operator >= ( Vector3 right ) float operator [] ( int index ) Vector3 Vector3

## 常量¶

AXIS_X = `0`

X 轴的枚举值。由 max_axis_indexmin_axis_index 返回。

AXIS_Y = `1`

Y 轴的枚举值。由 max_axis_indexmin_axis_index 返回。

AXIS_Z = `2`

Z 轴的枚举值。由 max_axis_indexmin_axis_index 返回。

ZERO = `Vector3(0, 0, 0)`

ONE = `Vector3(1, 1, 1)`

INF = `Vector3(inf, inf, inf)`

LEFT = `Vector3(-1, 0, 0)`

RIGHT = `Vector3(1, 0, 0)`

UP = `Vector3(0, 1, 0)`

DOWN = `Vector3(0, -1, 0)`

FORWARD = `Vector3(0, 0, -1)`

BACK = `Vector3(0, 0, 1)`

MODEL_LEFT = `Vector3(1, 0, 0)`

MODEL_RIGHT = `Vector3(-1, 0, 0)`

MODEL_TOP = `Vector3(0, 1, 0)`

MODEL_BOTTOM = `Vector3(0, -1, 0)`

MODEL_FRONT = `Vector3(0, 0, 1)`

MODEL_REAR = `Vector3(0, 0, -1)`

## 属性说明¶

float x = `0.0`

float y = `0.0`

float z = `0.0`

## 构造函数说明¶

Vector3 Vector3 ( )

Vector3 Vector3 ( Vector3 from )

Vector3 Vector3 ( Vector3i from )

Vector3i 构造新的 Vector3

Vector3 Vector3 ( float x, float y, float z )

## 方法说明¶

Vector3 abs ( ) const

float angle_to ( Vector3 to ) const

Vector3 bezier_derivative ( Vector3 control_1, Vector3 control_2, Vector3 end, float t ) const

Vector3 bezier_interpolate ( Vector3 control_1, Vector3 control_2, Vector3 end, float t ) const

Vector3 bounce ( Vector3 n ) const

Vector3 ceil ( ) const

Vector3 clamp ( Vector3 min, Vector3 max ) const

Vector3 cross ( Vector3 with ) const

Vector3 cubic_interpolate ( Vector3 b, Vector3 pre_a, Vector3 post_b, float weight ) const

Vector3 cubic_interpolate_in_time ( Vector3 b, Vector3 pre_a, Vector3 post_b, float weight, float b_t, float pre_a_t, float post_b_t ) const

Vector3 direction_to ( Vector3 to ) const

float distance_squared_to ( Vector3 to ) const

float distance_to ( Vector3 to ) const

float dot ( Vector3 with ) const

Vector3 floor ( ) const

Vector3 inverse ( ) const

bool is_equal_approx ( Vector3 to ) const

bool is_finite ( ) const

bool is_normalized ( ) const

bool is_zero_approx ( ) const

float length ( ) const

float length_squared ( ) const

Vector3 lerp ( Vector3 to, float weight ) const

Vector3 limit_length ( float length=1.0 ) const

int max_axis_index ( ) const

int min_axis_index ( ) const

Vector3 move_toward ( Vector3 to, float delta ) const

Vector3 normalized ( ) const

Vector3 octahedron_decode ( Vector2 uv ) static

Vector2 octahedron_encode ( ) const

Basis outer ( Vector3 with ) const

Vector3 posmod ( float mod ) const

Vector3 posmodv ( Vector3 modv ) const

Vector3 project ( Vector3 b ) const

Vector3 reflect ( Vector3 n ) const

Vector3 rotated ( Vector3 axis, float angle ) const

Vector3 round ( ) const

Vector3 sign ( ) const

float signed_angle_to ( Vector3 to, Vector3 axis ) const

Vector3 slerp ( Vector3 to, float weight ) const

Vector3 slide ( Vector3 n ) const

Vector3 snapped ( Vector3 step ) const

## 操作符说明¶

bool operator != ( Vector3 right )

Vector3 operator * ( Basis right )

`vector * basis` 性当于 `basis.transposed() * vector`。请参阅 Basis.transposed

Vector3 operator * ( Quaternion right )

Vector3 与给定的 Quaternion 进行逆向变换（相乘）。

`vector * quaternion` 相当于 `quaternion.inverse() * vector`。请参阅 Quaternion.inverse

Vector3 operator * ( Transform3D right )

`vector * transform` 相当于 `transform.inverse() * vector`。请参阅 Transform3D.inverse

Vector3 operator * ( Vector3 right )

```print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # 输出 "(30, 80, 150)"
```

Vector3 operator * ( float right )

Vector3 operator * ( int right )

Vector3 operator + ( Vector3 right )

```print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # 输出 "(13, 24, 35)"
```

Vector3 operator - ( Vector3 right )

```print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # 输出 "(7, 16, 25)"
```

Vector3 operator / ( Vector3 right )

```print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # 输出 "(5, 4, 10)"
```

Vector3 operator / ( float right )

Vector3 operator / ( int right )

bool operator < ( Vector3 right )

bool operator <= ( Vector3 right )

bool operator == ( Vector3 right )

bool operator > ( Vector3 right )

bool operator >= ( Vector3 right )

float operator [] ( int index )

Vector3 operator unary+ ( )

Vector3 operator unary- ( )