replate-camera 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,8 +14,8 @@ RCT_EXPORT_VIEW_PROPERTY(color, NSString)
|
|
|
14
14
|
@interface RCT_EXTERN_MODULE(ReplateCameraController, NSObject)
|
|
15
15
|
|
|
16
16
|
RCT_EXTERN_METHOD(takePhoto:(BOOL*)unlimited
|
|
17
|
-
|
|
18
|
-
rejecter:(RCTPromiseRejectBlock)
|
|
17
|
+
resolver:(RCTPromiseResolveBlock)resolver
|
|
18
|
+
rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
19
19
|
|
|
20
20
|
RCT_EXTERN_METHOD(getPhotosCount:(RCTPromiseResolveBlock*)resolve
|
|
21
21
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -181,11 +181,6 @@ class ReplateCameraView : UIView, ARSessionDelegate {
|
|
|
181
181
|
// guard !ReplateCameraView.arView.canBecomeFocused else {
|
|
182
182
|
// return
|
|
183
183
|
// }
|
|
184
|
-
let callback = ReplateCameraController.anchorSetCallback
|
|
185
|
-
if (callback != nil){
|
|
186
|
-
callback!([])
|
|
187
|
-
ReplateCameraController.anchorSetCallback = nil
|
|
188
|
-
}
|
|
189
184
|
let tapLocation: CGPoint = recognizer.location(in: ReplateCameraView.arView)
|
|
190
185
|
let estimatedPlane: ARRaycastQuery.Target = .estimatedPlane
|
|
191
186
|
let alignment: ARRaycastQuery.TargetAlignment = .horizontal
|
|
@@ -207,8 +202,10 @@ class ReplateCameraView : UIView, ARSessionDelegate {
|
|
|
207
202
|
ReplateCameraView.initialCameraAngle = ReplateCameraController.calculateAngle(cameraPosition, anchorPosition)
|
|
208
203
|
}else{}
|
|
209
204
|
print("ANCHOR FOUND\n", anchor.transform)
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
let callback = ReplateCameraController.anchorSetCallback
|
|
206
|
+
if (callback != nil){
|
|
207
|
+
callback!([])
|
|
208
|
+
ReplateCameraController.anchorSetCallback = nil
|
|
212
209
|
}
|
|
213
210
|
if (ReplateCameraView.model == nil && ReplateCameraView.anchorEntity == nil){
|
|
214
211
|
ReplateCameraView.anchorEntity = anchor
|
|
@@ -416,7 +413,7 @@ class ReplateCameraController: NSObject {
|
|
|
416
413
|
}
|
|
417
414
|
|
|
418
415
|
@objc(takePhoto:resolver:rejecter:)
|
|
419
|
-
func takePhoto(_ unlimited: Bool, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) -> Void {
|
|
416
|
+
func takePhoto(_ unlimited: Bool = false, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) -> Void {
|
|
420
417
|
|
|
421
418
|
//DEVICE ORIENTATION
|
|
422
419
|
guard let anchorNode = ReplateCameraView.anchorEntity else {
|
|
@@ -464,7 +461,7 @@ class ReplateCameraController: NSObject {
|
|
|
464
461
|
print("Point 1 position: \(point1) Point 2 position: \(point2)")
|
|
465
462
|
print("Angle to first: ", angleToFirstPoint, " Angle to second: ", angleToSecondPoint)
|
|
466
463
|
print("Threshold \(dynamicThreshold)")
|
|
467
|
-
let isPointingAtFirstPoint = angleToFirstPoint < dynamicThreshold && cameraPosition.y
|
|
464
|
+
let isPointingAtFirstPoint = angleToFirstPoint < dynamicThreshold && cameraPosition.y <= anchorNode.position.y + ReplateCameraView.spheresHeight
|
|
468
465
|
let isPointingAtSecondPoint = angleToSecondPoint < dynamicThreshold && cameraPosition.y >= anchorNode.position.y + ReplateCameraView.spheresHeight
|
|
469
466
|
if (isPointingAtFirstPoint) {
|
|
470
467
|
deviceTargetInFocus = 0
|
|
@@ -592,6 +589,10 @@ class ReplateCameraController: NSObject {
|
|
|
592
589
|
print("Calculated angle \(angleForIndex)")
|
|
593
590
|
}
|
|
594
591
|
let sphereIndex = Int(floor(angleForIndex/5))
|
|
592
|
+
if(sphereIndex >= 72 || sphereIndex < 0){
|
|
593
|
+
print("WRONG SPHERE INDEX: \(sphereIndex)")
|
|
594
|
+
return false
|
|
595
|
+
}
|
|
595
596
|
var mesh: ModelEntity?
|
|
596
597
|
var newAngle: Bool = false
|
|
597
598
|
if(deviceTargetInFocus == 1 && !ReplateCameraView.upperSpheresSet[sphereIndex]){
|