Instance Method

prepareObjects:withCompletionHandler:

Prepares the specified SceneKit objects for rendering, using a background thread.

Required.

Declaration

- (void)prepareObjects:(NSArray *)objects withCompletionHandler:(void (^)(BOOL success))completionHandler;

Parameters

objects

An array of containing one or more SCNScene, SCNNode, SCNGeometry, or SCNMaterial instances.

completionHandler

A block that SceneKit calls when object preparation fails or completes.

The block takes the following parameter:

success

YES if all content was successfully prepared for rendering; otherwise, NO.

Discussion

By default, SceneKit lazily loads resources onto the GPU for rendering. This approach uses memory and GPU bandwidth efficiently, but can lead to stutters in an otherwise smooth frame rate when you add large amounts of new content to an animated scene. To avoid such issues, use this method to prepare content for drawing before adding it to the scene. SceneKit uses a secondary thread to prepare content asynchronously.

SceneKit prepares all content associated with the objects you provide. If you provide an SCNMaterial object, SceneKit loads any texture images assigned to its material properties. If you provide an SCNGeometry object, SceneKit loads all materials attached to the geometry, as well as its vertex data. If you provide an SCNNode or SCNScene object, SceneKit loads all geometries and materials associated with the node and all its child nodes, or with the entire node hierarchy of the scene.

You can observe the progress of this operation with the NSProgress class. For details, see NSProgress.

See Also

Preloading Renderer Resources

- prepareObject:shouldAbortBlock:

Prepares a SceneKit object for rendering.

Required.