curved surfaces

Skip to first unread message


Jun 8, 2010, 2:05:16 PM6/8/10
to pre3d

I find your code extremely useful! Many thanks. Couple of questions:

- Is the project active? Are there plans to extend?
- Is there a way to make curved surfaces?
- Is it possible to add a very basic example, which includes drawing
individual pixels and lines?

Thanks again, Jos


Jun 8, 2010, 5:44:18 PM6/8/10

I think the project is still active, but I more or less wrote it so
solve a very basic task and once it was done I haven't had a lot more
things I wanted to do to the core. Most things I've worked on could
be built along side it, instead of into it.

Like most low level 3d engines, pre3d works in planar surfaces. It
happens that I wrote it with quads as the basic primitives, and it
also supports triangles. The reason to support quads is mostly for
performance. If you're talking about curved surfaces, like NURBS,
you'll need to decompose them into quads or triangles.

I played around with some concepts of vector paths in 3d, but I think
there would be a lot of difficulty extending any of that to curved

pre3d backs to the <canvas> tag, it is not an entire drawing library,
it only handles the 3d aspects. If you're interested in accessing or
drawing individual pixels or 2d vector graphics, you can do this
directly on the <canvas> element. If you're interested in drawing 3d
lines, you can do this with the pre3d path support.

-- dean

> --
> You received this message because you are subscribed to the Google Groups "pre3d" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Yosef Akhtman

Jun 8, 2010, 11:14:56 PM6/8/10
I am quite a beginner in this field, so I might be saying something silly. I think your engine could form an excellent basis for plugin-free scientific visualization, in particular visualization of chemical compounds. One thing, which would be particularly valuable for that purpose is a smooth sphere primitive. To the best of my understanding, the only way to achieve smoothness at the moment is to dramatically increase the number of tessellation segments, which in my tests has a prohibitive impact on speed. Is there any better way to create a smooth sphere?

Thanks, Jos


Jun 9, 2010, 9:59:17 AM6/9/10
Yes, it especially depends on how you want the lighting. For a sphere
you would normally want per-pixel lighting with some kind of shading.
Since pre3d works on top of the <canvas> vector API, it's not doing
per-pixel rasterization, but instead per-quad/triangle, and doing a
single color fill. So the results for sphere is usually something
that looks more like a golf ball.

If you're okay with wireframe instead of lighted 3d objects, you
should be able to easily get something that looks like a globe just
using circles. I'm not sure how chemical compounds are usually
visualized, but when I think about it usually imagine 2d blue-print
style illustrations. You could try to achieve something like this
aesthetic while still allowing 3d navigation by doing it with vectors
in 3d, if that makes sense. For an example, see the slink or spiral

Hope that was helpful. If you send a link to the type of information
you're trying to visualize, I might be able to help better.

In the end, if you really do need full-blown 3d rendering with good
lighting, etc, I think you'll need to look at WebGL.

-- dean

Yosef Akhtman

Jun 9, 2010, 11:25:15 AM6/9/10
Many thanks for the very informative response. I am currently trying to do something like this for my research: 

It is basically a very simple structure, but the smooth spheres are quite important. Not sure how to make it look nice without them. I have looked into WebGL, but the support for it is still very scarce (developers and enthusiasts only, so there is no advantage over plugin-based solutions, such as flash). It will probably take time before the situation will improve. I have also looked at o3d, but this is again back to plugins. Any suggestions?

Thanks, Jos


Jun 9, 2010, 12:54:32 PM6/9/10
Hi Jos,

I don't think it will be possible to achieve that sort of look. I can
see some benefits of the "3d look" for getting a sense of depth and
placement in 3d space. Another half of me can't help but think there
could be a much cleaner and more beautiful flat
mechanical/architectural style illustration that could clearly convey
the same data.

If you did want to try to achieve something like the 3d examples
you've shown, you could get away with doing the spheres with just a 2d
overlay of circles. You'd probably have to deal with depth sorting.
That would also be something you'd have to deal with for the
illustration style also.

I'd probably just use Flash? :\

Good luck!
-- dean

Reply all
Reply to author
0 new messages