zoukankan      html  css  js  c++  java
  • iOS开发之SceneKit框架--SCNView.h

    1、SCNView

      在macOS中,SCNView是NSView的子类,在iOS和tvOS中,SCNView是UIView的子类。SCNView用于显示SceneKit的3D场景,而需要设置场景的相关内容和属性需要通过SCNScene。SCNView需要遵循SCNSceneRenderer协议和SCNTechniqueSupport协议。

    2、相关API简介

    • 初始化方法  
    - (instancetype)initWithFrame:(CGRect)frame options:(nullable NSDictionary<NSString *, id> *)options;
    • 设置SCNScene场景
    @property(nonatomic, retain, nullable) SCNScene *scene;
    • 对视图进行配置
    //视图在什么时候重绘
    //当YES时,视图在显示链接帧速率上继续重绘。
    //当设NO时,该视图将只在某些改变或在接收器场景中动画时重新绘制。默认为NO。
    @property(nonatomic, assign) BOOL rendersContinuously;
    //设置动画帧速率 @property(nonatomic) NSInteger preferredFramesPerSecond API_AVAILABLE(macos(10.12));
    //设置抗锯齿模式me局 @property(nonatomic) SCNAntialiasingMode antialiasingMode API_AVAILABLE(macos(10.10));
    • 相机管理控制
    //允许操纵相机,用户可以改变视角的位置和方向
    @property(nonatomic) BOOL allowsCameraControl;
    
    //allowsCameraControl为YES时 获取当前相机的相关配置(只读属性)
    @property(nonatomic, readonly) id <SCNCameraControlConfiguration> cameraControlConfiguration API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    
    //allowsCameraControl为YES时 获取默认相机控制器
    @property(nonnull, nonatomic, readonly) SCNCameraController* defaultCameraController API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    • 在视图的场景中播放动作和动画
    //恢复播放视图的场景。
    - (IBAction)play:(nullable id)sender;
    
    //暂停视图场景的播放。
    - (IBAction)pause:(nullable id)sender;
    
    //停止回放视图的场景,并将场景时间重置到其开始时间
    - (IBAction)stop:(nullable id)sender;
    • 其它方法
    //指定与接收器相关的EAGL上下文。
    //如果当前API为金属,则此属性返回零,并没有影响。
    @property(nonatomic, retain, nullable) EAGLContext *eaglContext;
    
    //截屏
    - (UIImage *)snapshot API_AVAILABLE(macos(10.10));
    •  相关枚举和结构体
    #if defined(SWIFT_SDK_OVERLAY2_SCENEKIT_EPOCH) && SWIFT_SDK_OVERLAY2_SCENEKIT_EPOCH >= 3
    typedef NSString * SCNViewOption NS_STRING_ENUM;
    #else
    typedef NSString * SCNViewOption;
    #endif
    
    //SCNRenderingAPI
    FOUNDATION_EXTERN SCNViewOption const SCNPreferredRenderingAPIKey API_AVAILABLE(macos(10.11), ios(9.0)) __WATCHOS_UNAVAILABLE;
    
    //The value is directly a id <MTLDevice>. 金属
    FOUNDATION_EXTERN SCNViewOption const SCNPreferredDeviceKey API_AVAILABLE(macos(10.11), ios(9.0));
    
    //The value is a NSNumber wrapping a BOOL. Defaults to NO. 非金属
    FOUNDATION_EXTERN SCNViewOption const SCNPreferLowPowerDeviceKey API_AVAILABLE(macos(10.11), ios(9.0));
    
    #define SCNViewOptionPreferredRenderingAPI SCNPreferredRenderingAPIKey
    #define SCNViewOptionPreferredDevice       SCNPreferredDeviceKey
    #define SCNViewOptionPreferLowPowerDevice  SCNPreferLowPowerDeviceKey
    
    //相机控制器相关信息
    API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
    @protocol SCNCameraControlConfiguration <NSObject>
    @property(nonatomic, assign) BOOL autoSwitchToFreeCamera;
    @property(nonatomic, assign) BOOL allowsTranslation;
    @property(nonatomic, assign) CGFloat flyModeVelocity; // in m/s
    @property(nonatomic, assign) CGFloat panSensitivity;
    @property(nonatomic, assign) CGFloat truckSensitivity;
    @property(nonatomic, assign) CGFloat rotationSensitivity;
    @end
  • 相关阅读:
    心灵絮语(一)
    JavaScript基础之对象
    asp.net多线程(收藏)
    详解:数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名
    凡事求个合理
    坐班一族快速消除疲劳七妙招
    电脑前保健攻略
    《孔子》都曰了些啥?
    幸福的来源不是财富的增长,而是欲望的降低
    [转]从一个男人关注的事情上 可以看出他的修养和抱负
  • 原文地址:https://www.cnblogs.com/xianfeng-zhang/p/8967544.html
Copyright © 2011-2022 走看看