AppleSCNView - UBogun/Xojo-iosLib GitHub Wiki

Inherits from AppleView
Memory leak check: not yet done.
Status: incomplete.

In Renderer Protocol: Metal Functions and AudioEnvironmentNode missing.
Needs a custom subclass to implement OverlaySKScene as a property and presentScene method. SCNTechnique support not implemented. UICoordinateSpace and UIAppearanceContainer Protocols not yet implemented

This is an implementation of SCNView, a UIView subclass that is the basic view subclass for displaying 3D content created by SceneKit.
For easier access, you will usually want to use the iOSLibSCNView custom control.

General information

SceneKit Framework description

Xojo integration

For easier handling, the custom control iOSLibSCNView is available.

Constructor

Constructor (Frame As FoundationFramework.NSRect, dict as AppleSCNViewInitializationOptionDictionary = nil): Creates a new SCNView object.

Only pass an Initialization dictionary on a device running iOS 9.0 or later!

Properties

AbortObjectPreparation As Boolean: A helper property for use in conjunction with the PrepareObject method. Set to true if you want to cancel preparations. Don’t forget to set to False again or following preparations will be cancelled too. Works in conjunction with the standard PreparationCancelBlock.

AllowsCameraControl As Boolean: If True, the user can change the camera with gestures. Default False.

AntialiasingMode As SCNAntialiasingMode: Lets you select between different type of smoothing. Default None.

SCNAntialiasingMode Definition
None No antialiasing
Multi2x Antialiasing with 2 samples per pixel
Multi4x Antialiasing with 4 samples per pixel

AudioEngine As AppleAVAudioengine: The audio engine SceneKit uses for playing scene sounds. (read-only). Available since iOS 9.0.

AudioListener As AppleSCNNode: The node representing the listener’s position in the scene for use with positional audio effects.

AutoEnablesDefaultLighting As Boolean: If true, SceneKit automatically adds and places an omnidirectional light source when rendering scenes that contain no lights or only contain ambient lights. Default False.

Context As AppleEAGLCOntext: The OpenGL rendering context that SceneKit uses for rendering the scene. (read-only)

DebugOptions As AppleSCNDebugOptions: Options for drawing overlay content in a scene that can aid debugging. Available since iOS 9.0.

###AppleSCNDebugOptions is a helper class that basically just encompasses a UInteger and offers computed properties to change the bits. The avaialable bits are:

  • ShowPhysicsShapes
  • ShowBoundingBoxes
  • ShowLightInfluences
  • ShowLightExtents
  • ShowPhysicsFields
  • ShowWireframe
    Shared constructors for NoOptions and AllOptions are available too.

EAGLContext As AppleEAGLContext: If you use OpenGL ES for custom rendering, you can use this property to share OpenGL ES resources between the context used for rendering the scene and other OpenGL ES contexts your app uses. SceneKit automatically shares its own OpenGL ES resources between multiple SCNView instances in your app as needed.

JitteringEnabled As Boolean: Jittering is a process that SceneKit uses to improve the visual quality of a rendered scene. While the scene’s content is still, SceneKit moves the pointOfView location very slightly (by less than a pixel in projected screen space). It then composites images rendered after several such moves to create the final rendered scene, creating an antialiasing effect that smooths the edges of rendered geometry. Default False.

Loops As Boolean: Whether SceneKit restarts the scene time after all animations in the scene have played.

Playing As Boolean: Whether the scene is playing. If False (the default), SceneKit does not increment the scene time, so animations associated with the scene do not play.

PointOfView As AppleSCNNode: The node from which the scene’s contents are viewed for rendering. Usually a SCNCamera or SCNLight-Spotlight.

PreferredFramesPerSecond As Integer: SceneKit chooses an actual frame rate that is as close as possible to your preferred frame rate based on the capabilities of the screen the view is displayed on. Default 60.

RenderingAPI As SceneKitFramework.RenderingAPI: The graphics technology SceneKit uses to render the scene. (read-only). Available since iOS 9.0.

RenderingAPI Definition
Metal Use the Metal framework for SceneKit rendering. Metal provides improved graphics performance on supported devices, allows you to integrate GPU-compute tasks into a rendering workflow, and provides the same API in both iOS and OS X.
OpenGLES2 Use the OpenGL ES 2.0 API for SceneKit rendering in iOS. This option is available on all iOS devices supporting SceneKit. If you request the Metal rendering API for an SCNView object on a device that does not support Metal, SceneKit falls back to the OpenGL ES 2.0 API.

Scene As AppleSCNScene: The scene to be displayed in the view.

SceneTime As Double: The current scene time.

ShowsStatistics As Boolean: Whether SceneKit displays rendering performance statistics in an accessory view.

##Methods HitTest (aPoint As FoundationFramework.NSPoint, opt. options as AppleSCNHitTestingDictionary) As AppleArray of AppleSCNHitTestResult: Searches the renderer’s scene for objects corresponding to a point in the rendered image. If you specify no HitTestingDictionary, a standard dictionary for the view will be used.

IsNodeInsideFrustrum (Node As AppleSCNNode, PointOfView As AppleSCNNode): Returns a Boolean value indicating whether a node might be visible from a specified point of view.
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.

NodesInsideFrustrum (PointOfView As AppleSCNNode) As AppleArray of AppleNode: Returns all nodes that might be visible from a specified point of view. Available since iOS 9.0.

Pause(): Pauses playback of the view’s scene.

Play(): Resumes playback of the view’s scene.

PrepareObject (AnObject As AppleSCNObject, opt. Block As AppleBlock) As Boolean: Prepares a SceneKit object (An SCNScene, SCNNode, SCNGeometry, or SCNMaterial instance) for rendering. Returns the preparation result. If you do not define a custom block, the default PreparationCancelBlock of the class will be used. This checks the AbortObjectPreparation Property periodically and aborts preparations if it is true.

PrepareObjects (Objects As Paramarray/AppleArray of AppleSCNObject, opt. Block As AppleBlock): Prepares an array ofSceneKit objects (SCNScene, SCNNode, SCNGeometry, or SCNMaterial instances) for rendering. If you do not define a custom block, the default CompletionHandlerTemplate of the class will be used and the ObjectsPreparationEnded event will fire after completion.

ProjectPoint (aPoint As SCNVector3) As SCNVector3: Projects a point from the 3D world coordinate system of the scene to the 2D pixel coordinate system of the renderer. 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.

Snapshot() As AppleImage: Renders the view’s scene into a new image object.

Stop(): Stops playback of the view’s scene and resets the scene time to its start time.

UnprojectPoint (aPoint As SCNVector3) As SCNVector3: Unprojects a point from the 2D pixel coordinate system of the renderer to the 3D world coordinate system of the scene.

Shared Methods

Appearance() As AppleSCNView: Returns the appearance proxy for the AppleSCNView class.

Appearance (Collection As AppleTraitCollection) As AppleSCNView: Returns the appearance proxy for the AppleSCNView class that has the passed trait collection.