jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
943 stars 188 forks source link

TypeError when using Vector3 class #401

Open JagnDC opened 1 year ago

JagnDC commented 1 year ago

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 commented 1 year ago

@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?