BruceSherwood/glowscript

Unable to compound with local_light

Closed this issue · 1 comments

Simple Program like the following fails:

A = sphere(pos=vec(1,0,0))
B = local_light(pos=vec(1,0,0), color=color.yellow)
C = compound([A,B])

Error is:
TypeError: Cannot read property 'file' of undefined
Line 5: C = compound([A,B])

It never occurred to me that one would want to include a light in a compound, and it's not trivial to make this possible. The implementation of compound is that it combines the "meshes" of the various objects -- that is, the triangles that make up the several objects are combined together into one large set of triangles, after which the compound object is added to the store of "models" in GPU memory, thereby having essentially the same status as a box or sphere or cone. This is why after making the compound you can change pos, size, axis, color, up; it really is now a standard object. A light however is a very different kind of object; it's not a bunch of triangles. My initial reaction is that combining graphics primitives with lights should be done with frame (yet to be implemented), not with compound. The documentation should explain that lights and canvases and graphs cannot be part of a compound.