public readonly struct Vector3A three-component vector: positions, directions, scales, and everything else the engine measures in world space.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Right-handed, Y-up, −Z forward. Fields rather than properties so ref returns and Unsafe.As reinterpretation are legal and free. See Conventions.md.
Fields and properties (19)
public const int ComponentCountNumber of components.
public readonly float XThe X component.
public readonly float YThe Y component.
public readonly float ZThe Z component.
public static Vector3 ZeroAll components zero.
public static Vector3 OneAll components one.
public static Vector3 UnitXThe X axis.
public static Vector3 UnitYThe Y axis.
public static Vector3 UnitZThe Z axis.
public static Vector3 Up+Y.
public static Vector3 Down−Y.
public static Vector3 Right+X.
public static Vector3 Left−X.
public static Vector3 Forward−Z. Right-handed, so the direction a camera looks is negative Z.
public static Vector3 Backward+Z.
public Vector2 XyThe X and Y components.
public float this[int index]The component at .
public bool IsZeroWhether every component is zero.
public bool IsNaNWhether any component is NaN.
Methods (39)
public Vector3(float x, float y, float z)Builds a vector from its components.
public Vector3(float value)Builds a vector with every component set to .
public Vector3(Vector2 xy, float z)Extends a Vector2 with a Z component.
public ReadOnlySpan<float> AsSpan()The vector's components as a span, for bulk copies and interop. [UnscopedRef] because the span aliases this instance: it is valid exactly as long as the vector it came from, and the compiler enforces that rather than trusting the caller.
public void CopyTo(Span<float> destination)Copies the components into a caller-owned span.
public float Length()The length of the vector.
public float LengthSquared()The squared length. Prefer it wherever the answer is only compared — culling, nearest searches, tolerance tests — because it skips a square root per element.
public static Vector3 Normalize(Vector3 value)The vector scaled to unit length. A zero-length vector normalises to Zero rather than to NaN, so a degenerate input propagates as something visible instead of poisoning every later comparison.
public static float Dot(Vector3 left, Vector3 right)The dot product.
public static Vector3 Cross(Vector3 left, Vector3 right)The cross product, right-handed: Cross(UnitX, UnitY) is UnitZ.
public static float Distance(Vector3 left, Vector3 right)The distance between two points.
public static float DistanceSquared(Vector3 left, Vector3 right)The squared distance between two points.
public static Vector3 Lerp(Vector3 from, Vector3 to, float amount)Linearly interpolates between two vectors.
public static Vector3 Min(Vector3 left, Vector3 right)The component-wise minimum.
public static Vector3 Max(Vector3 left, Vector3 right)The component-wise maximum.
public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3 max)Constrains each component to the matching interval.
public static Vector3 Abs(Vector3 value)The component-wise absolute value.
public static Vector3 Reflect(Vector3 direction, Vector3 normal)Reflects a direction about a surface normal.
public static Vector3 Project(Vector3 value, Vector3 onto)The component of along .
public static bool NearEqual(Vector3 left, Vector3 right, float tolerance = 1E-06)Whether two vectors agree to within a tolerance, component by component.
public static Vector3 operator +(Vector3 left, Vector3 right)Adds two vectors.
public static Vector3 operator -(Vector3 left, Vector3 right)Subtracts one vector from another.
public static Vector3 operator -(Vector3 value)Negates a vector.
public static Vector3 operator *(Vector3 left, Vector3 right)Multiplies component by component.
public static Vector3 operator *(Vector3 value, float scale)Scales a vector.
public static Vector3 operator *(float scale, Vector3 value)Scales a vector.
public static Vector3 operator /(Vector3 left, Vector3 right)Divides component by component.
public static Vector3 operator /(Vector3 value, float divisor)Divides a vector by a scalar.
public static bool operator ==(Vector3 left, Vector3 right)Exact component-wise equality, with IEEE semantics: two vectors holding NaN are not equal. Approximate comparison is NearEqual, never this.
public static bool operator !=(Vector3 left, Vector3 right)The negation of op_Equality.
public static implicit operator Vector3(Vector3 value)Converts to the BCL vector, which has the same layout.
public static implicit operator Vector3(Vector3 value)Converts from the BCL vector, which has the same layout.
public void Deconstruct(out float x, out float y, out float z)Splits the vector into its components.
public bool Equals(Vector3 other)Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)Indicates whether this instance and a specified object are equal.
public override int GetHashCode()Returns the hash code for this instance.
public override string ToString()Returns the fully qualified type name of this instance.
public string ToString(string? format, IFormatProvider? formatProvider)Formats the value of the current instance using the specified format.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider? provider = null)Tries to format the value of the current instance into the provided span of characters.
Used by (1198, showing 40)
- ArenaMultiplayer
- ArenaThirdPersonShooter
- ArenaBoxThirdPersonShooter
- ArenaCameraOcclusionThirdPersonShooter
- ArenaFrameThirdPersonShooter
- ArenaIlluminationThirdPersonShooter
- BoxCollisionThirdPersonShooter
- CharacterAnimationThirdPersonShooter
- ConcreteThirdPersonShooter
- FighterMultiplayer
- FrameDocumentTestsThirdPersonShooter.Frame.Tests
- GameClientMultiplayer
- IcosphereVirtualGeometry
- LocalMatchMultiplayer
- PbrShowcaseGamePbrShowcase
- PlayerRigThirdPersonShooter
- PreethamRadianceThirdPersonShooter
- RespawnWhenBelowThirdPersonShooter
- SampleLogThirdPersonShooter
- SoakNetworkSoak
- SpherePbrShowcase
- SunOrbitThirdPersonShooter
- TypeRegistrationThirdPersonShooter
- VertexPbrShowcase
- VirtualGeometryGameVirtualGeometry
- Vixen_Samples_ThirdPersonShooter_BoxCollisionSerializerThirdPersonShooter
- WeaponFireThirdPersonShooter
- BakeBenchmarksVixen.Benchmarks.Navigation
- BulkTransformBenchmarksVixen.Benchmarks.Math
- ConstraintStageBenchmarksVixen.Benchmarks.Animation
- CrowdBenchmarksVixen.Benchmarks.Navigation
- LevelVixen.Benchmarks.Navigation
- PathQueueBenchmarksVixen.Benchmarks.Navigation
- QueryBenchmarksVixen.Benchmarks.Navigation
- RigsVixen.Benchmarks.Animation
- AccelerationStructureDeviceTestsVixen.Graphics.Golden.Tests
- AdaptiveProbeTestsVixen.Rendering.ScreenProbes.Tests
- AgentVixen.Navigation
- AimGoalVixen.Animation
- AlgebraicPropertyTestsVixen.Core.Mathematics.Tests