I'd like to know the location of the pivot point of a ModelEntity, is there any way to get this? Alternatively can I get it from a USDZ file?
I want to place models in a specific location and some models have the pivot in the center while others have it at the bottom. If I can detect this I can adjust accordingly and place them correctly. I don't have control over the models, alas.
Thanks,
Spiff
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm recreating the ARQuickLook controller in code. One of its behaviors is to move the model to the visible center when entering Obj mode. I've hacked the ARViewContainer of the default Xcode Augmented Reality App to demonstrate what I'm trying to do.
I think that moving the entity to 0,0,0 will generally not do the right thing because the world origin will be elsewhere. What I'm not clear on is how to specify the translation for entity.move() in the code. I'm assuming I'll need to raycast using a CGPoint describing view center to obtain the appropriate translation but I'm not sure about the details. Thanks for any help with this.
struct ARViewContainer: UIViewRepresentable {
let arView = ARView(frame: .zero)
let boxAnchor = try! Experience.loadBox()
func makeUIView(context: Context) -> ARView {
arView.scene.anchors.append(boxAnchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
arView.environment.background = .color(.white)
arView.cameraMode = .nonAR
if let entity = boxAnchor.children.first {
let translation = SIMD3<Float>(x: 0, y: 0, z: 0 )
let transform = Transform(scale: .one, rotation: simd_quatf(), translation: translation)
entity.move(to: transform, relativeTo: nil, duration: 2, timingFunction: .easeInOut)
}
}
}
}
AR Quick Look has two modes:
Object Mode: one can view a model in an empty space with a ground plane and a shadow
AR Mode: one can view the model in an SR context, within a real environment
Does the developer have access to this functionality (moving between camera and non-camera modes)? I'm really asking if the camera can be disabled and reenabled in the same session.
Thanks
I am subclassing ARView. I'm seeing the following crash on Firebase during initialization. Unfortunately I can't reproduce it locally so I don't really know what is going on. All the devices are running iOS 15. Most of the devices have < 60 MB available RAM but not all, a few have more. It doesn't smell like a memory issue, but I mention it here... has anyone seen this?
It crashes in this thread:
Crashed: com.apple.root.default-qos
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000arrow_right
0
CoreRE
re::CompoundShape::~CompoundShape() + 168
1
CoreRE
re::CompoundShape::~CompoundShape() + 148
2
CoreRE
re::CollisionShapeAssetLoader::unloadAsset(void*) + 176
3
CoreRE
re::internal::AssetBackgroundLoader::unloadAsset(re::internal::AssetLoadItem&) + 168
4
CoreRE
re::internal::AssetBackgroundLoader::runIfNeeded(re::internal::AssetLoadItem&) + 88
after starting on the main three:
com.apple.main-thread0
ARKitCore
+[ARSession setRenderType:] + 1022
2RealityKit
ARView.init(frame:cameraMode:automaticallyConfigureSession:) + 740
I am presenting a list of Items which are sections by the categoryIdentifier property. My app uses CloudKit. When I add change the categoryIdentifier for an item it is display in the correct section and other running instances of the app do the same. When restarting the app some items are grouped under an incorrect section, but the cstegoryIdentifier within the item is still as it was set. My question is what I'm doing wrong that upon restart the organization is incorrect. In case it matters, I'm setting this in the container:
container.viewContext.automaticallyMergesChangesFromParent = true
As an aside: It seems necessary to make the sectioning type optional (as is the case in the underlying entity) like this
SectionedFetchResults<String?, Item>
Though the examples don't seem to need this.
struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
@State private var isShowingItem = false
@State private var isAddingItem = false
@SectionedFetchRequest(
sectionIdentifier: \.categoryIdentifier,
sortDescriptors: [NSSortDescriptor(keyPath: \Item.name, ascending: true)],
animation: .default) private var sectionedItems: SectionedFetchResults<String?, Item>
var body: some View {
NavigationView {
List {
ForEach(sectionedItems) { section in
Section(header: Text(Category.nameForId(section.id, context: viewContext)).font(.headline)) {
ForEach(section) { item in
NavigationLink(destination: ItemInputView(item: item, category: Category.get(identifier: item.category, context: viewContext))) {
Text(item.getName())
}
}
}
}
}
.navigationTitle("Foo")
.sheet(isPresented: $isAddingItem) {
ItemInputView(item: nil, category: Category.getDefault(context: viewContext))
}
}
.navigationViewStyle(.stack)
}
}
Hi, after rotating the iPad ARCamera.trackingState transitions to .initilizing and the video freezes. The application as a whole still functions. I'm unable to extract a relevant code example as this is embedded in a larger application. I am not seeing this behavior on iPhone. Is there any possibility that this is related to layout constraints? I see some warnings when the rotation occurs. Is there anything else I might examine?
Thank you
I'm trying to render a MKPolyline on tvOS and get a runtime exception with
_validateTextureView:531: failed assertion `cannot create View from Memoryless texture.'
This same code works fine on the iPad and I'm starting to think it just doesn't work on tvOS...unless this is a beta issue.