Vector3
Vector3 is used to represent 3D vectors and points. It is used internally by the editor to pass 3D positions and directions, and also includes functions for performing common vector operations.
构造方法
Vector3.new ( x : number? , y : number? , z : number? ) |
| Creates a new Vector3 object with the specified x, y, and z components. |
成员变量
Vector3.x : number |
| X Component |
Vector3.y : number |
| Y Component |
Vector3.z : number |
| Z Component |
Vector3.minChannel : number |
| (Read Only) The smallest component value in the vector. |
Vector3.negative : Vector3 |
| (Read-only) The opposite of the vector. |
Vector3.maxChannel : number |
| (Read-only) The maximum component value in the vector. |
Vector3.magnitude : number |
| (Read Only) The length of the vector. |
Vector3.sqrMagnitude : number |
| (Read Only) The square magnitude of the current vector. |
Vector3.inverse : Vector3 |
| (Read-only) The reciprocal of the vector. |
Vector3.normalized : Vector3 |
| (Read Only) The normalized vector of the current vector. |
Vector3.abs : Vector3 |
| (Read-only) The result of negating the current vector. |
Vector3.almostZero : boolean |
| (Read-only) Determines if the vector is close to the zero vector. |
静态变量
Vector3.zero : Vector3 |
| The shorthand form of Vector3(0, 0, 0). (Read-only) |
Vector3.right : Vector3 |
| (Read Only) The shorthand form of Vector3(1, 0, 0). |
Vector3.one : Vector3 |
| (Read-only) The shorthand form of Vector3(1, 1, 1). |
Vector3.down : Vector3 |
| (Read-only) Abbreviated form of Vector3(0, -1, 0). |
Vector3.up : Vector3 |
| (Read-only) The shorthand form of Vector3(0, 1, 0). |
Vector3.left : Vector3 |
| The shorthand form of Vector3(-1, 0, 0). |
Vector3.forward : Vector3 |
| A shorthand for Vector3(0, 0, 1) which is a read-only property. |
Vector3.back : Vector3 |
| (Read-only) Abbreviated form of Vector3(0, 0, -1). |
Vector3.infinity : Vector3 |
| Positive infinity, shorthand for Vector3(Infinity, Infinity, Infinity). Read-only. |
成员方法
Vector3.SetValues ( x : number , y : number , z : number ) : void |
| Set the x, y, and z components of the vector. |
Vector3.Scale ( scale : Vector3 ) : void |
| Scales a 3D vector. |
Vector3.Negative ( ) : void |
| Get the opposite of the current vector. |
Vector3.Inverse ( ) : void |
| Get the reciprocal of the current vector. |
Vector3.toString ( ) : string |
| Returns the formatted string of this vector. |
Vector3.Normalize ( ) : void |
| Normalize a vector. |
Vector3.CopyFrom ( from : Vector3 ) : void |
| Changes the values of the individual components of the vector to the specified vector. |
Vector3.Get ( index : number ) : number |
| Get the x, y, and z components of the current Vector3. |
Vector3.Set ( index : number , value : number ) : void |
| Set the x, y, and z components of the vector based on the index. |
Vector3.Add ( rhs : number|Vector3 ) : Vector3 |
| Adds the calling vector to the input parameter vector. |
Vector3.Sub ( rhs : number|Vector3 ) : Vector3 |
| Subtracts the calling vector by the input parameter vector. |
Vector3.Mul ( rhs : number|Vector3 ) : Vector3 |
| Multiply this vector by a specified value. |
Vector3.Div ( rhs : number|Vector3 ) : Vector3 |
| Divides this vector by a specified value. |
Vector3.AddAssign ( rhs : number|Vector3 ) : void |
| Add to self, adds the vector with the parameter vector and assigns the result to the calling vector. |
Vector3.SubAssign ( rhs : number|Vector3 ) : void |
| Subtracts the calling vector by the input vector or number and assigns the result to the calling vector. |
Vector3.MulAssign ( rhs : number|Vector3 ) : void |
| Multiply this vector by a specified value and assign the result to itself. |
Vector3.DivAssign ( rhs : number|Vector3 ) : void |
| Divides this vector by a specified value and assigns the result to itself. |
Vector3.EqualsTo ( other : Vector3 ) : boolean |
| Determines whether the current Vector3 is equal to the target Vector3. |
静态方法
Vector3.Clone ( val : Vector3 ) : Vector3 |
| Copy a vector. |
Vector3.Dot ( lhs : Vector3 , rhs : Vector3 ) : number |
| Calculates the dot product between two vectors. |
Vector3.Lerp ( lhs : Vector3 , rhs : Vector3 , t : number ) : Vector3 |
| Performs a linear interpolation between vector lhs and vector rhs using t. |
Vector3.LerpUnclamped ( lhs : Vector3 , rhs : Vector3 , t : number ) : Vector3 |
| Performs a linear interpolation between vector lhs and vector rhs using parameter t. |
Vector3.Min ( lhs : Vector3 , rhs : Vector3 ) : Vector3 |
| Returns a vector composed of the minimum components of two vectors. |
Vector3.Cross ( lhs : Vector3 , rhs : Vector3 ) : Vector3 |
| Calculates the cross product of two vectors. |
Vector3.Distance ( lhs : Vector3 , rhs : Vector3 ) : number |
| Calculates the straight-line distance between two vectors. |
Vector3.Max ( lhs : Vector3 , rhs : Vector3 ) : Vector3 |
| Returns a vector composed of the maximum components of two vectors. |
Vector3.Angle ( from : Vector3 , to : Vector3 ) : number |
| Calculate the angle between two vectors. |
Vector3.MoveTowards ( source : Vector3 , target : Vector3 , max_delta_dis : number ) : Vector3 |
| Moves a game object from its current position to a target position along a straight line. |
Vector3.RotateTowards ( source : Vector3 , target : Vector3 , max_delta_radians : number , max_delta_mag : number ) : Vector3 |
| Rotates a game object from its current direction to a target direction. |
Vector3.EqualsTo ( lhs : Vector3 , rhs : Vector3 ) : boolean |
| Check if two Vector3 objects are equal. |
