Vector3
Two example Vector3 objects used to set the position (right) and the orientation (left) of a part .
The Vector3 data type is composed of three numerical components: X, Y, and Z. Vector3 is typically used to represent a position , size , direction, or orientation. Roblox uses Vector3 to represent vectors within a Cartesian coordinate system and orientations in form of Euler angles . Roblox also rarely uses Vector3 as a color (DataModelMesh.VertexColor ).
In Lua , Vector3 is also known as vector in type
function and is treated as a value type unlike other Roblox types.[1]
Usage [ ]
Vector3, along with CFrame , is used by properties in the Roblox API to determine the location and orientation of objects.
Unlike CFrame, two Vector3s are used by the Roblox API to represent both positional and rotational data. Vector3 uses Euler angles to determine the orientation, which can encounter gimbal lock . CFrame uses a rotation matrix which avoids this problem.
Data type [ ]
Constructors [ ]
Constructor
Description
Vector3 . new (
number x ,
number y ,
number z )
Creates a Vector3 positioned at x , y , z
.
Vector3 . fromNormalId (
Enum.NormalId normalId )
orVector3 . FromNormalId (
Enum.NormalId normalId )
Creates a Vector3 that is equivalent to the direction of normalId
.
Vector3 . fromAxis (
Enum.Axis axis )
orVector3 . FromAxis (
Enum.Axis axis )
Creates a Vector3 for axis
.
Properties [ ]
Property
Description
Vector3 Vector3 . zero
A Vector3 whose X, Y, and Z components are 0, 0, 0 respectively. Note that this is a constant and must be accessed through the Vector3 global, not a Vector3 object itself.
Vector3 Vector3 . one
A Vector3 whose X, Y, and Z axes are 1, 1, 1 respectively. Note that this is a constant and must be accessed through the Vector3 global, not a Vector3 object itself.
Vector3 Vector3 . xAxis
A Vector3 whose X, Y, and Z axes are 1, 0, 0 respectively. Note that this is a constant and must be accessed through the Vector3 global, not a Vector3 object itself.
Vector3 Vector3 . yAxis
A Vector3 whose X, Y, and Z axes are 0, 1, 0 respectively. Note that this is a constant and must be accessed through the Vector3 global, not a Vector3 object itself.
Vector3 Vector3 . zAxis
A Vector3 whose X, Y, and Z axes are 0, 0, 1 respectively. Note that this is a constant and must be accessed through the Vector3 global, not a Vector3 object itself.
number Vector3 . X
The X-coordinate of the Vector3.
number Vector3 . Y
The Y-coordinate of the Vector3.
number Vector3 . Z
The Z-coordinate of the Vector3.
number Vector3 . Magnitude
The length of the Vector3.
Vector3 Vector3 . Unit
A normalized copy of the Vector3; the vector that has the same direction as the initial Vector3, but with a length of 1.
Methods [ ]
Method
Description
Vector3 Vector3 : Cross (
Vector3 otherVector )
Returns the cross product of the two vectors.
number Vector3 : Angle (
Vector3 otherVector ,
Vector3 axis )
Returns the angle in radians between the two vectors. If axis is provided, the returned number will be signed (positive or negative).
number Vector3 : Dot (
Vector3 otherVector )
Returns the dot product of the two vectors.
boolean Vector3 : FuzzyEq (
Vector3 otherVector ,
number epsilon )
Returns whether or not each of the X Y and Z components of the vector are within epsilon units of the other.
Vector3 Vector3 : Lerp (
Vector3 otherVector ,
number alpha )
Linearly interpolates a vector between this Vector3 and otherVector, by the fraction alpha. Note that this can be used to extrapolate as alpha is not constrained between 0 and 1.
Vector3 Vector3 : Max (
Vector3 otherVector )
Returns a Vector3 with each component as the highest among the two vectors.
Vector3 Vector3 : Min (
Vector3 otherVector )
Returns a Vector3 with each component as the lowest among the two vectors.
Operators [ ]
Method
Description
Vector3 Vector3 + Vector3
Returns a Vector3 where each respective axis is added to the other.
Vector3 Vector3 - Vector3
Returns a Vector3 where each respective axis is subtracted from the other.
Vector3 Vector3 * Vector3
Returns a Vector3 where each respective axis is multiplied by the other.
Vector3 Vector3 / Vector3
Returns a Vector3 where each respective axis is divided by the other.
Vector3 Vector3 * number
Returns a Vector3 where each axis is multiplied by number
.
Vector3 Vector3 / number
Returns a Vector3 where each axis is divided by number
.
Referenced by [ ]
EditableMesh:AddNormal (normal )
EditableMesh:AddVertex (p )
EditableMesh:FindClosestPointOnSurface (point )
EditableMesh:FindClosestVertex (toThisPoint )
EditableMesh:FindVerticesWithinSphere (center )
EditableMesh:GetCenter
EditableMesh:GetNormal
EditableMesh:GetPosition
EditableMesh:GetSize
EditableMesh:RaycastLocal (origin , direction )
EditableMesh:SetNormal (normal )
EditableMesh:SetPosition (p )
EditableMesh:CreateMeshPartAsync (initialSize )
AccessoryDescription.Position
AccessoryDescription.Rotation
AccessoryDescription.Scale
Accoutrement.AttachmentForward
Accoutrement.AttachmentPos
Accoutrement.AttachmentRight
Accoutrement.AttachmentUp
WorkspaceAnnotation.AdorneeOffset
WorkspaceAnnotation:GetAbsolutePosition
WorkspaceAnnotation:SetAdorneeOffsetFromAbsolutePosition (position )
Attachment.Axis
Attachment.Orientation
Attachment.Position
Attachment.Rotation
Attachment.SecondaryAxis
Attachment.WorldAxis
Attachment.WorldOrientation
Attachment.WorldPosition
Attachment.WorldRotation
Attachment.WorldSecondaryAxis
Attachment:GetAxis
Attachment:GetSecondaryAxis
Attachment:SetAxis (axis )
Attachment:SetSecondaryAxis (axis )
MeshImportData.Dimensions
RootImportData.FileDimensions
BaseWrap:GetCageOffset
BodyAngularVelocity.AngularVelocity
BodyAngularVelocity.MaxTorque
BodyAngularVelocity.angularvelocity
BodyAngularVelocity.maxTorque
BodyForce.Force
BodyForce.force
BodyGyro.MaxTorque
BodyGyro.maxTorque
BodyPosition.MaxForce
BodyPosition.Position
BodyPosition.maxForce
BodyPosition.position
BodyPosition:GetLastForce
BodyPosition:lastForce
BodyThrust.Force
BodyThrust.Location
BodyThrust.force
BodyThrust.location
BodyVelocity.MaxForce
BodyVelocity.Velocity
BodyVelocity.maxForce
BodyVelocity.velocity
BodyVelocity:GetLastForce
BodyVelocity:lastForce
RocketPropulsion.MaxTorque
RocketPropulsion.TargetOffset
Camera:WorldToScreenPoint (worldPoint )
Camera:WorldToViewportPoint (worldPoint )
Camera:ZoomToExtents (boundingBoxSize )
DragDetector.Axis
DragDetector.MaxDragTranslation
DragDetector.MinDragTranslation
DragDetector.Orientation
DragDetector.SecondaryAxis
DragDetector.WorldAxis
DragDetector.WorldSecondaryAxis
Constraint:GetDebugAppliedForce
Constraint:GetDebugAppliedTorque
AlignOrientation.LookAtPosition
AlignOrientation.PrimaryAxis
AlignOrientation.SecondaryAxis
AlignPosition.MaxAxesForce
AlignPosition.Position
AngularVelocity.AngularVelocity
LinearVelocity.LineDirection
LinearVelocity.MaxAxesForce
LinearVelocity.PrimaryTangentAxis
LinearVelocity.SecondaryTangentAxis
LinearVelocity.VectorVelocity
CylindricalConstraint.WorldRotationAxis
Torque.Torque
VectorForce.Force
AirController.LinearImpulse
ControllerManager.FacingDirection
ControllerManager.MovingDirection
ControllerManager.UpDirection
DataModelMesh.Offset
DataModelMesh.Scale
DataModelMesh.VertexColor
Dialog.TriggerOffset
Dragger:MouseDown (pointOnMousePart )
Explosion.Position
ViewportFrame.LightDirection
BillboardGui.ExtentsOffset
BillboardGui.ExtentsOffsetWorldSpace
BillboardGui.StudsOffset
BillboardGui.StudsOffsetWorldSpace
HandleAdornment.SizeRelativeOffset
BoxHandleAdornment.Size
WireframeHandleAdornment.Scale
WireframeHandleAdornment:AddLine (from , to )
WireframeHandleAdornment:AddText (point )
SelectionPointLasso.Point
GuiService:GetClosestDialogToPosition (position )
HapticEffect.Position
Humanoid.CameraOffset
Humanoid.MoveDirection
Humanoid.TargetPoint
Humanoid.WalkToPoint
Humanoid:GetAccessoryHandleScale
Humanoid:GetMoveVelocity
Humanoid:Move (moveDirection )
Humanoid:MoveTo (location )
InputObject.Delta
InputObject.Position
Glue.F0
Glue.F1
Glue.F2
Glue.F3
Lighting:GetMoonDirection
Lighting:GetSunDirection
Noise:SampleDirectional (position , direction )
Noise:SampleUniform (position )
BasePart.AssemblyAngularVelocity
BasePart.AssemblyCenterOfMass
BasePart.AssemblyLinearVelocity
BasePart.CenterOfMass
BasePart.ExtentsSize
BasePart.Orientation
BasePart.Position
BasePart.RotVelocity
BasePart.Rotation
BasePart.Size
BasePart.Velocity
BasePart:AngularAccelerationToTorque
BasePart:AngularAccelerationToTorque (angAcceleration , angVelocity )
BasePart:ApplyAngularImpulse (impulse )
BasePart:ApplyImpulse (impulse )
BasePart:ApplyImpulseAtPosition (impulse , position )
BasePart:GetClosestPointOnSurface
BasePart:GetClosestPointOnSurface (position )
BasePart:GetVelocityAtPosition
BasePart:GetVelocityAtPosition (position )
BasePart:TorqueToAngularAcceleration
BasePart:TorqueToAngularAcceleration (torque , angVelocity )
SkateboardPlatform:ApplySpecificImpulse (impulseWorld )
Terrain:CellCenterToWorld
Terrain:CellCornerToWorld
Terrain:FillBall (center )
Terrain:FillBlock (size )
Terrain:FillWedge (size )
Terrain:GetTerrainWireframe (size )
Terrain:ReplaceMaterialInTransform (size )
Terrain:ReplaceMaterialInTransformSubregion (size )
Terrain:SetMaterialInTransform (size )
Terrain:SetMaterialInTransformSubregion (size )
Terrain:WorldToCell
Terrain:WorldToCell (position )
Terrain:WorldToCellPreferEmpty
Terrain:WorldToCellPreferEmpty (position )
Terrain:WorldToCellPreferSolid
Terrain:WorldToCellPreferSolid (position )
TriangleMeshPart.MeshSize
TriangleMeshPart.UnscaledCofm
TriangleMeshPart.UnscaledVolInertiaDiags
TriangleMeshPart.UnscaledVolInertiaOffDiags
MeshPart.JointOffset
Model:GetExtentsSize
Model:GetModelSize
Model:MoveTo (position )
Model:TranslateBy (delta )
Model:move (location )
Model:moveTo (location )
Tool.GripForward
Tool.GripPos
Tool.GripRight
Tool.GripUp
WorldRoot:Blockcast (size , direction )
WorldRoot:CacheCurrentTerrain (center )
WorldRoot:GetPartBoundsInBox (size )
WorldRoot:GetPartBoundsInRadius (position )
WorldRoot:Raycast (origin , direction )
WorldRoot:RaycastCachedTerrain (origin , direction )
WorldRoot:SetInsertPoint (point )
WorldRoot:Shapecast (direction )
WorldRoot:Spherecast (position , direction )
Workspace.GlobalWind
Workspace.InsertPoint
ParticleEmitter.Acceleration
Path:ComputeAsync (start , finish )
PathfindingService:ComputeRawPathAsync (start , finish )
PathfindingService:ComputeSmoothPathAsync (start , finish )
PathfindingService:FindPathAsync (start , finish )
Player:DistanceFromCharacter (point )
Player:Move (walkDirection )
Player:RequestStreamAroundAsync (position )
RenderingTest.Orientation
RenderingTest.Position
Selection:SetTerrainSelectionHack (center , size )
AtmosphereSensor.RelativeWindVelocity
ControllerPartSensor.HitNormal
FluidForceSensor.CenterOfPressure
FluidForceSensor.Force
FluidForceSensor.Torque
FluidForceSensor:EvaluateAsync (linearVelocity , angularVelocity )
StudioService:GizmoRaycast (origin , direction )
TerrainRegion.SizeInCells
TerrainRegion:ApplyTransform (size )
TerrainRegion:ApplyTransformSubregion (size )
BubbleChatConfiguration.LocalPlayerStudsOffset
UGCValidationService:CalculateEditableMeshInsideMeshPercentage (meshQueryScale )
UGCValidationService:CalculateEditableMeshTotalSurfaceArea (meshScale )
UGCValidationService:CheckEditableMeshInCameraFrustum (meshScale )
UGCValidationService:GetEditableCagingRelevancyMetrics (offsetInner , offsetOuter )
UGCValidationService:GetEditableMeshMaxNearbyVerticesCollisions (meshScale )
UGCValidationService:GetEditableMeshVerticesSimilarityRate (meshScale )
UGCValidationService:IsEditableMeshNumCoplanarIntersectionsOverLimit (meshScale )
UGCValidationService:ValidateEditableMeshBounds (meshScale , boundsOffset )
UGCValidationService:CalculateMeshInsideMeshPercentage (meshQueryScale )
UGCValidationService:CalculateTotalSurfaceArea (meshScale )
UGCValidationService:CheckMeshInCameraFrustum (meshScale )
UGCValidationService:GetCagingRelevancyMetrics (offsetInner , offsetOuter )
UGCValidationService:GetMaxNearbyVerticesCollisions (meshScale )
UGCValidationService:GetMeshVerticesSimilarityRate (meshScale )
UGCValidationService:IsNumCoplanarIntersectionsOverLimit (meshScale )
UGCValidationService:ValidateFacialBounds (partSize )
UGCValidationService:ValidateFacialExpressiveness (partSize )
UGCValidationService:ValidateMeshBounds (meshScale , boundsOffset )
UnvalidatedAssetService:AppendTempAssetId (lookAt , camPos )
UnvalidatedAssetService:AppendVantagePoint (lookAt , camPos )
Vector3Value.Value
Vector3Value.Changed (value )
Vector3Value.changed (value )
DynamicMesh:AddVertex (p ) (removed)
DynamicMesh:FindClosestPointOnSurface (point ) (removed)
DynamicMesh:FindClosestVertex (toThisPoint ) (removed)
DynamicMesh:FindVerticesWithinSphere (center ) (removed)
DynamicMesh:GetPosition (removed)
DynamicMesh:GetVertexNormal (removed)
DynamicMesh:Raycast (origin , direction ) (removed)
DynamicMesh:SetPosition (p ) (removed)
DynamicMesh:SetVertexNormal (vnormal ) (removed)
ImporterMeshSettings.Dimensions (removed)
ImporterRootSettings.FileDimensions (removed)
LinearVelocityConstraint.LineDirection (removed)
LinearVelocityConstraint.PrimaryTangentAxis (removed)
LinearVelocityConstraint.SecondaryTangentAxis (removed)
LinearVelocityConstraint.VectorVelocity (removed)
MeshDataExperimental.Size (removed)
NavigationService:FindPathAsync (start , finish ) (removed)
NavigationWaypoint.Position (removed)
PathWaypoint.Position (removed)
PseudoPlayer:DistanceFromCharacter (point ) (removed)
BasePart.BodyAngularVelocity (removed)
BasePart.BodyCenterOfMass (removed)
BasePart.BodyLinearVelocity (removed)
BasePart.LinearVelocity (removed)
EditableMesh:GetVertexNormal (removed)
EditableMesh:Raycast (origin , direction ) (removed)
EditableMesh:SetVertexNormal (vnormal ) (removed)
MeshPart.MeshSize (removed)
Model.World Pivot Orientation (removed)
Model.World Pivot Position (removed)
PVInstance.Origin Orientation (removed)
PVInstance.Origin Position (removed)
PVInstance.Pivot Offset Orientation (removed)
PVInstance.Pivot Offset Position (removed)
StudioDeviceEmulatorService:GetKeyboardShortcut (position ) (removed)
StudioDeviceEmulatorService:SendGamepadEvent (position , rotation ) (removed)
StudioDeviceEmulatorService:UpdateKeyMapping (position ) (removed)
Terrain.Position (removed)
Terrain.RotVelocity (removed)
Terrain:SetTerrainRegion (size ) (removed)
Terrain:SetWireframeRegion (size ) (removed)
Terrain.Velocity (removed)
UnvalidatedAssetService:AppendTempAsset (lookAt , camPos ) (removed)
References [ ]
Basic Lua types Roblox types
Colors Sequences Events Vectors Instances Internal types Other types
API reference only