Geometry 3D
Module: terminaltexteffects.utils.geometry3d
New in 0.16.0
geometry3d is available on development main and is not in the published 0.15.0 package.
Low-level building blocks for placing and drawing things in 3D on a terminal canvas: vectors, rotations, a camera, meshes, rasterization into a per-cell depth buffer, wireframe edges and Lambert shading.
World space is measured in terminal columns. The origin is the center of the canvas, +x points right, +y points
up, and +z points toward the default viewer. A Camera projects world points onto canvas cells and corrects for cells
being about twice as tall as they are wide, so a cube looks like a cube. With the default settings, a cell lifted
onto the z=0 plane with Camera.cell_to_world() projects back onto the same cell.
import math
from terminaltexteffects.utils import geometry3d as g3
camera = g3.Camera(center_column=40.5, center_row=12.5)
cube = g3.box(20, 20, 20)
turn = g3.Rotation.about_y(math.radians(30)) * g3.Rotation.about_x(math.radians(20))
light = g3.Vec3(-0.5, 0.6, 1.0)
for cell, fragment in g3.rasterize(cube, camera, rotation=turn).items():
brightness = g3.lambert(fragment.normal, light) # 0 in shadow, 1 facing the light
Camera position and orientation can change with set_position and set_rotation. depth(point) reports
view-axis depth. ray(coord) supplies a world ray, and cell_to_world(coord, z=...) intersects it with a world-z
plane, raising ValueError for parallel rays. For movement helpers and tweens, use the world's camera, terminal.world.camera.
position and rotation are read-only. distance moves the implicit eye until set_position makes that
position explicit; with focal=None, focal length continues to follow distance. A camera's world-z plane
intersection can lie behind its eye; project the result and handle None when visibility matters.
ray directions are scaled to one unit of view-axis depth rather than normalized to unit Euclidean length.
The low-level class has pose setters and projection, while engine.camera.Camera adds travel/aiming controls and
a queue the world plays inside the effect's update().
Angles are in radians. Rotations compose with *: second * first applies first, then second.
rasterize and wireframe take bounds=g3.Bounds.for_canvas(canvas) to fill only cells on the canvas. Without
bounds they fill every cell a shape covers, which can be a great many for a shape close to the camera.
Camera point queries accept Vec3 values or (x, y, z) world positions in terminal columns.
transform_points also accepts tuples for local input points and its world translation;
rasterize and wireframe accept either form for the mesh origin's world position.
Returned positions remain Vec3 values.
3D geometry primitives for placing and drawing things in 3D space on a terminal canvas.
World space is measured in terminal columns. The origin is the center of the canvas, +x points right, +y points
up, and +z points toward the default viewer. Terminal cells are about twice as tall as they are wide, so one row spans
TERMINAL_ROW_SCALE world units vertically; Camera corrects for this when projecting, so a cube looks like a
cube rather than a tall box.
These are the low-level building blocks: vectors, rotations, a camera, meshes, rasterization into a per-cell depth buffer, wireframe edges and Lambert shading. Angles are in radians. Everything is pure Python.
Classes:
| Name | Description |
|---|---|
Vec3 |
An immutable 3D vector. |
Rotation |
A rotation stored as a unit quaternion. |
Projected |
A point projected onto the canvas, with its depth. |
Bounds |
A rectangle of canvas cells that drawing is limited to. |
Camera |
Projects world-space points onto canvas cells. |
Face |
One polygonal face of a mesh. |
Mesh |
Vertices and faces describing a solid. |
Fragment |
The nearest surface found in one cell by |
EdgeCell |
One cell of a wireframe edge found by |
Functions:
| Name | Description |
|---|---|
transform_points |
Rotates, scales and moves many points at once. |
box, prism, pyramid, tetrahedron, octahedron, icosahedron, cylinder, uv_sphere, torus |
Build meshes. |
rasterize |
Fills a mesh's visible faces into a per-cell depth buffer. |
wireframe |
Finds the cells along a mesh's edges. |
line_symbol |
Picks the symbol that best follows a projected line. |
lambert |
Returns how directly a surface faces a light. |
Matrix3 = tuple[float, float, float, float, float, float, float, float, float]
module-attribute
A 3x3 matrix in row-major order.
ORIGIN = Vec3(0.0, 0.0, 0.0)
module-attribute
The world origin, at the center of the canvas.
Point3 = Union[Vec3, tuple[float, float, float]]
module-attribute
A Vec3 or (x, y, z) triple, in the coordinate space and units of the receiving API.
X_AXIS = Vec3(1.0, 0.0, 0.0)
module-attribute
The unit vector pointing right.
Y_AXIS = Vec3(0.0, 1.0, 0.0)
module-attribute
The unit vector pointing up.
Z_AXIS = Vec3(0.0, 0.0, 1.0)
module-attribute
The unit vector pointing toward the default viewer.
Bounds
Bases: NamedTuple
A rectangle of canvas cells, inclusive on every side, that rasterize and wireframe are limited to.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
int
|
First column. |
right |
int
|
Last column. |
bottom |
int
|
First row. |
top |
int
|
Last row. |
Source code in terminaltexteffects/utils/geometry3d.py
contains(coord)
Camera
dataclass
Project world points from a positioned and oriented camera onto canvas cells.
Initially the eye is (0, 0, distance), looking along -z with +y up. set_position
decouples the eye from legacy distance; set_rotation turns its local axes in world
space. Camera depth is distance along the viewing axis, not Euclidean range.
focal=None follows distance, including after camera movement. Orthographic views
ignore focal length. The default view preserves the z=0 plane's size.
Settings are mutable and validated only at construction. Preserve their positive-value
constraints when assigning them. near < distance is a construction constraint for the
initial view; a moved camera can aim anywhere and clips using view-axis depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_column
|
float
|
Canvas column at the center of the view. |
required |
center_row
|
float
|
Canvas row at the center of the view. |
required |
distance
|
float
|
Initial eye z and fallback focal length, in columns. |
120.0
|
focal
|
float | None
|
Positive focal length; |
None
|
orthographic
|
bool
|
Project without perspective scaling. |
False
|
near
|
float
|
Positive minimum view-axis depth. |
1.0
|
row_scale
|
float
|
World units per row, correcting for tall cells. |
TERMINAL_ROW_SCALE
|
Attributes:
| Name | Type | Description |
|---|---|---|
position |
Vec3
|
Eye in world space, following |
rotation |
Rotation
|
Orientation in world space; identity looks along -z. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If distance, focal, near or row_scale is not positive, or near >= distance. |
Source code in terminaltexteffects/utils/geometry3d.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
position
property
World position of the eye; follows distance until explicitly positioned.
rotation
property
World orientation; identity looks along -z, with +x right and +y up.
__post_init__()
Validate the camera settings.
Source code in terminaltexteffects/utils/geometry3d.py
cell_to_world(coord, z=0.0)
Intersect a cell's viewing ray with world-z plane z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coord
|
Coord
|
Canvas cell through which the viewing ray passes. |
required |
z
|
float
|
World-z plane to intersect, in columns. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Vec3 |
Vec3
|
World-space point or direction. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ray is parallel to the plane, so there is no unique intersection. |
Source code in terminaltexteffects/utils/geometry3d.py
depth(point)
Signed distance along the view axis; smaller positive values are nearer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point3
|
World |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Signed distance along the viewing axis. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
for_canvas(canvas, **settings)
classmethod
Return a camera centered on canvas. settings are passed to Camera.
Source code in terminaltexteffects/utils/geometry3d.py
project(point)
Project a world point, or return None when it is before the near plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point3
|
World |
required |
Returns:
| Type | Description |
|---|---|
Projected | None
|
Projected | None: Projected position and depth, or |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
project_points(points)
Return project applied to each point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
Iterable[Point3]
|
World |
required |
Returns:
| Type | Description |
|---|---|
list[Projected | None]
|
list[Projected | None]: One projected result per input point. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
ray(coord)
Return a world origin and direction through a cell, advancing one unit of camera depth.
Perspective rays begin at the eye. Orthographic rays begin on the eye plane.
The direction is deliberately not normalized: a distance d along it has camera depth d.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coord
|
Coord
|
Canvas cell through which the viewing ray passes. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Vec3, Vec3]
|
tuple[Vec3, Vec3]: World ray origin and direction, scaled to one unit of camera depth. |
Source code in terminaltexteffects/utils/geometry3d.py
set_perspective(strength=1.0)
Set how strongly depth shrinks things, now: 1 is natural, larger exaggerates depth, 0 is orthographic.
The eye's reference distance becomes 120 / strength (120 when orthographic) and focal length follows it, so
the z = 0 plane keeps its size at any strength. An explicitly positioned eye stays where it is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strength
|
float
|
Perspective strength; 0 or more, and less than 120 divided by |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Camera |
Camera
|
This camera, for chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
set_position(x=0.0, y=None, z=None)
Set the eye's world coordinates, independently of distance, now.
Mixing a complete point with y or z raises TypeError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float | Point3
|
Absolute world x in columns, or a |
0.0
|
y
|
float | None
|
World y in columns; omitted/ |
None
|
z
|
float | None
|
World z in columns; omitted/ |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Camera |
Camera
|
This camera, for chaining. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
set_rotation(rotation=None)
Set the world orientation, now. None looks along -z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotation
|
Rotation | None
|
Target world orientation; |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Camera |
Camera
|
This camera, for chaining. |
Source code in terminaltexteffects/utils/geometry3d.py
view_direction(point)
Return the unit vector from point toward the eye, or opposite the orthographic view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point3
|
World |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Vec3 |
Vec3
|
World-space point or direction. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
EdgeCell
Bases: NamedTuple
One cell of a wireframe edge found by wireframe.
Attributes:
| Name | Type | Description |
|---|---|---|
depth |
float
|
Distance along the camera view axis. Smaller is nearer. |
front |
bool
|
Whether the edge borders a face turned toward the camera and, with |
symbol |
str
|
A line symbol following the edge's on-screen slope. |
Source code in terminaltexteffects/utils/geometry3d.py
Face
dataclass
One flat, convex polygonal face of a mesh.
Vertices are listed counterclockwise as seen from outside the solid, so the face's normal points outward.
Attributes:
| Name | Type | Description |
|---|---|---|
indices |
tuple[int, ...]
|
Indexes into the mesh's vertices, at least three. |
uvs |
tuple[tuple[float, float], ...] | None
|
|
tag |
int
|
A label the mesh constructor gives the face, such as the side number of a prism. |
Source code in terminaltexteffects/utils/geometry3d.py
__post_init__()
Validate the face.
Source code in terminaltexteffects/utils/geometry3d.py
Fragment
Bases: NamedTuple
The nearest surface rasterize found in one canvas cell.
Attributes:
| Name | Type | Description |
|---|---|---|
depth |
float
|
Distance along the camera view axis. Smaller is nearer. |
normal |
Vec3
|
The face's world-space unit normal, for shading. |
facing |
bool
|
Whether the face points toward the camera. |
face |
int
|
Index of the face in the mesh. |
tag |
int
|
The face's tag. |
uv |
tuple[float, float] | None
|
Texture coordinates at the cell, or |
Source code in terminaltexteffects/utils/geometry3d.py
Mesh
dataclass
Vertices and faces describing a solid, centered on its own origin.
Built-in mesh factories expect positive dimensions. Dimensions are intentionally unchecked: zero can collapse faces, and negative values can reverse winding and normals. Their shading and texture behavior is not guaranteed. Custom faces should be flat, convex and consistently wound outward.
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
tuple[Vec3, ...]
|
Corner positions in the mesh's own space. |
faces |
tuple[Face, ...]
|
Faces built from those vertices. |
Source code in terminaltexteffects/utils/geometry3d.py
normals
property
Each face's outward unit normal, in the same order as faces.
__post_init__()
Validate the faces and compute their outward normals.
Source code in terminaltexteffects/utils/geometry3d.py
edges()
scaled(x, y=None, z=None)
Return a copy stretched by x, y and z along each axis. y and z default to x.
Source code in terminaltexteffects/utils/geometry3d.py
Projected
Bases: NamedTuple
A world-space point projected onto the canvas.
Attributes:
| Name | Type | Description |
|---|---|---|
column |
float
|
Canvas column, before rounding to a cell. |
row |
float
|
Canvas row, before rounding to a cell. |
depth |
float
|
Distance from the camera along its view axis. Smaller is nearer. |
Source code in terminaltexteffects/utils/geometry3d.py
coord
property
The canvas cell containing the point.
Rotation
dataclass
A rotation stored as a unit quaternion.
Quaternions compose without gimbal lock and interpolate smoothly with slerp. Build rotations with the
about_* constructors rather than setting the components directly. Rotation() is no rotation.
Combine rotations with *: second * first applies first, then second.
Attributes:
| Name | Type | Description |
|---|---|---|
w |
float
|
Scalar part. |
x |
float
|
Vector part, x component. |
y |
float
|
Vector part, y component. |
z |
float
|
Vector part, z component. |
Source code in terminaltexteffects/utils/geometry3d.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
__mul__(other)
Return the rotation that applies other, then this rotation.
Source code in terminaltexteffects/utils/geometry3d.py
about_axis(axis, angle)
staticmethod
Return a rotation of angle radians about axis, counterclockwise when looking down the axis.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
about_x(angle)
staticmethod
Return an x-axis rotation of angle radians; positive angles tip the top toward the default viewer.
about_y(angle)
staticmethod
Return a rotation of angle radians about the y axis. Positive angles turn the front to the right.
about_z(angle)
staticmethod
Return a rotation of angle radians about the z axis. Positive angles turn counterclockwise.
apply(vector)
Return vector rotated by this rotation.
Source code in terminaltexteffects/utils/geometry3d.py
inverse()
matrix()
Return the equivalent 3x3 rotation matrix in row-major order, for transforming many points quickly.
Source code in terminaltexteffects/utils/geometry3d.py
normalized()
Return this rotation rescaled to unit length, correcting drift from many compositions.
Source code in terminaltexteffects/utils/geometry3d.py
slerp(other, t)
Return the rotation t of the way from this rotation to other along the shortest path.
t of 0 returns this rotation and 1 returns other. The turn proceeds at a constant angular speed, so an
easing function applied to t shapes the motion.
Source code in terminaltexteffects/utils/geometry3d.py
Vec3
dataclass
An immutable 3D vector or point in world space.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Right, in terminal columns. |
y |
float
|
Up, in terminal columns. |
z |
float
|
Toward the default viewer, in terminal columns. |
Source code in terminaltexteffects/utils/geometry3d.py
__add__(other)
__mul__(scalar)
__neg__()
__rmul__(scalar)
__sub__(other)
__truediv__(scalar)
cross(other)
Return the cross product, a vector perpendicular to both.
Source code in terminaltexteffects/utils/geometry3d.py
dot(other)
Return the dot product, which is positive when both vectors point the same general way.
length()
lerp(other, t)
Return the point t of the way from this vector to other, where 0 is this vector and 1 is other.
Source code in terminaltexteffects/utils/geometry3d.py
normalized()
Return a vector of length 1 pointing the same way.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the vector has zero length, so it has no direction. |
Source code in terminaltexteffects/utils/geometry3d.py
box(width, height, depth)
Return a box centered on the origin. Each face is textured from 0 to 1 and tagged 0 to 5.
Tags: 0 front (+z), 1 right (+x), 2 back (-z), 3 left (-x), 4 top (+y), 5 bottom (-y).
Source code in terminaltexteffects/utils/geometry3d.py
cylinder(radius, height, segments=32, *, caps=True)
Return a cylinder around the y axis, built from segments flat sides.
The side is textured once around: u runs from 0 at the front, rightward around to 1, and v from 0 at the bottom to 1 at the top. Side faces are tagged 0; caps, when included, are tagged 1 (top) and 2 (bottom).
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
icosahedron(radius)
Return a regular icosahedron whose corners are radius from the origin.
Source code in terminaltexteffects/utils/geometry3d.py
lambert(normal, light)
Return how directly a surface faces a light, from 0 (edge-on or facing away) to 1 (facing it squarely).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normal
|
Vec3
|
The surface's outward normal. |
required |
light
|
Vec3
|
Direction from the surface toward the light. |
required |
Source code in terminaltexteffects/utils/geometry3d.py
line_symbol(column_change, row_change, row_scale=TERMINAL_ROW_SCALE)
Return -, /, | or \, whichever best follows a line with this on-screen change.
The row change is scaled by row_scale first, so the choice follows the line's visible angle on tall cells.
Source code in terminaltexteffects/utils/geometry3d.py
octahedron(radius)
Return a regular octahedron whose corners are radius from the origin.
Source code in terminaltexteffects/utils/geometry3d.py
prism(sides, radius, height)
Return a prism with sides rectangular sides around the y axis, capped top and bottom.
radius is the distance from the axis to each corner. Side i is tagged i and textured from 0 to 1; going
around, side i + 1 is to the right of side i. The top cap is tagged sides and the bottom sides + 1.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
pyramid(sides, radius, height)
Return a pyramid with a sides-sided base, centered so its base and apex are height / 2 from the origin.
Side i is tagged i; the base is tagged sides.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
rasterize(mesh, camera, *, rotation=None, scale=1.0, position=ORIGIN, cull='back', buffer=None, bounds=None)
Fill the mesh's faces into a per-cell depth buffer and return it.
The mesh is scaled, rotated and moved to position, then each face is projected and every cell whose center
it covers is compared with what the buffer already holds; the nearer surface wins. Pass the same buffer to
several calls to draw several meshes into one view with correct overlap. Faces crossing the near plane
are clipped, with texture coordinates interpolated at the new corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
The solid to draw. |
required |
camera
|
Camera
|
Projects the mesh onto the canvas. |
required |
rotation
|
Rotation | None
|
Orientation of the mesh. Defaults to no rotation. |
None
|
scale
|
float
|
Uniform size multiplier. |
1.0
|
position
|
Point3
|
Absolute world |
ORIGIN
|
cull
|
str
|
Skip faces turned |
'back'
|
buffer
|
dict[Coord, Fragment] | None
|
A buffer to draw into. Defaults to a new one. |
None
|
bounds
|
Bounds | None
|
Only fill cells inside these bounds, such as the canvas. Work outside them is skipped, so geometry that projects far off screen stays cheap. Defaults to no limit. |
None
|
Returns:
| Type | Description |
|---|---|
dict[Coord, Fragment]
|
dict[Coord, Fragment]: The nearest surface in each covered cell. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
tetrahedron(radius)
Return a regular tetrahedron whose corners are radius from the origin.
Source code in terminaltexteffects/utils/geometry3d.py
torus(major_radius, minor_radius, segments=36, sides=18)
Return a ring-shaped torus lying flat around the y axis.
major_radius is from the center of the hole to the center of the tube, and minor_radius is the tube's
radius. The tube is built from segments sections, each with sides faces.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
transform_points(points, rotation=None, *, scale=1.0, position=ORIGIN)
Return points scaled, then rotated, then moved to position.
points contains local (x, y, z) positions or Vec3 values in terminal columns.
position is the world (x, y, z) translation in columns, supplied as a tuple or Vec3.
The rotation is converted to a matrix once, so this is faster than calling Rotation.apply per point.
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
uv_sphere(radius, segments=24, rings=12)
Return a sphere built from segments slices around the y axis and rings bands from pole to pole.
Textured like a globe: u runs once around from the front, rightward, and v from 0 at the south pole to 1 at the north pole. Faces touching a pole are triangles.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in terminaltexteffects/utils/geometry3d.py
wireframe(mesh, camera, *, rotation=None, scale=1.0, position=ORIGIN, bounds=None, depth_test=False)
Return the cells along the mesh's edges.
Where edges cross, a front edge wins over a hidden one, and otherwise the nearer edge wins. Edges crossing
the near plane retain their visible segment. With bounds, only the cells of each edge inside them are
visited, so an edge reaching far off screen costs no more than one on it.
position is the absolute world (x, y, z) position of the mesh origin in columns,
supplied as a tuple or Vec3.
By default, front classifies adjacent face orientation, which only approximates visibility for concave
meshes. With depth_test=True, cells behind the mesh's filled surface are also classified as hidden.
This adds a rasterization pass, restricted to the same bounds.
Raises:
| Type | Description |
|---|---|
TypeError
|
If a point is not a |
Source code in terminaltexteffects/utils/geometry3d.py
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | |