a real-time 3D rendering engine in JavaScript
Dave Long
dave.long at bluewin.ch
Sat Feb 10 10:18:48 EST 2007
Sweet! just when I wanted a torus illustration for a Betti number
calculator.
http://en.literateprograms.org/Betti_numbers_%28Python%29
> It's not even doing backface removal because I'm too dumb to figure
> out how to do it safely with perspective;
Looking at the sign of the Z-component of the normal after perspective
(effectively 2D, ready for orthographic projection onto screen pixels)
ought to do it -- are there just some numerical issues with what you
tried? (the "topological" way to determine orientations seems to be to
take determinants, but they really eat up the flops, so all this
messing about with normals can be viewed as a design-time
partial-evaluation to reduce calculation)
A backwards-facing triangle in 3D is also a backwards-wound triangle in
2D. If it's possible to change the winding rule for canvas.fill, that
might be a cheaper method than doing the calculation in JavaScript.
> Maybe there's some way to do the Z-sort without invoking a JavaScript
> function for every pair of elements to be compared;
It should be possible to left-pad the elements with suitable elements
so that the string-based .sort() puts everything in Z-order -- but I
don't think the sort's expensive enough to bother.
> There's, like, no UI. There are some nifty solid-modeling things in
> the code that aren't obvious from the UI.
> Also, maybe it would be nice to be able to pull out that logic for use
> in some other kind of mesh-generation code, like something that graphs
> a height field or a parametric function.
If you pull that logic out, I'll try to do a 3D version of the
combinator turtle language:
http://en.literateprograms.org/Turtle_graphics_%28JavaScript%29
-Dave
More information about the Kragen-discuss
mailing list