For more 3D, see the 3D framework studio here: http://scratch.mit.edu/studios/202972 Use arrow keys and WASD to fly through the starfield. This is kinda insane, but was just me wondering how well Scratch can move through big lists - and render lotsa dots :) The answer, it seems, is fairly encouraging. Once you get to about 20000 stars it starts to look a bit silly, since there's no attempt to order the stars (but see below for a possibility...) It's based on the "3D Engine -part 3" project: http://scratch.mit.edu/projects/10096235/ which doesn't have so much optimisation trickery as this. [ See the whole 3d engine studio here: http://scratch.mit.edu/studios/202972 ] On my old Mac Mini I was getting about 2fps with 10000 stars for a slightly more optimised version of the original "3D engine -part3" project. -This one gives me nearer 4fps for 10000 stars. Only 0.35fps for 100000 stars, but I'm hoping someone out there has a machine that can manage at least 2fps... :)
The original version of this just goes through all the stars in the list (randomly positioned in a large cube) and works out where each one should appear on the screen (if at all) using the camera transformation matrix - see the original project for info. This version splits up the large cube of stars into 8x8x8 boxes. For each frame it starts by working out which boxes will be visible (at least partly) in the viewscreen, and then it only goes through the stars in those boxes instead of all of them. Note this adds considerable overhead that only becomes worthwhile after a few thousand stars, so it would be slower than the original project for a couple of thousand stars. Therefore, it skips the box checking if the star count is 2000 or less. But 10000 should be significantly better than the original project. One of the interesting ideas to add to this is a bit of ordering for the rendering - since the stars are in separate boxes, we could render the stars starting with the furthest box. This would at least mean some of the very furthest stars will be rendered before the nearest, which could help make it look a little better once the star count hits the tens of thousands...