SCNSceneRenderer
Direct Implemented:
Methods and properties common to the SCNView, SCNLayer and SCNRenderer classes.
Constructor Summary
Public Constructor | ||
public |
constructor |
Member Summary
Public Members | ||
public get |
audioEngine: AVAudioEngine SceneKit uses this audio engine to play sounds from SCNAudioPlayer objects attached to nodes in the scene. |
|
public get |
audioEnvironmentNode: AVAudioEnvironmentNode SceneKit uses this audio node to spatialize sounds from SCNAudioPlayer objects attached to nodes in the scene. |
|
public |
Required. |
|
public |
Required. |
|
public get |
colorPixelFormat: MTLPixelFormat Use this property, along with the depthPixelFormat and stencilPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. |
|
public get |
commandQueue: MTLCommandQueue Use this property to schedule additional command buffers for the Metal device to execute as part of the render cycle. |
|
public get |
In macOS, the value of this property is a Core OpenGL cglContextObj object.In iOS, the value of this property is an EAGLContext object. |
|
public get |
currentRenderCommandEncoder: MTLRenderCommandEncoder Use this render command encoder to encode additional rendering commands before or after SceneKit draws its own content.This property is valid only during the SceneKit rendering loop—that is, within one of the methods defined in the SCNSceneRendererDelegate protocol. |
|
public |
Required. |
|
public |
Required. |
|
public |
Required. |
|
public get |
depthPixelFormat: MTLPixelFormat Use this property, along with the colorPixelFormat and stencilPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. |
|
public get |
device: MTLDevice Use this property to create or look up other Metal resources that use the same device as your SceneKit renderer.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. |
|
public |
Required. |
|
public |
Required. |
|
public |
Required. |
|
public |
Required. |
|
public |
Required. |
|
public get |
You choose a graphics technology when initializing a scene renderer:When initializing a SCNView object, use the init(frame:options:) initializer and the preferredRenderingAPI key. |
|
public |
Required. |
|
public |
Required. |
|
public |
Required. |
|
public get |
stencilPixelFormat: MTLPixelFormat Use this property, along with the depthPixelFormat and colorPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. |
Method Summary
Public Methods | ||
public |
hitTest(point: CGPoint, options: Map<SCNHitTestOption, Object>): SCNHitTestResult[] A 2D point in the rendered screen coordinate space can refer to any point along a line segment in the 3D scene coordinate space. |
|
public |
isNodeInsideFrustumOf(node: SCNNode, pointOfView: SCNNode): boolean Any node containing a camera or spotlight may serve as a point of view (see the pointOfView property for details). |
|
public |
nodesInsideFrustumOf(pointOfView: SCNNode): SCNNode[] Any node containing a camera or spotlight may serve as a point of view (see the pointOfView property for details). |
|
public |
By default, SceneKit lazily loads resources onto the GPU for rendering. |
|
public |
prepareShouldAbortBlock(object: Object, block: function(): boolean): boolean By default, SceneKit lazily loads resources onto the GPU for rendering. |
|
public |
presentWithIncomingPointOfView(scene: SCNScene, transition: SKTransition, pointOfView: SCNNode, completionHandler: function(): void): void Use this method to change the scene displayed in a SceneKit view (or other renderer) with an animated transition. |
|
public |
projectPoint(point: SCNVector3): SCNVector3 The z-coordinate of the returned point describes the depth of the projected point relative to the near and far clipping planes of the renderer’s viewing frustum (defined by its pointOfView node). |
|
public |
unprojectPoint(point: SCNVector3): SCNVector3 The z-coordinate of the point parameter describes the depth at which to unproject the point relative to the near and far clipping planes of the renderer’s viewing frustum (defined by its pointOfView node). |
Public Constructors
Public Members
public get audioEngine: AVAudioEngine source
SceneKit uses this audio engine to play sounds from SCNAudioPlayer objects attached to nodes in the scene. You can use this object directly to add other sound sources not related to scene contents, or to add other sound processing nodes or mixing nodes to the audio engine. To identify the node SceneKit uses for spatializing scene sounds when connecting other nodes, use the audioEnvironmentNode property.
public get audioEnvironmentNode: AVAudioEnvironmentNode source
SceneKit uses this audio node to spatialize sounds from SCNAudioPlayer objects attached to nodes in the scene. You can use this object in conjunction with the audioEngine property to rearrange the audio graph to add other, non-spatialized audio sources or mix in audio processing effects.
public audioListener: SCNNode source
Required. The node representing the listener’s position in the scene for use with positional audio effects.
public autoenablesDefaultLighting: boolean source
Required. A Boolean value that determines whether SceneKit automatically adds lights to a scene.
public get colorPixelFormat: MTLPixelFormat source
Use this property, along with the depthPixelFormat and stencilPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. You create a SceneKit view that renders using Metal with the preferredRenderingAPI initialization option or in Interface Builder, or an SCNRenderer that uses Metal with the init(device:options:) method. For OpenGL-based scene renderers, this property’s value is always nil.
public get commandQueue: MTLCommandQueue source
Use this property to schedule additional command buffers for the Metal device to execute as part of the render cycle. For example, you can use a compute command encoder to modify the vertex data in a Metal buffer for use by a SCNGeometrySource object.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. You create a SceneKit view that renders using Metal with the preferredRenderingAPI initialization option or in Interface Builder, or an SCNRenderer that uses Metal with the init(device:options:) method. For OpenGL-based scene renderers, this property’s value is always nil.
public get context: Object source
In macOS, the value of this property is a Core OpenGL cglContextObj object.In iOS, the value of this property is an EAGLContext object.
public get currentRenderCommandEncoder: MTLRenderCommandEncoder source
Use this render command encoder to encode additional rendering commands before or after SceneKit draws its own content.This property is valid only during the SceneKit rendering loop—that is, within one of the methods defined in the SCNSceneRendererDelegate protocol. Accessing this property at any other time returns nil.
public debugOptions: SCNDebugOptions source
Required. Options for drawing overlay content in a scene that can aid debugging.
public delegate: SCNSceneRendererDelegate source
Required. A delegate object that receives messages about SceneKit’s rendering process.
public get depthPixelFormat: MTLPixelFormat source
Use this property, along with the colorPixelFormat and stencilPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. You create a SceneKit view that renders using Metal with the preferredRenderingAPI initialization option or in Interface Builder, or an SCNRenderer that uses Metal with the init(device:options:) method. For OpenGL-based scene renderers, this property’s value is always nil.
public get device: MTLDevice source
Use this property to create or look up other Metal resources that use the same device as your SceneKit renderer.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. You create a SceneKit view that renders using Metal with the preferredRenderingAPI initialization option or in Interface Builder, or an SCNRenderer that uses Metal with the init(device:options:) method. For OpenGL-based scene renderers, this property’s value is always nil.
public isJitteringEnabled: boolean source
Required. A Boolean value that determines whether SceneKit applies jittering to reduce aliasing artifacts.
public isPlaying: boolean source
Required. A Boolean value that determines whether the scene is playing.
public loops: boolean source
Required. A Boolean value that determines whether SceneKit restarts the scene time after all animations in the scene have played.
public overlaySKScene: SKScene source
Required. A Sprite Kit scene to be rendered on top of the SceneKit content.
public pointOfView: SCNNode source
Required. The node from which the scene’s contents are viewed for rendering.
public get renderingAPI: SCNRenderingAPI source
You choose a graphics technology when initializing a scene renderer:When initializing a SCNView object, use the init(frame:options:) initializer and the preferredRenderingAPI key. Alternatively, create a view in Interface Builder and use the Rendering API control in the inspector. During initialization, the view will attempt to use the preferred API, but will fall back to a different API if the preferred one is not supported on the current hardware.To create a SCNRenderer object that renders into your own OpenGL contect, use the init(context:options:) initializer. To create a renderer for use in your own Metal workflow, use the init(device:options:) initializer.The rendering technology used by a SCNLayer object is determined by Core Animation.After initializing a renderer, this property reflects the rendering technology in use.
public showsStatistics: boolean source
Required. A Boolean value that determines whether SceneKit displays rendering performance statistics in an accessory view.
public get stencilPixelFormat: MTLPixelFormat source
Use this property, along with the depthPixelFormat and colorPixelFormat properties, if you perform custom drawing with Metal (see the SCNSceneRendererDelegate and SCNNodeRendererDelegate classes) and need to create a new MTLRenderPipelineState object to change the GPU state as part of your rendering.NoteThis property is valid only for scene renderers whose renderingAPI value is metal. You create a SceneKit view that renders using Metal with the preferredRenderingAPI initialization option or in Interface Builder, or an SCNRenderer that uses Metal with the init(device:options:) method. For OpenGL-based scene renderers, this property’s value is always nil.
Public Methods
public hitTest(point: CGPoint, options: Map<SCNHitTestOption, Object>): SCNHitTestResult[] source
A 2D point in the rendered screen coordinate space can refer to any point along a line segment in the 3D scene coordinate space. Hit-testing is the process of finding elements of a scene located along this line segment. For example, you can use this method to find the geometry corresponding to a click event in a SceneKit view.
Params:
Name | Type | Attribute | Description |
point | CGPoint | ||
options | Map<SCNHitTestOption, Object> |
|
A dictionary of options affecting the search. See Hit Testing Options Keys for acceptable values. |
public isNodeInsideFrustumOf(node: SCNNode, pointOfView: SCNNode): boolean source
Any node containing a camera or spotlight may serve as a point of view (see the pointOfView property for details). Such a node defines a viewing frustum—a portion of the scene’s coordinate space, shaped like a truncated pyramid, that encloses all points visible from that point of view.Use this method to test whether a node lies within the viewing frustum defined by another node (which may or may not be the scene renderer’s current pointOfView node). For example, in a game scene containing multiple camera nodes, you could use this method to determine which camera is currently best for viewing a moving player character.Note that this method does not perform occlusion testing. That is, it returns true if the tested node lies within the specified viewing frustum regardless of whether that node’s contents are obscured by other geometry.
public nodesInsideFrustumOf(pointOfView: SCNNode): SCNNode[] source
Any node containing a camera or spotlight may serve as a point of view (see the pointOfView property for details). Such a node defines a viewing frustum—a portion of the scene’s coordinate space, shaped like a truncated pyramid, that encloses all points visible from that point of view.Use this method find all nodes whose content lies within the viewing frustum defined by another node (which may or may not be the scene renderer’s current pointOfView node).Note that this method does not perform occlusion testing. That is, the returned array includes any node that lies within the specified viewing frustum regardless of whether that node’s contents are obscured by other geometry.
Params:
Name | Type | Attribute | Description |
pointOfView | SCNNode | A node defining a point of view, as used by the pointOfView property. |
public prepare(objects: Object[], completionHandler: function(arg1: boolean): void): void source
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 Progress class. For details, see Progress.
Params:
Name | Type | Attribute | Description |
objects | Object[] | An array of containing one or more SCNScene, SCNNode, SCNGeometry, or SCNMaterial instances. |
|
completionHandler | function(arg1: boolean): void |
|
A block that SceneKit calls when object preparation fails or completes.The block takes the following parameter:successtrue if all content was successfully prepared for rendering; otherwise, false. |
Return:
void |
public prepareShouldAbortBlock(object: Object, block: function(): boolean): boolean source
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. You can call this method on a secondary thread to prepare content asynchronously. SceneKit prepares all content associated with the object parameter 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 use the block parameter to cancel preparation if content is no longer needed. For example, in a game you might use this method to preload areas of the game world the player is soon to enter, but if the player character dies before entering those areas, you can return true from the block to cancel preloading.You can observe the progress of this operation with the Progress class. For details, see Progress.
Params:
Name | Type | Attribute | Description |
object | Object | An SCNScene, SCNNode, SCNGeometry, or SCNMaterial instance. |
|
block | function(): boolean |
|
A block that SceneKit calls periodically while preparing the object. The block takes no parameters.Your block should return false to tell SceneKit to continue preparing the object, or true to cancel preparation.Pass nil for this parameter if you do not need an opportunity to cancel preparing the object. |
public presentWithIncomingPointOfView(scene: SCNScene, transition: SKTransition, pointOfView: SCNNode, completionHandler: function(): void): void source
Use this method to change the scene displayed in a SceneKit view (or other renderer) with an animated transition. For details on transition styles, see SKTransition.
Params:
Name | Type | Attribute | Description |
scene | SCNScene | The new scene to be displayed. |
|
transition | SKTransition | An object that specifies the duration and style of the animated transition. |
|
pointOfView | SCNNode |
|
The node to use as the pointOfView property when displaying the new scene. |
completionHandler | function(): void |
|
A block that SceneKit calls after the transition animation has completed.This block takes no parameters and has no return value. |
Return:
void |
public projectPoint(point: SCNVector3): SCNVector3 source
The z-coordinate of the returned point describes the depth of the projected point relative to the near and far clipping planes of the renderer’s viewing frustum (defined by its pointOfView node). Projecting a point on the near clipping plane returns a point whose z-coordinate is 0.0; projecting a point on the far clipping plane returns a point whose z-coordinate is 1.0.
Params:
Name | Type | Attribute | Description |
point | SCNVector3 | A point in the world coordinate system of the renderer’s scene. |
public unprojectPoint(point: SCNVector3): SCNVector3 source
The z-coordinate of the point parameter describes the depth at which to unproject the point relative to the near and far clipping planes of the renderer’s viewing frustum (defined by its pointOfView node). Unprojecting a point whose z-coordinate is 0.0 returns a point on the near clipping plane; unprojecting a point whose z-coordinate is 1.0 returns a point on the far clipping plane.A 2D point in the rendered screen coordinate space can refer to any point along a line segment in the 3D scene coordinate space. To test for scene contents along this line—for example, to find the geometry corresponding to the location of a click event in a view—use the hitTest(_:options:) method.
Params:
Name | Type | Attribute | Description |
point | SCNVector3 | A point in the screen-space (view, layer, or GPU viewport) coordinate system of the scene renderer. |