Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adjustment of a LocationAnnotationNode's Y screen coordinate. #230

Merged
merged 6 commits into from
Oct 11, 2019
Merged
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
14 changes: 8 additions & 6 deletions Sources/ARKit-CoreLocation/Nodes/LocationAnnotationNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ open class LocationAnnotationNode: LocationNode {
/// Subnodes and adjustments should be applied to this subnode
/// Required to allow scaling at the same time as having a 2D 'billboard' appearance
public let annotationNode: AnnotationNode

/// Parameter to raise or lower the label's rendering position relative to the node's actual project location.
/// The default value of 1.1 places the label at a pleasing height above the node.
/// To draw the label exactly on the true location, use a value of 0. To draw it below the true location,
/// use a negative value.
public var annotationHeightAdjustmentFactor = 1.1

public init(location: CLLocation?, image: UIImage) {
let plane = SCNPlane(width: image.size.width / 100, height: image.size.height / 100)
plane.firstMaterial?.diffuse.contents = image
Expand Down Expand Up @@ -109,11 +114,8 @@ open class LocationAnnotationNode: LocationNode {
}
}

// Adjust the pivot in the Y axis so the label will show above the actual node location.
// The actual adjustment should probably be a parameter or property of some sort instead
// of a magic "-1.1". Some applications want the label drawn exactly in place, and some
// might even want to use a positive pivot, to draw below its true location.
self.pivot = SCNMatrix4MakeTranslation(0, -1.1 * scale, 0)
// Translate the pivot's Y coordinate so the label will show above or below the actual node location.
self.pivot = SCNMatrix4MakeTranslation(0, Float(-1 * annotationHeightAdjustmentFactor) * scale, 0)

SCNTransaction.commit()

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog
- 1.2.2
- [PR #230 - Expose an adjustment factor for label annotation height](https://github.com/ProjectDent/ARKit-CoreLocation/pull/230)
- [PR #225 - Expose SceneLocationView.locationOfLocationNode ](https://github.com/ProjectDent/ARKit-CoreLocation/pull/225)
- [PR #222 - Trigger viewWillDisappear/viewWillAppear calls when app backgrounded/foregrounded](https://github.com/ProjectDent/ARKit-CoreLocation/pull/222)
- [PR #220 - Render distant nodes behind closer nodes ](https://github.com/ProjectDent/ARKit-CoreLocation/pull/220)
Expand Down