{"id":19902137,"url":"https://github.com/stemkoski/three.py","last_synced_at":"2025-05-02T23:32:17.499Z","repository":{"id":150991095,"uuid":"179490554","full_name":"stemkoski/three.py","owner":"stemkoski","description":"Python 3D library.","archived":false,"fork":false,"pushed_at":"2023-01-19T02:16:26.000Z","size":5990,"stargazers_count":110,"open_issues_count":5,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-21T01:01:20.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/stemkoski.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-04T12:11:59.000Z","updated_at":"2024-05-06T06:16:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"07835f22-b667-4c40-841f-33ddba042c15","html_url":"https://github.com/stemkoski/three.py","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/stemkoski%2Fthree.py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemkoski%2Fthree.py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemkoski%2Fthree.py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemkoski%2Fthree.py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stemkoski","download_url":"https://codeload.github.com/stemkoski/three.py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122348,"owners_count":21698306,"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":[],"created_at":"2024-11-12T20:17:14.237Z","updated_at":"2025-05-02T23:32:17.492Z","avatar_url":"https://github.com/stemkoski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"three.py\n========\n\n#### Python 3D library ####\n\nThe aim of this project is to create an easy to use 3D library for Python.\n\nThis project was inspired by [Three.js](https://threejs.org/), and attempts to follow the effective and reliable class structure from that project whenever possible.\n\nThree.py was originally designed for educational purposes, and rendering efficiency and optimization will occasionally be sacrificed for simplicity and clarity.\n\nTo see what the Three.py library is capable of, see the [list of examples](https://github.com/stemkoski/three.py/wiki/Examples) or watch the [sample projects video](https://www.youtube.com/watch?v=vs6LdP6pWKI).\n\n[![Three.py video](https://raw.githubusercontent.com/stemkoski/three.py/master/three.py/docs/youtube-preview.png)](https://www.youtube.com/watch?v=vs6LdP6pWKI)\n\nThis project was initially developed by Lee Stemkoski and Michael Pascale.\n\nThis project uses the MIT license.\n\n### Usage ###\n\nThree.py uses the Python libraries [PyGame](https://www.pygame.org/), [PyOpenGL](http://pyopengl.sourceforge.net/), and [NumPy](http://www.numpy.org/). \n\nThe following code creates a scene, a camera, ambient and directional lights, and adds a light blue cube to the scene. It animates (spins) the cube, and allows the user to move the camera with first-person controls.\n\n```python\nfrom core import *\nfrom cameras import *\nfrom lights import *\nfrom geometry import *\nfrom material import *\n\nclass TestCube(Base):\n    \n    def initialize(self):\n\n        self.setWindowTitle('Cube')\n        self.setWindowSize(800,600)\n\n        self.renderer = Renderer()\n        self.renderer.setViewportSize(800,600)\n        self.renderer.setClearColor(0.25,0.25,0.25)\n        \n        self.scene = Scene()\n        \n        self.camera = PerspectiveCamera()\n        self.camera.transform.setPosition(0, 1, 7)\n        self.camera.transform.lookAt(0, 0, 0)\n        self.cameraControls = FirstPersonController(self.input, self.camera)\n\n        self.scene.add( AmbientLight(strength=0.25) )\n        self.scene.add( DirectionalLight(direction=[-1,-1,-1]) )\n\n        self.cube = Mesh( BoxGeometry(), SurfaceLightMaterial(color=[0.5,0.5,1.0]) )\n        self.scene.add(self.cube)\n        \n    def update(self):\n        \n        self.cameraControls.update()\n\n        if self.input.resize():\n            size = self.input.getWindowSize()\n            self.camera.setAspectRatio( size[\"width\"]/size[\"height\"] )\n            self.renderer.setViewportSize(size[\"width\"], size[\"height\"])\n                \n        self.cube.transform.rotateX(0.02, Matrix.LOCAL)\n        self.cube.transform.rotateY(0.03, Matrix.LOCAL)\n        \n        self.renderer.render(self.scene, self.camera)\n                    \n# instantiate and run the program\nTestCube().run()\n```\n\nIn case you are having difficulties related to versions of the dependencies (PyGame, PyOpenGL, NumPy), a [pipenv](https://docs.pipenv.org/en/latest/) pipfile is provided to set up a [virtualenv](https://virtualenv.pypa.io/en/latest/).\nIt can be used as follows:\n\n```bash\npip install pipenv\npipenv install\npipenv shell\ncd three.py\npython TestAnimatedDayNight.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstemkoski%2Fthree.py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstemkoski%2Fthree.py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstemkoski%2Fthree.py/lists"}