UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

707 lines (307 loc) 8.08 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [Vector3](./server.vector3.md) ## Vector3 class Represents a 3-dimensional vector. **Signature:** ```typescript export default class Vector3 extends Float32Array implements Vector3Like ``` **Extends:** Float32Array **Implements:** [Vector3Like](./server.vector3like.md) ## Remarks All vector methods result in mutation of the vector instance. This class extends `Float32Array` to provide an efficient way to create and manipulate a 3-dimensional vector. Various convenience methods are provided for common vector operations. ## Constructors <table><thead><tr><th> Constructor </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [(constructor)(x, y, z)](./server.vector3._constructor_.md) </td><td> </td><td> Constructs a new instance of the `Vector3` class </td></tr> </tbody></table> ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [length](./server.vector3.length.md) </td><td> `readonly` </td><td> number </td><td> The length of the vector. </td></tr> <tr><td> [magnitude](./server.vector3.magnitude.md) </td><td> `readonly` </td><td> number </td><td> The magnitude of the vector. Alias for `length`<!-- -->. </td></tr> <tr><td> [squaredLength](./server.vector3.squaredlength.md) </td><td> `readonly` </td><td> number </td><td> The squared length of the vector. </td></tr> <tr><td> [squaredMagnitude](./server.vector3.squaredmagnitude.md) </td><td> `readonly` </td><td> number </td><td> The squared magnitude of the vector. Alias for `squaredLength`<!-- -->. </td></tr> <tr><td> [x](./server.vector3.x.md) </td><td> </td><td> number </td><td> The x-component of the vector. </td></tr> <tr><td> [y](./server.vector3.y.md) </td><td> </td><td> number </td><td> The y-component of the vector. </td></tr> <tr><td> [z](./server.vector3.z.md) </td><td> </td><td> number </td><td> The z-component of the vector. </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [add(vector3)](./server.vector3.add.md) </td><td> </td><td> Adds a vector to the current vector. </td></tr> <tr><td> [ceil()](./server.vector3.ceil.md) </td><td> </td><td> Rounds each component of the vector up to the nearest integer. </td></tr> <tr><td> [clone()](./server.vector3.clone.md) </td><td> </td><td> Returns a new vector with the same components as the current vector. </td></tr> <tr><td> [copy(vector3)](./server.vector3.copy.md) </td><td> </td><td> Copies the components of a vector to the current vector. </td></tr> <tr><td> [create()](./server.vector3.create.md) </td><td> `static` </td><td> Creates a new `Vector3` instance. </td></tr> <tr><td> [cross(vector3)](./server.vector3.cross.md) </td><td> </td><td> Calculates the cross product of the current vector and another vector. </td></tr> <tr><td> [distance(vector3)](./server.vector3.distance.md) </td><td> </td><td> Calculates the distance between the current vector and another vector. </td></tr> <tr><td> [divide(vector3)](./server.vector3.divide.md) </td><td> </td><td> Divides each component of the current vector by the corresponding component of another vector. </td></tr> <tr><td> [dot(vector3)](./server.vector3.dot.md) </td><td> </td><td> Returns the dot product of this vector and another vector. </td></tr> <tr><td> [equals(vector3)](./server.vector3.equals.md) </td><td> </td><td> Checks if the current vector is approximately equal to another vector. </td></tr> <tr><td> [exactEquals(vector3)](./server.vector3.exactequals.md) </td><td> </td><td> Checks if the current vector is exactly equal to another vector. </td></tr> <tr><td> [floor()](./server.vector3.floor.md) </td><td> </td><td> Rounds each component of the vector down to the nearest integer. </td></tr> <tr><td> [fromVector3Like(vector3Like)](./server.vector3.fromvector3like.md) </td><td> `static` </td><td> Creates a new `Vector3` instance from a `Vector3Like` object. </td></tr> <tr><td> [invert()](./server.vector3.invert.md) </td><td> </td><td> Inverts each component of the vector. </td></tr> <tr><td> [lerp(vector3, t)](./server.vector3.lerp.md) </td><td> </td><td> Linearly interpolates between the current vector and another vector. </td></tr> <tr><td> [max(vector3)](./server.vector3.max.md) </td><td> </td><td> Sets each component of the vector to the maximum of the current vector and another vector. </td></tr> <tr><td> [min(vector3)](./server.vector3.min.md) </td><td> </td><td> Sets each component of the vector to the minimum of the current vector and another vector. </td></tr> <tr><td> [multiply(vector3)](./server.vector3.multiply.md) </td><td> </td><td> Multiplies each component of the current vector by the corresponding component of another vector. </td></tr> <tr><td> [negate()](./server.vector3.negate.md) </td><td> </td><td> Negates each component of the vector. </td></tr> <tr><td> [normalize()](./server.vector3.normalize.md) </td><td> </td><td> Normalizes the vector. </td></tr> <tr><td> [randomize(scale)](./server.vector3.randomize.md) </td><td> </td><td> Randomizes the vector. </td></tr> <tr><td> [rotateX(vector3, angle)](./server.vector3.rotatex.md) </td><td> </td><td> Rotates the vector around the x-axis. </td></tr> <tr><td> [rotateY(vector3, angle)](./server.vector3.rotatey.md) </td><td> </td><td> Rotates the vector around the y-axis. </td></tr> <tr><td> [rotateZ(vector3, angle)](./server.vector3.rotatez.md) </td><td> </td><td> Rotates the vector around the z-axis. </td></tr> <tr><td> [round()](./server.vector3.round.md) </td><td> </td><td> Rounds each component of the vector to the nearest integer. </td></tr> <tr><td> [scale(scale)](./server.vector3.scale.md) </td><td> </td><td> Scales each component of the vector by a scalar value. </td></tr> <tr><td> [scaleAndAdd(vector3, scale)](./server.vector3.scaleandadd.md) </td><td> </td><td> Adds 2 vectors together after scaling the provided vector by a scalar value. </td></tr> <tr><td> [subtract(vector3)](./server.vector3.subtract.md) </td><td> </td><td> Subtracts a vector from the current vector. </td></tr> <tr><td> [toString()](./server.vector3.tostring.md) </td><td> </td><td> Returns a string representation of the vector in x,y,z format. </td></tr> <tr><td> [transformMatrix3(matrix3)](./server.vector3.transformmatrix3.md) </td><td> </td><td> Transforms the vector by a matrix3. </td></tr> <tr><td> [transformMatrix4(matrix4)](./server.vector3.transformmatrix4.md) </td><td> </td><td> Transforms the vector by a matrix4. </td></tr> <tr><td> [transformQuaternion(quaternion)](./server.vector3.transformquaternion.md) </td><td> </td><td> Transforms the vector by a quaternion. </td></tr> <tr><td> [zero()](./server.vector3.zero.md) </td><td> </td><td> Sets each component of the vector to zero. </td></tr> </tbody></table>