Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using Vector3 class #401

Open
JagnDC opened this issue Apr 1, 2023 · 1 comment
Open

TypeError when using Vector3 class #401

JagnDC opened this issue Apr 1, 2023 · 1 comment
Labels

Comments

@JagnDC
Copy link

JagnDC commented Apr 1, 2023

I'm trying to use the Vector3 class from PyThreeJS to represent 3D vectors in my Python code, but I keep getting a TypeError when trying to create a new Vector3 object. Here's the relevant code snippet:

”“”
from pythreejs import Vector3
vec1 = Vector3(1, 2, 3)
print("Vector 1:", vec1)
“”“

When I run this code, I get the following error message:

”“”
TypeError: init() takes from 1 to 3 positional arguments but 4 were given
I have already updated PyThreeJS to the latest version, but the error persists. I'm running Python 3.7.16 on Windows 10.
“”“

Can someone please help me resolve this issue? Thank you in advance for your help!

Steps to reproduce:

Install PyThreeJS using pip install pythreejs
Run the above code snippet

Expected result:

The code should create a new Vector3 object and print its value.

Actual result:

The code raises a TypeError with the message __init__() takes from 1 to 3 positional arguments but 4 were given.

Environment:

PyThreeJS version: 2.4.2
Python version: 3.7.16
Operating system: Windows10

@vidartf
Copy link
Member

vidartf commented Apr 30, 2023

@JagnDC The Vector3 class in pythreejs is a "trait" used with the config system from the traitlets package. It is not mean to be instantiated directly, but rather assigned as a class variable in a HasTraits class. Would you mind explaining what you are trying to do, and why simply using a tree-valued tuple (e.g. (1, 2, 3)) isn't sufficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants