Vec3

3D vector class with swizzling and basic operations.

Vec3

Located in ursina/vec3.py

Properties

PropertyDescription
.xX component (float)
.yY component (float)
.zZ component (float)
.xySwizzle (x, y) as Vec2
.yxSwizzle (y, x) as Vec2
.xzSwizzle (x, z) as Vec2
.yzSwizzle (y, z) as Vec2
.XInteger-cast X
.YInteger-cast Y
.ZInteger-cast Z

Example

from ursina.math import Vec3

a = Vec3(1, 0, 0) * 2
print(a)         # Vec3(2, 0, 0)

a = Vec3(1, 0, 1) * Vec3(2, 1, 2)
print(a)         # Vec3(2, 0, 2)

b = Vec3(1.25235, 0, 1)
b += Vec3(0, 1, 0)
print(b)         # Vec3(1.25235, 1, 1)