{"id":15009914,"url":"https://github.com/neric89/3dturtles","last_synced_at":"2026-03-18T02:04:30.417Z","repository":{"id":63905064,"uuid":"566980424","full_name":"neric89/3DTurtles","owner":"neric89","description":"3D extension of the python turtles module","archived":false,"fork":false,"pushed_at":"2022-11-28T18:04:37.000Z","size":63,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T17:17:26.163Z","etag":null,"topics":["3d","3d-turtle","python","python-3","python3","turtle","turtle-graphics","turtle-python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neric89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-16T20:24:24.000Z","updated_at":"2023-10-08T18:58:17.000Z","dependencies_parsed_at":"2022-11-28T19:21:14.135Z","dependency_job_id":null,"html_url":"https://github.com/neric89/3DTurtles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neric89%2F3DTurtles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neric89%2F3DTurtles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neric89%2F3DTurtles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neric89%2F3DTurtles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neric89","download_url":"https://codeload.github.com/neric89/3DTurtles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258505,"owners_count":20262300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-turtle","python","python-3","python3","turtle","turtle-graphics","turtle-python"],"created_at":"2024-09-24T19:29:06.807Z","updated_at":"2025-12-27T05:30:37.306Z","avatar_url":"https://github.com/neric89.png","language":"Python","readme":"# Turtle3D\nTurtle 3D is designed to be a 3D extension of the python turtle module. It is very limited as far as 3D renderers go, but can be useful for simple 3D modeling.\n\nEffort was made to make this feel as much like the original turtle module as possible, and many functions simply point to the original turtle module. However, due\nto the nature of the approach used and the difficulty of expanding some features to the third dimension, some of the original functions do not exist, and some occasional\nvisual defects do occur. Plans are to continue expanding this module to include more of the functionality the was present in the original turtle module, and hopefully remove\nthe visual defects, although some of these pose particularly difficult challenges. Suggestions or solutions are welcome.\n\n# Installation\n\n```\npip install turtles3D\n```\n\n# Examples\nThe following example shows a demonstration of creating a 3D cube, and then animating its rotation by calling the rotation functions repeatedly.\n\n```\nimport time\nfrom turtles3D import Turtle3D\n\ndef connect(t: Turtle3D, point1, point2):\n    \"\"\"Helper function to draw a connecting line between 2 points\"\"\"\n\n    start = t.pos()\n    d = t.isdown()\n    t.penup()\n    t.goto(point1)\n    t.pendown()\n    t.goto(point2)\n    t.penup()\n    t.goto(start)\n    if d:\n        t.pendown()\n\ndef draw_axes(t: Turtle3D):\n    \"\"\"Helper function to draw the x,y, and z axes in different colors to help visualize where they are\"\"\"\n\n    t.pencolor(\"blue\")\n    t.goto(500, 0, 0)\n    t.write(\"X\")\n    t.goto(-500, 0, 0)\n    t.write(\"-X\")\n    t.home()\n    t.pencolor(\"red\")\n    t.goto(0, 500, 0)\n    t.write(\"Y\")\n    t.goto(0, -500, 0)\n    t.write(\"-Y\")\n    t.home()\n    t.pencolor(\"green\")\n    t.goto(0, 0, 500)\n    t.write(\"Z\")\n    t.goto(0, 0, -500)\n    t.write(\"-Z\")\n    t.home()\n    t.pencolor(\"black\")\n\ndef run(t: Turtle3D):\n    \"\"\"Main function to handle our drawing and animation\"\"\"\n\n    # here we define the eight points that make up the corners of our cube\n    points = [\n        [50, -50, -50],  # bottom-right-front\n        [50, 50, -50],  # top-right-front\n        [-50, 50, -50],  # top-left-front\n        [-50, -50, -50],  # bottom-left-front\n        [50, -50, 50],  # bottom-right-back\n        [50, 50, 50],  # top-right-back\n        [-50, 50, 50],  # top-left-back\n        [-50, -50, 50],  # bottom-left-back\n    ]\n\n    # connecting each of the points to the other points it needs to\n    for i in range(4):\n        connect(t, points[i], points[(i + 1) % 4])\n        connect(t, points[i + 4], points[((i + 1) % 4) + 4])\n        connect(t, points[i], points[i + 4])\n\n\n    # animating 2 degree rotations of each axis 10,000 times\n    angle = 2\n    for i in range(10000):\n\n        t.rotateX(angle, False) # False because we don't want to redraw the lines until the final rotation\n        t.rotateY(angle, False)\n        t.rotateZ(angle)\n\n        time.sleep(1 / 60) # so we are redrawing 60 times per second. not exactly equal to 60fps due draw times, but pretty close.\n\n\nif __name__ == \"__main__\":\n    t = Turtle3D()\n    s = t.getscreen()\n\n    draw_axes(t) # comment out this line for smoother animation\n\n    run(t)\n    s.exitonclick()\n\n```\n# API Reference\n\nSince many of these functions point to or expand on the original turtle functions, view\nhttps://docs.python.org/3/library/turtle.html for more information.\n\n#### Turtle3D.position()\n#### Turtle3D.pos()\nreturns the current x,y,z coordinates of the turtle\n\n\n#### Turtle3D.setpos(x: float | List[], y: float = None, z: float = None) -\u003e None\n#### Turtle3D.setposition(x: float | List[], y: float = None, z: float = None) -\u003e None\n#### Turtle3D.goto(x: float | List[], y: float = None, z: float = None) -\u003e None\nmoves turtle to (x,y,z)\n\n\n#### Turtle3D.fd(distance: float) -\u003e None\n#### Turtle3D.forward(distance: float) -\u003e None\nmoves the turtle distance pixels in the direction it is currently heading\n\n\n#### Turtle3D.back(distance: float) -\u003e None\n#### Turtle3D.backward(distance: float) | Turtle3D.bk() -\u003e None\nmoves the turtle distance pixels in the opposite direction of its current heading\n\n\n#### Turtle3D.rt(angle: float) -\u003e None\n#### Turtle3D.right(angle: float) -\u003e None\nturns the turtle clockwise by angle degrees in the XY plane\n\n\n#### Turtle3D.lt(angle: float) -\u003e None\n#### Turtle3D.left(angle: float) -\u003e None\nturns the turtle counterclockwise by angle degrees in the XY plane\n\n\n#### Turtle3D.seth(XY_angle: float, Z_angle: float = None) -\u003e None\n#### Turtle3D.setheading(XY_angle: float, Z_angle: float = None) -\u003e None\nset the turtle's current heading to be XY_angle in the XY plane, and Z_angle in the XZ plane\n\n\n#### Turtle3D.clone()\nreturns a copy of the turtle with the same heading, position, pensize, fillcolor, and pencolor.\n\n\n#### Turtle3D.heading()\nreturns the turtle's current heading, XY_angle in the XY plane, and Z_angle in the XZ plane\n\n\n#### Turtle3D.stamp()\ncreates an imprint of the turtle at the current location. This will appear the same shape no matter how the axes are rotated.\n\nreturns an id for the stamp created\n\n\n#### Turtle3D.clearstamps(n: int = None) -\u003e None\nDelete all or first/last n of turtle's stamps.\n\nOptional argument   n -- an integer\n\nIf n is None, delete all of pen's stamps, else if n \u003e 0 delete first n stamps else if n \u003c 0 delete last n stamps.\n\n\n#### Turtle3D.clearstamp(stampid: int) -\u003e None\nclears stamp with given stampid\n\n\n#### Turtle3D.yup(angle: float) -\u003e None\nturns the turtle counterclockwise in the XZ plane by angle degrees\n\n\n#### Turtle3D.ydown(angle: float) -\u003e None\nturns the turtle clockwise in the XZ plane by angle degrees\n\n\n#### Turtle3D.xup(angle: float) -\u003e None\nturns the turtle counterclockwise in the YZ plane by angle degrees\n\n\n#### Turtle3D.xdown(angle: float) -\u003e None\nturns the turtle clockwise in the YZ plane by angle degrees\n\n#### Turtle3D.reset() -\u003e None\nDelete the turtle's drawings from the screen, re-center the turtle and set variables to the default values.\n\n\n#### Turtle3D.clear() -\u003e None\nDelete the turtle's drawings from the screen. Do not move turtle. State and position of the turtle as well as drawings of other turtles are not affected.\n\n\n#### Turtle3D.xcor() -\u003e float\nreturns the current X-coordinate of the turtle in the 3D space\n\n\n#### Turtle3D.ycor() -\u003e float\nreturns the current Y-coordinate of the turtle in the 3D space\n\n\n#### Turtle3D.zcor() -\u003e float\nreturns the current Z-coordinate of the turtle in the 3D space\n\n\n#### Turtle3D.setx(x: float) -\u003e None\nmoves the turtle to the given x-position. y and z positions remain unchanged\n\n\n#### Turtle3D.sety(y: float) -\u003e None\nmoves the turtle to the given y-position. x and z positions remain unchanged\n\n\n#### Turtle3D.setz(z: float) -\u003e None\nmoves the turtle to the given z-position. x and y positions remain unchanged\n\n\n#### Turtle3D.undo() -\u003e None\nundoes the last command and removes it from the redraw buffer\n\n\n#### Turtle3D.dot() -\u003e None\nPoints to turtle.dot()\nDue to the 3d nature of the drawing, the dot at this location will appear as an orb in 3d space.\n\n\n#### Turtle3D.write() -\u003e None\nputs the given text on the screen at the current location. text changes position when axes are rotated, but does not itself rotate (i.e. the letter 'E' will always display as an 'E', it will not become skewed or flattened if rotated)\n\n\n#### Turtle3D.home() -\u003e None\nmoves the turtle to (0, 0, 0)\n\n\n#### Turtle3D.rotateZ(angle: float, redraw=True) -\u003e None\nrotate the XY plane angle degrees about the Z axis and redraws the canvas from the new canvas perspective.\n\nif redraw is set to False, the redraw phase is skipped. new lines will be drawn from the new perspective,\nbut on the next redraw all lines will change to the new perspective. setting this to False is only recommended\nwhen doing multiple rotations at once, so that the canvas only needs to be redrawn from the final rotation of\nperspective.\n\n\n#### Turtle3D.rotateX(angle: float, redraw=True) -\u003e None\nrotate the YZ plane angle degrees about the X axis and redraws the canvas from the new canvas perspective.\n\nif redraw is set to False, the redraw phase is skipped. new lines will be drawn from the new perspective,\nbut on the next redraw all lines will change to the new perspective. setting this to False is only recommended\nwhen doing multiple rotations at once, so that the canvas only needs to be redrawn from the final rotation of\nperspective.\n\n\n#### Turtle3D.rotateY(angle: float, redraw=True) -\u003e None\nrotate the XZ plane angle degrees about the Y axis and redraws the canvas from the new canvas perspective.\n\nif redraw is set to False, the redraw phase is skipped. new lines will be drawn from the new perspective,\nbut on the next redraw all lines will change to the new perspective. setting this to False is only recommended\nwhen doing multiple rotations at once, so that the canvas only needs to be redrawn from the final rotation of\nperspective.\n\n\n#### Turtle3D.begin_fill() -\u003e None\npoints to turtle.begin_fill()\n\n\n#### Turtle3D.end_fill() -\u003e None\npoints to turtle.end_fill()\n\n\n#### Turtle3D.filling() -\u003e bool\npoints to turtle.filling()\n\n\n#### Turtle3D.ht() -\u003e None\n#### Turtle3D.hideturtle() -\u003e None\npoints to turtle.hideturtle()\n\n\n#### Turtle3D.st() -\u003e None\n#### Turtle3D.showturtle() -\u003e None\npoints to turtle.showturtle()\n\n\n#### Turtle3D.isvisible() -\u003e bool\npoints to turtle.isvisible()\n\n\n#### Turtle3D.shape()\npoints to turtle.shape()\n\n\n#### Turtle3D.pu() -\u003e None\n#### Turtle3D.penup() -\u003e None\n#### Turtle3D.up() -\u003e None\npoints to turtle.penup()\n\n\n#### Turtle3D.pd() -\u003e None\n#### Turtle3D.down() -\u003e None\n#### Turtle3D.pendown() -\u003e None\npoints to turtle.pendown()\n\n\n#### Turtle3D.width()\n#### Turtle3D.pensize()\npoints to turtle.pensize()\n\n\n#### Turtle3D.isdown()\npoints to turtle.isdown()\n\n\n#### Turtle3D.onclick()\npoints to turtle.onclick()\n\n\n#### Turtle3D.onrelease()\npoints to turtle.onrelease()\n\n\n#### Turtle3D.ondrag()\npoints to turtle.ondrag()\n\n\n#### Turtle3D.speed()\npoints to turtle.speed()\n\n\n#### Turtle3D.getscreen()\npoints to turtle.getscreen()\n\n\n#### Turtle3D.pencolor()\npoints to turtle.pencolor()\n\n\n#### Turtle3D.color()\npoints to turtle.color()\n\n\n#### Turtle3D.fillcolor()\npoints to turtle.fillcolor()\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneric89%2F3dturtles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneric89%2F3dturtles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneric89%2F3dturtles/lists"}