I placed 3d object to ARViewController
after 3 seconds of placing object, then I want to rotate object by 90degree
arView.scene.addAnchor(anchorEntity)
DispatchQueue.main.asyncAfter(deadline: .now() + 3){
print("after 3 sec ! ")
let radians = 90.0 * Float.pi / 180.0
anchorEntity.orientation = simd_quatf(angle: radians, axis: SIMD3(x: 0, y: 1, z: 0))
}
it works very well but the problem is that I want to smooth rotation , as you can see short video, it suddenly rotate which seem weird.
how can I do this ?
https://youtu.be/Ixk2elm-bfU
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm testing code with destination sample app
but I really don't know how to add button beside of title in playbackcontrols.
I can add button with customoverlay and customInfoViewControllers but it is not like apple tv's seat change button . how can I add button ?
reference : https://wjwickham.com/posts/refreshing-data-in-the-background-on-watchOS/
on init function ,
which mean, for every 5 min it should come to
handle function in Extension Delegate.swift
but it won't come to handle any
anything else that I should do ?
let preferredDate = Date().addingTimeInterval(60 * 5)// 5min later
preferredDate, userInfo: nil) { (error) in
WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: preferredDate, userInfo: nil) { (error: Error?) in
guard error == nil else {
print("Couldn't schedule background refresh.")
return
}
print("Scheduled next background update task for: \(preferredDate)")
}
ExtensionDelegate.swift
//
// ExtensionDelegate.swift
// Coffee Tracker WatchKit Extension
//
// Created by pedro jung on 2022/06/15.
// Copyright © 2022 Apple. All rights reserved.
//
import Foundation
import WatchKit
class ExtensionDelegate: NSObject,ObservableObject, WKExtensionDelegate {
func applicationDidFinishLaunching() {
print("applicationDidFinishLaunching")
// Perform any final initialization of your application.
}
func applicationDidBecomeActive() {
print("applicationDidBecomeActive")
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillResignActive() {
print("applicationWillResignActive")
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, etc.
}
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
for task in backgroundTasks {
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
BackgroundService.shared.updateContent()
backgroundTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
BackgroundService.shared.handleDownload(urlSessionTask)
default:
task.setTaskCompletedWithSnapshot(false)
}
}
}
}
I also check other way
after checking reply of below link
https://developer.apple.com/forums/thread/661892
but with no luck ...
import SwiftUI
import WatchKit
@main
struct CoffeeTrackerApp: App {
@Environment(\.scenePhase) var scenePhase
@WKExtensionDelegateAdaptor(ExtensionDelegate.self) var delegate
@SceneBuilder var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
}
.onChange(of: scenePhase) { phase in
switch phase {
case .active:
print("\(#function) REPORTS - App change of scenePhase to ACTIVE")
case .inactive:
print("\(#function) REPORTS - App change of scenePhase Inactive")
case .background:
let preferredDate = Date().addingTimeInterval(60 * 1)// One hour later
// delegate.shared().scheduleBackgroundRefresh(withPreferredDate: preferredDate, userInfo: nil) { (error) in
WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: preferredDate, userInfo: nil) { (error: Error?) in
guard error == nil else {
print("Couldn't schedule background refresh.")
return
}
print("Scheduled next background update task for: \(preferredDate)")
}
delegate.test()
default:
print("\(#function) REPORTS - App change of scenePhase Default")
}
}
}
}
}
there's position which is simd3
and there 's anchorEntity.
I want to get distance between two.
how I did is
var distance = distance(position, ( self.modelentity.position(relativeTo:nil) )
var distance = distance(position, ( self.modelentity.position )
but both failed because it seems calculating distance between world origin anchor
not distance between position to self.modelentity.
how can I calculate distance ?