pythreejs icon indicating copy to clipboard operation
pythreejs copied to clipboard

How to create a TubeGeometry - use of Three.Curve

Open hagrid67 opened this issue 6 years ago • 1 comments

In your notebook examples/Geometries.ipynb you have the following for TubeGeometry:

# TODO: handling THREE.Curve
TubeGeometry(
    path=None,

I've naively tried using a LineCurve3 for the path but I get an error along the following lines:

TraitError: The 'path' trait of a TubeGeometry instance must be a Curve or None, but a value of class 'pythreejs.extras.curves.LineCurve3_autogen.LineCurve3' (i.e. LineCurve3()) was specified.

Is there a way to get TubeGeometry to work as things stand? Or can you sketch out what work would need to be done?

Comparing this with another example where a constructor takes another pythreejs object:

ball = Mesh(geometry=SphereGeometry(radius=1, widthSegments=32, heightSegments=24), 
            material=MeshLambertMaterial(color='red'),
            position=[2, 1, 0])

Here I find that SphereGeometry is configured in three-class-config.js to have superClass BaseGeometry. Whereas LineCurve3 has a fairly empty configuration, and the autogen python has only ThreeWidget rather than Curve as its superclass.

Many thanks.

hagrid67 avatar Sep 21 '19 13:09 hagrid67

I think this was left as a TODO because some logic has to be added to make sure Curve cannot be instantiated on the kernel side (it is an abstract base class). If you want to help with this, you could start by:

  1. Updating the class config to match the three.js docs as closely as possible.
  2. Add a manual override class in Python that cannot be instantiated directly (but can be instantiated as a subclass).

vidartf avatar Sep 23 '19 08:09 vidartf