Skip to main content

p3D

Get it on GitHub Get it on PyPI

Getting Started

To install the package, run this command in the directory of your project's code.

pip install python3D

You can now start writing your first 3D script. Paste the following code to get started.

import python3D as p3D


def setup():
    """Put your setup code here, to run once."""
    global models


def loop(elapsed_time):
    """Put your main code here, to run repeatedly."""


p3D.run(setup, loop)

The setup and loop functions are not required parameters of p3D.run(), but all project functions are added in them.

You're ready to start developing in 3D!

Documentation

Models

To add an OBJ model, you can use the models registry in your setup() function.

def setup():
    """Put your setup code here, to run once."""
    global models
    p3D.models['model'] = p3D.Model('model.obj', 'optional_texture.png')

To modify the transformational properties of your models, you can use the change_position() property.

models['model'].change_position(x=1)

When in the loop() function, you must use p3D.models['model'] instead.

x, y, z - left/right, up/down, and forward/backward displacements, respectively

rot_x, rot_y, rot_z - rotation on x, y, and z axes, respectively

scale - percentage-based size change of model. Support for axis-based scaling is not supported at this time.

reset - takes inputted values as the new position of the model when set to 1; 0 by default (adds new values to current values).

Preferences

p3D.preferences can be used to modify functionality by changing an attribute.

p3D.preferences['attribute'] = value

The following attributes are available:

  • 'title' - string used for default loading screen, window caption, and system logs. 'p3D' by default.
  • 'camera' - list [x, y, z, h, v] of starting camera attributes where x, y, z is the position of the camera and h, v is the starting horizontal and vertical camera angles. [0, 0, 0, 0.01, 0.01] by default.
    • The amount of decimal places in the starting horizontal and vertical camera angles is the amount of decimal places possible in simulation. For example, having 0, 0 as your h, v values would make the camera rotate in integer values only, reducing freedom.
  • 'font' - string file path to font file of choice. font.ttf by default.
  • 'skybox' - string file path to skybox image of choice; replaces black environment. None by default.
  • 'loading' - function taking parameters surface and title, regardless of whether they are used. Custom loading screens must be drawn on with pygame functions.
  • 'GUI' - boolean value determining whether to show runtime metrics. False by default.

Logs

The p3D.log() function takes in three parameters (prefix, message, data=None) and logs in the command line in color, if supported.

prefix - determines type of message sent. Possible values include:

  • 'warning': yellow, user warnings
  • 'error': red, both computational and logical errors
  • 'log': blue, general messages, runtime checkpoints, and data logging

message - message body to be sent; should be one line.

data - list, where each item appears after the message body on a separate line.

Proper Usage

When using the p3D.log() function, following proper usage guides can ensure that in-built engine logs match the style of your project's logs.

  • Use warnings when something atypical for your project (e.g., a user hasn't claimed their account and information may be lost) occurs, NOT when an error is anticipated.
  • Errors should be used for issues specific to your project (e.g., an item is too expensive for the player to buy).
    • If a runtime error occurs, FATAL. must precede your message, and for specific errors, you must include relevant information (e.g. filenames) in the data list.
    • If the error is not specific (i.e. general Exception), then after relevant information, include f'Error {str(e)} in the data list.
    • Unhelpful error messages often don't include a fix or course of action.
  • Make sure to log all important stages of app progression (e.g, a user signs up).

Other

Issue Reporting

To report issues, please refer to our GitHub Issues page.

Contacts

For questions concerning the contents of this repository, please contact aaravhdave[at]gmail.com.

Metadata

Release files for python3D 2024.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python3D 2024.1.3
File Size Uploaded Provenance Actions
python3d-2024.1.3.tar.gz 11.2 kB Without provenance Details for python3d-2024.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python3D 2024.1.3
File Interpreter ABI Platform Actions
python3d-2024.1.3-py3-none-any.whl Python 3 none any Details for python3d-2024.1.3-py3-none-any.whl

Total release size: 23.2 kB

Release files / python3d-2024.1.3.tar.gz

Download URL python3d-2024.1.3.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1fbb26970d11414877dfc1966b89bd408c99faab3b6a8baa733918a16eac54be
BLAKE2b-256 checksum
How to use checksums
5b68c912c0ed9d590e74800473b414ad781796867a60d02dc4fd583e0d6c47a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Release files / python3d-2024.1.3-py3-none-any.whl

Download URL python3d-2024.1.3-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e50d6c7eccb6fb923e7ba2824d0e09081dd48c60b9367d9656e3b47da8ec1a4
BLAKE2b-256 checksum
How to use checksums
4449f142c0ca8afca607f43064ab075bd760a3dbecdb61943fe975dfdd2c66ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Security for python3D 2024.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2024.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page