CrashLog panicString
Discuss spatial computing on Apple platforms and how to design and build an entirely new universe of apps and games for Apple Vision Pro.
Post
Replies
Boosts
Views
Activity
I have recently developed an interest in the shader effects commonly found in Apple's UI and have been studying them. Additionally, as I own a Vision Pro, I have a strong desire to understand LowLevelMesh and am currently analyzing the sample code after watching the related session.
The part where I am completely stuck and unable to understand is the initializer section of CurveExtruder.
/// Initializes the `CurveExtruder` with the shape to sweep along the curve.
///
/// - Parameters:
/// - shape: The 2D shape to sweep along the curve.
init(shape: [SIMD2<Float>]) {
self.shape = shape
// Compute topology //
// Triangle fan lists each vertex in `shape` once for each ring, except for vertex `0` of `shape` which
// is listed twice. Plus one extra index for the end-index (0xFFFFFFFF).
let indexCountPerFan = 2 * (shape.count + 1) + 1
var topology: [UInt32] = []
topology.reserveCapacity(indexCountPerFan)
// Build triangle fan.
for vertexIndex in shape.indices.reversed() {
topology.append(UInt32(vertexIndex))
topology.append(UInt32(shape.count + vertexIndex))
}
// Wrap around to the first vertex.
topology.append(UInt32(shape.count - 1))
topology.append(UInt32(2 * shape.count - 1))
// Add end-index.
topology.append(UInt32.max)
assert(topology.count == indexCountPerFan)
I have tried to understand why the capacity reserved for the topology array is 2 * (shape.count + 1) + 1, but I am struggling to figure it out.
I do not understand the principle behind the order in which vertexIndex is added to the topology.
The confusion is even greater because, while the comment mentions trianglefan, the actual creation of the LowLevelMesh.Part object uses the topology: .triangleStrip argument. (Did I misunderstand? I know that the topology option includes triangle, but this uses duplicated vertices.)
I am feeling very stuck. It's hard to find answers even through search options or LLMs. Maybe this requires specialized knowledge in computer graphics, which makes me feel embarrassed to ask.
However, personally, I have tried various directions without external help but still cannot find a clear path, so I am desperately seeking assistance!
P.S. As Korean is my primary language, I apologize in advance if there are any awkward or rude expressions.
I have an Entity exported from Blender, after loaded from RealityView, the "Body" and "Mesh" Entity have no ModelComponent, but they have Material Bindings reference, how can I update their materials?
I am using the Xcode visionOS debugging tool to visualize the bounds of all the containers, but it shows my Entity is inside the Volume. Then why does it get clipped? Is there something wrong with the debugger, or am I missing something?
import SwiftUI
@main
struct RealityViewAttachmentApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.volumetric)
.defaultSize(Size3D(width: 1, height: 1, depth: 1), in: .meters)
}
}
import SwiftUI
import RealityKit
import RealityKitContent
struct ContentView: View {
var body: some View {
RealityView { content, attachments in
if let earth = try? await Entity(named: "Scene", in: realityKitContentBundle) {
content.add(earth)
if let earthAttachment = attachments.entity(for: "earth_label") {
earthAttachment.position = [0, -0.15, 0]
earth.addChild(earthAttachment)
}
if let textAttachment = attachments.entity(for: "text_label") {
textAttachment.position = [-0.5, 0, 0]
earth.addChild(textAttachment)
}
}
} attachments: {
Attachment(id: "earth_label") {
Text("Earth")
}
Attachment(id: "text_label") {
VStack {
Text("This is just an example")
.font(.title)
.padding(.bottom, 20)
Text("This is just some random content")
.font(.caption)
}
.frame(minWidth: 100, maxWidth: 300, minHeight: 100, maxHeight: 300)
.glassBackgroundEffect()
}
}
}
}
My app has a window and a volume. I am trying to display the volume on the right side of the window. I know .defaultWindowPlacement can achieve that, but I want more control over the exact position of my volume in relation to my window. I need the volume to move as I move the window so that it always stays in the same position relative to the window. I think I need a way to track the positions of both the window and the volume. If this can be achieved without immersive space, it would be great. If not, how do I do that in immersive space?
Current code:
import SwiftUI
@main
struct tiktokForSpacialModelingApp: App {
@State private var appModel: AppModel = AppModel()
var body: some Scene {
WindowGroup(id: appModel.launchWindowID) {
LaunchWindow()
.environment(appModel)
}
.windowResizability(.contentSize)
WindowGroup(id: appModel.mainViewWindowID) {
MainView()
.frame(minWidth: 500, maxWidth: 600, minHeight: 1200, maxHeight: 1440)
.environment(appModel)
}
.windowResizability(.contentSize)
WindowGroup(id: appModel.postVolumeID) {
let initialSize = Size3D(width: 900, height: 500, depth: 900)
PostVolume()
.frame(minWidth: initialSize.width, maxWidth: initialSize.width * 4, minHeight: initialSize.height, maxHeight: initialSize.height * 4)
.frame(minDepth: initialSize.depth, maxDepth: initialSize.depth * 4)
}
.windowStyle(.volumetric)
.windowResizability(.contentSize)
.defaultWindowPlacement { content, context in
// Get WindowProxy from context based on id
if let mainViewWindow = context.windows.first(where: { $0.id == appModel.mainViewWindowID }) {
return WindowPlacement(.trailing(mainViewWindow))
} else {
return WindowPlacement()
}
}
ImmersiveSpace(id: appModel.immersiveSpaceID) {
ImmersiveView()
.onAppear {
appModel.immersiveSpaceState = .open
}
.onDisappear {
appModel.immersiveSpaceState = .closed
}
}
.immersionStyle(selection: .constant(.progressive), in: .progressive)
}
}
I am trying to add joints via code in my visionOS app. My scenario requires me to combine models from Reality Composer Pro with entities and components from code to generate the dynamic result.
I am using the latest visionOS beta and Xcode versions and there is no documentation about joints. I tried to add them via the available API but regardless of how I combine pins, joints and various component, my entities will not get restricted or stay fixated like they are when they are in a child/parent relationship.
I am using RealityKit and RealityView in mixed mode. I also searched the whole internet for related information without finding anything.
Any insights or pointers appreciated!
Hello,
I have an iOS app that is using SwiftUI but the gesture code is written using UIGestureRecognizer. When I run this app on visionOS using the "Designed for iPad" destination and try to use any of my gestures I see this warning in the console:
Trying to convert coordinates between views that are in different UIWindows, which isn't supported. Use convertPoint:fromCoordinateSpace: instead.
But I don't see any visible problems with the gestures.
I see this warning printed out after the gesture takes place but before any of our gesture methods get kicked off. So now I am wondering if this is something we need to deal with or some internal work that needs to happen in UIKit.
Does anyone have any thoughts on this?
I have read this thread to send notification to play animations in RCP.
If I now want to pause and come back later or stop and reset the timeline, is there a way to do so?
I'm developing an augmented images app using ARKit. The images themselves are sourced online. The app is mostly done and working fine. However, I download the images the app will be tracking every time the app starts up. I'd like to avoid this by perhaps downloading the images and storing them to the device.
My concern is that as the number of images grow, the app would download too many images to the device. I'd like some thoughts on how to best approach this. For example, should I download and store some of the images in CoreData, or perhaps not store them at all?
If I attach my swiftui view via an ViewAttachmentEntity it will show the view but any ornaments defined are not showing up at all. When I use Xcode preview on the swiftui view the ornaments show up correctly. I am using visionOS beta 3 and the problem easy to reproduce.
Are ornaments on views supported if the view is displayed via an ViewAttachmentEntity?
What’s the difference between an action and an animation eg.: FromToByAnimation vs FromToByAction.
The documentation on them is pretty similar and I'm not understanding the differences exactly... : S
FromToByAnimation → https://developer.apple.com/documentation/realitykit/fromtobyanimation?changes=__2_2
FromToByAction → https://developer.apple.com/documentation/realitykit/fromtobyaction?changes=__2_2
As developer, when should we reach out to use an animation vs action ? 🤔
Hi,
I have a Spatial Video that I am trying to load in a visionOS app with PreviewApplication API
let url = URL(string: "https://mauiman.azureedge.net/videos/SpatialJourney/watermelon_cat.MOV")
let item = PreviewItem(url: url!)
_ = PreviewApplication.open(items: [item])
When I run the application, I am getting the following error. Did I miss anything?
QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x6000022edfe0> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=2 "couldn't issue sandbox extension com.apple.quicklook.readonly for '/videos/SpatialJourney/watermelon_cat.MOV': No such file or directory" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.quicklook.readonly for '/videos/SpatialJourney/watermelon_cat.MOV': No such file or directory} #PreviewItem
The screen shows up as:
Putting the spatial video locally, I get the following error:
let url = URL(fileURLWithPath: "watermelon_cat.MOV")
let item = PreviewItem(url: url)
_ = PreviewApplication.open(items: [item])
Error getting the size of file(watermelon_cat.MOV -- file:///) with error (Error Domain=NSCocoaErrorDomain Code=260 "The file “watermelon_cat.MOV” couldn’t be opened because there is no such file." UserInfo={NSURL=watermelon_cat.MOV -- file:///, NSFilePath=/watermelon_cat.MOV, NSUnderlyingError=0x600000ea1650 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}) #Generic
Any help is greatly appreciated. Thank you in advance.
I am using Model3D to display an RCP scene/model in my UI.
How can I get to the entities so I can set material properties to adjust the appearance?
I looked at interfaces for Model3D and ResolvedModel3D and could not find a way to get access to the RCP scene or RealityKit entity.
The object capture feature in Reality Composer App is only available in iOS and iPadOS at the moment, would this feature be available for visionOS in near future?
Reality Composer App Store
https://apps.apple.com/us/app/reality-composer/id1462358802
I want to use 3dmax software to generate two panoramic renderings, one for the left eye and the other for the right eye, so that I can get a realistic sense of space.
At the technical implementation level, are there relevant APIs that can control the left and right eyes to see different content?
Hello,
I am trying to create new outfits based on ar kits body tracking skeleton example - the controlled robot.
Is it just me or is this skeleton super annoying to work with? The bones all stand out like thorns and don't follow along the actual limb, which makes it impossible to automatically weight paint new meshes to the skeleton.
Changing the bones is also not possible, since this will result in a distorted body tracking.
I am an experienced modeller but I have never seen such a crazy skeleton. Even simple meshes are a pain in the bud to pair with these bones. You basically have to weight paint everything manually.
Or am I missing something?
I have looked here:
Reality View Documentation
Found this thread:
RealityView Update Closure Thread
I am not able to find documentation on how the update closure works.
I am loading attachments using reality view's attachment feature (really helpful). I want to remove them programmatically from another file. I found that @State variables can be used. But I am not able to modify them from out side of the ImmersiveView swift file. The second problem I faced was even if I update them inside the file. My debugging statements don't execute.
So exactly when does update function run. I know it get's executed at the start (twice for some reason). It also get's executed when I add a window using:
openWindow?(id: "ButtonView")
I need to use the update closure because I am also not able to get the reference to RealityViewAttachment outside the RealityView struct.
My Code(only shown the code necessary. there is other code):
@State private var pleaseRefresh = ""
@StateObject var model = HandTrackingViewModel()
var body: some View {
RealityView { content, attachments in
if let immersiveContentEntity = try? await Entity(named: "Immersive", in: realityKitContentBundle) {
content.add(immersiveContentEntity)
}
content.add(model.setupContentEntity())
content.add(entityDummy)
print("View Loaded")
} update: { content, attachments in
print("Update Closure Executed")
if (model.editWindowAdded) {
print("WINDOW ADDED")
let theattachment = attachments.entity(for: "sample")!
entityDummy.addChild(theattachment)
// more code here
}
}
attachments: {
Attachment(id: "sample") {
Button(action: {
model.canEditPos = true
model.canRotate = false
pleaseRefresh = "changed"
}) {
HStack {
Image(systemName: "pencil.and.outline")
.resizable()
.scaledToFit()
.frame(width: 32, height: 32)
Text("Edit Placement")
.font(.caption)
}
.padding(4)
}
.frame(width: 160, height: 60)
}
}
How can the update method (or the code inside it) run when I want it to?
I am new to swift. I apologize if my question seems naive.
We have an issue with Apple Roomplan - on regular bases the objects which are captured are not positioned corretly in the model which happens 50% of the cases we have - that makes the feature almost useless. Is there any idea how to solve that problem?
Just like this pic shows, how to add secondary panel out side of the main panel by using SwiftUI?
Is it possible to access the main camera feed in full frame using the Enterprise API? Image tracking in Vision OS only updates once per second, so I am considering using the Enterprise API to access the camera feed and implement it using our custom learning model. Please provide a response.