Note that viewof gl does not depend explicitly on draw so I suppose the bundler has no way of knowing to include the latter. The code in draw does modify viewof gl so that it renders, though, so you’ve got to indlude draw to see viewof gl.
I suppose the idea is to be able to continually modify viewof gl, without re-rendering the whole thing. I’ve seen similar sorts of things when working with X3Dom.
Exactly. And that’s because of side-effects: the draw cell is mutating the WebGL context created by the viewof gl cell.
In general, we try to avoid side-effects in Observable: the value of a cell should only depend on the other cells it references, and cells shouldn’t mutate values defined by other cells (with the exception of the mutable operator).
But certain web APIs, including WebGL, are inherently mutable APIs: the only way to draw to a WebGL context is to call methods that change the state of the context and the contents of the buffers etc.
For side-effects to work when importing or embedding, the side-effect cells must be named (as draw is here) and embedded for them to run.