BruceSherwood/glowscript

cc.pos=[vector, vector] fails if cc is a curve

Closed this issue · 1 comments

Consider the following code:
test-curve.py.txt

  • Expected and desired behavior:
    It works fine as a python program from the command line. Also it worked under glowscript not too long ago.
  • Observed behavior: Nowadays it fails when running in the browser using glowscript. The error message is:
    «Property 'pos' must be a vector.» The error is charged to the line following "if 1".

I conjecture this is the result of overzealous error-checking. For a curve, it is not required that the pos property be a single vector.

An oddity is that the list of vectors [.....] is inside parens, as in ([.....]). However, the real issue is that the API for curve in both GlowScript VPython and Jupyter VPython is different from that of Classic VPython, and in particular as of version 2.0 you have to manipulate points with methods.

Here is what was announced with 2.0 (Jan. 2016): The list of positions in a curve named c cannot be referenced directly as c.pos. If the curve is named c and N is the nth point in the curve, c.point(N) returns {pos:p, color:col, radius:r, visible:v}. To change the nth point, use c.modify(N, pos=p, color=col, radius=r, visible=v). See the documentation for the curve object for the full list of methods available for accessing or changing an existing curve. (From http://www.glowscript.org/docs/GlowScriptDocs/history.html; the motivation for this has to do with various issues, including the "remoteness" of the browser from a Jupyter Python program.)

See curve documentation: http://www.glowscript.org/docs/VPythonDocs/curve.html