Skip to content
This repository was archived by the owner on Jul 3, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1
5.0
2 changes: 1 addition & 1 deletion MetalScope.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MetalScope'
s.version = '0.16.0'
s.version = '0.19.0'
s.summary = 'Metal-backed 360° panorama view for iOS'

s.homepage = 'https://github.com/ejeinc/MetalScope'
Expand Down
17 changes: 12 additions & 5 deletions MetalScope.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,22 +258,23 @@
BFB8916F1E2E013400FA9129 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "eje Inc.";
TargetAttributes = {
BFB891771E2E013400FA9129 = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = BFB891721E2E013400FA9129 /* Build configuration list for PBXProject "MetalScope" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = BFB8916E1E2E013400FA9129;
productRefGroup = BFB891791E2E013400FA9129 /* Products */;
Expand Down Expand Up @@ -355,13 +356,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -395,6 +398,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -414,13 +418,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -446,6 +452,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -471,7 +478,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -492,7 +499,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.eje-c.MetalScope";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MetalScope

![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat) ![CocoaPods compatible](https://img.shields.io/cocoapods/v/MetalScope.svg) ![Swift 3.0.x](https://img.shields.io/badge/Swift-3.1.x-orange.svg)
![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat) ![CocoaPods compatible](https://img.shields.io/cocoapods/v/MetalScope.svg) ![Swift 5.0.x](https://img.shields.io/badge/Swift-5.0.x-orange.svg)

Metal-backed 360° panorama view for iOS.

Expand All @@ -12,7 +12,7 @@ Metal-backed 360° panorama view for iOS.
| :arrow_forward: | Direct access to AVPlayer for video control
| :point_up_2: | Smooth touch rotation and re-centering
| :sunrise_over_mountains: | Custom SCNScene presentation
| :bird: | Written in Swift 3
| :bird: | Written in Swift 5

## Usage

Expand Down
2 changes: 1 addition & 1 deletion Sources/DeviceOrientationProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension DeviceOrientationProvider {

let queue = DispatchQueue(label: "com.eje-c.MetalScope.DeviceOrientationProvider.waitingQueue")
let timer = DispatchSource.makeTimerSource(queue: queue)
timer.scheduleRepeating(deadline: .now(), interval: .milliseconds(10))
timer.schedule(deadline: .now(), repeating: .milliseconds(10))
timer.setEventHandler {
guard let _ = self.deviceOrientation(atTime: time) else {
return
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.16.0</string>
<string>0.19.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
26 changes: 19 additions & 7 deletions Sources/InterfaceOrientationUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal final class InterfaceOrientationUpdater {

UIDevice.current.beginGeneratingDeviceOrientationNotifications()

let observer = NotificationCenter.default.addObserver(forName: .UIDeviceOrientationDidChange, object: nil, queue: .main) { [weak self] _ in
let observer = NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification, object: nil, queue: .main) { [weak self] _ in
guard UIDevice.current.orientation.isValidInterfaceOrientation, self?.isTransitioning == false else {
return
}
Expand All @@ -76,21 +76,33 @@ internal final class InterfaceOrientationUpdater {
}
}

private extension UIViewAnimationCurve {
private extension UIView.AnimationCurve {
var caMediaTimingFunction: CAMediaTimingFunction {
let name: String

switch self {
case .easeIn:
name = kCAMediaTimingFunctionEaseIn
name = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
case .easeOut:
name = kCAMediaTimingFunctionEaseOut
name = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut)
case .easeInOut:
name = kCAMediaTimingFunctionEaseInEaseOut
name = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeInEaseOut)
case .linear:
name = kCAMediaTimingFunctionLinear
name = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.linear)
@unknown default:
name = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn)
}

return CAMediaTimingFunction(name: name)
return CAMediaTimingFunction(name: convertToCAMediaTimingFunctionName(name))
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromCAMediaTimingFunctionName(_ input: CAMediaTimingFunctionName) -> String {
return input.rawValue
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToCAMediaTimingFunctionName(_ input: String) -> CAMediaTimingFunctionName {
return CAMediaTimingFunctionName(rawValue: input)
}
3 changes: 1 addition & 2 deletions Sources/OrientationIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public protocol OrientationIndicatorDataSource: class {
}

public protocol OrientationIndicator {
weak var dataSource: OrientationIndicatorDataSource? { get set }

var dataSource: OrientationIndicatorDataSource? { get set }
func updateOrientation()
}

Expand Down
12 changes: 6 additions & 6 deletions Sources/PanoramaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,28 +129,28 @@ extension PanoramaView {
}
}

public func snapshot() -> UIImage {
@objc public func snapshot() -> UIImage {
return scnView.snapshot()
}

public var panGestureRecognizer: UIPanGestureRecognizer {
@objc public var panGestureRecognizer: UIPanGestureRecognizer {
return panGestureManager.gestureRecognizer
}

public func updateInterfaceOrientation() {
@objc public func updateInterfaceOrientation() {
interfaceOrientationUpdater.updateInterfaceOrientation()
}

public func updateInterfaceOrientation(with transitionCoordinator: UIViewControllerTransitionCoordinator) {
@objc public func updateInterfaceOrientation(with transitionCoordinator: UIViewControllerTransitionCoordinator) {
interfaceOrientationUpdater.updateInterfaceOrientation(with: transitionCoordinator)
}

public func setNeedsResetRotation(animated: Bool = false) {
@objc public func setNeedsResetRotation(animated: Bool = false) {
panGestureManager.stopAnimations()
orientationNode.setNeedsResetRotation(animated: animated)
}

public func setNeedsResetRotation(_ sender: Any?) {
@objc public func setNeedsResetRotation(_ sender: Any?) {
setNeedsResetRotation(animated: true)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/PlayerItemRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public final class PlayerItemRenderer {
let destinationOrigin = MTLOriginMake(0, 0, 0)

let blitCommandEncoder = commandBuffer.makeBlitCommandEncoder()
blitCommandEncoder.copy(from: sourceTexture, sourceSlice: 0, sourceLevel: 0, sourceOrigin: sourceOrigin, sourceSize: sourceSize, to: texture, destinationSlice: 0, destinationLevel: 0, destinationOrigin: destinationOrigin)
blitCommandEncoder.endEncoding()
blitCommandEncoder?.copy(from: sourceTexture, sourceSlice: 0, sourceLevel: 0, sourceOrigin: sourceOrigin, sourceSize: sourceSize, to: texture, destinationSlice: 0, destinationLevel: 0, destinationOrigin: destinationOrigin)
blitCommandEncoder?.endEncoding()
}

public func hasNewPixelBuffer(atHostTime time: TimeInterval) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion Sources/RenderLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class RenderLoop {

private lazy var displayLink: CADisplayLink = {
let link = CADisplayLink(target: self, selector: #selector(handleDisplayLink(_:)))
link.add(to: .main, forMode: .commonModes)
link.add(to: .main, forMode: RunLoop.Mode.common)
link.isPaused = true
return link
}()
Expand Down
8 changes: 4 additions & 4 deletions Sources/StereoRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ internal final class StereoRenderer {
eyeTextureDescriptor.usage = .renderTarget

eyeRenderingConfigurations = [
.left: EyeRenderingConfiguration(texture: device.makeTexture(descriptor: eyeTextureDescriptor)),
.right: EyeRenderingConfiguration(texture: device.makeTexture(descriptor: eyeTextureDescriptor))
.left: EyeRenderingConfiguration(texture: device.makeTexture(descriptor: eyeTextureDescriptor)!),
.right: EyeRenderingConfiguration(texture: device.makeTexture(descriptor: eyeTextureDescriptor)!)
]
}

Expand All @@ -75,7 +75,7 @@ internal final class StereoRenderer {
for (eye, configuration) in eyeRenderingConfigurations {
semaphore.wait()

let commandBuffer = commandQueue.makeCommandBuffer()
guard let commandBuffer = commandQueue.makeCommandBuffer()else { return}

rendererDelegateProxy.currentRenderingEye = eye

Expand All @@ -99,7 +99,7 @@ internal final class StereoRenderer {
destinationOrigin = MTLOrigin(x: outputTexture.width / 2, y: 0, z: 0)
}

let blitCommandEncoder = commandBuffer.makeBlitCommandEncoder()
guard let blitCommandEncoder = commandBuffer.makeBlitCommandEncoder() else { return}
blitCommandEncoder.copy(
from: texture,
sourceSlice: 0,
Expand Down
2 changes: 1 addition & 1 deletion Sources/StereoScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal final class StereoScene: SCNScene {

let mesh = SCNGeometry(
sources: [
SCNGeometrySource(vertices: vertices, count: vertices.count),
SCNGeometrySource(vertices: vertices),
SCNGeometrySource(texcoord: texcoord),
SCNGeometrySource(colors: colors)
],
Expand Down
2 changes: 1 addition & 1 deletion Sources/StereoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public final class StereoView: UIView, SceneLoadable {
height: Int(textureSize.height),
mipmapped: true
)
let texture = device.makeTexture(descriptor: textureDescriptor)
let texture = device.makeTexture(descriptor: textureDescriptor)!

self.init(stereoTexture: texture)

Expand Down
4 changes: 2 additions & 2 deletions Sources/StereoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SceneKit

open class StereoViewController: UIViewController, SceneLoadable {
#if (arch(arm) || arch(arm64)) && os(iOS)
open let device: MTLDevice
public let device: MTLDevice
#endif

open var scene: SCNScene? {
Expand Down Expand Up @@ -344,7 +344,7 @@ open class StereoViewController: UIViewController, SceneLoadable {
precondition(introductionViewUpdateTimer == nil)

let timer = DispatchSource.makeTimerSource(queue: .main)
timer.scheduleRepeating(deadline: .now() + delay, interval: interval)
timer.schedule(deadline: .now() + delay, repeating: interval)
timer.setEventHandler { [weak self] in
guard self?.isViewLoaded == true, let _ = self?.introductionView else {
return
Expand Down
Loading