Flash 3D makes me sad

I’ve been dabbling with Flash 10’s native 3D support. Try my engine:

Click to set the focus. Use the arrow keys to move. Touch blocks to illuminate.

I’m disappointed with two things:

1). How much time is required to create a 3D engine, even a grid-based one like mine. I’ve been wrestling this project for 4+ hours every day, for a week. I feel like I must be lagging behind, but there are ten thousand things that will go wrong when developing in 3D. The paradigm is uniquely punishing, there are always edge cases where some polygons aren’t drawn correctly. This project hasn’t been a joy.


2). Flash’s native 3D is not suited for a high-performance application like this one. It would be fine if I was only spinning a few DisplayObjects in space. However, the scene above displays up to 125 Bitmaps simultaneously. (Light all 25 bulbs (3 Bitmaps each), stand in the corner facing them, and the 25-segment walls.) 125 Bitmaps would be child’s play in OpenGL. But after you light a few blocks, Flash Player chokes pretty hard.

Here’s another version that uses a BlendMode on the lightbulbs. It looks great, but its performance is even less acceptable.

Here’s an early version that uses my own 3D computations, and the Graphics API. Also it has a limited field of view, which I widened for the latest builds. The performance is surprisingly high. I abandoned my custom 3D when I reached this point; drawing lines around each cube face was expensive, so I switched to Bitmaps, and the native 3D.

The cube faces are set to width & height of 100. However, the bitmaps are higher resolution, a 200×200 region is shown. They’re being downsampled at 100×100 before they’re rendered, not by my choice.

At runtime, I get periodic warnings like these:

Warning: 3D DisplayObject will not render. Its dimensions (8238, 1628) are too large to be drawn.

What?! How is this happening? I swear that any blocks behind the camera are being removed from the Stage. (Actually, this is difficult to verify. If I shrink the scene, Flash magically applies the 3D perspective with a weird projection, and distorts everything in Lovecraftian dimensions.) Please, Adobe, tell me that you’re not rendering the scene at 8000 pixels wide, then scaling it down to my 700×400 window, frame after frame?

Also note that you, the developer, are responsible for drawing the DisplayObjects in the correct depth order (farthest to nearest), Flash doesn’t handle it automatically. This is known as “2.5D“, and it’s wildly inconvenient.

So, I’m pretty disappointed with Flash 10’s native 3D. Even with my limited 3D experience, I dislike how it renders the scene (I’m not alone in this) and the performance is obviously sub-par. This technology will not bring 3D games to the web, it cannot.

I need to decide whether to endure its shortcomings for 4 more weeks, or if I should abandon this project altogether. There are moments when you realize you’ve outgrown something you used to love, and this may be one of mine.