2008 03 12Core Animation culling problems
Unfortunately, it looks … pretty bad.
Once you setup a projection matrix and give your layers a z position, Core Animation handles your layers as 3D objects. The problem here is culling : deciding which layers are visible on screen. In 2D the problem is trivial : just check the x,y position of the layer and test that against the NSView boundaries. In 3D, take x,y,zPosition of layers and project them using the projection matrix. You then get a x,y position on screen to render the layer. Rendering works fine — but Core Animation uses the original x,y position of layers to cull them.
Mini workaround
We can somewhat offset the problem by selecting one layer and making it big enough to take up the whole view. But layers will stil be culled to the view boundary according to their original position. Download the sample and check 'fix culling', then drag the dots to an edge : you'll see them disappearing almost all at once.
Core Animation
- CocoaNav a Cocoa Class Browser using Core Animation
- Core Animation Starfield Core Animation sample using 3D layers
CoreAnimationStarfield.zip - Core Animation culling problems Don't setup a projection transform on the root layer !
- Threaded Core Animation while on the main thread, update your display with
[CATransaction commit]
CoreAnimationUpdateOnMainThread.zip - Core Animation Bindings binding Cocoa objects to
CALayer
s
Core Animation Bindings.zip - Core Animation Phantom Fade seeing ghosting ? Use two transaction to create and animate your objects
CoreAnimationPhantomFade.zip - Photoshop-like compositing with Core Animation
Blending Modes.zip
There's actually a "sphereContainer" sublayer that holds all of the floating orbs. I'm not sure what the exact effect was that you were going for, I changed this line:
To this:
And it looks a lot better. I think Core Animation is actually doing the right thing. The NSView's backing layer had the sublayerTransform applied, so the sphereContainer layer was floating out in space.