-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
644 additions
and
1 deletion.
There are no files selected for viewing
Submodule Examples
updated
2 files
+2 −2 | demo/SnowplowObjcDemo/Podfile.lock | |
+2 −2 | demo/SnowplowSwiftCocoapodsDemo/Podfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import Foundation | ||
import RealityFoundation | ||
|
||
/** | ||
Properties for the RealityKit component entity. | ||
Entity schema: `iglu:com.apple.arkit/component/jsonschema/1-0-0` | ||
*/ | ||
@objc(SPComponentEntity) | ||
public class ComponentEntity: NSObject { | ||
|
||
/// A globally unique ID for a component. | ||
public var id: String | ||
/// Type of the component, e.g. "PointLightComponent". | ||
public var type: String | ||
/// Textual description of the component. | ||
public var componentDescription: String? | ||
|
||
internal var entity: SelfDescribingJson { | ||
var data: [String : Any] = [ | ||
"id": id, | ||
"type": type | ||
] | ||
if let componentDescription = componentDescription { data["description"] = componentDescription } | ||
|
||
return SelfDescribingJson(schema: VisionOsSchemata.component, andData: data) | ||
} | ||
|
||
/// - Parameter id: A globally unique ID for a component. | ||
/// - Parameter type: Type of the component, e.g. "PointLightComponent". | ||
/// - Parameter componentDescription: Textual description of the component. | ||
@objc | ||
init( | ||
id: String, | ||
type: String, | ||
componentDescription: String? = nil | ||
) { | ||
self.id = id | ||
self.type = type | ||
self.componentDescription = componentDescription | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import Foundation | ||
|
||
/** | ||
Properties for the VisionOS immersive space entity. | ||
Entity schema: `iglu:com.apple.swiftui/immersive_space/jsonschema/1-0-0` | ||
*/ | ||
@objc(SPImmersiveSpaceEntity) | ||
public class ImmersiveSpaceEntity: NSObject { | ||
|
||
/// Randomly generated ID for the view of the immersive space by the tracker. | ||
public var id: String | ||
/// The identifier of the immersive space to present. | ||
public var immersiveSpaceId: String? | ||
/// The style of an immersive space. | ||
public var immersionStyle: ImmersionStyle | ||
/// Preferred visibility of the user's upper limbs, while an immersive space scene is presented. | ||
public var upperLimbVisibility: UpperLimbVisibility | ||
|
||
internal var entity: SelfDescribingJson { | ||
var data: [String : Any] = [ | ||
"id": id | ||
] | ||
if let immersiveSpaceId = immersiveSpaceId { data["immersive_space_id"] = immersiveSpaceId } | ||
data["immersion_style"] = immersionStyle.value | ||
data["upper_limb_visibility"] = upperLimbVisibility.value | ||
|
||
return SelfDescribingJson(schema: VisionOsSchemata.immersiveSpace, andData: data) | ||
} | ||
|
||
/// - Parameter id: Randomly generated ID for the view of the immersive space by the tracker. | ||
/// - Parameter immersiveSpaceId: A localized string key to use for the window's title in system menus and in the window's title bar. | ||
/// - Parameter immersionStyle: A specification for the appearance and interaction of a window. | ||
/// - Parameter upperLimbVisibility: A specification for the appearance and interaction of a window. | ||
@objc | ||
public init( | ||
id: String, | ||
immersiveSpaceId: String? = nil, | ||
immersionStyle: ImmersionStyle, | ||
upperLimbVisibility: UpperLimbVisibility | ||
) { | ||
self.id = id | ||
self.immersiveSpaceId = immersiveSpaceId | ||
self.immersionStyle = immersionStyle | ||
self.upperLimbVisibility = upperLimbVisibility | ||
} | ||
} | ||
|
||
// MARK: - ImmersionStyle | ||
|
||
/// The style of a VisionOS immersive space. | ||
@objc(SPImmersionStyle) | ||
public enum ImmersionStyle: Int { | ||
/// Default immersion style. | ||
case automatic | ||
/// Displays unbounded content that obscures pass-through video. | ||
case full | ||
/// Displays unbounded content intermixed with other app content. | ||
case mixed | ||
/// Content displays with no clipping boundaries applied. | ||
case progressive | ||
} | ||
|
||
extension ImmersionStyle { | ||
var value: String { | ||
switch self { | ||
case .automatic: | ||
return "automatic" | ||
case .full: | ||
return "full" | ||
case .mixed: | ||
return "mixed" | ||
case .progressive: | ||
return "progressive" | ||
} | ||
} | ||
} | ||
|
||
// MARK: - UpperLimbVisibility | ||
|
||
/// The visibility of the user's upper limbs in a VisionOS immersive space. | ||
@objc(SPUpperLimbVisibility) | ||
public enum UpperLimbVisibility: Int { | ||
/// Limbs may be visible or hidden depending on the policies of the component accepting the visibility configuration. | ||
case automatic | ||
/// Limbs may be visible. | ||
case visible | ||
/// Limbs may be hidden. | ||
case hidden | ||
} | ||
|
||
extension UpperLimbVisibility { | ||
var value: String { | ||
switch self { | ||
case .automatic: | ||
return "automatic" | ||
case .visible: | ||
return "visible" | ||
case .hidden: | ||
return "hidden" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import Foundation | ||
|
||
/** | ||
Properties for the Snowplow entity that represents a RealityKit Entity. | ||
Entity schema: `iglu:com.apple.realitykit/entity/jsonschema/1-0-0` | ||
*/ | ||
@objc(SPRealityKitEntity) | ||
public class RealityKitEntity: NSObject { | ||
|
||
// /// Randomly generated ID for the view of the immersive space by the tracker. | ||
// public var id: String | ||
// /// The identifier of the immersive space to present. | ||
// public var immersiveSpaceId: String? | ||
// /// The style of an immersive space. | ||
// public var immersionStyle: ImmersionStyle | ||
// /// Preferred visibility of the user's upper limbs, while an immersive space scene is presented. | ||
// public var upperLimbVisibility: UpperLimbVisibility | ||
// | ||
// internal var entity: SelfDescribingJson { | ||
// var data: [String : Any] = [ | ||
// "id": id | ||
// ] | ||
// if let immersiveSpaceId = immersiveSpaceId { data["immersive_space_id"] = immersiveSpaceId } | ||
// data["immersion_style"] = immersionStyle.value | ||
// data["upper_limb_visibility"] = upperLimbVisibility.value | ||
// | ||
// return SelfDescribingJson(schema: VisionOsSchemata.immersiveSpace, andData: data) | ||
// } | ||
// | ||
// /// - Parameter id: Randomly generated ID for the view of the immersive space by the tracker. | ||
// /// - Parameter immersiveSpaceId: A localized string key to use for the window's title in system menus and in the window's title bar. | ||
// /// - Parameter immersionStyle: A specification for the appearance and interaction of a window. | ||
// /// - Parameter upperLimbVisibility: A specification for the appearance and interaction of a window. | ||
// @objc | ||
// public init( | ||
// id: String, | ||
// immersiveSpaceId: String? = nil, | ||
// immersionStyle: ImmersionStyle, | ||
// upperLimbVisibility: UpperLimbVisibility | ||
// ) { | ||
// self.id = id | ||
// self.immersiveSpaceId = immersiveSpaceId | ||
// self.immersionStyle = immersionStyle | ||
// self.upperLimbVisibility = upperLimbVisibility | ||
// } | ||
} |
119 changes: 119 additions & 0 deletions
119
Sources/Snowplow/VisionOS/Entities/TrackableAnchorEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import Foundation | ||
import ARKit | ||
|
||
/** | ||
Properties for the ARKit trackable anchor entity. | ||
Entity schema: `iglu:com.apple.arkit/trackable_anchor/jsonschema/1-0-0` | ||
*/ | ||
@objc(SPTrackableAnchorEntity) | ||
public class TrackableAnchorEntity: NSObject { | ||
|
||
/// A globally unique ID for a device anchor. | ||
public var id: String | ||
/// Type of the anchor. | ||
public var type: TrackableAnchorType? | ||
/// Textual description of the anchor. | ||
public var anchorDescription: String? | ||
/// Whether ARKit is tracking the anchor. | ||
public var isTracked: Bool | ||
/// The reference image that this image anchor tracks. | ||
public var referenceImage: ARReferenceImage? | ||
|
||
internal var entity: SelfDescribingJson { | ||
var data: [String : Any] = [ | ||
"id": id | ||
] | ||
if let type = type { data["type"] = type } | ||
if let anchorDescription = anchorDescription { data["description"] = anchorDescription } | ||
data["is_tracked"] = isTracked | ||
if let referenceImage = referenceImage { | ||
var imageData: [String : Any] = [ | ||
"physical_size": "\(referenceImage.physicalSize.width)x\(referenceImage.physicalSize.height)", | ||
"description": referenceImage.description | ||
] | ||
if let name = referenceImage.name { data["name"] = name } | ||
data["reference_image"] = imageData | ||
} | ||
|
||
return SelfDescribingJson(schema: VisionOsSchemata.trackableAnchor, andData: data) | ||
} | ||
|
||
/// - Parameter id: A globally unique ID for a device anchor. | ||
/// - Parameter type: Type of the anchor. | ||
/// - Parameter anchorDescription: Textual description of the anchor. | ||
/// - Parameter isTracked: Whether ARKit is tracking the anchor. | ||
/// - Parameter referenceImage: The reference image that this image anchor tracks. | ||
public init( | ||
id: String, | ||
type: TrackableAnchorType? = nil, | ||
anchorDescription: String? = nil, | ||
isTracked: Bool, | ||
referenceImage: ARReferenceImage? = nil | ||
) { | ||
self.id = id | ||
self.type = type | ||
self.anchorDescription = anchorDescription | ||
self.isTracked = isTracked | ||
self.referenceImage = referenceImage | ||
} | ||
|
||
/// - Parameter id: A globally unique ID for a device anchor. | ||
/// - Parameter anchorDescription: Textual description of the anchor. | ||
/// - Parameter isTracked: Whether ARKit is tracking the anchor. | ||
/// - Parameter referenceImage: The reference image that this image anchor tracks. | ||
@objc | ||
public init( | ||
id: String, | ||
anchorDescription: String? = nil, | ||
isTracked: Bool, | ||
referenceImage: ARReferenceImage? = nil | ||
) { | ||
self.id = id | ||
self.anchorDescription = anchorDescription | ||
self.isTracked = isTracked | ||
self.referenceImage = referenceImage | ||
} | ||
} | ||
|
||
// MARK: - TrackableAnchorType | ||
|
||
/// The visibility of the user's upper limbs in a VisionOS immersive space. | ||
@objc(SPTrackableAnchorType) | ||
public enum TrackableAnchorType: Int { | ||
/// TODO. | ||
case device | ||
/// TODO. | ||
case world | ||
/// TODO. | ||
case hand | ||
/// TODO. | ||
case image | ||
} | ||
|
||
extension TrackableAnchorType { | ||
var value: String { | ||
switch self { | ||
case .device: | ||
return "device" | ||
case .world: | ||
return "world" | ||
case .hand: | ||
return "hand" | ||
case .image: | ||
return "image" | ||
} | ||
} | ||
} |
Oops, something went wrong.